BulletSim: fix bug that caused error (and a crash on 32 bit Linux) when mesh assets weren't already in the cache. Comment cleanups.
parent
7272a4cae8
commit
14eeb8b31b
|
@ -34,6 +34,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
|
||||
public abstract class BSConstraint : IDisposable
|
||||
{
|
||||
private static string LogHeader = "[BULLETSIM CONSTRAINT]";
|
||||
|
||||
protected BulletSim m_world;
|
||||
protected BulletBody m_body1;
|
||||
protected BulletBody m_body2;
|
||||
|
@ -124,7 +126,7 @@ public abstract class BSConstraint : IDisposable
|
|||
}
|
||||
else
|
||||
{
|
||||
m_world.physicsScene.Logger.ErrorFormat("[BULLETSIM CONSTRAINT] CalculateTransforms failed. A={0}, B={1}", Body1.ID, Body2.ID);
|
||||
m_world.physicsScene.Logger.ErrorFormat("{0} CalculateTransforms failed. A={1}, B={2}", LogHeader, Body1.ID, Body2.ID);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
|
|
@ -464,8 +464,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
// Set the prim's inertia to zero. The vehicle code handles that and this
|
||||
// removes the motion and torque actions introduced by Bullet.
|
||||
Vector3 inertia = Vector3.Zero;
|
||||
BulletSimAPI.SetMassProps2(Prim.BSBody.ptr, Prim.MassRaw, inertia);
|
||||
BulletSimAPI.UpdateInertiaTensor2(Prim.BSBody.ptr);
|
||||
// comment out for DEBUG test
|
||||
// BulletSimAPI.SetMassProps2(Prim.BSBody.ptr, Prim.MassRaw, inertia);
|
||||
// BulletSimAPI.UpdateInertiaTensor2(Prim.BSBody.ptr);
|
||||
}
|
||||
|
||||
// One step of the vehicle properties for the next 'pTimestep' seconds.
|
||||
|
|
|
@ -165,6 +165,9 @@ public abstract class BSLinkset
|
|||
bool ret = false;
|
||||
lock (m_linksetActivityLock)
|
||||
{
|
||||
if (m_children.Contains(child))
|
||||
ret = true;
|
||||
/*
|
||||
foreach (BSPhysObject bp in m_children)
|
||||
{
|
||||
if (child.LocalID == bp.LocalID)
|
||||
|
@ -173,6 +176,7 @@ public abstract class BSLinkset
|
|||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -196,21 +200,20 @@ public abstract class BSLinkset
|
|||
// Called at taint-time!
|
||||
public abstract bool MakeStatic(BSPhysObject child);
|
||||
|
||||
// If the software is handling the movement of all the objects in a linkset
|
||||
// (like if one doesn't use constraints for static linksets), this is called
|
||||
// when an update for the root of the linkset is received.
|
||||
// Called when a parameter update comes from the physics engine for any object
|
||||
// of the linkset is received.
|
||||
// Called at taint-time!!
|
||||
public abstract void UpdateProperties(BSPhysObject physObject);
|
||||
|
||||
// Routine used when rebuilding the body of the root of the linkset
|
||||
// Destroy all the constraints have have been made to root.
|
||||
// This is called when the root body is changing.
|
||||
// Returns 'true' of something eas actually removed and would need restoring
|
||||
// Returns 'true' of something was actually removed and would need restoring
|
||||
// Called at taint-time!!
|
||||
public abstract bool RemoveBodyDependencies(BSPrim child);
|
||||
|
||||
// Companion to RemoveBodyDependencies(). If RemoveBodyDependencies() returns 'true',
|
||||
// this routine will restore the removed constraints.
|
||||
// this routine will restore the removed constraints.
|
||||
// Called at taint-time!!
|
||||
public abstract void RestoreBodyDependencies(BSPrim child);
|
||||
|
||||
|
|
|
@ -46,9 +46,8 @@ public class BSLinksetConstraints : BSLinkset
|
|||
// May be called at runtime or taint-time (just pass the appropriate flag).
|
||||
public override void Refresh(BSPhysObject requestor, bool inTaintTime)
|
||||
{
|
||||
// If there are no children, not physical or not root, I am not the one that recomputes the constraints
|
||||
// (For the moment, static linksets do create constraints so remove the test for physical.)
|
||||
if (!HasAnyChildren || /*!requestor.IsPhysical ||*/ !IsRoot(requestor))
|
||||
// If there are no children or not root, I am not the one that recomputes the constraints
|
||||
if (!HasAnyChildren || !IsRoot(requestor))
|
||||
return;
|
||||
|
||||
BSScene.TaintCallback refreshOperation = delegate()
|
||||
|
@ -85,20 +84,10 @@ public class BSLinksetConstraints : BSLinkset
|
|||
return false;
|
||||
}
|
||||
|
||||
// If the software is handling the movement of all the objects in a linkset
|
||||
// (like if one doesn't use constraints for static linksets), this is called
|
||||
// when an update for the root of the linkset is received.
|
||||
// Called at taint-time!!
|
||||
public override void UpdateProperties(BSPhysObject physObject)
|
||||
public override void UpdateProperties(BSPhysObject updated)
|
||||
{
|
||||
// The root local properties have been updated. Apply to the children if appropriate.
|
||||
if (IsRoot(physObject) && HasAnyChildren)
|
||||
{
|
||||
if (!physObject.IsPhysical)
|
||||
{
|
||||
// TODO: implement software linkset update for static object linksets
|
||||
}
|
||||
}
|
||||
// Nothing to do for constraints on property updates
|
||||
}
|
||||
|
||||
// Routine used when rebuilding the body of the root of the linkset
|
||||
|
|
|
@ -399,7 +399,7 @@ public sealed class BSPrim : BSPhysObject
|
|||
{
|
||||
// Done at taint time so we're sure the physics engine is not using the variables
|
||||
// Vehicle code changes the parameters for this vehicle type.
|
||||
this._vehicle.ProcessTypeChange(type);
|
||||
_vehicle.ProcessTypeChange(type);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1246,12 +1246,13 @@ public sealed class BSPrim : BSPhysObject
|
|||
FillShapeInfo(out shapeData);
|
||||
|
||||
// If this prim is part of a linkset, we must remove and restore the physical
|
||||
// links of the body is rebuilt.
|
||||
// links if the body is rebuilt.
|
||||
bool needToRestoreLinkset = false;
|
||||
|
||||
// Create the correct physical representation for this type of object.
|
||||
// Updates BSBody and BSShape with the new information.
|
||||
// Ignore 'forceRebuild'. This routine makes the right choices and changes of necessary.
|
||||
// Returns 'true' if either the body or the shape was changed.
|
||||
PhysicsScene.Shapes.GetBodyAndShape(false, PhysicsScene.World, this, shapeData, BaseShape,
|
||||
null, delegate(BulletBody dBody)
|
||||
{
|
||||
|
@ -1355,7 +1356,7 @@ public sealed class BSPrim : BSPhysObject
|
|||
DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
|
||||
LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity);
|
||||
|
||||
// BulletSimAPI.DumpRigidBody2(Scene.World.Ptr, BSBody.Ptr);
|
||||
BulletSimAPI.DumpRigidBody2(PhysicsScene.World.ptr, BSBody.ptr); // DEBUG DEBUG DEBUG
|
||||
|
||||
base.RequestPhysicsterseUpdate();
|
||||
}
|
||||
|
@ -1368,8 +1369,8 @@ public sealed class BSPrim : BSPhysObject
|
|||
entprop.Acceleration, entprop.RotationalVelocity);
|
||||
}
|
||||
*/
|
||||
// The linkset implimentation might want to know about this.
|
||||
|
||||
// The linkset implimentation might want to know about this.
|
||||
Linkset.UpdateProperties(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -716,6 +716,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DetailLog("{0},BSScene.ProcessTaints,doTaintException,id={1}", DetailLogZero, oneCallback.ident); // DEBUG DEBUG DEBUG
|
||||
m_log.ErrorFormat("{0}: ProcessTaints: {1}: Exception: {2}", LogHeader, oneCallback.ident, e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
{
|
||||
public class BSShapeCollection : IDisposable
|
||||
{
|
||||
// private static string LogHeader = "[BULLETSIM SHAPE COLLECTION]";
|
||||
private static string LogHeader = "[BULLETSIM SHAPE COLLECTION]";
|
||||
|
||||
protected BSScene PhysicsScene { get; set; }
|
||||
|
||||
|
@ -434,16 +434,26 @@ public class BSShapeCollection : IDisposable
|
|||
ShapeData shapeData, ShapeData.FixedShapeKey shapeKey)
|
||||
{
|
||||
BulletShape newShape;
|
||||
// Need to make sure the passed shape information is for the native type.
|
||||
ShapeData nativeShapeData = shapeData;
|
||||
nativeShapeData.Type = shapeType;
|
||||
nativeShapeData.MeshKey = (ulong)shapeKey;
|
||||
nativeShapeData.HullKey = (ulong)shapeKey;
|
||||
|
||||
if (shapeType == ShapeData.PhysicsShapeType.SHAPE_AVATAR)
|
||||
{
|
||||
newShape = new BulletShape(
|
||||
BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 1.0f, 1.0f, shapeData.Scale),
|
||||
shapeType);
|
||||
BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 1.0f, 1.0f, nativeShapeData.Scale), shapeType);
|
||||
DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", nativeShapeData.ID, nativeShapeData.Scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
newShape = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, shapeData), shapeType);
|
||||
newShape = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, nativeShapeData), shapeType);
|
||||
}
|
||||
if (newShape.ptr == IntPtr.Zero)
|
||||
{
|
||||
PhysicsScene.Logger.ErrorFormat("{0} BuildPhysicalNativeShape failed. ID={1}, shape={2}",
|
||||
LogHeader, nativeShapeData.ID, nativeShapeData.Type);
|
||||
}
|
||||
newShape.shapeKey = (System.UInt64)shapeKey;
|
||||
newShape.isNativeShape = true;
|
||||
|
@ -716,6 +726,8 @@ public class BSShapeCollection : IDisposable
|
|||
{
|
||||
prim.LastAssetBuildFailed = true;
|
||||
BSPhysObject xprim = prim;
|
||||
DetailLog("{0},BSShapeCollection.VerifyMeshCreated,fetchAsset,lID={1},lastFailed={2}",
|
||||
LogHeader, shapeData.ID.ToString("X"), prim.LastAssetBuildFailed);
|
||||
Util.FireAndForget(delegate
|
||||
{
|
||||
RequestAssetDelegate assetProvider = PhysicsScene.RequestAssetMethod;
|
||||
|
@ -732,16 +744,25 @@ public class BSShapeCollection : IDisposable
|
|||
yprim.BaseShape.SculptData = asset.Data;
|
||||
// This will cause the prim to see that the filler shape is not the right
|
||||
// one and try again to build the object.
|
||||
// No race condition with the native sphere setting since the rebuild is at taint time.
|
||||
yprim.ForceBodyShapeRebuild(false);
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (prim.LastAssetBuildFailed)
|
||||
{
|
||||
PhysicsScene.Logger.ErrorFormat("{0} Mesh failed to fetch asset. lID={1}, texture={2}",
|
||||
LogHeader, shapeData.ID, pbs.SculptTexture);
|
||||
}
|
||||
}
|
||||
|
||||
// While we figure out the real problem, stick a simple native shape on the object.
|
||||
BulletShape fillinShape =
|
||||
BuildPhysicalNativeShape(ShapeData.PhysicsShapeType.SHAPE_SPHERE, shapeData, ShapeData.FixedShapeKey.KEY_SPHERE);
|
||||
BuildPhysicalNativeShape(ShapeData.PhysicsShapeType.SHAPE_BOX, shapeData, ShapeData.FixedShapeKey.KEY_BOX);
|
||||
|
||||
return fillinShape;
|
||||
}
|
||||
|
|
|
@ -201,9 +201,7 @@ public class BSTerrainManager
|
|||
// If called with a mapInfo in m_heightMaps and there is an existing terrain body, a new
|
||||
// terrain shape is created and added to the body.
|
||||
// This call is most often used to update the heightMap and parameters of the terrain.
|
||||
// The 'doNow' boolean says whether to do all the unmanaged activities right now (like when
|
||||
// calling this routine from initialization or taint-time routines) or whether to delay
|
||||
// all the unmanaged activities to taint-time.
|
||||
// (The above does suggest that some simplification/refactoring is in order.)
|
||||
private void UpdateOrCreateTerrain(uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords, bool inTaintTime)
|
||||
{
|
||||
DetailLog("{0},BSTerrainManager.UpdateOrCreateTerrain,call,minC={1},maxC={2},inTaintTime={3}",
|
||||
|
|
Loading…
Reference in New Issue