BulletSim: Properly regenerate hulls when objects made physical.

This fixes the problem of non-base shapes (cubes and spheres)
    falling through the terrain.
integration
Robert Adams 2012-08-17 14:45:18 -07:00
parent f57c1ac386
commit 7243d4f842
2 changed files with 33 additions and 17 deletions

View File

@ -1392,14 +1392,14 @@ namespace OpenSim.Region.Framework.Scenes
else if (FlyDisabled) else if (FlyDisabled)
newFlying = false; newFlying = false;
else else
newFlying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); newFlying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
if (actor.Flying != newFlying) if (actor.Flying != newFlying)
{ {
// Note: ScenePresence.Flying is actually fetched from the physical actor // Note: ScenePresence.Flying is actually fetched from the physical actor
// so setting PhysActor.Flying here also sets the ScenePresence's value. // so setting PhysActor.Flying here also sets the ScenePresence's value.
actor.Flying = newFlying; actor.Flying = newFlying;
update_movementflag = true; update_movementflag = true;
} }
if (ParentID == 0) if (ParentID == 0)

View File

@ -481,11 +481,8 @@ public sealed class BSPrim : PhysicsActor
// No locking here because only called when it is safe // No locking here because only called when it is safe
private void SetObjectDynamic() private void SetObjectDynamic()
{ {
// RA: remove this for the moment. // If it's becoming dynamic, it will need hullness
// The problem is that dynamic objects are hulls so if we are becoming physical VerifyCorrectPhysicalShape();
// the shape has to be checked and possibly built.
// Maybe a VerifyCorrectPhysicalShape() routine?
// RecreateGeomAndObject();
// Bullet wants static objects to have a mass of zero // Bullet wants static objects to have a mass of zero
float mass = IsStatic ? 0f : _mass; float mass = IsStatic ? 0f : _mass;
@ -1214,6 +1211,27 @@ public sealed class BSPrim : PhysicsActor
return; return;
} }
private void VerifyCorrectPhysicalShape()
{
if (IsStatic)
{
// if static, we don't need a hull so, if there is one, rebuild without it
if (_hullKey != 0)
{
RecreateGeomAndObject();
}
}
else
{
// if not static, it will need a hull to efficiently collide with things
if (_hullKey == 0)
{
RecreateGeomAndObject();
}
}
}
// Create an object in Bullet if it has not already been created // Create an object in Bullet if it has not already been created
// No locking here because this is done when the physics engine is not simulating // No locking here because this is done when the physics engine is not simulating
// Returns 'true' if an object was actually created. // Returns 'true' if an object was actually created.
@ -1338,10 +1356,8 @@ public sealed class BSPrim : PhysicsActor
_acceleration = entprop.Acceleration; _acceleration = entprop.Acceleration;
_rotationalVelocity = entprop.RotationalVelocity; _rotationalVelocity = entprop.RotationalVelocity;
// m_log.DebugFormat("{0}: RequestTerseUpdate. id={1}, ch={2}, pos={3}, rot={4}, vel={5}, acc={6}, rvel={7}", DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
// LogHeader, LocalID, changed, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity);
// DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
// LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity);
base.RequestPhysicsterseUpdate(); base.RequestPhysicsterseUpdate();
} }