29 using System.Collections.Generic;
33 using OpenSim.Region.PhysicsModules.SharedBase;
35 using OMV = OpenMetaverse;
37 namespace OpenSim.Region.PhysicsModule.BulletS
44 : base(physicsScene, pObj, actorName)
47 m_physicsScene.DetailLog(
"{0},BSActorMoveToTarget,constructor", m_controllingPrim.LocalID);
51 public override bool isActive
54 get {
return Enabled && m_controllingPrim.IsPhysicallyActive; }
62 DeactivateMoveToTarget();
70 m_physicsScene.DetailLog(
"{0},BSActorMoveToTarget,refresh,enabled={1},active={2},target={3},tau={4}",
71 m_controllingPrim.LocalID, Enabled, m_controllingPrim.MoveToTargetActive,
72 m_controllingPrim.MoveToTargetTarget, m_controllingPrim.MoveToTargetTau );
75 if (!m_controllingPrim.MoveToTargetActive)
82 ActivateMoveToTarget();
86 DeactivateMoveToTarget();
100 private void ActivateMoveToTarget()
102 if (m_targetMotor == null)
105 m_controllingPrim.ZeroMotion(
true);
112 m_targetMotor =
new BSVMotor(
"BSActorMoveToTarget-" + m_controllingPrim.LocalID.ToString(),
113 m_controllingPrim.MoveToTargetTau,
117 m_targetMotor.PhysicsScene = m_physicsScene;
118 m_targetMotor.SetTarget(m_controllingPrim.MoveToTargetTarget);
119 m_targetMotor.SetCurrent(m_controllingPrim.RawPosition);
122 m_physicsScene.BeforeStep += Mover2;
127 m_targetMotor.SetTarget(m_controllingPrim.MoveToTargetTarget);
128 m_targetMotor.SetCurrent(m_controllingPrim.RawPosition);
132 private void DeactivateMoveToTarget()
134 if (m_targetMotor != null)
137 m_physicsScene.BeforeStep -= Mover2;
138 m_targetMotor = null;
146 private void Mover(
float timeStep)
152 OMV.Vector3 origPosition = m_controllingPrim.RawPosition;
155 OMV.Vector3 movePosition = m_controllingPrim.RawPosition + m_targetMotor.Step(timeStep);
158 if (m_targetMotor.ErrorIsZero())
160 m_physicsScene.DetailLog(
"{0},BSActorMoveToTarget.Mover,zeroMovement,movePos={1},pos={2},mass={3}",
161 m_controllingPrim.LocalID, movePosition, m_controllingPrim.RawPosition, m_controllingPrim.Mass);
162 m_controllingPrim.ForcePosition = m_targetMotor.TargetValue;
163 m_controllingPrim.ForceVelocity = OMV.Vector3.Zero;
165 m_physicsScene.PE.PushUpdate(m_controllingPrim.PhysBody);
169 m_controllingPrim.ForcePosition = movePosition;
171 m_physicsScene.PE.PushUpdate(m_controllingPrim.PhysBody);
173 m_physicsScene.DetailLog(
"{0},BSActorMoveToTarget.Mover,move,fromPos={1},movePos={2}",
174 m_controllingPrim.LocalID, origPosition, movePosition);
180 private void Mover2(
float timeStep)
186 OMV.Vector3 origPosition = m_controllingPrim.RawPosition;
187 OMV.Vector3 addedForce = OMV.Vector3.Zero;
190 OMV.Vector3 correctionVector = m_targetMotor.Step(timeStep, m_controllingPrim.RawPosition);
193 if (m_targetMotor.ErrorIsZero())
195 m_physicsScene.DetailLog(
"{0},BSActorMoveToTarget.Mover3,zeroMovement,pos={1},mass={2}",
196 m_controllingPrim.LocalID, m_controllingPrim.RawPosition, m_controllingPrim.Mass);
197 m_controllingPrim.ForcePosition = m_targetMotor.TargetValue;
198 m_controllingPrim.ForceVelocity = OMV.Vector3.Zero;
200 m_physicsScene.PE.PushUpdate(m_controllingPrim.PhysBody);
205 addedForce = correctionVector / timeStep;
207 addedForce -= m_controllingPrim.RawVelocity;
209 addedForce -= m_controllingPrim.Gravity;
212 addedForce *= m_controllingPrim.Mass;
214 m_controllingPrim.AddForce(
true , addedForce);
216 m_physicsScene.DetailLog(
"{0},BSActorMoveToTarget.Mover3,move,fromPos={1},addedForce={2}",
217 m_controllingPrim.LocalID, origPosition, addedForce);
Each physical object can have 'actors' who are pushing the object around. This can be used for hover...
BSActorMoveToTarget(BSScene physicsScene, BSPhysObject pObj, string actorName)
override void RemoveDependencies()