CollisionSphere into CollisionSegment => Not supported?

Hello!

I’ve got a collision sphere moving around, and I’ve setup a collision segment I was hoping to see it collide into. However, the game was nice enough to let me know what the sphere into segement logic hasn’t been coded yet. (version 1.0.1)

Is there a chance this is going to change anytime soon? What I’m really trying to do is have a ball run into a box. But in this case it is slightly simplified as everythign is at Z=0/it is really just 2D (And no z movement). So I figured I could really just surround the box with collision segments at z=0. (Which would hopefully be a quicker test). I suppose the next best solution would be to use 2 CollisionPolygons to cover each face of the box. (Or at least the 4 sides that intersect the Z=0 plane) Or is there a faster method that would allow me to properly intersect a box?

Thanks!
-Nick

You wouldn’t actually save any computation time for using a CollisionSegment instead of a CollisionPolygon, even if we had the intersection test implemented. So you might as well build the box out of polygons.

I would use four CollisionPolygons, one for each face of the box in the Z=0 plane. Your polygons should extend a little above and below the Z plane to avoid problems with numerical inaccuracy with a zero-width polygon.

Note that CollisionPolygons can be general polygons with any number of vertices, including quads, and quads are preferred to triangles. (Testing intersections against two triangles takes twice as much time as testing against a single quad.)

David

Excellent! that makes the solution a no brainer! :slight_smile:

Yeah, the objects are actually centered at z=0, so this isn’t a problem. = )

Ahhh! Saw that the constructor just took 3 points and made a bad assumption. :slight_smile:

Not that this will be the case, but just curious, I assume that it gets really funky/not handled well if the 4+ points that make up the poly aren’t coplanar?

As always, Thanks David. :smiley:
-Nick

Yep, if you pass four non-coplanar points to the CollisionPolygon constructor, it will be forced planar: an arbitrary plane will be chosen, and the vertices will be adjusted slightly to line within that plane. Experience shows that it usually chooses the wrong plane. :slight_smile:

If you build an egg file that defines a CollisionPolygon quad that is non-coplanar, the egg loader will complain, and triangulate the quad.

David