BulletSim: protect character property setting to remove crash from taints setting properties after the destroy character taint.
parent
63099184db
commit
d4e0e98c00
|
@ -195,9 +195,12 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
LocalID, _size, Scale, _avatarDensity, _avatarVolume, RawMass);
|
LocalID, _size, Scale, _avatarDensity, _avatarVolume, RawMass);
|
||||||
|
|
||||||
PhysicsScene.TaintedObject("BSCharacter.setSize", delegate()
|
PhysicsScene.TaintedObject("BSCharacter.setSize", delegate()
|
||||||
|
{
|
||||||
|
if (PhysShape.HasPhysicalShape)
|
||||||
{
|
{
|
||||||
BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale);
|
BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale);
|
||||||
UpdatePhysicalMassProperties(RawMass);
|
UpdatePhysicalMassProperties(RawMass);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -238,6 +241,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
// Zero some other properties directly into the physics engine
|
// Zero some other properties directly into the physics engine
|
||||||
PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate()
|
PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate()
|
||||||
{
|
{
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.ClearAllForces2(PhysBody.ptr);
|
BulletSimAPI.ClearAllForces2(PhysBody.ptr);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -246,11 +250,14 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
_rotationalVelocity = OMV.Vector3.Zero;
|
_rotationalVelocity = OMV.Vector3.Zero;
|
||||||
|
|
||||||
PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate()
|
PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate()
|
||||||
|
{
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero);
|
BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero);
|
||||||
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero);
|
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero);
|
||||||
// The next also get rid of applied linear force but the linear velocity is untouched.
|
// The next also get rid of applied linear force but the linear velocity is untouched.
|
||||||
BulletSimAPI.ClearForces2(PhysBody.ptr);
|
BulletSimAPI.ClearForces2(PhysBody.ptr);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,6 +282,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
PhysicsScene.TaintedObject("BSCharacter.setPosition", delegate()
|
PhysicsScene.TaintedObject("BSCharacter.setPosition", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -334,6 +342,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.PositionSanityCheck", delegate()
|
PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.PositionSanityCheck", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation);
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
||||||
});
|
});
|
||||||
ret = true;
|
ret = true;
|
||||||
|
@ -361,6 +370,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
PhysicsScene.TaintedObject("BSCharacter.SetForce", delegate()
|
PhysicsScene.TaintedObject("BSCharacter.SetForce", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force);
|
DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force);
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force);
|
BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -400,6 +410,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
if (_currentFriction != PhysicsScene.Params.avatarStandingFriction)
|
if (_currentFriction != PhysicsScene.Params.avatarStandingFriction)
|
||||||
{
|
{
|
||||||
_currentFriction = PhysicsScene.Params.avatarStandingFriction;
|
_currentFriction = PhysicsScene.Params.avatarStandingFriction;
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction);
|
BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -408,6 +419,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
if (_currentFriction != PhysicsScene.Params.avatarFriction)
|
if (_currentFriction != PhysicsScene.Params.avatarFriction)
|
||||||
{
|
{
|
||||||
_currentFriction = PhysicsScene.Params.avatarFriction;
|
_currentFriction = PhysicsScene.Params.avatarFriction;
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction);
|
BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -444,9 +456,12 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
_orientation = value;
|
_orientation = value;
|
||||||
// m_log.DebugFormat("{0}: set orientation to {1}", LogHeader, _orientation);
|
// m_log.DebugFormat("{0}: set orientation to {1}", LogHeader, _orientation);
|
||||||
PhysicsScene.TaintedObject("BSCharacter.setOrientation", delegate()
|
PhysicsScene.TaintedObject("BSCharacter.setOrientation", delegate()
|
||||||
|
{
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
// _position = BulletSimAPI.GetPosition2(BSBody.ptr);
|
// _position = BulletSimAPI.GetPosition2(BSBody.ptr);
|
||||||
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -518,11 +533,14 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
set {
|
set {
|
||||||
_floatOnWater = value;
|
_floatOnWater = value;
|
||||||
PhysicsScene.TaintedObject("BSCharacter.setFloatOnWater", delegate()
|
PhysicsScene.TaintedObject("BSCharacter.setFloatOnWater", delegate()
|
||||||
|
{
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
{
|
{
|
||||||
if (_floatOnWater)
|
if (_floatOnWater)
|
||||||
CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER);
|
CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER);
|
||||||
else
|
else
|
||||||
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER);
|
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -555,6 +573,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
DetailLog("{0},BSCharacter.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
|
DetailLog("{0},BSCharacter.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
|
||||||
// Buoyancy is faked by changing the gravity applied to the object
|
// Buoyancy is faked by changing the gravity applied to the object
|
||||||
float grav = PhysicsScene.Params.gravity * (1f - _buoyancy);
|
float grav = PhysicsScene.Params.gravity * (1f - _buoyancy);
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav));
|
BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -601,6 +620,7 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
PhysicsScene.TaintedObject("BSCharacter.AddForce", delegate()
|
PhysicsScene.TaintedObject("BSCharacter.AddForce", delegate()
|
||||||
{
|
{
|
||||||
DetailLog("{0},BSCharacter.setAddForce,taint,addedForce={1}", LocalID, _force);
|
DetailLog("{0},BSCharacter.setAddForce,taint,addedForce={1}", LocalID, _force);
|
||||||
|
if (PhysBody.HasPhysicalBody)
|
||||||
BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force);
|
BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,7 +191,8 @@ public sealed class BSPrim : BSPhysObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override bool Selected {
|
public override bool Selected {
|
||||||
set {
|
set
|
||||||
|
{
|
||||||
if (value != _isSelected)
|
if (value != _isSelected)
|
||||||
{
|
{
|
||||||
_isSelected = value;
|
_isSelected = value;
|
||||||
|
|
Loading…
Reference in New Issue