aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs')
-rw-r--r--OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs374
1 files changed, 187 insertions, 187 deletions
diff --git a/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs b/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs
index 8934330..b1c3b7c 100644
--- a/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs
+++ b/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs
@@ -212,7 +212,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
212 212
213 public IntPtr Body = IntPtr.Zero; 213 public IntPtr Body = IntPtr.Zero;
214 private Vector3 _target_velocity; 214 private Vector3 _target_velocity;
215 private d.Mass pMass; 215 private SafeNativeMethods.Mass pMass;
216 216
217 private int m_eventsubscription; 217 private int m_eventsubscription;
218 private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); 218 private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate();
@@ -356,13 +356,13 @@ namespace OpenSim.Region.PhysicsModule.ODE
356 356
357 if (m_assetFailed) 357 if (m_assetFailed)
358 { 358 {
359 d.GeomSetCategoryBits(prim_geom, 0); 359 SafeNativeMethods.GeomSetCategoryBits(prim_geom, 0);
360 d.GeomSetCollideBits(prim_geom, (uint)BadMeshAssetCollideBits); 360 SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)BadMeshAssetCollideBits);
361 } 361 }
362 else 362 else
363 { 363 {
364 d.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); 364 SafeNativeMethods.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories);
365 d.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); 365 SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags);
366 } 366 }
367 367
368 _parent_scene.geom_name_map[prim_geom] = Name; 368 _parent_scene.geom_name_map[prim_geom] = Name;
@@ -386,7 +386,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
386 { 386 {
387 if (IsPhysical && Body != IntPtr.Zero) 387 if (IsPhysical && Body != IntPtr.Zero)
388 { 388 {
389 d.BodyEnable(Body); 389 SafeNativeMethods.BodyEnable(Body);
390 if (m_vehicle.Type != Vehicle.TYPE_NONE) 390 if (m_vehicle.Type != Vehicle.TYPE_NONE)
391 m_vehicle.Enable(Body, _parent_scene); 391 m_vehicle.Enable(Body, _parent_scene);
392 } 392 }
@@ -401,7 +401,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
401 401
402 if (IsPhysical && Body != IntPtr.Zero) 402 if (IsPhysical && Body != IntPtr.Zero)
403 { 403 {
404 d.BodyDisable(Body); 404 SafeNativeMethods.BodyDisable(Body);
405 } 405 }
406 } 406 }
407 407
@@ -415,22 +415,22 @@ namespace OpenSim.Region.PhysicsModule.ODE
415 if (!childPrim) 415 if (!childPrim)
416 { 416 {
417 // Sets the geom to a body 417 // Sets the geom to a body
418 Body = d.BodyCreate(_parent_scene.world); 418 Body = SafeNativeMethods.BodyCreate(_parent_scene.world);
419 419
420 setMass(); 420 setMass();
421 d.BodySetPosition(Body, _position.X, _position.Y, _position.Z); 421 SafeNativeMethods.BodySetPosition(Body, _position.X, _position.Y, _position.Z);
422 d.Quaternion myrot = new d.Quaternion(); 422 SafeNativeMethods.Quaternion myrot = new SafeNativeMethods.Quaternion();
423 myrot.X = _orientation.X; 423 myrot.X = _orientation.X;
424 myrot.Y = _orientation.Y; 424 myrot.Y = _orientation.Y;
425 myrot.Z = _orientation.Z; 425 myrot.Z = _orientation.Z;
426 myrot.W = _orientation.W; 426 myrot.W = _orientation.W;
427 d.BodySetQuaternion(Body, ref myrot); 427 SafeNativeMethods.BodySetQuaternion(Body, ref myrot);
428 d.GeomSetBody(prim_geom, Body); 428 SafeNativeMethods.GeomSetBody(prim_geom, Body);
429 429
430 if (m_assetFailed) 430 if (m_assetFailed)
431 { 431 {
432 d.GeomSetCategoryBits(prim_geom, 0); 432 SafeNativeMethods.GeomSetCategoryBits(prim_geom, 0);
433 d.GeomSetCollideBits(prim_geom, (uint)BadMeshAssetCollideBits); 433 SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)BadMeshAssetCollideBits);
434 } 434 }
435 else 435 else
436 { 436 {
@@ -438,14 +438,14 @@ namespace OpenSim.Region.PhysicsModule.ODE
438 m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); 438 m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
439 } 439 }
440 440
441 d.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); 441 SafeNativeMethods.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories);
442 d.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); 442 SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags);
443 443
444 d.BodySetAutoDisableFlag(Body, true); 444 SafeNativeMethods.BodySetAutoDisableFlag(Body, true);
445 d.BodySetAutoDisableSteps(Body, body_autodisable_frames); 445 SafeNativeMethods.BodySetAutoDisableSteps(Body, body_autodisable_frames);
446 446
447 // disconnect from world gravity so we can apply buoyancy 447 // disconnect from world gravity so we can apply buoyancy
448 d.BodySetGravityMode (Body, false); 448 SafeNativeMethods.BodySetGravityMode (Body, false);
449 449
450 m_interpenetrationcount = 0; 450 m_interpenetrationcount = 0;
451 m_collisionscore = 0; 451 m_collisionscore = 0;
@@ -787,8 +787,8 @@ namespace OpenSim.Region.PhysicsModule.ODE
787 787
788 //m_log.Info("[PHYSICS]: New Mass: " + newmass.ToString()); 788 //m_log.Info("[PHYSICS]: New Mass: " + newmass.ToString());
789 789
790 d.MassSetBoxTotal(out pMass, newmass, _size.X, _size.Y, _size.Z); 790 SafeNativeMethods.MassSetBoxTotal(out pMass, newmass, _size.X, _size.Y, _size.Z);
791 d.BodySetMass(Body, ref pMass); 791 SafeNativeMethods.BodySetMass(Body, ref pMass);
792 } 792 }
793 } 793 }
794 794
@@ -796,7 +796,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
796 { 796 {
797 if (Body != (IntPtr)0) 797 if (Body != (IntPtr)0)
798 { 798 {
799 d.BodySetAngularVel(Body, x, y, z); 799 SafeNativeMethods.BodySetAngularVel(Body, x, y, z);
800 } 800 }
801 } 801 }
802 802
@@ -818,16 +818,16 @@ namespace OpenSim.Region.PhysicsModule.ODE
818 818
819 if (m_assetFailed) 819 if (m_assetFailed)
820 { 820 {
821 d.GeomSetCategoryBits(prim_geom, 0); 821 SafeNativeMethods.GeomSetCategoryBits(prim_geom, 0);
822 d.GeomSetCollideBits(prim_geom, 0); 822 SafeNativeMethods.GeomSetCollideBits(prim_geom, 0);
823 } 823 }
824 else 824 else
825 { 825 {
826 d.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); 826 SafeNativeMethods.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories);
827 d.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); 827 SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags);
828 } 828 }
829 829
830 d.BodyDestroy(Body); 830 SafeNativeMethods.BodyDestroy(Body);
831 lock (childrenPrim) 831 lock (childrenPrim)
832 { 832 {
833 if (childrenPrim.Count > 0) 833 if (childrenPrim.Count > 0)
@@ -851,14 +851,14 @@ namespace OpenSim.Region.PhysicsModule.ODE
851 851
852 if (m_assetFailed) 852 if (m_assetFailed)
853 { 853 {
854 d.GeomSetCategoryBits(prim_geom, 0); 854 SafeNativeMethods.GeomSetCategoryBits(prim_geom, 0);
855 d.GeomSetCollideBits(prim_geom, 0); 855 SafeNativeMethods.GeomSetCollideBits(prim_geom, 0);
856 } 856 }
857 else 857 else
858 { 858 {
859 859
860 d.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); 860 SafeNativeMethods.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories);
861 d.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); 861 SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags);
862 } 862 }
863 863
864 Body = IntPtr.Zero; 864 Body = IntPtr.Zero;
@@ -915,10 +915,10 @@ namespace OpenSim.Region.PhysicsModule.ODE
915 } 915 }
916 else 916 else
917 { 917 {
918 _triMeshData = d.GeomTriMeshDataCreate(); 918 _triMeshData = SafeNativeMethods.GeomTriMeshDataCreate();
919 919
920 d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride); 920 SafeNativeMethods.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride);
921 d.GeomTriMeshDataPreprocess(_triMeshData); 921 SafeNativeMethods.GeomTriMeshDataPreprocess(_triMeshData);
922 m_MeshToTriMeshMap[mesh] = _triMeshData; 922 m_MeshToTriMeshMap[mesh] = _triMeshData;
923 } 923 }
924 } 924 }
@@ -926,7 +926,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
926// _parent_scene.waitForSpaceUnlock(m_targetSpace); 926// _parent_scene.waitForSpaceUnlock(m_targetSpace);
927 try 927 try
928 { 928 {
929 SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, null, null, null)); 929 SetGeom(SafeNativeMethods.CreateTriMesh(m_targetSpace, _triMeshData, null, null, null));
930 } 930 }
931 catch (AccessViolationException) 931 catch (AccessViolationException)
932 { 932 {
@@ -1032,7 +1032,7 @@ Console.WriteLine("ZProcessTaints for " + Name);
1032 { 1032 {
1033 if (Amotor != IntPtr.Zero) 1033 if (Amotor != IntPtr.Zero)
1034 { 1034 {
1035 d.JointDestroy(Amotor); 1035 SafeNativeMethods.JointDestroy(Amotor);
1036 Amotor = IntPtr.Zero; 1036 Amotor = IntPtr.Zero;
1037 } 1037 }
1038 } 1038 }
@@ -1107,7 +1107,7 @@ Console.WriteLine("ZProcessTaints for " + Name);
1107 1107
1108 if (Body == IntPtr.Zero) 1108 if (Body == IntPtr.Zero)
1109 { 1109 {
1110 Body = d.BodyCreate(_parent_scene.world); 1110 Body = SafeNativeMethods.BodyCreate(_parent_scene.world);
1111 setMass(); 1111 setMass();
1112 } 1112 }
1113 1113
@@ -1123,21 +1123,21 @@ Console.WriteLine("ZProcessTaints for " + Name);
1123 1123
1124 foreach (OdePrim prm in childrenPrim) 1124 foreach (OdePrim prm in childrenPrim)
1125 { 1125 {
1126 d.Mass m2; 1126 SafeNativeMethods.Mass m2;
1127 d.MassSetZero(out m2); 1127 SafeNativeMethods.MassSetZero(out m2);
1128 d.MassSetBoxTotal(out m2, prm.CalculateMass(), prm._size.X, prm._size.Y, prm._size.Z); 1128 SafeNativeMethods.MassSetBoxTotal(out m2, prm.CalculateMass(), prm._size.X, prm._size.Y, prm._size.Z);
1129 1129
1130 d.Quaternion quat = new d.Quaternion(); 1130 SafeNativeMethods.Quaternion quat = new SafeNativeMethods.Quaternion();
1131 quat.W = prm._orientation.W; 1131 quat.W = prm._orientation.W;
1132 quat.X = prm._orientation.X; 1132 quat.X = prm._orientation.X;
1133 quat.Y = prm._orientation.Y; 1133 quat.Y = prm._orientation.Y;
1134 quat.Z = prm._orientation.Z; 1134 quat.Z = prm._orientation.Z;
1135 1135
1136 d.Matrix3 mat = new d.Matrix3(); 1136 SafeNativeMethods.Matrix3 mat = new SafeNativeMethods.Matrix3();
1137 d.RfromQ(out mat, ref quat); 1137 SafeNativeMethods.RfromQ(out mat, ref quat);
1138 d.MassRotate(ref m2, ref mat); 1138 SafeNativeMethods.MassRotate(ref m2, ref mat);
1139 d.MassTranslate(ref m2, Position.X - prm.Position.X, Position.Y - prm.Position.Y, Position.Z - prm.Position.Z); 1139 SafeNativeMethods.MassTranslate(ref m2, Position.X - prm.Position.X, Position.Y - prm.Position.Y, Position.Z - prm.Position.Z);
1140 d.MassAdd(ref pMass, ref m2); 1140 SafeNativeMethods.MassAdd(ref pMass, ref m2);
1141 } 1141 }
1142 1142
1143 foreach (OdePrim prm in childrenPrim) 1143 foreach (OdePrim prm in childrenPrim)
@@ -1148,36 +1148,36 @@ Console.WriteLine("ZProcessTaints for " + Name);
1148//Console.WriteLine(" GeomSetCategoryBits 1: " + prm.prim_geom + " - " + (int)prm.m_collisionCategories + " for " + Name); 1148//Console.WriteLine(" GeomSetCategoryBits 1: " + prm.prim_geom + " - " + (int)prm.m_collisionCategories + " for " + Name);
1149 if (prm.m_assetFailed) 1149 if (prm.m_assetFailed)
1150 { 1150 {
1151 d.GeomSetCategoryBits(prm.prim_geom, 0); 1151 SafeNativeMethods.GeomSetCategoryBits(prm.prim_geom, 0);
1152 d.GeomSetCollideBits(prm.prim_geom, (uint)prm.BadMeshAssetCollideBits); 1152 SafeNativeMethods.GeomSetCollideBits(prm.prim_geom, (uint)prm.BadMeshAssetCollideBits);
1153 } 1153 }
1154 else 1154 else
1155 { 1155 {
1156 d.GeomSetCategoryBits(prm.prim_geom, (uint)prm.m_collisionCategories); 1156 SafeNativeMethods.GeomSetCategoryBits(prm.prim_geom, (uint)prm.m_collisionCategories);
1157 d.GeomSetCollideBits(prm.prim_geom, (uint)prm.m_collisionFlags); 1157 SafeNativeMethods.GeomSetCollideBits(prm.prim_geom, (uint)prm.m_collisionFlags);
1158 } 1158 }
1159 1159
1160 d.Quaternion quat = new d.Quaternion(); 1160 SafeNativeMethods.Quaternion quat = new SafeNativeMethods.Quaternion();
1161 quat.W = prm._orientation.W; 1161 quat.W = prm._orientation.W;
1162 quat.X = prm._orientation.X; 1162 quat.X = prm._orientation.X;
1163 quat.Y = prm._orientation.Y; 1163 quat.Y = prm._orientation.Y;
1164 quat.Z = prm._orientation.Z; 1164 quat.Z = prm._orientation.Z;
1165 1165
1166 d.Matrix3 mat = new d.Matrix3(); 1166 SafeNativeMethods.Matrix3 mat = new SafeNativeMethods.Matrix3();
1167 d.RfromQ(out mat, ref quat); 1167 SafeNativeMethods.RfromQ(out mat, ref quat);
1168 if (Body != IntPtr.Zero) 1168 if (Body != IntPtr.Zero)
1169 { 1169 {
1170 d.GeomSetBody(prm.prim_geom, Body); 1170 SafeNativeMethods.GeomSetBody(prm.prim_geom, Body);
1171 prm.childPrim = true; 1171 prm.childPrim = true;
1172 d.GeomSetOffsetWorldPosition(prm.prim_geom, prm.Position.X , prm.Position.Y, prm.Position.Z); 1172 SafeNativeMethods.GeomSetOffsetWorldPosition(prm.prim_geom, prm.Position.X , prm.Position.Y, prm.Position.Z);
1173 //d.GeomSetOffsetPosition(prim.prim_geom, 1173 //d.GeomSetOffsetPosition(prim.prim_geom,
1174 // (Position.X - prm.Position.X) - pMass.c.X, 1174 // (Position.X - prm.Position.X) - pMass.c.X,
1175 // (Position.Y - prm.Position.Y) - pMass.c.Y, 1175 // (Position.Y - prm.Position.Y) - pMass.c.Y,
1176 // (Position.Z - prm.Position.Z) - pMass.c.Z); 1176 // (Position.Z - prm.Position.Z) - pMass.c.Z);
1177 d.GeomSetOffsetWorldRotation(prm.prim_geom, ref mat); 1177 SafeNativeMethods.GeomSetOffsetWorldRotation(prm.prim_geom, ref mat);
1178 //d.GeomSetOffsetRotation(prm.prim_geom, ref mat); 1178 //d.GeomSetOffsetRotation(prm.prim_geom, ref mat);
1179 d.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z); 1179 SafeNativeMethods.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z);
1180 d.BodySetMass(Body, ref pMass); 1180 SafeNativeMethods.BodySetMass(Body, ref pMass);
1181 } 1181 }
1182 else 1182 else
1183 { 1183 {
@@ -1197,37 +1197,37 @@ Console.WriteLine("ZProcessTaints for " + Name);
1197 1197
1198 if (m_assetFailed) 1198 if (m_assetFailed)
1199 { 1199 {
1200 d.GeomSetCategoryBits(prim_geom, 0); 1200 SafeNativeMethods.GeomSetCategoryBits(prim_geom, 0);
1201 d.GeomSetCollideBits(prim_geom, (uint)BadMeshAssetCollideBits); 1201 SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)BadMeshAssetCollideBits);
1202 } 1202 }
1203 else 1203 else
1204 { 1204 {
1205 //Console.WriteLine("GeomSetCategoryBits 2: " + prim_geom + " - " + (int)m_collisionCategories + " for " + Name); 1205 //Console.WriteLine("GeomSetCategoryBits 2: " + prim_geom + " - " + (int)m_collisionCategories + " for " + Name);
1206 d.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); 1206 SafeNativeMethods.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories);
1207 //Console.WriteLine(" Post GeomSetCategoryBits 2"); 1207 //Console.WriteLine(" Post GeomSetCategoryBits 2");
1208 d.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); 1208 SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags);
1209 } 1209 }
1210 1210
1211 d.Quaternion quat2 = new d.Quaternion(); 1211 SafeNativeMethods.Quaternion quat2 = new SafeNativeMethods.Quaternion();
1212 quat2.W = _orientation.W; 1212 quat2.W = _orientation.W;
1213 quat2.X = _orientation.X; 1213 quat2.X = _orientation.X;
1214 quat2.Y = _orientation.Y; 1214 quat2.Y = _orientation.Y;
1215 quat2.Z = _orientation.Z; 1215 quat2.Z = _orientation.Z;
1216 1216
1217 d.Matrix3 mat2 = new d.Matrix3(); 1217 SafeNativeMethods.Matrix3 mat2 = new SafeNativeMethods.Matrix3();
1218 d.RfromQ(out mat2, ref quat2); 1218 SafeNativeMethods.RfromQ(out mat2, ref quat2);
1219 d.GeomSetBody(prim_geom, Body); 1219 SafeNativeMethods.GeomSetBody(prim_geom, Body);
1220 d.GeomSetOffsetWorldPosition(prim_geom, Position.X - pMass.c.X, Position.Y - pMass.c.Y, Position.Z - pMass.c.Z); 1220 SafeNativeMethods.GeomSetOffsetWorldPosition(prim_geom, Position.X - pMass.c.X, Position.Y - pMass.c.Y, Position.Z - pMass.c.Z);
1221 //d.GeomSetOffsetPosition(prim.prim_geom, 1221 //d.GeomSetOffsetPosition(prim.prim_geom,
1222 // (Position.X - prm.Position.X) - pMass.c.X, 1222 // (Position.X - prm.Position.X) - pMass.c.X,
1223 // (Position.Y - prm.Position.Y) - pMass.c.Y, 1223 // (Position.Y - prm.Position.Y) - pMass.c.Y,
1224 // (Position.Z - prm.Position.Z) - pMass.c.Z); 1224 // (Position.Z - prm.Position.Z) - pMass.c.Z);
1225 //d.GeomSetOffsetRotation(prim_geom, ref mat2); 1225 //d.GeomSetOffsetRotation(prim_geom, ref mat2);
1226 d.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z); 1226 SafeNativeMethods.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z);
1227 d.BodySetMass(Body, ref pMass); 1227 SafeNativeMethods.BodySetMass(Body, ref pMass);
1228 1228
1229 d.BodySetAutoDisableFlag(Body, true); 1229 SafeNativeMethods.BodySetAutoDisableFlag(Body, true);
1230 d.BodySetAutoDisableSteps(Body, body_autodisable_frames); 1230 SafeNativeMethods.BodySetAutoDisableSteps(Body, body_autodisable_frames);
1231 1231
1232 m_interpenetrationcount = 0; 1232 m_interpenetrationcount = 0;
1233 m_collisionscore = 0; 1233 m_collisionscore = 0;
@@ -1240,7 +1240,7 @@ Console.WriteLine("ZProcessTaints for " + Name);
1240 createAMotor(m_angularlock); 1240 createAMotor(m_angularlock);
1241 } 1241 }
1242 1242
1243 d.BodySetPosition(Body, Position.X, Position.Y, Position.Z); 1243 SafeNativeMethods.BodySetPosition(Body, Position.X, Position.Y, Position.Z);
1244 1244
1245 if (m_vehicle.Type != Vehicle.TYPE_NONE) 1245 if (m_vehicle.Type != Vehicle.TYPE_NONE)
1246 m_vehicle.Enable(Body, _parent_scene); 1246 m_vehicle.Enable(Body, _parent_scene);
@@ -1370,13 +1370,13 @@ Console.WriteLine("ZProcessTaints for " + Name);
1370 1370
1371 if (m_assetFailed) 1371 if (m_assetFailed)
1372 { 1372 {
1373 d.GeomSetCategoryBits(prim_geom, 0); 1373 SafeNativeMethods.GeomSetCategoryBits(prim_geom, 0);
1374 d.GeomSetCollideBits(prim_geom, 0); 1374 SafeNativeMethods.GeomSetCollideBits(prim_geom, 0);
1375 } 1375 }
1376 else 1376 else
1377 { 1377 {
1378 d.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); 1378 SafeNativeMethods.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories);
1379 d.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); 1379 SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags);
1380 } 1380 }
1381 1381
1382 if (IsPhysical) 1382 if (IsPhysical)
@@ -1400,21 +1400,21 @@ Console.WriteLine("ZProcessTaints for " + Name);
1400 1400
1401 if (m_assetFailed) 1401 if (m_assetFailed)
1402 { 1402 {
1403 d.GeomSetCategoryBits(prim_geom, 0); 1403 SafeNativeMethods.GeomSetCategoryBits(prim_geom, 0);
1404 d.GeomSetCollideBits(prim_geom, (uint)BadMeshAssetCollideBits); 1404 SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)BadMeshAssetCollideBits);
1405 } 1405 }
1406 else 1406 else
1407 { 1407 {
1408 d.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories); 1408 SafeNativeMethods.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories);
1409 d.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); 1409 SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags);
1410 } 1410 }
1411 1411
1412 if (IsPhysical) 1412 if (IsPhysical)
1413 { 1413 {
1414 if (Body != IntPtr.Zero) 1414 if (Body != IntPtr.Zero)
1415 { 1415 {
1416 d.BodySetLinearVel(Body, 0f, 0f, 0f); 1416 SafeNativeMethods.BodySetLinearVel(Body, 0f, 0f, 0f);
1417 d.BodySetForce(Body, 0, 0, 0); 1417 SafeNativeMethods.BodySetForce(Body, 0, 0, 0);
1418 enableBodySoft(); 1418 enableBodySoft();
1419 } 1419 }
1420 } 1420 }
@@ -1463,7 +1463,7 @@ Console.WriteLine("CreateGeom:");
1463 try 1463 try
1464 { 1464 {
1465//Console.WriteLine(" CreateGeom 1"); 1465//Console.WriteLine(" CreateGeom 1");
1466 SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2)); 1466 SetGeom(SafeNativeMethods.CreateSphere(m_targetSpace, _size.X / 2));
1467 m_expectedCollisionContacts = 3; 1467 m_expectedCollisionContacts = 3;
1468 } 1468 }
1469 catch (AccessViolationException) 1469 catch (AccessViolationException)
@@ -1478,7 +1478,7 @@ Console.WriteLine("CreateGeom:");
1478 try 1478 try
1479 { 1479 {
1480//Console.WriteLine(" CreateGeom 2"); 1480//Console.WriteLine(" CreateGeom 2");
1481 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); 1481 SetGeom(SafeNativeMethods.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
1482 m_expectedCollisionContacts = 4; 1482 m_expectedCollisionContacts = 4;
1483 } 1483 }
1484 catch (AccessViolationException) 1484 catch (AccessViolationException)
@@ -1494,7 +1494,7 @@ Console.WriteLine("CreateGeom:");
1494 try 1494 try
1495 { 1495 {
1496//Console.WriteLine(" CreateGeom 3"); 1496//Console.WriteLine(" CreateGeom 3");
1497 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); 1497 SetGeom(SafeNativeMethods.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
1498 m_expectedCollisionContacts = 4; 1498 m_expectedCollisionContacts = 4;
1499 } 1499 }
1500 catch (AccessViolationException) 1500 catch (AccessViolationException)
@@ -1510,7 +1510,7 @@ Console.WriteLine("CreateGeom:");
1510 try 1510 try
1511 { 1511 {
1512//Console.WriteLine(" CreateGeom 4"); 1512//Console.WriteLine(" CreateGeom 4");
1513 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); 1513 SetGeom(SafeNativeMethods.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
1514 m_expectedCollisionContacts = 4; 1514 m_expectedCollisionContacts = 4;
1515 } 1515 }
1516 catch (AccessViolationException) 1516 catch (AccessViolationException)
@@ -1536,7 +1536,7 @@ Console.WriteLine("CreateGeom:");
1536 { 1536 {
1537 _parent_scene.geom_name_map.Remove(prim_geom); 1537 _parent_scene.geom_name_map.Remove(prim_geom);
1538 _parent_scene.actor_name_map.Remove(prim_geom); 1538 _parent_scene.actor_name_map.Remove(prim_geom);
1539 d.GeomDestroy(prim_geom); 1539 SafeNativeMethods.GeomDestroy(prim_geom);
1540 m_expectedCollisionContacts = 0; 1540 m_expectedCollisionContacts = 0;
1541 prim_geom = IntPtr.Zero; 1541 prim_geom = IntPtr.Zero;
1542 } 1542 }
@@ -1593,13 +1593,13 @@ Console.WriteLine("changeadd 1");
1593#endif 1593#endif
1594 CreateGeom(m_targetSpace, mesh); 1594 CreateGeom(m_targetSpace, mesh);
1595 1595
1596 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); 1596 SafeNativeMethods.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
1597 d.Quaternion myrot = new d.Quaternion(); 1597 SafeNativeMethods.Quaternion myrot = new SafeNativeMethods.Quaternion();
1598 myrot.X = _orientation.X; 1598 myrot.X = _orientation.X;
1599 myrot.Y = _orientation.Y; 1599 myrot.Y = _orientation.Y;
1600 myrot.Z = _orientation.Z; 1600 myrot.Z = _orientation.Z;
1601 myrot.W = _orientation.W; 1601 myrot.W = _orientation.W;
1602 d.GeomSetQuaternion(prim_geom, ref myrot); 1602 SafeNativeMethods.GeomSetQuaternion(prim_geom, ref myrot);
1603 1603
1604 if (IsPhysical && Body == IntPtr.Zero) 1604 if (IsPhysical && Body == IntPtr.Zero)
1605 enableBody(); 1605 enableBody();
@@ -1627,14 +1627,14 @@ Console.WriteLine("changeadd 1");
1627 { 1627 {
1628 if (m_linkJoint != IntPtr.Zero) 1628 if (m_linkJoint != IntPtr.Zero)
1629 { 1629 {
1630 d.JointDestroy(m_linkJoint); 1630 SafeNativeMethods.JointDestroy(m_linkJoint);
1631 m_linkJoint = IntPtr.Zero; 1631 m_linkJoint = IntPtr.Zero;
1632 } 1632 }
1633 } 1633 }
1634 1634
1635 if (Body != IntPtr.Zero) 1635 if (Body != IntPtr.Zero)
1636 { 1636 {
1637 d.BodySetPosition(Body, _position.X, _position.Y, _position.Z); 1637 SafeNativeMethods.BodySetPosition(Body, _position.X, _position.Y, _position.Z);
1638 1638
1639 if (_parent != null) 1639 if (_parent != null)
1640 { 1640 {
@@ -1643,12 +1643,12 @@ Console.WriteLine("changeadd 1");
1643 { 1643 {
1644// KF: Fixed Joints were removed? Anyway - this Console.WriteLine does not show up, so routine is not used?? 1644// KF: Fixed Joints were removed? Anyway - this Console.WriteLine does not show up, so routine is not used??
1645Console.WriteLine(" JointCreateFixed"); 1645Console.WriteLine(" JointCreateFixed");
1646 m_linkJoint = d.JointCreateFixed(_parent_scene.world, _linkJointGroup); 1646 m_linkJoint = SafeNativeMethods.JointCreateFixed(_parent_scene.world, _linkJointGroup);
1647 d.JointAttach(m_linkJoint, Body, odParent.Body); 1647 SafeNativeMethods.JointAttach(m_linkJoint, Body, odParent.Body);
1648 d.JointSetFixed(m_linkJoint); 1648 SafeNativeMethods.JointSetFixed(m_linkJoint);
1649 } 1649 }
1650 } 1650 }
1651 d.BodyEnable(Body); 1651 SafeNativeMethods.BodyEnable(Body);
1652 if (m_vehicle.Type != Vehicle.TYPE_NONE) 1652 if (m_vehicle.Type != Vehicle.TYPE_NONE)
1653 { 1653 {
1654 m_vehicle.Enable(Body, _parent_scene); 1654 m_vehicle.Enable(Body, _parent_scene);
@@ -1674,10 +1674,10 @@ Console.WriteLine(" JointCreateFixed");
1674 1674
1675// _parent_scene.waitForSpaceUnlock(m_targetSpace); 1675// _parent_scene.waitForSpaceUnlock(m_targetSpace);
1676 1676
1677 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); 1677 SafeNativeMethods.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
1678 1678
1679// _parent_scene.waitForSpaceUnlock(m_targetSpace); 1679// _parent_scene.waitForSpaceUnlock(m_targetSpace);
1680 d.SpaceAdd(m_targetSpace, prim_geom); 1680 SafeNativeMethods.SpaceAdd(m_targetSpace, prim_geom);
1681 1681
1682 changeSelectedStatus(); 1682 changeSelectedStatus();
1683 1683
@@ -1704,7 +1704,7 @@ Console.WriteLine(" JointCreateFixed");
1704 else 1704 else
1705 { 1705 {
1706//Console.WriteLine("Move " + Name); 1706//Console.WriteLine("Move " + Name);
1707 if (!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009 1707 if (!SafeNativeMethods.BodyIsEnabled (Body)) SafeNativeMethods.BodyEnable (Body); // KF add 161009
1708 1708
1709 float m_mass = CalculateMass(); 1709 float m_mass = CalculateMass();
1710 1710
@@ -1746,9 +1746,9 @@ Console.WriteLine(" JointCreateFixed");
1746 //PidStatus = true; 1746 //PidStatus = true;
1747 1747
1748 // PhysicsVector vec = new PhysicsVector(); 1748 // PhysicsVector vec = new PhysicsVector();
1749 d.Vector3 vel = d.BodyGetLinearVel(Body); 1749 SafeNativeMethods.Vector3 vel = SafeNativeMethods.BodyGetLinearVel(Body);
1750 1750
1751 d.Vector3 pos = d.BodyGetPosition(Body); 1751 SafeNativeMethods.Vector3 pos = SafeNativeMethods.BodyGetPosition(Body);
1752 _target_velocity = 1752 _target_velocity =
1753 new Vector3( 1753 new Vector3(
1754 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep), 1754 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep),
@@ -1770,9 +1770,9 @@ Console.WriteLine(" JointCreateFixed");
1770 //fx = (_target_velocity.X - vel.X) * (PID_D) + (_zeroPosition.X - pos.X) * (PID_P * 2); 1770 //fx = (_target_velocity.X - vel.X) * (PID_D) + (_zeroPosition.X - pos.X) * (PID_P * 2);
1771 //fy = (_target_velocity.Y - vel.Y) * (PID_D) + (_zeroPosition.Y - pos.Y) * (PID_P * 2); 1771 //fy = (_target_velocity.Y - vel.Y) * (PID_D) + (_zeroPosition.Y - pos.Y) * (PID_P * 2);
1772 //fz = fz + (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P; 1772 //fz = fz + (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P;
1773 d.BodySetPosition(Body, m_PIDTarget.X, m_PIDTarget.Y, m_PIDTarget.Z); 1773 SafeNativeMethods.BodySetPosition(Body, m_PIDTarget.X, m_PIDTarget.Y, m_PIDTarget.Z);
1774 d.BodySetLinearVel(Body, 0, 0, 0); 1774 SafeNativeMethods.BodySetLinearVel(Body, 0, 0, 0);
1775 d.BodyAddForce(Body, 0, 0, fz); 1775 SafeNativeMethods.BodyAddForce(Body, 0, 0, fz);
1776 return; 1776 return;
1777 } 1777 }
1778 else 1778 else
@@ -1813,8 +1813,8 @@ Console.WriteLine(" JointCreateFixed");
1813 } 1813 }
1814 1814
1815 // Where are we, and where are we headed? 1815 // Where are we, and where are we headed?
1816 d.Vector3 pos = d.BodyGetPosition(Body); 1816 SafeNativeMethods.Vector3 pos = SafeNativeMethods.BodyGetPosition(Body);
1817 d.Vector3 vel = d.BodyGetLinearVel(Body); 1817 SafeNativeMethods.Vector3 vel = SafeNativeMethods.BodyGetLinearVel(Body);
1818 1818
1819 // Non-Vehicles have a limited set of Hover options. 1819 // Non-Vehicles have a limited set of Hover options.
1820 // determine what our target height really is based on HoverType 1820 // determine what our target height really is based on HoverType
@@ -1856,9 +1856,9 @@ Console.WriteLine(" JointCreateFixed");
1856 // Avatar to Avatar collisions 1856 // Avatar to Avatar collisions
1857 // Prim to avatar collisions 1857 // Prim to avatar collisions
1858 1858
1859 d.BodySetPosition(Body, pos.X, pos.Y, m_targetHoverHeight); 1859 SafeNativeMethods.BodySetPosition(Body, pos.X, pos.Y, m_targetHoverHeight);
1860 d.BodySetLinearVel(Body, vel.X, vel.Y, 0); 1860 SafeNativeMethods.BodySetLinearVel(Body, vel.X, vel.Y, 0);
1861 d.BodyAddForce(Body, 0, 0, fz); 1861 SafeNativeMethods.BodyAddForce(Body, 0, 0, fz);
1862 return; 1862 return;
1863 } 1863 }
1864 else 1864 else
@@ -1884,13 +1884,13 @@ Console.WriteLine(" JointCreateFixed");
1884 //m_taintdisable = true; 1884 //m_taintdisable = true;
1885 //base.RaiseOutOfBounds(Position); 1885 //base.RaiseOutOfBounds(Position);
1886 //d.BodySetLinearVel(Body, fx, fy, 0f); 1886 //d.BodySetLinearVel(Body, fx, fy, 0f);
1887 if (!d.BodyIsEnabled(Body)) 1887 if (!SafeNativeMethods.BodyIsEnabled(Body))
1888 { 1888 {
1889 // A physical body at rest on a surface will auto-disable after a while, 1889 // A physical body at rest on a surface will auto-disable after a while,
1890 // this appears to re-enable it incase the surface it is upon vanishes, 1890 // this appears to re-enable it incase the surface it is upon vanishes,
1891 // and the body should fall again. 1891 // and the body should fall again.
1892 d.BodySetLinearVel(Body, 0f, 0f, 0f); 1892 SafeNativeMethods.BodySetLinearVel(Body, 0f, 0f, 0f);
1893 d.BodySetForce(Body, 0, 0, 0); 1893 SafeNativeMethods.BodySetForce(Body, 0, 0, 0);
1894 enableBodySoft(); 1894 enableBodySoft();
1895 } 1895 }
1896 1896
@@ -1906,7 +1906,7 @@ Console.WriteLine(" JointCreateFixed");
1906 fy = nmax; 1906 fy = nmax;
1907 if (fy < nmin) 1907 if (fy < nmin)
1908 fy = nmin; 1908 fy = nmin;
1909 d.BodyAddForce(Body, fx, fy, fz); 1909 SafeNativeMethods.BodyAddForce(Body, fx, fy, fz);
1910//Console.WriteLine("AddForce " + fx + "," + fy + "," + fz); 1910//Console.WriteLine("AddForce " + fx + "," + fy + "," + fz);
1911 } 1911 }
1912 } 1912 }
@@ -1922,7 +1922,7 @@ Console.WriteLine(" JointCreateFixed");
1922 1922
1923 private void rotate() 1923 private void rotate()
1924 { 1924 {
1925 d.Quaternion myrot = new d.Quaternion(); 1925 SafeNativeMethods.Quaternion myrot = new SafeNativeMethods.Quaternion();
1926 myrot.X = _orientation.X; 1926 myrot.X = _orientation.X;
1927 myrot.Y = _orientation.Y; 1927 myrot.Y = _orientation.Y;
1928 myrot.Z = _orientation.Z; 1928 myrot.Z = _orientation.Z;
@@ -1930,7 +1930,7 @@ Console.WriteLine(" JointCreateFixed");
1930 if (Body != IntPtr.Zero) 1930 if (Body != IntPtr.Zero)
1931 { 1931 {
1932 // KF: If this is a root prim do BodySet 1932 // KF: If this is a root prim do BodySet
1933 d.BodySetQuaternion(Body, ref myrot); 1933 SafeNativeMethods.BodySetQuaternion(Body, ref myrot);
1934 if (IsPhysical) 1934 if (IsPhysical)
1935 { 1935 {
1936 // create or remove locks 1936 // create or remove locks
@@ -1940,7 +1940,7 @@ Console.WriteLine(" JointCreateFixed");
1940 else 1940 else
1941 { 1941 {
1942 // daughter prim, do Geom set 1942 // daughter prim, do Geom set
1943 d.GeomSetQuaternion(prim_geom, ref myrot); 1943 SafeNativeMethods.GeomSetQuaternion(prim_geom, ref myrot);
1944 } 1944 }
1945 1945
1946 resetCollisionAccounting(); 1946 resetCollisionAccounting();
@@ -1962,7 +1962,7 @@ Console.WriteLine(" JointCreateFixed");
1962 m_disabled = true; 1962 m_disabled = true;
1963 if (Body != IntPtr.Zero) 1963 if (Body != IntPtr.Zero)
1964 { 1964 {
1965 d.BodyDisable(Body); 1965 SafeNativeMethods.BodyDisable(Body);
1966 Body = IntPtr.Zero; 1966 Body = IntPtr.Zero;
1967 } 1967 }
1968 1968
@@ -2051,10 +2051,10 @@ Console.WriteLine(" JointCreateFixed");
2051 } 2051 }
2052 } 2052 }
2053 2053
2054 if (d.SpaceQuery(m_targetSpace, prim_geom)) 2054 if (SafeNativeMethods.SpaceQuery(m_targetSpace, prim_geom))
2055 { 2055 {
2056// _parent_scene.waitForSpaceUnlock(m_targetSpace); 2056// _parent_scene.waitForSpaceUnlock(m_targetSpace);
2057 d.SpaceRemove(m_targetSpace, prim_geom); 2057 SafeNativeMethods.SpaceRemove(m_targetSpace, prim_geom);
2058 } 2058 }
2059 2059
2060 RemoveGeom(); 2060 RemoveGeom();
@@ -2084,13 +2084,13 @@ Console.WriteLine(" JointCreateFixed");
2084 } 2084 }
2085 2085
2086 CreateGeom(m_targetSpace, mesh); 2086 CreateGeom(m_targetSpace, mesh);
2087 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); 2087 SafeNativeMethods.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
2088 d.Quaternion myrot = new d.Quaternion(); 2088 SafeNativeMethods.Quaternion myrot = new SafeNativeMethods.Quaternion();
2089 myrot.X = _orientation.X; 2089 myrot.X = _orientation.X;
2090 myrot.Y = _orientation.Y; 2090 myrot.Y = _orientation.Y;
2091 myrot.Z = _orientation.Z; 2091 myrot.Z = _orientation.Z;
2092 myrot.W = _orientation.W; 2092 myrot.W = _orientation.W;
2093 d.GeomSetQuaternion(prim_geom, ref myrot); 2093 SafeNativeMethods.GeomSetQuaternion(prim_geom, ref myrot);
2094 2094
2095 //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); 2095 //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
2096 if (IsPhysical && Body == IntPtr.Zero && !childPrim) 2096 if (IsPhysical && Body == IntPtr.Zero && !childPrim)
@@ -2098,7 +2098,7 @@ Console.WriteLine(" JointCreateFixed");
2098 // Re creates body on size. 2098 // Re creates body on size.
2099 // EnableBody also does setMass() 2099 // EnableBody also does setMass()
2100 enableBody(); 2100 enableBody();
2101 d.BodyEnable(Body); 2101 SafeNativeMethods.BodyEnable(Body);
2102 } 2102 }
2103 2103
2104 changeSelectedStatus(); 2104 changeSelectedStatus();
@@ -2133,10 +2133,10 @@ Console.WriteLine(" JointCreateFixed");
2133 } 2133 }
2134 2134
2135 if (m_assetFailed) 2135 if (m_assetFailed)
2136 d.GeomSetCollideBits(prim_geom, (uint)BadMeshAssetCollideBits); 2136 SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)BadMeshAssetCollideBits);
2137 else 2137 else
2138 2138
2139 d.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags); 2139 SafeNativeMethods.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags);
2140 } 2140 }
2141 /// <summary> 2141 /// <summary>
2142 /// Change prim in response to a shape taint. 2142 /// Change prim in response to a shape taint.
@@ -2190,14 +2190,14 @@ Console.WriteLine(" JointCreateFixed");
2190 } 2190 }
2191 2191
2192 CreateGeom(m_targetSpace, mesh); 2192 CreateGeom(m_targetSpace, mesh);
2193 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); 2193 SafeNativeMethods.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
2194 d.Quaternion myrot = new d.Quaternion(); 2194 SafeNativeMethods.Quaternion myrot = new SafeNativeMethods.Quaternion();
2195 //myrot.W = _orientation.w; 2195 //myrot.W = _orientation.w;
2196 myrot.W = _orientation.W; 2196 myrot.W = _orientation.W;
2197 myrot.X = _orientation.X; 2197 myrot.X = _orientation.X;
2198 myrot.Y = _orientation.Y; 2198 myrot.Y = _orientation.Y;
2199 myrot.Z = _orientation.Z; 2199 myrot.Z = _orientation.Z;
2200 d.GeomSetQuaternion(prim_geom, ref myrot); 2200 SafeNativeMethods.GeomSetQuaternion(prim_geom, ref myrot);
2201 2201
2202 //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); 2202 //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
2203 if (IsPhysical && Body == IntPtr.Zero) 2203 if (IsPhysical && Body == IntPtr.Zero)
@@ -2207,7 +2207,7 @@ Console.WriteLine(" JointCreateFixed");
2207 enableBody(); 2207 enableBody();
2208 if (Body != IntPtr.Zero) 2208 if (Body != IntPtr.Zero)
2209 { 2209 {
2210 d.BodyEnable(Body); 2210 SafeNativeMethods.BodyEnable(Body);
2211 } 2211 }
2212 } 2212 }
2213 2213
@@ -2264,8 +2264,8 @@ Console.WriteLine(" JointCreateFixed");
2264 m_taintforce = false; 2264 m_taintforce = false;
2265 return; 2265 return;
2266 } 2266 }
2267 d.BodyEnable(Body); 2267 SafeNativeMethods.BodyEnable(Body);
2268 d.BodyAddForce(Body, iforce.X, iforce.Y, iforce.Z); 2268 SafeNativeMethods.BodyAddForce(Body, iforce.X, iforce.Y, iforce.Z);
2269 } 2269 }
2270 m_forcelist.Clear(); 2270 m_forcelist.Clear();
2271 } 2271 }
@@ -2286,7 +2286,7 @@ Console.WriteLine(" JointCreateFixed");
2286 { 2286 {
2287 if (IsPhysical && Body != IntPtr.Zero) 2287 if (IsPhysical && Body != IntPtr.Zero)
2288 { 2288 {
2289 d.BodySetTorque(Body, m_taintTorque.X, m_taintTorque.Y, m_taintTorque.Z); 2289 SafeNativeMethods.BodySetTorque(Body, m_taintTorque.X, m_taintTorque.Y, m_taintTorque.Z);
2290 } 2290 }
2291 } 2291 }
2292 2292
@@ -2310,8 +2310,8 @@ Console.WriteLine(" JointCreateFixed");
2310 { 2310 {
2311 iforce = iforce + (m_angularforcelist[i] * 100); 2311 iforce = iforce + (m_angularforcelist[i] * 100);
2312 } 2312 }
2313 d.BodyEnable(Body); 2313 SafeNativeMethods.BodyEnable(Body);
2314 d.BodyAddTorque(Body, iforce.X, iforce.Y, iforce.Z); 2314 SafeNativeMethods.BodyAddTorque(Body, iforce.X, iforce.Y, iforce.Z);
2315 2315
2316 } 2316 }
2317 m_angularforcelist.Clear(); 2317 m_angularforcelist.Clear();
@@ -2339,7 +2339,7 @@ Console.WriteLine(" JointCreateFixed");
2339 { 2339 {
2340 if (Body != IntPtr.Zero) 2340 if (Body != IntPtr.Zero)
2341 { 2341 {
2342 d.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z); 2342 SafeNativeMethods.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z);
2343 } 2343 }
2344 } 2344 }
2345 2345
@@ -2665,7 +2665,7 @@ Console.WriteLine(" JointCreateFixed");
2665 } 2665 }
2666 */ 2666 */
2667 2667
2668 d.AllocateODEDataForThread(0U); 2668 SafeNativeMethods.AllocateODEDataForThread(0U);
2669 2669
2670 _position.X = Util.Clip(_position.X, 0.5f, _parent_scene.WorldExtents.X - 0.5f); 2670 _position.X = Util.Clip(_position.X, 0.5f, _parent_scene.WorldExtents.X - 0.5f);
2671 _position.Y = Util.Clip(_position.Y, 0.5f, _parent_scene.WorldExtents.Y - 0.5f); 2671 _position.Y = Util.Clip(_position.Y, 0.5f, _parent_scene.WorldExtents.Y - 0.5f);
@@ -2680,8 +2680,8 @@ Console.WriteLine(" JointCreateFixed");
2680 2680
2681 if (Body != IntPtr.Zero) 2681 if (Body != IntPtr.Zero)
2682 { 2682 {
2683 d.BodySetLinearVel(Body, 0, 0, 0); // stop it 2683 SafeNativeMethods.BodySetLinearVel(Body, 0, 0, 0); // stop it
2684 d.BodySetPosition(Body, _position.X, _position.Y, _position.Z); 2684 SafeNativeMethods.BodySetPosition(Body, _position.X, _position.Y, _position.Z);
2685 } 2685 }
2686 2686
2687 if(m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE) 2687 if(m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE)
@@ -2728,11 +2728,11 @@ Console.WriteLine(" JointCreateFixed");
2728 float m_minvelocity = 0; 2728 float m_minvelocity = 0;
2729 if (Body != IntPtr.Zero) // FIXME -> or if it is a joint 2729 if (Body != IntPtr.Zero) // FIXME -> or if it is a joint
2730 { 2730 {
2731 d.Vector3 vec = d.BodyGetPosition(Body); 2731 SafeNativeMethods.Vector3 vec = SafeNativeMethods.BodyGetPosition(Body);
2732 d.Quaternion ori = d.BodyGetQuaternion(Body); 2732 SafeNativeMethods.Quaternion ori = SafeNativeMethods.BodyGetQuaternion(Body);
2733 d.Vector3 vel = d.BodyGetLinearVel(Body); 2733 SafeNativeMethods.Vector3 vel = SafeNativeMethods.BodyGetLinearVel(Body);
2734 d.Vector3 rotvel = d.BodyGetAngularVel(Body); 2734 SafeNativeMethods.Vector3 rotvel = SafeNativeMethods.BodyGetAngularVel(Body);
2735 d.Vector3 torque = d.BodyGetTorque(Body); 2735 SafeNativeMethods.Vector3 torque = SafeNativeMethods.BodyGetTorque(Body);
2736 _torque = new Vector3(torque.X, torque.Y, torque.Z); 2736 _torque = new Vector3(torque.X, torque.Y, torque.Z);
2737 Vector3 l_position = Vector3.Zero; 2737 Vector3 l_position = Vector3.Zero;
2738 Quaternion l_orientation = Quaternion.Identity; 2738 Quaternion l_orientation = Quaternion.Identity;
@@ -2812,11 +2812,11 @@ Console.WriteLine(" JointCreateFixed");
2812 else 2812 else
2813 Util.Clamp(l_position.Y, _parent_scene.WorldExtents.Y + 0.1f, _parent_scene.WorldExtents.Y + 2f); 2813 Util.Clamp(l_position.Y, _parent_scene.WorldExtents.Y + 0.1f, _parent_scene.WorldExtents.Y + 2f);
2814 2814
2815 d.BodySetPosition(Body, l_position.X, l_position.Y, l_position.Z); 2815 SafeNativeMethods.BodySetPosition(Body, l_position.X, l_position.Y, l_position.Z);
2816 2816
2817 // stop it 2817 // stop it
2818 d.BodySetAngularVel(Body, 0, 0, 0); 2818 SafeNativeMethods.BodySetAngularVel(Body, 0, 0, 0);
2819 d.BodySetLinearVel(Body, 0, 0, 0); 2819 SafeNativeMethods.BodySetLinearVel(Body, 0, 0, 0);
2820 disableBodySoft(); 2820 disableBodySoft();
2821 2821
2822 _position = l_position; 2822 _position = l_position;
@@ -3009,7 +3009,7 @@ Console.WriteLine(" JointCreateFixed");
3009 3009
3010 if (Amotor != IntPtr.Zero) 3010 if (Amotor != IntPtr.Zero)
3011 { 3011 {
3012 d.JointDestroy(Amotor); 3012 SafeNativeMethods.JointDestroy(Amotor);
3013 Amotor = IntPtr.Zero; 3013 Amotor = IntPtr.Zero;
3014 } 3014 }
3015 3015
@@ -3039,19 +3039,19 @@ Console.WriteLine(" JointCreateFixed");
3039 if(axisnum == 0) 3039 if(axisnum == 0)
3040 return; 3040 return;
3041 // stop it 3041 // stop it
3042 d.BodySetTorque(Body, 0, 0, 0); 3042 SafeNativeMethods.BodySetTorque(Body, 0, 0, 0);
3043 d.BodySetAngularVel(Body, 0, 0, 0); 3043 SafeNativeMethods.BodySetAngularVel(Body, 0, 0, 0);
3044 3044
3045 Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero); 3045 Amotor = SafeNativeMethods.JointCreateAMotor(_parent_scene.world, IntPtr.Zero);
3046 d.JointAttach(Amotor, Body, IntPtr.Zero); 3046 SafeNativeMethods.JointAttach(Amotor, Body, IntPtr.Zero);
3047 3047
3048 d.JointSetAMotorMode(Amotor, 0); 3048 SafeNativeMethods.JointSetAMotorMode(Amotor, 0);
3049 3049
3050 d.JointSetAMotorNumAxes(Amotor, axisnum); 3050 SafeNativeMethods.JointSetAMotorNumAxes(Amotor, axisnum);
3051 3051
3052 // get current orientation to lock 3052 // get current orientation to lock
3053 3053
3054 d.Quaternion dcur = d.BodyGetQuaternion(Body); 3054 SafeNativeMethods.Quaternion dcur = SafeNativeMethods.BodyGetQuaternion(Body);
3055 Quaternion curr; // crap convertion between identical things 3055 Quaternion curr; // crap convertion between identical things
3056 curr.X = dcur.X; 3056 curr.X = dcur.X;
3057 curr.Y = dcur.Y; 3057 curr.Y = dcur.Y;
@@ -3064,17 +3064,17 @@ Console.WriteLine(" JointCreateFixed");
3064 if (axisX) 3064 if (axisX)
3065 { 3065 {
3066 ax = (new Vector3(1, 0, 0)) * curr; // rotate world X to current local X 3066 ax = (new Vector3(1, 0, 0)) * curr; // rotate world X to current local X
3067 d.JointSetAMotorAxis(Amotor, 0, 0, ax.X, ax.Y, ax.Z); 3067 SafeNativeMethods.JointSetAMotorAxis(Amotor, 0, 0, ax.X, ax.Y, ax.Z);
3068 d.JointSetAMotorAngle(Amotor, 0, 0); 3068 SafeNativeMethods.JointSetAMotorAngle(Amotor, 0, 0);
3069 d.JointSetAMotorParam(Amotor, (int)d.JointParam.LoStop, 0f); 3069 SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.LoStop, 0f);
3070 d.JointSetAMotorParam(Amotor, (int)d.JointParam.HiStop, 0f); 3070 SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.HiStop, 0f);
3071 d.JointSetAMotorParam(Amotor, (int)d.JointParam.Vel, 0); 3071 SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.Vel, 0);
3072 d.JointSetAMotorParam(Amotor, (int)d.JointParam.FudgeFactor, 0.0001f); 3072 SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.FudgeFactor, 0.0001f);
3073 d.JointSetAMotorParam(Amotor, (int)d.JointParam.Bounce, 0f); 3073 SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.Bounce, 0f);
3074 d.JointSetAMotorParam(Amotor, (int)d.JointParam.CFM, 0f); 3074 SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.CFM, 0f);
3075 d.JointSetAMotorParam(Amotor, (int)d.JointParam.FMax, 5e8f); 3075 SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.FMax, 5e8f);
3076 d.JointSetAMotorParam(Amotor, (int)d.JointParam.StopCFM, 0f); 3076 SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.StopCFM, 0f);
3077 d.JointSetAMotorParam(Amotor, (int)d.JointParam.StopERP, 0.8f); 3077 SafeNativeMethods.JointSetAMotorParam(Amotor, (int)SafeNativeMethods.JointParam.StopERP, 0.8f);
3078 i++; 3078 i++;
3079 j = 256; // move to next axis set 3079 j = 256; // move to next axis set
3080 } 3080 }
@@ -3082,17 +3082,17 @@ Console.WriteLine(" JointCreateFixed");
3082 if (axisY) 3082 if (axisY)
3083 { 3083 {
3084 ax = (new Vector3(0, 1, 0)) * curr; 3084 ax = (new Vector3(0, 1, 0)) * curr;
3085 d.JointSetAMotorAxis(Amotor, i, 0, ax.X, ax.Y, ax.Z); 3085 SafeNativeMethods.JointSetAMotorAxis(Amotor, i, 0, ax.X, ax.Y, ax.Z);
3086 d.JointSetAMotorAngle(Amotor, i, 0); 3086 SafeNativeMethods.JointSetAMotorAngle(Amotor, i, 0);
3087 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.LoStop, 0f); 3087 SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.LoStop, 0f);
3088 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.HiStop, 0f); 3088 SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.HiStop, 0f);
3089 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.Vel, 0); 3089 SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.Vel, 0);
3090 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.FudgeFactor, 0.0001f); 3090 SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.FudgeFactor, 0.0001f);
3091 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.Bounce, 0f); 3091 SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.Bounce, 0f);
3092 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.CFM, 0f); 3092 SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.CFM, 0f);
3093 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.FMax, 5e8f); 3093 SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.FMax, 5e8f);
3094 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.StopCFM, 0f); 3094 SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.StopCFM, 0f);
3095 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.StopERP, 0.8f); 3095 SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.StopERP, 0.8f);
3096 i++; 3096 i++;
3097 j += 256; 3097 j += 256;
3098 } 3098 }
@@ -3100,17 +3100,17 @@ Console.WriteLine(" JointCreateFixed");
3100 if (axisZ) 3100 if (axisZ)
3101 { 3101 {
3102 ax = (new Vector3(0, 0, 1)) * curr; 3102 ax = (new Vector3(0, 0, 1)) * curr;
3103 d.JointSetAMotorAxis(Amotor, i, 0, ax.X, ax.Y, ax.Z); 3103 SafeNativeMethods.JointSetAMotorAxis(Amotor, i, 0, ax.X, ax.Y, ax.Z);
3104 d.JointSetAMotorAngle(Amotor, i, 0); 3104 SafeNativeMethods.JointSetAMotorAngle(Amotor, i, 0);
3105 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.LoStop, 0f); 3105 SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.LoStop, 0f);
3106 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.HiStop, 0f); 3106 SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.HiStop, 0f);
3107 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.Vel, 0); 3107 SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.Vel, 0);
3108 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.FudgeFactor, 0.0001f); 3108 SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.FudgeFactor, 0.0001f);
3109 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.Bounce, 0f); 3109 SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.Bounce, 0f);
3110 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.CFM, 0f); 3110 SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.CFM, 0f);
3111 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.FMax, 5e8f); 3111 SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.FMax, 5e8f);
3112 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.StopCFM, 0f); 3112 SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.StopCFM, 0f);
3113 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.StopERP, 0.8f); 3113 SafeNativeMethods.JointSetAMotorParam(Amotor, j + (int)SafeNativeMethods.JointParam.StopERP, 0.8f);
3114 } 3114 }
3115 } 3115 }
3116 3116