Updating information required for ray cast when paused?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Spankenstein
Posts: 249
Joined: Wed Nov 17, 2010 1:49 pm

Updating information required for ray cast when paused?

Post 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.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Updating information required for ray cast when paused?

Post 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.
Spankenstein
Posts: 249
Joined: Wed Nov 17, 2010 1:49 pm

Re: Updating information required for ray cast when paused?

Post 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?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Updating information required for ray cast when paused?

Post 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.
Spankenstein
Posts: 249
Joined: Wed Nov 17, 2010 1:49 pm

Re: Updating information required for ray cast when paused?

Post by Spankenstein »

I knew there would be a valid reason for it. Thank you for explaining.
Post Reply