aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs69
1 files changed, 38 insertions, 31 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 988e03b..4193d22 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -160,16 +160,18 @@ public sealed class BSPrim : PhysicsActor
160 public void Destroy() 160 public void Destroy()
161 { 161 {
162 // m_log.DebugFormat("{0}: Destroy, id={1}", LogHeader, LocalID); 162 // m_log.DebugFormat("{0}: Destroy, id={1}", LogHeader, LocalID);
163 // DetailLog("{0},Destroy", LocalID); 163 // DetailLog("{0},BSPrim.Destroy", LocalID);
164 164
165 // Undo any vehicle properties 165 // Undo any vehicle properties
166 _vehicle.ProcessTypeChange(Vehicle.TYPE_NONE); 166 _vehicle.ProcessTypeChange(Vehicle.TYPE_NONE);
167 _scene.RemoveVehiclePrim(this); // just to make sure 167 _scene.RemoveVehiclePrim(this); // just to make sure
168 168
169 // Undo any links between me and any other object
170 _linkset = _linkset.RemoveMeFromLinkset(this);
171
169 _scene.TaintedObject("BSPrim.destroy", delegate() 172 _scene.TaintedObject("BSPrim.destroy", delegate()
170 { 173 {
171 // Undo any links between me and any other object 174 DetailLog("{0},BSPrim.Destroy,taint,", LocalID);
172 _linkset = _linkset.RemoveMeFromLinkset(this);
173 175
174 // everything in the C# world will get garbage collected. Tell the C++ world to free stuff. 176 // everything in the C# world will get garbage collected. Tell the C++ world to free stuff.
175 BulletSimAPI.DestroyObject(_scene.WorldID, LocalID); 177 BulletSimAPI.DestroyObject(_scene.WorldID, LocalID);
@@ -187,7 +189,7 @@ public sealed class BSPrim : PhysicsActor
187 { 189 {
188 _mass = CalculateMass(); // changing size changes the mass 190 _mass = CalculateMass(); // changing size changes the mass
189 BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, (IsPhysical ? _mass : 0f), IsPhysical); 191 BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, (IsPhysical ? _mass : 0f), IsPhysical);
190 // DetailLog("{0}: setSize: size={1}, mass={2}, physical={3}", LocalID, _size, _mass, IsPhysical); 192 // DetailLog("{0}: BSPrim.setSize: size={1}, mass={2}, physical={3}", LocalID, _size, _mass, IsPhysical);
191 RecreateGeomAndObject(); 193 RecreateGeomAndObject();
192 }); 194 });
193 } 195 }
@@ -227,7 +229,7 @@ public sealed class BSPrim : PhysicsActor
227 if (parent != null) 229 if (parent != null)
228 { 230 {
229 DebugLog("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, parent.LocalID); 231 DebugLog("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, parent.LocalID);
230 DetailLog("{0},link,parent={1}", LocalID, parent.LocalID); 232 DetailLog("{0},BSPrim.link,parent={1}", LocalID, parent.LocalID);
231 _linkset = _linkset.AddMeToLinkset(this, parent); 233 _linkset = _linkset.AddMeToLinkset(this, parent);
232 } 234 }
233 return; 235 return;
@@ -239,9 +241,14 @@ public sealed class BSPrim : PhysicsActor
239 // Race condition here: if link() and delink() in same simulation tick, the delink will not happen 241 // Race condition here: if link() and delink() in same simulation tick, the delink will not happen
240 DebugLog("{0}: delink {1}/{2}. Parent={3}", LogHeader, _avName, _localID, 242 DebugLog("{0}: delink {1}/{2}. Parent={3}", LogHeader, _avName, _localID,
241 _linkset.Root._avName+"/"+_linkset.Root.LocalID.ToString()); 243 _linkset.Root._avName+"/"+_linkset.Root.LocalID.ToString());
242 DetailLog("{0},delink,parent={1}", LocalID, _linkset.Root.LocalID.ToString());
243 244
244 _linkset.RemoveMeFromLinkset(this); 245 BSPrim parentBefore = _linkset.Root;
246 int childrenBefore = _linkset.NumberOfChildren;
247
248 _linkset = _linkset.RemoveMeFromLinkset(this);
249
250 DetailLog("{0},BSPrim.delink,parentBefore={1},childrenBefore={2},parentAfter={3},childrenAfter={4}, ",
251 LocalID, parentBefore.LocalID, childrenBefore, _linkset.Root.LocalID, _linkset.NumberOfChildren);
245 return; 252 return;
246 } 253 }
247 254
@@ -264,7 +271,7 @@ public sealed class BSPrim : PhysicsActor
264 271
265 public override void LockAngularMotion(OMV.Vector3 axis) 272 public override void LockAngularMotion(OMV.Vector3 axis)
266 { 273 {
267 DetailLog("{0},LockAngularMotion,call,axis={1}", LocalID, axis); 274 DetailLog("{0},BSPrim.LockAngularMotion,call,axis={1}", LocalID, axis);
268 return; 275 return;
269 } 276 }
270 277
@@ -283,7 +290,7 @@ public sealed class BSPrim : PhysicsActor
283 // TODO: what does it mean to set the position of a child prim?? Rebuild the constraint? 290 // TODO: what does it mean to set the position of a child prim?? Rebuild the constraint?
284 _scene.TaintedObject("BSPrim.setPosition", delegate() 291 _scene.TaintedObject("BSPrim.setPosition", delegate()
285 { 292 {
286 DetailLog("{0},SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); 293 DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
287 BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); 294 BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
288 }); 295 });
289 } 296 }
@@ -320,7 +327,7 @@ public sealed class BSPrim : PhysicsActor
320 _force = value; 327 _force = value;
321 _scene.TaintedObject("BSPrim.setForce", delegate() 328 _scene.TaintedObject("BSPrim.setForce", delegate()
322 { 329 {
323 DetailLog("{0},setForce,taint,force={1}", LocalID, _force); 330 DetailLog("{0},BSPrim.setForce,taint,force={1}", LocalID, _force);
324 // BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force); 331 // BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force);
325 BulletSimAPI.SetObjectForce2(Body.Ptr, _force); 332 BulletSimAPI.SetObjectForce2(Body.Ptr, _force);
326 }); 333 });
@@ -335,7 +342,7 @@ public sealed class BSPrim : PhysicsActor
335 Vehicle type = (Vehicle)value; 342 Vehicle type = (Vehicle)value;
336 _scene.TaintedObject("BSPrim.setVehicleType", delegate() 343 _scene.TaintedObject("BSPrim.setVehicleType", delegate()
337 { 344 {
338 DetailLog("{0},SetVehicleType,taint,type={1}", LocalID, type); 345 DetailLog("{0},BSPrim.SetVehicleType,taint,type={1}", LocalID, type);
339 _vehicle.ProcessTypeChange(type); 346 _vehicle.ProcessTypeChange(type);
340 if (type == Vehicle.TYPE_NONE) 347 if (type == Vehicle.TYPE_NONE)
341 { 348 {
@@ -405,7 +412,7 @@ public sealed class BSPrim : PhysicsActor
405 _velocity = value; 412 _velocity = value;
406 _scene.TaintedObject("BSPrim.setVelocity", delegate() 413 _scene.TaintedObject("BSPrim.setVelocity", delegate()
407 { 414 {
408 DetailLog("{0},SetVelocity,taint,vel={1}", LocalID, _velocity); 415 DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, _velocity);
409 BulletSimAPI.SetObjectVelocity(_scene.WorldID, LocalID, _velocity); 416 BulletSimAPI.SetObjectVelocity(_scene.WorldID, LocalID, _velocity);
410 }); 417 });
411 } 418 }
@@ -413,7 +420,7 @@ public sealed class BSPrim : PhysicsActor
413 public override OMV.Vector3 Torque { 420 public override OMV.Vector3 Torque {
414 get { return _torque; } 421 get { return _torque; }
415 set { _torque = value; 422 set { _torque = value;
416 DetailLog("{0},SetTorque,call,torque={1}", LocalID, _torque); 423 DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque);
417 } 424 }
418 } 425 }
419 public override float CollisionScore { 426 public override float CollisionScore {
@@ -440,7 +447,7 @@ public sealed class BSPrim : PhysicsActor
440 _scene.TaintedObject("BSPrim.setOrientation", delegate() 447 _scene.TaintedObject("BSPrim.setOrientation", delegate()
441 { 448 {
442 // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); 449 // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID);
443 DetailLog("{0},setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); 450 DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation);
444 BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); 451 BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
445 }); 452 });
446 } 453 }
@@ -486,7 +493,7 @@ public sealed class BSPrim : PhysicsActor
486 // Bullet wants static objects to have a mass of zero 493 // Bullet wants static objects to have a mass of zero
487 float mass = IsStatic ? 0f : _mass; 494 float mass = IsStatic ? 0f : _mass;
488 495
489 DetailLog("{0},SetObjectDynamic,taint,static={1},solid={2},mass={3}", LocalID, IsStatic, IsSolid, mass); 496 DetailLog("{0},BSPrim.SetObjectDynamic,taint,static={1},solid={2},mass={3}", LocalID, IsStatic, IsSolid, mass);
490 BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), mass); 497 BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), mass);
491 } 498 }
492 499
@@ -544,7 +551,7 @@ public sealed class BSPrim : PhysicsActor
544 // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); 551 // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity);
545 _scene.TaintedObject("BSPrim.setRotationalVelocity", delegate() 552 _scene.TaintedObject("BSPrim.setRotationalVelocity", delegate()
546 { 553 {
547 DetailLog("{0},SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); 554 DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity);
548 BulletSimAPI.SetObjectAngularVelocity(_scene.WorldID, LocalID, _rotationalVelocity); 555 BulletSimAPI.SetObjectAngularVelocity(_scene.WorldID, LocalID, _rotationalVelocity);
549 }); 556 });
550 } 557 }
@@ -561,7 +568,7 @@ public sealed class BSPrim : PhysicsActor
561 _buoyancy = value; 568 _buoyancy = value;
562 _scene.TaintedObject("BSPrim.setBuoyancy", delegate() 569 _scene.TaintedObject("BSPrim.setBuoyancy", delegate()
563 { 570 {
564 DetailLog("{0},SetBuoyancy,taint,buoy={1}", LocalID, _buoyancy); 571 DetailLog("{0},BSPrim.SetBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
565 BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, _localID, _buoyancy); 572 BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, _localID, _buoyancy);
566 }); 573 });
567 } 574 }
@@ -624,17 +631,17 @@ public sealed class BSPrim : PhysicsActor
624 } 631 }
625 m_accumulatedForces.Clear(); 632 m_accumulatedForces.Clear();
626 } 633 }
627 DetailLog("{0},AddObjectForce,taint,force={1}", LocalID, _force); 634 DetailLog("{0},BSPrim.AddObjectForce,taint,force={1}", LocalID, _force);
628 BulletSimAPI.AddObjectForce2(Body.Ptr, fSum); 635 BulletSimAPI.AddObjectForce2(Body.Ptr, fSum);
629 }); 636 });
630 } 637 }
631 638
632 public override void AddAngularForce(OMV.Vector3 force, bool pushforce) { 639 public override void AddAngularForce(OMV.Vector3 force, bool pushforce) {
633 DetailLog("{0},AddAngularForce,call,angForce={1},push={2}", LocalID, force, pushforce); 640 DetailLog("{0},BSPrim.AddAngularForce,call,angForce={1},push={2}", LocalID, force, pushforce);
634 // m_log.DebugFormat("{0}: AddAngularForce. f={1}, push={2}", LogHeader, force, pushforce); 641 // m_log.DebugFormat("{0}: AddAngularForce. f={1}, push={2}", LogHeader, force, pushforce);
635 } 642 }
636 public override void SetMomentum(OMV.Vector3 momentum) { 643 public override void SetMomentum(OMV.Vector3 momentum) {
637 DetailLog("{0},SetMomentum,call,mom={1}", LocalID, momentum); 644 DetailLog("{0},BSPrim.SetMomentum,call,mom={1}", LocalID, momentum);
638 } 645 }
639 public override void SubscribeEvents(int ms) { 646 public override void SubscribeEvents(int ms) {
640 _subscribedEventsMs = ms; 647 _subscribedEventsMs = ms;
@@ -978,7 +985,7 @@ public sealed class BSPrim : PhysicsActor
978 // m_log.DebugFormat("{0}: CreateGeom: Defaulting to sphere of size {1}", LogHeader, _size); 985 // m_log.DebugFormat("{0}: CreateGeom: Defaulting to sphere of size {1}", LogHeader, _size);
979 if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_SPHERE)) 986 if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_SPHERE))
980 { 987 {
981 DetailLog("{0},CreateGeom,sphere (force={1}", LocalID, forceRebuild); 988 DetailLog("{0},BSPrim.CreateGeom,sphere (force={1}", LocalID, forceRebuild);
982 _shapeType = ShapeData.PhysicsShapeType.SHAPE_SPHERE; 989 _shapeType = ShapeData.PhysicsShapeType.SHAPE_SPHERE;
983 // Bullet native objects are scaled by the Bullet engine so pass the size in 990 // Bullet native objects are scaled by the Bullet engine so pass the size in
984 _scale = _size; 991 _scale = _size;
@@ -992,7 +999,7 @@ public sealed class BSPrim : PhysicsActor
992 // m_log.DebugFormat("{0}: CreateGeom: Defaulting to box. lid={1}, type={2}, size={3}", LogHeader, LocalID, _shapeType, _size); 999 // m_log.DebugFormat("{0}: CreateGeom: Defaulting to box. lid={1}, type={2}, size={3}", LogHeader, LocalID, _shapeType, _size);
993 if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_BOX)) 1000 if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_BOX))
994 { 1001 {
995 DetailLog("{0},CreateGeom,box (force={1})", LocalID, forceRebuild); 1002 DetailLog("{0},BSPrim.CreateGeom,box (force={1})", LocalID, forceRebuild);
996 _shapeType = ShapeData.PhysicsShapeType.SHAPE_BOX; 1003 _shapeType = ShapeData.PhysicsShapeType.SHAPE_BOX;
997 _scale = _size; 1004 _scale = _size;
998 // TODO: do we need to check for and destroy a mesh or hull that might have been left from before? 1005 // TODO: do we need to check for and destroy a mesh or hull that might have been left from before?
@@ -1035,12 +1042,12 @@ public sealed class BSPrim : PhysicsActor
1035 // if this new shape is the same as last time, don't recreate the mesh 1042 // if this new shape is the same as last time, don't recreate the mesh
1036 if (_meshKey == newMeshKey) return; 1043 if (_meshKey == newMeshKey) return;
1037 1044
1038 DetailLog("{0},CreateGeomMesh,create,key={1}", LocalID, newMeshKey); 1045 DetailLog("{0},BSPrim.CreateGeomMesh,create,key={1}", LocalID, newMeshKey);
1039 // Since we're recreating new, get rid of any previously generated shape 1046 // Since we're recreating new, get rid of any previously generated shape
1040 if (_meshKey != 0) 1047 if (_meshKey != 0)
1041 { 1048 {
1042 // m_log.DebugFormat("{0}: CreateGeom: deleting old mesh. lID={1}, Key={2}", LogHeader, _localID, _meshKey); 1049 // m_log.DebugFormat("{0}: CreateGeom: deleting old mesh. lID={1}, Key={2}", LogHeader, _localID, _meshKey);
1043 DetailLog("{0},CreateGeomMesh,deleteOld,key={1}", LocalID, _meshKey); 1050 DetailLog("{0},BSPrim.CreateGeomMesh,deleteOld,key={1}", LocalID, _meshKey);
1044 BulletSimAPI.DestroyMesh(_scene.WorldID, _meshKey); 1051 BulletSimAPI.DestroyMesh(_scene.WorldID, _meshKey);
1045 _mesh = null; 1052 _mesh = null;
1046 _meshKey = 0; 1053 _meshKey = 0;
@@ -1070,7 +1077,7 @@ public sealed class BSPrim : PhysicsActor
1070 _shapeType = ShapeData.PhysicsShapeType.SHAPE_MESH; 1077 _shapeType = ShapeData.PhysicsShapeType.SHAPE_MESH;
1071 // meshes are already scaled by the meshmerizer 1078 // meshes are already scaled by the meshmerizer
1072 _scale = new OMV.Vector3(1f, 1f, 1f); 1079 _scale = new OMV.Vector3(1f, 1f, 1f);
1073 DetailLog("{0},CreateGeomMesh,done", LocalID); 1080 DetailLog("{0},BSPrim.CreateGeomMesh,done", LocalID);
1074 return; 1081 return;
1075 } 1082 }
1076 1083
@@ -1084,17 +1091,17 @@ public sealed class BSPrim : PhysicsActor
1084 // if the hull hasn't changed, don't rebuild it 1091 // if the hull hasn't changed, don't rebuild it
1085 if (newHullKey == _hullKey) return; 1092 if (newHullKey == _hullKey) return;
1086 1093
1087 DetailLog("{0},CreateGeomHull,create,key={1}", LocalID, _meshKey); 1094 DetailLog("{0},BSPrim.CreateGeomHull,create,key={1}", LocalID, _meshKey);
1088 1095
1089 // Since we're recreating new, get rid of any previously generated shape 1096 // Since we're recreating new, get rid of any previously generated shape
1090 if (_hullKey != 0) 1097 if (_hullKey != 0)
1091 { 1098 {
1092 // m_log.DebugFormat("{0}: CreateGeom: deleting old hull. Key={1}", LogHeader, _hullKey); 1099 // m_log.DebugFormat("{0}: CreateGeom: deleting old hull. Key={1}", LogHeader, _hullKey);
1093 DetailLog("{0},CreateGeomHull,deleteOldHull,key={1}", LocalID, _meshKey); 1100 DetailLog("{0},BSPrim.CreateGeomHull,deleteOldHull,key={1}", LocalID, _meshKey);
1094 BulletSimAPI.DestroyHull(_scene.WorldID, _hullKey); 1101 BulletSimAPI.DestroyHull(_scene.WorldID, _hullKey);
1095 _hullKey = 0; 1102 _hullKey = 0;
1096 _hulls.Clear(); 1103 _hulls.Clear();
1097 DetailLog("{0},CreateGeomHull,deleteOldMesh,key={1}", LocalID, _meshKey); 1104 DetailLog("{0},BSPrim.CreateGeomHull,deleteOldMesh,key={1}", LocalID, _meshKey);
1098 BulletSimAPI.DestroyMesh(_scene.WorldID, _meshKey); 1105 BulletSimAPI.DestroyMesh(_scene.WorldID, _meshKey);
1099 _mesh = null; // the mesh cannot match either 1106 _mesh = null; // the mesh cannot match either
1100 _meshKey = 0; 1107 _meshKey = 0;
@@ -1191,7 +1198,7 @@ public sealed class BSPrim : PhysicsActor
1191 _shapeType = ShapeData.PhysicsShapeType.SHAPE_HULL; 1198 _shapeType = ShapeData.PhysicsShapeType.SHAPE_HULL;
1192 // meshes are already scaled by the meshmerizer 1199 // meshes are already scaled by the meshmerizer
1193 _scale = new OMV.Vector3(1f, 1f, 1f); 1200 _scale = new OMV.Vector3(1f, 1f, 1f);
1194 DetailLog("{0},CreateGeomHull,done", LocalID); 1201 DetailLog("{0},BSPrim.CreateGeomHull,done", LocalID);
1195 return; 1202 return;
1196 } 1203 }
1197 1204
@@ -1329,7 +1336,7 @@ public sealed class BSPrim : PhysicsActor
1329 1336
1330 // m_log.DebugFormat("{0}: RequestTerseUpdate. id={1}, ch={2}, pos={3}, rot={4}, vel={5}, acc={6}, rvel={7}", 1337 // m_log.DebugFormat("{0}: RequestTerseUpdate. id={1}, ch={2}, pos={3}, rot={4}, vel={5}, acc={6}, rvel={7}",
1331 // LogHeader, LocalID, changed, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); 1338 // LogHeader, LocalID, changed, _position, _orientation, _velocity, _acceleration, _rotationalVelocity);
1332 DetailLog("{0},UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", 1339 DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
1333 LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); 1340 LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity);
1334 1341
1335 base.RequestPhysicsterseUpdate(); 1342 base.RequestPhysicsterseUpdate();
@@ -1337,7 +1344,7 @@ public sealed class BSPrim : PhysicsActor
1337 else 1344 else
1338 { 1345 {
1339 // For debugging, we also report the movement of children 1346 // For debugging, we also report the movement of children
1340 DetailLog("{0},UpdateProperties,child,pos={1},orient={2},vel={3},accel={4},rotVel={5}", 1347 DetailLog("{0},BSPrim.BSPrim.UpdateProperties,child,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
1341 LocalID, entprop.Position, entprop.Rotation, entprop.Velocity, 1348 LocalID, entprop.Position, entprop.Rotation, entprop.Velocity,
1342 entprop.Acceleration, entprop.RotationalVelocity); 1349 entprop.Acceleration, entprop.RotationalVelocity);
1343 } 1350 }