BulletSim: add position resetting for stationary avatars so they don't

move around when standing on a stationary object.
Create proper linkage between BSCharacter and its actor by generating
a UpdatedProperties event the same way BSPrim does.
cpu-performance
Robert Adams 2013-07-18 19:09:55 -07:00
parent 52bb732692
commit f05654d8d6
2 changed files with 20 additions and 5 deletions

View File

@ -130,6 +130,7 @@ public class BSActorAvatarMove : BSActor
SetVelocityAndTarget(m_controllingPrim.RawVelocity, m_controllingPrim.TargetVelocity, true /* inTaintTime */); SetVelocityAndTarget(m_controllingPrim.RawVelocity, m_controllingPrim.TargetVelocity, true /* inTaintTime */);
m_physicsScene.BeforeStep += Mover; m_physicsScene.BeforeStep += Mover;
m_controllingPrim.OnPreUpdateProperty += Process_OnPreUpdateProperty;
m_walkingUpStairs = 0; m_walkingUpStairs = 0;
} }
@ -139,6 +140,7 @@ public class BSActorAvatarMove : BSActor
{ {
if (m_velocityMotor != null) if (m_velocityMotor != null)
{ {
m_controllingPrim.OnPreUpdateProperty -= Process_OnPreUpdateProperty;
m_physicsScene.BeforeStep -= Mover; m_physicsScene.BeforeStep -= Mover;
m_velocityMotor = null; m_velocityMotor = null;
} }
@ -197,7 +199,7 @@ public class BSActorAvatarMove : BSActor
{ {
if (m_controllingPrim.Flying) if (m_controllingPrim.Flying)
{ {
// Flying and not collising and velocity nearly zero. // Flying and not colliding and velocity nearly zero.
m_controllingPrim.ZeroMotion(true /* inTaintTime */); m_controllingPrim.ZeroMotion(true /* inTaintTime */);
} }
} }
@ -266,6 +268,19 @@ public class BSActorAvatarMove : BSActor
} }
} }
// Called just as the property update is received from the physics engine.
// Do any mode necessary for avatar movement.
private void Process_OnPreUpdateProperty(ref EntityProperties entprop)
{
// Don't change position if standing on a stationary object.
if (m_controllingPrim.IsStationary)
{
entprop.Position = m_controllingPrim.RawPosition;
m_physicsScene.PE.SetTranslation(m_controllingPrim.PhysBody, entprop.Position, entprop.Rotation);
}
}
// Decide if the character is colliding with a low object and compute a force to pop the // Decide if the character is colliding with a low object and compute a force to pop the
// avatar up so it can walk up and over the low objects. // avatar up so it can walk up and over the low objects.
private OMV.Vector3 WalkUpStairs() private OMV.Vector3 WalkUpStairs()

View File

@ -709,10 +709,10 @@ public sealed class BSCharacter : BSPhysObject
// the world that things have changed. // the world that things have changed.
public override void UpdateProperties(EntityProperties entprop) public override void UpdateProperties(EntityProperties entprop)
{ {
// Don't change position if standing on a stationary object. // Let anyone (like the actors) modify the updated properties before they are pushed into the object and the simulator.
if (!IsStationary) TriggerPreUpdatePropertyAction(ref entprop);
RawPosition = entprop.Position;
RawPosition = entprop.Position;
RawOrientation = entprop.Rotation; RawOrientation = entprop.Rotation;
// Smooth velocity. OpenSimulator is VERY sensitive to changes in velocity of the avatar // Smooth velocity. OpenSimulator is VERY sensitive to changes in velocity of the avatar
@ -740,7 +740,7 @@ public sealed class BSCharacter : BSPhysObject
// Linkset.UpdateProperties(UpdatedProperties.EntPropUpdates, this); // Linkset.UpdateProperties(UpdatedProperties.EntPropUpdates, this);
// Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop. // Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop.
// base.RequestPhysicsterseUpdate(); // PhysScene.PostUpdate(this);
DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
LocalID, RawPosition, RawOrientation, RawVelocity, _acceleration, _rotationalVelocity); LocalID, RawPosition, RawOrientation, RawVelocity, _acceleration, _rotationalVelocity);