BulletSim: add ID parameter to TaintedObject calls so logging will include LocalID of object which created the taint.

0.7.6-extended
Robert Adams 2013-08-20 09:20:48 -07:00 committed by Justin Clark-Casey (justincc)
parent 21a046e622
commit 1b021e0eaa
8 changed files with 91 additions and 72 deletions

View File

@ -105,7 +105,7 @@ public class BSActorAvatarMove : BSActor
// into the movement motor. // into the movement motor.
public void SetVelocityAndTarget(OMV.Vector3 vel, OMV.Vector3 targ, bool inTaintTime) public void SetVelocityAndTarget(OMV.Vector3 vel, OMV.Vector3 targ, bool inTaintTime)
{ {
m_physicsScene.TaintedObject(inTaintTime, "BSActorAvatarMove.setVelocityAndTarget", delegate() m_physicsScene.TaintedObject(inTaintTime, m_controllingPrim.LocalID, "BSActorAvatarMove.setVelocityAndTarget", delegate()
{ {
if (m_velocityMotor != null) if (m_velocityMotor != null)
{ {

View File

@ -93,7 +93,7 @@ public sealed class BSCharacter : BSPhysObject
LocalID, _size, Scale, Density, _avatarVolume, RawMass, pos); LocalID, _size, Scale, Density, _avatarVolume, RawMass, pos);
// do actual creation in taint time // do actual creation in taint time
PhysScene.TaintedObject("BSCharacter.create", delegate() PhysScene.TaintedObject(LocalID, "BSCharacter.create", delegate()
{ {
DetailLog("{0},BSCharacter.create,taint", LocalID); DetailLog("{0},BSCharacter.create,taint", LocalID);
// New body and shape into PhysBody and PhysShape // New body and shape into PhysBody and PhysShape
@ -121,7 +121,7 @@ public sealed class BSCharacter : BSPhysObject
base.Destroy(); base.Destroy();
DetailLog("{0},BSCharacter.Destroy", LocalID); DetailLog("{0},BSCharacter.Destroy", LocalID);
PhysScene.TaintedObject("BSCharacter.destroy", delegate() PhysScene.TaintedObject(LocalID, "BSCharacter.destroy", delegate()
{ {
PhysScene.Shapes.DereferenceBody(PhysBody, null /* bodyCallback */); PhysScene.Shapes.DereferenceBody(PhysBody, null /* bodyCallback */);
PhysBody.Clear(); PhysBody.Clear();
@ -209,7 +209,7 @@ public sealed class BSCharacter : BSPhysObject
DetailLog("{0},BSCharacter.setSize,call,size={1},scale={2},density={3},volume={4},mass={5}", DetailLog("{0},BSCharacter.setSize,call,size={1},scale={2},density={3},volume={4},mass={5}",
LocalID, _size, Scale, Density, _avatarVolume, RawMass); LocalID, _size, Scale, Density, _avatarVolume, RawMass);
PhysScene.TaintedObject("BSCharacter.setSize", delegate() PhysScene.TaintedObject(LocalID, "BSCharacter.setSize", delegate()
{ {
if (PhysBody.HasPhysicalBody && PhysShape.physShapeInfo.HasPhysicalShape) if (PhysBody.HasPhysicalBody && PhysShape.physShapeInfo.HasPhysicalShape)
{ {
@ -257,7 +257,7 @@ public sealed class BSCharacter : BSPhysObject
_rotationalVelocity = OMV.Vector3.Zero; _rotationalVelocity = OMV.Vector3.Zero;
// Zero some other properties directly into the physics engine // Zero some other properties directly into the physics engine
PhysScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate() PhysScene.TaintedObject(inTaintTime, LocalID, "BSCharacter.ZeroMotion", delegate()
{ {
if (PhysBody.HasPhysicalBody) if (PhysBody.HasPhysicalBody)
PhysScene.PE.ClearAllForces(PhysBody); PhysScene.PE.ClearAllForces(PhysBody);
@ -267,7 +267,7 @@ public sealed class BSCharacter : BSPhysObject
{ {
_rotationalVelocity = OMV.Vector3.Zero; _rotationalVelocity = OMV.Vector3.Zero;
PhysScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate() PhysScene.TaintedObject(inTaintTime, LocalID, "BSCharacter.ZeroMotion", delegate()
{ {
if (PhysBody.HasPhysicalBody) if (PhysBody.HasPhysicalBody)
{ {
@ -291,7 +291,7 @@ public sealed class BSCharacter : BSPhysObject
set { set {
RawPosition = value; RawPosition = value;
PhysScene.TaintedObject("BSCharacter.setPosition", delegate() PhysScene.TaintedObject(LocalID, "BSCharacter.setPosition", delegate()
{ {
DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, RawPosition, RawOrientation); DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, RawPosition, RawOrientation);
PositionSanityCheck(); PositionSanityCheck();
@ -363,7 +363,7 @@ public sealed class BSCharacter : BSPhysObject
{ {
// The new position value must be pushed into the physics engine but we can't // The new position value must be pushed into the physics engine but we can't
// just assign to "Position" because of potential call loops. // just assign to "Position" because of potential call loops.
PhysScene.TaintedObject(inTaintTime, "BSCharacter.PositionSanityCheck", delegate() PhysScene.TaintedObject(inTaintTime, LocalID, "BSCharacter.PositionSanityCheck", delegate()
{ {
DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, RawPosition, RawOrientation); DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, RawPosition, RawOrientation);
ForcePosition = RawPosition; ForcePosition = RawPosition;
@ -390,7 +390,7 @@ public sealed class BSCharacter : BSPhysObject
set { set {
RawForce = value; RawForce = value;
// m_log.DebugFormat("{0}: Force = {1}", LogHeader, _force); // m_log.DebugFormat("{0}: Force = {1}", LogHeader, _force);
PhysScene.TaintedObject("BSCharacter.SetForce", delegate() PhysScene.TaintedObject(LocalID, "BSCharacter.SetForce", delegate()
{ {
DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, RawForce); DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, RawForce);
if (PhysBody.HasPhysicalBody) if (PhysBody.HasPhysicalBody)
@ -438,7 +438,7 @@ public sealed class BSCharacter : BSPhysObject
set { set {
RawVelocity = value; RawVelocity = value;
// m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, RawVelocity); // m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, RawVelocity);
PhysScene.TaintedObject("BSCharacter.setVelocity", delegate() PhysScene.TaintedObject(LocalID, "BSCharacter.setVelocity", delegate()
{ {
if (m_moveActor != null) if (m_moveActor != null)
m_moveActor.SetVelocityAndTarget(RawVelocity, RawVelocity, true /* inTaintTime */); m_moveActor.SetVelocityAndTarget(RawVelocity, RawVelocity, true /* inTaintTime */);
@ -480,7 +480,7 @@ public sealed class BSCharacter : BSPhysObject
if (RawOrientation != value) if (RawOrientation != value)
{ {
RawOrientation = value; RawOrientation = value;
PhysScene.TaintedObject("BSCharacter.setOrientation", delegate() PhysScene.TaintedObject(LocalID, "BSCharacter.setOrientation", delegate()
{ {
// Bullet assumes we know what we are doing when forcing orientation // Bullet assumes we know what we are doing when forcing orientation
// so it lets us go against all the rules and just compensates for them later. // so it lets us go against all the rules and just compensates for them later.
@ -560,7 +560,7 @@ public sealed class BSCharacter : BSPhysObject
public override bool FloatOnWater { public override bool FloatOnWater {
set { set {
_floatOnWater = value; _floatOnWater = value;
PhysScene.TaintedObject("BSCharacter.setFloatOnWater", delegate() PhysScene.TaintedObject(LocalID, "BSCharacter.setFloatOnWater", delegate()
{ {
if (PhysBody.HasPhysicalBody) if (PhysBody.HasPhysicalBody)
{ {
@ -588,7 +588,7 @@ public sealed class BSCharacter : BSPhysObject
public override float Buoyancy { public override float Buoyancy {
get { return _buoyancy; } get { return _buoyancy; }
set { _buoyancy = value; set { _buoyancy = value;
PhysScene.TaintedObject("BSCharacter.setBuoyancy", delegate() PhysScene.TaintedObject(LocalID, "BSCharacter.setBuoyancy", delegate()
{ {
DetailLog("{0},BSCharacter.setBuoyancy,taint,buoy={1}", LocalID, _buoyancy); DetailLog("{0},BSCharacter.setBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
ForceBuoyancy = _buoyancy; ForceBuoyancy = _buoyancy;
@ -633,7 +633,7 @@ public sealed class BSCharacter : BSPhysObject
OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude); OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude);
// DetailLog("{0},BSCharacter.addForce,call,force={1}", LocalID, addForce); // DetailLog("{0},BSCharacter.addForce,call,force={1}", LocalID, addForce);
PhysScene.TaintedObject(inTaintTime, "BSCharacter.AddForce", delegate() PhysScene.TaintedObject(inTaintTime, LocalID, "BSCharacter.AddForce", delegate()
{ {
// Bullet adds this central force to the total force for this tick // Bullet adds this central force to the total force for this tick
// DetailLog("{0},BSCharacter.addForce,taint,force={1}", LocalID, addForce); // DetailLog("{0},BSCharacter.addForce,taint,force={1}", LocalID, addForce);

View File

@ -297,7 +297,7 @@ public sealed class BSLinksetConstraints : BSLinkset
rootx.LocalID, rootx.PhysBody.AddrString, rootx.LocalID, rootx.PhysBody.AddrString,
childx.LocalID, childx.PhysBody.AddrString); childx.LocalID, childx.PhysBody.AddrString);
m_physicsScene.TaintedObject(inTaintTime, "BSLinksetConstraints.RemoveChildFromLinkset", delegate() m_physicsScene.TaintedObject(inTaintTime, childx.LocalID, "BSLinksetConstraints.RemoveChildFromLinkset", delegate()
{ {
PhysicallyUnlinkAChildFromRoot(rootx, childx); PhysicallyUnlinkAChildFromRoot(rootx, childx);
}); });
@ -508,7 +508,7 @@ public sealed class BSLinksetConstraints : BSLinkset
BSPrimLinkable child = pParams[0] as BSPrimLinkable; BSPrimLinkable child = pParams[0] as BSPrimLinkable;
if (child != null) if (child != null)
{ {
m_physicsScene.TaintedObject("BSLinksetConstraint.PhysFunctChangeLinkType", delegate() m_physicsScene.TaintedObject(child.LocalID, "BSLinksetConstraint.PhysFunctChangeLinkType", delegate()
{ {
// Pick up all the constraints currently created. // Pick up all the constraints currently created.
RemoveDependencies(child); RemoveDependencies(child);

View File

@ -826,7 +826,7 @@ public static class BSParam
private static void ResetConstraintSolverTainted(BSScene pPhysScene, float v) private static void ResetConstraintSolverTainted(BSScene pPhysScene, float v)
{ {
BSScene physScene = pPhysScene; BSScene physScene = pPhysScene;
physScene.TaintedObject("BSParam.ResetConstraintSolver", delegate() physScene.TaintedObject(BSScene.DetailLogZero, "BSParam.ResetConstraintSolver", delegate()
{ {
physScene.PE.ResetConstraintSolver(physScene.World); physScene.PE.ResetConstraintSolver(physScene.World);
}); });

View File

@ -121,7 +121,7 @@ public abstract class BSPhysObject : PhysicsActor
public virtual void Destroy() public virtual void Destroy()
{ {
PhysicalActors.Enable(false); PhysicalActors.Enable(false);
PhysScene.TaintedObject("BSPhysObject.Destroy", delegate() PhysScene.TaintedObject(LocalID, "BSPhysObject.Destroy", delegate()
{ {
PhysicalActors.Dispose(); PhysicalActors.Dispose();
}); });
@ -509,7 +509,7 @@ public abstract class BSPhysObject : PhysicsActor
// make sure first collision happens // make sure first collision happens
NextCollisionOkTime = Util.EnvironmentTickCountSubtract(SubscribedEventsMs); NextCollisionOkTime = Util.EnvironmentTickCountSubtract(SubscribedEventsMs);
PhysScene.TaintedObject(TypeName+".SubscribeEvents", delegate() PhysScene.TaintedObject(LocalID, TypeName+".SubscribeEvents", delegate()
{ {
if (PhysBody.HasPhysicalBody) if (PhysBody.HasPhysicalBody)
CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
@ -524,7 +524,7 @@ public abstract class BSPhysObject : PhysicsActor
public override void UnSubscribeEvents() { public override void UnSubscribeEvents() {
// DetailLog("{0},{1}.UnSubscribeEvents,unsubscribing", LocalID, TypeName); // DetailLog("{0},{1}.UnSubscribeEvents,unsubscribing", LocalID, TypeName);
SubscribedEventsMs = 0; SubscribedEventsMs = 0;
PhysScene.TaintedObject(TypeName+".UnSubscribeEvents", delegate() PhysScene.TaintedObject(LocalID, TypeName+".UnSubscribeEvents", delegate()
{ {
// Make sure there is a body there because sometimes destruction happens in an un-ideal order. // Make sure there is a body there because sometimes destruction happens in an un-ideal order.
if (PhysBody.HasPhysicalBody) if (PhysBody.HasPhysicalBody)

View File

@ -102,7 +102,7 @@ public class BSPrim : BSPhysObject
// DetailLog("{0},BSPrim.constructor,call", LocalID); // DetailLog("{0},BSPrim.constructor,call", LocalID);
// do the actual object creation at taint time // do the actual object creation at taint time
PhysScene.TaintedObject("BSPrim.create", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.create", delegate()
{ {
// Make sure the object is being created with some sanity. // Make sure the object is being created with some sanity.
ExtremeSanityCheck(true /* inTaintTime */); ExtremeSanityCheck(true /* inTaintTime */);
@ -126,7 +126,7 @@ public class BSPrim : BSPhysObject
// Undo any vehicle properties // Undo any vehicle properties
this.VehicleType = (int)Vehicle.TYPE_NONE; this.VehicleType = (int)Vehicle.TYPE_NONE;
PhysScene.TaintedObject("BSPrim.Destroy", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.Destroy", delegate()
{ {
DetailLog("{0},BSPrim.Destroy,taint,", LocalID); DetailLog("{0},BSPrim.Destroy,taint,", LocalID);
// If there are physical body and shape, release my use of same. // If there are physical body and shape, release my use of same.
@ -161,7 +161,7 @@ public class BSPrim : BSPhysObject
} }
public override bool ForceBodyShapeRebuild(bool inTaintTime) public override bool ForceBodyShapeRebuild(bool inTaintTime)
{ {
PhysScene.TaintedObject(inTaintTime, "BSPrim.ForceBodyShapeRebuild", delegate() PhysScene.TaintedObject(inTaintTime, LocalID, "BSPrim.ForceBodyShapeRebuild", delegate()
{ {
_mass = CalculateMass(); // changing the shape changes the mass _mass = CalculateMass(); // changing the shape changes the mass
CreateGeomAndObject(true); CreateGeomAndObject(true);
@ -178,7 +178,7 @@ public class BSPrim : BSPhysObject
if (value != _isSelected) if (value != _isSelected)
{ {
_isSelected = value; _isSelected = value;
PhysScene.TaintedObject("BSPrim.setSelected", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.setSelected", delegate()
{ {
DetailLog("{0},BSPrim.selected,taint,selected={1}", LocalID, _isSelected); DetailLog("{0},BSPrim.selected,taint,selected={1}", LocalID, _isSelected);
SetObjectDynamic(false); SetObjectDynamic(false);
@ -224,7 +224,7 @@ public class BSPrim : BSPhysObject
_rotationalVelocity = OMV.Vector3.Zero; _rotationalVelocity = OMV.Vector3.Zero;
// Zero some other properties in the physics engine // Zero some other properties in the physics engine
PhysScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate() PhysScene.TaintedObject(inTaintTime, LocalID, "BSPrim.ZeroMotion", delegate()
{ {
if (PhysBody.HasPhysicalBody) if (PhysBody.HasPhysicalBody)
PhysScene.PE.ClearAllForces(PhysBody); PhysScene.PE.ClearAllForces(PhysBody);
@ -234,7 +234,7 @@ public class BSPrim : BSPhysObject
{ {
_rotationalVelocity = OMV.Vector3.Zero; _rotationalVelocity = OMV.Vector3.Zero;
// Zero some other properties in the physics engine // Zero some other properties in the physics engine
PhysScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate() PhysScene.TaintedObject(inTaintTime, LocalID, "BSPrim.ZeroMotion", delegate()
{ {
// DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity); // DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity);
if (PhysBody.HasPhysicalBody) if (PhysBody.HasPhysicalBody)
@ -262,7 +262,7 @@ public class BSPrim : BSPhysObject
}); });
// Update parameters so the new actor's Refresh() action is called at the right time. // Update parameters so the new actor's Refresh() action is called at the right time.
PhysScene.TaintedObject("BSPrim.LockAngularMotion", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.LockAngularMotion", delegate()
{ {
UpdatePhysicalParameters(); UpdatePhysicalParameters();
}); });
@ -287,7 +287,7 @@ public class BSPrim : BSPhysObject
RawPosition = value; RawPosition = value;
PositionSanityCheck(false); PositionSanityCheck(false);
PhysScene.TaintedObject("BSPrim.setPosition", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.setPosition", delegate()
{ {
DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, RawPosition, RawOrientation); DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, RawPosition, RawOrientation);
ForcePosition = RawPosition; ForcePosition = RawPosition;
@ -531,7 +531,7 @@ public class BSPrim : BSPhysObject
set { set {
Vehicle type = (Vehicle)value; Vehicle type = (Vehicle)value;
PhysScene.TaintedObject("setVehicleType", delegate() PhysScene.TaintedObject(LocalID, "setVehicleType", delegate()
{ {
// Some vehicle scripts change vehicle type on the fly as an easy way to // Some vehicle scripts change vehicle type on the fly as an easy way to
// change all the parameters. Like a plane changing to CAR when on the // change all the parameters. Like a plane changing to CAR when on the
@ -561,7 +561,7 @@ public class BSPrim : BSPhysObject
} }
public override void VehicleFloatParam(int param, float value) public override void VehicleFloatParam(int param, float value)
{ {
PhysScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.VehicleFloatParam", delegate()
{ {
BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */);
if (vehicleActor != null) if (vehicleActor != null)
@ -573,7 +573,7 @@ public class BSPrim : BSPhysObject
} }
public override void VehicleVectorParam(int param, OMV.Vector3 value) public override void VehicleVectorParam(int param, OMV.Vector3 value)
{ {
PhysScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.VehicleVectorParam", delegate()
{ {
BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */);
if (vehicleActor != null) if (vehicleActor != null)
@ -585,7 +585,7 @@ public class BSPrim : BSPhysObject
} }
public override void VehicleRotationParam(int param, OMV.Quaternion rotation) public override void VehicleRotationParam(int param, OMV.Quaternion rotation)
{ {
PhysScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.VehicleRotationParam", delegate()
{ {
BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */);
if (vehicleActor != null) if (vehicleActor != null)
@ -597,7 +597,7 @@ public class BSPrim : BSPhysObject
} }
public override void VehicleFlags(int param, bool remove) public override void VehicleFlags(int param, bool remove)
{ {
PhysScene.TaintedObject("BSPrim.VehicleFlags", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.VehicleFlags", delegate()
{ {
BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */);
if (vehicleActor != null) if (vehicleActor != null)
@ -613,7 +613,7 @@ public class BSPrim : BSPhysObject
if (_isVolumeDetect != newValue) if (_isVolumeDetect != newValue)
{ {
_isVolumeDetect = newValue; _isVolumeDetect = newValue;
PhysScene.TaintedObject("BSPrim.SetVolumeDetect", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.SetVolumeDetect", delegate()
{ {
// DetailLog("{0},setVolumeDetect,taint,volDetect={1}", LocalID, _isVolumeDetect); // DetailLog("{0},setVolumeDetect,taint,volDetect={1}", LocalID, _isVolumeDetect);
SetObjectDynamic(true); SetObjectDynamic(true);
@ -628,7 +628,7 @@ public class BSPrim : BSPhysObject
public override void SetMaterial(int material) public override void SetMaterial(int material)
{ {
base.SetMaterial(material); base.SetMaterial(material);
PhysScene.TaintedObject("BSPrim.SetMaterial", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.SetMaterial", delegate()
{ {
UpdatePhysicalParameters(); UpdatePhysicalParameters();
}); });
@ -641,7 +641,7 @@ public class BSPrim : BSPhysObject
if (base.Friction != value) if (base.Friction != value)
{ {
base.Friction = value; base.Friction = value;
PhysScene.TaintedObject("BSPrim.setFriction", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.setFriction", delegate()
{ {
UpdatePhysicalParameters(); UpdatePhysicalParameters();
}); });
@ -656,7 +656,7 @@ public class BSPrim : BSPhysObject
if (base.Restitution != value) if (base.Restitution != value)
{ {
base.Restitution = value; base.Restitution = value;
PhysScene.TaintedObject("BSPrim.setRestitution", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.setRestitution", delegate()
{ {
UpdatePhysicalParameters(); UpdatePhysicalParameters();
}); });
@ -673,7 +673,7 @@ public class BSPrim : BSPhysObject
if (base.Density != value) if (base.Density != value)
{ {
base.Density = value; base.Density = value;
PhysScene.TaintedObject("BSPrim.setDensity", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.setDensity", delegate()
{ {
UpdatePhysicalParameters(); UpdatePhysicalParameters();
}); });
@ -688,7 +688,7 @@ public class BSPrim : BSPhysObject
if (base.GravModifier != value) if (base.GravModifier != value)
{ {
base.GravModifier = value; base.GravModifier = value;
PhysScene.TaintedObject("BSPrim.setGravityModifier", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.setGravityModifier", delegate()
{ {
UpdatePhysicalParameters(); UpdatePhysicalParameters();
}); });
@ -699,7 +699,7 @@ public class BSPrim : BSPhysObject
get { return RawVelocity; } get { return RawVelocity; }
set { set {
RawVelocity = value; RawVelocity = value;
PhysScene.TaintedObject("BSPrim.setVelocity", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.setVelocity", delegate()
{ {
// DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, RawVelocity); // DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, RawVelocity);
ForceVelocity = RawVelocity; ForceVelocity = RawVelocity;
@ -745,7 +745,7 @@ public class BSPrim : BSPhysObject
return; return;
RawOrientation = value; RawOrientation = value;
PhysScene.TaintedObject("BSPrim.setOrientation", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.setOrientation", delegate()
{ {
ForceOrientation = RawOrientation; ForceOrientation = RawOrientation;
}); });
@ -776,7 +776,7 @@ public class BSPrim : BSPhysObject
if (_isPhysical != value) if (_isPhysical != value)
{ {
_isPhysical = value; _isPhysical = value;
PhysScene.TaintedObject("BSPrim.setIsPhysical", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.setIsPhysical", delegate()
{ {
DetailLog("{0},setIsPhysical,taint,isPhys={1}", LocalID, _isPhysical); DetailLog("{0},setIsPhysical,taint,isPhys={1}", LocalID, _isPhysical);
SetObjectDynamic(true); SetObjectDynamic(true);
@ -1020,7 +1020,7 @@ public class BSPrim : BSPhysObject
public override bool FloatOnWater { public override bool FloatOnWater {
set { set {
_floatOnWater = value; _floatOnWater = value;
PhysScene.TaintedObject("BSPrim.setFloatOnWater", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.setFloatOnWater", delegate()
{ {
if (_floatOnWater) if (_floatOnWater)
CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER); CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER);
@ -1037,7 +1037,7 @@ public class BSPrim : BSPhysObject
_rotationalVelocity = value; _rotationalVelocity = value;
Util.ClampV(_rotationalVelocity, BSParam.MaxAngularVelocity); Util.ClampV(_rotationalVelocity, BSParam.MaxAngularVelocity);
// m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity);
PhysScene.TaintedObject("BSPrim.setRotationalVelocity", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.setRotationalVelocity", delegate()
{ {
ForceRotationalVelocity = _rotationalVelocity; ForceRotationalVelocity = _rotationalVelocity;
}); });
@ -1068,7 +1068,7 @@ public class BSPrim : BSPhysObject
get { return _buoyancy; } get { return _buoyancy; }
set { set {
_buoyancy = value; _buoyancy = value;
PhysScene.TaintedObject("BSPrim.setBuoyancy", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.setBuoyancy", delegate()
{ {
ForceBuoyancy = _buoyancy; ForceBuoyancy = _buoyancy;
}); });
@ -1142,7 +1142,7 @@ public class BSPrim : BSPhysObject
// DetailLog("{0},BSPrim.addForce,call,force={1}", LocalID, addForce); // DetailLog("{0},BSPrim.addForce,call,force={1}", LocalID, addForce);
OMV.Vector3 addForce = force; OMV.Vector3 addForce = force;
PhysScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate() PhysScene.TaintedObject(inTaintTime, LocalID, "BSPrim.AddForce", delegate()
{ {
// Bullet adds this central force to the total force for this tick. // Bullet adds this central force to the total force for this tick.
// Deep down in Bullet: // Deep down in Bullet:
@ -1172,7 +1172,7 @@ public class BSPrim : BSPhysObject
OMV.Vector3 addImpulse = Util.ClampV(impulse, BSParam.MaxAddForceMagnitude); OMV.Vector3 addImpulse = Util.ClampV(impulse, BSParam.MaxAddForceMagnitude);
// DetailLog("{0},BSPrim.addForceImpulse,call,impulse={1}", LocalID, impulse); // DetailLog("{0},BSPrim.addForceImpulse,call,impulse={1}", LocalID, impulse);
PhysScene.TaintedObject(inTaintTime, "BSPrim.AddImpulse", delegate() PhysScene.TaintedObject(inTaintTime, LocalID, "BSPrim.AddImpulse", delegate()
{ {
// Bullet adds this impulse immediately to the velocity // Bullet adds this impulse immediately to the velocity
DetailLog("{0},BSPrim.addForceImpulse,taint,impulseforce={1}", LocalID, addImpulse); DetailLog("{0},BSPrim.addForceImpulse,taint,impulseforce={1}", LocalID, addImpulse);
@ -1197,7 +1197,7 @@ public class BSPrim : BSPhysObject
if (force.IsFinite()) if (force.IsFinite())
{ {
OMV.Vector3 angForce = force; OMV.Vector3 angForce = force;
PhysScene.TaintedObject(inTaintTime, "BSPrim.AddAngularForce", delegate() PhysScene.TaintedObject(inTaintTime, LocalID, "BSPrim.AddAngularForce", delegate()
{ {
if (PhysBody.HasPhysicalBody) if (PhysBody.HasPhysicalBody)
{ {
@ -1221,7 +1221,7 @@ public class BSPrim : BSPhysObject
public void ApplyTorqueImpulse(OMV.Vector3 impulse, bool inTaintTime) public void ApplyTorqueImpulse(OMV.Vector3 impulse, bool inTaintTime)
{ {
OMV.Vector3 applyImpulse = impulse; OMV.Vector3 applyImpulse = impulse;
PhysScene.TaintedObject(inTaintTime, "BSPrim.ApplyTorqueImpulse", delegate() PhysScene.TaintedObject(inTaintTime, LocalID, "BSPrim.ApplyTorqueImpulse", delegate()
{ {
if (PhysBody.HasPhysicalBody) if (PhysBody.HasPhysicalBody)
{ {

View File

@ -108,7 +108,7 @@ public class BSPrimLinkable : BSPrimDisplaced
set set
{ {
base.Position = value; base.Position = value;
PhysScene.TaintedObject("BSPrimLinkable.setPosition", delegate() PhysScene.TaintedObject(LocalID, "BSPrimLinkable.setPosition", delegate()
{ {
Linkset.UpdateProperties(UpdatedProperties.Position, this); Linkset.UpdateProperties(UpdatedProperties.Position, this);
}); });
@ -122,7 +122,7 @@ public class BSPrimLinkable : BSPrimDisplaced
set set
{ {
base.Orientation = value; base.Orientation = value;
PhysScene.TaintedObject("BSPrimLinkable.setOrientation", delegate() PhysScene.TaintedObject(LocalID, "BSPrimLinkable.setOrientation", delegate()
{ {
Linkset.UpdateProperties(UpdatedProperties.Orientation, this); Linkset.UpdateProperties(UpdatedProperties.Orientation, this);
}); });
@ -304,7 +304,7 @@ public class BSPrimLinkable : BSPrimDisplaced
BSLinkset.LinksetImplementation linksetType = (BSLinkset.LinksetImplementation)pParams[0]; BSLinkset.LinksetImplementation linksetType = (BSLinkset.LinksetImplementation)pParams[0];
if (Linkset.IsRoot(this)) if (Linkset.IsRoot(this))
{ {
PhysScene.TaintedObject("BSPrim.PhysFunctSetLinksetType", delegate() PhysScene.TaintedObject(LocalID, "BSPrim.PhysFunctSetLinksetType", delegate()
{ {
// Cause the linkset type to change // Cause the linkset type to change
DetailLog("{0},BSPrimLinkable.Extension.physSetLinksetType, oldType={1},newType={2}", DetailLog("{0},BSPrimLinkable.Extension.physSetLinksetType, oldType={1},newType={2}",

View File

@ -157,12 +157,20 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
public delegate void TaintCallback(); public delegate void TaintCallback();
private struct TaintCallbackEntry private struct TaintCallbackEntry
{ {
public String originator;
public String ident; public String ident;
public TaintCallback callback; public TaintCallback callback;
public TaintCallbackEntry(string i, TaintCallback c) public TaintCallbackEntry(string pIdent, TaintCallback pCallBack)
{ {
ident = i; originator = BSScene.DetailLogZero;
callback = c; ident = pIdent;
callback = pCallBack;
}
public TaintCallbackEntry(string pOrigin, string pIdent, TaintCallback pCallBack)
{
originator = pOrigin;
ident = pIdent;
callback = pCallBack;
} }
} }
private Object _taintLock = new Object(); // lock for using the next object private Object _taintLock = new Object(); // lock for using the next object
@ -888,26 +896,37 @@ public sealed 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(String ident, TaintCallback callback) public void TaintedObject(string pOriginator, string pIdent, TaintCallback pCallback)
{
TaintedObject(false /*inTaintTime*/, pOriginator, pIdent, pCallback);
}
public void TaintedObject(uint pOriginator, String pIdent, TaintCallback pCallback)
{
TaintedObject(false /*inTaintTime*/, m_physicsLoggingEnabled ? pOriginator.ToString() : BSScene.DetailLogZero, pIdent, pCallback);
}
public void TaintedObject(bool inTaintTime, String pIdent, TaintCallback pCallback)
{
TaintedObject(inTaintTime, BSScene.DetailLogZero, pIdent, pCallback);
}
public void TaintedObject(bool inTaintTime, uint pOriginator, String pIdent, TaintCallback pCallback)
{
TaintedObject(inTaintTime, m_physicsLoggingEnabled ? pOriginator.ToString() : BSScene.DetailLogZero, pIdent, pCallback);
}
// Sometimes a potentially tainted operation can be used in and out of taint time.
// This routine executes the command immediately if in taint-time otherwise it is queued.
public void TaintedObject(bool inTaintTime, string pOriginator, string pIdent, TaintCallback pCallback)
{ {
if (!m_initialized) return; if (!m_initialized) return;
lock (_taintLock)
{
_taintOperations.Add(new TaintCallbackEntry(ident, callback));
}
return;
}
// Sometimes a potentially tainted operation can be used in and out of taint time.
// This routine executes the command immediately if in taint-time otherwise it is queued.
public void TaintedObject(bool inTaintTime, string ident, TaintCallback callback)
{
if (inTaintTime) if (inTaintTime)
callback(); pCallback();
else else
TaintedObject(ident, callback); {
lock (_taintLock)
{
_taintOperations.Add(new TaintCallbackEntry(pOriginator, pIdent, pCallback));
}
}
} }
private void TriggerPreStepEvent(float timeStep) private void TriggerPreStepEvent(float timeStep)
@ -951,7 +970,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
{ {
try try
{ {
DetailLog("{0},BSScene.ProcessTaints,doTaint,id={1}", DetailLogZero, tcbe.ident); // DEBUG DEBUG DEBUG DetailLog("{0},BSScene.ProcessTaints,doTaint,id={1}", tcbe.originator, tcbe.ident); // DEBUG DEBUG DEBUG
tcbe.callback(); tcbe.callback();
} }
catch (Exception e) catch (Exception e)
@ -1081,7 +1100,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
string xval = val; string xval = val;
List<uint> xlIDs = lIDs; List<uint> xlIDs = lIDs;
string xparm = parm; string xparm = parm;
TaintedObject("BSScene.UpdateParameterSet", delegate() { TaintedObject(DetailLogZero, "BSScene.UpdateParameterSet", delegate() {
BSParam.ParameterDefnBase thisParam; BSParam.ParameterDefnBase thisParam;
if (BSParam.TryGetParameter(xparm, out thisParam)) if (BSParam.TryGetParameter(xparm, out thisParam))
{ {