Hi, (I feel superbad for asking this question because it should be easy.) I heard that it's possible to create a single concave body by combining multiple convex shapes. Unfortunately, I wasn't able to find any details from the forums. I'm thinking I need to create 2 bodies then combine them somehow... but how, indeed. I just need a tiny push in the right direction. Thank you kindly. 🙂
Creating multiple convex bodies to build Concave shapes
General DiscussionOh! I see. A body can create multiple fixtures! Is this the correct answer?
This has me thinking about pushing the "multiple fixtures" concept to the logical extreme...
If I'm creating the 'floor' for a platforming game, which is more efficient for Box2D?
-Create one looooong body
-Create a bunch of short bodies
-Create one looooong body that is formed from a set of short fixtures?
Thanks!
This has me thinking about pushing the "multiple fixtures" concept to the logical extreme...
If I'm creating the 'floor' for a platforming game, which is more efficient for Box2D?
-Create one looooong body
-Create a bunch of short bodies
-Create one looooong body that is formed from a set of short fixtures?
Thanks!
fewer bodies and fewer fixtures is more efficient. as far as box2d is concerned.
so one long body would be better than the other options.
you may also want to look into what is more efficient for the graphics processing of the platform you are working on.
also there are classes to help automate decomposition of concave shapes into multiple convex fixtures for use in a single body. not sure what port your using but it seems like a common tool to be added.
so one long body would be better than the other options.
you may also want to look into what is more efficient for the graphics processing of the platform you are working on.
also there are classes to help automate decomposition of concave shapes into multiple convex fixtures for use in a single body. not sure what port your using but it seems like a common tool to be added.
Awesome. Many thanks for pointing me in the right direction. 🙂
I'm not really sure one long body is better than many small bodies. Box2D uses AABB bounding boxes around the bodies to determine whether to include them in calculation at all and when the body is sleeping and far enough it won't be included. Though if you add one long body it will be included in the calculation all the time (with all it's vertices) which I think would be less efficient.
Am I missing something? Or why do you think otherwise @sketchbookgames?
Am I missing something? Or why do you think otherwise @sketchbookgames?
Original thread: https://box2d.org/forum/viewtopic.php?t=6586