BulletSim: Use full linkset mass when computing vehicle gravity force. Add taint-time specification to new AddForce().
parent
919569f6ec
commit
3a458e2a36
|
@ -462,7 +462,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
return;
|
||||
|
||||
// Set the prim's inertia to zero. The vehicle code handles that and this
|
||||
// removes the torque action introduced by Bullet.
|
||||
// removes the motion and torque actions introduced by Bullet.
|
||||
Vector3 inertia = Vector3.Zero;
|
||||
BulletSimAPI.SetMassProps2(Prim.BSBody.ptr, Prim.MassRaw, inertia);
|
||||
BulletSimAPI.UpdateInertiaTensor2(Prim.BSBody.ptr);
|
||||
|
@ -540,7 +540,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
// add Gravity and Buoyancy
|
||||
// There is some gravity, make a gravity force vector that is applied after object velocity.
|
||||
// m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g;
|
||||
Vector3 grav = Prim.PhysicsScene.DefaultGravity * (Prim.MassRaw * (1f - m_VehicleBuoyancy));
|
||||
Vector3 grav = Prim.PhysicsScene.DefaultGravity * (Prim.Linkset.LinksetMass * (1f - m_VehicleBuoyancy));
|
||||
|
||||
/*
|
||||
* RA: Not sure why one would do this
|
||||
|
@ -681,7 +681,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
Prim.ForceVelocity = m_newVelocity;
|
||||
// apply gravity force
|
||||
// Why is this set here? The physics engine already does gravity.
|
||||
Prim.AddForce(grav, false);
|
||||
Prim.AddForce(grav, false, true);
|
||||
|
||||
// Apply friction
|
||||
Vector3 keepFraction = Vector3.One - (Vector3.One / (m_linearFrictionTimescale / pTimestep));
|
||||
|
|
|
@ -165,13 +165,11 @@ public class BSLinkset
|
|||
// May be called at runtime or taint-time (just pass the appropriate flag).
|
||||
public void Refresh(BSPhysObject requestor, bool inTaintTime)
|
||||
{
|
||||
// If there are no children, there can't be any constraints to recompute
|
||||
if (!HasAnyChildren)
|
||||
// If there are no children, not physical or not root, I am not the one that recomputes the constraints
|
||||
// (For the moment, static linksets do create constraints so remove the test for physical.)
|
||||
if (!HasAnyChildren || /*!requestor.IsPhysical ||*/ !IsRoot(requestor))
|
||||
return;
|
||||
|
||||
// Only the root does the recomputation
|
||||
if (IsRoot(requestor))
|
||||
{
|
||||
BSScene.TaintCallback refreshOperation = delegate()
|
||||
{
|
||||
RecomputeLinksetConstraintVariables();
|
||||
|
@ -183,7 +181,6 @@ public class BSLinkset
|
|||
else
|
||||
PhysicsScene.TaintedObject("BSLinkSet.Refresh", refreshOperation);
|
||||
}
|
||||
}
|
||||
|
||||
// The object is going dynamic (physical). Do any setup necessary
|
||||
// for a dynamic linkset.
|
||||
|
|
|
@ -855,6 +855,9 @@ public sealed class BSPrim : BSPhysObject
|
|||
|
||||
private List<OMV.Vector3> m_accumulatedForces = new List<OMV.Vector3>();
|
||||
public override void AddForce(OMV.Vector3 force, bool pushforce) {
|
||||
AddForce(force, pushforce, false);
|
||||
}
|
||||
public void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) {
|
||||
// for an object, doesn't matter if force is a pushforce or not
|
||||
if (force.IsFinite())
|
||||
{
|
||||
|
@ -867,11 +870,12 @@ public sealed class BSPrim : BSPhysObject
|
|||
m_log.WarnFormat("{0}: Got a NaN force applied to a prim. LocalID={1}", LogHeader, LocalID);
|
||||
return;
|
||||
}
|
||||
PhysicsScene.TaintedObject("BSPrim.AddForce", delegate()
|
||||
BSScene.TaintCallback addForceOperation = delegate()
|
||||
{
|
||||
OMV.Vector3 fSum = OMV.Vector3.Zero;
|
||||
lock (m_accumulatedForces)
|
||||
{
|
||||
// Sum the accumulated additional forces for one big force to apply once.
|
||||
foreach (OMV.Vector3 v in m_accumulatedForces)
|
||||
{
|
||||
fSum += v;
|
||||
|
@ -881,7 +885,11 @@ public sealed class BSPrim : BSPhysObject
|
|||
// DetailLog("{0},BSPrim.AddObjectForce,taint,force={1}", LocalID, fSum);
|
||||
// For unknown reasons, "ApplyCentralForce" adds this force to the total force on the object.
|
||||
BulletSimAPI.ApplyCentralForce2(BSBody.ptr, fSum);
|
||||
});
|
||||
};
|
||||
if (inTaintTime)
|
||||
addForceOperation();
|
||||
else
|
||||
PhysicsScene.TaintedObject("BSPrim.AddForce", addForceOperation);
|
||||
}
|
||||
|
||||
public override void AddAngularForce(OMV.Vector3 force, bool pushforce) {
|
||||
|
|
Loading…
Reference in New Issue