Bear in mind during this post that because I'm using JBox2d 2.0.1, the old "sweep & prune" broadphase collision detection is where I'm at.
I'm considering how to construct level boundaries (ultimately some sort of concave polygon). Given the use of sweep and prune for broadphase, I want to determine the best way to do this. Here are the options I see:
(a) Use a polygon with reverse vertex ordering to create it "inside-out", that is, as in internal space / external filled polygon.
(b) Use one long edge chain to define the edges.
(c) Use a sequence of 2-vertex edge chains. I'm using this at the moment, but only because I'm sure I read somewhere that using polygons as described in (a) is not recommended (can't recall the reason).
In regards to these options:
(a) Seems by far the easiest, and it ensures nothing could ever leave the level. However I'm not sure if this sort of inside-out usage is recommended for polygons. Polygons (especially the inside-out kind, I'm sure) are also best at dealing with bullet collisions, which is a nice plus as I'd like to use these if possible.
(b) Is pretty easy, but I'm not sure what, if any benefit this would get me over using an inverse polygon. And edges suck at bullet collisions (see here).
(c) Is what I am presently doing, but only because I'm sure I read somewhere that using polygons as described in (a) is not recommended (can't recall the reason, maybe it wasn't a good one). More bodies = more fixtures, that much I read here. If having more fixtures truly is only heavier on memory and not on processing, then I can live with that. However in that discussion they are referring to the new broadphase (hierarchical) not sweep and prune, so I am not sure this applies to my situation. Lasty, edges (let me repeat this once more)... edges are not so good for bullet-type collisions.
My main concern is speed. As I understand it, sweep and prune will iterate through everything in the world anyway, unlike a hierarchical broadphase approach. With my level boundaries obviously being defined as static bodies, I'm wondering how do I make sure that things are as fast as possible? Is there any sense in me removing bodies from the world, that are beyond a certain range from the player? Or does static + sleeping(?) + sweep and prune do all this for me anyway?
PS. My understanding that the broadphase method has changed comes from here, just so it doesn't look like I sucked my thumb for that assumption.
I'm considering how to construct level boundaries (ultimately some sort of concave polygon). Given the use of sweep and prune for broadphase, I want to determine the best way to do this. Here are the options I see:
(a) Use a polygon with reverse vertex ordering to create it "inside-out", that is, as in internal space / external filled polygon.
(b) Use one long edge chain to define the edges.
(c) Use a sequence of 2-vertex edge chains. I'm using this at the moment, but only because I'm sure I read somewhere that using polygons as described in (a) is not recommended (can't recall the reason).
In regards to these options:
(a) Seems by far the easiest, and it ensures nothing could ever leave the level. However I'm not sure if this sort of inside-out usage is recommended for polygons. Polygons (especially the inside-out kind, I'm sure) are also best at dealing with bullet collisions, which is a nice plus as I'd like to use these if possible.
(b) Is pretty easy, but I'm not sure what, if any benefit this would get me over using an inverse polygon. And edges suck at bullet collisions (see here).
(c) Is what I am presently doing, but only because I'm sure I read somewhere that using polygons as described in (a) is not recommended (can't recall the reason, maybe it wasn't a good one). More bodies = more fixtures, that much I read here. If having more fixtures truly is only heavier on memory and not on processing, then I can live with that. However in that discussion they are referring to the new broadphase (hierarchical) not sweep and prune, so I am not sure this applies to my situation. Lasty, edges (let me repeat this once more)... edges are not so good for bullet-type collisions.
My main concern is speed. As I understand it, sweep and prune will iterate through everything in the world anyway, unlike a hierarchical broadphase approach. With my level boundaries obviously being defined as static bodies, I'm wondering how do I make sure that things are as fast as possible? Is there any sense in me removing bodies from the world, that are beyond a certain range from the player? Or does static + sleeping(?) + sweep and prune do all this for me anyway?
PS. My understanding that the broadphase method has changed comes from here, just so it doesn't look like I sucked my thumb for that assumption.