Collision with non-contiguous static meshes
Posted: Mon Jul 04, 2011 8:38 pm
We're porting a game to XNA on Windows Phone 7, and running into some issues with collision with level geometry. It's a 2.5D platformer, and the level geometry is specified as a list of vertices/indices, which we read and create a static mesh for at runtime. The level isn't one solid body, though.
The first issue occurs in our test level, which looks like this: The red and blue boxes are kinematic collision boxes attached to the player for doing ground checks. If the box is at the position of the red box in the above image, BEPU finds a collision between the box and the level geometry, several units down in Y from where the box actually is. However, if the box is at the position of the blue box, there's no collision. Since the blue box is outside of the entire level geometry static mesh, while the red box is inside it, my guess is that BEPU doesn't handle this case well. Is that an accurate assumption?
As a workaround, we've thought of splitting the collision into individual pieces (in this case, one for the top platform, and one for the bottom/right side). Would this be effective?
The second issue is performance based. When we load the geometry for a real level, Space.Update() takes over 100ms. The only difference is the complexity of the level geometry, so our working theory is that it's doing triangle-* collision tests for every triangle in the mesh with every other collidable, since everything is a broadphase hit with the mesh. We think the same workaround will probably help here as well. Does that make sense? Any other suggestions?
I apologize that I can't post actual screenshots for confidentiality purposes.
The first issue occurs in our test level, which looks like this: The red and blue boxes are kinematic collision boxes attached to the player for doing ground checks. If the box is at the position of the red box in the above image, BEPU finds a collision between the box and the level geometry, several units down in Y from where the box actually is. However, if the box is at the position of the blue box, there's no collision. Since the blue box is outside of the entire level geometry static mesh, while the red box is inside it, my guess is that BEPU doesn't handle this case well. Is that an accurate assumption?
As a workaround, we've thought of splitting the collision into individual pieces (in this case, one for the top platform, and one for the bottom/right side). Would this be effective?
The second issue is performance based. When we load the geometry for a real level, Space.Update() takes over 100ms. The only difference is the complexity of the level geometry, so our working theory is that it's doing triangle-* collision tests for every triangle in the mesh with every other collidable, since everything is a broadphase hit with the mesh. We think the same workaround will probably help here as well. Does that make sense? Any other suggestions?
I apologize that I can't post actual screenshots for confidentiality purposes.