aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
diff options
context:
space:
mode:
authoropensim2009-09-30 18:51:02 +0200
committeropensim2009-09-30 18:51:02 +0200
commit827b0fb1993c6f9b1289931a1ac38ff2b810952c (patch)
tree3c5e7b7fe5b21fdf159d64f1264a9d41ceac7b69 /OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
parentFinish the (untested) authentication connector (diff)
downloadopensim-SC_OLD-827b0fb1993c6f9b1289931a1ac38ff2b810952c.zip
opensim-SC_OLD-827b0fb1993c6f9b1289931a1ac38ff2b810952c.tar.gz
opensim-SC_OLD-827b0fb1993c6f9b1289931a1ac38ff2b810952c.tar.bz2
opensim-SC_OLD-827b0fb1993c6f9b1289931a1ac38ff2b810952c.tar.xz
Commit initial version of KittoFlora's vehicle changes
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 673ae39..34844c0 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;
@@ -147,8 +162,6 @@ namespace OpenSim.Region.Physics.OdePlugin
147 public int m_roundsUnderMotionThreshold = 0; 162 public int m_roundsUnderMotionThreshold = 0;
148 private int m_crossingfailures = 0; 163 private int m_crossingfailures = 0;
149 164
150 public float m_buoyancy = 0f;
151
152 public bool outofBounds = false; 165 public bool outofBounds = false;
153 private float m_density = 10.000006836f; // Aluminum g/cm3; 166 private float m_density = 10.000006836f; // Aluminum g/cm3;
154 167
@@ -156,7 +169,8 @@ namespace OpenSim.Region.Physics.OdePlugin
156 private bool m_lastUpdateSent = false; 169 private bool m_lastUpdateSent = false;
157 170
158 public IntPtr Body = (IntPtr) 0; 171 public IntPtr Body = (IntPtr) 0;
159 private String m_primName; 172 public String m_primName;
173// private String m_primName;
160 private PhysicsVector _target_velocity; 174 private PhysicsVector _target_velocity;
161 public d.Mass pMass; 175 public d.Mass pMass;
162 176
@@ -167,7 +181,7 @@ namespace OpenSim.Region.Physics.OdePlugin
167 181
168 public volatile bool childPrim = false; 182 public volatile bool childPrim = false;
169 183
170 private ODEVehicleSettings m_vehicle; 184 private ODEDynamics m_vehicle;
171 185
172 internal int m_material = (int)Material.Wood; 186 internal int m_material = (int)Material.Wood;
173 187
@@ -175,7 +189,7 @@ namespace OpenSim.Region.Physics.OdePlugin
175 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode) 189 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode)
176 { 190 {
177 _target_velocity = new PhysicsVector(0, 0, 0); 191 _target_velocity = new PhysicsVector(0, 0, 0);
178 m_vehicle = new ODEVehicleSettings(); 192 m_vehicle = new ODEDynamics();
179 //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned); 193 //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned);
180 ode = dode; 194 ode = dode;
181 _velocity = new PhysicsVector(); 195 _velocity = new PhysicsVector();
@@ -260,11 +274,6 @@ namespace OpenSim.Region.Physics.OdePlugin
260 m_localID = value; } 274 m_localID = value; }
261 } 275 }
262 276
263 public override int GetHashCode()
264 {
265 return (int)m_localID;
266 }
267
268 public override bool Grabbed 277 public override bool Grabbed
269 { 278 {
270 set { return; } 279 set { return; }
@@ -273,6 +282,8 @@ namespace OpenSim.Region.Physics.OdePlugin
273 public override bool Selected 282 public override bool Selected
274 { 283 {
275 set { 284 set {
285
286
276 // This only makes the object not collidable if the object 287 // This only makes the object not collidable if the object
277 // is physical or the object is modified somehow *IN THE FUTURE* 288 // is physical or the object is modified somehow *IN THE FUTURE*
278 // without this, if an avatar selects prim, they can walk right 289 // without this, if an avatar selects prim, they can walk right
@@ -288,6 +299,7 @@ namespace OpenSim.Region.Physics.OdePlugin
288 m_taintselected = value; 299 m_taintselected = value;
289 m_isSelected = value; 300 m_isSelected = value;
290 } 301 }
302 if(m_isSelected) disableBodySoft();
291 } 303 }
292 } 304 }
293 305
@@ -295,6 +307,7 @@ namespace OpenSim.Region.Physics.OdePlugin
295 { 307 {
296 prev_geom = prim_geom; 308 prev_geom = prim_geom;
297 prim_geom = geom; 309 prim_geom = geom;
310//Console.WriteLine("SetGeom to " + prim_geom + " for " + m_primName);
298 if (prim_geom != IntPtr.Zero) 311 if (prim_geom != IntPtr.Zero)
299 { 312 {
300 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); 313 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
@@ -306,6 +319,7 @@ namespace OpenSim.Region.Physics.OdePlugin
306 if (_parent != null && _parent is OdePrim) 319 if (_parent != null && _parent is OdePrim)
307 { 320 {
308 OdePrim parent = (OdePrim)_parent; 321 OdePrim parent = (OdePrim)_parent;
322//Console.WriteLine("SetGeom calls ChildSetGeom");
309 parent.ChildSetGeom(this); 323 parent.ChildSetGeom(this);
310 } 324 }
311 } 325 }
@@ -321,7 +335,8 @@ namespace OpenSim.Region.Physics.OdePlugin
321 if (m_isphysical && Body != IntPtr.Zero) 335 if (m_isphysical && Body != IntPtr.Zero)
322 { 336 {
323 d.BodyEnable(Body); 337 d.BodyEnable(Body);
324 m_vehicle.Enable(Body, _parent_scene); 338 if (m_vehicle.Type != Vehicle.TYPE_NONE)
339 m_vehicle.Enable(Body, _parent_scene);
325 } 340 }
326 341
327 m_disabled = false; 342 m_disabled = false;
@@ -335,7 +350,6 @@ namespace OpenSim.Region.Physics.OdePlugin
335 if (m_isphysical && Body != IntPtr.Zero) 350 if (m_isphysical && Body != IntPtr.Zero)
336 { 351 {
337 d.BodyDisable(Body); 352 d.BodyDisable(Body);
338 m_vehicle.Disable();
339 } 353 }
340 } 354 }
341 355
@@ -365,6 +379,9 @@ namespace OpenSim.Region.Physics.OdePlugin
365 379
366 d.BodySetAutoDisableFlag(Body, true); 380 d.BodySetAutoDisableFlag(Body, true);
367 d.BodySetAutoDisableSteps(Body, body_autodisable_frames); 381 d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
382
383 // disconnect from world gravity so we can apply buoyancy
384 d.BodySetGravityMode (Body, false);
368 385
369 m_interpenetrationcount = 0; 386 m_interpenetrationcount = 0;
370 m_collisionscore = 0; 387 m_collisionscore = 0;
@@ -711,13 +728,8 @@ namespace OpenSim.Region.Physics.OdePlugin
711 break; 728 break;
712 } 729 }
713 } 730 }
714
715
716
717
718
719 return returnMass; 731 return returnMass;
720 } 732 }// end CalculateMass
721 733
722 #endregion 734 #endregion
723 735
@@ -743,7 +755,6 @@ namespace OpenSim.Region.Physics.OdePlugin
743 if (Body != IntPtr.Zero) 755 if (Body != IntPtr.Zero)
744 { 756 {
745 _parent_scene.remActivePrim(this); 757 _parent_scene.remActivePrim(this);
746 m_vehicle.Destroy();
747 m_collisionCategories &= ~CollisionCategories.Body; 758 m_collisionCategories &= ~CollisionCategories.Body;
748 m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land); 759 m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land);
749 760
@@ -838,6 +849,7 @@ namespace OpenSim.Region.Physics.OdePlugin
838 { 849 {
839 if (prim_geom == IntPtr.Zero) 850 if (prim_geom == IntPtr.Zero)
840 { 851 {
852//Console.WriteLine(" setMesh 1");
841 SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null)); 853 SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null));
842 } 854 }
843 } 855 }
@@ -865,19 +877,35 @@ namespace OpenSim.Region.Physics.OdePlugin
865 877
866 public void ProcessTaints(float timestep) 878 public void ProcessTaints(float timestep)
867 { 879 {
880//Console.WriteLine("ProcessTaints for " + m_primName );
868 if (m_taintadd) 881 if (m_taintadd)
869 { 882 {
870 changeadd(timestep); 883 changeadd(timestep);
871 } 884 }
885
872 if (prim_geom != IntPtr.Zero) 886 if (prim_geom != IntPtr.Zero)
873 { 887 {
874 if (!_position.IsIdentical(m_taintposition,0f)) 888 if (!_position.IsIdentical(m_taintposition,0f))
875 changemove(timestep); 889 changemove(timestep);
876 890
877 if (m_taintrot != _orientation) 891 if (m_taintrot != _orientation)
878 rotate(timestep); 892 {
893 if(childPrim && IsPhysical) // For physical child prim...
894 {
895 rotate(timestep);
896 // KF: ODE will also rotate the parent prim!
897 // so rotate the root back to where it was
898 OdePrim parent = (OdePrim)_parent;
899 parent.rotate(timestep);
900 }
901 else
902 {
903 //Just rotate the prim
904 rotate(timestep);
905 }
906 }
879 // 907 //
880 908
881 if (m_taintPhysics != m_isphysical && !(m_taintparent != _parent)) 909 if (m_taintPhysics != m_isphysical && !(m_taintparent != _parent))
882 changePhysicsStatus(timestep); 910 changePhysicsStatus(timestep);
883 // 911 //
@@ -916,8 +944,7 @@ namespace OpenSim.Region.Physics.OdePlugin
916 944
917 if (!m_angularlock.IsIdentical(m_taintAngularLock,0)) 945 if (!m_angularlock.IsIdentical(m_taintAngularLock,0))
918 changeAngularLock(timestep); 946 changeAngularLock(timestep);
919 947
920
921 } 948 }
922 else 949 else
923 { 950 {
@@ -949,11 +976,6 @@ namespace OpenSim.Region.Physics.OdePlugin
949 Amotor = IntPtr.Zero; 976 Amotor = IntPtr.Zero;
950 } 977 }
951 } 978 }
952
953 if (m_vehicle.Type != Vehicle.TYPE_NONE)
954 {
955 m_vehicle.Reset();
956 }
957 } 979 }
958 } 980 }
959 // Store this for later in case we get turned into a separate body 981 // Store this for later in case we get turned into a separate body
@@ -971,7 +993,7 @@ namespace OpenSim.Region.Physics.OdePlugin
971 { 993 {
972 OdePrim obj = (OdePrim)m_taintparent; 994 OdePrim obj = (OdePrim)m_taintparent;
973 //obj.disableBody(); 995 //obj.disableBody();
974 996//Console.WriteLine("changelink calls ParentPrim");
975 obj.ParentPrim(this); 997 obj.ParentPrim(this);
976 998
977 /* 999 /*
@@ -989,6 +1011,8 @@ namespace OpenSim.Region.Physics.OdePlugin
989 // destroy link 1011 // destroy link
990 else if (_parent != null && m_taintparent == null) 1012 else if (_parent != null && m_taintparent == null)
991 { 1013 {
1014//Console.WriteLine(" changelink B");
1015
992 if (_parent is OdePrim) 1016 if (_parent is OdePrim)
993 { 1017 {
994 OdePrim obj = (OdePrim)_parent; 1018 OdePrim obj = (OdePrim)_parent;
@@ -1005,7 +1029,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1005 m_linkJoint = (IntPtr)0; 1029 m_linkJoint = (IntPtr)0;
1006 */ 1030 */
1007 } 1031 }
1008 1032
1009 _parent = m_taintparent; 1033 _parent = m_taintparent;
1010 m_taintPhysics = m_isphysical; 1034 m_taintPhysics = m_isphysical;
1011 } 1035 }
@@ -1014,6 +1038,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1014 // prim is the child 1038 // prim is the child
1015 public void ParentPrim(OdePrim prim) 1039 public void ParentPrim(OdePrim prim)
1016 { 1040 {
1041//Console.WriteLine("ParentPrim " + m_primName);
1017 if (this.m_localID != prim.m_localID) 1042 if (this.m_localID != prim.m_localID)
1018 { 1043 {
1019 if (Body == IntPtr.Zero) 1044 if (Body == IntPtr.Zero)
@@ -1027,6 +1052,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1027 { 1052 {
1028 if (!childrenPrim.Contains(prim)) 1053 if (!childrenPrim.Contains(prim))
1029 { 1054 {
1055//Console.WriteLine("childrenPrim.Add " + prim);
1030 childrenPrim.Add(prim); 1056 childrenPrim.Add(prim);
1031 1057
1032 foreach (OdePrim prm in childrenPrim) 1058 foreach (OdePrim prm in childrenPrim)
@@ -1050,6 +1076,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1050 } 1076 }
1051 foreach (OdePrim prm in childrenPrim) 1077 foreach (OdePrim prm in childrenPrim)
1052 { 1078 {
1079
1053 prm.m_collisionCategories |= CollisionCategories.Body; 1080 prm.m_collisionCategories |= CollisionCategories.Body;
1054 prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); 1081 prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
1055 1082
@@ -1058,7 +1085,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1058 m_log.Warn("[PHYSICS]: Unable to link one of the linkset elements. No geom yet"); 1085 m_log.Warn("[PHYSICS]: Unable to link one of the linkset elements. No geom yet");
1059 continue; 1086 continue;
1060 } 1087 }
1061 1088//Console.WriteLine(" GeomSetCategoryBits 1: " + prm.prim_geom + " - " + (int)prm.m_collisionCategories + " for " + m_primName);
1062 d.GeomSetCategoryBits(prm.prim_geom, (int)prm.m_collisionCategories); 1089 d.GeomSetCategoryBits(prm.prim_geom, (int)prm.m_collisionCategories);
1063 d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags); 1090 d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags);
1064 1091
@@ -1103,11 +1130,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1103 prm.Body = Body; 1130 prm.Body = Body;
1104 _parent_scene.addActivePrim(prm); 1131 _parent_scene.addActivePrim(prm);
1105 } 1132 }
1106
1107 m_collisionCategories |= CollisionCategories.Body; 1133 m_collisionCategories |= CollisionCategories.Body;
1108 m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); 1134 m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
1109 1135
1136//Console.WriteLine("GeomSetCategoryBits 2: " + prim_geom + " - " + (int)m_collisionCategories + " for " + m_primName);
1110 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); 1137 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
1138//Console.WriteLine(" Post GeomSetCategoryBits 2");
1111 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); 1139 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
1112 1140
1113 1141
@@ -1143,7 +1171,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1143 createAMotor(m_angularlock); 1171 createAMotor(m_angularlock);
1144 } 1172 }
1145 d.BodySetPosition(Body, Position.X, Position.Y, Position.Z); 1173 d.BodySetPosition(Body, Position.X, Position.Y, Position.Z);
1146 m_vehicle.Enable(Body, _parent_scene); 1174 if (m_vehicle.Type != Vehicle.TYPE_NONE) m_vehicle.Enable(Body, _parent_scene);
1147 _parent_scene.addActivePrim(this); 1175 _parent_scene.addActivePrim(this);
1148 } 1176 }
1149 } 1177 }
@@ -1180,6 +1208,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1180 { 1208 {
1181 foreach (OdePrim prm in childrenPrim) 1209 foreach (OdePrim prm in childrenPrim)
1182 { 1210 {
1211//Console.WriteLine("ChildSetGeom calls ParentPrim");
1183 ParentPrim(prm); 1212 ParentPrim(prm);
1184 } 1213 }
1185 } 1214 }
@@ -1206,6 +1235,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1206 1235
1207 lock (childrenPrim) 1236 lock (childrenPrim)
1208 { 1237 {
1238 //Console.WriteLine("childrenPrim.Remove " + odePrim);
1209 childrenPrim.Remove(odePrim); 1239 childrenPrim.Remove(odePrim);
1210 } 1240 }
1211 1241
@@ -1223,6 +1253,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1223 { 1253 {
1224 foreach (OdePrim prm in childrenPrim) 1254 foreach (OdePrim prm in childrenPrim)
1225 { 1255 {
1256//Console.WriteLine("ChildDelink calls ParentPrim");
1226 ParentPrim(prm); 1257 ParentPrim(prm);
1227 } 1258 }
1228 } 1259 }
@@ -1307,7 +1338,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1307 1338
1308 resetCollisionAccounting(); 1339 resetCollisionAccounting();
1309 m_isSelected = m_taintselected; 1340 m_isSelected = m_taintselected;
1310 } 1341 }//end changeSelectedStatus
1311 1342
1312 public void ResetTaints() 1343 public void ResetTaints()
1313 { 1344 {
@@ -1324,6 +1355,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1324 1355
1325 public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh) 1356 public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh)
1326 { 1357 {
1358//Console.WriteLine("CreateGeom:");
1327 if (_mesh != null) 1359 if (_mesh != null)
1328 { 1360 {
1329 setMesh(_parent_scene, _mesh); 1361 setMesh(_parent_scene, _mesh);
@@ -1339,6 +1371,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1339 _parent_scene.waitForSpaceUnlock(m_targetSpace); 1371 _parent_scene.waitForSpaceUnlock(m_targetSpace);
1340 try 1372 try
1341 { 1373 {
1374//Console.WriteLine(" CreateGeom 1");
1342 SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2)); 1375 SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2));
1343 } 1376 }
1344 catch (AccessViolationException) 1377 catch (AccessViolationException)
@@ -1353,6 +1386,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1353 _parent_scene.waitForSpaceUnlock(m_targetSpace); 1386 _parent_scene.waitForSpaceUnlock(m_targetSpace);
1354 try 1387 try
1355 { 1388 {
1389//Console.WriteLine(" CreateGeom 2");
1356 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); 1390 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
1357 } 1391 }
1358 catch (AccessViolationException) 1392 catch (AccessViolationException)
@@ -1368,6 +1402,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1368 _parent_scene.waitForSpaceUnlock(m_targetSpace); 1402 _parent_scene.waitForSpaceUnlock(m_targetSpace);
1369 try 1403 try
1370 { 1404 {
1405//Console.WriteLine(" CreateGeom 3");
1371 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); 1406 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
1372 } 1407 }
1373 catch (AccessViolationException) 1408 catch (AccessViolationException)
@@ -1384,6 +1419,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1384 _parent_scene.waitForSpaceUnlock(m_targetSpace); 1419 _parent_scene.waitForSpaceUnlock(m_targetSpace);
1385 try 1420 try
1386 { 1421 {
1422//Console.WriteLine(" CreateGeom 4");
1387 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); 1423 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
1388 } 1424 }
1389 catch (AccessViolationException) 1425 catch (AccessViolationException)
@@ -1420,6 +1456,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1420 1456
1421 lock (_parent_scene.OdeLock) 1457 lock (_parent_scene.OdeLock)
1422 { 1458 {
1459//Console.WriteLine("changeadd 1");
1423 CreateGeom(m_targetSpace, _mesh); 1460 CreateGeom(m_targetSpace, _mesh);
1424 1461
1425 if (prim_geom != IntPtr.Zero) 1462 if (prim_geom != IntPtr.Zero)
@@ -1475,6 +1512,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1475 OdePrim odParent = (OdePrim)_parent; 1512 OdePrim odParent = (OdePrim)_parent;
1476 if (Body != (IntPtr)0 && odParent.Body != (IntPtr)0 && Body != odParent.Body) 1513 if (Body != (IntPtr)0 && odParent.Body != (IntPtr)0 && Body != odParent.Body)
1477 { 1514 {
1515// KF: Fixed Joints were removed? Anyway - this Console.WriteLine does not show up, so routine is not used??
1516Console.WriteLine(" JointCreateFixed");
1478 m_linkJoint = d.JointCreateFixed(_parent_scene.world, _linkJointGroup); 1517 m_linkJoint = d.JointCreateFixed(_parent_scene.world, _linkJointGroup);
1479 d.JointAttach(m_linkJoint, Body, odParent.Body); 1518 d.JointAttach(m_linkJoint, Body, odParent.Body);
1480 d.JointSetFixed(m_linkJoint); 1519 d.JointSetFixed(m_linkJoint);
@@ -1528,239 +1567,236 @@ namespace OpenSim.Region.Physics.OdePlugin
1528 float fz = 0; 1567 float fz = 0;
1529 1568
1530 1569
1531 if (IsPhysical && Body != IntPtr.Zero && !m_isSelected) 1570 if (IsPhysical && (Body != IntPtr.Zero) && !m_isSelected && !childPrim) // KF: Only move root prims.
1532 { 1571 {
1533 if (d.BodyIsEnabled(Body) && !m_angularlock.IsIdentical(PhysicsVector.Zero, 0.003f)) 1572 if (m_vehicle.Type != Vehicle.TYPE_NONE)
1534 { 1573 {
1535 d.Vector3 avel2 = d.BodyGetAngularVel(Body); 1574 // 'VEHICLES' are dealt with in ODEDynamics.cs
1536 if (m_angularlock.X == 1) 1575 m_vehicle.Step(timestep, _parent_scene);
1537 avel2.X = 0; 1576 }
1538 if (m_angularlock.Y == 1) 1577 else
1539 avel2.Y = 0; 1578 {
1540 if (m_angularlock.Z == 1) 1579 // NON-'VEHICLES' are dealt with here
1541 avel2.Z = 0; 1580 if (d.BodyIsEnabled(Body) && !m_angularlock.IsIdentical(PhysicsVector.Zero, 0.003f))
1542 d.BodySetAngularVel(Body, avel2.X, avel2.Y, avel2.Z); 1581 {
1543 } 1582 d.Vector3 avel2 = d.BodyGetAngularVel(Body);
1544 //float PID_P = 900.0f; 1583 if (m_angularlock.X == 1)
1545 1584 avel2.X = 0;
1546 float m_mass = CalculateMass(); 1585 if (m_angularlock.Y == 1)
1547 1586 avel2.Y = 0;
1548 fz = 0f; 1587 if (m_angularlock.Z == 1)
1588 avel2.Z = 0;
1589 d.BodySetAngularVel(Body, avel2.X, avel2.Y, avel2.Z);
1590 }
1591 //float PID_P = 900.0f;
1592
1593 float m_mass = CalculateMass();
1594
1595// fz = 0f;
1549 //m_log.Info(m_collisionFlags.ToString()); 1596 //m_log.Info(m_collisionFlags.ToString());
1550 1597
1551 if (m_buoyancy != 0) 1598
1552 { 1599 //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle.
1553 if (m_buoyancy > 0) 1600 // would come from SceneObjectPart.cs, public void SetBuoyancy(float fvalue) , PhysActor.Buoyancy = fvalue; ??
1554 { 1601 // m_buoyancy: (unlimited value) <0=Falls fast; 0=1g; 1=0g; >1 = floats up
1555 fz = (((-1 * _parent_scene.gravityz) * m_buoyancy) * m_mass); 1602 // gravityz multiplier = 1 - m_buoyancy
1556 1603 fz = _parent_scene.gravityz * (1.0f - m_buoyancy) * m_mass;
1557 //d.Vector3 l_velocity = d.BodyGetLinearVel(Body); 1604
1558 //m_log.Info("Using Buoyancy: " + buoyancy + " G: " + (_parent_scene.gravityz * m_buoyancy) + "mass:" + m_mass + " Pos: " + Position.ToString()); 1605 if (m_usePID)
1559 } 1606 {
1560 else 1607 // KF - this is for object move? eg. llSetPos() ?
1561 { 1608 //if (!d.BodyIsEnabled(Body))
1562 fz = (-1 * (((-1 * _parent_scene.gravityz) * (-1 * m_buoyancy)) * m_mass)); 1609 //d.BodySetForce(Body, 0f, 0f, 0f);
1563 } 1610 // If we're using the PID controller, then we have no gravity
1564 } 1611 //fz = (-1 * _parent_scene.gravityz) * m_mass; //KF: ?? Prims have no global gravity,so simply...
1565 1612 fz = 0f;
1566 if (m_usePID) 1613
1567 { 1614 // no lock; for now it's only called from within Simulate()
1615
1616 // If the PID Controller isn't active then we set our force
1617 // calculating base velocity to the current position
1618
1619 if ((m_PIDTau < 1) && (m_PIDTau != 0))
1620 {
1621 //PID_G = PID_G / m_PIDTau;
1622 m_PIDTau = 1;
1623 }
1624
1625 if ((PID_G - m_PIDTau) <= 0)
1626 {
1627 PID_G = m_PIDTau + 1;
1628 }
1629 //PidStatus = true;
1630
1631 // PhysicsVector vec = new PhysicsVector();
1632 d.Vector3 vel = d.BodyGetLinearVel(Body);
1633
1634 d.Vector3 pos = d.BodyGetPosition(Body);
1635 _target_velocity =
1636 new PhysicsVector(
1637 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep),
1638 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep),
1639 (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep)
1640 );
1641
1642 // if velocity is zero, use position control; otherwise, velocity control
1643
1644 if (_target_velocity.IsIdentical(PhysicsVector.Zero,0.1f))
1645 {
1646 // keep track of where we stopped. No more slippin' & slidin'
1647
1648 // We only want to deactivate the PID Controller if we think we want to have our surrogate
1649 // react to the physics scene by moving it's position.
1650 // Avatar to Avatar collisions
1651 // Prim to avatar collisions
1652
1653 //fx = (_target_velocity.X - vel.X) * (PID_D) + (_zeroPosition.X - pos.X) * (PID_P * 2);
1654 //fy = (_target_velocity.Y - vel.Y) * (PID_D) + (_zeroPosition.Y - pos.Y) * (PID_P * 2);
1655 //fz = fz + (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P;
1656 d.BodySetPosition(Body, m_PIDTarget.X, m_PIDTarget.Y, m_PIDTarget.Z);
1657 d.BodySetLinearVel(Body, 0, 0, 0);
1658 d.BodyAddForce(Body, 0, 0, fz);
1659 return;
1660 }
1661 else
1662 {
1663 _zeroFlag = false;
1664
1665 // We're flying and colliding with something
1666 fx = ((_target_velocity.X) - vel.X) * (PID_D);
1667 fy = ((_target_velocity.Y) - vel.Y) * (PID_D);
1668
1669 // vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P;
1670
1671 fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass);
1672 }
1673 } // end if (m_usePID)
1674
1675 // Hover PID Controller needs to be mutually exlusive to MoveTo PID controller
1676 if (m_useHoverPID && !m_usePID)
1677 {
1678 // If we're using the PID controller, then we have no gravity
1679 fz = (-1 * _parent_scene.gravityz) * m_mass;
1680
1681 // no lock; for now it's only called from within Simulate()
1682
1683 // If the PID Controller isn't active then we set our force
1684 // calculating base velocity to the current position
1685
1686 if ((m_PIDTau < 1))
1687 {
1688 PID_G = PID_G / m_PIDTau;
1689 }
1690
1691 if ((PID_G - m_PIDTau) <= 0)
1692 {
1693 PID_G = m_PIDTau + 1;
1694 }
1568 1695
1569 //if (!d.BodyIsEnabled(Body))
1570 //d.BodySetForce(Body, 0f, 0f, 0f);
1571 // If we're using the PID controller, then we have no gravity
1572 fz = (-1 * _parent_scene.gravityz) * m_mass;
1573 1696
1574 // no lock; for now it's only called from within Simulate() 1697 // Where are we, and where are we headed?
1698 d.Vector3 pos = d.BodyGetPosition(Body);
1699 d.Vector3 vel = d.BodyGetLinearVel(Body);
1700
1701
1702 // Non-Vehicles have a limited set of Hover options.
1703 // determine what our target height really is based on HoverType
1704 switch (m_PIDHoverType)
1705 {
1706 case PIDHoverType.Ground:
1707 m_groundHeight = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y);
1708 m_targetHoverHeight = m_groundHeight + m_PIDHoverHeight;
1709 break;
1710 case PIDHoverType.GroundAndWater:
1711 m_groundHeight = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y);
1712 m_waterHeight = _parent_scene.GetWaterLevel();
1713 if (m_groundHeight > m_waterHeight)
1714 {
1715 m_targetHoverHeight = m_groundHeight + m_PIDHoverHeight;
1716 }
1717 else
1718 {
1719 m_targetHoverHeight = m_waterHeight + m_PIDHoverHeight;
1720 }
1721 break;
1722
1723 } // end switch (m_PIDHoverType)
1724
1725
1726 _target_velocity =
1727 new PhysicsVector(0.0f, 0.0f,
1728 (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep)
1729 );
1730
1731 // if velocity is zero, use position control; otherwise, velocity control
1732
1733 if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f))
1734 {
1735 // keep track of where we stopped. No more slippin' & slidin'
1736
1737 // We only want to deactivate the PID Controller if we think we want to have our surrogate
1738 // react to the physics scene by moving it's position.
1739 // Avatar to Avatar collisions
1740 // Prim to avatar collisions
1741
1742 d.BodySetPosition(Body, pos.X, pos.Y, m_targetHoverHeight);
1743 d.BodySetLinearVel(Body, vel.X, vel.Y, 0);
1744 d.BodyAddForce(Body, 0, 0, fz);
1745 return;
1746 }
1747 else
1748 {
1749 _zeroFlag = false;
1750
1751 // We're flying and colliding with something
1752 fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass);
1753 }
1754 }
1755
1756 fx *= m_mass;
1757 fy *= m_mass;
1758 //fz *= m_mass;
1759
1760 fx += m_force.X;
1761 fy += m_force.Y;
1762 fz += m_force.Z;
1763
1764 //m_log.Info("[OBJPID]: X:" + fx.ToString() + " Y:" + fy.ToString() + " Z:" + fz.ToString());
1765 if (fx != 0 || fy != 0 || fz != 0)
1766 {
1767 //m_taintdisable = true;
1768 //base.RaiseOutOfBounds(Position);
1769 //d.BodySetLinearVel(Body, fx, fy, 0f);
1770 if (!d.BodyIsEnabled(Body))
1771 {
1772 // A physical body at rest on a surface will auto-disable after a while,
1773 // this appears to re-enable it incase the surface it is upon vanishes,
1774 // and the body should fall again.
1775 d.BodySetLinearVel(Body, 0f, 0f, 0f);
1776 d.BodySetForce(Body, 0, 0, 0);
1777 enableBodySoft();
1778 }
1779
1780 // 35x10 = 350n times the mass per second applied maximum.
1781 float nmax = 35f * m_mass;
1782 float nmin = -35f * m_mass;
1575 1783
1576 // If the PID Controller isn't active then we set our force
1577 // calculating base velocity to the current position
1578
1579 if ((m_PIDTau < 1) && (m_PIDTau != 0))
1580 {
1581 //PID_G = PID_G / m_PIDTau;
1582 m_PIDTau = 1;
1583 }
1584
1585 if ((PID_G - m_PIDTau) <= 0)
1586 {
1587 PID_G = m_PIDTau + 1;
1588 }
1589 //PidStatus = true;
1590
1591 // PhysicsVector vec = new PhysicsVector();
1592 d.Vector3 vel = d.BodyGetLinearVel(Body);
1593
1594 d.Vector3 pos = d.BodyGetPosition(Body);
1595 _target_velocity =
1596 new PhysicsVector(
1597 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep),
1598 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep),
1599 (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep)
1600 );
1601
1602 // if velocity is zero, use position control; otherwise, velocity control
1603
1604 if (_target_velocity.IsIdentical(PhysicsVector.Zero,0.1f))
1605 {
1606 // keep track of where we stopped. No more slippin' & slidin'
1607
1608 // We only want to deactivate the PID Controller if we think we want to have our surrogate
1609 // react to the physics scene by moving it's position.
1610 // Avatar to Avatar collisions
1611 // Prim to avatar collisions
1612
1613 //fx = (_target_velocity.X - vel.X) * (PID_D) + (_zeroPosition.X - pos.X) * (PID_P * 2);
1614 //fy = (_target_velocity.Y - vel.Y) * (PID_D) + (_zeroPosition.Y - pos.Y) * (PID_P * 2);
1615 //fz = fz + (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P;
1616 d.BodySetPosition(Body, m_PIDTarget.X, m_PIDTarget.Y, m_PIDTarget.Z);
1617 d.BodySetLinearVel(Body, 0, 0, 0);
1618 d.BodyAddForce(Body, 0, 0, fz);
1619 return;
1620 }
1621 else
1622 {
1623 _zeroFlag = false;
1624
1625 // We're flying and colliding with something
1626 fx = ((_target_velocity.X) - vel.X) * (PID_D);
1627 fy = ((_target_velocity.Y) - vel.Y) * (PID_D);
1628
1629 // vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P;
1630
1631 fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass);
1632 }
1633 }
1634
1635 // Hover PID Controller needs to be mutually exlusive to MoveTo PID controller
1636 if (m_useHoverPID && !m_usePID)
1637 {
1638 // If we're using the PID controller, then we have no gravity
1639 fz = (-1 * _parent_scene.gravityz) * m_mass;
1640
1641 // no lock; for now it's only called from within Simulate()
1642
1643 // If the PID Controller isn't active then we set our force
1644 // calculating base velocity to the current position
1645
1646 if ((m_PIDTau < 1))
1647 {
1648 PID_G = PID_G / m_PIDTau;
1649 }
1650
1651 if ((PID_G - m_PIDTau) <= 0)
1652 {
1653 PID_G = m_PIDTau + 1;
1654 }
1655 1784
1656 1785 if (fx > nmax)
1657 // Where are we, and where are we headed? 1786 fx = nmax;
1658 d.Vector3 pos = d.BodyGetPosition(Body); 1787 if (fx < nmin)
1659 d.Vector3 vel = d.BodyGetLinearVel(Body); 1788 fx = nmin;
1660 1789 if (fy > nmax)
1661 // determine what our target height really is based on HoverType 1790 fy = nmax;
1662 switch (m_PIDHoverType) 1791 if (fy < nmin)
1663 { 1792 fy = nmin;
1664 case PIDHoverType.Absolute: 1793 d.BodyAddForce(Body, fx, fy, fz);
1665 m_targetHoverHeight = m_PIDHoverHeight; 1794 }
1666 break; 1795 }
1667 case PIDHoverType.Ground:
1668 m_groundHeight = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y);
1669 m_targetHoverHeight = m_groundHeight + m_PIDHoverHeight;
1670 break;
1671 case PIDHoverType.GroundAndWater:
1672 m_groundHeight = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y);
1673 m_waterHeight = _parent_scene.GetWaterLevel();
1674 if (m_groundHeight > m_waterHeight)
1675 {
1676 m_targetHoverHeight = m_groundHeight + m_PIDHoverHeight;
1677 }
1678 else
1679 {
1680 m_targetHoverHeight = m_waterHeight + m_PIDHoverHeight;
1681 }
1682 break;
1683 case PIDHoverType.Water:
1684 m_waterHeight = _parent_scene.GetWaterLevel();
1685 m_targetHoverHeight = m_waterHeight + m_PIDHoverHeight;
1686 break;
1687 }
1688
1689
1690 _target_velocity =
1691 new PhysicsVector(0.0f, 0.0f,
1692 (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep)
1693 );
1694
1695 // if velocity is zero, use position control; otherwise, velocity control
1696
1697 if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f))
1698 {
1699 // keep track of where we stopped. No more slippin' & slidin'
1700
1701 // We only want to deactivate the PID Controller if we think we want to have our surrogate
1702 // react to the physics scene by moving it's position.
1703 // Avatar to Avatar collisions
1704 // Prim to avatar collisions
1705
1706 d.BodySetPosition(Body, pos.X, pos.Y, m_targetHoverHeight);
1707 d.BodySetLinearVel(Body, vel.X, vel.Y, 0);
1708 d.BodyAddForce(Body, 0, 0, fz);
1709 return;
1710 }
1711 else
1712 {
1713 _zeroFlag = false;
1714
1715 // We're flying and colliding with something
1716 fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass);
1717 }
1718 }
1719
1720 fx *= m_mass;
1721 fy *= m_mass;
1722 //fz *= m_mass;
1723
1724 fx += m_force.X;
1725 fy += m_force.Y;
1726 fz += m_force.Z;
1727
1728 //m_log.Info("[OBJPID]: X:" + fx.ToString() + " Y:" + fy.ToString() + " Z:" + fz.ToString());
1729 if (fx != 0 || fy != 0 || fz != 0)
1730 {
1731 //m_taintdisable = true;
1732 //base.RaiseOutOfBounds(Position);
1733 //d.BodySetLinearVel(Body, fx, fy, 0f);
1734 if (!d.BodyIsEnabled(Body))
1735 {
1736 d.BodySetLinearVel(Body, 0f, 0f, 0f);
1737 d.BodySetForce(Body, 0, 0, 0);
1738 enableBodySoft();
1739 }
1740
1741 // 35x10 = 350n times the mass per second applied maximum.
1742 float nmax = 35f * m_mass;
1743 float nmin = -35f * m_mass;
1744
1745
1746 if (fx > nmax)
1747 fx = nmax;
1748 if (fx < nmin)
1749 fx = nmin;
1750 if (fy > nmax)
1751 fy = nmax;
1752 if (fy < nmin)
1753 fy = nmin;
1754 d.BodyAddForce(Body, fx, fy, fz);
1755 }
1756 if (m_vehicle.Body == IntPtr.Zero && m_vehicle.Type != Vehicle.TYPE_NONE)
1757 m_vehicle.Enable(Body, _parent_scene);
1758
1759 m_vehicle.Step(timestep);
1760 } 1796 }
1761 else 1797 else
1762 { 1798 { // is not physical, or is not a body or is selected
1763 // _zeroPosition = d.BodyGetPosition(Body); 1799 // _zeroPosition = d.BodyGetPosition(Body);
1764 return; 1800 return;
1765 } 1801 }
1766 } 1802 }
@@ -1774,14 +1810,22 @@ namespace OpenSim.Region.Physics.OdePlugin
1774 myrot.Y = _orientation.Y; 1810 myrot.Y = _orientation.Y;
1775 myrot.Z = _orientation.Z; 1811 myrot.Z = _orientation.Z;
1776 myrot.W = _orientation.W; 1812 myrot.W = _orientation.W;
1777 d.GeomSetQuaternion(prim_geom, ref myrot); 1813 if (Body != IntPtr.Zero)
1778 if (m_isphysical && Body != IntPtr.Zero)
1779 { 1814 {
1815 // KF: If this is a root prim do BodySet
1780 d.BodySetQuaternion(Body, ref myrot); 1816 d.BodySetQuaternion(Body, ref myrot);
1781 if (!m_angularlock.IsIdentical(new PhysicsVector(1, 1, 1), 0)) 1817 if (m_isphysical)
1782 createAMotor(m_angularlock); 1818 {
1819 if (!m_angularlock.IsIdentical(new PhysicsVector(1, 1, 1), 0))
1820 createAMotor(m_angularlock);
1821 }
1822 }
1823 else
1824 {
1825 // daughter prim, do Geom set
1826 d.GeomSetQuaternion(prim_geom, ref myrot);
1783 } 1827 }
1784 1828
1785 resetCollisionAccounting(); 1829 resetCollisionAccounting();
1786 m_taintrot = _orientation; 1830 m_taintrot = _orientation;
1787 } 1831 }
@@ -1843,7 +1887,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1843 m_log.Error("[PHYSICS]: PrimGeom dead"); 1887 m_log.Error("[PHYSICS]: PrimGeom dead");
1844 } 1888 }
1845 } 1889 }
1846 1890//Console.WriteLine("changePhysicsStatus for " + m_primName );
1847 changeadd(2f); 1891 changeadd(2f);
1848 } 1892 }
1849 if (childPrim) 1893 if (childPrim)
@@ -1921,7 +1965,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1921 mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); 1965 mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
1922 1966
1923 //IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); 1967 //IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
1924 1968//Console.WriteLine("changesize 1");
1925 CreateGeom(m_targetSpace, mesh); 1969 CreateGeom(m_targetSpace, mesh);
1926 1970
1927 1971
@@ -1929,6 +1973,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1929 else 1973 else
1930 { 1974 {
1931 _mesh = null; 1975 _mesh = null;
1976//Console.WriteLine("changesize 2");
1932 CreateGeom(m_targetSpace, _mesh); 1977 CreateGeom(m_targetSpace, _mesh);
1933 } 1978 }
1934 1979
@@ -2035,6 +2080,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2035 else 2080 else
2036 { 2081 {
2037 _mesh = null; 2082 _mesh = null;
2083//Console.WriteLine("changeshape");
2038 CreateGeom(m_targetSpace, null); 2084 CreateGeom(m_targetSpace, null);
2039 } 2085 }
2040 2086
@@ -2376,7 +2422,9 @@ namespace OpenSim.Region.Physics.OdePlugin
2376 set 2422 set
2377 { 2423 {
2378 if (QuaternionIsFinite(value)) 2424 if (QuaternionIsFinite(value))
2425 {
2379 _orientation = value; 2426 _orientation = value;
2427 }
2380 else 2428 else
2381 m_log.Warn("[PHYSICS]: Got NaN quaternion Orientation from Scene in Object"); 2429 m_log.Warn("[PHYSICS]: Got NaN quaternion Orientation from Scene in Object");
2382 2430
@@ -2595,12 +2643,16 @@ namespace OpenSim.Region.Physics.OdePlugin
2595 //outofBounds = true; 2643 //outofBounds = true;
2596 } 2644 }
2597 2645
2646 float Adiff = 1.0f - Math.Abs(Quaternion.Dot(m_lastorientation, l_orientation));
2647//Console.WriteLine("Adiff " + m_primName + " = " + Adiff);
2598 if ((Math.Abs(m_lastposition.X - l_position.X) < 0.02) 2648 if ((Math.Abs(m_lastposition.X - l_position.X) < 0.02)
2599 && (Math.Abs(m_lastposition.Y - l_position.Y) < 0.02) 2649 && (Math.Abs(m_lastposition.Y - l_position.Y) < 0.02)
2600 && (Math.Abs(m_lastposition.Z - l_position.Z) < 0.02) 2650 && (Math.Abs(m_lastposition.Z - l_position.Z) < 0.02)
2601 && (1.0 - Math.Abs(Quaternion.Dot(m_lastorientation, l_orientation)) < 0.01)) 2651// && (1.0 - Math.Abs(Quaternion.Dot(m_lastorientation, l_orientation)) < 0.01))
2652 && (1.0 - Math.Abs(Quaternion.Dot(m_lastorientation, l_orientation)) < 0.0001)) // KF 0.01 is far to large
2602 { 2653 {
2603 _zeroFlag = true; 2654 _zeroFlag = true;
2655//Console.WriteLine("ZFT 2");
2604 m_throttleUpdates = false; 2656 m_throttleUpdates = false;
2605 } 2657 }
2606 else 2658 else