BulletSim: working on COM

user_profiles
Robert Adams 2013-01-23 08:28:36 -08:00
parent 775fd6f8cc
commit c1371ab786
4 changed files with 36 additions and 7 deletions

View File

@ -140,6 +140,25 @@ public struct EntityProperties
public Vector3 Velocity; public Vector3 Velocity;
public Vector3 Acceleration; public Vector3 Acceleration;
public Vector3 RotationalVelocity; public Vector3 RotationalVelocity;
public override string ToString()
{
StringBuilder buff = new StringBuilder();
buff.Append("<i=");
buff.Append(ID.ToString());
buff.Append(",p=");
buff.Append(Position.ToString());
buff.Append(",r=");
buff.Append(Rotation.ToString());
buff.Append(",v=");
buff.Append(Velocity.ToString());
buff.Append(",a=");
buff.Append(Acceleration.ToString());
buff.Append(",rv=");
buff.Append(RotationalVelocity.ToString());
buff.Append(">");
return buff.ToString();
}
} }
// Format of this structure must match the definition in the C++ code // Format of this structure must match the definition in the C++ code

View File

@ -377,7 +377,7 @@ public sealed class BSLinksetCompound : BSLinkset
// Constraint linksets are rebuilt every time. // Constraint linksets are rebuilt every time.
// Note that this works for rebuilding just the root after a linkset is taken apart. // Note that this works for rebuilding just the root after a linkset is taken apart.
// Called at taint time!! // Called at taint time!!
private bool disableCOM = true; // disable until we get this debugged private bool disableCOM = false; // disable until we get this debugged
private void RecomputeLinksetCompound() private void RecomputeLinksetCompound()
{ {
try try
@ -400,8 +400,9 @@ public sealed class BSLinksetCompound : BSLinkset
} // DEBUG DEBUG } // DEBUG DEBUG
else else
{ {
centerOfMass = ComputeLinksetGeometricCenter(); centerOfMass = ComputeLinksetCenterOfMass();
centerDisplacement = centerOfMass - LinksetRoot.RawPosition; // 'centerDisplacement' is the value to *add* to all the shape offsets
centerDisplacement = LinksetRoot.RawPosition - centerOfMass;
// Since we're displacing the center of the shape, we need to move the body in the world // Since we're displacing the center of the shape, we need to move the body in the world
LinksetRoot.PositionDisplacement = centerDisplacement; LinksetRoot.PositionDisplacement = centerDisplacement;

View File

@ -336,6 +336,7 @@ public sealed class BSPrim : BSPhysObject
} }
} }
} }
/* Disable. Presume whoever is setting displacement is already adjusting position, etc.
// Override to have position displacement immediately update the physical position. // Override to have position displacement immediately update the physical position.
// A feeble attempt to keep the sim and physical positions in sync // A feeble attempt to keep the sim and physical positions in sync
// Must be called at taint time. // Must be called at taint time.
@ -355,6 +356,7 @@ public sealed class BSPrim : BSPhysObject
}); });
} }
} }
*/
// Check that the current position is sane and, if not, modify the position to make it so. // Check that the current position is sane and, if not, modify the position to make it so.
// Check for being below terrain and being out of bounds. // Check for being below terrain and being out of bounds.
@ -371,11 +373,11 @@ public sealed class BSPrim : BSPhysObject
return ret; return ret;
} }
float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position); float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition);
OMV.Vector3 upForce = OMV.Vector3.Zero; OMV.Vector3 upForce = OMV.Vector3.Zero;
if (RawPosition.Z < terrainHeight) if (RawPosition.Z < terrainHeight)
{ {
DetailLog("{0},BSPrim.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, _position, terrainHeight); DetailLog("{0},BSPrim.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, RawPosition, terrainHeight);
float targetHeight = terrainHeight + (Size.Z / 2f); float targetHeight = terrainHeight + (Size.Z / 2f);
// If the object is below ground it just has to be moved up because pushing will // If the object is below ground it just has to be moved up because pushing will
// not get it through the terrain // not get it through the terrain
@ -1637,7 +1639,11 @@ public sealed class BSPrim : BSPhysObject
// entprop.RotationalVelocity = OMV.Vector3.Zero; // entprop.RotationalVelocity = OMV.Vector3.Zero;
} }
DetailLog("{0},BSPrim.UpdateProperties,entry,entprop={1}", LocalID, entprop); // DEBUG DEBUG
// Assign directly to the local variables so the normal set actions do not happen // Assign directly to the local variables so the normal set actions do not happen
// Undo any center-of-mass displacement that might have been done.
entprop.Position -= PositionDisplacement; entprop.Position -= PositionDisplacement;
_position = entprop.Position; _position = entprop.Position;
_orientation = entprop.Rotation; _orientation = entprop.Rotation;
@ -1645,6 +1651,8 @@ public sealed class BSPrim : BSPhysObject
_acceleration = entprop.Acceleration; _acceleration = entprop.Acceleration;
_rotationalVelocity = entprop.RotationalVelocity; _rotationalVelocity = entprop.RotationalVelocity;
DetailLog("{0},BSPrim.UpdateProperties,afterAssign,entprop={1}", LocalID, entprop); // DEBUG DEBUG
// The sanity check can change the velocity and/or position. // The sanity check can change the velocity and/or position.
if (IsPhysical && PositionSanityCheck(true)) if (IsPhysical && PositionSanityCheck(true))
{ {
@ -1653,8 +1661,7 @@ public sealed class BSPrim : BSPhysObject
} }
OMV.Vector3 direction = OMV.Vector3.UnitX * _orientation; // DEBUG DEBUG DEBUG OMV.Vector3 direction = OMV.Vector3.UnitX * _orientation; // DEBUG DEBUG DEBUG
DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},dir={3},vel={4},rotVel={5}", DetailLog("{0},BSPrim.UpdateProperties,call,entProp={1},dir={2}", LocalID, entprop, direction);
LocalID, _position, _orientation, direction, _velocity, _rotationalVelocity);
// remember the current and last set values // remember the current and last set values
LastEntityProperties = CurrentEntityProperties; LastEntityProperties = CurrentEntityProperties;

View File

@ -1,5 +1,7 @@
CURRENT PRIORITIES CURRENT PRIORITIES
================================================= =================================================
Deleting a linkset while standing on the root will leave the physical shape of the root behind.
Not sure if it is because standing on it. Done with large prim linksets.
Child movement in linkset (don't rebuild linkset) Child movement in linkset (don't rebuild linkset)
Vehicle angular vertical attraction Vehicle angular vertical attraction
vehicle angular banking vehicle angular banking