Box2D, performance, and error(!) questions
Posted: Wed Feb 20, 2013 2:03 am
A few random Box2D questions that will assist my current project:
1) What's the fastest type of shape? Circles, right?
2) How can I boost the performance of Box2D? I tried using setFixedRotation on my circles, but that only seemed to give ~1 FPS more.
3) Is there any way to do a world:update() which moves everything, but skips collision? I figure, doing collision every other frame or something would be good enough, and would reduce CPU usage.
4) In a world with many bodies, what would be the best-performing kind of weapon? Circles with setSensor, raycast "hitscan", something else? If fixtures with setSensor are fast, would someone mind explaining how to use them, please? Their wiki page is very sparse. Do I use them will collision callbacks like regular fixtures?
5) Will using fixture:setMask improve performance?
6) Is there any way to apply a small amount of friction (ie, air friction) to an entire world?
7) Why is it if I make bodies with minuscule, or even 0 mass, they can still shove other bodies around? How can I make them less "pushy"?
Oh, and this one is important: 8) How can I determine the force with which two bodies have collided? I want to do damage based on how hard they hit things.
Thanks in advance. The new Box2D in 0.8.0 pretty much made the little I used to know obsolete.
EDIT) I'm getting a strange error: "Box2D error: IsLocked() == false". Outright crashes Love2D. Am I not allowed to add bodies within the scope of a collision callback?
1) What's the fastest type of shape? Circles, right?
2) How can I boost the performance of Box2D? I tried using setFixedRotation on my circles, but that only seemed to give ~1 FPS more.
3) Is there any way to do a world:update() which moves everything, but skips collision? I figure, doing collision every other frame or something would be good enough, and would reduce CPU usage.
4) In a world with many bodies, what would be the best-performing kind of weapon? Circles with setSensor, raycast "hitscan", something else? If fixtures with setSensor are fast, would someone mind explaining how to use them, please? Their wiki page is very sparse. Do I use them will collision callbacks like regular fixtures?
5) Will using fixture:setMask improve performance?
6) Is there any way to apply a small amount of friction (ie, air friction) to an entire world?
7) Why is it if I make bodies with minuscule, or even 0 mass, they can still shove other bodies around? How can I make them less "pushy"?
Oh, and this one is important: 8) How can I determine the force with which two bodies have collided? I want to do damage based on how hard they hit things.
Thanks in advance. The new Box2D in 0.8.0 pretty much made the little I used to know obsolete.
EDIT) I'm getting a strange error: "Box2D error: IsLocked() == false". Outright crashes Love2D. Am I not allowed to add bodies within the scope of a collision callback?