aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/ODEPrim.cs')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs594
1 files changed, 323 insertions, 271 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 63bfc90..864ea80 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -1,4 +1,15 @@
1/* 1/*
2 * Revised August 26 2009 by Kitto Flora. ODEDynamics.cs replaces
3 * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
4 * ODEPrim.cs contains methods dealing with Prim editing, Prim
5 * characteristics and Kinetic motion.
6 * ODEDynamics.cs contains methods dealing with Prim Physical motion
7 * (dynamics) and the associated settings. Old Linear and angular
8 * motors for dynamic motion have been replace with MoveLinear()
9 * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
10 * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_<other> is to
11 * switch between 'VEHICLE' parameter use and general dynamics
12 * settings use.
2 * Copyright (c) Contributors, http://opensimulator.org/ 13 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 14 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 15 *
@@ -72,6 +83,9 @@ namespace OpenSim.Region.Physics.OdePlugin
72 private float PID_G = 25f; 83 private float PID_G = 25f;
73 private bool m_usePID = false; 84 private bool m_usePID = false;
74 85
86 // KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau),
87 // and are for non-VEHICLES only.
88
75 private float m_PIDHoverHeight = 0f; 89 private float m_PIDHoverHeight = 0f;
76 private float m_PIDHoverTau = 0f; 90 private float m_PIDHoverTau = 0f;
77 private bool m_useHoverPID = false; 91 private bool m_useHoverPID = false;
@@ -79,6 +93,7 @@ namespace OpenSim.Region.Physics.OdePlugin
79 private float m_targetHoverHeight = 0f; 93 private float m_targetHoverHeight = 0f;
80 private float m_groundHeight = 0f; 94 private float m_groundHeight = 0f;
81 private float m_waterHeight = 0f; 95 private float m_waterHeight = 0f;
96 private float m_buoyancy = 0f; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle.
82 97
83 // private float m_tensor = 5f; 98 // private float m_tensor = 5f;
84 private int body_autodisable_frames = 20; 99 private int body_autodisable_frames = 20;
@@ -146,8 +161,6 @@ namespace OpenSim.Region.Physics.OdePlugin
146 public int m_roundsUnderMotionThreshold = 0; 161 public int m_roundsUnderMotionThreshold = 0;
147 private int m_crossingfailures = 0; 162 private int m_crossingfailures = 0;
148 163
149 public float m_buoyancy = 0f;
150
151 public bool outofBounds = false; 164 public bool outofBounds = false;
152 private float m_density = 10.000006836f; // Aluminum g/cm3; 165 private float m_density = 10.000006836f; // Aluminum g/cm3;
153 166
@@ -155,7 +168,8 @@ namespace OpenSim.Region.Physics.OdePlugin
155 private bool m_lastUpdateSent = false; 168 private bool m_lastUpdateSent = false;
156 169
157 public IntPtr Body = (IntPtr) 0; 170 public IntPtr Body = (IntPtr) 0;
158 private String m_primName; 171 public String m_primName;
172// private String m_primName;
159 private PhysicsVector _target_velocity; 173 private PhysicsVector _target_velocity;
160 public d.Mass pMass; 174 public d.Mass pMass;
161 175
@@ -166,7 +180,7 @@ namespace OpenSim.Region.Physics.OdePlugin
166 180
167 public volatile bool childPrim = false; 181 public volatile bool childPrim = false;
168 182
169 private ODEVehicleSettings m_vehicle; 183 private ODEDynamics m_vehicle;
170 184
171 internal int m_material = (int)Material.Wood; 185 internal int m_material = (int)Material.Wood;
172 186
@@ -174,7 +188,7 @@ namespace OpenSim.Region.Physics.OdePlugin
174 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode) 188 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode)
175 { 189 {
176 _target_velocity = new PhysicsVector(0, 0, 0); 190 _target_velocity = new PhysicsVector(0, 0, 0);
177 m_vehicle = new ODEVehicleSettings(); 191 m_vehicle = new ODEDynamics();
178 //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned); 192 //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned);
179 ode = dode; 193 ode = dode;
180 _velocity = new PhysicsVector(); 194 _velocity = new PhysicsVector();
@@ -259,11 +273,6 @@ namespace OpenSim.Region.Physics.OdePlugin
259 m_localID = value; } 273 m_localID = value; }
260 } 274 }
261 275
262 public override int GetHashCode()
263 {
264 return (int)m_localID;
265 }
266
267 public override bool Grabbed 276 public override bool Grabbed
268 { 277 {
269 set { return; } 278 set { return; }
@@ -272,6 +281,8 @@ namespace OpenSim.Region.Physics.OdePlugin
272 public override bool Selected 281 public override bool Selected
273 { 282 {
274 set { 283 set {
284
285
275 // This only makes the object not collidable if the object 286 // This only makes the object not collidable if the object
276 // is physical or the object is modified somehow *IN THE FUTURE* 287 // is physical or the object is modified somehow *IN THE FUTURE*
277 // without this, if an avatar selects prim, they can walk right 288 // without this, if an avatar selects prim, they can walk right
@@ -287,6 +298,7 @@ namespace OpenSim.Region.Physics.OdePlugin
287 m_taintselected = value; 298 m_taintselected = value;
288 m_isSelected = value; 299 m_isSelected = value;
289 } 300 }
301 if(m_isSelected) disableBodySoft();
290 } 302 }
291 } 303 }
292 304
@@ -294,6 +306,7 @@ namespace OpenSim.Region.Physics.OdePlugin
294 { 306 {
295 prev_geom = prim_geom; 307 prev_geom = prim_geom;
296 prim_geom = geom; 308 prim_geom = geom;
309//Console.WriteLine("SetGeom to " + prim_geom + " for " + m_primName);
297 if (prim_geom != IntPtr.Zero) 310 if (prim_geom != IntPtr.Zero)
298 { 311 {
299 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); 312 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
@@ -305,6 +318,7 @@ namespace OpenSim.Region.Physics.OdePlugin
305 if (_parent != null && _parent is OdePrim) 318 if (_parent != null && _parent is OdePrim)
306 { 319 {
307 OdePrim parent = (OdePrim)_parent; 320 OdePrim parent = (OdePrim)_parent;
321//Console.WriteLine("SetGeom calls ChildSetGeom");
308 parent.ChildSetGeom(this); 322 parent.ChildSetGeom(this);
309 } 323 }
310 } 324 }
@@ -320,7 +334,8 @@ namespace OpenSim.Region.Physics.OdePlugin
320 if (m_isphysical && Body != IntPtr.Zero) 334 if (m_isphysical && Body != IntPtr.Zero)
321 { 335 {
322 d.BodyEnable(Body); 336 d.BodyEnable(Body);
323 m_vehicle.Enable(Body, _parent_scene); 337 if (m_vehicle.Type != Vehicle.TYPE_NONE)
338 m_vehicle.Enable(Body, _parent_scene);
324 } 339 }
325 340
326 m_disabled = false; 341 m_disabled = false;
@@ -334,7 +349,6 @@ namespace OpenSim.Region.Physics.OdePlugin
334 if (m_isphysical && Body != IntPtr.Zero) 349 if (m_isphysical && Body != IntPtr.Zero)
335 { 350 {
336 d.BodyDisable(Body); 351 d.BodyDisable(Body);
337 m_vehicle.Disable();
338 } 352 }
339 } 353 }
340 354
@@ -364,6 +378,9 @@ namespace OpenSim.Region.Physics.OdePlugin
364 378
365 d.BodySetAutoDisableFlag(Body, true); 379 d.BodySetAutoDisableFlag(Body, true);
366 d.BodySetAutoDisableSteps(Body, body_autodisable_frames); 380 d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
381
382 // disconnect from world gravity so we can apply buoyancy
383 d.BodySetGravityMode (Body, false);
367 384
368 m_interpenetrationcount = 0; 385 m_interpenetrationcount = 0;
369 m_collisionscore = 0; 386 m_collisionscore = 0;
@@ -710,13 +727,8 @@ namespace OpenSim.Region.Physics.OdePlugin
710 break; 727 break;
711 } 728 }
712 } 729 }
713
714
715
716
717
718 return returnMass; 730 return returnMass;
719 } 731 }// end CalculateMass
720 732
721 #endregion 733 #endregion
722 734
@@ -742,7 +754,6 @@ namespace OpenSim.Region.Physics.OdePlugin
742 if (Body != IntPtr.Zero) 754 if (Body != IntPtr.Zero)
743 { 755 {
744 _parent_scene.remActivePrim(this); 756 _parent_scene.remActivePrim(this);
745 m_vehicle.Destroy();
746 m_collisionCategories &= ~CollisionCategories.Body; 757 m_collisionCategories &= ~CollisionCategories.Body;
747 m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land); 758 m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land);
748 759
@@ -832,6 +843,7 @@ namespace OpenSim.Region.Physics.OdePlugin
832 { 843 {
833 if (prim_geom == IntPtr.Zero) 844 if (prim_geom == IntPtr.Zero)
834 { 845 {
846//Console.WriteLine(" setMesh 1");
835 SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null)); 847 SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null));
836 } 848 }
837 } 849 }
@@ -853,19 +865,35 @@ namespace OpenSim.Region.Physics.OdePlugin
853 865
854 public void ProcessTaints(float timestep) 866 public void ProcessTaints(float timestep)
855 { 867 {
868//Console.WriteLine("ProcessTaints for " + m_primName );
856 if (m_taintadd) 869 if (m_taintadd)
857 { 870 {
858 changeadd(timestep); 871 changeadd(timestep);
859 } 872 }
873
860 if (prim_geom != IntPtr.Zero) 874 if (prim_geom != IntPtr.Zero)
861 { 875 {
862 if (!_position.IsIdentical(m_taintposition,0f)) 876 if (!_position.IsIdentical(m_taintposition,0f))
863 changemove(timestep); 877 changemove(timestep);
864 878
865 if (m_taintrot != _orientation) 879 if (m_taintrot != _orientation)
866 rotate(timestep); 880 {
881 if(childPrim && IsPhysical) // For physical child prim...
882 {
883 rotate(timestep);
884 // KF: ODE will also rotate the parent prim!
885 // so rotate the root back to where it was
886 OdePrim parent = (OdePrim)_parent;
887 parent.rotate(timestep);
888 }
889 else
890 {
891 //Just rotate the prim
892 rotate(timestep);
893 }
894 }
867 // 895 //
868 896
869 if (m_taintPhysics != m_isphysical && !(m_taintparent != _parent)) 897 if (m_taintPhysics != m_isphysical && !(m_taintparent != _parent))
870 changePhysicsStatus(timestep); 898 changePhysicsStatus(timestep);
871 // 899 //
@@ -904,8 +932,7 @@ namespace OpenSim.Region.Physics.OdePlugin
904 932
905 if (!m_angularlock.IsIdentical(m_taintAngularLock,0)) 933 if (!m_angularlock.IsIdentical(m_taintAngularLock,0))
906 changeAngularLock(timestep); 934 changeAngularLock(timestep);
907 935
908
909 } 936 }
910 else 937 else
911 { 938 {
@@ -937,11 +964,6 @@ namespace OpenSim.Region.Physics.OdePlugin
937 Amotor = IntPtr.Zero; 964 Amotor = IntPtr.Zero;
938 } 965 }
939 } 966 }
940
941 if (m_vehicle.Type != Vehicle.TYPE_NONE)
942 {
943 m_vehicle.Reset();
944 }
945 } 967 }
946 } 968 }
947 // Store this for later in case we get turned into a separate body 969 // Store this for later in case we get turned into a separate body
@@ -959,7 +981,7 @@ namespace OpenSim.Region.Physics.OdePlugin
959 { 981 {
960 OdePrim obj = (OdePrim)m_taintparent; 982 OdePrim obj = (OdePrim)m_taintparent;
961 //obj.disableBody(); 983 //obj.disableBody();
962 984//Console.WriteLine("changelink calls ParentPrim");
963 obj.ParentPrim(this); 985 obj.ParentPrim(this);
964 986
965 /* 987 /*
@@ -977,6 +999,8 @@ namespace OpenSim.Region.Physics.OdePlugin
977 // destroy link 999 // destroy link
978 else if (_parent != null && m_taintparent == null) 1000 else if (_parent != null && m_taintparent == null)
979 { 1001 {
1002//Console.WriteLine(" changelink B");
1003
980 if (_parent is OdePrim) 1004 if (_parent is OdePrim)
981 { 1005 {
982 OdePrim obj = (OdePrim)_parent; 1006 OdePrim obj = (OdePrim)_parent;
@@ -993,7 +1017,7 @@ namespace OpenSim.Region.Physics.OdePlugin
993 m_linkJoint = (IntPtr)0; 1017 m_linkJoint = (IntPtr)0;
994 */ 1018 */
995 } 1019 }
996 1020
997 _parent = m_taintparent; 1021 _parent = m_taintparent;
998 m_taintPhysics = m_isphysical; 1022 m_taintPhysics = m_isphysical;
999 } 1023 }
@@ -1002,6 +1026,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1002 // prim is the child 1026 // prim is the child
1003 public void ParentPrim(OdePrim prim) 1027 public void ParentPrim(OdePrim prim)
1004 { 1028 {
1029//Console.WriteLine("ParentPrim " + m_primName);
1005 if (this.m_localID != prim.m_localID) 1030 if (this.m_localID != prim.m_localID)
1006 { 1031 {
1007 if (Body == IntPtr.Zero) 1032 if (Body == IntPtr.Zero)
@@ -1015,6 +1040,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1015 { 1040 {
1016 if (!childrenPrim.Contains(prim)) 1041 if (!childrenPrim.Contains(prim))
1017 { 1042 {
1043//Console.WriteLine("childrenPrim.Add " + prim);
1018 childrenPrim.Add(prim); 1044 childrenPrim.Add(prim);
1019 1045
1020 foreach (OdePrim prm in childrenPrim) 1046 foreach (OdePrim prm in childrenPrim)
@@ -1038,6 +1064,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1038 } 1064 }
1039 foreach (OdePrim prm in childrenPrim) 1065 foreach (OdePrim prm in childrenPrim)
1040 { 1066 {
1067
1041 prm.m_collisionCategories |= CollisionCategories.Body; 1068 prm.m_collisionCategories |= CollisionCategories.Body;
1042 prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); 1069 prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
1043 1070
@@ -1046,7 +1073,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1046 m_log.Warn("[PHYSICS]: Unable to link one of the linkset elements. No geom yet"); 1073 m_log.Warn("[PHYSICS]: Unable to link one of the linkset elements. No geom yet");
1047 continue; 1074 continue;
1048 } 1075 }
1049 1076//Console.WriteLine(" GeomSetCategoryBits 1: " + prm.prim_geom + " - " + (int)prm.m_collisionCategories + " for " + m_primName);
1050 d.GeomSetCategoryBits(prm.prim_geom, (int)prm.m_collisionCategories); 1077 d.GeomSetCategoryBits(prm.prim_geom, (int)prm.m_collisionCategories);
1051 d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags); 1078 d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags);
1052 1079
@@ -1091,11 +1118,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1091 prm.Body = Body; 1118 prm.Body = Body;
1092 _parent_scene.addActivePrim(prm); 1119 _parent_scene.addActivePrim(prm);
1093 } 1120 }
1094
1095 m_collisionCategories |= CollisionCategories.Body; 1121 m_collisionCategories |= CollisionCategories.Body;
1096 m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); 1122 m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
1097 1123
1124//Console.WriteLine("GeomSetCategoryBits 2: " + prim_geom + " - " + (int)m_collisionCategories + " for " + m_primName);
1098 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); 1125 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
1126//Console.WriteLine(" Post GeomSetCategoryBits 2");
1099 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); 1127 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
1100 1128
1101 1129
@@ -1131,7 +1159,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1131 createAMotor(m_angularlock); 1159 createAMotor(m_angularlock);
1132 } 1160 }
1133 d.BodySetPosition(Body, Position.X, Position.Y, Position.Z); 1161 d.BodySetPosition(Body, Position.X, Position.Y, Position.Z);
1134 m_vehicle.Enable(Body, _parent_scene); 1162 if (m_vehicle.Type != Vehicle.TYPE_NONE) m_vehicle.Enable(Body, _parent_scene);
1135 _parent_scene.addActivePrim(this); 1163 _parent_scene.addActivePrim(this);
1136 } 1164 }
1137 } 1165 }
@@ -1168,6 +1196,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1168 { 1196 {
1169 foreach (OdePrim prm in childrenPrim) 1197 foreach (OdePrim prm in childrenPrim)
1170 { 1198 {
1199//Console.WriteLine("ChildSetGeom calls ParentPrim");
1171 ParentPrim(prm); 1200 ParentPrim(prm);
1172 } 1201 }
1173 } 1202 }
@@ -1194,6 +1223,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1194 1223
1195 lock (childrenPrim) 1224 lock (childrenPrim)
1196 { 1225 {
1226 //Console.WriteLine("childrenPrim.Remove " + odePrim);
1197 childrenPrim.Remove(odePrim); 1227 childrenPrim.Remove(odePrim);
1198 } 1228 }
1199 1229
@@ -1211,6 +1241,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1211 { 1241 {
1212 foreach (OdePrim prm in childrenPrim) 1242 foreach (OdePrim prm in childrenPrim)
1213 { 1243 {
1244//Console.WriteLine("ChildDelink calls ParentPrim");
1214 ParentPrim(prm); 1245 ParentPrim(prm);
1215 } 1246 }
1216 } 1247 }
@@ -1295,7 +1326,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1295 1326
1296 resetCollisionAccounting(); 1327 resetCollisionAccounting();
1297 m_isSelected = m_taintselected; 1328 m_isSelected = m_taintselected;
1298 } 1329 }//end changeSelectedStatus
1299 1330
1300 public void ResetTaints() 1331 public void ResetTaints()
1301 { 1332 {
@@ -1312,6 +1343,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1312 1343
1313 public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh) 1344 public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh)
1314 { 1345 {
1346//Console.WriteLine("CreateGeom:");
1315 if (_mesh != null) 1347 if (_mesh != null)
1316 { 1348 {
1317 setMesh(_parent_scene, _mesh); 1349 setMesh(_parent_scene, _mesh);
@@ -1327,6 +1359,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1327 _parent_scene.waitForSpaceUnlock(m_targetSpace); 1359 _parent_scene.waitForSpaceUnlock(m_targetSpace);
1328 try 1360 try
1329 { 1361 {
1362//Console.WriteLine(" CreateGeom 1");
1330 SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2)); 1363 SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2));
1331 } 1364 }
1332 catch (AccessViolationException) 1365 catch (AccessViolationException)
@@ -1341,6 +1374,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1341 _parent_scene.waitForSpaceUnlock(m_targetSpace); 1374 _parent_scene.waitForSpaceUnlock(m_targetSpace);
1342 try 1375 try
1343 { 1376 {
1377//Console.WriteLine(" CreateGeom 2");
1344 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); 1378 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
1345 } 1379 }
1346 catch (AccessViolationException) 1380 catch (AccessViolationException)
@@ -1356,6 +1390,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1356 _parent_scene.waitForSpaceUnlock(m_targetSpace); 1390 _parent_scene.waitForSpaceUnlock(m_targetSpace);
1357 try 1391 try
1358 { 1392 {
1393//Console.WriteLine(" CreateGeom 3");
1359 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); 1394 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
1360 } 1395 }
1361 catch (AccessViolationException) 1396 catch (AccessViolationException)
@@ -1372,6 +1407,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1372 _parent_scene.waitForSpaceUnlock(m_targetSpace); 1407 _parent_scene.waitForSpaceUnlock(m_targetSpace);
1373 try 1408 try
1374 { 1409 {
1410//Console.WriteLine(" CreateGeom 4");
1375 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); 1411 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
1376 } 1412 }
1377 catch (AccessViolationException) 1413 catch (AccessViolationException)
@@ -1408,6 +1444,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1408 1444
1409 lock (_parent_scene.OdeLock) 1445 lock (_parent_scene.OdeLock)
1410 { 1446 {
1447//Console.WriteLine("changeadd 1");
1411 CreateGeom(m_targetSpace, _mesh); 1448 CreateGeom(m_targetSpace, _mesh);
1412 1449
1413 if (prim_geom != IntPtr.Zero) 1450 if (prim_geom != IntPtr.Zero)
@@ -1463,6 +1500,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1463 OdePrim odParent = (OdePrim)_parent; 1500 OdePrim odParent = (OdePrim)_parent;
1464 if (Body != (IntPtr)0 && odParent.Body != (IntPtr)0 && Body != odParent.Body) 1501 if (Body != (IntPtr)0 && odParent.Body != (IntPtr)0 && Body != odParent.Body)
1465 { 1502 {
1503// KF: Fixed Joints were removed? Anyway - this Console.WriteLine does not show up, so routine is not used??
1504Console.WriteLine(" JointCreateFixed");
1466 m_linkJoint = d.JointCreateFixed(_parent_scene.world, _linkJointGroup); 1505 m_linkJoint = d.JointCreateFixed(_parent_scene.world, _linkJointGroup);
1467 d.JointAttach(m_linkJoint, Body, odParent.Body); 1506 d.JointAttach(m_linkJoint, Body, odParent.Body);
1468 d.JointSetFixed(m_linkJoint); 1507 d.JointSetFixed(m_linkJoint);
@@ -1516,239 +1555,236 @@ namespace OpenSim.Region.Physics.OdePlugin
1516 float fz = 0; 1555 float fz = 0;
1517 1556
1518 1557
1519 if (IsPhysical && Body != IntPtr.Zero && !m_isSelected) 1558 if (IsPhysical && (Body != IntPtr.Zero) && !m_isSelected && !childPrim) // KF: Only move root prims.
1520 { 1559 {
1521 if (d.BodyIsEnabled(Body) && !m_angularlock.IsIdentical(PhysicsVector.Zero, 0.003f)) 1560 if (m_vehicle.Type != Vehicle.TYPE_NONE)
1522 { 1561 {
1523 d.Vector3 avel2 = d.BodyGetAngularVel(Body); 1562 // 'VEHICLES' are dealt with in ODEDynamics.cs
1524 if (m_angularlock.X == 1) 1563 m_vehicle.Step(timestep, _parent_scene);
1525 avel2.X = 0; 1564 }
1526 if (m_angularlock.Y == 1) 1565 else
1527 avel2.Y = 0; 1566 {
1528 if (m_angularlock.Z == 1) 1567 // NON-'VEHICLES' are dealt with here
1529 avel2.Z = 0; 1568 if (d.BodyIsEnabled(Body) && !m_angularlock.IsIdentical(PhysicsVector.Zero, 0.003f))
1530 d.BodySetAngularVel(Body, avel2.X, avel2.Y, avel2.Z); 1569 {
1531 } 1570 d.Vector3 avel2 = d.BodyGetAngularVel(Body);
1532 //float PID_P = 900.0f; 1571 if (m_angularlock.X == 1)
1533 1572 avel2.X = 0;
1534 float m_mass = CalculateMass(); 1573 if (m_angularlock.Y == 1)
1535 1574 avel2.Y = 0;
1536 fz = 0f; 1575 if (m_angularlock.Z == 1)
1576 avel2.Z = 0;
1577 d.BodySetAngularVel(Body, avel2.X, avel2.Y, avel2.Z);
1578 }
1579 //float PID_P = 900.0f;
1580
1581 float m_mass = CalculateMass();
1582
1583// fz = 0f;
1537 //m_log.Info(m_collisionFlags.ToString()); 1584 //m_log.Info(m_collisionFlags.ToString());
1538 1585
1539 if (m_buoyancy != 0) 1586
1540 { 1587 //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle.
1541 if (m_buoyancy > 0) 1588 // would come from SceneObjectPart.cs, public void SetBuoyancy(float fvalue) , PhysActor.Buoyancy = fvalue; ??
1542 { 1589 // m_buoyancy: (unlimited value) <0=Falls fast; 0=1g; 1=0g; >1 = floats up
1543 fz = (((-1 * _parent_scene.gravityz) * m_buoyancy) * m_mass); 1590 // gravityz multiplier = 1 - m_buoyancy
1544 1591 fz = _parent_scene.gravityz * (1.0f - m_buoyancy) * m_mass;
1545 //d.Vector3 l_velocity = d.BodyGetLinearVel(Body); 1592
1546 //m_log.Info("Using Buoyancy: " + buoyancy + " G: " + (_parent_scene.gravityz * m_buoyancy) + "mass:" + m_mass + " Pos: " + Position.ToString()); 1593 if (m_usePID)
1547 } 1594 {
1548 else 1595 // KF - this is for object move? eg. llSetPos() ?
1549 { 1596 //if (!d.BodyIsEnabled(Body))
1550 fz = (-1 * (((-1 * _parent_scene.gravityz) * (-1 * m_buoyancy)) * m_mass)); 1597 //d.BodySetForce(Body, 0f, 0f, 0f);
1551 } 1598 // If we're using the PID controller, then we have no gravity
1552 } 1599 //fz = (-1 * _parent_scene.gravityz) * m_mass; //KF: ?? Prims have no global gravity,so simply...
1553 1600 fz = 0f;
1554 if (m_usePID) 1601
1555 { 1602 // no lock; for now it's only called from within Simulate()
1603
1604 // If the PID Controller isn't active then we set our force
1605 // calculating base velocity to the current position
1606
1607 if ((m_PIDTau < 1) && (m_PIDTau != 0))
1608 {
1609 //PID_G = PID_G / m_PIDTau;
1610 m_PIDTau = 1;
1611 }
1612
1613 if ((PID_G - m_PIDTau) <= 0)
1614 {
1615 PID_G = m_PIDTau + 1;
1616 }
1617 //PidStatus = true;
1618
1619 // PhysicsVector vec = new PhysicsVector();
1620 d.Vector3 vel = d.BodyGetLinearVel(Body);
1621
1622 d.Vector3 pos = d.BodyGetPosition(Body);
1623 _target_velocity =
1624 new PhysicsVector(
1625 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep),
1626 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep),
1627 (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep)
1628 );
1629
1630 // if velocity is zero, use position control; otherwise, velocity control
1631
1632 if (_target_velocity.IsIdentical(PhysicsVector.Zero,0.1f))
1633 {
1634 // keep track of where we stopped. No more slippin' & slidin'
1635
1636 // We only want to deactivate the PID Controller if we think we want to have our surrogate
1637 // react to the physics scene by moving it's position.
1638 // Avatar to Avatar collisions
1639 // Prim to avatar collisions
1640
1641 //fx = (_target_velocity.X - vel.X) * (PID_D) + (_zeroPosition.X - pos.X) * (PID_P * 2);
1642 //fy = (_target_velocity.Y - vel.Y) * (PID_D) + (_zeroPosition.Y - pos.Y) * (PID_P * 2);
1643 //fz = fz + (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P;
1644 d.BodySetPosition(Body, m_PIDTarget.X, m_PIDTarget.Y, m_PIDTarget.Z);
1645 d.BodySetLinearVel(Body, 0, 0, 0);
1646 d.BodyAddForce(Body, 0, 0, fz);
1647 return;
1648 }
1649 else
1650 {
1651 _zeroFlag = false;
1652
1653 // We're flying and colliding with something
1654 fx = ((_target_velocity.X) - vel.X) * (PID_D);
1655 fy = ((_target_velocity.Y) - vel.Y) * (PID_D);
1656
1657 // vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P;
1658
1659 fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass);
1660 }
1661 } // end if (m_usePID)
1662
1663 // Hover PID Controller needs to be mutually exlusive to MoveTo PID controller
1664 if (m_useHoverPID && !m_usePID)
1665 {
1666 // If we're using the PID controller, then we have no gravity
1667 fz = (-1 * _parent_scene.gravityz) * m_mass;
1668
1669 // no lock; for now it's only called from within Simulate()
1670
1671 // If the PID Controller isn't active then we set our force
1672 // calculating base velocity to the current position
1673
1674 if ((m_PIDTau < 1))
1675 {
1676 PID_G = PID_G / m_PIDTau;
1677 }
1678
1679 if ((PID_G - m_PIDTau) <= 0)
1680 {
1681 PID_G = m_PIDTau + 1;
1682 }
1556 1683
1557 //if (!d.BodyIsEnabled(Body))
1558 //d.BodySetForce(Body, 0f, 0f, 0f);
1559 // If we're using the PID controller, then we have no gravity
1560 fz = (-1 * _parent_scene.gravityz) * m_mass;
1561 1684
1562 // no lock; for now it's only called from within Simulate() 1685 // Where are we, and where are we headed?
1686 d.Vector3 pos = d.BodyGetPosition(Body);
1687 d.Vector3 vel = d.BodyGetLinearVel(Body);
1688
1689
1690 // Non-Vehicles have a limited set of Hover options.
1691 // determine what our target height really is based on HoverType
1692 switch (m_PIDHoverType)
1693 {
1694 case PIDHoverType.Ground:
1695 m_groundHeight = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y);
1696 m_targetHoverHeight = m_groundHeight + m_PIDHoverHeight;
1697 break;
1698 case PIDHoverType.GroundAndWater:
1699 m_groundHeight = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y);
1700 m_waterHeight = _parent_scene.GetWaterLevel();
1701 if (m_groundHeight > m_waterHeight)
1702 {
1703 m_targetHoverHeight = m_groundHeight + m_PIDHoverHeight;
1704 }
1705 else
1706 {
1707 m_targetHoverHeight = m_waterHeight + m_PIDHoverHeight;
1708 }
1709 break;
1710
1711 } // end switch (m_PIDHoverType)
1712
1713
1714 _target_velocity =
1715 new PhysicsVector(0.0f, 0.0f,
1716 (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep)
1717 );
1718
1719 // if velocity is zero, use position control; otherwise, velocity control
1720
1721 if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f))
1722 {
1723 // keep track of where we stopped. No more slippin' & slidin'
1724
1725 // We only want to deactivate the PID Controller if we think we want to have our surrogate
1726 // react to the physics scene by moving it's position.
1727 // Avatar to Avatar collisions
1728 // Prim to avatar collisions
1729
1730 d.BodySetPosition(Body, pos.X, pos.Y, m_targetHoverHeight);
1731 d.BodySetLinearVel(Body, vel.X, vel.Y, 0);
1732 d.BodyAddForce(Body, 0, 0, fz);
1733 return;
1734 }
1735 else
1736 {
1737 _zeroFlag = false;
1738
1739 // We're flying and colliding with something
1740 fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass);
1741 }
1742 }
1743
1744 fx *= m_mass;
1745 fy *= m_mass;
1746 //fz *= m_mass;
1747
1748 fx += m_force.X;
1749 fy += m_force.Y;
1750 fz += m_force.Z;
1751
1752 //m_log.Info("[OBJPID]: X:" + fx.ToString() + " Y:" + fy.ToString() + " Z:" + fz.ToString());
1753 if (fx != 0 || fy != 0 || fz != 0)
1754 {
1755 //m_taintdisable = true;
1756 //base.RaiseOutOfBounds(Position);
1757 //d.BodySetLinearVel(Body, fx, fy, 0f);
1758 if (!d.BodyIsEnabled(Body))
1759 {
1760 // A physical body at rest on a surface will auto-disable after a while,
1761 // this appears to re-enable it incase the surface it is upon vanishes,
1762 // and the body should fall again.
1763 d.BodySetLinearVel(Body, 0f, 0f, 0f);
1764 d.BodySetForce(Body, 0, 0, 0);
1765 enableBodySoft();
1766 }
1767
1768 // 35x10 = 350n times the mass per second applied maximum.
1769 float nmax = 35f * m_mass;
1770 float nmin = -35f * m_mass;
1563 1771
1564 // If the PID Controller isn't active then we set our force
1565 // calculating base velocity to the current position
1566
1567 if ((m_PIDTau < 1) && (m_PIDTau != 0))
1568 {
1569 //PID_G = PID_G / m_PIDTau;
1570 m_PIDTau = 1;
1571 }
1572
1573 if ((PID_G - m_PIDTau) <= 0)
1574 {
1575 PID_G = m_PIDTau + 1;
1576 }
1577 //PidStatus = true;
1578
1579 // PhysicsVector vec = new PhysicsVector();
1580 d.Vector3 vel = d.BodyGetLinearVel(Body);
1581
1582 d.Vector3 pos = d.BodyGetPosition(Body);
1583 _target_velocity =
1584 new PhysicsVector(
1585 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep),
1586 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep),
1587 (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep)
1588 );
1589
1590 // if velocity is zero, use position control; otherwise, velocity control
1591
1592 if (_target_velocity.IsIdentical(PhysicsVector.Zero,0.1f))
1593 {
1594 // keep track of where we stopped. No more slippin' & slidin'
1595
1596 // We only want to deactivate the PID Controller if we think we want to have our surrogate
1597 // react to the physics scene by moving it's position.
1598 // Avatar to Avatar collisions
1599 // Prim to avatar collisions
1600
1601 //fx = (_target_velocity.X - vel.X) * (PID_D) + (_zeroPosition.X - pos.X) * (PID_P * 2);
1602 //fy = (_target_velocity.Y - vel.Y) * (PID_D) + (_zeroPosition.Y - pos.Y) * (PID_P * 2);
1603 //fz = fz + (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P;
1604 d.BodySetPosition(Body, m_PIDTarget.X, m_PIDTarget.Y, m_PIDTarget.Z);
1605 d.BodySetLinearVel(Body, 0, 0, 0);
1606 d.BodyAddForce(Body, 0, 0, fz);
1607 return;
1608 }
1609 else
1610 {
1611 _zeroFlag = false;
1612
1613 // We're flying and colliding with something
1614 fx = ((_target_velocity.X) - vel.X) * (PID_D);
1615 fy = ((_target_velocity.Y) - vel.Y) * (PID_D);
1616
1617 // vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P;
1618
1619 fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass);
1620 }
1621 }
1622
1623 // Hover PID Controller needs to be mutually exlusive to MoveTo PID controller
1624 if (m_useHoverPID && !m_usePID)
1625 {
1626 // If we're using the PID controller, then we have no gravity
1627 fz = (-1 * _parent_scene.gravityz) * m_mass;
1628
1629 // no lock; for now it's only called from within Simulate()
1630
1631 // If the PID Controller isn't active then we set our force
1632 // calculating base velocity to the current position
1633
1634 if ((m_PIDTau < 1))
1635 {
1636 PID_G = PID_G / m_PIDTau;
1637 }
1638
1639 if ((PID_G - m_PIDTau) <= 0)
1640 {
1641 PID_G = m_PIDTau + 1;
1642 }
1643 1772
1644 1773 if (fx > nmax)
1645 // Where are we, and where are we headed? 1774 fx = nmax;
1646 d.Vector3 pos = d.BodyGetPosition(Body); 1775 if (fx < nmin)
1647 d.Vector3 vel = d.BodyGetLinearVel(Body); 1776 fx = nmin;
1648 1777 if (fy > nmax)
1649 // determine what our target height really is based on HoverType 1778 fy = nmax;
1650 switch (m_PIDHoverType) 1779 if (fy < nmin)
1651 { 1780 fy = nmin;
1652 case PIDHoverType.Absolute: 1781 d.BodyAddForce(Body, fx, fy, fz);
1653 m_targetHoverHeight = m_PIDHoverHeight; 1782 }
1654 break; 1783 }
1655 case PIDHoverType.Ground:
1656 m_groundHeight = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y);
1657 m_targetHoverHeight = m_groundHeight + m_PIDHoverHeight;
1658 break;
1659 case PIDHoverType.GroundAndWater:
1660 m_groundHeight = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y);
1661 m_waterHeight = _parent_scene.GetWaterLevel();
1662 if (m_groundHeight > m_waterHeight)
1663 {
1664 m_targetHoverHeight = m_groundHeight + m_PIDHoverHeight;
1665 }
1666 else
1667 {
1668 m_targetHoverHeight = m_waterHeight + m_PIDHoverHeight;
1669 }
1670 break;
1671 case PIDHoverType.Water:
1672 m_waterHeight = _parent_scene.GetWaterLevel();
1673 m_targetHoverHeight = m_waterHeight + m_PIDHoverHeight;
1674 break;
1675 }
1676
1677
1678 _target_velocity =
1679 new PhysicsVector(0.0f, 0.0f,
1680 (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep)
1681 );
1682
1683 // if velocity is zero, use position control; otherwise, velocity control
1684
1685 if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f))
1686 {
1687 // keep track of where we stopped. No more slippin' & slidin'
1688
1689 // We only want to deactivate the PID Controller if we think we want to have our surrogate
1690 // react to the physics scene by moving it's position.
1691 // Avatar to Avatar collisions
1692 // Prim to avatar collisions
1693
1694 d.BodySetPosition(Body, pos.X, pos.Y, m_targetHoverHeight);
1695 d.BodySetLinearVel(Body, vel.X, vel.Y, 0);
1696 d.BodyAddForce(Body, 0, 0, fz);
1697 return;
1698 }
1699 else
1700 {
1701 _zeroFlag = false;
1702
1703 // We're flying and colliding with something
1704 fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass);
1705 }
1706 }
1707
1708 fx *= m_mass;
1709 fy *= m_mass;
1710 //fz *= m_mass;
1711
1712 fx += m_force.X;
1713 fy += m_force.Y;
1714 fz += m_force.Z;
1715
1716 //m_log.Info("[OBJPID]: X:" + fx.ToString() + " Y:" + fy.ToString() + " Z:" + fz.ToString());
1717 if (fx != 0 || fy != 0 || fz != 0)
1718 {
1719 //m_taintdisable = true;
1720 //base.RaiseOutOfBounds(Position);
1721 //d.BodySetLinearVel(Body, fx, fy, 0f);
1722 if (!d.BodyIsEnabled(Body))
1723 {
1724 d.BodySetLinearVel(Body, 0f, 0f, 0f);
1725 d.BodySetForce(Body, 0, 0, 0);
1726 enableBodySoft();
1727 }
1728
1729 // 35x10 = 350n times the mass per second applied maximum.
1730 float nmax = 35f * m_mass;
1731 float nmin = -35f * m_mass;
1732
1733
1734 if (fx > nmax)
1735 fx = nmax;
1736 if (fx < nmin)
1737 fx = nmin;
1738 if (fy > nmax)
1739 fy = nmax;
1740 if (fy < nmin)
1741 fy = nmin;
1742 d.BodyAddForce(Body, fx, fy, fz);
1743 }
1744 if (m_vehicle.Body == IntPtr.Zero && m_vehicle.Type != Vehicle.TYPE_NONE)
1745 m_vehicle.Enable(Body, _parent_scene);
1746
1747 m_vehicle.Step(timestep);
1748 } 1784 }
1749 else 1785 else
1750 { 1786 { // is not physical, or is not a body or is selected
1751 // _zeroPosition = d.BodyGetPosition(Body); 1787 // _zeroPosition = d.BodyGetPosition(Body);
1752 return; 1788 return;
1753 } 1789 }
1754 } 1790 }
@@ -1762,14 +1798,22 @@ namespace OpenSim.Region.Physics.OdePlugin
1762 myrot.Y = _orientation.Y; 1798 myrot.Y = _orientation.Y;
1763 myrot.Z = _orientation.Z; 1799 myrot.Z = _orientation.Z;
1764 myrot.W = _orientation.W; 1800 myrot.W = _orientation.W;
1765 d.GeomSetQuaternion(prim_geom, ref myrot); 1801 if (Body != IntPtr.Zero)
1766 if (m_isphysical && Body != IntPtr.Zero)
1767 { 1802 {
1803 // KF: If this is a root prim do BodySet
1768 d.BodySetQuaternion(Body, ref myrot); 1804 d.BodySetQuaternion(Body, ref myrot);
1769 if (!m_angularlock.IsIdentical(new PhysicsVector(1, 1, 1), 0)) 1805 if (m_isphysical)
1770 createAMotor(m_angularlock); 1806 {
1807 if (!m_angularlock.IsIdentical(new PhysicsVector(1, 1, 1), 0))
1808 createAMotor(m_angularlock);
1809 }
1810 }
1811 else
1812 {
1813 // daughter prim, do Geom set
1814 d.GeomSetQuaternion(prim_geom, ref myrot);
1771 } 1815 }
1772 1816
1773 resetCollisionAccounting(); 1817 resetCollisionAccounting();
1774 m_taintrot = _orientation; 1818 m_taintrot = _orientation;
1775 } 1819 }
@@ -1831,7 +1875,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1831 m_log.Error("[PHYSICS]: PrimGeom dead"); 1875 m_log.Error("[PHYSICS]: PrimGeom dead");
1832 } 1876 }
1833 } 1877 }
1834 1878//Console.WriteLine("changePhysicsStatus for " + m_primName );
1835 changeadd(2f); 1879 changeadd(2f);
1836 } 1880 }
1837 if (childPrim) 1881 if (childPrim)
@@ -1909,7 +1953,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1909 mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); 1953 mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
1910 1954
1911 //IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); 1955 //IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
1912 1956//Console.WriteLine("changesize 1");
1913 CreateGeom(m_targetSpace, mesh); 1957 CreateGeom(m_targetSpace, mesh);
1914 1958
1915 1959
@@ -1917,6 +1961,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1917 else 1961 else
1918 { 1962 {
1919 _mesh = null; 1963 _mesh = null;
1964//Console.WriteLine("changesize 2");
1920 CreateGeom(m_targetSpace, _mesh); 1965 CreateGeom(m_targetSpace, _mesh);
1921 } 1966 }
1922 1967
@@ -2023,6 +2068,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2023 else 2068 else
2024 { 2069 {
2025 _mesh = null; 2070 _mesh = null;
2071//Console.WriteLine("changeshape");
2026 CreateGeom(m_targetSpace, null); 2072 CreateGeom(m_targetSpace, null);
2027 } 2073 }
2028 2074
@@ -2364,7 +2410,9 @@ namespace OpenSim.Region.Physics.OdePlugin
2364 set 2410 set
2365 { 2411 {
2366 if (QuaternionIsFinite(value)) 2412 if (QuaternionIsFinite(value))
2413 {
2367 _orientation = value; 2414 _orientation = value;
2415 }
2368 else 2416 else
2369 m_log.Warn("[PHYSICS]: Got NaN quaternion Orientation from Scene in Object"); 2417 m_log.Warn("[PHYSICS]: Got NaN quaternion Orientation from Scene in Object");
2370 2418
@@ -2583,12 +2631,16 @@ namespace OpenSim.Region.Physics.OdePlugin
2583 //outofBounds = true; 2631 //outofBounds = true;
2584 } 2632 }
2585 2633
2634 float Adiff = 1.0f - Math.Abs(Quaternion.Dot(m_lastorientation, l_orientation));
2635//Console.WriteLine("Adiff " + m_primName + " = " + Adiff);
2586 if ((Math.Abs(m_lastposition.X - l_position.X) < 0.02) 2636 if ((Math.Abs(m_lastposition.X - l_position.X) < 0.02)
2587 && (Math.Abs(m_lastposition.Y - l_position.Y) < 0.02) 2637 && (Math.Abs(m_lastposition.Y - l_position.Y) < 0.02)
2588 && (Math.Abs(m_lastposition.Z - l_position.Z) < 0.02) 2638 && (Math.Abs(m_lastposition.Z - l_position.Z) < 0.02)
2589 && (1.0 - Math.Abs(Quaternion.Dot(m_lastorientation, l_orientation)) < 0.01)) 2639// && (1.0 - Math.Abs(Quaternion.Dot(m_lastorientation, l_orientation)) < 0.01))
2640 && (1.0 - Math.Abs(Quaternion.Dot(m_lastorientation, l_orientation)) < 0.0001)) // KF 0.01 is far to large
2590 { 2641 {
2591 _zeroFlag = true; 2642 _zeroFlag = true;
2643//Console.WriteLine("ZFT 2");
2592 m_throttleUpdates = false; 2644 m_throttleUpdates = false;
2593 } 2645 }
2594 else 2646 else