BulletSim: zero vehicle motion when changing vehicle type.

Rebuild compound linkset of any child in the linkset changes shape.
Comments and better detailed logging messages.
user_profiles
Robert Adams 2013-05-03 14:23:53 -07:00
parent 4042c82a72
commit 5d25bb3084
6 changed files with 18 additions and 26 deletions

View File

@ -559,9 +559,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin
break; break;
} }
// Update any physical parameters based on this type.
Refresh();
m_linearMotor = new BSVMotor("LinearMotor", m_linearMotorTimescale, m_linearMotor = new BSVMotor("LinearMotor", m_linearMotorTimescale,
m_linearMotorDecayTimescale, m_linearFrictionTimescale, m_linearMotorDecayTimescale, m_linearFrictionTimescale,
1f); 1f);
@ -589,6 +586,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
{ {
RegisterForSceneEvents(); RegisterForSceneEvents();
} }
// Update any physical parameters based on this type.
Refresh();
} }
#endregion // Vehicle parameter setting #endregion // Vehicle parameter setting

View File

@ -246,7 +246,8 @@ public sealed class BSLinksetCompound : BSLinkset
} }
// Routine called when rebuilding the body of some member of the linkset. // Routine called when rebuilding the body of some member of the linkset.
// Since we don't keep in world relationships, do nothing unless it's a child changing. // If one of the bodies is being changed, the linkset needs rebuilding.
// For instance, a linkset is built and then a mesh asset is read in and the mesh is recreated.
// Returns 'true' of something was actually removed and would need restoring // Returns 'true' of something was actually removed and would need restoring
// Called at taint-time!! // Called at taint-time!!
public override bool RemoveDependencies(BSPrimLinkable child) public override bool RemoveDependencies(BSPrimLinkable child)
@ -256,14 +257,7 @@ public sealed class BSLinksetCompound : BSLinkset
DetailLog("{0},BSLinksetCompound.RemoveBodyDependencies,refreshIfChild,rID={1},rBody={2},isRoot={3}", DetailLog("{0},BSLinksetCompound.RemoveBodyDependencies,refreshIfChild,rID={1},rBody={2},isRoot={3}",
child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody, IsRoot(child)); child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody, IsRoot(child));
if (!IsRoot(child)) ScheduleRebuild(child);
{
child.LinksetInfo = null;
}
// Cannot schedule a refresh/rebuild here because this routine is called when
// the linkset is being rebuilt.
// InternalRefresh(LinksetRoot);
return ret; return ret;
} }
@ -322,7 +316,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 UseBulletSimRootOffsetHack = false; private bool UseBulletSimRootOffsetHack = false; // Attempt to have Bullet track the coords of root compound shape
private bool disableCOM = true; // For basic linkset debugging, turn off the center-of-mass setting private bool disableCOM = true; // For basic linkset debugging, turn off the center-of-mass setting
private void RecomputeLinksetCompound() private void RecomputeLinksetCompound()
{ {
@ -382,7 +376,7 @@ public sealed class BSLinksetCompound : BSLinkset
OMV.Quaternion offsetRot = cPrim.RawOrientation * invRootOrientation; OMV.Quaternion offsetRot = cPrim.RawOrientation * invRootOrientation;
m_physicsScene.PE.AddChildShapeToCompoundShape(linksetShape.physShapeInfo, childShape.physShapeInfo, offsetPos, offsetRot); m_physicsScene.PE.AddChildShapeToCompoundShape(linksetShape.physShapeInfo, childShape.physShapeInfo, offsetPos, offsetRot);
DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addChild,indx={1},cShape={2},offPos={3},offRot={4}", DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addChild,indx={1},cShape={2},offPos={3},offRot={4}",
LinksetRoot.LocalID, memberIndex, cPrim.PhysShape, offsetPos, offsetRot); LinksetRoot.LocalID, memberIndex, childShape, offsetPos, offsetRot);
// Since we are borrowing the shape of the child, disable the origional child body // Since we are borrowing the shape of the child, disable the origional child body
if (!IsRoot(cPrim)) if (!IsRoot(cPrim))

View File

