29 using System.Collections.Generic;
30 using System.Reflection;
31 using System.Runtime.InteropServices;
33 using OpenSim.Framework;
34 using OpenSim.Region.PhysicsModules.SharedBase;
36 using OMV = OpenMetaverse;
38 namespace OpenSim.
Region.PhysicsModule.BulletS
58 public virtual OMV.Vector3 PositionDisplacement {
get; set; }
62 : base(localID, primName, parent_scene, pos, size,
rotation, pbs, pisPhysical)
71 if (UserSetCenterOfMassDisplacement.HasValue)
72 PositionDisplacement = (OMV.Vector3)UserSetCenterOfMassDisplacement;
74 PositionDisplacement = OMV.Vector3.Zero;
84 PhysScene.AssertInTaintTime(
"BSPrimDisplaced.SetEffectiveCenterOfMassDisplacement");
86 if (UserSetCenterOfMassDisplacement.HasValue)
87 comDisp = (OMV.Vector3)UserSetCenterOfMassDisplacement;
89 comDisp = centerOfMassDisplacement;
92 if (comDisp.ApproxEquals(Vector3.Zero, 0.01f) )
93 comDisp = Vector3.Zero;
95 DetailLog(
"{0},BSPrimDisplaced.SetEffectiveCenterOfMassDisplacement,userSet={1},comDisp={2}",
96 LocalID, UserSetCenterOfMassDisplacement.HasValue, comDisp);
97 if ( !comDisp.ApproxEquals(PositionDisplacement, 0.01f) )
101 PositionDisplacement = comDisp;
102 this.ForcePosition = RawPosition;
105 return PositionDisplacement;
110 public override Vector3 ForcePosition
113 OMV.Vector3 physPosition = PhysScene.PE.GetPosition(PhysBody);
114 if (PositionDisplacement !=
OMV.Vector3.Zero)
118 OMV.Vector3 displacement = PositionDisplacement * ForceOrientation;
119 DetailLog(
"{0},BSPrimDisplaced.ForcePosition,get,physPos={1},disp={2},simPos={3}",
120 LocalID, physPosition, displacement, physPosition - displacement);
121 physPosition -= displacement;
123 RawPosition = physPosition;
128 if (PositionDisplacement !=
OMV.Vector3.Zero)
134 OMV.Vector3 displacement = PositionDisplacement * RawOrientation;
135 OMV.Vector3 displacedPos = RawPosition + displacement;
136 DetailLog(
"{0},BSPrimDisplaced.ForcePosition,set,simPos={1},disp={2},physPos={3}",
137 LocalID, RawPosition, displacement, displacedPos);
138 if (PhysBody.HasPhysicalBody)
140 PhysScene.PE.SetTranslation(PhysBody, displacedPos, RawOrientation);
141 ActivateIfPhysical(
false);
146 base.ForcePosition = value;
152 public override OMV.Vector3 CenterOfMass
154 get {
return RawPosition; }
157 public override OMV.Vector3 GeometricCenter
159 get {
return RawPosition; }
165 if (PositionDisplacement !=
OMV.Vector3.Zero)
172 OMV.Vector3 displacement = PositionDisplacement * entprop.Rotation;
173 OMV.Vector3 displacedPos = entprop.Position - displacement;
174 DetailLog(
"{0},BSPrimDisplaced.UpdateProperties,physPos={1},disp={2},simPos={3}",
175 LocalID, entprop.
Position, displacement, displacedPos);
176 entprop.Position = displacedPos;
179 base.UpdateProperties(entprop);
virtual Vector3 SetEffectiveCenterOfMassDisplacement(Vector3 centerOfMassDisplacement)
OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion rotation
BSPrimDisplaced(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
override void UpdateProperties(EntityProperties entprop)