aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
diff options
context:
space:
mode:
authorlbsa712007-12-27 21:41:48 +0000
committerlbsa712007-12-27 21:41:48 +0000
commitefd90b56b761219af6425b1c7a2cdd3b6ffb4de2 (patch)
treebf5b897e1e3c13211e3e2fc61d30508b94c928c0 /OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
parent* removed always true if (diff)
downloadopensim-SC_OLD-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.zip
opensim-SC_OLD-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.gz
opensim-SC_OLD-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.bz2
opensim-SC_OLD-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.xz
* Optimized usings
* shortened references * Removed redundant 'this' * Normalized EOF
Diffstat (limited to 'OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs')
-rw-r--r--OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs206
1 files changed, 124 insertions, 82 deletions
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
index 5602301..a88299e 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
@@ -70,12 +70,11 @@ using XnaDevRu.BulletX;
70using XnaDevRu.BulletX.Dynamics; 70using XnaDevRu.BulletX.Dynamics;
71using AxiomQuaternion = Axiom.Math.Quaternion; 71using AxiomQuaternion = Axiom.Math.Quaternion;
72using BoxShape=XnaDevRu.BulletX.BoxShape; 72using BoxShape=XnaDevRu.BulletX.BoxShape;
73#endregion
74 73
74#endregion
75 75
76namespace OpenSim.Region.Physics.BulletXPlugin 76namespace OpenSim.Region.Physics.BulletXPlugin
77{ 77{
78
79 /// <summary> 78 /// <summary>
80 /// BulletXConversions are called now BulletXMaths 79 /// BulletXConversions are called now BulletXMaths
81 /// This Class converts objects and types for BulletX and give some operations 80 /// This Class converts objects and types for BulletX and give some operations
@@ -263,25 +262,25 @@ namespace OpenSim.Region.Physics.BulletXPlugin
263 262
264 // Class to detect and debug collisions 263 // Class to detect and debug collisions
265 // Mainly used for debugging purposes 264 // Mainly used for debugging purposes
266 class CollisionDispatcherLocal : CollisionDispatcher 265 internal class CollisionDispatcherLocal : CollisionDispatcher
267 { 266 {
268 267 private BulletXScene relatedScene;
269 BulletXScene relatedScene;
270 268
271 public CollisionDispatcherLocal(BulletXScene s) 269 public CollisionDispatcherLocal(BulletXScene s)
272 : base() 270 : base()
273 { 271 {
274 relatedScene=s; 272 relatedScene = s;
275 } 273 }
276 274
277 public override bool NeedsCollision(CollisionObject bodyA, CollisionObject bodyB) 275 public override bool NeedsCollision(CollisionObject bodyA, CollisionObject bodyB)
278 { 276 {
279 RigidBody rb; 277 RigidBody rb;
280 BulletXCharacter bxcA=null; 278 BulletXCharacter bxcA = null;
281 BulletXPrim bxpA = null; 279 BulletXPrim bxpA = null;
282 Type t = bodyA.GetType(); 280 Type t = bodyA.GetType();
283 if (t==typeof(RigidBody)) { 281 if (t == typeof (RigidBody))
284 rb = (RigidBody)bodyA; 282 {
283 rb = (RigidBody) bodyA;
285 relatedScene._characters.TryGetValue(rb, out bxcA); 284 relatedScene._characters.TryGetValue(rb, out bxcA);
286 relatedScene._prims.TryGetValue(rb, out bxpA); 285 relatedScene._prims.TryGetValue(rb, out bxpA);
287 } 286 }
@@ -296,9 +295,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin
296 BulletXCharacter bxcB = null; 295 BulletXCharacter bxcB = null;
297 BulletXPrim bxpB = null; 296 BulletXPrim bxpB = null;
298 t = bodyB.GetType(); 297 t = bodyB.GetType();
299 if (t == typeof(RigidBody)) 298 if (t == typeof (RigidBody))
300 { 299 {
301 rb = (RigidBody)bodyB; 300 rb = (RigidBody) bodyB;
302 relatedScene._characters.TryGetValue(rb, out bxcB); 301 relatedScene._characters.TryGetValue(rb, out bxcB);
303 relatedScene._prims.TryGetValue(rb, out bxpB); 302 relatedScene._prims.TryGetValue(rb, out bxpB);
304 } 303 }
@@ -310,15 +309,16 @@ namespace OpenSim.Region.Physics.BulletXPlugin
310 else 309 else
311 nameB = "null"; 310 nameB = "null";
312 311
313 bool needsCollision=base.NeedsCollision(bodyA, bodyB); 312 bool needsCollision = base.NeedsCollision(bodyA, bodyB);
314 313
315 MainLog.Instance.Debug("BulletX", "A collision was detected between {0} and {1} --> {2}", nameA, nameB, needsCollision); 314 MainLog.Instance.Debug("BulletX", "A collision was detected between {0} and {1} --> {2}", nameA, nameB,
315 needsCollision);
316 316
317 317
318 return needsCollision; 318 return needsCollision;
319 } 319 }
320 } 320 }
321 321
322 /// <summary> 322 /// <summary>
323 /// PhysicsScene Class for BulletX 323 /// PhysicsScene Class for BulletX
324 /// </summary> 324 /// </summary>
@@ -439,7 +439,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
439 ((BulletXCharacter) actor).RigidBody.ActivationState = ActivationState.DisableSimulation; 439 ((BulletXCharacter) actor).RigidBody.ActivationState = ActivationState.DisableSimulation;
440 AddForgottenRigidBody(((BulletXCharacter) actor).RigidBody); 440 AddForgottenRigidBody(((BulletXCharacter) actor).RigidBody);
441 } 441 }
442 _characters.Remove(((BulletXCharacter)actor).RigidBody); 442 _characters.Remove(((BulletXCharacter) actor).RigidBody);
443 } 443 }
444 GC.Collect(); 444 GC.Collect();
445 } 445 }
@@ -448,8 +448,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin
448 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 448 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
449 PhysicsVector size, AxiomQuaternion rotation) 449 PhysicsVector size, AxiomQuaternion rotation)
450 { 450 {
451 return this.AddPrimShape(primName, pbs, position, size, rotation, false); 451 return AddPrimShape(primName, pbs, position, size, rotation, false);
452 } 452 }
453
453 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 454 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position,
454 PhysicsVector size, AxiomQuaternion rotation, bool isPhysical) 455 PhysicsVector size, AxiomQuaternion rotation, bool isPhysical)
455 { 456 {
@@ -514,7 +515,6 @@ namespace OpenSim.Region.Physics.BulletXPlugin
514 515
515 public override void AddPhysicsActorTaint(PhysicsActor prim) 516 public override void AddPhysicsActorTaint(PhysicsActor prim)
516 { 517 {
517
518 } 518 }
519 519
520 public override float Simulate(float timeStep) 520 public override float Simulate(float timeStep)
@@ -526,10 +526,10 @@ namespace OpenSim.Region.Physics.BulletXPlugin
526 RemoveForgottenRigidBodies(); 526 RemoveForgottenRigidBodies();
527 //End of remove 527 //End of remove
528 MoveAllObjects(timeStep); 528 MoveAllObjects(timeStep);
529 529
530 530
531 fps = (timeStep * simulationSubSteps); 531 fps = (timeStep*simulationSubSteps);
532 532
533 ddWorld.StepSimulation(timeStep, simulationSubSteps, timeStep); 533 ddWorld.StepSimulation(timeStep, simulationSubSteps, timeStep);
534 //Extra Heightmap Validation: BulletX's HeightFieldTerrain somestimes doesn't work so fine. 534 //Extra Heightmap Validation: BulletX's HeightFieldTerrain somestimes doesn't work so fine.
535 ValidateHeightForAll(); 535 ValidateHeightForAll();
@@ -768,7 +768,13 @@ namespace OpenSim.Region.Physics.BulletXPlugin
768 public override PhysicsVector Size 768 public override PhysicsVector Size
769 { 769 {
770 get { return _size; } 770 get { return _size; }
771 set { lock (BulletXScene.BulletXLock) { _size = value; } } 771 set
772 {
773 lock (BulletXScene.BulletXLock)
774 {
775 _size = value;
776 }
777 }
772 } 778 }
773 779
774 public override PhysicsVector Force 780 public override PhysicsVector Force
@@ -788,10 +794,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
788 794
789 public override PrimitiveBaseShape Shape 795 public override PrimitiveBaseShape Shape
790 { 796 {
791 set 797 set { return; }
792 {
793 return;
794 }
795 } 798 }
796 799
797 public override bool SetAlwaysRun 800 public override bool SetAlwaysRun
@@ -818,9 +821,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin
818 } 821 }
819 } 822 }
820 823
821 public override float Mass 824 public override float Mass
822 { 825 {
823 get { return ActorMass; } 826 get { return ActorMass; }
824 } 827 }
825 828
826 public virtual float ActorMass 829 public virtual float ActorMass
@@ -841,7 +844,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
841 844
842 public Vector3 RigidBodyPosition 845 public Vector3 RigidBodyPosition
843 { 846 {
844 get { return this.rigidBody.CenterOfMassPosition; } 847 get { return rigidBody.CenterOfMassPosition; }
845 } 848 }
846 849
847 public override bool IsPhysical 850 public override bool IsPhysical
@@ -855,6 +858,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
855 get { return flying; } 858 get { return flying; }
856 set { flying = value; } 859 set { flying = value; }
857 } 860 }
861
858 public override bool ThrottleUpdates 862 public override bool ThrottleUpdates
859 { 863 {
860 get { return false; } 864 get { return false; }
@@ -889,19 +893,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin
889 893
890 public override bool Kinematic 894 public override bool Kinematic
891 { 895 {
892 get 896 get { return false; }
893 { 897 set { }
894 return false;
895 }
896 set
897 {
898
899 }
900 } 898 }
901 899
902 public override void AddForce(PhysicsVector force) 900 public override void AddForce(PhysicsVector force)
903 { 901 {
904
905 } 902 }
906 903
907 public override void SetMomentum(PhysicsVector momentum) 904 public override void SetMomentum(PhysicsVector momentum)
@@ -917,31 +914,37 @@ namespace OpenSim.Region.Physics.BulletXPlugin
917 } 914 }
918 915
919 #region Methods for updating values of RigidBody 916 #region Methods for updating values of RigidBody
920 internal protected void Translate() 917
918 protected internal void Translate()
921 { 919 {
922 Translate(this._position); 920 Translate(_position);
923 } 921 }
924 internal protected void Translate(PhysicsVector _newPos) 922
923 protected internal void Translate(PhysicsVector _newPos)
925 { 924 {
926 Vector3 _translation; 925 Vector3 _translation;
927 _translation = BulletXMaths.PhysicsVectorToXnaVector3(_newPos) - rigidBody.CenterOfMassPosition; 926 _translation = BulletXMaths.PhysicsVectorToXnaVector3(_newPos) - rigidBody.CenterOfMassPosition;
928 rigidBody.Translate(_translation); 927 rigidBody.Translate(_translation);
929 } 928 }
930 internal protected void Speed() 929
930 protected internal void Speed()
931 { 931 {
932 Speed(this._velocity); 932 Speed(_velocity);
933 } 933 }
934 internal protected void Speed(PhysicsVector _newSpeed) 934
935 protected internal void Speed(PhysicsVector _newSpeed)
935 { 936 {
936 Vector3 _speed; 937 Vector3 _speed;
937 _speed = BulletXMaths.PhysicsVectorToXnaVector3(_newSpeed); 938 _speed = BulletXMaths.PhysicsVectorToXnaVector3(_newSpeed);
938 rigidBody.LinearVelocity = _speed; 939 rigidBody.LinearVelocity = _speed;
939 } 940 }
940 internal protected void ReOrient() 941
942 protected internal void ReOrient()
941 { 943 {
942 ReOrient(this._orientation); 944 ReOrient(_orientation);
943 } 945 }
944 internal protected void ReOrient(AxiomQuaternion _newOrient) 946
947 protected internal void ReOrient(AxiomQuaternion _newOrient)
945 { 948 {
946 Quaternion _newOrientation; 949 Quaternion _newOrientation;
947 _newOrientation = BulletXMaths.AxiomQuaternionToXnaQuaternion(_newOrient); 950 _newOrientation = BulletXMaths.AxiomQuaternionToXnaQuaternion(_newOrient);
@@ -949,17 +952,21 @@ namespace OpenSim.Region.Physics.BulletXPlugin
949 BulletXMaths.SetRotation(ref _comTransform, _newOrientation); 952 BulletXMaths.SetRotation(ref _comTransform, _newOrientation);
950 rigidBody.CenterOfMassTransform = _comTransform; 953 rigidBody.CenterOfMassTransform = _comTransform;
951 } 954 }
952 internal protected void ReSize() 955
956 protected internal void ReSize()
953 { 957 {
954 ReSize(this._size); 958 ReSize(_size);
955 } 959 }
956 internal protected virtual void ReSize(PhysicsVector _newSize) 960
961 protected internal virtual void ReSize(PhysicsVector _newSize)
957 { 962 {
958 } 963 }
964
959 public virtual void ScheduleTerseUpdate() 965 public virtual void ScheduleTerseUpdate()
960 { 966 {
961 base.RequestPhysicsterseUpdate(); 967 base.RequestPhysicsterseUpdate();
962 } 968 }
969
963 #endregion 970 #endregion
964 } 971 }
965 972
@@ -972,11 +979,13 @@ namespace OpenSim.Region.Physics.BulletXPlugin
972 : this("", parent_scene, pos) 979 : this("", parent_scene, pos)
973 { 980 {
974 } 981 }
982
975 public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos) 983 public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos)
976 : this(avName, parent_scene, pos, new PhysicsVector(), new PhysicsVector(), new PhysicsVector(), 984 : this(avName, parent_scene, pos, new PhysicsVector(), new PhysicsVector(), new PhysicsVector(),
977 AxiomQuaternion.Identity) 985 AxiomQuaternion.Identity)
978 { 986 {
979 } 987 }
988
980 public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity, 989 public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity,
981 PhysicsVector size, PhysicsVector acceleration, AxiomQuaternion orientation) 990 PhysicsVector size, PhysicsVector acceleration, AxiomQuaternion orientation)
982 : base(avName) 991 : base(avName)
@@ -1026,45 +1035,54 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1026 parent_scene.ddWorld.AddRigidBody(rigidBody); 1035 parent_scene.ddWorld.AddRigidBody(rigidBody);
1027 } 1036 }
1028 } 1037 }
1038
1029 public override int PhysicsActorType 1039 public override int PhysicsActorType
1030 { 1040 {
1031 get { return (int)ActorTypes.Agent; } 1041 get { return (int) ActorTypes.Agent; }
1032 set { return; } 1042 set { return; }
1033 } 1043 }
1044
1034 public override PhysicsVector Position 1045 public override PhysicsVector Position
1035 { 1046 {
1036 get { return base.Position; } 1047 get { return base.Position; }
1037 set { base.Position = value; } 1048 set { base.Position = value; }
1038 } 1049 }
1050
1039 public override PhysicsVector Velocity 1051 public override PhysicsVector Velocity
1040 { 1052 {
1041 get { return base.Velocity; } 1053 get { return base.Velocity; }
1042 set { base.Velocity = value; } 1054 set { base.Velocity = value; }
1043 } 1055 }
1056
1044 public override PhysicsVector Size 1057 public override PhysicsVector Size
1045 { 1058 {
1046 get { return base.Size; } 1059 get { return base.Size; }
1047 set { base.Size = value; } 1060 set { base.Size = value; }
1048 } 1061 }
1062
1049 public override PhysicsVector Acceleration 1063 public override PhysicsVector Acceleration
1050 { 1064 {
1051 get { return base.Acceleration; } 1065 get { return base.Acceleration; }
1052 } 1066 }
1067
1053 public override AxiomQuaternion Orientation 1068 public override AxiomQuaternion Orientation
1054 { 1069 {
1055 get { return base.Orientation; } 1070 get { return base.Orientation; }
1056 set { base.Orientation = value; } 1071 set { base.Orientation = value; }
1057 } 1072 }
1073
1058 public override bool Flying 1074 public override bool Flying
1059 { 1075 {
1060 get { return base.Flying; } 1076 get { return base.Flying; }
1061 set { base.Flying = value; } 1077 set { base.Flying = value; }
1062 } 1078 }
1079
1063 public override bool IsColliding 1080 public override bool IsColliding
1064 { 1081 {
1065 get { return base.IsColliding; } 1082 get { return base.IsColliding; }
1066 set { base.IsColliding = value; } 1083 set { base.IsColliding = value; }
1067 } 1084 }
1085
1068 public override bool Kinematic 1086 public override bool Kinematic
1069 { 1087 {
1070 get { return base.Kinematic; } 1088 get { return base.Kinematic; }
@@ -1075,10 +1093,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1075 { 1093 {
1076 base.SetAcceleration(accel); 1094 base.SetAcceleration(accel);
1077 } 1095 }
1096
1078 public override void AddForce(PhysicsVector force) 1097 public override void AddForce(PhysicsVector force)
1079 { 1098 {
1080 base.AddForce(force); 1099 base.AddForce(force);
1081 } 1100 }
1101
1082 public override void SetMomentum(PhysicsVector momentum) 1102 public override void SetMomentum(PhysicsVector momentum)
1083 { 1103 {
1084 base.SetMomentum(momentum); 1104 base.SetMomentum(momentum);
@@ -1117,6 +1137,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1117 } 1137 }
1118 rigidBody.LinearVelocity = vec; 1138 rigidBody.LinearVelocity = vec;
1119 } 1139 }
1140
1120 //This validation is very basic 1141 //This validation is very basic
1121 internal override void ValidateHeight(float heighmapPositionValue) 1142 internal override void ValidateHeight(float heighmapPositionValue)
1122 { 1143 {
@@ -1131,6 +1152,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1131 Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f)); 1152 Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f));
1132 } 1153 }
1133 } 1154 }
1155
1134 internal override void UpdateKinetics() 1156 internal override void UpdateKinetics()
1135 { 1157 {
1136 _position = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.CenterOfMassPosition); 1158 _position = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.CenterOfMassPosition);
@@ -1154,12 +1176,15 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1154 1176
1155 public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector size, 1177 public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector size,
1156 AxiomQuaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool isPhysical) 1178 AxiomQuaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool isPhysical)
1157 : this(primName, parent_scene, pos, new PhysicsVector(), size, new PhysicsVector(), rotation, mesh, pbs, isPhysical) 1179 : this(
1180 primName, parent_scene, pos, new PhysicsVector(), size, new PhysicsVector(), rotation, mesh, pbs,
1181 isPhysical)
1158 { 1182 {
1159 } 1183 }
1184
1160 public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity, 1185 public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity,
1161 PhysicsVector size, 1186 PhysicsVector size,
1162 PhysicsVector acceleration, AxiomQuaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, 1187 PhysicsVector acceleration, AxiomQuaternion rotation, IMesh mesh, PrimitiveBaseShape pbs,
1163 bool isPhysical) 1188 bool isPhysical)
1164 : base(primName) 1189 : base(primName)
1165 { 1190 {
@@ -1177,27 +1202,28 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1177 1202
1178 CreateRigidBody(parent_scene, mesh, pos, size); 1203 CreateRigidBody(parent_scene, mesh, pos, size);
1179 } 1204 }
1205
1180 public override int PhysicsActorType 1206 public override int PhysicsActorType
1181 { 1207 {
1182 get { return (int)ActorTypes.Prim; } 1208 get { return (int) ActorTypes.Prim; }
1183 set { return; } 1209 set { return; }
1184 } 1210 }
1211
1185 public override PhysicsVector Position 1212 public override PhysicsVector Position
1186 { 1213 {
1187 get { return base.Position; } 1214 get { return base.Position; }
1188 set { base.Position = value; } 1215 set { base.Position = value; }
1189 } 1216 }
1217
1190 public override PhysicsVector Velocity 1218 public override PhysicsVector Velocity
1191 { 1219 {
1192 get { return base.Velocity; } 1220 get { return base.Velocity; }
1193 set { base.Velocity = value; } 1221 set { base.Velocity = value; }
1194 } 1222 }
1223
1195 public override PhysicsVector Size 1224 public override PhysicsVector Size
1196 { 1225 {
1197 get 1226 get { return _size; }
1198 {
1199 return _size;
1200 }
1201 set 1227 set
1202 { 1228 {
1203 lock (BulletXScene.BulletXLock) 1229 lock (BulletXScene.BulletXLock)
@@ -1207,29 +1233,30 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1207 } 1233 }
1208 } 1234 }
1209 } 1235 }
1236
1210 public override PhysicsVector Acceleration 1237 public override PhysicsVector Acceleration
1211 { 1238 {
1212 get { return base.Acceleration; } 1239 get { return base.Acceleration; }
1213 } 1240 }
1241
1214 public override AxiomQuaternion Orientation 1242 public override AxiomQuaternion Orientation
1215 { 1243 {
1216 get { return base.Orientation; } 1244 get { return base.Orientation; }
1217 set { base.Orientation = value; } 1245 set { base.Orientation = value; }
1218 } 1246 }
1247
1219 public override float ActorMass 1248 public override float ActorMass
1220 { 1249 {
1221 get 1250 get
1222 { 1251 {
1223 //For now all prims are boxes 1252 //For now all prims are boxes
1224 return (_physical ? 1 : 0) * _density * _size.X * _size.Y * _size.Z; 1253 return (_physical ? 1 : 0)*_density*_size.X*_size.Y*_size.Z;
1225 } 1254 }
1226 } 1255 }
1256
1227 public override bool IsPhysical 1257 public override bool IsPhysical
1228 { 1258 {
1229 get 1259 get { return base.IsPhysical; }
1230 {
1231 return base.IsPhysical;
1232 }
1233 set 1260 set
1234 { 1261 {
1235 base.IsPhysical = value; 1262 base.IsPhysical = value;
@@ -1238,27 +1265,30 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1238 //--- 1265 //---
1239 PhysicsPluginManager.PhysicsPluginMessage("Physical - Recreate", true); 1266 PhysicsPluginManager.PhysicsPluginMessage("Physical - Recreate", true);
1240 //--- 1267 //---
1241 ReCreateRigidBody(this._size); 1268 ReCreateRigidBody(_size);
1242 } 1269 }
1243 else 1270 else
1244 { 1271 {
1245 //--- 1272 //---
1246 PhysicsPluginManager.PhysicsPluginMessage("Physical - SetMassProps", true); 1273 PhysicsPluginManager.PhysicsPluginMessage("Physical - SetMassProps", true);
1247 //--- 1274 //---
1248 this.rigidBody.SetMassProps(Mass, new Vector3()); 1275 rigidBody.SetMassProps(Mass, new Vector3());
1249 } 1276 }
1250 } 1277 }
1251 } 1278 }
1279
1252 public override bool Flying 1280 public override bool Flying
1253 { 1281 {
1254 get { return base.Flying; } 1282 get { return base.Flying; }
1255 set { base.Flying = value; } 1283 set { base.Flying = value; }
1256 } 1284 }
1285
1257 public override bool IsColliding 1286 public override bool IsColliding
1258 { 1287 {
1259 get { return base.IsColliding; } 1288 get { return base.IsColliding; }
1260 set { base.IsColliding = value; } 1289 set { base.IsColliding = value; }
1261 } 1290 }
1291
1262 public override bool Kinematic 1292 public override bool Kinematic
1263 { 1293 {
1264 get { return base.Kinematic; } 1294 get { return base.Kinematic; }
@@ -1272,10 +1302,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1272 _acceleration = accel; 1302 _acceleration = accel;
1273 } 1303 }
1274 } 1304 }
1305
1275 public override void AddForce(PhysicsVector force) 1306 public override void AddForce(PhysicsVector force)
1276 { 1307 {
1277 base.AddForce(force); 1308 base.AddForce(force);
1278 } 1309 }
1310
1279 public override void SetMomentum(PhysicsVector momentum) 1311 public override void SetMomentum(PhysicsVector momentum)
1280 { 1312 {
1281 base.SetMomentum(momentum); 1313 base.SetMomentum(momentum);
@@ -1296,6 +1328,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1296 Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f)); 1328 Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f));
1297 } 1329 }
1298 } 1330 }
1331
1299 internal override void UpdateKinetics() 1332 internal override void UpdateKinetics()
1300 { 1333 {
1301 if (_physical) //Updates properties. Prim updates its properties physically 1334 if (_physical) //Updates properties. Prim updates its properties physically
@@ -1320,7 +1353,6 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1320 { 1353 {
1321 m_lastUpdateSent = false; 1354 m_lastUpdateSent = false;
1322 base.ScheduleTerseUpdate(); 1355 base.ScheduleTerseUpdate();
1323
1324 } 1356 }
1325 m_prev_position = _position; 1357 m_prev_position = _position;
1326 } 1358 }
@@ -1333,7 +1365,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1333 } 1365 }
1334 1366
1335 #region Methods for updating values of RigidBody 1367 #region Methods for updating values of RigidBody
1336 internal protected void CreateRigidBody(BulletXScene parent_scene, IMesh mesh, PhysicsVector pos, PhysicsVector size) 1368
1369 protected internal void CreateRigidBody(BulletXScene parent_scene, IMesh mesh, PhysicsVector pos,
1370 PhysicsVector size)
1337 { 1371 {
1338 //For RigidBody Constructor. The next values might change 1372 //For RigidBody Constructor. The next values might change
1339 float _linearDamping = 0.0f; 1373 float _linearDamping = 0.0f;
@@ -1349,27 +1383,31 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1349 CollisionShape _collisionShape; 1383 CollisionShape _collisionShape;
1350 if (mesh == null) 1384 if (mesh == null)
1351 { 1385 {
1352 _collisionShape = new XnaDevRu.BulletX.BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(size) / 2.0f); 1386 _collisionShape = new BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(size)/2.0f);
1353 } else { 1387 }
1388 else
1389 {
1354 int iVertexCount = mesh.getVertexList().Count; 1390 int iVertexCount = mesh.getVertexList().Count;
1355 int[] indices = mesh.getIndexListAsInt(); 1391 int[] indices = mesh.getIndexListAsInt();
1356 Vector3[] v3Vertices = new Vector3[iVertexCount]; 1392 Vector3[] v3Vertices = new Vector3[iVertexCount];
1357 for (int i = 0; i < iVertexCount; i++) 1393 for (int i = 0; i < iVertexCount; i++)
1358 { 1394 {
1359 PhysicsVector v=mesh.getVertexList()[i]; 1395 PhysicsVector v = mesh.getVertexList()[i];
1360 if (v != null) // Note, null has special meaning. See meshing code for details 1396 if (v != null) // Note, null has special meaning. See meshing code for details
1361 v3Vertices[i] = BulletXMaths.PhysicsVectorToXnaVector3(v); 1397 v3Vertices[i] = BulletXMaths.PhysicsVectorToXnaVector3(v);
1362 else 1398 else
1363 v3Vertices[i] = MonoXnaCompactMaths.Vector3.Zero; 1399 v3Vertices[i] = Vector3.Zero;
1364 } 1400 }
1365 TriangleIndexVertexArray triMesh = new TriangleIndexVertexArray(indices, v3Vertices); 1401 TriangleIndexVertexArray triMesh = new TriangleIndexVertexArray(indices, v3Vertices);
1366 1402
1367 _collisionShape = new XnaDevRu.BulletX.TriangleMeshShape(triMesh); 1403 _collisionShape = new TriangleMeshShape(triMesh);
1368 } 1404 }
1369 DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset); 1405 DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset);
1370 Vector3 _localInertia = new Vector3(); 1406 Vector3 _localInertia = new Vector3();
1371 if (_physical) _collisionShape.CalculateLocalInertia(Mass, out _localInertia); //Always when mass > 0 1407 if (_physical) _collisionShape.CalculateLocalInertia(Mass, out _localInertia); //Always when mass > 0
1372 rigidBody = new RigidBody(Mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, _friction, _restitution); 1408 rigidBody =
1409 new RigidBody(Mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping,
1410 _friction, _restitution);
1373 //rigidBody.ActivationState = ActivationState.DisableDeactivation; 1411 //rigidBody.ActivationState = ActivationState.DisableDeactivation;
1374 //It's seems that there are a bug with rigidBody constructor and its CenterOfMassPosition 1412 //It's seems that there are a bug with rigidBody constructor and its CenterOfMassPosition
1375 Vector3 _vDebugTranslation; 1413 Vector3 _vDebugTranslation;
@@ -1379,30 +1417,34 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1379 parent_scene.ddWorld.AddRigidBody(rigidBody); 1417 parent_scene.ddWorld.AddRigidBody(rigidBody);
1380 } 1418 }
1381 } 1419 }
1382 internal protected void ReCreateRigidBody(PhysicsVector size) 1420
1421 protected internal void ReCreateRigidBody(PhysicsVector size)
1383 { 1422 {
1384 //There is a bug when trying to remove a rigidBody that is colliding with something.. 1423 //There is a bug when trying to remove a rigidBody that is colliding with something..
1385 try 1424 try
1386 { 1425 {
1387 this._parent_scene.ddWorld.RemoveRigidBody(rigidBody); 1426 _parent_scene.ddWorld.RemoveRigidBody(rigidBody);
1388 } 1427 }
1389 catch (Exception ex) 1428 catch (Exception ex)
1390 { 1429 {
1391 this._parent_scene.BulletXMessage(this._parent_scene.is_ex_message + ex.Message, true); 1430 _parent_scene.BulletXMessage(_parent_scene.is_ex_message + ex.Message, true);
1392 rigidBody.ActivationState = ActivationState.DisableSimulation; 1431 rigidBody.ActivationState = ActivationState.DisableSimulation;
1393 this._parent_scene.AddForgottenRigidBody(rigidBody); 1432 _parent_scene.AddForgottenRigidBody(rigidBody);
1394 } 1433 }
1395 CreateRigidBody(this._parent_scene, null, this._position, size); // Note, null for the meshing definitely is wrong. It's here for the moment to apease the compiler 1434 CreateRigidBody(_parent_scene, null, _position, size);
1396 if (_physical) Speed();//Static objects don't have linear velocity 1435 // Note, null for the meshing definitely is wrong. It's here for the moment to apease the compiler
1436 if (_physical) Speed(); //Static objects don't have linear velocity
1397 ReOrient(); 1437 ReOrient();
1398 GC.Collect(); 1438 GC.Collect();
1399 } 1439 }
1400 internal protected override void ReSize(PhysicsVector _newSize) 1440
1441 protected internal override void ReSize(PhysicsVector _newSize)
1401 { 1442 {
1402 //I wonder to know how to resize with a simple instruction in BulletX. It seems that for now there isn't 1443 //I wonder to know how to resize with a simple instruction in BulletX. It seems that for now there isn't
1403 //so i have to do it manually. That's recreating rigidbody 1444 //so i have to do it manually. That's recreating rigidbody
1404 ReCreateRigidBody(_newSize); 1445 ReCreateRigidBody(_newSize);
1405 } 1446 }
1447
1406 #endregion 1448 #endregion
1407 } 1449 }
1408 1450
@@ -1486,4 +1528,4 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1486 return height; 1528 return height;
1487 } 1529 }
1488 } 1530 }
1489} 1531} \ No newline at end of file