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},BSActorHover,constructor", m_controllingPrim.LocalID);
51 public override bool isActive
53 get {
return Enabled; }
69 m_physicsScene.DetailLog(
"{0},BSActorHover,refresh", m_controllingPrim.LocalID);
72 if (!m_controllingPrim.HoverActive)
98 private void ActivateHover()
100 if (m_hoverMotor == null)
103 m_hoverMotor =
new BSFMotor(
"BSActorHover",
104 m_controllingPrim.HoverTau,
108 m_hoverMotor.SetTarget(ComputeCurrentHoverHeight());
109 m_hoverMotor.SetCurrent(m_controllingPrim.RawPosition.Z);
110 m_hoverMotor.PhysicsScene = m_physicsScene;
112 m_physicsScene.BeforeStep += Hoverer;
116 private void DeactivateHover()
118 if (m_hoverMotor != null)
120 m_physicsScene.BeforeStep -= Hoverer;
126 private void Hoverer(
float timeStep)
132 m_hoverMotor.SetCurrent(m_controllingPrim.RawPosition.Z);
133 m_hoverMotor.SetTarget(ComputeCurrentHoverHeight());
134 float targetHeight = m_hoverMotor.Step(timeStep);
138 float moveForce = (targetHeight - m_controllingPrim.RawPosition.Z) * m_controllingPrim.RawMass;
140 moveForce = -m_controllingPrim.RawVelocity.Z * m_controllingPrim.Mass;
142 m_physicsScene.PE.ApplyCentralImpulse(m_controllingPrim.PhysBody,
new OMV.Vector3(0f, 0f, moveForce));
143 m_physicsScene.DetailLog(
"{0},BSPrim.Hover,move,targHt={1},moveForce={2},mass={3}",
144 m_controllingPrim.LocalID, targetHeight, moveForce, m_controllingPrim.RawMass);
149 private float ComputeCurrentHoverHeight()
151 float ret = m_controllingPrim.HoverHeight;
152 float groundHeight = m_physicsScene.TerrainManager.GetTerrainHeightAtXYZ(m_controllingPrim.RawPosition);
154 switch (m_controllingPrim.HoverType)
156 case PIDHoverType.Ground:
157 ret = groundHeight + m_controllingPrim.HoverHeight;
159 case PIDHoverType.GroundAndWater:
160 float waterHeight = m_physicsScene.TerrainManager.GetWaterLevelAtXYZ(m_controllingPrim.RawPosition);
161 if (groundHeight > waterHeight)
163 ret = groundHeight + m_controllingPrim.HoverHeight;
167 ret = waterHeight + m_controllingPrim.HoverHeight;
BSActorHover(BSScene physicsScene, BSPhysObject pObj, string actorName)
Each physical object can have 'actors' who are pushing the object around. This can be used for hover...
override void RemoveDependencies()