Hey guys,
I have a scenario where I have one box shaped DetectorVolume that doesn't currently move, and one box shaped kinetic entity that I can control with user input and move around. I'd like to detect and have an event go off whenever the kinetic entity does any kind of colliding with the DetectorVolume.
The problem I'm having is the only time a collision is being detected is when the center position of the kinetic entity is inside of the DetectorVolume. So if part of the kinetic entity is inside of the DetectorVolume, but the exact center of the entity isn't, then it's acting like there's zero collision. Any idea what might be going wrong here? Is this a bug? It seems like the event EntityBeginsTouching is actually doing the same thing as VolumeBeginsContainingEntity.
I took a look at the DetectorVolumeDemo and that seems to be working perfectly fine, which is leading me to think I'm probably doing something weird here.
Using a DetectorVolume with Kinetic Entities
-
- Posts: 10
- Joined: Wed Nov 24, 2010 9:29 pm
- Location: United States
- Contact:
Re: Using a DetectorVolume with Kinetic Entities
To isolate the problem, what happens if you just pull the mesh in question over into the BEPUphysicsDemos and make the DetectorVolumeDemo use it? If that reproduces the issue, it could just be something about the mesh which confuses the detector volume system (maybe an issue with winding, lack of mesh watertightness, or possibly some numerical tolerance gone awry). In this case I could take a look and see if I can do anything about it.
What you describe sounds like the volume isn't finding any triangles in the vicinity of the shape, but the ray cast is still working as expected so containment is defined by the entity's position.
What you describe sounds like the volume isn't finding any triangles in the vicinity of the shape, but the ray cast is still working as expected so containment is defined by the entity's position.
Re: Using a DetectorVolume with Kinetic Entities
Another specific thing to look at is collision rules. Maybe collision rules aren't used consistently somewhere in the detector, leading to a 'partial' detection.
Re: Using a DetectorVolume with Kinetic Entities
Never mind about the collision rules bit- it appears they are completely unused by the DetectorVolume
I'll fix that in the development version soon, though it won't address your issue.
I'll fix that in the development version soon, though it won't address your issue.
-
- Posts: 10
- Joined: Wed Nov 24, 2010 9:29 pm
- Location: United States
- Contact:
Re: Using a DetectorVolume with Kinetic Entities
Hey Norbo,
It looks like I might have found the issue. I was moving the kinetic entity around by updating it's world transform every update, instead of just trying to move it around purely using velocities. After doing a quick test with only velocity based movement, it looks like it's detecting collision the way I'd expect it to.
That's really the only difference between my code and the demo code (which I'm guessing turns out to be a big difference). I knew that forcibly re-positioning a kinetic entity could cause squishy issues regarding collision response, but I guess I wasn't aware that it could even cause problems with more basic collision detection. I'm surprised though, since that doesn't require collision response behaviors, but more or less just overlap detection.
In any case, I should be good for the moment, but I'll let you know if I run into the same issue again.
It looks like I might have found the issue. I was moving the kinetic entity around by updating it's world transform every update, instead of just trying to move it around purely using velocities. After doing a quick test with only velocity based movement, it looks like it's detecting collision the way I'd expect it to.
That's really the only difference between my code and the demo code (which I'm guessing turns out to be a big difference). I knew that forcibly re-positioning a kinetic entity could cause squishy issues regarding collision response, but I guess I wasn't aware that it could even cause problems with more basic collision detection. I'm surprised though, since that doesn't require collision response behaviors, but more or less just overlap detection.
The mesh seems to work fine in the demo, so it makes me think even more that I just need to stop moving things via position and just use velocities from now on. I wish moving kinetic objects using position wasn't so convenient, then maybe I wouldn't keep getting lured back into using it.Norbo wrote:To isolate the problem, what happens if you just pull the mesh in question over into the BEPUphysicsDemos and make the DetectorVolumeDemo use it?
The winding and lack of mesh tightness were my thoughts too initially, but after switching from my complex mesh to a simple code-made box I saw I was still having the same issue.Norbo wrote:If that reproduces the issue, it could just be something about the mesh which confuses the detector volume system (maybe an issue with winding, lack of mesh watertightness, or possibly some numerical tolerance gone awry). In this case I could take a look and see if I can do anything about it..
Haha, yeah I fooled around with that earlier and it started tossing null exceptions my way. I was like, "I've been tricked!"Norbo wrote:Never mind about the collision rules bit- it appears they are completely unused by the DetectorVolume
I'll fix that in the development version soon, though it won't address your issue.
In any case, I should be good for the moment, but I'll let you know if I run into the same issue again.
Re: Using a DetectorVolume with Kinetic Entities
For the detector volume specifically (and indeed, collision detection in general), that should actually work fine. The detector volume works entirely on the last frame's stored containment state and the current frame's detected collision state, which is defined entirely by the location and orientation of the collision shape.I was moving the kinetic entity around by updating it's world transform every update, instead of just trying to move it around purely using velocities.
Another possibility: if the bounding box is somehow not being updated or the entity is otherwise unfindable by the broad phase query accelerator, the DetectorVolume would not detect anything.
A new development version is now available that removes the deceptionHaha, yeah I fooled around with that earlier and it started tossing null exceptions my way. I was like, "I've been tricked!"
-
- Posts: 10
- Joined: Wed Nov 24, 2010 9:29 pm
- Location: United States
- Contact:
Re: Using a DetectorVolume with Kinetic Entities
Ah, so I wasn't completely just making things up in my head (always a good thing).
Hm...I don't think that was happening but it's something to watch out for.Norbo wrote: Another possibility: if the bounding box is somehow not being updated or the entity is otherwise unfindable by the broad phase query accelerator, the DetectorVolume would not detect anything.
Awesome.Norbo wrote:A new development version is now available that removes the deception