BulletSim: protect prim property setting to remove crash from taints setting properties after the destroy object taint has happened.

0.7.5-pf-bulletsim
Robert Adams 2012-12-11 13:42:23 -08:00
parent 905d7c43ad
commit 63099184db
3 changed files with 45 additions and 20 deletions

View File

@ -65,7 +65,7 @@ public abstract class BSMotor
// Can all the incremental stepping be replaced with motor classes? // Can all the incremental stepping be replaced with motor classes?
// Motor which moves CurrentValue to TargetValue over TimeScale seconds. // Motor which moves CurrentValue to TargetValue over TimeScale seconds.
// The TargetValue is decays in TargetValueDecayTimeScale and // The TargetValue decays in TargetValueDecayTimeScale and
// the CurrentValue will be held back by FrictionTimeScale. // the CurrentValue will be held back by FrictionTimeScale.
// TimeScale and TargetDelayTimeScale may be 'infinite' which means go decay. // TimeScale and TargetDelayTimeScale may be 'infinite' which means go decay.

View File

@ -249,6 +249,7 @@ public sealed class BSPrim : BSPhysObject
// Zero some other properties in the physics engine // Zero some other properties in the physics engine
PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate() PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate()
{ {
if (PhysBody.HasPhysicalBody)
BulletSimAPI.ClearAllForces2(PhysBody.ptr); BulletSimAPI.ClearAllForces2(PhysBody.ptr);
}); });
} }
@ -259,8 +260,11 @@ public sealed class BSPrim : BSPhysObject
PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate() PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate()
{ {
// DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity); // DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity);
if (PhysBody.HasPhysicalBody)
{
BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, _rotationalVelocity); BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity); BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
}
}); });
} }
@ -297,8 +301,11 @@ public sealed class BSPrim : BSPhysObject
PhysicsScene.TaintedObject("BSPrim.setPosition", delegate() PhysicsScene.TaintedObject("BSPrim.setPosition", delegate()
{ {
// DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); // DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
if (PhysBody.HasPhysicalBody)
{
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
ActivateIfPhysical(false); ActivateIfPhysical(false);
}
}); });
} }
} }
@ -415,6 +422,7 @@ public sealed class BSPrim : BSPhysObject
PhysicsScene.TaintedObject("BSPrim.setForce", delegate() PhysicsScene.TaintedObject("BSPrim.setForce", delegate()
{ {
// DetailLog("{0},BSPrim.setForce,taint,force={1}", LocalID, _force); // DetailLog("{0},BSPrim.setForce,taint,force={1}", LocalID, _force);
if (PhysBody.HasPhysicalBody)
BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force); BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force);
}); });
} }
@ -509,6 +517,7 @@ public sealed class BSPrim : BSPhysObject
PhysicsScene.TaintedObject("BSPrim.setVelocity", delegate() PhysicsScene.TaintedObject("BSPrim.setVelocity", delegate()
{ {
// DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, _velocity); // DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, _velocity);
if (PhysBody.HasPhysicalBody)
BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity); BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity);
}); });
} }
@ -557,10 +566,13 @@ public sealed class BSPrim : BSPhysObject
_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?
PhysicsScene.TaintedObject("BSPrim.setOrientation", delegate() PhysicsScene.TaintedObject("BSPrim.setOrientation", delegate()
{
if (PhysBody.HasPhysicalBody)
{ {
// _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr); // _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr);
// DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); // DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation);
BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
}
}); });
} }
} }
@ -865,6 +877,7 @@ public sealed class BSPrim : BSPhysObject
PhysicsScene.TaintedObject("BSPrim.setRotationalVelocity", delegate() PhysicsScene.TaintedObject("BSPrim.setRotationalVelocity", delegate()
{ {
DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity);
if (PhysBody.HasPhysicalBody)
BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity); BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity);
}); });
} }
@ -900,10 +913,13 @@ public sealed class BSPrim : BSPhysObject
_buoyancy = value; _buoyancy = value;
// DetailLog("{0},BSPrim.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy); // DetailLog("{0},BSPrim.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
if (PhysBody.HasPhysicalBody)
{
float grav = PhysicsScene.Params.gravity * (1f - _buoyancy); float grav = PhysicsScene.Params.gravity * (1f - _buoyancy);
BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav)); BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav));
} }
} }
}
// Used for MoveTo // Used for MoveTo
public override OMV.Vector3 PIDTarget { public override OMV.Vector3 PIDTarget {
@ -969,6 +985,7 @@ public sealed class BSPrim : BSPhysObject
} }
DetailLog("{0},BSPrim.AddForce,taint,force={1}", LocalID, fSum); DetailLog("{0},BSPrim.AddForce,taint,force={1}", LocalID, fSum);
if (fSum != OMV.Vector3.Zero) if (fSum != OMV.Vector3.Zero)
if (PhysBody.HasPhysicalBody)
BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, fSum); BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, fSum);
}); });
} }
@ -980,6 +997,7 @@ public sealed class BSPrim : BSPhysObject
PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ApplyForceImpulse", delegate() PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ApplyForceImpulse", delegate()
{ {
DetailLog("{0},BSPrim.ApplyForceImpulse,taint,tImpulse={1}", LocalID, applyImpulse); DetailLog("{0},BSPrim.ApplyForceImpulse,taint,tImpulse={1}", LocalID, applyImpulse);
if (PhysBody.HasPhysicalBody)
BulletSimAPI.ApplyCentralImpulse2(PhysBody.ptr, applyImpulse); BulletSimAPI.ApplyCentralImpulse2(PhysBody.ptr, applyImpulse);
}); });
} }
@ -1016,6 +1034,7 @@ public sealed class BSPrim : BSPhysObject
DetailLog("{0},BSPrim.AddAngularForce,taint,aForce={1}", LocalID, fSum); DetailLog("{0},BSPrim.AddAngularForce,taint,aForce={1}", LocalID, fSum);
if (fSum != OMV.Vector3.Zero) if (fSum != OMV.Vector3.Zero)
{ {
if (PhysBody.HasPhysicalBody)
BulletSimAPI.ApplyTorque2(PhysBody.ptr, fSum); BulletSimAPI.ApplyTorque2(PhysBody.ptr, fSum);
_torque = fSum; _torque = fSum;
} }
@ -1030,6 +1049,7 @@ public sealed class BSPrim : BSPhysObject
OMV.Vector3 applyImpulse = impulse; OMV.Vector3 applyImpulse = impulse;
PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ApplyTorqueImpulse", delegate() PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ApplyTorqueImpulse", delegate()
{ {
if (PhysBody.HasPhysicalBody)
BulletSimAPI.ApplyTorqueImpulse2(PhysBody.ptr, applyImpulse); BulletSimAPI.ApplyTorqueImpulse2(PhysBody.ptr, applyImpulse);
}); });
} }

