BulletSim: add an identifier to the TaintObject call so exceptions that happen when the taint is invoked can be debugged
parent
38e79b80a8
commit
320982cae3
|
@ -122,7 +122,7 @@ public class BSCharacter : PhysicsActor
|
||||||
shapeData.Restitution = _scene.Params.avatarRestitution;
|
shapeData.Restitution = _scene.Params.avatarRestitution;
|
||||||
|
|
||||||
// do actual create at taint time
|
// do actual create at taint time
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSCharacter.create", delegate()
|
||||||
{
|
{
|
||||||
BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData);
|
BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData);
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ public class BSCharacter : PhysicsActor
|
||||||
public void Destroy()
|
public void Destroy()
|
||||||
{
|
{
|
||||||
// DetailLog("{0},Destroy", LocalID);
|
// DetailLog("{0},Destroy", LocalID);
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSCharacter.destroy", delegate()
|
||||||
{
|
{
|
||||||
BulletSimAPI.DestroyObject(_scene.WorldID, _localID);
|
BulletSimAPI.DestroyObject(_scene.WorldID, _localID);
|
||||||
});
|
});
|
||||||
|
@ -169,7 +169,7 @@ public class BSCharacter : PhysicsActor
|
||||||
|
|
||||||
ComputeAvatarVolumeAndMass();
|
ComputeAvatarVolumeAndMass();
|
||||||
|
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSCharacter.setSize", delegate()
|
||||||
{
|
{
|
||||||
BulletSimAPI.SetObjectScaleMass(_scene.WorldID, LocalID, _scale, _mass, true);
|
BulletSimAPI.SetObjectScaleMass(_scene.WorldID, LocalID, _scale, _mass, true);
|
||||||
});
|
});
|
||||||
|
@ -207,7 +207,7 @@ public class BSCharacter : PhysicsActor
|
||||||
_position = value;
|
_position = value;
|
||||||
PositionSanityCheck();
|
PositionSanityCheck();
|
||||||
|
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSCharacter.setPosition", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
DetailLog("{0},SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
||||||
BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
|
BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
|
||||||
|
@ -246,7 +246,7 @@ public class BSCharacter : PhysicsActor
|
||||||
set {
|
set {
|
||||||
_force = value;
|
_force = value;
|
||||||
// m_log.DebugFormat("{0}: Force = {1}", LogHeader, _force);
|
// m_log.DebugFormat("{0}: Force = {1}", LogHeader, _force);
|
||||||
Scene.TaintedObject(delegate()
|
Scene.TaintedObject("BSCharacter.SetForce", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},setForce,taint,force={1}", LocalID, _force);
|
DetailLog("{0},setForce,taint,force={1}", LocalID, _force);
|
||||||
BulletSimAPI.SetObjectForce(Scene.WorldID, LocalID, _force);
|
BulletSimAPI.SetObjectForce(Scene.WorldID, LocalID, _force);
|
||||||
|
@ -273,7 +273,7 @@ public class BSCharacter : PhysicsActor
|
||||||
set {
|
set {
|
||||||
_velocity = value;
|
_velocity = value;
|
||||||
// m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, _velocity);
|
// m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, _velocity);
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSCharacter.setVelocity", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},setVelocity,taint,vel={1}", LocalID, _velocity);
|
DetailLog("{0},setVelocity,taint,vel={1}", LocalID, _velocity);
|
||||||
BulletSimAPI.SetObjectVelocity(_scene.WorldID, _localID, _velocity);
|
BulletSimAPI.SetObjectVelocity(_scene.WorldID, _localID, _velocity);
|
||||||
|
@ -299,7 +299,7 @@ public class BSCharacter : PhysicsActor
|
||||||
set {
|
set {
|
||||||
_orientation = value;
|
_orientation = value;
|
||||||
// m_log.DebugFormat("{0}: set orientation to {1}", LogHeader, _orientation);
|
// m_log.DebugFormat("{0}: set orientation to {1}", LogHeader, _orientation);
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSCharacter.setOrientation", delegate()
|
||||||
{
|
{
|
||||||
// _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID);
|
// _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID);
|
||||||
BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
|
BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
|
||||||
|
@ -366,7 +366,7 @@ public class BSCharacter : PhysicsActor
|
||||||
public override float Buoyancy {
|
public override float Buoyancy {
|
||||||
get { return _buoyancy; }
|
get { return _buoyancy; }
|
||||||
set { _buoyancy = value;
|
set { _buoyancy = value;
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSCharacter.setBuoyancy", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},setBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
|
DetailLog("{0},setBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
|
||||||
BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _buoyancy);
|
BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _buoyancy);
|
||||||
|
@ -413,7 +413,7 @@ public class BSCharacter : PhysicsActor
|
||||||
_force.Y += force.Y;
|
_force.Y += force.Y;
|
||||||
_force.Z += force.Z;
|
_force.Z += force.Z;
|
||||||
// m_log.DebugFormat("{0}: AddForce. adding={1}, newForce={2}", LogHeader, force, _force);
|
// m_log.DebugFormat("{0}: AddForce. adding={1}, newForce={2}", LogHeader, force, _force);
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSCharacter.AddForce", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},setAddForce,taint,addedForce={1}", LocalID, _force);
|
DetailLog("{0},setAddForce,taint,addedForce={1}", LocalID, _force);
|
||||||
BulletSimAPI.AddObjectForce2(Body.Ptr, _force);
|
BulletSimAPI.AddObjectForce2(Body.Ptr, _force);
|
||||||
|
@ -439,7 +439,7 @@ public class BSCharacter : PhysicsActor
|
||||||
// make sure first collision happens
|
// make sure first collision happens
|
||||||
_nextCollisionOkTime = Util.EnvironmentTickCount() - _subscribedEventsMs;
|
_nextCollisionOkTime = Util.EnvironmentTickCount() - _subscribedEventsMs;
|
||||||
|
|
||||||
Scene.TaintedObject(delegate()
|
Scene.TaintedObject("BSCharacter.SubscribeEvents", delegate()
|
||||||
{
|
{
|
||||||
BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
||||||
});
|
});
|
||||||
|
@ -449,7 +449,7 @@ public class BSCharacter : PhysicsActor
|
||||||
public override void UnSubscribeEvents() {
|
public override void UnSubscribeEvents() {
|
||||||
_subscribedEventsMs = 0;
|
_subscribedEventsMs = 0;
|
||||||
// Avatars get all their collision events
|
// Avatars get all their collision events
|
||||||
// Scene.TaintedObject(delegate()
|
// Scene.TaintedObject("BSCharacter.UnSubscribeEvents", delegate()
|
||||||
// {
|
// {
|
||||||
// BulletSimAPI.RemoveFromCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
// BulletSimAPI.RemoveFromCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
||||||
// });
|
// });
|
||||||
|
|
|
@ -236,7 +236,7 @@ public class BSLinkset
|
||||||
{
|
{
|
||||||
m_children.Add(child);
|
m_children.Add(child);
|
||||||
|
|
||||||
m_scene.TaintedObject(delegate()
|
m_scene.TaintedObject("AddChildToLinkset", delegate()
|
||||||
{
|
{
|
||||||
DebugLog("{0}: AddChildToLinkset: adding child {1} to {2}", LogHeader, child.LocalID, m_linksetRoot.LocalID);
|
DebugLog("{0}: AddChildToLinkset: adding child {1} to {2}", LogHeader, child.LocalID, m_linksetRoot.LocalID);
|
||||||
DetailLog("{0},AddChildToLinkset,taint,child={1}", m_linksetRoot.LocalID, pchild.LocalID);
|
DetailLog("{0},AddChildToLinkset,taint,child={1}", m_linksetRoot.LocalID, pchild.LocalID);
|
||||||
|
@ -265,7 +265,7 @@ public class BSLinkset
|
||||||
|
|
||||||
if (m_children.Remove(child))
|
if (m_children.Remove(child))
|
||||||
{
|
{
|
||||||
m_scene.TaintedObject(delegate()
|
m_scene.TaintedObject("RemoveChildFromLinkset", delegate()
|
||||||
{
|
{
|
||||||
DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID);
|
DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID);
|
||||||
DetailLog("{0},RemoveChildFromLinkset,taint,child={1}", m_linksetRoot.LocalID, pchild.LocalID);
|
DetailLog("{0},RemoveChildFromLinkset,taint,child={1}", m_linksetRoot.LocalID, pchild.LocalID);
|
||||||
|
|
|
@ -145,7 +145,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
_vehicle = new BSDynamics(this); // add vehicleness
|
_vehicle = new BSDynamics(this); // add vehicleness
|
||||||
_mass = CalculateMass();
|
_mass = CalculateMass();
|
||||||
// do the actual object creation at taint time
|
// do the actual object creation at taint time
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSPrim.create", delegate()
|
||||||
{
|
{
|
||||||
RecreateGeomAndObject();
|
RecreateGeomAndObject();
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
_vehicle.ProcessTypeChange(Vehicle.TYPE_NONE);
|
_vehicle.ProcessTypeChange(Vehicle.TYPE_NONE);
|
||||||
_scene.RemoveVehiclePrim(this); // just to make sure
|
_scene.RemoveVehiclePrim(this); // just to make sure
|
||||||
|
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSPrim.destroy", delegate()
|
||||||
{
|
{
|
||||||
// Undo any links between me and any other object
|
// Undo any links between me and any other object
|
||||||
_linkset = _linkset.RemoveMeFromLinkset(this);
|
_linkset = _linkset.RemoveMeFromLinkset(this);
|
||||||
|
@ -183,7 +183,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
get { return _size; }
|
get { return _size; }
|
||||||
set {
|
set {
|
||||||
_size = value;
|
_size = value;
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSPrim.setSize", delegate()
|
||||||
{
|
{
|
||||||
_mass = CalculateMass(); // changing size changes the mass
|
_mass = CalculateMass(); // changing size changes the mass
|
||||||
BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, (IsPhysical ? _mass : 0f), IsPhysical);
|
BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, (IsPhysical ? _mass : 0f), IsPhysical);
|
||||||
|
@ -195,7 +195,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
public override PrimitiveBaseShape Shape {
|
public override PrimitiveBaseShape Shape {
|
||||||
set {
|
set {
|
||||||
_pbs = value;
|
_pbs = value;
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSPrim.setShape", delegate()
|
||||||
{
|
{
|
||||||
_mass = CalculateMass(); // changing the shape changes the mass
|
_mass = CalculateMass(); // changing the shape changes the mass
|
||||||
RecreateGeomAndObject();
|
RecreateGeomAndObject();
|
||||||
|
@ -213,7 +213,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
public override bool Selected {
|
public override bool Selected {
|
||||||
set {
|
set {
|
||||||
_isSelected = value;
|
_isSelected = value;
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSPrim.setSelected", delegate()
|
||||||
{
|
{
|
||||||
SetObjectDynamic();
|
SetObjectDynamic();
|
||||||
});
|
});
|
||||||
|
@ -281,7 +281,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
set {
|
set {
|
||||||
_position = value;
|
_position = value;
|
||||||
// TODO: what does it mean to set the position of a child prim?? Rebuild the constraint?
|
// TODO: what does it mean to set the position of a child prim?? Rebuild the constraint?
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSPrim.setPosition", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
DetailLog("{0},SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
||||||
BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
|
BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
|
||||||
|
@ -318,7 +318,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
get { return _force; }
|
get { return _force; }
|
||||||
set {
|
set {
|
||||||
_force = value;
|
_force = value;
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSPrim.setForce", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},setForce,taint,force={1}", LocalID, _force);
|
DetailLog("{0},setForce,taint,force={1}", LocalID, _force);
|
||||||
// BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force);
|
// BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force);
|
||||||
|
@ -333,7 +333,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
Vehicle type = (Vehicle)value;
|
Vehicle type = (Vehicle)value;
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSPrim.setVehicleType", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},SetVehicleType,taint,type={1}", LocalID, type);
|
DetailLog("{0},SetVehicleType,taint,type={1}", LocalID, type);
|
||||||
_vehicle.ProcessTypeChange(type);
|
_vehicle.ProcessTypeChange(type);
|
||||||
|
@ -343,12 +343,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_scene.TaintedObject(delegate()
|
|
||||||
{
|
|
||||||
// Tell the physics engine to clear state
|
|
||||||
BulletSimAPI.ClearForces2(this.Body.Ptr);
|
BulletSimAPI.ClearForces2(this.Body.Ptr);
|
||||||
});
|
|
||||||
|
|
||||||
// make it so the scene will call us each tick to do vehicle things
|
// make it so the scene will call us each tick to do vehicle things
|
||||||
_scene.AddVehiclePrim(this);
|
_scene.AddVehiclePrim(this);
|
||||||
}
|
}
|
||||||
|
@ -358,28 +353,28 @@ public sealed class BSPrim : PhysicsActor
|
||||||
}
|
}
|
||||||
public override void VehicleFloatParam(int param, float value)
|
public override void VehicleFloatParam(int param, float value)
|
||||||
{
|
{
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSPrim.VehicleFloatParam", delegate()
|
||||||
{
|
{
|
||||||
_vehicle.ProcessFloatVehicleParam((Vehicle)param, value, _scene.LastSimulatedTimestep);
|
_vehicle.ProcessFloatVehicleParam((Vehicle)param, value, _scene.LastSimulatedTimestep);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public override void VehicleVectorParam(int param, OMV.Vector3 value)
|
public override void VehicleVectorParam(int param, OMV.Vector3 value)
|
||||||
{
|
{
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSPrim.VehicleVectorParam", delegate()
|
||||||
{
|
{
|
||||||
_vehicle.ProcessVectorVehicleParam((Vehicle)param, value, _scene.LastSimulatedTimestep);
|
_vehicle.ProcessVectorVehicleParam((Vehicle)param, value, _scene.LastSimulatedTimestep);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public override void VehicleRotationParam(int param, OMV.Quaternion rotation)
|
public override void VehicleRotationParam(int param, OMV.Quaternion rotation)
|
||||||
{
|
{
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSPrim.VehicleRotationParam", delegate()
|
||||||
{
|
{
|
||||||
_vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation);
|
_vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public override void VehicleFlags(int param, bool remove)
|
public override void VehicleFlags(int param, bool remove)
|
||||||
{
|
{
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSPrim.VehicleFlags", delegate()
|
||||||
{
|
{
|
||||||
_vehicle.ProcessVehicleFlags(param, remove);
|
_vehicle.ProcessVehicleFlags(param, remove);
|
||||||
});
|
});
|
||||||
|
@ -397,7 +392,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
public override void SetVolumeDetect(int param) {
|
public override void SetVolumeDetect(int param) {
|
||||||
bool newValue = (param != 0);
|
bool newValue = (param != 0);
|
||||||
_isVolumeDetect = newValue;
|
_isVolumeDetect = newValue;
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSPrim.SetVolumeDetect", delegate()
|
||||||
{
|
{
|
||||||
SetObjectDynamic();
|
SetObjectDynamic();
|
||||||
});
|
});
|
||||||
|
@ -408,7 +403,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
get { return _velocity; }
|
get { return _velocity; }
|
||||||
set {
|
set {
|
||||||
_velocity = value;
|
_velocity = value;
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSPrim.setVelocity", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},SetVelocity,taint,vel={1}", LocalID, _velocity);
|
DetailLog("{0},SetVelocity,taint,vel={1}", LocalID, _velocity);
|
||||||
BulletSimAPI.SetObjectVelocity(_scene.WorldID, LocalID, _velocity);
|
BulletSimAPI.SetObjectVelocity(_scene.WorldID, LocalID, _velocity);
|
||||||
|
@ -442,7 +437,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
set {
|
set {
|
||||||
_orientation = value;
|
_orientation = value;
|
||||||
// TODO: what does it mean if a child in a linkset changes its orientation? Rebuild the constraint?
|
// TODO: what does it mean if a child in a linkset changes its orientation? Rebuild the constraint?
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSPrim.setOrientation", delegate()
|
||||||
{
|
{
|
||||||
// _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID);
|
// _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID);
|
||||||
DetailLog("{0},setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
DetailLog("{0},setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
||||||
|
@ -459,7 +454,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
get { return _isPhysical; }
|
get { return _isPhysical; }
|
||||||
set {
|
set {
|
||||||
_isPhysical = value;
|
_isPhysical = value;
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSPrim.setIsPhysical", delegate()
|
||||||
{
|
{
|
||||||
SetObjectDynamic();
|
SetObjectDynamic();
|
||||||
});
|
});
|
||||||
|
@ -547,7 +542,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
set {
|
set {
|
||||||
_rotationalVelocity = value;
|
_rotationalVelocity = value;
|
||||||
// m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity);
|
// m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity);
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSPrim.setRotationalVelocity", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity);
|
DetailLog("{0},SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity);
|
||||||
BulletSimAPI.SetObjectAngularVelocity(_scene.WorldID, LocalID, _rotationalVelocity);
|
BulletSimAPI.SetObjectAngularVelocity(_scene.WorldID, LocalID, _rotationalVelocity);
|
||||||
|
@ -564,7 +559,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
get { return _buoyancy; }
|
get { return _buoyancy; }
|
||||||
set {
|
set {
|
||||||
_buoyancy = value;
|
_buoyancy = value;
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSPrim.setBuoyancy", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},SetBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
|
DetailLog("{0},SetBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
|
||||||
BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, _localID, _buoyancy);
|
BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, _localID, _buoyancy);
|
||||||
|
@ -618,7 +613,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
m_log.WarnFormat("{0}: Got a NaN force applied to a Character", LogHeader);
|
m_log.WarnFormat("{0}: Got a NaN force applied to a Character", LogHeader);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject("BSPrim.AddForce", delegate()
|
||||||
{
|
{
|
||||||
OMV.Vector3 fSum = OMV.Vector3.Zero;
|
OMV.Vector3 fSum = OMV.Vector3.Zero;
|
||||||
lock (m_accumulatedForces)
|
lock (m_accumulatedForces)
|
||||||
|
@ -648,7 +643,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
// make sure first collision happens
|
// make sure first collision happens
|
||||||
_nextCollisionOkTime = Util.EnvironmentTickCount() - _subscribedEventsMs;
|
_nextCollisionOkTime = Util.EnvironmentTickCount() - _subscribedEventsMs;
|
||||||
|
|
||||||
Scene.TaintedObject(delegate()
|
Scene.TaintedObject("BSPrim.SubscribeEvents", delegate()
|
||||||
{
|
{
|
||||||
BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
||||||
});
|
});
|
||||||
|
@ -656,7 +651,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
}
|
}
|
||||||
public override void UnSubscribeEvents() {
|
public override void UnSubscribeEvents() {
|
||||||
_subscribedEventsMs = 0;
|
_subscribedEventsMs = 0;
|
||||||
Scene.TaintedObject(delegate()
|
Scene.TaintedObject("BSPrim.UnSubscribeEvents", delegate()
|
||||||
{
|
{
|
||||||
BulletSimAPI.RemoveFromCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
BulletSimAPI.RemoveFromCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
|
||||||
});
|
});
|
||||||
|
|
|
@ -162,7 +162,17 @@ public class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
}
|
}
|
||||||
|
|
||||||
public delegate void TaintCallback();
|
public delegate void TaintCallback();
|
||||||
private List<TaintCallback> _taintedObjects;
|
private struct TaintCallbackEntry
|
||||||
|
{
|
||||||
|
public String ident;
|
||||||
|
public TaintCallback callback;
|
||||||
|
public TaintCallbackEntry(string i, TaintCallback c)
|
||||||
|
{
|
||||||
|
ident = i;
|
||||||
|
callback = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private List<TaintCallbackEntry> _taintedObjects;
|
||||||
private Object _taintLock = new Object();
|
private Object _taintLock = new Object();
|
||||||
|
|
||||||
// A pointer to an instance if this structure is passed to the C++ code
|
// A pointer to an instance if this structure is passed to the C++ code
|
||||||
|
@ -232,7 +242,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
BulletSimAPI.SetDebugLogCallback(m_DebugLogCallbackHandle);
|
BulletSimAPI.SetDebugLogCallback(m_DebugLogCallbackHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
_taintedObjects = new List<TaintCallback>();
|
_taintedObjects = new List<TaintCallbackEntry>();
|
||||||
|
|
||||||
mesher = meshmerizer;
|
mesher = meshmerizer;
|
||||||
// The bounding box for the simulated world
|
// The bounding box for the simulated world
|
||||||
|
@ -535,7 +545,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
|
|
||||||
public override void SetTerrain(float[] heightMap) {
|
public override void SetTerrain(float[] heightMap) {
|
||||||
m_heightMap = heightMap;
|
m_heightMap = heightMap;
|
||||||
this.TaintedObject(delegate()
|
this.TaintedObject("BSScene.SetTerrain", delegate()
|
||||||
{
|
{
|
||||||
BulletSimAPI.SetHeightmap(m_worldID, m_heightMap);
|
BulletSimAPI.SetHeightmap(m_worldID, m_heightMap);
|
||||||
});
|
});
|
||||||
|
@ -727,12 +737,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
// Calls to the PhysicsActors can't directly call into the physics engine
|
// Calls to the PhysicsActors can't directly call into the physics engine
|
||||||
// because it might be busy. We delay changes to a known time.
|
// because it might be busy. We delay changes to a known time.
|
||||||
// We rely on C#'s closure to save and restore the context for the delegate.
|
// We rely on C#'s closure to save and restore the context for the delegate.
|
||||||
public void TaintedObject(TaintCallback callback)
|
public void TaintedObject(String ident, TaintCallback callback)
|
||||||
{
|
{
|
||||||
if (!m_initialized) return;
|
if (!m_initialized) return;
|
||||||
|
|
||||||
lock (_taintLock)
|
lock (_taintLock)
|
||||||
_taintedObjects.Add(callback);
|
_taintedObjects.Add(new TaintCallbackEntry(ident, callback));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -744,22 +754,22 @@ public class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
if (_taintedObjects.Count > 0) // save allocating new list if there is nothing to process
|
if (_taintedObjects.Count > 0) // save allocating new list if there is nothing to process
|
||||||
{
|
{
|
||||||
// swizzle a new list into the list location so we can process what's there
|
// swizzle a new list into the list location so we can process what's there
|
||||||
List<TaintCallback> oldList;
|
List<TaintCallbackEntry> oldList;
|
||||||
lock (_taintLock)
|
lock (_taintLock)
|
||||||
{
|
{
|
||||||
oldList = _taintedObjects;
|
oldList = _taintedObjects;
|
||||||
_taintedObjects = new List<TaintCallback>();
|
_taintedObjects = new List<TaintCallbackEntry>();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (TaintCallback callback in oldList)
|
foreach (TaintCallbackEntry tcbe in oldList)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
callback();
|
tcbe.callback();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat("{0}: ProcessTaints: Exception: {1}", LogHeader, e);
|
m_log.ErrorFormat("{0}: ProcessTaints: {1}: Exception: {2}", LogHeader, tcbe.ident, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
oldList.Clear();
|
oldList.Clear();
|
||||||
|
@ -1248,7 +1258,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
List<uint> objectIDs = lIDs;
|
List<uint> objectIDs = lIDs;
|
||||||
string xparm = parm.ToLower();
|
string xparm = parm.ToLower();
|
||||||
float xval = val;
|
float xval = val;
|
||||||
TaintedObject(delegate() {
|
TaintedObject("BSScene.UpdateParameterSet", delegate() {
|
||||||
foreach (uint lID in objectIDs)
|
foreach (uint lID in objectIDs)
|
||||||
{
|
{
|
||||||
BulletSimAPI.UpdateParameter(m_worldID, lID, xparm, xval);
|
BulletSimAPI.UpdateParameter(m_worldID, lID, xparm, xval);
|
||||||
|
@ -1268,7 +1278,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
uint xlocalID = localID;
|
uint xlocalID = localID;
|
||||||
string xparm = parm.ToLower();
|
string xparm = parm.ToLower();
|
||||||
float xval = val;
|
float xval = val;
|
||||||
TaintedObject(delegate() {
|
TaintedObject("BSScene.TaintedUpdateParameter", delegate() {
|
||||||
BulletSimAPI.UpdateParameter(m_worldID, xlocalID, xparm, xval);
|
BulletSimAPI.UpdateParameter(m_worldID, xlocalID, xparm, xval);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue