BulletSim: make sure vehicle physical properties are set when going

physical by delaying setting until pre-step time. Change vehicle.Refresh()
to schedule the pre-step setting.
Comments and updating of TODO list.
user_profiles
Robert Adams 2013-01-31 10:26:53 -08:00
parent 371449db2f
commit ed71c939fc
5 changed files with 35 additions and 46 deletions

View File

@ -581,9 +581,18 @@ namespace OpenSim.Region.Physics.BulletSPlugin
}
#endregion // Vehicle parameter setting
public void Refresh()
{
// If asking for a refresh, reset the physical parameters before the next simulation step.
PhysicsScene.PostTaintObject("BSDynamics.Refresh", Prim.LocalID, delegate()
{
SetPhysicalParameters();
});
}
// Some of the properties of this prim may have changed.
// Do any updating needed for a vehicle
public void Refresh()
private void SetPhysicalParameters()
{
if (IsActive)
{
@ -614,7 +623,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
// The actual vehicle gravity is set to zero in Bullet so we can do all the application of same.
PhysicsScene.PE.SetGravity(Prim.PhysBody, Vector3.Zero);
VDetailLog("{0},BSDynamics.Refresh,mass={1},inert={2},grav={3},aDamp={4},frict={5},rest={6},lFact={7},aFact={8}",
VDetailLog("{0},BSDynamics.SetPhysicalParameters,mass={1},inert={2},vehGrav={3},aDamp={4},frict={5},rest={6},lFact={7},aFact={8}",
Prim.LocalID, m_vehicleMass, Prim.Inertia, m_VehicleGravity,
BSParam.VehicleAngularDamping, BSParam.VehicleFriction, BSParam.VehicleRestitution,
BSParam.VehicleLinearFactor, BSParam.VehicleAngularFactor
@ -622,26 +631,15 @@ namespace OpenSim.Region.Physics.BulletSPlugin
}
else
{
PhysicsScene.PE.RemoveFromCollisionFlags(Prim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS);
if (Prim.PhysBody.HasPhysicalBody)
PhysicsScene.PE.RemoveFromCollisionFlags(Prim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS);
}
}
public bool RemoveBodyDependencies(BSPhysObject prim)
{
// If active, we need to add our properties back when the body is rebuilt.
return IsActive;
}
public void RestoreBodyDependencies(BSPhysObject prim)
{
if (Prim.LocalID != prim.LocalID)
{
// The call should be on us by our prim. Error if not.
PhysicsScene.Logger.ErrorFormat("{0} RestoreBodyDependencies: called by not my prim. passedLocalID={1}, vehiclePrimLocalID={2}",
LogHeader, prim.LocalID, Prim.LocalID);
return;
}
Refresh();
return IsActive;
}
#region Known vehicle value functions

View File

@ -274,7 +274,7 @@ public sealed class BSLinksetCompound : BSLinkset
bool ret = false;
DetailLog("{0},BSLinksetCompound.RemoveBodyDependencies,refreshIfChild,rID={1},rBody={2},isRoot={3}",
child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString, IsRoot(child));
child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody, IsRoot(child));
if (!IsRoot(child))
{
@ -382,11 +382,11 @@ public sealed class BSLinksetCompound : BSLinkset
{
try
{
// Suppress rebuilding while rebuilding
// Suppress rebuilding while rebuilding. (We know rebuilding is on only one thread.)
Rebuilding = true;
// Cause the root shape to be rebuilt as a compound object with just the root in it
LinksetRoot.ForceBodyShapeRebuild(true);
LinksetRoot.ForceBodyShapeRebuild(true /* inTaintTime */);
// The center of mass for the linkset is the geometric center of the group.
// Compute a displacement for each component so it is relative to the center-of-mass.

View File

@ -1597,9 +1597,9 @@ public sealed class BSPrim : BSPhysObject
public void CreateGeomAndObject(bool forceRebuild)
{
// Create the correct physical representation for this type of object.
// Updates PhysBody and PhysShape with the new information.
// Updates base.PhysBody and base.PhysShape with the new information.
// Ignore 'forceRebuild'. This routine makes the right choices and changes of necessary.
PhysicsScene.Shapes.GetBodyAndShape(false, PhysicsScene.World, this, null, delegate(BulletBody dBody)
PhysicsScene.Shapes.GetBodyAndShape(false /*forceRebuild */, PhysicsScene.World, this, null, delegate(BulletBody dBody)
{
// Called if the current prim body is about to be destroyed.
// Remove all the physical dependencies on the old body.

View File

@ -116,8 +116,7 @@ public sealed class BSShapeCollection : IDisposable
// rebuild the body around it.
// Updates prim.BSBody with information/pointers to requested body
// Returns 'true' if BSBody was changed.
bool newBody = CreateBody((newGeom || forceRebuild), prim, PhysicsScene.World,
prim.PhysShape, bodyCallback);
bool newBody = CreateBody((newGeom || forceRebuild), prim, PhysicsScene.World, bodyCallback);
ret = newGeom || newBody;
}
DetailLog("{0},BSShapeCollection.GetBodyAndShape,taintExit,force={1},ret={2},body={3},shape={4}",
@ -933,8 +932,7 @@ public sealed class BSShapeCollection : IDisposable
// Updates prim.BSBody with the information about the new body if one is created.
// Returns 'true' if an object was actually created.
// Called at taint-time.
private bool CreateBody(bool forceRebuild, BSPhysObject prim, BulletWorld sim, BulletShape shape,
BodyDestructionCallback bodyCallback)
private bool CreateBody(bool forceRebuild, BSPhysObject prim, BulletWorld sim, BodyDestructionCallback bodyCallback)
{
bool ret = false;
@ -951,6 +949,7 @@ public sealed class BSShapeCollection : IDisposable
{
// If the collisionObject is not the correct type for solidness, rebuild what's there
mustRebuild = true;
if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,forceRebuildBecauseChangingBodyType,bodyType={1}", prim.LocalID, bodyType);
}
}
@ -962,12 +961,12 @@ public sealed class BSShapeCollection : IDisposable
BulletBody aBody;
if (prim.IsSolid)
{
aBody = PhysicsScene.PE.CreateBodyFromShape(sim, shape, prim.LocalID, prim.RawPosition, prim.RawOrientation);
aBody = PhysicsScene.PE.CreateBodyFromShape(sim, prim.PhysShape, prim.LocalID, prim.RawPosition, prim.RawOrientation);
if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,mesh,body={1}", prim.LocalID, aBody);
}
else
{
aBody = PhysicsScene.PE.CreateGhostFromShape(sim, shape, prim.LocalID, prim.RawPosition, prim.RawOrientation);
aBody = PhysicsScene.PE.CreateGhostFromShape(sim, prim.PhysShape, prim.LocalID, prim.RawPosition, prim.RawOrientation);
if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,ghost,body={1}", prim.LocalID, aBody);
}

View File

@ -6,6 +6,7 @@ One sided meshes? Should terrain be built into a closed shape?
Ref: http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4869
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.
Terrain detail: double terrain mesh detail
Vehicle angular vertical attraction
vehicle angular banking
Center-of-gravity
@ -34,34 +35,20 @@ Vehicle script tuning/debugging
Weapon shooter script
Add material densities to the material types
CRASHES
=================================================
Crazyness during 20130115 office hours was PositionAdjustUnderground for both char and prim
m1:logs/20130115.0934/physics-BulletSim-20130115083613.log
Creation of Neb's terrain made the terrain "disappear". Everything started to fall
and then get restored to be above terrain.
20121129.1411: editting/moving phys object across region boundries causes crash
getPos-> btRigidBody::upcast -> getBodyType -> BOOM
20121128.1600: mesh object not rezzing (no physics mesh).
Causes many errors. Doesn't stop after first error with box shape.
Eventually crashes when deleting the object.
20121206.1434: rez Sam-pan into OSGrid BulletSim11 region
Immediate simulator crash. Mono does not output any stacktrace and
log just stops after reporting taint-time linking of the linkset.
VEHICLES TODO LIST:
=================================================
Border crossing with linked vehicle causes crash
20121129.1411: editting/moving phys object across region boundries causes crash
getPos-> btRigidBody::upcast -> getBodyType -> BOOM
Vehicles (Move smoothly)
Some vehicles should not be able to turn if no speed or off ground.
What to do if vehicle and prim buoyancy differ?
Cannot edit/move a vehicle being ridden: it jumps back to the origional position.
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.
Implement referenceFrame for all the motion routines.
For limitMotorUp, use raycast down to find if vehicle is in the air.
Angular motion around Z moves the vehicle in world Z and not vehicle Z in ODE.
Verify that angular motion specified around Z moves in the vehicle coordinates.
Verify llGetVel() is returning a smooth and good value for vehicle movement.
llGetVel() should return the root's velocity if requested in a child prim.
Implement function efficiency for lineaar and angular motion.
@ -73,10 +60,11 @@ Remove vehicle angular velocity zeroing in BSPrim.UpdateProperties().
Incorporate inter-relationship of angular corrections. For instance, angularDeflection
and angularMotorUp will compute same X or Y correction. When added together
creates over-correction and over-shoot and wabbling.
Vehicle attributes are not restored when a vehicle is rezzed on region creation
Create vehicle, setup vehicle properties, restart region, vehicle is not reinitialized.
GENERAL TODO LIST:
=================================================
Avatar standing on a moving object should start to move with the object.
llMoveToTarget objects are not effected by gravity until target is removed.
Compute CCD parameters based on body size
Can solver iterations be changed per body/shape? Can be for constraints but what
@ -330,4 +318,8 @@ Boats float low in the water (DONE)
Boats floating at proper level (DONE)
When is force introduced by SetForce removed? The prestep action could go forever. (DONE)
(Resolution: setForce registers a prestep action which keeps applying the force)
Child movement in linkset (don't rebuild linkset) (DONE 20130122))
Child movement in linkset (don't rebuild linkset) (DONE 20130122))
Avatar standing on a moving object should start to move with the object. (DONE 20130125)
Angular motion around Z moves the vehicle in world Z and not vehicle Z in ODE.
Verify that angular motion specified around Z moves in the vehicle coordinates.
DONE 20130120: BulletSim properly applies force in vehicle relative coordinates.