Hi, I was looking through the demos and noticed that entities become deactivated when they have no velocity. Then I found that each space has a DeactivationManager that is supposed to do that.
However in my game, entities are always active even with very high VelocityLowerLimit values... Also I never used IsAlwaysActive and everything related to deactivation is set to default.
Does anyone know why this is happening?
Thanks.
Entities are always active
Re: Entities are always active
Is anything changing entity properties every frame? Setting velocity, momentum, position, and orientation (or equivalent properties) will wake an entity up. There are some other actions which could cause an entity to wake up; in general, if the simulation needs to run to understand a change, the entity will wake up to accommodate it.
If that's not it, can you reproduce it in an isolated demo (perhaps a modified BEPUphysicsDemos demo)? That should make the cause clearer.
If that's not it, can you reproduce it in an isolated demo (perhaps a modified BEPUphysicsDemos demo)? That should make the cause clearer.
Re: Entities are always active
Thanks. I found it:
I'm thinking about just adding
I don't if there's a more optimized way to limit the velocity though.
Code: Select all
foreach (BEPUphysics.Entities.Entity k in collisionSpace.Entities)
{
k.LinearVelocity = Vector3.Clamp(k.LinearVelocity, new Vector3(-15), new Vector3(15));
}
Code: Select all
if(k.LinearVelocity.Length() > 15)
Re: Entities are always active
Chances are it won't be a performance bottleneck (at least on the PC), but you could hook into the entity.PositionUpdated event. It only fires when the entity is active and a position update occurs. The event is fired after the position is integrated so it won't stop a momentary violation, but it's no different from limiting the velocity externally in that respect.
Edit: Adding in a check to avoid setting the linear velocity is still valuable though. Checking the entity.ActivityInformation.IsDeactivationCandidate would tell you if it's a nearly stopped object that's trying to go to sleep. If the IsDeactivationCandidate property is true, the linear velocity does not need to be set.
Edit: Adding in a check to avoid setting the linear velocity is still valuable though. Checking the entity.ActivityInformation.IsDeactivationCandidate would tell you if it's a nearly stopped object that's trying to go to sleep. If the IsDeactivationCandidate property is true, the linear velocity does not need to be set.
Re: Entities are always active
Thanks, that's much better.