@ -511,7 +511,7 @@ public class BSPrim : BSPhysObject
PhysScene.TaintedObject("setVehicleType", delegate() PhysScene.TaintedObject("setVehicleType", delegate()
{ {
// Vehicle code changes the parameters for this vehicle type. ZeroMotion(true /* inTaintTime */);
VehicleActor.ProcessTypeChange(type); VehicleActor.ProcessTypeChange(type);
ActivateIfPhysical(false); ActivateIfPhysical(false);
}); });

View File

@ -182,6 +182,10 @@ public class BSPrimLinkable : BSPrimDisplaced
{ {
return false; return false;
} }
// TODO: handle collisions of other objects with with children of linkset.
// This is a problem for LinksetCompound since the children are packed into the root.
return base.Collide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth); return base.Collide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth);
} }
} }

View File

@ -254,10 +254,10 @@ public sealed class BSShapeCollection : IDisposable
} }
else else
{ {
// The current shape on the prim is the correct one. We don't need the potential reference.
potentialHull.Dereference(m_physicsScene); potentialHull.Dereference(m_physicsScene);
} }
if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,hull,shape={1},key={2}", if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,hull,shape={1}", prim.LocalID, prim.PhysShape);
prim.LocalID, prim.PhysShape, prim.PhysShape.physShapeInfo.shapeKey.ToString("X"));
} }
else else
{ {
@ -277,8 +277,7 @@ public sealed class BSShapeCollection : IDisposable
// We don't need this reference to the mesh that is already being using. // We don't need this reference to the mesh that is already being using.
potentialMesh.Dereference(m_physicsScene); potentialMesh.Dereference(m_physicsScene);
} }
if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,mesh,shape={1},key={2}", if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,mesh,shape={1}", prim.LocalID, prim.PhysShape);
prim.LocalID, prim.PhysShape, prim.PhysShape.physShapeInfo.shapeKey.ToString("X"));
} }
return ret; return ret;
} }

View File

@ -352,9 +352,6 @@ public class BSShapeMesh : BSShape
float lod; float lod;
System.UInt64 newMeshKey = BSShape.ComputeShapeKey(prim.Size, prim.BaseShape, out lod); System.UInt64 newMeshKey = BSShape.ComputeShapeKey(prim.Size, prim.BaseShape, out lod);
physicsScene.DetailLog("{0},BSShapeMesh,getReference,newKey={1},size={2},lod={3}",
prim.LocalID, newMeshKey.ToString("X"), prim.Size, lod);
BSShapeMesh retMesh = null; BSShapeMesh retMesh = null;
lock (Meshes) lock (Meshes)
{ {
@ -380,6 +377,7 @@ public class BSShapeMesh : BSShape
retMesh.physShapeInfo = newShape; retMesh.physShapeInfo = newShape;
} }
} }
physicsScene.DetailLog("{0},BSShapeMesh,getReference,mesh={1},size={2},lod={3}", prim.LocalID, retMesh, prim.Size, lod);
return retMesh; return retMesh;
} }
public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim) public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim)
@ -507,9 +505,6 @@ public class BSShapeHull : BSShape
float lod; float lod;
System.UInt64 newHullKey = BSShape.ComputeShapeKey(prim.Size, prim.BaseShape, out lod); System.UInt64 newHullKey = BSShape.ComputeShapeKey(prim.Size, prim.BaseShape, out lod);
physicsScene.DetailLog("{0},BSShapeHull,getReference,newKey={1},size={2},lod={3}",
prim.LocalID, newHullKey.ToString("X"), prim.Size, lod);
BSShapeHull retHull = null; BSShapeHull retHull = null;
lock (Hulls) lock (Hulls)
{ {
@ -531,10 +526,10 @@ public class BSShapeHull : BSShape
// If a mesh was what was created, remember the built shape for later sharing. // If a mesh was what was created, remember the built shape for later sharing.
Hulls.Add(newHullKey, retHull); Hulls.Add(newHullKey, retHull);
} }
retHull.physShapeInfo = newShape; retHull.physShapeInfo = newShape;
} }
} }
physicsScene.DetailLog("{0},BSShapeHull,getReference,hull={1},size={2},lod={3}", prim.LocalID, retHull, prim.Size, lod);
return retHull; return retHull;
} }
public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim) public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim)