Only render compound bounds

This commit is contained in:
Richard Davey 2020-01-09 00:43:38 +00:00
parent 312f4dab10
commit 4d0618232b

View file

@ -1569,6 +1569,8 @@ var World = new Class({
/**
* Renders the bounds of an array of Bodies to the given Graphics instance.
*
* If the body is a compound body, it will render the bounds for the parent compound.
*
* The debug renderer calls this method if the `showBounds` config value is set.
*
* This method is used internally by the Matter Debug Renderer, but is also exposed publically should
@ -1596,6 +1598,19 @@ var World = new Class({
continue;
}
var bounds = body.bounds;
if (bounds)
{
graphics.strokeRect(
bounds.min.x,
bounds.min.y,
bounds.max.x - bounds.min.x,
bounds.max.y - bounds.min.y
);
}
else
{
var parts = body.parts;
for (var j = parts.length > 1 ? 1 : 0; j < parts.length; j++)
@ -1610,6 +1625,7 @@ var World = new Class({
);
}
}
}
return this;
},