BulletSim: fix crash when mesh asset wasn't available when meshing
the first time. Debugging added for mesh/hull asset fetch.user_profiles
parent
0378baed35
commit
ed46b42fea
|
@ -132,6 +132,7 @@ public sealed class BSShapeCollection : IDisposable
|
||||||
PrimitiveBaseShape pbs = prim.BaseShape;
|
PrimitiveBaseShape pbs = prim.BaseShape;
|
||||||
|
|
||||||
// Kludge to create the capsule for the avatar.
|
// Kludge to create the capsule for the avatar.
|
||||||
|
// TDOD: Remove/redo this when BSShapeAvatar is working!!
|
||||||
BSCharacter theChar = prim as BSCharacter;
|
BSCharacter theChar = prim as BSCharacter;
|
||||||
if (theChar != null)
|
if (theChar != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -164,6 +164,8 @@ public abstract class BSShape
|
||||||
prim.PrimAssetState = BSPhysObject.PrimAssetCondition.Failed;
|
prim.PrimAssetState = BSPhysObject.PrimAssetCondition.Failed;
|
||||||
physicsScene.Logger.WarnFormat("{0} Fetched asset would not mesh. {1}, texture={2}",
|
physicsScene.Logger.WarnFormat("{0} Fetched asset would not mesh. {1}, texture={2}",
|
||||||
LogHeader, prim.PhysObjectName, prim.BaseShape.SculptTexture);
|
LogHeader, prim.PhysObjectName, prim.BaseShape.SculptTexture);
|
||||||
|
physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,setFailed,objNam={1},tex={2}",
|
||||||
|
prim.LocalID, prim.PhysObjectName, prim.BaseShape.SculptTexture);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -174,29 +176,33 @@ public abstract class BSShape
|
||||||
&& prim.BaseShape.SculptTexture != OMV.UUID.Zero
|
&& prim.BaseShape.SculptTexture != OMV.UUID.Zero
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,fetchAsset", prim.LocalID);
|
physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,fetchAsset,objNam={1},tex={2}",
|
||||||
|
prim.LocalID, prim.PhysObjectName, prim.BaseShape.SculptTexture);
|
||||||
// Multiple requestors will know we're waiting for this asset
|
// Multiple requestors will know we're waiting for this asset
|
||||||
prim.PrimAssetState = BSPhysObject.PrimAssetCondition.Waiting;
|
prim.PrimAssetState = BSPhysObject.PrimAssetCondition.Waiting;
|
||||||
|
|
||||||
BSPhysObject xprim = prim;
|
BSPhysObject xprim = prim;
|
||||||
Util.FireAndForget(delegate
|
Util.FireAndForget(delegate
|
||||||
{
|
{
|
||||||
|
physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,inFireAndForget", xprim.LocalID);
|
||||||
RequestAssetDelegate assetProvider = physicsScene.RequestAssetMethod;
|
RequestAssetDelegate assetProvider = physicsScene.RequestAssetMethod;
|
||||||
if (assetProvider != null)
|
if (assetProvider != null)
|
||||||
{
|
{
|
||||||
BSPhysObject yprim = xprim; // probably not necessary, but, just in case.
|
BSPhysObject yprim = xprim; // probably not necessary, but, just in case.
|
||||||
assetProvider(yprim.BaseShape.SculptTexture, delegate(AssetBase asset)
|
assetProvider(yprim.BaseShape.SculptTexture, delegate(AssetBase asset)
|
||||||
{
|
{
|
||||||
|
physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,assetProviderCallback", xprim.LocalID);
|
||||||
bool assetFound = false;
|
bool assetFound = false;
|
||||||
string mismatchIDs = String.Empty; // DEBUG DEBUG
|
string mismatchIDs = String.Empty; // DEBUG DEBUG
|
||||||
if (asset != null && yprim.BaseShape.SculptEntry)
|
if (asset != null && yprim.BaseShape.SculptEntry)
|
||||||
{
|
{
|
||||||
if (yprim.BaseShape.SculptTexture.ToString() == asset.ID)
|
if (yprim.BaseShape.SculptTexture.ToString() == asset.ID)
|
||||||
{
|
{
|
||||||
yprim.BaseShape.SculptData = asset.Data;
|
yprim.BaseShape.SculptData = (byte[])asset.Data.Clone();
|
||||||
// This will cause the prim to see that the filler shape is not the right
|
// This will cause the prim to see that the filler shape is not the right
|
||||||
// one and try again to build the object.
|
// one and try again to build the object.
|
||||||
// No race condition with the normal shape setting since the rebuild is at taint time.
|
// No race condition with the normal shape setting since the rebuild is at taint time.
|
||||||
|
yprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Fetched;
|
||||||
yprim.ForceBodyShapeRebuild(false /* inTaintTime */);
|
yprim.ForceBodyShapeRebuild(false /* inTaintTime */);
|
||||||
assetFound = true;
|
assetFound = true;
|
||||||
}
|
}
|
||||||
|
@ -205,11 +211,11 @@ public abstract class BSShape
|
||||||
mismatchIDs = yprim.BaseShape.SculptTexture.ToString() + "/" + asset.ID;
|
mismatchIDs = yprim.BaseShape.SculptTexture.ToString() + "/" + asset.ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (assetFound)
|
if (!assetFound)
|
||||||
yprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Fetched;
|
{
|
||||||
else
|
|
||||||
yprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Failed;
|
yprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Failed;
|
||||||
physicsScene.DetailLog("{0},BSShape,fetchAssetCallback,found={1},isSculpt={2},ids={3}",
|
}
|
||||||
|
physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,fetchAssetCallback,found={1},isSculpt={2},ids={3}",
|
||||||
yprim.LocalID, assetFound, yprim.BaseShape.SculptEntry, mismatchIDs );
|
yprim.LocalID, assetFound, yprim.BaseShape.SculptEntry, mismatchIDs );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -227,6 +233,8 @@ public abstract class BSShape
|
||||||
{
|
{
|
||||||
physicsScene.Logger.WarnFormat("{0} Mesh failed to fetch asset. obj={1}, texture={2}",
|
physicsScene.Logger.WarnFormat("{0} Mesh failed to fetch asset. obj={1}, texture={2}",
|
||||||
LogHeader, prim.PhysObjectName, prim.BaseShape.SculptTexture);
|
LogHeader, prim.PhysObjectName, prim.BaseShape.SculptTexture);
|
||||||
|
physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,wasFailed,objNam={1},tex={2}",
|
||||||
|
prim.LocalID, prim.PhysObjectName, prim.BaseShape.SculptTexture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,7 +367,7 @@ public class BSShapeMesh : BSShape
|
||||||
|
|
||||||
// Check to see if mesh was created (might require an asset).
|
// Check to see if mesh was created (might require an asset).
|
||||||
newShape = VerifyMeshCreated(physicsScene, newShape, prim);
|
newShape = VerifyMeshCreated(physicsScene, newShape, prim);
|
||||||
if (newShape.shapeType == BSPhysicsShapeType.SHAPE_MESH)
|
if (!newShape.isNativeShape)
|
||||||
{
|
{
|
||||||
// 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.
|
||||||
Meshes.Add(newMeshKey, retMesh);
|
Meshes.Add(newMeshKey, retMesh);
|
||||||
|
@ -408,7 +416,7 @@ public class BSShapeMesh : BSShape
|
||||||
private BulletShape CreatePhysicalMesh(BSScene physicsScene, BSPhysObject prim, System.UInt64 newMeshKey,
|
private BulletShape CreatePhysicalMesh(BSScene physicsScene, BSPhysObject prim, System.UInt64 newMeshKey,
|
||||||
PrimitiveBaseShape pbs, OMV.Vector3 size, float lod)
|
PrimitiveBaseShape pbs, OMV.Vector3 size, float lod)
|
||||||
{
|
{
|
||||||
BulletShape newShape = null;
|
BulletShape newShape = new BulletShape();
|
||||||
|
|
||||||
IMesh meshData = physicsScene.mesher.CreateMesh(prim.PhysObjectName, pbs, size, lod,
|
IMesh meshData = physicsScene.mesher.CreateMesh(prim.PhysObjectName, pbs, size, lod,
|
||||||
false, // say it is not physical so a bounding box is not built
|
false, // say it is not physical so a bounding box is not built
|
||||||
|
@ -507,7 +515,7 @@ public class BSShapeHull : BSShape
|
||||||
|
|
||||||
// Check to see if hull was created (might require an asset).
|
// Check to see if hull was created (might require an asset).
|
||||||
newShape = VerifyMeshCreated(physicsScene, newShape, prim);
|
newShape = VerifyMeshCreated(physicsScene, newShape, prim);
|
||||||
if (newShape.shapeType == BSPhysicsShapeType.SHAPE_HULL)
|
if (!newShape.isNativeShape)
|
||||||
{
|
{
|
||||||
// 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);
|
||||||
|
@ -731,7 +739,7 @@ public class BSShapeCompound : BSShape
|
||||||
{
|
{
|
||||||
lock (physShapeInfo)
|
lock (physShapeInfo)
|
||||||
{
|
{
|
||||||
Dereference(physicsScene);
|
this.DecrementReference();
|
||||||
if (referenceCount <= 0)
|
if (referenceCount <= 0)
|
||||||
{
|
{
|
||||||
if (!physicsScene.PE.IsCompound(physShapeInfo))
|
if (!physicsScene.PE.IsCompound(physShapeInfo))
|
||||||
|
|
Loading…
Reference in New Issue