View File

@ -11,12 +11,14 @@ CRASHES
VEHICLES TODO LIST: VEHICLES TODO LIST:
================================================= =================================================
Neb car jiggling left and right Neb vehicle taking > 25ms of physics time!!
Happens on terrain and any other mesh object. Flat cubes are much smoother.
Vehicles (Move smoothly) Vehicles (Move smoothly)
Add vehicle collisions so IsColliding is properly reported. Add vehicle collisions so IsColliding is properly reported.
Needed for banking, limitMotorUp, movementLimiting, ... Needed for banking, limitMotorUp, movementLimiting, ...
Some vehicles should not be able to turn if no speed or off ground. Some vehicles should not be able to turn if no speed or off ground.
Neb car jiggling left and right
Happens on terrain and any other mesh object. Flat cubes are much smoother.
This has been reduced but not eliminated.
For limitMotorUp, use raycast down to find if vehicle is in the air. For limitMotorUp, use raycast down to find if vehicle is in the air.
Implement function efficiency for lineaar and angular motion. Implement function efficiency for lineaar and angular motion.
Should vehicle angular/linear movement friction happen after all the components Should vehicle angular/linear movement friction happen after all the components
@ -30,6 +32,9 @@ Border crossing with linked vehicle causes crash
BULLETSIM TODO LIST: BULLETSIM TODO LIST:
================================================= =================================================
Avatar height off after unsitting (float off ground)
Editting appearance then moving restores.
Must not be initializing height when recreating capsule after unsit.
Duplicating a physical prim causes old prim to jump away Duplicating a physical prim causes old prim to jump away
Dup a phys prim and the original become unselected and thus interacts w/ selected prim. Dup a phys prim and the original become unselected and thus interacts w/ selected prim.
Disable activity of passive linkset children. Disable activity of passive linkset children.