diff options
Diffstat (limited to 'OpenSim/Region/Physics')
17 files changed, 1333 insertions, 1026 deletions
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs index 25b9099..5e2eeeb 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs | |||
@@ -184,17 +184,12 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
184 | { | 184 | { |
185 | 185 | ||
186 | } | 186 | } |
187 | |||
188 | public override void VehicleFlagsSet(int flags) | ||
189 | { | ||
190 | 187 | ||
191 | } | 188 | public override void VehicleFlags(int param, bool remove) |
192 | |||
193 | public override void VehicleFlagsRemove(int flags) | ||
194 | { | 189 | { |
195 | 190 | ||
196 | } | 191 | } |
197 | 192 | ||
198 | public override void SetVolumeDetect(int param) | 193 | public override void SetVolumeDetect(int param) |
199 | { | 194 | { |
200 | 195 | ||
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs index 120d040..198962b 100644 --- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs +++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs | |||
@@ -361,17 +361,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin | |||
361 | { | 361 | { |
362 | 362 | ||
363 | } | 363 | } |
364 | |||
365 | public override void VehicleFlagsSet(int flags) | ||
366 | { | ||
367 | 364 | ||
368 | } | 365 | public override void VehicleFlags(int param, bool remove) |
369 | |||
370 | public override void VehicleFlagsRemove(int flags) | ||
371 | { | 366 | { |
372 | 367 | ||
373 | } | 368 | } |
374 | 369 | ||
375 | public override void SetVolumeDetect(int param) | 370 | public override void SetVolumeDetect(int param) |
376 | { | 371 | { |
377 | 372 | ||
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs index f430def..920ed96 100644 --- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs +++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs | |||
@@ -396,17 +396,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin | |||
396 | { | 396 | { |
397 | //TODO: | 397 | //TODO: |
398 | } | 398 | } |
399 | |||
400 | public override void VehicleFlagsSet(int flags) | ||
401 | { | ||
402 | 399 | ||
403 | } | 400 | public override void VehicleFlags(int param, bool remove) |
404 | |||
405 | public override void VehicleFlagsRemove(int flags) | ||
406 | { | 401 | { |
407 | 402 | ||
408 | } | 403 | } |
409 | 404 | ||
410 | public override void SetVolumeDetect(int param) | 405 | public override void SetVolumeDetect(int param) |
411 | { | 406 | { |
412 | //TODO: GhostObject | 407 | //TODO: GhostObject |
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index 9113ebe..f4245b6 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs | |||
@@ -500,6 +500,18 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
500 | public BulletXScene(String sceneIdentifier) | 500 | public BulletXScene(String sceneIdentifier) |
501 | { | 501 | { |
502 | //identifier = sceneIdentifier; | 502 | //identifier = sceneIdentifier; |
503 | cDispatcher = new CollisionDispatcherLocal(this); | ||
504 | Vector3 worldMinDim = new Vector3((float)minXY, (float)minXY, (float)minZ); | ||
505 | Vector3 worldMaxDim = new Vector3((float)maxXY, (float)maxXY, (float)maxZ); | ||
506 | opCache = new AxisSweep3(worldMinDim, worldMaxDim, maxHandles); | ||
507 | sicSolver = new SequentialImpulseConstraintSolver(); | ||
508 | |||
509 | lock (BulletXLock) | ||
510 | { | ||
511 | ddWorld = new DiscreteDynamicsWorld(cDispatcher, opCache, sicSolver); | ||
512 | ddWorld.Gravity = new Vector3(0, 0, -gravity); | ||
513 | } | ||
514 | //this._heightmap = new float[65536]; | ||
503 | } | 515 | } |
504 | 516 | ||
505 | public static float Gravity | 517 | public static float Gravity |
@@ -582,12 +594,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
582 | pos.Y = position.Y; | 594 | pos.Y = position.Y; |
583 | pos.Z = position.Z + 20; | 595 | pos.Z = position.Z + 20; |
584 | BulletXCharacter newAv = null; | 596 | BulletXCharacter newAv = null; |
585 | newAv.Flying = isFlying; | ||
586 | lock (BulletXLock) | 597 | lock (BulletXLock) |
587 | { | 598 | { |
588 | newAv = new BulletXCharacter(avName, this, pos); | 599 | newAv = new BulletXCharacter(avName, this, pos); |
589 | _characters.Add(newAv.RigidBody, newAv); | 600 | _characters.Add(newAv.RigidBody, newAv); |
590 | } | 601 | } |
602 | newAv.Flying = isFlying; | ||
591 | return newAv; | 603 | return newAv; |
592 | } | 604 | } |
593 | 605 | ||
@@ -984,17 +996,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
984 | { | 996 | { |
985 | 997 | ||
986 | } | 998 | } |
987 | |||
988 | public override void VehicleFlagsSet(int flags) | ||
989 | { | ||
990 | 999 | ||
991 | } | 1000 | public override void VehicleFlags(int param, bool remove) |
992 | |||
993 | public override void VehicleFlagsRemove(int flags) | ||
994 | { | 1001 | { |
995 | 1002 | ||
996 | } | 1003 | } |
997 | 1004 | ||
998 | public override void SetVolumeDetect(int param) | 1005 | public override void SetVolumeDetect(int param) |
999 | { | 1006 | { |
1000 | 1007 | ||
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs index 2eb519f..8e87ad9 100644 --- a/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs | |||
@@ -734,16 +734,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
734 | 734 | ||
735 | } | 735 | } |
736 | 736 | ||
737 | public override void VehicleFlagsSet(int flags) | 737 | public override void VehicleFlags(int flags, bool remove) |
738 | { | 738 | { |
739 | |||
740 | } | 739 | } |
741 | |||
742 | public override void VehicleFlagsRemove(int flags) | ||
743 | { | ||
744 | 740 | ||
745 | } | ||
746 | |||
747 | public override void SetVolumeDetect(int param) | 741 | public override void SetVolumeDetect(int param) |
748 | { | 742 | { |
749 | 743 | ||
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs index 5d24388..e51ef5b 100644 --- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs | |||
@@ -344,7 +344,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
344 | { | 344 | { |
345 | set { | 345 | set { |
346 | 346 | ||
347 | Console.WriteLine("Sel {0} {1} {2}", m_primName, value, m_isphysical); | 347 | //Console.WriteLine("Sel {0} {1} {2}", m_primName, value, m_isphysical); |
348 | // This only makes the object not collidable if the object | 348 | // This only makes the object not collidable if the object |
349 | // is physical or the object is modified somehow *IN THE FUTURE* | 349 | // is physical or the object is modified somehow *IN THE FUTURE* |
350 | // without this, if an avatar selects prim, they can walk right | 350 | // without this, if an avatar selects prim, they can walk right |
@@ -486,15 +486,10 @@ Console.WriteLine("Sel {0} {1} {2}", m_primName, value, m_isphysical); | |||
486 | { | 486 | { |
487 | ProcessRotationVehicleParam((Vehicle) param, rotation); | 487 | ProcessRotationVehicleParam((Vehicle) param, rotation); |
488 | } | 488 | } |
489 | 489 | ||
490 | public override void VehicleFlagsSet(int flags) | 490 | public override void VehicleFlags(int param, bool remove) |
491 | { | ||
492 | ProcessFlagsVehicleSet(flags); | ||
493 | } | ||
494 | |||
495 | public override void VehicleFlagsRemove(int flags) | ||
496 | { | 491 | { |
497 | ProcessFlagsVehicleRemove(flags); | 492 | ProcessVehicleFlags(param, remove); |
498 | } | 493 | } |
499 | 494 | ||
500 | public override void SetVolumeDetect(int param) | 495 | public override void SetVolumeDetect(int param) |
@@ -2425,8 +2420,9 @@ Console.WriteLine(" JointCreateFixed"); | |||
2425 | public void UpdatePositionAndVelocity() | 2420 | public void UpdatePositionAndVelocity() |
2426 | { | 2421 | { |
2427 | return; // moved to the MOVE() method | 2422 | return; // moved to the MOVE() method |
2423 | } | ||
2428 | // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! | 2424 | // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! |
2429 | if (_parent == null) | 2425 | /* if (_parent == null) |
2430 | { | 2426 | { |
2431 | Vector3 pv = Vector3.Zero; | 2427 | Vector3 pv = Vector3.Zero; |
2432 | bool lastZeroFlag = _zeroFlag; | 2428 | bool lastZeroFlag = _zeroFlag; |
@@ -2635,7 +2631,7 @@ Console.WriteLine(" JointCreateFixed"); | |||
2635 | } | 2631 | } |
2636 | } | 2632 | } |
2637 | } | 2633 | } |
2638 | 2634 | */ | |
2639 | public Matrix4 FromDMass(d.Mass pMass) | 2635 | public Matrix4 FromDMass(d.Mass pMass) |
2640 | { | 2636 | { |
2641 | Matrix4 obj; | 2637 | Matrix4 obj; |
@@ -2682,7 +2678,7 @@ Console.WriteLine(" JointCreateFixed"); | |||
2682 | { | 2678 | { |
2683 | _parent_scene.remCollisionEventReporting(this); | 2679 | _parent_scene.remCollisionEventReporting(this); |
2684 | m_eventsubscription = 0; | 2680 | m_eventsubscription = 0; |
2685 | } | 2681 | } |
2686 | 2682 | ||
2687 | public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) | 2683 | public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) |
2688 | { | 2684 | { |
@@ -3038,15 +3034,17 @@ Console.WriteLine(" JointCreateFixed"); | |||
3038 | } | 3034 | } |
3039 | 3035 | ||
3040 | }//end ProcessRotationVehicleParam | 3036 | }//end ProcessRotationVehicleParam |
3041 | 3037 | ||
3042 | internal void ProcessFlagsVehicleSet(int flags) | 3038 | internal void ProcessVehicleFlags(int pParam, bool remove) |
3043 | { | ||
3044 | m_flags |= (VehicleFlag)flags; | ||
3045 | } | ||
3046 | |||
3047 | internal void ProcessFlagsVehicleRemove(int flags) | ||
3048 | { | 3039 | { |
3049 | m_flags &= ~((VehicleFlag)flags); | 3040 | if (remove) |
3041 | { | ||
3042 | m_flags &= ~((VehicleFlag)pParam); | ||
3043 | } | ||
3044 | else | ||
3045 | { | ||
3046 | m_flags |= (VehicleFlag)pParam; | ||
3047 | } | ||
3050 | } | 3048 | } |
3051 | 3049 | ||
3052 | internal void ProcessTypeChange(Vehicle pType) | 3050 | internal void ProcessTypeChange(Vehicle pType) |
@@ -3253,7 +3251,7 @@ Console.WriteLine(" JointCreateFixed"); | |||
3253 | d.Vector3 vec = d.BodyGetPosition(Body); | 3251 | d.Vector3 vec = d.BodyGetPosition(Body); |
3254 | d.Quaternion ori = d.BodyGetQuaternion(Body); | 3252 | d.Quaternion ori = d.BodyGetQuaternion(Body); |
3255 | d.Vector3 vel = d.BodyGetLinearVel(Body); | 3253 | d.Vector3 vel = d.BodyGetLinearVel(Body); |
3256 | d.Vector3 rotvel = d.BodyGetAngularVel(Body); | 3254 | // d.Vector3 rotvel = d.BodyGetAngularVel(Body); |
3257 | d.Vector3 torque = d.BodyGetTorque(Body); | 3255 | d.Vector3 torque = d.BodyGetTorque(Body); |
3258 | _torque = new Vector3(torque.X, torque.Y, torque.Z); | 3256 | _torque = new Vector3(torque.X, torque.Y, torque.Z); |
3259 | Vector3 l_position = Vector3.Zero; | 3257 | Vector3 l_position = Vector3.Zero; |
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index f43de48..880c3ea 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs | |||
@@ -208,8 +208,7 @@ namespace OpenSim.Region.Physics.Manager | |||
208 | public abstract void VehicleFloatParam(int param, float value); | 208 | public abstract void VehicleFloatParam(int param, float value); |
209 | public abstract void VehicleVectorParam(int param, Vector3 value); | 209 | public abstract void VehicleVectorParam(int param, Vector3 value); |
210 | public abstract void VehicleRotationParam(int param, Quaternion rotation); | 210 | public abstract void VehicleRotationParam(int param, Quaternion rotation); |
211 | public abstract void VehicleFlagsSet(int flags); | 211 | public abstract void VehicleFlags(int param, bool remove); |
212 | public abstract void VehicleFlagsRemove(int flags); | ||
213 | 212 | ||
214 | public abstract void SetVolumeDetect(int param); // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more | 213 | public abstract void SetVolumeDetect(int param); // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more |
215 | 214 | ||
@@ -353,17 +352,12 @@ namespace OpenSim.Region.Physics.Manager | |||
353 | { | 352 | { |
354 | 353 | ||
355 | } | 354 | } |
356 | |||
357 | public override void VehicleFlagsSet(int flags) | ||
358 | { | ||
359 | 355 | ||
360 | } | 356 | public override void VehicleFlags(int param, bool remove) |
361 | |||
362 | public override void VehicleFlagsRemove(int flags) | ||
363 | { | 357 | { |
364 | 358 | ||
365 | } | 359 | } |
366 | 360 | ||
367 | public override void SetVolumeDetect(int param) | 361 | public override void SetVolumeDetect(int param) |
368 | { | 362 | { |
369 | 363 | ||
diff --git a/OpenSim/Region/Physics/Manager/VehicleConstants.cs b/OpenSim/Region/Physics/Manager/VehicleConstants.cs index 532e55e..f0775c1 100644 --- a/OpenSim/Region/Physics/Manager/VehicleConstants.cs +++ b/OpenSim/Region/Physics/Manager/VehicleConstants.cs | |||
@@ -91,7 +91,9 @@ namespace OpenSim.Region.Physics.Manager | |||
91 | BANKING_EFFICIENCY = 38, | 91 | BANKING_EFFICIENCY = 38, |
92 | BANKING_MIX = 39, | 92 | BANKING_MIX = 39, |
93 | BANKING_TIMESCALE = 40, | 93 | BANKING_TIMESCALE = 40, |
94 | REFERENCE_FRAME = 44 | 94 | REFERENCE_FRAME = 44, |
95 | BLOCK_EXIT = 45, | ||
96 | ROLL_FRAME = 46 | ||
95 | 97 | ||
96 | } | 98 | } |
97 | 99 | ||
@@ -107,7 +109,13 @@ namespace OpenSim.Region.Physics.Manager | |||
107 | LIMIT_MOTOR_UP = 64, | 109 | LIMIT_MOTOR_UP = 64, |
108 | MOUSELOOK_STEER = 128, | 110 | MOUSELOOK_STEER = 128, |
109 | MOUSELOOK_BANK = 256, | 111 | MOUSELOOK_BANK = 256, |
110 | CAMERA_DECOUPLED = 512 | 112 | CAMERA_DECOUPLED = 512, |
113 | NO_X = 1024, | ||
114 | NO_Y = 2048, | ||
115 | NO_Z = 4096, | ||
116 | LOCK_HOVER_HEIGHT = 8192, | ||
117 | NO_DEFLECTION = 16392, | ||
118 | LOCK_ROTATION = 32784 | ||
111 | } | 119 | } |
112 | 120 | ||
113 | } | 121 | } |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index b713142..2a66060 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | |||
@@ -733,17 +733,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
733 | { | 733 | { |
734 | 734 | ||
735 | } | 735 | } |
736 | |||
737 | public override void VehicleFlagsSet(int flags) | ||
738 | { | ||
739 | 736 | ||
740 | } | 737 | public override void VehicleFlags(int param, bool remove) |
741 | |||
742 | public override void VehicleFlagsRemove(int flags) | ||
743 | { | 738 | { |
744 | 739 | ||
745 | } | 740 | } |
746 | 741 | ||
747 | public override void SetVolumeDetect(int param) | 742 | public override void SetVolumeDetect(int param) |
748 | { | 743 | { |
749 | 744 | ||
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs index 008070b..9beeabb 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs | |||
@@ -72,37 +72,40 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
72 | 72 | ||
73 | 73 | ||
74 | // Vehicle properties | 74 | // Vehicle properties |
75 | private Vehicle m_type = Vehicle.TYPE_NONE; // If a 'VEHICLE', and what kind | 75 | private Vehicle m_type = Vehicle.TYPE_NONE; // If a 'VEHICLE', and what kind |
76 | // private Quaternion m_referenceFrame = Quaternion.Identity; // Axis modifier | 76 | // private Quaternion m_referenceFrame = Quaternion.Identity; // Axis modifier |
77 | private VehicleFlag m_flags = (VehicleFlag) 0; // Boolean settings: | 77 | private VehicleFlag m_flags = (VehicleFlag) 0; // Boolean settings: |
78 | // HOVER_TERRAIN_ONLY | 78 | // HOVER_TERRAIN_ONLY |
79 | // HOVER_GLOBAL_HEIGHT | 79 | // HOVER_GLOBAL_HEIGHT |
80 | // NO_DEFLECTION_UP | 80 | // NO_DEFLECTION_UP |
81 | // HOVER_WATER_ONLY | 81 | // HOVER_WATER_ONLY |
82 | // HOVER_UP_ONLY | 82 | // HOVER_UP_ONLY |
83 | // LIMIT_MOTOR_UP | 83 | // LIMIT_MOTOR_UP |
84 | // LIMIT_ROLL_ONLY | 84 | // LIMIT_ROLL_ONLY |
85 | 85 | private VehicleFlag m_Hoverflags = (VehicleFlag)0; | |
86 | private Vector3 m_BlockingEndPoint = Vector3.Zero; | ||
87 | private Quaternion m_RollreferenceFrame = Quaternion.Identity; | ||
86 | // Linear properties | 88 | // Linear properties |
87 | private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time | 89 | private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time |
88 | private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero; // velocity requested by LSL | 90 | private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero; // velocity requested by LSL |
89 | private Vector3 m_dir = Vector3.Zero; // velocity applied to body | 91 | private Vector3 m_dir = Vector3.Zero; // velocity applied to body |
90 | private Vector3 m_linearFrictionTimescale = Vector3.Zero; | 92 | private Vector3 m_linearFrictionTimescale = Vector3.Zero; |
91 | private float m_linearMotorDecayTimescale = 0; | 93 | private float m_linearMotorDecayTimescale = 0; |
92 | private float m_linearMotorTimescale = 0; | 94 | private float m_linearMotorTimescale = 0; |
93 | private Vector3 m_lastLinearVelocityVector = Vector3.Zero; | 95 | private Vector3 m_lastLinearVelocityVector = Vector3.Zero; |
96 | private d.Vector3 m_lastPositionVector = new d.Vector3(); | ||
94 | // private bool m_LinearMotorSetLastFrame = false; | 97 | // private bool m_LinearMotorSetLastFrame = false; |
95 | // private Vector3 m_linearMotorOffset = Vector3.Zero; | 98 | // private Vector3 m_linearMotorOffset = Vector3.Zero; |
96 | 99 | ||
97 | //Angular properties | 100 | //Angular properties |
98 | private Vector3 m_angularMotorDirection = Vector3.Zero; // angular velocity requested by LSL motor | 101 | private Vector3 m_angularMotorDirection = Vector3.Zero; // angular velocity requested by LSL motor |
99 | private int m_angularMotorApply = 0; // application frame counter | 102 | private int m_angularMotorApply = 0; // application frame counter |
100 | private Vector3 m_angularMotorVelocity = Vector3.Zero; // current angular motor velocity | 103 | private Vector3 m_angularMotorVelocity = Vector3.Zero; // current angular motor velocity |
101 | private float m_angularMotorTimescale = 0; // motor angular velocity ramp up rate | 104 | private float m_angularMotorTimescale = 0; // motor angular velocity ramp up rate |
102 | private float m_angularMotorDecayTimescale = 0; // motor angular velocity decay rate | 105 | private float m_angularMotorDecayTimescale = 0; // motor angular velocity decay rate |
103 | private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate | 106 | private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate |
104 | private Vector3 m_lastAngularVelocity = Vector3.Zero; // what was last applied to body | 107 | private Vector3 m_lastAngularVelocity = Vector3.Zero; // what was last applied to body |
105 | // private Vector3 m_lastVertAttractor = Vector3.Zero; // what VA was last applied to body | 108 | // private Vector3 m_lastVertAttractor = Vector3.Zero; // what VA was last applied to body |
106 | 109 | ||
107 | //Deflection properties | 110 | //Deflection properties |
108 | // private float m_angularDeflectionEfficiency = 0; | 111 | // private float m_angularDeflectionEfficiency = 0; |
@@ -120,14 +123,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
120 | // private float m_VhoverEfficiency = 0f; | 123 | // private float m_VhoverEfficiency = 0f; |
121 | private float m_VhoverTimescale = 0f; | 124 | private float m_VhoverTimescale = 0f; |
122 | private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height | 125 | private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height |
123 | private float m_VehicleBuoyancy = 0f; //KF: m_VehicleBuoyancy is set by VEHICLE_BUOYANCY for a vehicle. | 126 | private float m_VehicleBuoyancy = 0f; //KF: m_VehicleBuoyancy is set by VEHICLE_BUOYANCY for a vehicle. |
124 | // Modifies gravity. Slider between -1 (double-gravity) and 1 (full anti-gravity) | 127 | // Modifies gravity. Slider between -1 (double-gravity) and 1 (full anti-gravity) |
125 | // KF: So far I have found no good method to combine a script-requested .Z velocity and gravity. | 128 | // KF: So far I have found no good method to combine a script-requested .Z velocity and gravity. |
126 | // Therefore only m_VehicleBuoyancy=1 (0g) will use the script-requested .Z velocity. | 129 | // Therefore only m_VehicleBuoyancy=1 (0g) will use the script-requested .Z velocity. |
127 | 130 | ||
128 | //Attractor properties | 131 | //Attractor properties |
129 | private float m_verticalAttractionEfficiency = 1.0f; // damped | 132 | private float m_verticalAttractionEfficiency = 1.0f; // damped |
130 | private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor. | 133 | private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor. |
131 | 134 | ||
132 | internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue) | 135 | internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue) |
133 | { | 136 | { |
@@ -255,6 +258,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
255 | case Vehicle.LINEAR_MOTOR_OFFSET: | 258 | case Vehicle.LINEAR_MOTOR_OFFSET: |
256 | // m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z); | 259 | // m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z); |
257 | break; | 260 | break; |
261 | case Vehicle.BLOCK_EXIT: | ||
262 | m_BlockingEndPoint = new Vector3(pValue.X, pValue.Y, pValue.Z); | ||
263 | break; | ||
258 | } | 264 | } |
259 | }//end ProcessVectorVehicleParam | 265 | }//end ProcessVectorVehicleParam |
260 | 266 | ||
@@ -265,15 +271,189 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
265 | case Vehicle.REFERENCE_FRAME: | 271 | case Vehicle.REFERENCE_FRAME: |
266 | // m_referenceFrame = pValue; | 272 | // m_referenceFrame = pValue; |
267 | break; | 273 | break; |
274 | case Vehicle.ROLL_FRAME: | ||
275 | m_RollreferenceFrame = pValue; | ||
276 | break; | ||
268 | } | 277 | } |
269 | }//end ProcessRotationVehicleParam | 278 | }//end ProcessRotationVehicleParam |
270 | 279 | ||
280 | internal void ProcessVehicleFlags(int pParam, bool remove) | ||
281 | { | ||
282 | if (remove) | ||
283 | { | ||
284 | if (pParam == -1) | ||
285 | { | ||
286 | m_flags = (VehicleFlag)0; | ||
287 | m_Hoverflags = (VehicleFlag)0; | ||
288 | return; | ||
289 | } | ||
290 | if ((pParam & (int)VehicleFlag.HOVER_GLOBAL_HEIGHT) == (int)VehicleFlag.HOVER_GLOBAL_HEIGHT) | ||
291 | { | ||
292 | if ((m_Hoverflags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != (VehicleFlag)0) | ||
293 | m_Hoverflags &= ~(VehicleFlag.HOVER_GLOBAL_HEIGHT); | ||
294 | } | ||
295 | if ((pParam & (int)VehicleFlag.HOVER_TERRAIN_ONLY) == (int)VehicleFlag.HOVER_TERRAIN_ONLY) | ||
296 | { | ||
297 | if ((m_Hoverflags & VehicleFlag.HOVER_TERRAIN_ONLY) != (VehicleFlag)0) | ||
298 | m_Hoverflags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY); | ||
299 | } | ||
300 | if ((pParam & (int)VehicleFlag.HOVER_UP_ONLY) == (int)VehicleFlag.HOVER_UP_ONLY) | ||
301 | { | ||
302 | if ((m_Hoverflags & VehicleFlag.HOVER_UP_ONLY) != (VehicleFlag)0) | ||
303 | m_Hoverflags &= ~(VehicleFlag.HOVER_UP_ONLY); | ||
304 | } | ||
305 | if ((pParam & (int)VehicleFlag.HOVER_WATER_ONLY) == (int)VehicleFlag.HOVER_WATER_ONLY) | ||
306 | { | ||
307 | if ((m_Hoverflags & VehicleFlag.HOVER_WATER_ONLY) != (VehicleFlag)0) | ||
308 | m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY); | ||
309 | } | ||
310 | if ((pParam & (int)VehicleFlag.LIMIT_MOTOR_UP) == (int)VehicleFlag.LIMIT_MOTOR_UP) | ||
311 | { | ||
312 | if ((m_flags & VehicleFlag.LIMIT_MOTOR_UP) != (VehicleFlag)0) | ||
313 | m_flags &= ~(VehicleFlag.LIMIT_MOTOR_UP); | ||
314 | } | ||
315 | if ((pParam & (int)VehicleFlag.LIMIT_ROLL_ONLY) == (int)VehicleFlag.LIMIT_ROLL_ONLY) | ||
316 | { | ||
317 | if ((m_flags & VehicleFlag.LIMIT_ROLL_ONLY) != (VehicleFlag)0) | ||
318 | m_flags &= ~(VehicleFlag.LIMIT_ROLL_ONLY); | ||
319 | } | ||
320 | if ((pParam & (int)VehicleFlag.MOUSELOOK_BANK) == (int)VehicleFlag.MOUSELOOK_BANK) | ||
321 | { | ||
322 | if ((m_flags & VehicleFlag.MOUSELOOK_BANK) != (VehicleFlag)0) | ||
323 | m_flags &= ~(VehicleFlag.MOUSELOOK_BANK); | ||
324 | } | ||
325 | if ((pParam & (int)VehicleFlag.MOUSELOOK_STEER) == (int)VehicleFlag.MOUSELOOK_STEER) | ||
326 | { | ||
327 | if ((m_flags & VehicleFlag.MOUSELOOK_STEER) != (VehicleFlag)0) | ||
328 | m_flags &= ~(VehicleFlag.MOUSELOOK_STEER); | ||
329 | } | ||
330 | if ((pParam & (int)VehicleFlag.NO_DEFLECTION_UP) == (int)VehicleFlag.NO_DEFLECTION_UP) | ||
331 | { | ||
332 | if ((m_flags & VehicleFlag.NO_DEFLECTION_UP) != (VehicleFlag)0) | ||
333 | m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP); | ||
334 | } | ||
335 | if ((pParam & (int)VehicleFlag.CAMERA_DECOUPLED) == (int)VehicleFlag.CAMERA_DECOUPLED) | ||
336 | { | ||
337 | if ((m_flags & VehicleFlag.CAMERA_DECOUPLED) != (VehicleFlag)0) | ||
338 | m_flags &= ~(VehicleFlag.CAMERA_DECOUPLED); | ||
339 | } | ||
340 | if ((pParam & (int)VehicleFlag.NO_X) == (int)VehicleFlag.NO_X) | ||
341 | { | ||
342 | if ((m_flags & VehicleFlag.NO_X) != (VehicleFlag)0) | ||
343 | m_flags &= ~(VehicleFlag.NO_X); | ||
344 | } | ||
345 | if ((pParam & (int)VehicleFlag.NO_Y) == (int)VehicleFlag.NO_Y) | ||
346 | { | ||
347 | if ((m_flags & VehicleFlag.NO_Y) != (VehicleFlag)0) | ||
348 | m_flags &= ~(VehicleFlag.NO_Y); | ||
349 | } | ||
350 | if ((pParam & (int)VehicleFlag.NO_Z) == (int)VehicleFlag.NO_Z) | ||
351 | { | ||
352 | if ((m_flags & VehicleFlag.NO_Z) != (VehicleFlag)0) | ||
353 | m_flags &= ~(VehicleFlag.NO_Z); | ||
354 | } | ||
355 | if ((pParam & (int)VehicleFlag.LOCK_HOVER_HEIGHT) == (int)VehicleFlag.LOCK_HOVER_HEIGHT) | ||
356 | { | ||
357 | if ((m_Hoverflags & VehicleFlag.LOCK_HOVER_HEIGHT) != (VehicleFlag)0) | ||
358 | m_Hoverflags &= ~(VehicleFlag.LOCK_HOVER_HEIGHT); | ||
359 | } | ||
360 | if ((pParam & (int)VehicleFlag.NO_DEFLECTION) == (int)VehicleFlag.NO_DEFLECTION) | ||
361 | { | ||
362 | if ((m_flags & VehicleFlag.NO_DEFLECTION) != (VehicleFlag)0) | ||
363 | m_flags &= ~(VehicleFlag.NO_DEFLECTION); | ||
364 | } | ||
365 | if ((pParam & (int)VehicleFlag.LOCK_ROTATION) == (int)VehicleFlag.LOCK_ROTATION) | ||
366 | { | ||
367 | if ((m_flags & VehicleFlag.LOCK_ROTATION) != (VehicleFlag)0) | ||
368 | m_flags &= ~(VehicleFlag.LOCK_ROTATION); | ||
369 | } | ||
370 | } | ||
371 | else | ||
372 | { | ||
373 | if ((pParam & (int)VehicleFlag.HOVER_GLOBAL_HEIGHT) == (int)VehicleFlag.HOVER_GLOBAL_HEIGHT) | ||
374 | { | ||
375 | m_Hoverflags |= (VehicleFlag.HOVER_GLOBAL_HEIGHT | m_flags); | ||
376 | } | ||
377 | if ((pParam & (int)VehicleFlag.HOVER_TERRAIN_ONLY) == (int)VehicleFlag.HOVER_TERRAIN_ONLY) | ||
378 | { | ||
379 | m_Hoverflags |= (VehicleFlag.HOVER_TERRAIN_ONLY | m_flags); | ||
380 | } | ||
381 | if ((pParam & (int)VehicleFlag.HOVER_UP_ONLY) == (int)VehicleFlag.HOVER_UP_ONLY) | ||
382 | { | ||
383 | m_Hoverflags |= (VehicleFlag.HOVER_UP_ONLY | m_flags); | ||
384 | } | ||
385 | if ((pParam & (int)VehicleFlag.HOVER_WATER_ONLY) == (int)VehicleFlag.HOVER_WATER_ONLY) | ||
386 | { | ||
387 | m_Hoverflags |= (VehicleFlag.HOVER_WATER_ONLY | m_flags); | ||
388 | } | ||
389 | if ((pParam & (int)VehicleFlag.LIMIT_MOTOR_UP) == (int)VehicleFlag.LIMIT_MOTOR_UP) | ||
390 | { | ||
391 | m_flags |= (VehicleFlag.LIMIT_MOTOR_UP | m_flags); | ||
392 | } | ||
393 | if ((pParam & (int)VehicleFlag.MOUSELOOK_BANK) == (int)VehicleFlag.MOUSELOOK_BANK) | ||
394 | { | ||
395 | m_flags |= (VehicleFlag.MOUSELOOK_BANK | m_flags); | ||
396 | } | ||
397 | if ((pParam & (int)VehicleFlag.MOUSELOOK_STEER) == (int)VehicleFlag.MOUSELOOK_STEER) | ||
398 | { | ||
399 | m_flags |= (VehicleFlag.MOUSELOOK_STEER | m_flags); | ||
400 | } | ||
401 | if ((pParam & (int)VehicleFlag.NO_DEFLECTION_UP) == (int)VehicleFlag.NO_DEFLECTION_UP) | ||
402 | { | ||
403 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | m_flags); | ||
404 | } | ||
405 | if ((pParam & (int)VehicleFlag.CAMERA_DECOUPLED) == (int)VehicleFlag.CAMERA_DECOUPLED) | ||
406 | { | ||
407 | m_flags |= (VehicleFlag.CAMERA_DECOUPLED | m_flags); | ||
408 | } | ||
409 | if ((pParam & (int)VehicleFlag.NO_X) == (int)VehicleFlag.NO_X) | ||
410 | { | ||
411 | m_flags |= (VehicleFlag.NO_X); | ||
412 | } | ||
413 | if ((pParam & (int)VehicleFlag.NO_Y) == (int)VehicleFlag.NO_Y) | ||
414 | { | ||
415 | m_flags |= (VehicleFlag.NO_Y); | ||
416 | } | ||
417 | if ((pParam & (int)VehicleFlag.NO_Z) == (int)VehicleFlag.NO_Z) | ||
418 | { | ||
419 | m_flags |= (VehicleFlag.NO_Z); | ||
420 | } | ||
421 | if ((pParam & (int)VehicleFlag.LOCK_HOVER_HEIGHT) == (int)VehicleFlag.LOCK_HOVER_HEIGHT) | ||
422 | { | ||
423 | m_Hoverflags |= (VehicleFlag.LOCK_HOVER_HEIGHT); | ||
424 | } | ||
425 | if ((pParam & (int)VehicleFlag.NO_DEFLECTION) == (int)VehicleFlag.NO_DEFLECTION) | ||
426 | { | ||
427 | m_flags |= (VehicleFlag.NO_DEFLECTION); | ||
428 | } | ||
429 | if ((pParam & (int)VehicleFlag.LOCK_ROTATION) == (int)VehicleFlag.LOCK_ROTATION) | ||
430 | { | ||
431 | m_flags |= (VehicleFlag.LOCK_ROTATION); | ||
432 | } | ||
433 | } | ||
434 | }//end ProcessVehicleFlags | ||
435 | |||
271 | internal void ProcessTypeChange(Vehicle pType) | 436 | internal void ProcessTypeChange(Vehicle pType) |
272 | { | 437 | { |
273 | // Set Defaults For Type | 438 | // Set Defaults For Type |
274 | m_type = pType; | 439 | m_type = pType; |
275 | switch (pType) | 440 | switch (pType) |
276 | { | 441 | { |
442 | case Vehicle.TYPE_NONE: | ||
443 | m_linearFrictionTimescale = new Vector3(0, 0, 0); | ||
444 | m_angularFrictionTimescale = new Vector3(0, 0, 0); | ||
445 | m_linearMotorDirection = Vector3.Zero; | ||
446 | m_linearMotorTimescale = 0; | ||
447 | m_linearMotorDecayTimescale = 0; | ||
448 | m_angularMotorDirection = Vector3.Zero; | ||
449 | m_angularMotorTimescale = 0; | ||
450 | m_angularMotorDecayTimescale = 0; | ||
451 | m_VhoverHeight = 0; | ||
452 | m_VhoverTimescale = 0; | ||
453 | m_VehicleBuoyancy = 0; | ||
454 | m_flags = (VehicleFlag)0; | ||
455 | break; | ||
456 | |||
277 | case Vehicle.TYPE_SLED: | 457 | case Vehicle.TYPE_SLED: |
278 | m_linearFrictionTimescale = new Vector3(30, 1, 1000); | 458 | m_linearFrictionTimescale = new Vector3(30, 1, 1000); |
279 | m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); | 459 | m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); |
@@ -295,9 +475,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
295 | // m_bankingMix = 1; | 475 | // m_bankingMix = 1; |
296 | // m_bankingTimescale = 10; | 476 | // m_bankingTimescale = 10; |
297 | // m_referenceFrame = Quaternion.Identity; | 477 | // m_referenceFrame = Quaternion.Identity; |
298 | m_flags &= | 478 | m_Hoverflags &= |
299 | ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | | 479 | ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | |
300 | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); | 480 | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); |
301 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP); | 481 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP); |
302 | break; | 482 | break; |
303 | case Vehicle.TYPE_CAR: | 483 | case Vehicle.TYPE_CAR: |
@@ -323,9 +503,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
323 | // m_bankingMix = 1; | 503 | // m_bankingMix = 1; |
324 | // m_bankingTimescale = 1; | 504 | // m_bankingTimescale = 1; |
325 | // m_referenceFrame = Quaternion.Identity; | 505 | // m_referenceFrame = Quaternion.Identity; |
326 | m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); | 506 | m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); |
327 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.HOVER_UP_ONLY | | 507 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | |
328 | VehicleFlag.LIMIT_MOTOR_UP); | 508 | VehicleFlag.LIMIT_MOTOR_UP); |
509 | m_Hoverflags |= (VehicleFlag.HOVER_UP_ONLY); | ||
329 | break; | 510 | break; |
330 | case Vehicle.TYPE_BOAT: | 511 | case Vehicle.TYPE_BOAT: |
331 | m_linearFrictionTimescale = new Vector3(10, 3, 2); | 512 | m_linearFrictionTimescale = new Vector3(10, 3, 2); |
@@ -350,10 +531,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
350 | // m_bankingMix = 0.8f; | 531 | // m_bankingMix = 0.8f; |
351 | // m_bankingTimescale = 1; | 532 | // m_bankingTimescale = 1; |
352 | // m_referenceFrame = Quaternion.Identity; | 533 | // m_referenceFrame = Quaternion.Identity; |
353 | m_flags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.LIMIT_ROLL_ONLY | | 534 | m_Hoverflags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY | |
354 | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); | 535 | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); |
355 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.HOVER_WATER_ONLY | | 536 | m_flags &= ~(VehicleFlag.LIMIT_ROLL_ONLY); |
537 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | | ||
356 | VehicleFlag.LIMIT_MOTOR_UP); | 538 | VehicleFlag.LIMIT_MOTOR_UP); |
539 | m_Hoverflags |= (VehicleFlag.HOVER_WATER_ONLY); | ||
357 | break; | 540 | break; |
358 | case Vehicle.TYPE_AIRPLANE: | 541 | case Vehicle.TYPE_AIRPLANE: |
359 | m_linearFrictionTimescale = new Vector3(200, 10, 5); | 542 | m_linearFrictionTimescale = new Vector3(200, 10, 5); |
@@ -378,8 +561,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
378 | // m_bankingMix = 0.7f; | 561 | // m_bankingMix = 0.7f; |
379 | // m_bankingTimescale = 2; | 562 | // m_bankingTimescale = 2; |
380 | // m_referenceFrame = Quaternion.Identity; | 563 | // m_referenceFrame = Quaternion.Identity; |
381 | m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | | 564 | m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | |
382 | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY | VehicleFlag.LIMIT_MOTOR_UP); | 565 | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); |
566 | m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP); | ||
383 | m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); | 567 | m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); |
384 | break; | 568 | break; |
385 | case Vehicle.TYPE_BALLOON: | 569 | case Vehicle.TYPE_BALLOON: |
@@ -405,9 +589,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
405 | // m_bankingMix = 0.7f; | 589 | // m_bankingMix = 0.7f; |
406 | // m_bankingTimescale = 5; | 590 | // m_bankingTimescale = 5; |
407 | // m_referenceFrame = Quaternion.Identity; | 591 | // m_referenceFrame = Quaternion.Identity; |
408 | m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | | 592 | m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | |
409 | VehicleFlag.HOVER_UP_ONLY | VehicleFlag.LIMIT_MOTOR_UP); | 593 | VehicleFlag.HOVER_UP_ONLY); |
410 | m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); | 594 | m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP); |
595 | m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); | ||
596 | m_Hoverflags |= (VehicleFlag.HOVER_GLOBAL_HEIGHT); | ||
411 | break; | 597 | break; |
412 | 598 | ||
413 | } | 599 | } |
@@ -431,6 +617,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
431 | 617 | ||
432 | MoveLinear(pTimestep, pParentScene); | 618 | MoveLinear(pTimestep, pParentScene); |
433 | MoveAngular(pTimestep); | 619 | MoveAngular(pTimestep); |
620 | LimitRotation(pTimestep); | ||
434 | }// end Step | 621 | }// end Step |
435 | 622 | ||
436 | private void MoveLinear(float pTimestep, OdeScene _pParentScene) | 623 | private void MoveLinear(float pTimestep, OdeScene _pParentScene) |
@@ -477,61 +664,152 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
477 | // .Z velocity and gravity. Therefore only 0g will used script-requested | 664 | // .Z velocity and gravity. Therefore only 0g will used script-requested |
478 | // .Z velocity. >0g (m_VehicleBuoyancy < 1) will used modified gravity only. | 665 | // .Z velocity. >0g (m_VehicleBuoyancy < 1) will used modified gravity only. |
479 | Vector3 grav = Vector3.Zero; | 666 | Vector3 grav = Vector3.Zero; |
480 | if (m_VehicleBuoyancy < 1.0f) | 667 | // There is some gravity, make a gravity force vector |
668 | // that is applied after object velocity. | ||
669 | d.Mass objMass; | ||
670 | d.BodyGetMass(Body, out objMass); | ||
671 | // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g; | ||
672 | grav.Z = _pParentScene.gravityz * objMass.mass * (1f - m_VehicleBuoyancy); | ||
673 | // Preserve the current Z velocity | ||
674 | d.Vector3 vel_now = d.BodyGetLinearVel(Body); | ||
675 | m_dir.Z = vel_now.Z; // Preserve the accumulated falling velocity | ||
676 | |||
677 | d.Vector3 pos = d.BodyGetPosition(Body); | ||
678 | Vector3 accel = new Vector3(-(m_dir.X - m_lastLinearVelocityVector.X / 0.1f), -(m_dir.Y - m_lastLinearVelocityVector.Y / 0.1f), m_dir.Z - m_lastLinearVelocityVector.Z / 0.1f); | ||
679 | Vector3 posChange = new Vector3(); | ||
680 | posChange.X = pos.X - m_lastPositionVector.X; | ||
681 | posChange.Y = pos.Y - m_lastPositionVector.Y; | ||
682 | posChange.Z = pos.Z - m_lastPositionVector.Z; | ||
683 | double Zchange = Math.Abs(posChange.Z); | ||
684 | if (m_BlockingEndPoint != Vector3.Zero) | ||
685 | { | ||
686 | if (pos.X >= (m_BlockingEndPoint.X - (float)1)) | ||
687 | { | ||
688 | pos.X -= posChange.X + 1; | ||
689 | d.BodySetPosition(Body, pos.X, pos.Y, pos.Z); | ||
690 | } | ||
691 | if (pos.Y >= (m_BlockingEndPoint.Y - (float)1)) | ||
692 | { | ||
693 | pos.Y -= posChange.Y + 1; | ||
694 | d.BodySetPosition(Body, pos.X, pos.Y, pos.Z); | ||
695 | } | ||
696 | if (pos.Z >= (m_BlockingEndPoint.Z - (float)1)) | ||
697 | { | ||
698 | pos.Z -= posChange.Z + 1; | ||
699 | d.BodySetPosition(Body, pos.X, pos.Y, pos.Z); | ||
700 | } | ||
701 | if (pos.X <= 0) | ||
702 | { | ||
703 | pos.X += posChange.X + 1; | ||
704 | d.BodySetPosition(Body, pos.X, pos.Y, pos.Z); | ||
705 | } | ||
706 | if (pos.Y <= 0) | ||
707 | { | ||
708 | pos.Y += posChange.Y + 1; | ||
709 | d.BodySetPosition(Body, pos.X, pos.Y, pos.Z); | ||
710 | } | ||
711 | } | ||
712 | if (pos.Z < _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y)) | ||
481 | { | 713 | { |
482 | // There is some gravity, make a gravity force vector | 714 | pos.Z = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y) + 2; |
483 | // that is applied after object velocity. | 715 | d.BodySetPosition(Body, pos.X, pos.Y, pos.Z); |
484 | d.Mass objMass; | 716 | } |
485 | d.BodyGetMass(Body, out objMass); | ||
486 | // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g; | ||
487 | grav.Z = _pParentScene.gravityz * objMass.mass * (1f - m_VehicleBuoyancy); | ||
488 | // Preserve the current Z velocity | ||
489 | d.Vector3 vel_now = d.BodyGetLinearVel(Body); | ||
490 | m_dir.Z = vel_now.Z; // Preserve the accumulated falling velocity | ||
491 | } // else its 1.0, no gravity. | ||
492 | 717 | ||
493 | // Check if hovering | 718 | // Check if hovering |
494 | if ((m_flags & (VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT)) != 0) | 719 | if ((m_Hoverflags & (VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT)) != 0) |
495 | { | 720 | { |
496 | // We should hover, get the target height | 721 | // We should hover, get the target height |
497 | d.Vector3 pos = d.BodyGetPosition(Body); | 722 | if ((m_Hoverflags & VehicleFlag.HOVER_WATER_ONLY) != 0) |
498 | if ((m_flags & VehicleFlag.HOVER_WATER_ONLY) == VehicleFlag.HOVER_WATER_ONLY) | ||
499 | { | 723 | { |
500 | m_VhoverTargetHeight = _pParentScene.GetWaterLevel() + m_VhoverHeight; | 724 | m_VhoverTargetHeight = _pParentScene.GetWaterLevel() + m_VhoverHeight; |
501 | } | 725 | } |
502 | else if ((m_flags & VehicleFlag.HOVER_TERRAIN_ONLY) == VehicleFlag.HOVER_TERRAIN_ONLY) | 726 | if ((m_Hoverflags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0) |
503 | { | 727 | { |
504 | m_VhoverTargetHeight = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y) + m_VhoverHeight; | 728 | m_VhoverTargetHeight = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y) + m_VhoverHeight; |
505 | } | 729 | } |
506 | else if ((m_flags & VehicleFlag.HOVER_GLOBAL_HEIGHT) == VehicleFlag.HOVER_GLOBAL_HEIGHT) | 730 | if ((m_Hoverflags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != 0) |
507 | { | 731 | { |
508 | m_VhoverTargetHeight = m_VhoverHeight; | 732 | m_VhoverTargetHeight = m_VhoverHeight; |
509 | } | 733 | } |
510 | 734 | ||
511 | if ((m_flags & VehicleFlag.HOVER_UP_ONLY) == VehicleFlag.HOVER_UP_ONLY) | 735 | if ((m_Hoverflags & VehicleFlag.HOVER_UP_ONLY) != 0) |
512 | { | 736 | { |
513 | // If body is aready heigher, use its height as target height | 737 | // If body is aready heigher, use its height as target height |
514 | if (pos.Z > m_VhoverTargetHeight) m_VhoverTargetHeight = pos.Z; | 738 | if (pos.Z > m_VhoverTargetHeight) m_VhoverTargetHeight = pos.Z; |
515 | } | 739 | } |
740 | if ((m_Hoverflags & VehicleFlag.LOCK_HOVER_HEIGHT) != 0) | ||
741 | { | ||
742 | if ((pos.Z - m_VhoverTargetHeight) > .2 || (pos.Z - m_VhoverTargetHeight) < -.2) | ||
743 | { | ||
744 | d.BodySetPosition(Body, pos.X, pos.Y, m_VhoverTargetHeight); | ||
745 | } | ||
746 | } | ||
747 | else | ||
748 | { | ||
749 | float herr0 = pos.Z - m_VhoverTargetHeight; | ||
750 | // Replace Vertical speed with correction figure if significant | ||
751 | if (Math.Abs(herr0) > 0.01f) | ||
752 | { | ||
753 | m_dir.Z = -((herr0 * pTimestep * 50.0f) / m_VhoverTimescale); | ||
754 | //KF: m_VhoverEfficiency is not yet implemented | ||
755 | } | ||
756 | else | ||
757 | { | ||
758 | m_dir.Z = 0f; | ||
759 | } | ||
760 | } | ||
516 | 761 | ||
517 | // m_VhoverEfficiency = 0f; // 0=boucy, 1=Crit.damped | 762 | // m_VhoverEfficiency = 0f; // 0=boucy, 1=Crit.damped |
518 | // m_VhoverTimescale = 0f; // time to acheive height | 763 | // m_VhoverTimescale = 0f; // time to acheive height |
519 | // pTimestep is time since last frame,in secs | 764 | // pTimestep is time since last frame,in secs |
520 | float herr0 = pos.Z - m_VhoverTargetHeight; | 765 | } |
521 | // Replace Vertical speed with correction figure if significant | 766 | |
522 | if (Math.Abs(herr0) > 0.01f) | 767 | if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0) |
768 | { | ||
769 | //Start Experimental Values | ||
770 | if (Zchange > .3) | ||
523 | { | 771 | { |
524 | d.Mass objMass; | 772 | grav.Z = (float)(grav.Z * 3); |
525 | d.BodyGetMass(Body, out objMass); | ||
526 | m_dir.Z = - ((herr0 * pTimestep * 50.0f) / m_VhoverTimescale); | ||
527 | //KF: m_VhoverEfficiency is not yet implemented | ||
528 | } | 773 | } |
529 | else | 774 | if (Zchange > .15) |
775 | { | ||
776 | grav.Z = (float)(grav.Z * 2); | ||
777 | } | ||
778 | if (Zchange > .75) | ||
779 | { | ||
780 | grav.Z = (float)(grav.Z * 1.5); | ||
781 | } | ||
782 | if (Zchange > .05) | ||
783 | { | ||
784 | grav.Z = (float)(grav.Z * 1.25); | ||
785 | } | ||
786 | if (Zchange > .025) | ||
787 | { | ||
788 | grav.Z = (float)(grav.Z * 1.125); | ||
789 | } | ||
790 | float terraintemp = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y); | ||
791 | float postemp = (pos.Z - terraintemp); | ||
792 | if (postemp > 2.5f) | ||
530 | { | 793 | { |
531 | m_dir.Z = 0f; | 794 | grav.Z = (float)(grav.Z * 1.037125); |
532 | } | 795 | } |
796 | //End Experimental Values | ||
797 | } | ||
798 | if ((m_flags & (VehicleFlag.NO_X)) != 0) | ||
799 | { | ||
800 | m_dir.X = 0; | ||
801 | } | ||
802 | if ((m_flags & (VehicleFlag.NO_Y)) != 0) | ||
803 | { | ||
804 | m_dir.Y = 0; | ||
805 | } | ||
806 | if ((m_flags & (VehicleFlag.NO_Z)) != 0) | ||
807 | { | ||
808 | m_dir.Z = 0; | ||
533 | } | 809 | } |
534 | 810 | ||
811 | m_lastPositionVector = d.BodyGetPosition(Body); | ||
812 | |||
535 | // Apply velocity | 813 | // Apply velocity |
536 | d.BodySetLinearVel(Body, m_dir.X, m_dir.Y, m_dir.Z); | 814 | d.BodySetLinearVel(Body, m_dir.X, m_dir.Y, m_dir.Z); |
537 | // apply gravity force | 815 | // apply gravity force |
@@ -629,6 +907,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
629 | 907 | ||
630 | // Sum velocities | 908 | // Sum velocities |
631 | m_lastAngularVelocity = m_angularMotorVelocity + vertattr; // + bank + deflection | 909 | m_lastAngularVelocity = m_angularMotorVelocity + vertattr; // + bank + deflection |
910 | |||
911 | if ((m_flags & (VehicleFlag.NO_DEFLECTION_UP)) != 0) | ||
912 | { | ||
913 | m_lastAngularVelocity.X = 0; | ||
914 | m_lastAngularVelocity.Y = 0; | ||
915 | } | ||
632 | 916 | ||
633 | if (!m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f)) | 917 | if (!m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f)) |
634 | { | 918 | { |
@@ -647,5 +931,44 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
647 | d.BodySetAngularVel (Body, m_lastAngularVelocity.X, m_lastAngularVelocity.Y, m_lastAngularVelocity.Z); | 931 | d.BodySetAngularVel (Body, m_lastAngularVelocity.X, m_lastAngularVelocity.Y, m_lastAngularVelocity.Z); |
648 | 932 | ||
649 | } //end MoveAngular | 933 | } //end MoveAngular |
934 | internal void LimitRotation(float timestep) | ||
935 | { | ||
936 | d.Quaternion rot = d.BodyGetQuaternion(Body); | ||
937 | Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object | ||
938 | d.Quaternion m_rot = new d.Quaternion(); | ||
939 | bool changed = false; | ||
940 | m_rot.X = rotq.X; | ||
941 | m_rot.Y = rotq.Y; | ||
942 | m_rot.Z = rotq.Z; | ||
943 | m_rot.W = rotq.W; | ||
944 | if (m_RollreferenceFrame != Quaternion.Identity) | ||
945 | { | ||
946 | if (rotq.X >= m_RollreferenceFrame.X) | ||
947 | { | ||
948 | m_rot.X = rotq.X - (m_RollreferenceFrame.X / 2); | ||
949 | } | ||
950 | if (rotq.Y >= m_RollreferenceFrame.Y) | ||
951 | { | ||
952 | m_rot.Y = rotq.Y - (m_RollreferenceFrame.Y / 2); | ||
953 | } | ||
954 | if (rotq.X <= -m_RollreferenceFrame.X) | ||
955 | { | ||
956 | m_rot.X = rotq.X + (m_RollreferenceFrame.X / 2); | ||
957 | } | ||
958 | if (rotq.Y <= -m_RollreferenceFrame.Y) | ||
959 | { | ||
960 | m_rot.Y = rotq.Y + (m_RollreferenceFrame.Y / 2); | ||
961 | } | ||
962 | changed = true; | ||
963 | } | ||
964 | if ((m_flags & VehicleFlag.LOCK_ROTATION) != 0) | ||
965 | { | ||
966 | m_rot.X = 0; | ||
967 | m_rot.Y = 0; | ||
968 | changed = true; | ||
969 | } | ||
970 | if (changed) | ||
971 | d.BodySetQuaternion(Body, ref m_rot); | ||
972 | } | ||
650 | } | 973 | } |
651 | } | 974 | } |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index f354328..2ab00a3 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |||
@@ -2354,15 +2354,10 @@ Console.WriteLine(" JointCreateFixed"); | |||
2354 | { | 2354 | { |
2355 | m_vehicle.ProcessRotationVehicleParam((Vehicle) param, rotation); | 2355 | m_vehicle.ProcessRotationVehicleParam((Vehicle) param, rotation); |
2356 | } | 2356 | } |
2357 | |||
2358 | public override void VehicleFlagsSet(int flags) | ||
2359 | { | ||
2360 | 2357 | ||
2361 | } | 2358 | public override void VehicleFlags(int param, bool remove) |
2362 | |||
2363 | public override void VehicleFlagsRemove(int flags) | ||
2364 | { | 2359 | { |
2365 | 2360 | m_vehicle.ProcessVehicleFlags(param, remove); | |
2366 | } | 2361 | } |
2367 | 2362 | ||
2368 | public override void SetVolumeDetect(int param) | 2363 | public override void SetVolumeDetect(int param) |
diff --git a/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs b/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs index 491e200..a70179b 100644 --- a/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs +++ b/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs | |||
@@ -181,17 +181,9 @@ namespace OpenSim.Region.Physics.POSPlugin | |||
181 | { | 181 | { |
182 | 182 | ||
183 | } | 183 | } |
184 | |||
185 | public override void VehicleFlagsSet(int flags) | ||
186 | { | ||
187 | 184 | ||
188 | } | 185 | public override void VehicleFlags(int param, bool remove) { } |
189 | |||
190 | public override void VehicleFlagsRemove(int flags) | ||
191 | { | ||
192 | 186 | ||
193 | } | ||
194 | |||
195 | public override void SetVolumeDetect(int param) | 187 | public override void SetVolumeDetect(int param) |
196 | { | 188 | { |
197 | 189 | ||
diff --git a/OpenSim/Region/Physics/POSPlugin/POSPrim.cs b/OpenSim/Region/Physics/POSPlugin/POSPrim.cs index f8d49f9..9ba5ebb 100644 --- a/OpenSim/Region/Physics/POSPlugin/POSPrim.cs +++ b/OpenSim/Region/Physics/POSPlugin/POSPrim.cs | |||
@@ -138,17 +138,9 @@ namespace OpenSim.Region.Physics.POSPlugin | |||
138 | { | 138 | { |
139 | 139 | ||
140 | } | 140 | } |
141 | |||
142 | public override void VehicleFlagsSet(int flags) | ||
143 | { | ||
144 | 141 | ||
145 | } | 142 | public override void VehicleFlags(int param, bool remove) { } |
146 | |||
147 | public override void VehicleFlagsRemove(int flags) | ||
148 | { | ||
149 | 143 | ||
150 | } | ||
151 | |||
152 | public override void SetVolumeDetect(int param) | 144 | public override void SetVolumeDetect(int param) |
153 | { | 145 | { |
154 | 146 | ||
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXCharacter.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXCharacter.cs new file mode 100644 index 0000000..92261cd --- /dev/null +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXCharacter.cs | |||
@@ -0,0 +1,353 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using Nini.Config; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Physics.Manager; | ||
33 | using PhysXWrapper; | ||
34 | using Quaternion=OpenMetaverse.Quaternion; | ||
35 | using System.Reflection; | ||
36 | using log4net; | ||
37 | using OpenMetaverse; | ||
38 | |||
39 | namespace OpenSim.Region.Physics.PhysXPlugin | ||
40 | { | ||
41 | public class PhysXCharacter : PhysicsActor | ||
42 | { | ||
43 | private Vector3 _position; | ||
44 | private Vector3 _velocity; | ||
45 | private Vector3 m_rotationalVelocity = Vector3.Zero; | ||
46 | private Vector3 _acceleration; | ||
47 | private NxCharacter _character; | ||
48 | private bool flying; | ||
49 | private bool iscolliding = false; | ||
50 | private float gravityAccel; | ||
51 | |||
52 | public PhysXCharacter(NxCharacter character) | ||
53 | { | ||
54 | _character = character; | ||
55 | } | ||
56 | |||
57 | public override int PhysicsActorType | ||
58 | { | ||
59 | get { return (int) ActorTypes.Agent; } | ||
60 | set { return; } | ||
61 | } | ||
62 | |||
63 | public override bool SetAlwaysRun | ||
64 | { | ||
65 | get { return false; } | ||
66 | set { return; } | ||
67 | } | ||
68 | |||
69 | public override uint LocalID | ||
70 | { | ||
71 | set { return; } | ||
72 | } | ||
73 | |||
74 | public override bool Grabbed | ||
75 | { | ||
76 | set { return; } | ||
77 | } | ||
78 | |||
79 | public override bool Selected | ||
80 | { | ||
81 | set { return; } | ||
82 | } | ||
83 | |||
84 | public override float Buoyancy | ||
85 | { | ||
86 | get { return 0f; } | ||
87 | set { return; } | ||
88 | } | ||
89 | |||
90 | public override bool FloatOnWater | ||
91 | { | ||
92 | set { return; } | ||
93 | } | ||
94 | |||
95 | public override bool IsPhysical | ||
96 | { | ||
97 | get { return false; } | ||
98 | set { return; } | ||
99 | } | ||
100 | |||
101 | public override bool ThrottleUpdates | ||
102 | { | ||
103 | get { return false; } | ||
104 | set { return; } | ||
105 | } | ||
106 | |||
107 | public override bool Flying | ||
108 | { | ||
109 | get { return flying; } | ||
110 | set { flying = value; } | ||
111 | } | ||
112 | |||
113 | public override bool IsColliding | ||
114 | { | ||
115 | get { return iscolliding; } | ||
116 | set { iscolliding = value; } | ||
117 | } | ||
118 | |||
119 | public override bool CollidingGround | ||
120 | { | ||
121 | get { return false; } | ||
122 | set { return; } | ||
123 | } | ||
124 | |||
125 | public override bool CollidingObj | ||
126 | { | ||
127 | get { return false; } | ||
128 | set { return; } | ||
129 | } | ||
130 | |||
131 | public override Vector3 RotationalVelocity | ||
132 | { | ||
133 | get { return m_rotationalVelocity; } | ||
134 | set { m_rotationalVelocity = value; } | ||
135 | } | ||
136 | |||
137 | public override bool Stopped | ||
138 | { | ||
139 | get { return false; } | ||
140 | } | ||
141 | |||
142 | public override Vector3 Position | ||
143 | { | ||
144 | get { return _position; } | ||
145 | set | ||
146 | { | ||
147 | _position = value; | ||
148 | Vec3 ps = new Vec3(); | ||
149 | ps.X = value.X; | ||
150 | ps.Y = value.Y; | ||
151 | ps.Z = value.Z; | ||
152 | _character.Position = ps; | ||
153 | } | ||
154 | } | ||
155 | |||
156 | public override Vector3 Size | ||
157 | { | ||
158 | get { return Vector3.Zero; } | ||
159 | set { } | ||
160 | } | ||
161 | |||
162 | public override float Mass | ||
163 | { | ||
164 | get { return 0f; } | ||
165 | } | ||
166 | |||
167 | public override Vector3 Force | ||
168 | { | ||
169 | get { return Vector3.Zero; } | ||
170 | set { return; } | ||
171 | } | ||
172 | |||
173 | public override int VehicleType | ||
174 | { | ||
175 | get { return 0; } | ||
176 | set { return; } | ||
177 | } | ||
178 | |||
179 | public override void VehicleFloatParam(int param, float value) | ||
180 | { | ||
181 | } | ||
182 | |||
183 | public override void VehicleVectorParam(int param, Vector3 value) | ||
184 | { | ||
185 | } | ||
186 | |||
187 | public override void VehicleRotationParam(int param, Quaternion rotation) | ||
188 | { | ||
189 | } | ||
190 | |||
191 | public override void VehicleFlags(int param, bool remove) | ||
192 | { | ||
193 | } | ||
194 | |||
195 | public override void SetVolumeDetect(int param) | ||
196 | { | ||
197 | } | ||
198 | |||
199 | public override Vector3 CenterOfMass | ||
200 | { | ||
201 | get { return Vector3.Zero; } | ||
202 | } | ||
203 | |||
204 | public override Vector3 GeometricCenter | ||
205 | { | ||
206 | get { return Vector3.Zero; } | ||
207 | } | ||
208 | |||
209 | public override Vector3 Velocity | ||
210 | { | ||
211 | get { return _velocity; } | ||
212 | set { _velocity = value; } | ||
213 | } | ||
214 | |||
215 | public override float CollisionScore | ||
216 | { | ||
217 | get { return 0f; } | ||
218 | set { } | ||
219 | } | ||
220 | |||
221 | public override bool Kinematic | ||
222 | { | ||
223 | get { return false; } | ||
224 | set { } | ||
225 | } | ||
226 | |||
227 | public override Quaternion Orientation | ||
228 | { | ||
229 | get { return Quaternion.Identity; } | ||
230 | set { } | ||
231 | } | ||
232 | |||
233 | public override Vector3 Acceleration | ||
234 | { | ||
235 | get { return _acceleration; } | ||
236 | } | ||
237 | |||
238 | public void SetAcceleration(Vector3 accel) | ||
239 | { | ||
240 | _acceleration = accel; | ||
241 | } | ||
242 | |||
243 | public override void AddForce(Vector3 force, bool pushforce) | ||
244 | { | ||
245 | } | ||
246 | |||
247 | public override Vector3 Torque | ||
248 | { | ||
249 | get { return Vector3.Zero; } | ||
250 | set { return; } | ||
251 | } | ||
252 | |||
253 | public override void AddAngularForce(Vector3 force, bool pushforce) | ||
254 | { | ||
255 | } | ||
256 | |||
257 | public override void link(PhysicsActor obj) | ||
258 | { | ||
259 | } | ||
260 | |||
261 | public override void delink() | ||
262 | { | ||
263 | } | ||
264 | |||
265 | public override void LockAngularMotion(Vector3 axis) | ||
266 | { | ||
267 | } | ||
268 | |||
269 | public override void SetMomentum(Vector3 momentum) | ||
270 | { | ||
271 | } | ||
272 | |||
273 | public void Move(float timeStep) | ||
274 | { | ||
275 | Vec3 vec = new Vec3(); | ||
276 | vec.X = _velocity.X*timeStep; | ||
277 | vec.Y = _velocity.Y*timeStep; | ||
278 | if (flying) | ||
279 | { | ||
280 | vec.Z = (_velocity.Z)*timeStep; | ||
281 | } | ||
282 | else | ||
283 | { | ||
284 | gravityAccel += -9.8f; | ||
285 | vec.Z = (gravityAccel + _velocity.Z)*timeStep; | ||
286 | } | ||
287 | int res = _character.Move(vec); | ||
288 | if (res == 1) | ||
289 | { | ||
290 | gravityAccel = 0; | ||
291 | } | ||
292 | } | ||
293 | |||
294 | public override PrimitiveBaseShape Shape | ||
295 | { | ||
296 | set { return; } | ||
297 | } | ||
298 | |||
299 | public void UpdatePosition() | ||
300 | { | ||
301 | Vec3 vec = _character.Position; | ||
302 | _position.X = vec.X; | ||
303 | _position.Y = vec.Y; | ||
304 | _position.Z = vec.Z; | ||
305 | } | ||
306 | |||
307 | public override void CrossingFailure() | ||
308 | { | ||
309 | } | ||
310 | |||
311 | public override Vector3 PIDTarget { set { return; } } | ||
312 | public override bool PIDActive { set { return; } } | ||
313 | public override float PIDTau { set { return; } } | ||
314 | |||
315 | public override float PIDHoverHeight { set { return; } } | ||
316 | public override bool PIDHoverActive { set { return; } } | ||
317 | public override PIDHoverType PIDHoverType { set { return; } } | ||
318 | public override float PIDHoverTau { set { return; } } | ||
319 | |||
320 | public override Quaternion APIDTarget | ||
321 | { | ||
322 | set { return; } | ||
323 | } | ||
324 | |||
325 | public override bool APIDActive | ||
326 | { | ||
327 | set { return; } | ||
328 | } | ||
329 | |||
330 | public override float APIDStrength | ||
331 | { | ||
332 | set { return; } | ||
333 | } | ||
334 | |||
335 | public override float APIDDamping | ||
336 | { | ||
337 | set { return; } | ||
338 | } | ||
339 | |||
340 | public override void SubscribeEvents(int ms) | ||
341 | { | ||
342 | |||
343 | } | ||
344 | public override void UnSubscribeEvents() | ||
345 | { | ||
346 | |||
347 | } | ||
348 | public override bool SubscribedEvents() | ||
349 | { | ||
350 | return false; | ||
351 | } | ||
352 | } | ||
353 | } | ||
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs deleted file mode 100644 index e54065c..0000000 --- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs +++ /dev/null | |||
@@ -1,861 +0,0 @@ | |||
1 | /*/* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using Nini.Config; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Physics.Manager; | ||
33 | using PhysXWrapper; | ||
34 | using Quaternion=OpenMetaverse.Quaternion; | ||
35 | using System.Reflection; | ||
36 | using log4net; | ||
37 | using OpenMetaverse; | ||
38 | |||
39 | namespace OpenSim.Region.Physics.PhysXPlugin | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// Will be the PhysX plugin but for now will be a very basic physics engine | ||
43 | /// </summary> | ||
44 | public class PhysXPlugin : IPhysicsPlugin | ||
45 | { | ||
46 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | private PhysXScene _mScene; | ||
48 | |||
49 | public PhysXPlugin() | ||
50 | { | ||
51 | } | ||
52 | |||
53 | public bool Init() | ||
54 | { | ||
55 | return true; | ||
56 | } | ||
57 | |||
58 | public PhysicsScene GetScene(string sceneIdentifier) | ||
59 | { | ||
60 | if (_mScene == null) | ||
61 | { | ||
62 | _mScene = new PhysXScene(sceneIdentifier); | ||
63 | } | ||
64 | return (_mScene); | ||
65 | } | ||
66 | |||
67 | public string GetName() | ||
68 | { | ||
69 | return ("RealPhysX"); | ||
70 | } | ||
71 | |||
72 | public void Dispose() | ||
73 | { | ||
74 | } | ||
75 | } | ||
76 | |||
77 | public class PhysXScene : PhysicsScene | ||
78 | { | ||
79 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
80 | private List<PhysXCharacter> _characters = new List<PhysXCharacter>(); | ||
81 | private List<PhysXPrim> _prims = new List<PhysXPrim>(); | ||
82 | private float[] _heightMap = null; | ||
83 | private NxPhysicsSDK mySdk; | ||
84 | private NxScene scene; | ||
85 | |||
86 | // protected internal string sceneIdentifier; | ||
87 | public PhysXScene(string _sceneIdentifier) | ||
88 | { | ||
89 | //sceneIdentifier = _sceneIdentifier; | ||
90 | |||
91 | mySdk = NxPhysicsSDK.CreateSDK(); | ||
92 | m_log.Info("Sdk created - now creating scene"); | ||
93 | scene = mySdk.CreateScene(); | ||
94 | } | ||
95 | |||
96 | public override void Initialise(IMesher meshmerizer, IConfigSource config) | ||
97 | { | ||
98 | // Does nothing right now | ||
99 | } | ||
100 | public override void Dispose() | ||
101 | { | ||
102 | |||
103 | } | ||
104 | |||
105 | public override void SetWaterLevel(float baseheight) | ||
106 | { | ||
107 | |||
108 | } | ||
109 | |||
110 | public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) | ||
111 | { | ||
112 | Vec3 pos = new Vec3(); | ||
113 | pos.X = position.X; | ||
114 | pos.Y = position.Y; | ||
115 | pos.Z = position.Z; | ||
116 | PhysXCharacter act = new PhysXCharacter(scene.AddCharacter(pos)); | ||
117 | act.Flying = isFlying; | ||
118 | act.Position = position; | ||
119 | _characters.Add(act); | ||
120 | return act; | ||
121 | } | ||
122 | |||
123 | public override void RemovePrim(PhysicsActor prim) | ||
124 | { | ||
125 | } | ||
126 | |||
127 | public override void RemoveAvatar(PhysicsActor actor) | ||
128 | { | ||
129 | } | ||
130 | |||
131 | private PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation) | ||
132 | { | ||
133 | Vec3 pos = new Vec3(); | ||
134 | pos.X = position.X; | ||
135 | pos.Y = position.Y; | ||
136 | pos.Z = position.Z; | ||
137 | Vec3 siz = new Vec3(); | ||
138 | siz.X = size.X; | ||
139 | siz.Y = size.Y; | ||
140 | siz.Z = size.Z; | ||
141 | PhysXPrim act = new PhysXPrim(scene.AddNewBox(pos, siz)); | ||
142 | _prims.Add(act); | ||
143 | return act; | ||
144 | } | ||
145 | |||
146 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
147 | Vector3 size, Quaternion rotation) //To be removed | ||
148 | { | ||
149 | return AddPrimShape(primName, pbs, position, size, rotation, false); | ||
150 | } | ||
151 | |||
152 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
153 | Vector3 size, Quaternion rotation, bool isPhysical) | ||
154 | { | ||
155 | return AddPrim(position, size, rotation); | ||
156 | } | ||
157 | |||
158 | public override void AddPhysicsActorTaint(PhysicsActor prim) | ||
159 | { | ||
160 | } | ||
161 | |||
162 | public override float Simulate(float timeStep) | ||
163 | { | ||
164 | float fps = 0f; | ||
165 | try | ||
166 | { | ||
167 | foreach (PhysXCharacter actor in _characters) | ||
168 | { | ||
169 | actor.Move(timeStep); | ||
170 | } | ||
171 | scene.Simulate(timeStep); | ||
172 | scene.FetchResults(); | ||
173 | scene.UpdateControllers(); | ||
174 | |||
175 | foreach (PhysXCharacter actor in _characters) | ||
176 | { | ||
177 | actor.UpdatePosition(); | ||
178 | } | ||
179 | } | ||
180 | catch (Exception e) | ||
181 | { | ||
182 | m_log.Error(e.Message); | ||
183 | } | ||
184 | return fps; | ||
185 | } | ||
186 | |||
187 | public override void GetResults() | ||
188 | { | ||
189 | } | ||
190 | |||
191 | public override bool IsThreaded | ||
192 | { | ||
193 | get { return (false); // for now we won't be multithreaded | ||
194 | } | ||
195 | } | ||
196 | |||
197 | public override void SetTerrain(float[] heightMap) | ||
198 | { | ||
199 | if (_heightMap != null) | ||
200 | { | ||
201 | m_log.Debug("PhysX - deleting old terrain"); | ||
202 | scene.DeleteTerrain(); | ||
203 | } | ||
204 | _heightMap = heightMap; | ||
205 | scene.AddTerrain(heightMap); | ||
206 | } | ||
207 | |||
208 | public override void DeleteTerrain() | ||
209 | { | ||
210 | scene.DeleteTerrain(); | ||
211 | } | ||
212 | |||
213 | public override Dictionary<uint, float> GetTopColliders() | ||
214 | { | ||
215 | Dictionary<uint, float> returncolliders = new Dictionary<uint, float>(); | ||
216 | return returncolliders; | ||
217 | } | ||
218 | |||
219 | } | ||
220 | |||
221 | public class PhysXCharacter : PhysicsActor | ||
222 | { | ||
223 | private Vector3 _position; | ||
224 | private Vector3 _velocity; | ||
225 | private Vector3 m_rotationalVelocity = Vector3.Zero; | ||
226 | private Vector3 _acceleration; | ||
227 | private NxCharacter _character; | ||
228 | private bool flying; | ||
229 | private bool iscolliding = false; | ||
230 | private float gravityAccel; | ||
231 | |||
232 | public PhysXCharacter(NxCharacter character) | ||
233 | { | ||
234 | _character = character; | ||
235 | } | ||
236 | |||
237 | public override int PhysicsActorType | ||
238 | { | ||
239 | get { return (int) ActorTypes.Agent; } | ||
240 | set { return; } | ||
241 | } | ||
242 | |||
243 | public override bool SetAlwaysRun | ||
244 | { | ||
245 | get { return false; } | ||
246 | set { return; } | ||
247 | } | ||
248 | |||
249 | public override uint LocalID | ||
250 | { | ||
251 | set { return; } | ||
252 | } | ||
253 | |||
254 | public override bool Grabbed | ||
255 | { | ||
256 | set { return; } | ||
257 | } | ||
258 | |||
259 | public override bool Selected | ||
260 | { | ||
261 | set { return; } | ||
262 | } | ||
263 | |||
264 | public override float Buoyancy | ||
265 | { | ||
266 | get { return 0f; } | ||
267 | set { return; } | ||
268 | } | ||
269 | |||
270 | public override bool FloatOnWater | ||
271 | { | ||
272 | set { return; } | ||
273 | } | ||
274 | |||
275 | public override bool IsPhysical | ||
276 | { | ||
277 | get { return false; } | ||
278 | set { return; } | ||
279 | } | ||
280 | |||
281 | public override bool ThrottleUpdates | ||
282 | { | ||
283 | get { return false; } | ||
284 | set { return; } | ||
285 | } | ||
286 | |||
287 | public override bool Flying | ||
288 | { | ||
289 | get { return flying; } | ||
290 | set { flying = value; } | ||
291 | } | ||
292 | |||
293 | public override bool IsColliding | ||
294 | { | ||
295 | get { return iscolliding; } | ||
296 | set { iscolliding = value; } | ||
297 | } | ||
298 | |||
299 | public override bool CollidingGround | ||
300 | { | ||
301 | get { return false; } | ||
302 | set { return; } | ||
303 | } | ||
304 | |||
305 | public override bool CollidingObj | ||
306 | { | ||
307 | get { return false; } | ||
308 | set { return; } | ||
309 | } | ||
310 | |||
311 | public override Vector3 RotationalVelocity | ||
312 | { | ||
313 | get { return m_rotationalVelocity; } | ||
314 | set { m_rotationalVelocity = value; } | ||
315 | } | ||
316 | |||
317 | public override bool Stopped | ||
318 | { | ||
319 | get { return false; } | ||
320 | } | ||
321 | |||
322 | public override Vector3 Position | ||
323 | { | ||
324 | get { return _position; } | ||
325 | set | ||
326 | { | ||
327 | _position = value; | ||
328 | Vec3 ps = new Vec3(); | ||
329 | ps.X = value.X; | ||
330 | ps.Y = value.Y; | ||
331 | ps.Z = value.Z; | ||
332 | _character.Position = ps; | ||
333 | } | ||
334 | } | ||
335 | |||
336 | public override Vector3 Size | ||
337 | { | ||
338 | get { return Vector3.Zero; } | ||
339 | set { } | ||
340 | } | ||
341 | |||
342 | public override float Mass | ||
343 | { | ||
344 | get { return 0f; } | ||
345 | } | ||
346 | |||
347 | public override Vector3 Force | ||
348 | { | ||
349 | get { return Vector3.Zero; } | ||
350 | set { return; } | ||
351 | } | ||
352 | |||
353 | public override int VehicleType | ||
354 | { | ||
355 | get { return 0; } | ||
356 | set { return; } | ||
357 | } | ||
358 | |||
359 | public override void VehicleFloatParam(int param, float value) | ||
360 | { | ||
361 | |||
362 | } | ||
363 | |||
364 | public override void VehicleVectorParam(int param, Vector3 value) | ||
365 | { | ||
366 | |||
367 | } | ||
368 | |||
369 | public override void VehicleRotationParam(int param, Quaternion rotation) | ||
370 | { | ||
371 | |||
372 | } | ||
373 | |||
374 | public override void VehicleFlagsSet(int flags) | ||
375 | { | ||
376 | |||
377 | } | ||
378 | |||
379 | public override void VehicleFlagsRemove(int flags) | ||
380 | { | ||
381 | |||
382 | } | ||
383 | |||
384 | public override void SetVolumeDetect(int param) | ||
385 | { | ||
386 | |||
387 | } | ||
388 | |||
389 | |||
390 | public override Vector3 CenterOfMass | ||
391 | { | ||
392 | get { return Vector3.Zero; } | ||
393 | } | ||
394 | |||
395 | public override Vector3 GeometricCenter | ||
396 | { | ||
397 | get { return Vector3.Zero; } | ||
398 | } | ||
399 | |||
400 | public override Vector3 Velocity | ||
401 | { | ||
402 | get { return _velocity; } | ||
403 | set { _velocity = value; } | ||
404 | } | ||
405 | |||
406 | public override float CollisionScore | ||
407 | { | ||
408 | get { return 0f; } | ||
409 | set { } | ||
410 | } | ||
411 | |||
412 | public override bool Kinematic | ||
413 | { | ||
414 | get { return false; } | ||
415 | set { } | ||
416 | } | ||
417 | |||
418 | public override Quaternion Orientation | ||
419 | { | ||
420 | get { return Quaternion.Identity; } | ||
421 | set { } | ||
422 | } | ||
423 | |||
424 | public override Vector3 Acceleration | ||
425 | { | ||
426 | get { return _acceleration; } | ||
427 | } | ||
428 | |||
429 | public void SetAcceleration(Vector3 accel) | ||
430 | { | ||
431 | _acceleration = accel; | ||
432 | } | ||
433 | |||
434 | public override void AddForce(Vector3 force, bool pushforce) | ||
435 | { | ||
436 | } | ||
437 | public override Vector3 Torque | ||
438 | { | ||
439 | get { return Vector3.Zero; } | ||
440 | set { return; } | ||
441 | } | ||
442 | public override void AddAngularForce(Vector3 force, bool pushforce) | ||
443 | { | ||
444 | } | ||
445 | |||
446 | public override void link(PhysicsActor obj) | ||
447 | { | ||
448 | |||
449 | } | ||
450 | |||
451 | public override void delink() | ||
452 | { | ||
453 | |||
454 | } | ||
455 | |||
456 | public override void LockAngularMotion(Vector3 axis) | ||
457 | { | ||
458 | |||
459 | } | ||
460 | |||
461 | public override void SetMomentum(Vector3 momentum) | ||
462 | { | ||
463 | } | ||
464 | |||
465 | public void Move(float timeStep) | ||
466 | { | ||
467 | Vec3 vec = new Vec3(); | ||
468 | vec.X = _velocity.X*timeStep; | ||
469 | vec.Y = _velocity.Y*timeStep; | ||
470 | if (flying) | ||
471 | { | ||
472 | vec.Z = (_velocity.Z)*timeStep; | ||
473 | } | ||
474 | else | ||
475 | { | ||
476 | gravityAccel += -9.8f; | ||
477 | vec.Z = (gravityAccel + _velocity.Z)*timeStep; | ||
478 | } | ||
479 | int res = _character.Move(vec); | ||
480 | if (res == 1) | ||
481 | { | ||
482 | gravityAccel = 0; | ||
483 | } | ||
484 | } | ||
485 | |||
486 | public override PrimitiveBaseShape Shape | ||
487 | { | ||
488 | set { return; } | ||
489 | } | ||
490 | |||
491 | public void UpdatePosition() | ||
492 | { | ||
493 | Vec3 vec = _character.Position; | ||
494 | _position.X = vec.X; | ||
495 | _position.Y = vec.Y; | ||
496 | _position.Z = vec.Z; | ||
497 | } | ||
498 | public override void CrossingFailure() | ||
499 | { | ||
500 | |||
501 | } | ||
502 | |||
503 | public override Vector3 PIDTarget { set { return; } } | ||
504 | public override bool PIDActive { set { return; } } | ||
505 | public override float PIDTau { set { return; } } | ||
506 | |||
507 | public override float PIDHoverHeight { set { return; } } | ||
508 | public override bool PIDHoverActive { set { return; } } | ||
509 | public override PIDHoverType PIDHoverType { set { return; } } | ||
510 | public override float PIDHoverTau { set { return; } } | ||
511 | |||
512 | public override Quaternion APIDTarget | ||
513 | { | ||
514 | set { return; } | ||
515 | } | ||
516 | |||
517 | public override bool APIDActive | ||
518 | { | ||
519 | set { return; } | ||
520 | } | ||
521 | |||
522 | public override float APIDStrength | ||
523 | { | ||
524 | set { return; } | ||
525 | } | ||
526 | |||
527 | public override float APIDDamping | ||
528 | { | ||
529 | set { return; } | ||
530 | } | ||
531 | |||
532 | |||
533 | |||
534 | public override void SubscribeEvents(int ms) | ||
535 | { | ||
536 | |||
537 | } | ||
538 | public override void UnSubscribeEvents() | ||
539 | { | ||
540 | |||
541 | } | ||
542 | public override bool SubscribedEvents() | ||
543 | { | ||
544 | return false; | ||
545 | } | ||
546 | } | ||
547 | |||
548 | |||
549 | public class PhysXPrim : PhysicsActor | ||
550 | { | ||
551 | private Vector3 _velocity; | ||
552 | private Vector3 _acceleration; | ||
553 | private Vector3 m_rotationalVelocity; | ||
554 | private NxActor _prim; | ||
555 | |||
556 | public PhysXPrim(NxActor prim) | ||
557 | { | ||
558 | _velocity = Vector3.Zero; | ||
559 | _acceleration = Vector3.Zero; | ||
560 | _prim = prim; | ||
561 | } | ||
562 | |||
563 | public override int PhysicsActorType | ||
564 | { | ||
565 | get { return (int) ActorTypes.Prim; } | ||
566 | set { return; } | ||
567 | } | ||
568 | |||
569 | public override bool IsPhysical | ||
570 | { | ||
571 | get { return false; } | ||
572 | set { return; } | ||
573 | } | ||
574 | |||
575 | public override bool SetAlwaysRun | ||
576 | { | ||
577 | get { return false; } | ||
578 | set { return; } | ||
579 | } | ||
580 | |||
581 | public override uint LocalID | ||
582 | { | ||
583 | set { return; } | ||
584 | } | ||
585 | |||
586 | public override bool Grabbed | ||
587 | { | ||
588 | set { return; } | ||
589 | } | ||
590 | |||
591 | public override bool Selected | ||
592 | { | ||
593 | set { return; } | ||
594 | } | ||
595 | |||
596 | public override float Buoyancy | ||
597 | { | ||
598 | get { return 0f; } | ||
599 | set { return; } | ||
600 | } | ||
601 | |||
602 | public override bool FloatOnWater | ||
603 | { | ||
604 | set { return; } | ||
605 | } | ||
606 | |||
607 | public override bool ThrottleUpdates | ||
608 | { | ||
609 | get { return false; } | ||
610 | set { return; } | ||
611 | } | ||
612 | |||
613 | public override Vector3 RotationalVelocity | ||
614 | { | ||
615 | get { return m_rotationalVelocity; } | ||
616 | set { m_rotationalVelocity = value; } | ||
617 | } | ||
618 | |||
619 | public override bool Flying | ||
620 | { | ||
621 | get { return false; //no flying prims for you | ||
622 | } | ||
623 | set { } | ||
624 | } | ||
625 | |||
626 | public override bool IsColliding | ||
627 | { | ||
628 | get { return false; } | ||
629 | set { } | ||
630 | } | ||
631 | |||
632 | public override bool CollidingGround | ||
633 | { | ||
634 | get { return false; } | ||
635 | set { return; } | ||
636 | } | ||
637 | |||
638 | public override bool CollidingObj | ||
639 | { | ||
640 | get { return false; } | ||
641 | set { return; } | ||
642 | } | ||
643 | |||
644 | public override bool Stopped | ||
645 | { | ||
646 | get { return false; } | ||
647 | } | ||
648 | |||
649 | public override Vector3 Position | ||
650 | { | ||
651 | get | ||
652 | { | ||
653 | Vector3 pos = Vector3.Zero; | ||
654 | Vec3 vec = _prim.Position; | ||
655 | pos.X = vec.X; | ||
656 | pos.Y = vec.Y; | ||
657 | pos.Z = vec.Z; | ||
658 | return pos; | ||
659 | } | ||
660 | set | ||
661 | { | ||
662 | Vector3 vec = value; | ||
663 | Vec3 pos = new Vec3(); | ||
664 | pos.X = vec.X; | ||
665 | pos.Y = vec.Y; | ||
666 | pos.Z = vec.Z; | ||
667 | _prim.Position = pos; | ||
668 | } | ||
669 | } | ||
670 | |||
671 | public override PrimitiveBaseShape Shape | ||
672 | { | ||
673 | set { return; } | ||
674 | } | ||
675 | |||
676 | public override Vector3 Velocity | ||
677 | { | ||
678 | get { return _velocity; } | ||
679 | set { _velocity = value; } | ||
680 | } | ||
681 | |||
682 | public override Vector3 Torque | ||
683 | { | ||
684 | get { return Vector3.Zero; } | ||
685 | set { return; } | ||
686 | } | ||
687 | |||
688 | public override float CollisionScore | ||
689 | { | ||
690 | get { return 0f; } | ||
691 | set { } | ||
692 | } | ||
693 | |||
694 | public override bool Kinematic | ||
695 | { | ||
696 | get { return _prim.Kinematic; } | ||
697 | set { _prim.Kinematic = value; } | ||
698 | } | ||
699 | |||
700 | public override Quaternion Orientation | ||
701 | { | ||
702 | get | ||
703 | { | ||
704 | Quaternion res; | ||
705 | PhysXWrapper.Quaternion quat = _prim.GetOrientation(); | ||
706 | res.W = quat.W; | ||
707 | res.X = quat.X; | ||
708 | res.Y = quat.Y; | ||
709 | res.Z = quat.Z; | ||
710 | return res; | ||
711 | } | ||
712 | set { } | ||
713 | } | ||
714 | |||
715 | public override Vector3 Acceleration | ||
716 | { | ||
717 | get { return _acceleration; } | ||
718 | } | ||
719 | |||
720 | public void SetAcceleration(Vector3 accel) | ||
721 | { | ||
722 | _acceleration = accel; | ||
723 | } | ||
724 | |||
725 | public override void AddForce(Vector3 force, bool pushforce) | ||
726 | { | ||
727 | } | ||
728 | |||
729 | public override void AddAngularForce(Vector3 force, bool pushforce) | ||
730 | { | ||
731 | } | ||
732 | |||
733 | public override void SetMomentum(Vector3 momentum) | ||
734 | { | ||
735 | } | ||
736 | |||
737 | public override Vector3 Size | ||
738 | { | ||
739 | get { return Vector3.Zero; } | ||
740 | set { } | ||
741 | } | ||
742 | |||
743 | public override void link(PhysicsActor obj) | ||
744 | { | ||
745 | } | ||
746 | |||
747 | public override void delink() | ||
748 | { | ||
749 | } | ||
750 | |||
751 | public override void LockAngularMotion(Vector3 axis) | ||
752 | { | ||
753 | |||
754 | } | ||
755 | |||
756 | public override float Mass | ||
757 | { | ||
758 | get { return 0f; } | ||
759 | } | ||
760 | |||
761 | public override Vector3 Force | ||
762 | { | ||
763 | get { return Vector3.Zero; } | ||
764 | set { return; } | ||
765 | } | ||
766 | |||
767 | public override int VehicleType | ||
768 | { | ||
769 | get { return 0; } | ||
770 | set { return; } | ||
771 | } | ||
772 | |||
773 | public override void VehicleFloatParam(int param, float value) | ||
774 | { | ||
775 | |||
776 | } | ||
777 | |||
778 | public override void VehicleVectorParam(int param, Vector3 value) | ||
779 | { | ||
780 | |||
781 | } | ||
782 | |||
783 | public override void VehicleRotationParam(int param, Quaternion rotation) | ||
784 | { | ||
785 | |||
786 | } | ||
787 | |||
788 | public override void VehicleFlagsSet(int flags) | ||
789 | { | ||
790 | |||
791 | } | ||
792 | |||
793 | public override void VehicleFlagsRemove(int flags) | ||
794 | { | ||
795 | |||
796 | } | ||
797 | |||
798 | public override void SetVolumeDetect(int param) | ||
799 | { | ||
800 | |||
801 | } | ||
802 | |||
803 | public override Vector3 CenterOfMass | ||
804 | { | ||
805 | get { return Vector3.Zero; } | ||
806 | } | ||
807 | |||
808 | public override Vector3 GeometricCenter | ||
809 | { | ||
810 | get { return Vector3.Zero; } | ||
811 | } | ||
812 | |||
813 | public override void CrossingFailure() | ||
814 | { | ||
815 | } | ||
816 | |||
817 | public override Vector3 PIDTarget { set { return; } } | ||
818 | public override bool PIDActive { set { return; } } | ||
819 | public override float PIDTau { set { return; } } | ||
820 | |||
821 | public override float PIDHoverHeight { set { return; } } | ||
822 | public override bool PIDHoverActive { set { return; } } | ||
823 | public override PIDHoverType PIDHoverType { set { return; } } | ||
824 | public override float PIDHoverTau { set { return; } } | ||
825 | |||
826 | public override Quaternion APIDTarget | ||
827 | { | ||
828 | set { return; } | ||
829 | } | ||
830 | |||
831 | public override bool APIDActive | ||
832 | { | ||
833 | set { return; } | ||
834 | } | ||
835 | |||
836 | public override float APIDStrength | ||
837 | { | ||
838 | set { return; } | ||
839 | } | ||
840 | |||
841 | public override float APIDDamping | ||
842 | { | ||
843 | set { return; } | ||
844 | } | ||
845 | |||
846 | |||
847 | |||
848 | public override void SubscribeEvents(int ms) | ||
849 | { | ||
850 | |||
851 | } | ||
852 | public override void UnSubscribeEvents() | ||
853 | { | ||
854 | |||
855 | } | ||
856 | public override bool SubscribedEvents() | ||
857 | { | ||
858 | return false; | ||
859 | } | ||
860 | } | ||
861 | } | ||
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPrim.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPrim.cs new file mode 100644 index 0000000..d1b5b7e --- /dev/null +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPrim.cs | |||
@@ -0,0 +1,349 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using Nini.Config; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Physics.Manager; | ||
33 | using PhysXWrapper; | ||
34 | using Quaternion=OpenMetaverse.Quaternion; | ||
35 | using System.Reflection; | ||
36 | using log4net; | ||
37 | using OpenMetaverse; | ||
38 | |||
39 | namespace OpenSim.Region.Physics.PhysXPlugin | ||
40 | { | ||
41 | public class PhysXPrim : PhysicsActor | ||
42 | { | ||
43 | private Vector3 _velocity; | ||
44 | private Vector3 _acceleration; | ||
45 | private Vector3 m_rotationalVelocity; | ||
46 | private NxActor _prim; | ||
47 | |||
48 | public PhysXPrim(NxActor prim) | ||
49 | { | ||
50 | _velocity = Vector3.Zero; | ||
51 | _acceleration = Vector3.Zero; | ||
52 | _prim = prim; | ||
53 | } | ||
54 | |||
55 | public override int PhysicsActorType | ||
56 | { | ||
57 | get { return (int) ActorTypes.Prim; } | ||
58 | set { return; } | ||
59 | } | ||
60 | |||
61 | public override bool IsPhysical | ||
62 | { | ||
63 | get { return false; } | ||
64 | set { return; } | ||
65 | } | ||
66 | |||
67 | public override bool SetAlwaysRun | ||
68 | { | ||
69 | get { return false; } | ||
70 | set { return; } | ||
71 | } | ||
72 | |||
73 | public override uint LocalID | ||
74 | { | ||
75 | set { return; } | ||
76 | } | ||
77 | |||
78 | public override bool Grabbed | ||
79 | { | ||
80 | set { return; } | ||
81 | } | ||
82 | |||
83 | public override bool Selected | ||
84 | { | ||
85 | set { return; } | ||
86 | } | ||
87 | |||
88 | public override float Buoyancy | ||
89 | { | ||
90 | get { return 0f; } | ||
91 | set { return; } | ||
92 | } | ||
93 | |||
94 | public override bool FloatOnWater | ||
95 | { | ||
96 | set { return; } | ||
97 | } | ||
98 | |||
99 | public override bool ThrottleUpdates | ||
100 | { | ||
101 | get { return false; } | ||
102 | set { return; } | ||
103 | } | ||
104 | |||
105 | public override Vector3 RotationalVelocity | ||
106 | { | ||
107 | get { return m_rotationalVelocity; } | ||
108 | set { m_rotationalVelocity = value; } | ||
109 | } | ||
110 | |||
111 | public override bool Flying | ||
112 | { | ||
113 | get { return false; //no flying prims for you | ||
114 | } | ||
115 | set { } | ||
116 | } | ||
117 | |||
118 | public override bool IsColliding | ||
119 | { | ||
120 | get { return false; } | ||
121 | set { } | ||
122 | } | ||
123 | |||
124 | public override bool CollidingGround | ||
125 | { | ||
126 | get { return false; } | ||
127 | set { return; } | ||
128 | } | ||
129 | |||
130 | public override bool CollidingObj | ||
131 | { | ||
132 | get { return false; } | ||
133 | set { return; } | ||
134 | } | ||
135 | |||
136 | public override bool Stopped | ||
137 | { | ||
138 | get { return false; } | ||
139 | } | ||
140 | |||
141 | public override Vector3 Position | ||
142 | { | ||
143 | get | ||
144 | { | ||
145 | Vector3 pos = Vector3.Zero; | ||
146 | Vec3 vec = _prim.Position; | ||
147 | pos.X = vec.X; | ||
148 | pos.Y = vec.Y; | ||
149 | pos.Z = vec.Z; | ||
150 | return pos; | ||
151 | } | ||
152 | set | ||
153 | { | ||
154 | Vector3 vec = value; | ||
155 | Vec3 pos = new Vec3(); | ||
156 | pos.X = vec.X; | ||
157 | pos.Y = vec.Y; | ||
158 | pos.Z = vec.Z; | ||
159 | _prim.Position = pos; | ||
160 | } | ||
161 | } | ||
162 | |||
163 | public override PrimitiveBaseShape Shape | ||
164 | { | ||
165 | set { return; } | ||
166 | } | ||
167 | |||
168 | public override Vector3 Velocity | ||
169 | { | ||
170 | get { return _velocity; } | ||
171 | set { _velocity = value; } | ||
172 | } | ||
173 | |||
174 | public override Vector3 Torque | ||
175 | { | ||
176 | get { return Vector3.Zero; } | ||
177 | set { return; } | ||
178 | } | ||
179 | |||
180 | public override float CollisionScore | ||
181 | { | ||
182 | get { return 0f; } | ||
183 | set { } | ||
184 | } | ||
185 | |||
186 | public override bool Kinematic | ||
187 | { | ||
188 | get { return _prim.Kinematic; } | ||
189 | set { _prim.Kinematic = value; } | ||
190 | } | ||
191 | |||
192 | public override Quaternion Orientation | ||
193 | { | ||
194 | get | ||
195 | { | ||
196 | Quaternion res; | ||
197 | PhysXWrapper.Quaternion quat = _prim.GetOrientation(); | ||
198 | res.W = quat.W; | ||
199 | res.X = quat.X; | ||
200 | res.Y = quat.Y; | ||
201 | res.Z = quat.Z; | ||
202 | return res; | ||
203 | } | ||
204 | set { } | ||
205 | } | ||
206 | |||
207 | public override Vector3 Acceleration | ||
208 | { | ||
209 | get { return _acceleration; } | ||
210 | } | ||
211 | |||
212 | public void SetAcceleration(Vector3 accel) | ||
213 | { | ||
214 | _acceleration = accel; | ||
215 | } | ||
216 | |||
217 | public override void AddForce(Vector3 force, bool pushforce) | ||
218 | { | ||
219 | } | ||
220 | |||
221 | public override void AddAngularForce(Vector3 force, bool pushforce) | ||
222 | { | ||
223 | } | ||
224 | |||
225 | public override void SetMomentum(Vector3 momentum) | ||
226 | { | ||
227 | } | ||
228 | |||
229 | public override Vector3 Size | ||
230 | { | ||
231 | get { return Vector3.Zero; } | ||
232 | set { } | ||
233 | } | ||
234 | |||
235 | public override void link(PhysicsActor obj) | ||
236 | { | ||
237 | } | ||
238 | |||
239 | public override void delink() | ||
240 | { | ||
241 | } | ||
242 | |||
243 | public override void LockAngularMotion(Vector3 axis) | ||
244 | { | ||
245 | |||
246 | } | ||
247 | |||
248 | public override float Mass | ||
249 | { | ||
250 | get { return 0f; } | ||
251 | } | ||
252 | |||
253 | public override Vector3 Force | ||
254 | { | ||
255 | get { return Vector3.Zero; } | ||
256 | set { return; } | ||
257 | } | ||
258 | |||
259 | public override int VehicleType | ||
260 | { | ||
261 | get { return 0; } | ||
262 | set { return; } | ||
263 | } | ||
264 | |||
265 | public override void VehicleFloatParam(int param, float value) | ||
266 | { | ||
267 | |||
268 | } | ||
269 | |||
270 | public override void VehicleVectorParam(int param, Vector3 value) | ||
271 | { | ||
272 | |||
273 | } | ||
274 | |||
275 | public override void VehicleRotationParam(int param, Quaternion rotation) | ||
276 | { | ||
277 | |||
278 | } | ||
279 | |||
280 | public override void VehicleFlags(int param, bool remove) { } | ||
281 | |||
282 | public override void VehicleFlagsSet(int param) { } | ||
283 | |||
284 | public override void VehicleFlagsRemove(int param) { } | ||
285 | |||
286 | public override void SetVolumeDetect(int param) | ||
287 | { | ||
288 | |||
289 | } | ||
290 | |||
291 | public override Vector3 CenterOfMass | ||
292 | { | ||
293 | get { return Vector3.Zero; } | ||
294 | } | ||
295 | |||
296 | public override Vector3 GeometricCenter | ||
297 | { | ||
298 | get { return Vector3.Zero; } | ||
299 | } | ||
300 | |||
301 | public override void CrossingFailure() | ||
302 | { | ||
303 | } | ||
304 | |||
305 | public override Vector3 PIDTarget { set { return; } } | ||
306 | public override bool PIDActive { set { return; } } | ||
307 | public override float PIDTau { set { return; } } | ||
308 | |||
309 | public override float PIDHoverHeight { set { return; } } | ||
310 | public override bool PIDHoverActive { set { return; } } | ||
311 | public override PIDHoverType PIDHoverType { set { return; } } | ||
312 | public override float PIDHoverTau { set { return; } } | ||
313 | |||
314 | public override Quaternion APIDTarget | ||
315 | { | ||
316 | set { return; } | ||
317 | } | ||
318 | |||
319 | public override bool APIDActive | ||
320 | { | ||
321 | set { return; } | ||
322 | } | ||
323 | |||
324 | public override float APIDStrength | ||
325 | { | ||
326 | set { return; } | ||
327 | } | ||
328 | |||
329 | public override float APIDDamping | ||
330 | { | ||
331 | set { return; } | ||
332 | } | ||
333 | |||
334 | |||
335 | |||
336 | public override void SubscribeEvents(int ms) | ||
337 | { | ||
338 | |||
339 | } | ||
340 | public override void UnSubscribeEvents() | ||
341 | { | ||
342 | |||
343 | } | ||
344 | public override bool SubscribedEvents() | ||
345 | { | ||
346 | return false; | ||
347 | } | ||
348 | } | ||
349 | } | ||
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs new file mode 100644 index 0000000..4de4b01 --- /dev/null +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs | |||
@@ -0,0 +1,183 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using Nini.Config; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Physics.Manager; | ||
33 | using PhysXWrapper; | ||
34 | using Quaternion=OpenMetaverse.Quaternion; | ||
35 | using System.Reflection; | ||
36 | using log4net; | ||
37 | using OpenMetaverse; | ||
38 | |||
39 | namespace OpenSim.Region.Physics.PhysXPlugin | ||
40 | { | ||
41 | public class PhysXScene : PhysicsScene | ||
42 | { | ||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | private List<PhysXCharacter> _characters = new List<PhysXCharacter>(); | ||
45 | private List<PhysXPrim> _prims = new List<PhysXPrim>(); | ||
46 | private float[] _heightMap = null; | ||
47 | private NxPhysicsSDK mySdk; | ||
48 | private NxScene scene; | ||
49 | |||
50 | // protected internal string sceneIdentifier; | ||
51 | public PhysXScene(string _sceneIdentifier) | ||
52 | { | ||
53 | //sceneIdentifier = _sceneIdentifier; | ||
54 | |||
55 | mySdk = NxPhysicsSDK.CreateSDK(); | ||
56 | m_log.Info("Sdk created - now creating scene"); | ||
57 | scene = mySdk.CreateScene(); | ||
58 | } | ||
59 | |||
60 | public override void Initialise(IMesher meshmerizer, IConfigSource config) | ||
61 | { | ||
62 | // Does nothing right now | ||
63 | } | ||
64 | public override void Dispose() | ||
65 | { | ||
66 | |||
67 | } | ||
68 | |||
69 | public override void SetWaterLevel(float baseheight) | ||
70 | { | ||
71 | |||
72 | } | ||
73 | |||
74 | public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) | ||
75 | { | ||
76 | Vec3 pos = new Vec3(); | ||
77 | pos.X = position.X; | ||
78 | pos.Y = position.Y; | ||
79 | pos.Z = position.Z; | ||
80 | PhysXCharacter act = new PhysXCharacter(scene.AddCharacter(pos)); | ||
81 | act.Flying = isFlying; | ||
82 | act.Position = position; | ||
83 | _characters.Add(act); | ||
84 | return act; | ||
85 | } | ||
86 | |||
87 | public override void RemovePrim(PhysicsActor prim) | ||
88 | { | ||
89 | } | ||
90 | |||
91 | public override void RemoveAvatar(PhysicsActor actor) | ||
92 | { | ||
93 | } | ||
94 | |||
95 | private PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation) | ||
96 | { | ||
97 | Vec3 pos = new Vec3(); | ||
98 | pos.X = position.X; | ||
99 | pos.Y = position.Y; | ||
100 | pos.Z = position.Z; | ||
101 | Vec3 siz = new Vec3(); | ||
102 | siz.X = size.X; | ||
103 | siz.Y = size.Y; | ||
104 | siz.Z = size.Z; | ||
105 | PhysXPrim act = new PhysXPrim(scene.AddNewBox(pos, siz)); | ||
106 | _prims.Add(act); | ||
107 | return act; | ||
108 | } | ||
109 | |||
110 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
111 | Vector3 size, Quaternion rotation) //To be removed | ||
112 | { | ||
113 | return AddPrimShape(primName, pbs, position, size, rotation, false); | ||
114 | } | ||
115 | |||
116 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
117 | Vector3 size, Quaternion rotation, bool isPhysical) | ||
118 | { | ||
119 | return AddPrim(position, size, rotation); | ||
120 | } | ||
121 | |||
122 | public override void AddPhysicsActorTaint(PhysicsActor prim) | ||
123 | { | ||
124 | } | ||
125 | |||
126 | public override float Simulate(float timeStep) | ||
127 | { | ||
128 | float fps = 0f; | ||
129 | try | ||
130 | { | ||
131 | foreach (PhysXCharacter actor in _characters) | ||
132 | { | ||
133 | actor.Move(timeStep); | ||
134 | } | ||
135 | scene.Simulate(timeStep); | ||
136 | scene.FetchResults(); | ||
137 | scene.UpdateControllers(); | ||
138 | |||
139 | foreach (PhysXCharacter actor in _characters) | ||
140 | { | ||
141 | actor.UpdatePosition(); | ||
142 | } | ||
143 | } | ||
144 | catch (Exception e) | ||
145 | { | ||
146 | m_log.Error(e.Message); | ||
147 | } | ||
148 | return fps; | ||
149 | } | ||
150 | |||
151 | public override void GetResults() | ||
152 | { | ||
153 | } | ||
154 | |||
155 | public override bool IsThreaded | ||
156 | { | ||
157 | // for now we won't be multithreaded | ||
158 | get { return (false); } | ||
159 | } | ||
160 | |||
161 | public override void SetTerrain(float[] heightMap) | ||
162 | { | ||
163 | if (_heightMap != null) | ||
164 | { | ||
165 | m_log.Debug("PhysX - deleting old terrain"); | ||
166 | scene.DeleteTerrain(); | ||
167 | } | ||
168 | _heightMap = heightMap; | ||
169 | scene.AddTerrain(heightMap); | ||
170 | } | ||
171 | |||
172 | public override void DeleteTerrain() | ||
173 | { | ||
174 | scene.DeleteTerrain(); | ||
175 | } | ||
176 | |||
177 | public override Dictionary<uint, float> GetTopColliders() | ||
178 | { | ||
179 | Dictionary<uint, float> returncolliders = new Dictionary<uint, float>(); | ||
180 | return returncolliders; | ||
181 | } | ||
182 | } | ||
183 | } | ||