BulletSim: working on COM
parent
775fd6f8cc
commit
c1371ab786
|
@ -140,6 +140,25 @@ public struct EntityProperties
|
|||
public Vector3 Velocity;
|
||||
public Vector3 Acceleration;
|
||||
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
|
||||
|
|
|
@ -377,7 +377,7 @@ public sealed class BSLinksetCompound : BSLinkset
|
|||
// Constraint linksets are rebuilt every time.
|
||||
// Note that this works for rebuilding just the root after a linkset is taken apart.
|
||||
// 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()
|
||||
{
|
||||
try
|
||||
|
@ -400,8 +400,9 @@ public sealed class BSLinksetCompound : BSLinkset
|
|||
} // DEBUG DEBUG
|
||||
else
|
||||
{
|
||||
centerOfMass = ComputeLinksetGeometricCenter();
|
||||
centerDisplacement = centerOfMass - LinksetRoot.RawPosition;
|
||||
centerOfMass = ComputeLinksetCenterOfMass();
|
||||
// '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
|
||||
LinksetRoot.PositionDisplacement = centerDisplacement;
|
||||
|
|
|
@ -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.
|
||||
// A feeble attempt to keep the sim and physical positions in sync
|
||||
// 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 for being below terrain and being out of bounds.
|
||||
|
@ -371,11 +373,11 @@ public sealed class BSPrim : BSPhysObject
|
|||
return ret;
|
||||
}
|
||||
|
||||
float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position);
|
||||
float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition);
|
||||
OMV.Vector3 upForce = OMV.Vector3.Zero;
|
||||
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);
|
||||
// If the object is below ground it just has to be moved up because pushing will
|
||||
// not get it through the terrain
|
||||
|
@ -1637,7 +1639,11 @@ public sealed class BSPrim : BSPhysObject
|
|||
// 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
|
||||
|
||||
// Undo any center-of-mass displacement that might have been done.
|
||||
entprop.Position -= PositionDisplacement;
|
||||
_position = entprop.Position;
|
||||
_orientation = entprop.Rotation;
|
||||
|
@ -1645,6 +1651,8 @@ public sealed class BSPrim : BSPhysObject
|
|||
_acceleration = entprop.Acceleration;
|
||||
_rotationalVelocity = entprop.RotationalVelocity;
|
||||
|
||||
DetailLog("{0},BSPrim.UpdateProperties,afterAssign,entprop={1}", LocalID, entprop); // DEBUG DEBUG
|
||||
|
||||
// The sanity check can change the velocity and/or position.
|
||||
if (IsPhysical && PositionSanityCheck(true))
|
||||
{
|
||||
|
@ -1653,8 +1661,7 @@ public sealed class BSPrim : BSPhysObject
|
|||
}
|
||||
|
||||
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}",
|
||||
LocalID, _position, _orientation, direction, _velocity, _rotationalVelocity);
|
||||
DetailLog("{0},BSPrim.UpdateProperties,call,entProp={1},dir={2}", LocalID, entprop, direction);
|
||||
|
||||
// remember the current and last set values
|
||||
LastEntityProperties = CurrentEntityProperties;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
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)
|
||||
Vehicle angular vertical attraction
|
||||
vehicle angular banking
|
||||
|
|
Loading…
Reference in New Issue