wrong collision with a very tiny bounding box, how can I prevent it?
I have a very tiny Box and use its bounding box to check for collision in control Update(float tpf) loop.
but sometimes it collide with sky that is so higher than the Box in Y position . and a Spark (Particle Emitter) that is hidden.
I had this issue at one point, and solved it by reworking the collision code in my ‘map’ class so that the sky, particle emitters, and any similar non-collisiom objects are not in the same node as the rest of the world.
I had previously done all my collisions against the root mode, but that becomes much less efficient as the scene grows, so your best bet would be to nest collidable objects in a mode and only collide with that node.
Alternatively, you could flag the particle emitter and the sky with a userData value, and write your collision code to ignore certain user data values when choosing the closest valid contact point. But this won’t offer any increase in performance since the collision check happens before you check the user data filter. But this is still an effective way of sorting different collidbale groups.
I use a combination of the both these ways in my project.
I can’t say I know why exactly so I’m just guessing - but my assumption was that the bounding box for a sky box or sky dome is going to be so large that it always intersects with anything near the camera. And I don’t know much about how the bounds are calculated for a particle emitter - but if the bounds are updated every frame based on the location of each particle, then I’d imagine particle emitters could cause inaccurate collisions.
I never saw a realistic need to check collisions with particle emitters or the sky, so I just moved them to their own Node that isn’t used for collisions
Are you checking this collision against the model’s spatial, or against the bounding volume of that spatial?
If you are checking collisions with a bounding volume against another bounding volume (the model’s world bound’s in this case), then there is a good chance that the bounding boxes are overlapping and returning a valid collision, depending on the bounds of your model. Or the bounding box for the model might be calculated incorrectly to begin with.
A character that is modeled in a t-pose will have a wide bounding box to account for their arms sticking out, but then when your character is running animations and the arms are pulled in by its side, then the default bounding box will not be as accurate of a hit box.