aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs56
1 files changed, 19 insertions, 37 deletions
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
index 6960f4e..7159754 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
@@ -69,8 +69,6 @@ using XnaDevRu.BulletX;
69using XnaDevRu.BulletX.Dynamics; 69using XnaDevRu.BulletX.Dynamics;
70using AxiomQuaternion = Axiom.Math.Quaternion; 70using AxiomQuaternion = Axiom.Math.Quaternion;
71using BoxShape=XnaDevRu.BulletX.BoxShape; 71using BoxShape=XnaDevRu.BulletX.BoxShape;
72//Specific References for BulletXPlugin
73
74#endregion 72#endregion
75 73
76namespace OpenSim.Region.Physics.BulletXPlugin 74namespace OpenSim.Region.Physics.BulletXPlugin
@@ -734,7 +732,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
734 return rigidBody; 732 return rigidBody;
735 } 733 }
736 } 734 }
737 public MonoXnaCompactMaths.Vector3 RigidBodyPosition 735 public Vector3 RigidBodyPosition
738 { 736 {
739 get { return this.rigidBody.CenterOfMassPosition; } 737 get { return this.rigidBody.CenterOfMassPosition; }
740 } 738 }
@@ -804,7 +802,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
804 } 802 }
805 internal protected void Translate(PhysicsVector _newPos) 803 internal protected void Translate(PhysicsVector _newPos)
806 { 804 {
807 MonoXnaCompactMaths.Vector3 _translation; 805 Vector3 _translation;
808 _translation = BulletXMaths.PhysicsVectorToXnaVector3(_newPos) - rigidBody.CenterOfMassPosition; 806 _translation = BulletXMaths.PhysicsVectorToXnaVector3(_newPos) - rigidBody.CenterOfMassPosition;
809 rigidBody.Translate(_translation); 807 rigidBody.Translate(_translation);
810 } 808 }
@@ -814,7 +812,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
814 } 812 }
815 internal protected void Speed(PhysicsVector _newSpeed) 813 internal protected void Speed(PhysicsVector _newSpeed)
816 { 814 {
817 MonoXnaCompactMaths.Vector3 _speed; 815 Vector3 _speed;
818 _speed = BulletXMaths.PhysicsVectorToXnaVector3(_newSpeed); 816 _speed = BulletXMaths.PhysicsVectorToXnaVector3(_newSpeed);
819 rigidBody.LinearVelocity = _speed; 817 rigidBody.LinearVelocity = _speed;
820 } 818 }
@@ -824,7 +822,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
824 } 822 }
825 internal protected void ReOrient(AxiomQuaternion _newOrient) 823 internal protected void ReOrient(AxiomQuaternion _newOrient)
826 { 824 {
827 MonoXnaCompactMaths.Quaternion _newOrientation; 825 Quaternion _newOrientation;
828 _newOrientation = BulletXMaths.AxiomQuaternionToXnaQuaternion(_newOrient); 826 _newOrientation = BulletXMaths.AxiomQuaternionToXnaQuaternion(_newOrient);
829 Matrix _comTransform = rigidBody.CenterOfMassTransform; 827 Matrix _comTransform = rigidBody.CenterOfMassTransform;
830 BulletXMaths.SetRotation(ref _comTransform, _newOrientation); 828 BulletXMaths.SetRotation(ref _comTransform, _newOrientation);
@@ -1033,6 +1031,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1033 if (rotation.Norm == 0f) rotation = AxiomQuaternion.Identity; 1031 if (rotation.Norm == 0f) rotation = AxiomQuaternion.Identity;
1034 1032
1035 _position = pos; 1033 _position = pos;
1034 //ZZZ
1035 _physical = false;
1036 //zzz
1036 if (_physical) _velocity = velocity; 1037 if (_physical) _velocity = velocity;
1037 else _velocity = new PhysicsVector(); 1038 else _velocity = new PhysicsVector();
1038 _size = size; 1039 _size = size;
@@ -1041,32 +1042,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1041 1042
1042 _parent_scene = parent_scene; 1043 _parent_scene = parent_scene;
1043 1044
1044 //For RigidBody Constructor. The next values might change 1045 CreateRigidBody(parent_scene, pos, size);
1045 float _linearDamping = 0.0f;
1046 float _angularDamping = 0.0f;
1047 float _friction = 0.5f;
1048 float _restitution = 0.0f;
1049 Matrix _startTransform = Matrix.Identity;
1050 Matrix _centerOfMassOffset = Matrix.Identity;
1051 lock (BulletXScene.BulletXLock)
1052 {
1053 _startTransform.Translation = BulletXMaths.PhysicsVectorToXnaVector3(pos);
1054 //For now all prims are boxes
1055 CollisionShape _collisionShape = new BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(_size)/2.0f);
1056 DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset);
1057 Vector3 _localInertia = new Vector3();
1058 if (_physical) _collisionShape.CalculateLocalInertia(Mass, out _localInertia); //Always when mass > 0
1059 rigidBody =
1060 new RigidBody(Mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping,
1061 _friction, _restitution);
1062 //rigidBody.ActivationState = ActivationState.DisableDeactivation;
1063 //It's seems that there are a bug with rigidBody constructor and its CenterOfMassPosition
1064 Vector3 _vDebugTranslation;
1065 _vDebugTranslation = _startTransform.Translation - rigidBody.CenterOfMassPosition;
1066 rigidBody.Translate(_vDebugTranslation);
1067 //---
1068 parent_scene.ddWorld.AddRigidBody(rigidBody);
1069 }
1070 } 1046 }
1071 1047
1072 public override PhysicsVector Position 1048 public override PhysicsVector Position
@@ -1108,7 +1084,10 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1108 get 1084 get
1109 { 1085 {
1110 //For now all prims are boxes 1086 //For now all prims are boxes
1111 return (_physical ? 1 : 0) * _density * _size.X * _size.Y * _size.Z; 1087 //ZZZ
1088 return _density * _size.X * _size.Y * _size.Z;
1089 //return (_physical ? 1 : 0) * _density * _size.X * _size.Y * _size.Z;
1090 //zzz
1112 } 1091 }
1113 } 1092 }
1114 public Boolean Physical 1093 public Boolean Physical
@@ -1210,7 +1189,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1210 //For RigidBody Constructor. The next values might change 1189 //For RigidBody Constructor. The next values might change
1211 float _linearDamping = 0.0f; 1190 float _linearDamping = 0.0f;
1212 float _angularDamping = 0.0f; 1191 float _angularDamping = 0.0f;
1213 float _friction = 0.5f; 1192 float _friction = 1.0f;
1214 float _restitution = 0.0f; 1193 float _restitution = 0.0f;
1215 Matrix _startTransform = Matrix.Identity; 1194 Matrix _startTransform = Matrix.Identity;
1216 Matrix _centerOfMassOffset = Matrix.Identity; 1195 Matrix _centerOfMassOffset = Matrix.Identity;
@@ -1220,12 +1199,15 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1220 //For now all prims are boxes 1199 //For now all prims are boxes
1221 CollisionShape _collisionShape = new XnaDevRu.BulletX.BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(size) / 2.0f); 1200 CollisionShape _collisionShape = new XnaDevRu.BulletX.BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(size) / 2.0f);
1222 DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset); 1201 DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset);
1223 MonoXnaCompactMaths.Vector3 _localInertia = new MonoXnaCompactMaths.Vector3(); 1202 Vector3 _localInertia = new Vector3();
1224 if (_physical) _collisionShape.CalculateLocalInertia(Mass, out _localInertia); //Always when mass > 0 1203 //ZZZ
1204 if (Mass > 0) _collisionShape.CalculateLocalInertia(Mass, out _localInertia); //Always when mass > 0
1205 //if (_physical) _collisionShape.CalculateLocalInertia(Mass, out _localInertia); //Always when mass > 0
1206 //zzz
1225 rigidBody = new RigidBody(Mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, _friction, _restitution); 1207 rigidBody = new RigidBody(Mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, _friction, _restitution);
1226 //rigidBody.ActivationState = ActivationState.DisableDeactivation; 1208 //rigidBody.ActivationState = ActivationState.DisableDeactivation;
1227 //It's seems that there are a bug with rigidBody constructor and its CenterOfMassPosition 1209 //It's seems that there are a bug with rigidBody constructor and its CenterOfMassPosition
1228 MonoXnaCompactMaths.Vector3 _vDebugTranslation; 1210 Vector3 _vDebugTranslation;
1229 _vDebugTranslation = _startTransform.Translation - rigidBody.CenterOfMassPosition; 1211 _vDebugTranslation = _startTransform.Translation - rigidBody.CenterOfMassPosition;
1230 rigidBody.Translate(_vDebugTranslation); 1212 rigidBody.Translate(_vDebugTranslation);
1231 //--- 1213 //---