29 using System.Reflection;
30 using System.Collections.Generic;
33 using OMV = OpenMetaverse;
34 using OpenSim.Framework;
35 using OpenSim.Region.PhysicsModules.SharedBase;
36 using OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet;
38 namespace OpenSim.
Region.PhysicsModule.BulletS
44 protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 private static readonly
string LogHeader =
"[BULLETS PRIM]";
48 private OMV.Vector3 _size;
50 private bool _grabbed;
51 private bool _isSelected;
52 private bool _isVolumeDetect;
55 private OMV.Vector3 _acceleration;
56 private int _physicsActorType;
57 private bool _isPhysical;
59 private bool _setAlwaysRun;
60 private bool _throttleUpdates;
61 private bool _floatOnWater;
62 private OMV.Vector3 _rotationalVelocity;
63 private bool _kinematic;
64 private float _buoyancy;
66 private int CrossingFailures {
get; set; }
69 public const string VehicleActorName =
"BasicVehicle";
72 public const string HoverActorName =
"BSPrim.HoverActor";
74 public const String LockedAxisActorName =
"BSPrim.LockedAxis";
76 public const string MoveToTargetActorName =
"BSPrim.MoveToTargetActor";
78 public const string SetForceActorName =
"BSPrim.SetForceActor";
79 public const string SetTorqueActorName =
"BSPrim.SetTorqueActor";
83 : base(parent_scene, localID, primName,
"BSPrim")
92 RawVelocity =
OMV.Vector3.Zero;
93 _rotationalVelocity =
OMV.Vector3.Zero;
95 _isPhysical = pisPhysical;
96 _isVolumeDetect =
false;
98 _mass = CalculateMass();
103 PhysScene.TaintedObject(LocalID,
"BSPrim.create", delegate()
106 ExtremeSanityCheck(
true );
108 CreateGeomAndObject(
true);
110 CurrentCollisionFlags = PhysScene.PE.GetCollisionFlags(PhysBody);
112 IsInitialized =
true;
120 IsInitialized =
false;
125 this.VehicleType = (int)
Vehicle.TYPE_NONE;
127 PhysScene.TaintedObject(LocalID,
"BSPrim.Destroy", delegate()
129 DetailLog(
"{0},BSPrim.Destroy,taint,", LocalID);
131 PhysScene.Shapes.DereferenceBody(PhysBody, null);
133 PhysShape.Dereference(PhysScene);
139 public override bool Stopped {
140 get {
return false; }
143 public override bool IsIncomplete {
145 return ShapeRebuildScheduled;
152 public bool ShapeRebuildScheduled {
get;
protected set; }
154 public override OMV.Vector3
Size {
155 get {
return _size; }
161 ForceBodyShapeRebuild(
false);
169 PrimAssetState = PrimAssetCondition.Unknown;
170 ForceBodyShapeRebuild(
false);
183 _mass = CalculateMass();
184 CreateGeomAndObject(
true);
191 if (!ShapeRebuildScheduled)
194 ShapeRebuildScheduled =
true;
195 PhysScene.TaintedObject(LocalID,
"BSPrim.ForceBodyShapeRebuild", delegate()
197 _mass = CalculateMass();
198 CreateGeomAndObject(
true);
199 ShapeRebuildScheduled =
false;
206 public override bool Grabbed {
207 set { _grabbed = value;
210 public override bool Selected {
213 if (value != _isSelected)
216 PhysScene.TaintedObject(LocalID,
"BSPrim.setSelected", delegate()
218 DetailLog(
"{0},BSPrim.selected,taint,selected={1}", LocalID, _isSelected);
219 SetObjectDynamic(
false);
224 public override bool IsSelected
226 get {
return _isSelected; }
232 if (CrossingFailures > BSParam.CrossingFailuresBeforeOutOfBounds)
234 base.RaiseOutOfBounds(RawPosition);
236 else if (CrossingFailures == BSParam.CrossingFailuresBeforeOutOfBounds)
238 m_log.WarnFormat(
"{0} Too many crossing failures for {1}", LogHeader, Name);
257 RawVelocity = OMV.Vector3.Zero;
258 _acceleration = OMV.Vector3.Zero;
259 _rotationalVelocity = OMV.Vector3.Zero;
262 PhysScene.TaintedObject(inTaintTime, LocalID,
"BSPrim.ZeroMotion", delegate()
264 if (PhysBody.HasPhysicalBody)
265 PhysScene.PE.ClearAllForces(PhysBody);
270 _rotationalVelocity = OMV.Vector3.Zero;
272 PhysScene.TaintedObject(inTaintTime, LocalID,
"BSPrim.ZeroMotion", delegate()
275 if (PhysBody.HasPhysicalBody)
277 PhysScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity);
278 PhysScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity);
285 DetailLog(
"{0},BSPrim.LockAngularMotion,call,axis={1}", LocalID, axislocks);
288 if ((axislocks & 0x02) != 0)
292 if ((axislocks & 0x04) != 0)
296 if ((axislocks & 0x08) != 0)
301 InitializeAxisActor();
315 if (RawPosition == value)
317 DetailLog(
"{0},BSPrim.setPosition,call,positionNotChanging,pos={1},orient={2}", LocalID, RawPosition, RawOrientation);
321 PositionSanityCheck(
false);
323 PhysScene.TaintedObject(LocalID,
"BSPrim.setPosition", delegate()
325 DetailLog(
"{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, RawPosition, RawOrientation);
326 ForcePosition = RawPosition;
332 public override OMV.Vector3 ForcePosition {
334 RawPosition = PhysScene.PE.GetPosition(PhysBody);
339 if (PhysBody.HasPhysicalBody)
341 PhysScene.PE.SetTranslation(PhysBody, RawPosition, RawOrientation);
342 ActivateIfPhysical(
false);
350 private bool PositionSanityCheck(
bool inTaintTime)
355 if (!IsPhysicallyActive)
358 if (!PhysScene.TerrainManager.IsWithinKnownTerrain(RawPosition))
366 float terrainHeight = PhysScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition);
367 OMV.Vector3 upForce = OMV.Vector3.Zero;
368 float approxSize = Math.Max(Size.X, Math.Max(Size.Y, Size.Z));
369 if ((RawPosition.Z + approxSize / 2f) < terrainHeight)
371 DetailLog(
"{0},BSPrim.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, RawPosition, terrainHeight);
372 float targetHeight = terrainHeight + (Size.Z / 2f);
375 RawPosition =
new OMV.Vector3(RawPosition.X, RawPosition.Y, targetHeight);
378 ForcePosition = RawPosition;
381 ZeroMotion(inTaintTime);
385 if ((CurrentCollisionFlags &
CollisionFlags.BS_FLOATS_ON_WATER) != 0)
387 float waterHeight = PhysScene.TerrainManager.GetWaterLevelAtXYZ(RawPosition);
389 if (Math.Abs(RawPosition.Z - waterHeight) > 0.1f)
392 upForce.Z = (waterHeight - RawPosition.Z) * 1f;
395 OMV.Vector3 correctionForce = upForce - PhysScene.DefaultGravity;
396 DetailLog(
"{0},BSPrim.PositionSanityCheck,applyForce,pos={1},upForce={2},correctionForce={3}", LocalID, RawPosition, upForce, correctionForce);
397 AddForce(inTaintTime, correctionForce);
408 private bool ExtremeSanityCheck(
bool inTaintTime)
412 int wayOverThere = -1000;
413 int wayOutThere = 10000;
416 if ( RawPosition.X < wayOverThere || RawPosition.X > wayOutThere
417 || RawPosition.Y < wayOverThere || RawPosition.X > wayOutThere
418 || RawPosition.Z < wayOverThere || RawPosition.X > wayOutThere)
420 RawPosition =
new OMV.Vector3(10, 10, 50);
421 ZeroMotion(inTaintTime);
424 if (RawVelocity.LengthSquared() > BSParam.MaxLinearVelocitySquared)
426 RawVelocity = Util.ClampV(RawVelocity, BSParam.MaxLinearVelocity);
429 if (_rotationalVelocity.LengthSquared() > BSParam.MaxAngularVelocitySquared)
431 _rotationalVelocity = Util.ClampV(_rotationalVelocity, BSParam.MaxAngularVelocity);
441 public override float Mass
443 get {
return _mass; }
446 public virtual float TotalMass
448 get {
return _mass; }
451 public override float RawMass {
452 get {
return _mass; }
458 if (PhysBody.HasPhysicalBody && PhysShape.HasPhysicalShape)
462 PhysScene.PE.SetGravity(PhysBody, PhysScene.DefaultGravity);
463 Inertia = OMV.Vector3.Zero;
464 PhysScene.PE.SetMassProps(PhysBody, 0f, Inertia);
465 PhysScene.PE.UpdateInertiaTensor(PhysBody);
474 PhysScene.PE.RemoveObjectFromWorld(PhysScene.World, PhysBody);
478 Gravity = ComputeGravity(Buoyancy);
479 PhysScene.PE.SetGravity(PhysBody, Gravity);
484 Inertia = PhysScene.PE.CalculateLocalInertia(PhysShape.physShapeInfo, physMass);
485 PhysScene.PE.SetMassProps(PhysBody, physMass, Inertia);
486 PhysScene.PE.UpdateInertiaTensor(PhysBody);
488 DetailLog(
"{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2},grav={3},inWorld={4}",
489 LocalID, physMass, Inertia, Gravity, inWorld);
493 AddObjectToPhysicalWorld();
502 OMV.Vector3 ret = PhysScene.DefaultGravity;
506 ret *= (1f - buoyancy);
514 public override OMV.Vector3 CenterOfMass
516 get {
return RawPosition; }
520 public override OMV.Vector3 GeometricCenter
522 get {
return RawPosition; }
525 public override OMV.Vector3 Force {
526 get {
return RawForce; }
529 EnableActor(RawForce !=
OMV.Vector3.Zero, SetForceActorName, delegate()
535 PhysScene.TaintedObject(LocalID,
"BSPrim.setForce", delegate()
537 UpdatePhysicalParameters();
548 if (PhysicalActors.TryGetActor(VehicleActorName, out actor))
556 ret =
new BSDynamics(PhysScene,
this, VehicleActorName);
557 PhysicalActors.Add(ret.ActorName, ret);
563 public override int VehicleType {
565 int ret = (int)
Vehicle.TYPE_NONE;
566 BSDynamics vehicleActor = GetVehicleActor(
false );
567 if (vehicleActor != null)
568 ret = (int)vehicleActor.
Type;
574 PhysScene.TaintedObject(LocalID,
"setVehicleType", delegate()
583 BSDynamics vehicleActor = GetVehicleActor(
false );
584 if (vehicleActor != null)
586 PhysicalActors.RemoveAndRelease(vehicleActor.ActorName);
592 BSDynamics vehicleActor = GetVehicleActor(
true );
593 if (vehicleActor != null)
595 vehicleActor.ProcessTypeChange(type);
596 ActivateIfPhysical(
false);
604 PhysScene.TaintedObject(LocalID,
"BSPrim.VehicleFloatParam", delegate()
606 BSDynamics vehicleActor = GetVehicleActor(
true );
607 if (vehicleActor != null)
609 vehicleActor.ProcessFloatVehicleParam((
Vehicle)param, value);
610 ActivateIfPhysical(
false);
616 PhysScene.TaintedObject(LocalID,
"BSPrim.VehicleVectorParam", delegate()
618 BSDynamics vehicleActor = GetVehicleActor(
true );
619 if (vehicleActor != null)
621 vehicleActor.ProcessVectorVehicleParam((
Vehicle)param, value);
622 ActivateIfPhysical(
false);
628 PhysScene.TaintedObject(LocalID,
"BSPrim.VehicleRotationParam", delegate()
630 BSDynamics vehicleActor = GetVehicleActor(
true );
631 if (vehicleActor != null)
634 ActivateIfPhysical(
false);
640 PhysScene.TaintedObject(LocalID,
"BSPrim.VehicleFlags", delegate()
642 BSDynamics vehicleActor = GetVehicleActor(
true );
643 if (vehicleActor != null)
645 vehicleActor.ProcessVehicleFlags(param,
remove);
652 PhysScene.TaintedObject(LocalID,
"BSPrim.SetVehicle", delegate ()
654 BSDynamics vehicleActor = GetVehicleActor(
true );
655 if (vehicleActor != null && (pvdata is
VehicleData) )
657 VehicleData vdata = (VehicleData)pvdata;
660 vehicleActor.ProcessTypeChange(vdata.m_type);
661 vehicleActor.ProcessVehicleFlags(-1,
false);
662 vehicleActor.ProcessVehicleFlags((int)vdata.
m_flags,
false);
665 vehicleActor.ProcessVectorVehicleParam(Vehicle.LINEAR_MOTOR_DIRECTION, vdata.m_linearMotorDirection);
666 vehicleActor.ProcessVectorVehicleParam(Vehicle.LINEAR_FRICTION_TIMESCALE, vdata.m_linearFrictionTimescale);
667 vehicleActor.ProcessFloatVehicleParam(Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE, vdata.m_linearMotorDecayTimescale);
668 vehicleActor.ProcessFloatVehicleParam(Vehicle.LINEAR_MOTOR_TIMESCALE, vdata.m_linearMotorTimescale);
669 vehicleActor.ProcessVectorVehicleParam(Vehicle.LINEAR_MOTOR_OFFSET, vdata.m_linearMotorOffset);
672 vehicleActor.ProcessVectorVehicleParam(Vehicle.ANGULAR_MOTOR_DIRECTION, vdata.m_angularMotorDirection);
673 vehicleActor.ProcessFloatVehicleParam(Vehicle.ANGULAR_MOTOR_TIMESCALE, vdata.m_angularMotorTimescale);
674 vehicleActor.ProcessFloatVehicleParam(Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE, vdata.m_angularMotorDecayTimescale);
675 vehicleActor.ProcessVectorVehicleParam(Vehicle.ANGULAR_FRICTION_TIMESCALE, vdata.m_angularFrictionTimescale);
678 vehicleActor.ProcessFloatVehicleParam(Vehicle.ANGULAR_DEFLECTION_EFFICIENCY, vdata.m_angularDeflectionEfficiency);
679 vehicleActor.ProcessFloatVehicleParam(Vehicle.ANGULAR_DEFLECTION_TIMESCALE, vdata.m_angularDeflectionTimescale);
680 vehicleActor.ProcessFloatVehicleParam(Vehicle.LINEAR_DEFLECTION_EFFICIENCY, vdata.m_linearDeflectionEfficiency);
681 vehicleActor.ProcessFloatVehicleParam(Vehicle.LINEAR_DEFLECTION_TIMESCALE, vdata.m_linearDeflectionTimescale);
684 vehicleActor.ProcessFloatVehicleParam(Vehicle.BANKING_EFFICIENCY, vdata.m_bankingEfficiency);
685 vehicleActor.ProcessFloatVehicleParam(Vehicle.BANKING_MIX, vdata.m_bankingMix);
686 vehicleActor.ProcessFloatVehicleParam(Vehicle.BANKING_TIMESCALE, vdata.m_bankingTimescale);
689 vehicleActor.ProcessFloatVehicleParam(Vehicle.HOVER_HEIGHT, vdata.m_VhoverHeight);
690 vehicleActor.ProcessFloatVehicleParam(Vehicle.HOVER_EFFICIENCY, vdata.m_VhoverEfficiency);
691 vehicleActor.ProcessFloatVehicleParam(Vehicle.HOVER_TIMESCALE, vdata.m_VhoverTimescale);
692 vehicleActor.ProcessFloatVehicleParam(Vehicle.BUOYANCY, vdata.m_VehicleBuoyancy);
695 vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, vdata.m_verticalAttractionEfficiency);
696 vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, vdata.m_verticalAttractionTimescale);
698 vehicleActor.ProcessRotationVehicleParam(Vehicle.REFERENCE_FRAME, vdata.m_referenceFrame);
705 bool newValue = (param != 0);
706 if (_isVolumeDetect != newValue)
708 _isVolumeDetect = newValue;
709 PhysScene.TaintedObject(LocalID,
"BSPrim.SetVolumeDetect", delegate()
712 SetObjectDynamic(
true);
717 public override bool IsVolumeDetect
719 get {
return _isVolumeDetect; }
723 base.SetMaterial(material);
724 PhysScene.TaintedObject(LocalID,
"BSPrim.SetMaterial", delegate()
726 UpdatePhysicalParameters();
729 public override float Friction
731 get {
return base.Friction; }
734 if (base.Friction != value)
736 base.Friction = value;
737 PhysScene.TaintedObject(LocalID,
"BSPrim.setFriction", delegate()
739 UpdatePhysicalParameters();
744 public override float Restitution
746 get {
return base.Restitution; }
749 if (base.Restitution != value)
751 base.Restitution = value;
752 PhysScene.TaintedObject(LocalID,
"BSPrim.setRestitution", delegate()
754 UpdatePhysicalParameters();
761 public override float Density
763 get {
return base.Density; }
766 if (base.Density != value)
768 base.Density = value;
769 PhysScene.TaintedObject(LocalID,
"BSPrim.setDensity", delegate()
771 UpdatePhysicalParameters();
776 public override float GravModifier
778 get {
return base.GravModifier; }
781 if (base.GravModifier != value)
783 base.GravModifier = value;
784 PhysScene.TaintedObject(LocalID,
"BSPrim.setGravityModifier", delegate()
786 UpdatePhysicalParameters();
792 get {
return RawVelocity; }
795 PhysScene.TaintedObject(LocalID,
"BSPrim.setVelocity", delegate()
798 ForceVelocity = RawVelocity;
802 public override OMV.Vector3 ForceVelocity {
803 get {
return RawVelocity; }
805 PhysScene.AssertInTaintTime(
"BSPrim.ForceVelocity");
807 RawVelocity = Util.ClampV(value, BSParam.MaxLinearVelocity);
808 if (PhysBody.HasPhysicalBody)
810 DetailLog(
"{0},BSPrim.ForceVelocity,taint,vel={1}", LocalID, RawVelocity);
811 PhysScene.PE.SetLinearVelocity(PhysBody, RawVelocity);
812 ActivateIfPhysical(
false);
816 public override OMV.Vector3 Torque {
817 get {
return RawTorque; }
820 EnableActor(RawTorque !=
OMV.Vector3.Zero, SetTorqueActorName, delegate()
824 DetailLog(
"{0},BSPrim.SetTorque,call,torque={1}", LocalID, RawTorque);
827 PhysScene.TaintedObject(LocalID,
"BSPrim.setTorque", delegate()
829 UpdatePhysicalParameters();
834 get {
return _acceleration; }
835 set { _acceleration = value; }
840 return RawOrientation;
843 if (RawOrientation == value)
845 RawOrientation = value;
847 PhysScene.TaintedObject(LocalID,
"BSPrim.setOrientation", delegate()
849 ForceOrientation = RawOrientation;
854 public override OMV.Quaternion ForceOrientation
858 RawOrientation = PhysScene.PE.GetOrientation(PhysBody);
859 return RawOrientation;
863 RawOrientation = value;
864 if (PhysBody.HasPhysicalBody)
865 PhysScene.PE.SetTranslation(PhysBody, RawPosition, RawOrientation);
868 public override int PhysicsActorType {
869 get {
return _physicsActorType; }
870 set { _physicsActorType = value; }
872 public override bool IsPhysical {
873 get {
return _isPhysical; }
875 if (_isPhysical != value)
878 PhysScene.TaintedObject(LocalID,
"BSPrim.setIsPhysical", delegate()
880 DetailLog(
"{0},setIsPhysical,taint,isPhys={1}", LocalID, _isPhysical);
881 SetObjectDynamic(
true);
891 public override bool IsStatic
893 get {
return _isSelected || !IsPhysical; }
897 public override bool IsSolid
899 get {
return !IsPhantom && !_isVolumeDetect; }
903 public override bool IsPhysicallyActive
905 get {
return !_isSelected && IsPhysical; }
910 private void SetObjectDynamic(
bool forceRebuild)
913 CreateGeomAndObject(forceRebuild);
925 if (!PhysBody.HasPhysicalBody)
934 PhysScene.PE.RemoveObjectFromWorld(PhysScene.World, PhysBody);
937 MakeDynamic(IsStatic);
940 PhysicalActors.Refresh();
943 EnableCollisions(SubscribedEvents());
948 AddObjectToPhysicalWorld();
951 PhysScene.PE.UpdateSingleAabb(PhysScene.World, PhysBody);
953 DetailLog(
"{0},BSPrim.UpdatePhysicalParameters,taintExit,static={1},solid={2},mass={3},collide={4},cf={5:X},cType={6},body={7},shape={8}",
954 LocalID, IsStatic, IsSolid, Mass, SubscribedEvents(),
955 CurrentCollisionFlags, PhysBody.collisionType, PhysBody, PhysShape);
968 CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_STATIC_OBJECT);
973 PhysScene.PE.SetFriction(PhysBody, Friction);
974 PhysScene.PE.SetRestitution(PhysBody, Restitution);
975 PhysScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold);
978 UpdatePhysicalMassProperties(0f,
false);
980 if (BSParam.CcdMotionThreshold > 0f)
982 PhysScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold);
983 PhysScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius);
989 PhysScene.PE.ForceActivationState(PhysBody, ActivationState.ISLAND_SLEEPING);
992 PhysBody.collisionType = CollisionType.Static;
997 CurrentCollisionFlags = PhysScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.CF_STATIC_OBJECT);
1000 PhysScene.PE.SetFriction(PhysBody, Friction);
1001 PhysScene.PE.SetRestitution(PhysBody, Restitution);
1009 ForcePosition = RawPosition;
1010 ForceVelocity = RawVelocity;
1011 ForceRotationalVelocity = _rotationalVelocity;
1014 UpdatePhysicalMassProperties(RawMass,
false);
1017 if (BSParam.CcdMotionThreshold > 0f)
1019 PhysScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold);
1020 PhysScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius);
1024 PhysScene.PE.SetDamping(PhysBody, BSParam.LinearDamping, BSParam.AngularDamping);
1025 PhysScene.PE.SetDeactivationTime(PhysBody, BSParam.DeactivationTime);
1026 PhysScene.PE.SetSleepingThresholds(PhysBody, BSParam.LinearSleepingThreshold, BSParam.AngularSleepingThreshold);
1027 PhysScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold);
1030 PhysBody.collisionType = CollisionType.Dynamic;
1034 PhysScene.PE.ForceActivationState(PhysBody, ActivationState.ACTIVE_TAG);
1042 private void MakeSolid(
bool makeSolid)
1050 m_log.ErrorFormat(
"{0} MakeSolid: physical body of wrong type for solidity. id={1}, type={2}", LogHeader, LocalID, bodyType);
1052 CurrentCollisionFlags = PhysScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE);
1058 m_log.ErrorFormat(
"{0} MakeSolid: physical body of wrong type for non-solidness. id={1}, type={2}", LogHeader, LocalID, bodyType);
1060 CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE);
1063 PhysBody.collisionType = CollisionType.VolumeDetect;
1068 private void EnableCollisions(
bool wantsCollisionEvents)
1070 if (wantsCollisionEvents)
1072 CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
1076 CurrentCollisionFlags = PhysScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
1083 internal void AddObjectToPhysicalWorld()
1085 if (PhysBody.HasPhysicalBody)
1087 PhysScene.PE.AddObjectToWorld(PhysScene.World, PhysBody);
1091 m_log.ErrorFormat(
"{0} Attempt to add physical object without body. id={1}", LogHeader, LocalID);
1092 DetailLog(
"{0},BSPrim.AddObjectToPhysicalWorld,addObjectWithoutBody,cType={1}", LocalID, PhysBody.collisionType);
1097 public override bool Flying {
1098 get {
return _flying; }
1104 get {
return _setAlwaysRun; }
1105 set { _setAlwaysRun = value; }
1107 public override bool ThrottleUpdates {
1108 get {
return _throttleUpdates; }
1109 set { _throttleUpdates = value; }
1111 public bool IsPhantom {
1119 public override bool FloatOnWater {
1121 _floatOnWater = value;
1122 PhysScene.TaintedObject(LocalID,
"BSPrim.setFloatOnWater", delegate()
1125 CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER);
1127 CurrentCollisionFlags = PhysScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER);
1133 return _rotationalVelocity;
1136 _rotationalVelocity = value;
1137 Util.ClampV(_rotationalVelocity, BSParam.MaxAngularVelocity);
1139 PhysScene.TaintedObject(LocalID,
"BSPrim.setRotationalVelocity", delegate()
1141 ForceRotationalVelocity = _rotationalVelocity;
1145 public override OMV.Vector3 ForceRotationalVelocity {
1147 return _rotationalVelocity;
1150 _rotationalVelocity = Util.ClampV(value, BSParam.MaxAngularVelocity);
1151 if (PhysBody.HasPhysicalBody)
1153 DetailLog(
"{0},BSPrim.ForceRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity);
1154 PhysScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity);
1156 ActivateIfPhysical(
false);
1160 public override bool Kinematic {
1161 get {
return _kinematic; }
1162 set { _kinematic = value;
1166 public override float Buoyancy {
1167 get {
return _buoyancy; }
1170 PhysScene.TaintedObject(LocalID,
"BSPrim.setBuoyancy", delegate()
1172 ForceBuoyancy = _buoyancy;
1176 public override float ForceBuoyancy {
1177 get {
return _buoyancy; }
1182 UpdatePhysicalMassProperties(RawMass,
true);
1183 DetailLog(
"{0},BSPrim.ForceBuoyancy,buoy={1},mass={2},grav={3}", LocalID, _buoyancy, RawMass, Gravity);
1184 ActivateIfPhysical(
false);
1188 public override bool PIDActive
1192 return MoveToTargetActive;
1197 MoveToTargetActive = value;
1199 EnableActor(MoveToTargetActive, MoveToTargetActorName, delegate()
1205 PhysScene.TaintedObject(LocalID,
"BSPrim.PIDActive", delegate()
1207 UpdatePhysicalParameters();
1212 public override OMV.Vector3 PIDTarget
1216 base.PIDTarget = value;
1218 if (PhysicalActors.TryGetActor(MoveToTargetActorName, out actor))
1228 public override bool PIDHoverActive {
1231 return base.HoverActive;
1234 base.HoverActive = value;
1235 EnableActor(HoverActive, HoverActorName, delegate()
1237 return new BSActorHover(PhysScene,
this, HoverActorName);
1241 PhysScene.TaintedObject(LocalID,
"BSPrim.PIDHoverActive", delegate()
1243 UpdatePhysicalParameters();
1250 OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude);
1255 addForce /= PhysScene.LastTimeStep;
1258 AddForce(
false , addForce);
1265 if (IsPhysicallyActive)
1267 if (force.IsFinite())
1271 OMV.Vector3 addForce = force;
1272 PhysScene.TaintedObject(inTaintTime, LocalID,
"BSPrim.AddForce", delegate()
1277 DetailLog(
"{0},BSPrim.addForce,taint,force={1}", LocalID, addForce);
1278 if (PhysBody.HasPhysicalBody)
1280 PhysScene.PE.ApplyCentralForce(PhysBody, addForce);
1281 ActivateIfPhysical(
false);
1287 m_log.WarnFormat(
"{0}: AddForce: Got a NaN force applied to a prim. LocalID={1}", LogHeader, LocalID);
1295 if (!IsPhysicallyActive)
1297 if (impulse.IsFinite())
1299 OMV.Vector3 addImpulse = Util.ClampV(impulse, BSParam.MaxAddForceMagnitude);
1302 PhysScene.TaintedObject(inTaintTime, LocalID,
"BSPrim.AddImpulse", delegate()
1305 DetailLog(
"{0},BSPrim.addForceImpulse,taint,impulseforce={1}", LocalID, addImpulse);
1306 if (PhysBody.HasPhysicalBody)
1308 PhysScene.PE.ApplyCentralImpulse(PhysBody, addImpulse);
1309 ActivateIfPhysical(
false);
1315 m_log.WarnFormat(
"{0}: AddForceImpulse: Got a NaN impulse applied to a prim. LocalID={1}", LogHeader, LocalID);
1324 if (force.IsFinite())
1326 OMV.Vector3 angForce = force;
1327 PhysScene.TaintedObject(inTaintTime, LocalID,
"BSPrim.AddAngularForce", delegate()
1329 if (PhysBody.HasPhysicalBody)
1331 DetailLog(
"{0},BSPrim.AddAngularForce,taint,angForce={1}", LocalID, angForce);
1332 PhysScene.PE.ApplyTorque(PhysBody, angForce);
1333 ActivateIfPhysical(
false);
1339 m_log.WarnFormat(
"{0}: Got a NaN force applied to a prim. LocalID={1}", LogHeader, LocalID);
1350 OMV.Vector3 applyImpulse = impulse;
1351 PhysScene.TaintedObject(inTaintTime, LocalID,
"BSPrim.ApplyTorqueImpulse", delegate()
1353 if (PhysBody.HasPhysicalBody)
1355 PhysScene.PE.ApplyTorqueImpulse(PhysBody, applyImpulse);
1356 ActivateIfPhysical(
false);
1364 #region Mass Calculation
1366 private float CalculateMass()
1368 float volume = _size.X * _size.Y * _size.Z;
1371 float returnMass = 0;
1372 float hollowAmount = (float)BaseShape.ProfileHollow * 2.0e-5f;
1373 float hollowVolume = hollowAmount * hollowAmount;
1375 switch (BaseShape.ProfileShape)
1377 case ProfileShape.Square:
1380 if (BaseShape.PathCurve == (byte)Extrusion.Straight)
1382 if (hollowAmount > 0.0)
1384 switch (BaseShape.HollowShape)
1386 case HollowShape.Square:
1387 case HollowShape.Same:
1390 case HollowShape.Circle:
1392 hollowVolume *= 0.78539816339f;
1395 case HollowShape.Triangle:
1397 hollowVolume *= (0.5f * .5f);
1404 volume *= (1.0f - hollowVolume);
1408 else if (BaseShape.PathCurve == (byte)Extrusion.Curve1)
1412 volume *= 0.78539816339e-2f * (float)(200 - BaseShape.PathScaleX);
1413 tmp= 1.0f -2.0e-2f * (float)(200 - BaseShape.PathScaleY);
1414 volume -= volume*tmp*tmp;
1416 if (hollowAmount > 0.0)
1418 hollowVolume *= hollowAmount;
1420 switch (BaseShape.HollowShape)
1422 case HollowShape.Square:
1423 case HollowShape.Same:
1426 case HollowShape.Circle:
1427 hollowVolume *= 0.78539816339f;;
1430 case HollowShape.Triangle:
1431 hollowVolume *= 0.5f * 0.5f;
1437 volume *= (1.0f - hollowVolume);
1443 case ProfileShape.Circle:
1445 if (BaseShape.PathCurve == (byte)Extrusion.Straight)
1447 volume *= 0.78539816339f;
1449 if (hollowAmount > 0.0)
1451 switch (BaseShape.HollowShape)
1453 case HollowShape.Same:
1454 case HollowShape.Circle:
1457 case HollowShape.Square:
1458 hollowVolume *= 0.5f * 2.5984480504799f;
1461 case HollowShape.Triangle:
1462 hollowVolume *= .5f * 1.27323954473516f;
1469 volume *= (1.0f - hollowVolume);
1473 else if (BaseShape.PathCurve == (byte)Extrusion.Curve1)
1475 volume *= 0.61685027506808491367715568749226e-2f * (float)(200 - BaseShape.PathScaleX);
1476 tmp = 1.0f - .02f * (float)(200 - BaseShape.PathScaleY);
1477 volume *= (1.0f - tmp * tmp);
1479 if (hollowAmount > 0.0)
1483 hollowVolume *= hollowAmount;
1485 switch (BaseShape.HollowShape)
1487 case HollowShape.Same:
1488 case HollowShape.Circle:
1491 case HollowShape.Square:
1492 hollowVolume *= 0.5f * 2.5984480504799f;
1495 case HollowShape.Triangle:
1496 hollowVolume *= .5f * 1.27323954473516f;
1503 volume *= (1.0f - hollowVolume);
1508 case ProfileShape.HalfCircle:
1509 if (BaseShape.PathCurve == (byte)Extrusion.Curve1)
1511 volume *= 0.52359877559829887307710723054658f;
1515 case ProfileShape.EquilateralTriangle:
1517 if (BaseShape.PathCurve == (byte)Extrusion.Straight)
1519 volume *= 0.32475953f;
1521 if (hollowAmount > 0.0)
1525 switch (BaseShape.HollowShape)
1527 case HollowShape.Same:
1528 case HollowShape.Triangle:
1529 hollowVolume *= .25f;
1532 case HollowShape.Square:
1533 hollowVolume *= 0.499849f * 3.07920140172638f;
1536 case HollowShape.Circle:
1540 hollowVolume *= 0.1963495f * 3.07920140172638f;
1547 volume *= (1.0f - hollowVolume);
1550 else if (BaseShape.PathCurve == (byte)Extrusion.Curve1)
1552 volume *= 0.32475953f;
1553 volume *= 0.01f * (float)(200 - BaseShape.PathScaleX);
1554 tmp = 1.0f - .02f * (float)(200 - BaseShape.PathScaleY);
1555 volume *= (1.0f - tmp * tmp);
1557 if (hollowAmount > 0.0)
1560 hollowVolume *= hollowAmount;
1562 switch (BaseShape.HollowShape)
1564 case HollowShape.Same:
1565 case HollowShape.Triangle:
1566 hollowVolume *= .25f;
1569 case HollowShape.Square:
1570 hollowVolume *= 0.499849f * 3.07920140172638f;
1573 case HollowShape.Circle:
1575 hollowVolume *= 0.1963495f * 3.07920140172638f;
1582 volume *= (1.0f - hollowVolume);
1602 if (BaseShape.PathCurve == (byte)Extrusion.Straight || BaseShape.PathCurve == (byte)
Extrusion.Flexible)
1604 taperX1 = BaseShape.PathScaleX * 0.01f;
1606 taperX1 = 2.0f - taperX1;
1607 taperX = 1.0f - taperX1;
1609 taperY1 = BaseShape.PathScaleY * 0.01f;
1611 taperY1 = 2.0f - taperY1;
1612 taperY = 1.0f - taperY1;
1616 taperX = BaseShape.PathTaperX * 0.01f;
1619 taperX1 = 1.0f - taperX;
1621 taperY = BaseShape.PathTaperY * 0.01f;
1624 taperY1 = 1.0f - taperY;
1629 volume *= (taperX1 * taperY1 + 0.5f * (taperX1 * taperY + taperX * taperY1) + 0.3333333333f * taperX * taperY);
1631 pathBegin = (float)BaseShape.PathBegin * 2.0e-5f;
1632 pathEnd = 1.0f - (
float)BaseShape.PathEnd * 2.0e-5f;
1633 volume *= (pathEnd - pathBegin);
1636 profileBegin = (float)BaseShape.ProfileBegin * 2.0e-5f;
1637 profileEnd = 1.0f - (
float)BaseShape.ProfileEnd * 2.0e-5f;
1638 volume *= (profileEnd - profileBegin);
1640 returnMass = Density * BSParam.DensityScaleFactor * volume;
1642 returnMass = Util.Clamp(returnMass, BSParam.MinimumObjectMass, BSParam.MaximumObjectMass);
1644 DetailLog(
"{0},BSPrim.CalculateMass,den={1},vol={2},mass={3},pathB={4},pathE={5},profB={6},profE={7},siz={8}",
1645 LocalID, Density, volume, returnMass, pathBegin, pathEnd, profileBegin, profileEnd, _size);
1649 #endregion Mass Calculation
1659 PhysScene.Shapes.GetBodyAndShape(
false , PhysScene.World,
this, delegate(
BulletBody pBody,
BulletShape pShape)
1665 RemoveDependencies();
1669 UpdatePhysicalParameters();
1676 PhysicalActors.RemoveDependencies();
1680 public override object Extension(
string pFunct, params
object[] pParams)
1682 DetailLog(
"{0} BSPrim.Extension,op={1}", LocalID, pFunct);
1686 case ExtendedPhysics.PhysFunctAxisLockLimits:
1687 ret = SetAxisLockLimitsExtension(pParams);
1690 ret = base.Extension(pFunct, pParams);
1696 private void InitializeAxisActor()
1698 EnableActor(LockedAngularAxis != LockedAxisFree || LockedLinearAxis != LockedAxisFree,
1699 LockedAxisActorName, delegate()
1705 PhysScene.TaintedObject(LocalID,
"BSPrim.LockAxis", delegate()
1707 UpdatePhysicalParameters();
1714 private object SetAxisLockLimitsExtension(
object[] pParams)
1716 DetailLog(
"{0} SetAxisLockLimitsExtension. parmlen={1}", LocalID, pParams.GetLength(0));
1720 if (pParams.GetLength(0) > 1)
1723 while (index < pParams.GetLength(0))
1725 var funct = pParams[index];
1726 DetailLog(
"{0} SetAxisLockLimitsExtension. op={1}, index={2}", LocalID, funct, index);
1727 if (funct is Int32 || funct is Int64)
1732 case ExtendedPhysics.PHYS_AXIS_LOCK_LINEAR:
1733 case ExtendedPhysics.PHYS_AXIS_LOCK_LINEAR_X:
1734 case ExtendedPhysics.PHYS_AXIS_LOCK_LINEAR_Y:
1735 case ExtendedPhysics.PHYS_AXIS_LOCK_LINEAR_Z:
1736 case ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR:
1737 case ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_X:
1738 case ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_Y:
1739 case ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_Z:
1740 case ExtendedPhysics.PHYS_AXIS_UNLOCK_LINEAR:
1741 case ExtendedPhysics.PHYS_AXIS_UNLOCK_LINEAR_X:
1742 case ExtendedPhysics.PHYS_AXIS_UNLOCK_LINEAR_Y:
1743 case ExtendedPhysics.PHYS_AXIS_UNLOCK_LINEAR_Z:
1744 case ExtendedPhysics.PHYS_AXIS_UNLOCK_ANGULAR:
1745 case ExtendedPhysics.PHYS_AXIS_UNLOCK_ANGULAR_X:
1746 case ExtendedPhysics.PHYS_AXIS_UNLOCK_ANGULAR_Y:
1747 case ExtendedPhysics.PHYS_AXIS_UNLOCK_ANGULAR_Z:
1748 case ExtendedPhysics.PHYS_AXIS_UNLOCK:
1749 ApplyAxisLimits((
int)funct, 0f, 0f);
1753 case ExtendedPhysics.PHYS_AXIS_LIMIT_LINEAR_X:
1754 case ExtendedPhysics.PHYS_AXIS_LIMIT_LINEAR_Y:
1755 case ExtendedPhysics.PHYS_AXIS_LIMIT_LINEAR_Z:
1756 case ExtendedPhysics.PHYS_AXIS_LIMIT_ANGULAR_X:
1757 case ExtendedPhysics.PHYS_AXIS_LIMIT_ANGULAR_Y:
1758 case ExtendedPhysics.PHYS_AXIS_LIMIT_ANGULAR_Z:
1759 ApplyAxisLimits((
int)funct, (
float)pParams[index + 1], (
float)pParams[index + 2]);
1763 m_log.WarnFormat(
"{0} SetSxisLockLimitsExtension. Unknown op={1}", LogHeader, funct);
1769 InitializeAxisActor();
1770 ret = (object)index;
1775 m_log.WarnFormat(
"{0} SetSxisLockLimitsExtension exception in object {1}: {2}", LogHeader, this.Name, e);
1787 DetailLog(
"{0} ApplyAxisLimits. op={1}, low={2}, high={3}", LocalID, funct, low, high);
1788 float linearMax = 23000f;
1789 float angularMax = (float)Math.PI;
1793 case ExtendedPhysics.PHYS_AXIS_LOCK_LINEAR:
1794 this.LockedLinearAxis =
new OMV.Vector3(LockedAxis, LockedAxis, LockedAxis);
1795 this.LockedLinearAxisLow = OMV.Vector3.Zero;
1796 this.LockedLinearAxisHigh = OMV.Vector3.Zero;
1798 case ExtendedPhysics.PHYS_AXIS_LOCK_LINEAR_X:
1799 this.LockedLinearAxis.X = LockedAxis;
1800 this.LockedLinearAxisLow.X = 0f;
1801 this.LockedLinearAxisHigh.X = 0f;
1803 case ExtendedPhysics.PHYS_AXIS_LIMIT_LINEAR_X:
1804 this.LockedLinearAxis.X = LockedAxis;
1805 this.LockedLinearAxisLow.X = Util.Clip(low, -linearMax, linearMax);
1806 this.LockedLinearAxisHigh.X = Util.Clip(high, -linearMax, linearMax);
1808 case ExtendedPhysics.PHYS_AXIS_LOCK_LINEAR_Y:
1809 this.LockedLinearAxis.Y = LockedAxis;
1810 this.LockedLinearAxisLow.Y = 0f;
1811 this.LockedLinearAxisHigh.Y = 0f;
1813 case ExtendedPhysics.PHYS_AXIS_LIMIT_LINEAR_Y:
1814 this.LockedLinearAxis.Y = LockedAxis;
1815 this.LockedLinearAxisLow.Y = Util.Clip(low, -linearMax, linearMax);
1816 this.LockedLinearAxisHigh.Y = Util.Clip(high, -linearMax, linearMax);
1818 case ExtendedPhysics.PHYS_AXIS_LOCK_LINEAR_Z:
1819 this.LockedLinearAxis.Z = LockedAxis;
1820 this.LockedLinearAxisLow.Z = 0f;
1821 this.LockedLinearAxisHigh.Z = 0f;
1823 case ExtendedPhysics.PHYS_AXIS_LIMIT_LINEAR_Z:
1824 this.LockedLinearAxis.Z = LockedAxis;
1825 this.LockedLinearAxisLow.Z = Util.Clip(low, -linearMax, linearMax);
1826 this.LockedLinearAxisHigh.Z = Util.Clip(high, -linearMax, linearMax);
1828 case ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR:
1829 this.LockedAngularAxis =
new OMV.Vector3(LockedAxis, LockedAxis, LockedAxis);
1830 this.LockedAngularAxisLow = OMV.Vector3.Zero;
1831 this.LockedAngularAxisHigh = OMV.Vector3.Zero;
1833 case ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_X:
1834 this.LockedAngularAxis.X = LockedAxis;
1835 this.LockedAngularAxisLow.X = 0;
1836 this.LockedAngularAxisHigh.X = 0;
1838 case ExtendedPhysics.PHYS_AXIS_LIMIT_ANGULAR_X:
1839 this.LockedAngularAxis.X = LockedAxis;
1840 this.LockedAngularAxisLow.X = Util.Clip(low, -angularMax, angularMax);
1841 this.LockedAngularAxisHigh.X = Util.Clip(high, -angularMax, angularMax);
1843 case ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_Y:
1844 this.LockedAngularAxis.Y = LockedAxis;
1845 this.LockedAngularAxisLow.Y = 0;
1846 this.LockedAngularAxisHigh.Y = 0;
1848 case ExtendedPhysics.PHYS_AXIS_LIMIT_ANGULAR_Y:
1849 this.LockedAngularAxis.Y = LockedAxis;
1850 this.LockedAngularAxisLow.Y = Util.Clip(low, -angularMax, angularMax);
1851 this.LockedAngularAxisHigh.Y = Util.Clip(high, -angularMax, angularMax);
1853 case ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_Z:
1854 this.LockedAngularAxis.Z = LockedAxis;
1855 this.LockedAngularAxisLow.Z = 0;
1856 this.LockedAngularAxisHigh.Z = 0;
1858 case ExtendedPhysics.PHYS_AXIS_LIMIT_ANGULAR_Z:
1859 this.LockedAngularAxis.Z = LockedAxis;
1860 this.LockedAngularAxisLow.Z = Util.Clip(low, -angularMax, angularMax);
1861 this.LockedAngularAxisHigh.Z = Util.Clip(high, -angularMax, angularMax);
1863 case ExtendedPhysics.PHYS_AXIS_UNLOCK_LINEAR:
1864 this.LockedLinearAxis = LockedAxisFree;
1865 this.LockedLinearAxisLow =
new OMV.Vector3(-linearMax, -linearMax, -linearMax);
1866 this.LockedLinearAxisHigh =
new OMV.Vector3(linearMax, linearMax, linearMax);
1868 case ExtendedPhysics.PHYS_AXIS_UNLOCK_LINEAR_X:
1869 this.LockedLinearAxis.X = FreeAxis;
1870 this.LockedLinearAxisLow.X = -linearMax;
1871 this.LockedLinearAxisHigh.X = linearMax;
1873 case ExtendedPhysics.PHYS_AXIS_UNLOCK_LINEAR_Y:
1874 this.LockedLinearAxis.Y = FreeAxis;
1875 this.LockedLinearAxisLow.Y = -linearMax;
1876 this.LockedLinearAxisHigh.Y = linearMax;
1878 case ExtendedPhysics.PHYS_AXIS_UNLOCK_LINEAR_Z:
1879 this.LockedLinearAxis.Z = FreeAxis;
1880 this.LockedLinearAxisLow.Z = -linearMax;
1881 this.LockedLinearAxisHigh.Z = linearMax;
1883 case ExtendedPhysics.PHYS_AXIS_UNLOCK_ANGULAR:
1884 this.LockedAngularAxis = LockedAxisFree;
1885 this.LockedAngularAxisLow =
new OMV.Vector3(-angularMax, -angularMax, -angularMax);
1886 this.LockedAngularAxisHigh =
new OMV.Vector3(angularMax, angularMax, angularMax);
1888 case ExtendedPhysics.PHYS_AXIS_UNLOCK_ANGULAR_X:
1889 this.LockedAngularAxis.X = FreeAxis;
1890 this.LockedAngularAxisLow.X = -angularMax;
1891 this.LockedAngularAxisHigh.X = angularMax;
1893 case ExtendedPhysics.PHYS_AXIS_UNLOCK_ANGULAR_Y:
1894 this.LockedAngularAxis.Y = FreeAxis;
1895 this.LockedAngularAxisLow.Y = -angularMax;
1896 this.LockedAngularAxisHigh.Y = angularMax;
1898 case ExtendedPhysics.PHYS_AXIS_UNLOCK_ANGULAR_Z:
1899 this.LockedAngularAxis.Z = FreeAxis;
1900 this.LockedAngularAxisLow.Z = -angularMax;
1901 this.LockedAngularAxisHigh.Z = angularMax;
1903 case ExtendedPhysics.PHYS_AXIS_UNLOCK:
1912 #endregion // Extension
1921 TriggerPreUpdatePropertyAction(ref entprop);
1926 RawPosition = entprop.Position;
1927 RawOrientation = entprop.Rotation;
1930 if (entprop.Velocity ==
OMV.Vector3.Zero || !entprop.Velocity.ApproxEquals(RawVelocity, BSParam.UpdateVelocityChangeThreshold))
1931 RawVelocity = entprop.Velocity;
1932 _acceleration = entprop.Acceleration;
1933 _rotationalVelocity = entprop.RotationalVelocity;
1938 if (PositionSanityCheck(
true ))
1940 entprop.Position = RawPosition;
1941 entprop.Velocity = RawVelocity;
1942 entprop.RotationalVelocity = _rotationalVelocity;
1943 entprop.Acceleration = _acceleration;
1946 OMV.Vector3 direction = OMV.Vector3.UnitX * RawOrientation;
1947 DetailLog(
"{0},BSPrim.UpdateProperties,call,entProp={1},dir={2}", LocalID, entprop, direction);
1950 LastEntityProperties = CurrentEntityProperties;
1951 CurrentEntityProperties = entprop;
1953 PhysScene.PostUpdate(
this);
override void LockAngularMotion(byte axislocks)
override void ZeroAngularMotion(bool inTaintTime)
const int PHYS_AXIS_LOCK_ANGULAR_Z
override void VehicleVectorParam(int param, OMV.Vector3 value)
void ApplyTorqueImpulse(OMV.Vector3 impulse, bool inTaintTime)
static string PrimitiveBaseShapeToString(PrimitiveBaseShape pbs)
delegate void SetAlwaysRun(IClientAPI remoteClient, bool SetAlwaysRun)
Each physical object can have 'actors' who are pushing the object around. This can be used for hover...
override void ZeroMotion(bool inTaintTime)
override void SetVolumeDetect(int param)
Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more ...
override void UpdateProperties(EntityProperties entprop)
BSDynamics GetVehicleActor(bool createIfNone)
override void VehicleFlags(int param, bool remove)
override void VehicleFloatParam(int param, float value)
virtual void MakeDynamic(bool makeStatic)
void CreateGeomAndObject(bool forceRebuild)
OMV.Vector3 ComputeGravity(float buoyancy)
BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
const int PHYS_AXIS_UNLOCK_ANGULAR
OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion rotation
override void SetMomentum(OMV.Vector3 momentum)
override void CrossingFailure()
void AddForceImpulse(OMV.Vector3 impulse, bool pushforce, bool inTaintTime)
override void AddAngularForce(bool inTaintTime, OMV.Vector3 force)
override void VehicleRotationParam(int param, OMV.Quaternion rotation)
void ApplyAxisLimits(int funct, float low, float high)
const int PHYS_AXIS_UNLOCK_LINEAR
virtual void RemoveDependencies()
override object Extension(string pFunct, params object[] pParams)
override void AddForce(OMV.Vector3 force, bool pushforce)
override void SetVehicle(object pvdata)
const int PHYS_AXIS_LOCK_ANGULAR_Y
override void UpdatePhysicalMassProperties(float physMass, bool inWorld)
override void link(PhysicsActor obj)
virtual void UpdatePhysicalParameters()
const int PHYS_AXIS_LOCK_ANGULAR_X
override void SetMaterial(int material)
override void AddForce(bool inTaintTime, OMV.Vector3 force)
override bool ForceBodyShapeRebuild(bool inTaintTime)