Page 1 of 1

Updating information required for ray cast when paused?

Posted: Mon Jul 25, 2011 12:35 pm
by Spankenstein
If the physics simulation is paused, and therefore the Space.Update method isn't called, how can I update parameters associated with ray casting so objects can be moved around correctly.

Or, am I going to have to roll my own bounding volume hierarchy and bounding volumes?

Here's a video that shows the 'CollisionInformation.BoundingBox' for the entity in red doesn't update when the object is moved around:

http://www.youtube.com/watch?v=S7IGR29p7QI

The object can't be re-selected once move unless the red box is clicked.

Re: Updating information required for ray cast when paused?

Posted: Mon Jul 25, 2011 6:49 pm
by Norbo
If all you need to ray cast/query support, then you can call the entity.CollisionInformation.UpdateBoundingBox() method. Then, call the Space.BroadPhase.Update() method. This updates the acceleration structures for the new state. The space stages are designed to be usable independently.

Updating the broad phase isn't super cheap, so if at some point you find yourself moving tons of objects simultaneously, keep in mind that you can update their bounding boxes individually and then update the broad phase a single time afterwards.

Re: Updating information required for ray cast when paused?

Posted: Mon Jul 25, 2011 9:15 pm
by Spankenstein
Thank you. That worked. :)

Sidetracking a little here but still on the subject of BEPU.

Shouldn't both the angular and linear velocities be set to Vector3.Zero when using the Entity.BecomeKinematic method?

Currently they are not and I can't think of any reason why they would need to be preserved?

Re: Updating information required for ray cast when paused?

Posted: Mon Jul 25, 2011 9:24 pm
by Norbo
The velocity preservation is by design; it preserves velocity going from kinematic to dynamic and vice versa. Users can very easily understand how to zero out a velocity, but it might not be immediately obvious how to preserve velocity in both directions (though it isn't very complicated). So, since from a performance/development work standpoint they are basically identical, I just opted to do the conceptually harder work so most users wouldn't have to.

While preservation going from dynamic to kinematic is less important in general, it is consistent with the more obviously usable preservation when going from kinematic to dynamic.

Re: Updating information required for ray cast when paused?

Posted: Mon Jul 25, 2011 9:27 pm
by Spankenstein
I knew there would be a valid reason for it. Thank you for explaining.