the-butterfly-effect / tbe

The Butterfly Effect, a realistic physics simulation game
http://the-butterfly-effect.org
GNU General Public License v2.0
96 stars 13 forks source link

Bad collision polygons of some objects #348

Open Wuzzy2 opened 4 years ago

Wuzzy2 commented 4 years ago

Some objects have bad collision polygons that need improvement. The points of collision polygons should be as close to the image as possible. Some simplifications are acceptable, but what is unacceptable is when a point in the polygon is outside or inside the image.

Wuzzy2 commented 4 years ago
Wuzzy2 commented 4 years ago
kaa-ching commented 4 years ago

First of all, keep in mind that all polygons have to be convex. That already makes a single form for a bowling pin impossible. I believe you can assign a mass per polygon,but e.g. Cactus doesn't do that.

You're correct: in order to make physics calculations doable, objects need a certain thickness, otherwise, a small object may move through without the algorithms detecting a collision. This is why a wedge has 4 points. You may be right about the cardboard box.

BowlingPin: the polygons are defined such that the behavior of the pin matches reality. The top had to be of different size and different density. Cola Bottle: the bottle it is modeled after is not a very stable bottle anyway. But make sure that you keep a draft on the edge - otherwise it may get stuck behind an invisible edge. Hammer: original model was meant to be a temporary placeholder. Apparently I never fixed it.

kaa-ching commented 4 years ago

Be careful when fixing this: you may inadvertently break levels.

Wuzzy2 commented 4 years ago

Ugh, the wedge thing really annoys me. Box2D really doesn't let us have a freaking simple triangle? Wow, that's a huge disappointment. :-( Maybe the documentation should be checked out to see if Box2D is really that limited.

Ah, ok the bowling pin makes sense. But the polygons should at least not have that weird gap.

Wuzzy2 commented 4 years ago

New CardboardBox polygons:

(-0.40,-0.4)=(-0.33,-0.4)=(-0.33,0.40)=(-0.40,0.40);(0.33,-0.4)=(0.4,-0.4)=(0.4,0.40)=(0.33,0.40);(-0.33,-0.4)=(-0.33,-0.33)=(0.33,-0.33)=(0.33,-0.4)

(hopefully this is large enough)

New Hammer polygons:

(-0.5,-0.5)=(-0.3,-0.5)=(-0.3,0.5)=(-0.5,0.5);(-0.3,-0.16667)=(0.5,-0.16667)=(0.5,0.16667)=(-0.3,0.166667);

I wasn't able to fix RotatingBar. If I try to increate the outer bounds of the polygons, it stays the same. E.g. (-.5,0.05)=(-.5,-0.05)=(.5,-0.05)=(.5,0.05) gives the exact same result as (-.1,0.05)=(-.1,-0.05)=(.1,-0.05)=(.1,0.05). Apparently the whole polygon is taken and forcefully stretched to the whole object bounding box. :-( I think RotatingBar should be fixed differently. Turn it into a RectObject like BirchBar and use the normal BirchBar texture and just render the peg/pivot point separately (with a slightly higher ZValue). This would also fix annoying stretching issues.

Wuzzy2 commented 4 years ago

I have read the Box2D manual and there's no indication that simple triangles are disallowed. In fact, there's even an example of a triangle in the manual https://github.com/erincatto/box2d/blob/ecatto/manual/docs/manual.md, so I guess wedges actually can be perfect triangles, so there's no need for that weird 4th point. I can also confirm this in testing.