123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- using System;
- using System.Collections.Generic;
- using System.Reflection;
- using System.Runtime.InteropServices;
- using OpenMetaverse;
- using OpenSim.Framework;
- using OpenSim.Region.Physics.Manager;
- using OMV = OpenMetaverse;
- namespace OpenSim.Region.Physics.BulletSPlugin
- {
- public class BSPrimDisplaced : BSPrim
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public virtual OMV.Vector3 PositionDisplacement { get; set; }
- public BSPrimDisplaced(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
- OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
- : base(localID, primName, parent_scene, pos, size, rotation, pbs, pisPhysical)
- {
- ClearDisplacement();
- }
-
-
- public void ClearDisplacement()
- {
- if (UserSetCenterOfMassDisplacement.HasValue)
- PositionDisplacement = (OMV.Vector3)UserSetCenterOfMassDisplacement;
- else
- PositionDisplacement = OMV.Vector3.Zero;
- }
-
-
-
-
-
- public virtual Vector3 SetEffectiveCenterOfMassDisplacement(Vector3 centerOfMassDisplacement)
- {
- PhysScene.AssertInTaintTime("BSPrimDisplaced.SetEffectiveCenterOfMassDisplacement");
- Vector3 comDisp;
- if (UserSetCenterOfMassDisplacement.HasValue)
- comDisp = (OMV.Vector3)UserSetCenterOfMassDisplacement;
- else
- comDisp = centerOfMassDisplacement;
-
- if (comDisp.ApproxEquals(Vector3.Zero, 0.01f) )
- comDisp = Vector3.Zero;
- DetailLog("{0},BSPrimDisplaced.SetEffectiveCenterOfMassDisplacement,userSet={1},comDisp={2}",
- LocalID, UserSetCenterOfMassDisplacement.HasValue, comDisp);
- if ( !comDisp.ApproxEquals(PositionDisplacement, 0.01f) )
- {
-
-
- PositionDisplacement = comDisp;
- this.ForcePosition = RawPosition;
- }
- return PositionDisplacement;
- }
-
-
- public override Vector3 ForcePosition
- {
- get {
- OMV.Vector3 physPosition = PhysScene.PE.GetPosition(PhysBody);
- if (PositionDisplacement != OMV.Vector3.Zero)
- {
-
-
- OMV.Vector3 displacement = PositionDisplacement * ForceOrientation;
- DetailLog("{0},BSPrimDisplaced.ForcePosition,get,physPos={1},disp={2},simPos={3}",
- LocalID, physPosition, displacement, physPosition - displacement);
- physPosition -= displacement;
- }
- RawPosition = physPosition;
- return physPosition;
- }
- set
- {
- if (PositionDisplacement != OMV.Vector3.Zero)
- {
-
- RawPosition = value;
-
- OMV.Vector3 displacement = PositionDisplacement * RawOrientation;
- OMV.Vector3 displacedPos = RawPosition + displacement;
- DetailLog("{0},BSPrimDisplaced.ForcePosition,set,simPos={1},disp={2},physPos={3}",
- LocalID, RawPosition, displacement, displacedPos);
- if (PhysBody.HasPhysicalBody)
- {
- PhysScene.PE.SetTranslation(PhysBody, displacedPos, RawOrientation);
- ActivateIfPhysical(false);
- }
- }
- else
- {
- base.ForcePosition = value;
- }
- }
- }
-
- public override OMV.Vector3 CenterOfMass
- {
- get { return RawPosition; }
- }
- public override OMV.Vector3 GeometricCenter
- {
- get { return RawPosition; }
- }
- public override void UpdateProperties(EntityProperties entprop)
- {
-
- if (PositionDisplacement != OMV.Vector3.Zero)
- {
-
-
-
-
- OMV.Vector3 displacement = PositionDisplacement * entprop.Rotation;
- OMV.Vector3 displacedPos = entprop.Position - displacement;
- DetailLog("{0},BSPrimDisplaced.UpdateProperties,physPos={1},disp={2},simPos={3}",
- LocalID, entprop.Position, displacement, displacedPos);
- entprop.Position = displacedPos;
- }
- base.UpdateProperties(entprop);
- }
- }
- }
|