Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad collision polygons of some objects #348

Open
Wuzzy2 opened this issue Jan 13, 2020 · 7 comments
Open

Bad collision polygons of some objects #348

Wuzzy2 opened this issue Jan 13, 2020 · 7 comments

Comments

@Wuzzy2
Copy link
Member

Wuzzy2 commented Jan 13, 2020

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.

  • All wedges: Polygon has 4 points, not 3
  • Ramps: Collision polygon is not pixel-perfect
  • ColaBottle: The collision box is very imprecise and makes the bottle stand in a weird way
  • RotatingBar: Collision box extends into the air, but this is very subtle. Will only be noticable for very large rotating bars. When fixing this, I would ignore the peg.
  • Hammer: Just a rectangle
  • Weight: The upper side should be rounded a little, so that balls will roll away
@Wuzzy2
Copy link
Member Author

Wuzzy2 commented Jan 13, 2020

  • BowlingPin: This one is very weird, it's actually 2 polygons o_O

@Wuzzy2
Copy link
Member Author

Wuzzy2 commented Jan 13, 2020

  • CardboardBox: I think the polygon is too small for Box2D

@kaa-ching
Copy link
Member

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
Copy link
Member

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

@Wuzzy2
Copy link
Member Author

Wuzzy2 commented Jan 13, 2020

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
Copy link
Member Author

Wuzzy2 commented Jan 15, 2020

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
Copy link
Member Author

Wuzzy2 commented Jan 15, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants