Closed sbj42 closed 7 years ago
It's not technically a bug, because the user cannot change the position of the plane in the demo?
In any case you're right and it should be using the correct bounds, if someone wants to reuse the code. Wanna submit a PR?
You're right. In fact that's how I spotted this, I was adapting it for my own project.
Yes, I'll submit a pull request. I found some other things along the way that I think would be worth having in the demo, so I'll include those as well. For instance, The applied force for each shape can be multiplied by body.mass / body.shapes.length
so that it works better for bodies with different masses and compound bodies.
Pull request #263 submitted. I decided not to include the body.mass
multiplier because that's a slippery slope leading to questions of body density and I didn't think that was necessarily important for the demo.
In the buoyancy demo, if I put the "water" plane at a different Y position, the objects float at a different depth. Try setting
plane.position[1]
to -1 or 1, and see where the shapes come to rest.I believe this is because of a bug on line 89:
This is meant to compute the height of the portion of the shape's bounding box that is "underwater". I think that
0
should actually beplanePosition[1]
, so like this: