diff options
author | Robert Adams | 2013-05-01 17:16:46 -0700 |
---|---|---|
committer | Robert Adams | 2013-05-01 17:16:46 -0700 |
commit | ed46b42feae4659653ba54a9290dddede6f24f2e (patch) | |
tree | a00f35b1fedde0e8db38fb479f57b99977ed3941 /OpenSim | |
parent | BulletSim: rework LinksetCompound to work with new BSShape system. (diff) | |
download | opensim-SC_OLD-ed46b42feae4659653ba54a9290dddede6f24f2e.zip opensim-SC_OLD-ed46b42feae4659653ba54a9290dddede6f24f2e.tar.gz opensim-SC_OLD-ed46b42feae4659653ba54a9290dddede6f24f2e.tar.bz2 opensim-SC_OLD-ed46b42feae4659653ba54a9290dddede6f24f2e.tar.xz |
BulletSim: fix crash when mesh asset wasn't available when meshing
the first time.
Debugging added for mesh/hull asset fetch.
Diffstat (limited to 'OpenSim')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | 1 | ||||
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs | 28 |
2 files changed, 19 insertions, 10 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs index 19855da..a4250be 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | |||
@@ -132,6 +132,7 @@ public sealed class BSShapeCollection : IDisposable | |||
132 | PrimitiveBaseShape pbs = prim.BaseShape; | 132 | PrimitiveBaseShape pbs = prim.BaseShape; |
133 | 133 | ||
134 | // Kludge to create the capsule for the avatar. | 134 | // Kludge to create the capsule for the avatar. |
135 | // TDOD: Remove/redo this when BSShapeAvatar is working!! | ||
135 | BSCharacter theChar = prim as BSCharacter; | 136 | BSCharacter theChar = prim as BSCharacter; |
136 | if (theChar != null) | 137 | if (theChar != null) |
137 | { | 138 | { |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs index 3faa484..2962249 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs | |||
@@ -164,6 +164,8 @@ public abstract class BSShape | |||
164 | prim.PrimAssetState = BSPhysObject.PrimAssetCondition.Failed; | 164 | prim.PrimAssetState = BSPhysObject.PrimAssetCondition.Failed; |
165 | physicsScene.Logger.WarnFormat("{0} Fetched asset would not mesh. {1}, texture={2}", | 165 | physicsScene.Logger.WarnFormat("{0} Fetched asset would not mesh. {1}, texture={2}", |
166 | LogHeader, prim.PhysObjectName, prim.BaseShape.SculptTexture); | 166 | LogHeader, prim.PhysObjectName, prim.BaseShape.SculptTexture); |
167 | physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,setFailed,objNam={1},tex={2}", | ||
168 | prim.LocalID, prim.PhysObjectName, prim.BaseShape.SculptTexture); | ||
167 | } | 169 | } |
168 | else | 170 | else |
169 | { | 171 | { |
@@ -174,29 +176,33 @@ public abstract class BSShape | |||
174 | && prim.BaseShape.SculptTexture != OMV.UUID.Zero | 176 | && prim.BaseShape.SculptTexture != OMV.UUID.Zero |
175 | ) | 177 | ) |
176 | { | 178 | { |
177 | physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,fetchAsset", prim.LocalID); | 179 | physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,fetchAsset,objNam={1},tex={2}", |
180 | prim.LocalID, prim.PhysObjectName, prim.BaseShape.SculptTexture); | ||
178 | // Multiple requestors will know we're waiting for this asset | 181 | // Multiple requestors will know we're waiting for this asset |
179 | prim.PrimAssetState = BSPhysObject.PrimAssetCondition.Waiting; | 182 | prim.PrimAssetState = BSPhysObject.PrimAssetCondition.Waiting; |
180 | 183 | ||
181 | BSPhysObject xprim = prim; | 184 | BSPhysObject xprim = prim; |
182 | Util.FireAndForget(delegate | 185 | Util.FireAndForget(delegate |
183 | { | 186 | { |
187 | physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,inFireAndForget", xprim.LocalID); | ||
184 | RequestAssetDelegate assetProvider = physicsScene.RequestAssetMethod; | 188 | RequestAssetDelegate assetProvider = physicsScene.RequestAssetMethod; |
185 | if (assetProvider != null) | 189 | if (assetProvider != null) |
186 | { | 190 | { |
187 | BSPhysObject yprim = xprim; // probably not necessary, but, just in case. | 191 | BSPhysObject yprim = xprim; // probably not necessary, but, just in case. |
188 | assetProvider(yprim.BaseShape.SculptTexture, delegate(AssetBase asset) | 192 | assetProvider(yprim.BaseShape.SculptTexture, delegate(AssetBase asset) |
189 | { | 193 | { |
194 | physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,assetProviderCallback", xprim.LocalID); | ||
190 | bool assetFound = false; | 195 | bool assetFound = false; |
191 | string mismatchIDs = String.Empty; // DEBUG DEBUG | 196 | string mismatchIDs = String.Empty; // DEBUG DEBUG |
192 | if (asset != null && yprim.BaseShape.SculptEntry) | 197 | if (asset != null && yprim.BaseShape.SculptEntry) |
193 | { | 198 | { |
194 | if (yprim.BaseShape.SculptTexture.ToString() == asset.ID) | 199 | if (yprim.BaseShape.SculptTexture.ToString() == asset.ID) |
195 | { | 200 | { |
196 | yprim.BaseShape.SculptData = asset.Data; | 201 | yprim.BaseShape.SculptData = (byte[])asset.Data.Clone(); |
197 | // This will cause the prim to see that the filler shape is not the right | 202 | // This will cause the prim to see that the filler shape is not the right |
198 | // one and try again to build the object. | 203 | // one and try again to build the object. |
199 | // No race condition with the normal shape setting since the rebuild is at taint time. | 204 | // No race condition with the normal shape setting since the rebuild is at taint time. |
205 | yprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Fetched; | ||
200 | yprim.ForceBodyShapeRebuild(false /* inTaintTime */); | 206 | yprim.ForceBodyShapeRebuild(false /* inTaintTime */); |
201 | assetFound = true; | 207 | assetFound = true; |
202 | } | 208 | } |
@@ -205,11 +211,11 @@ public abstract class BSShape | |||
205 | mismatchIDs = yprim.BaseShape.SculptTexture.ToString() + "/" + asset.ID; | 211 | mismatchIDs = yprim.BaseShape.SculptTexture.ToString() + "/" + asset.ID; |
206 | } | 212 | } |
207 | } | 213 | } |
208 | if (assetFound) | 214 | if (!assetFound) |
209 | yprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Fetched; | 215 | { |
210 | else | ||
211 | yprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Failed; | 216 | yprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Failed; |
212 | physicsScene.DetailLog("{0},BSShape,fetchAssetCallback,found={1},isSculpt={2},ids={3}", | 217 | } |
218 | physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,fetchAssetCallback,found={1},isSculpt={2},ids={3}", | ||
213 | yprim.LocalID, assetFound, yprim.BaseShape.SculptEntry, mismatchIDs ); | 219 | yprim.LocalID, assetFound, yprim.BaseShape.SculptEntry, mismatchIDs ); |
214 | }); | 220 | }); |
215 | } | 221 | } |
@@ -227,6 +233,8 @@ public abstract class BSShape | |||
227 | { | 233 | { |
228 | physicsScene.Logger.WarnFormat("{0} Mesh failed to fetch asset. obj={1}, texture={2}", | 234 | physicsScene.Logger.WarnFormat("{0} Mesh failed to fetch asset. obj={1}, texture={2}", |
229 | LogHeader, prim.PhysObjectName, prim.BaseShape.SculptTexture); | 235 | LogHeader, prim.PhysObjectName, prim.BaseShape.SculptTexture); |
236 | physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,wasFailed,objNam={1},tex={2}", | ||
237 | prim.LocalID, prim.PhysObjectName, prim.BaseShape.SculptTexture); | ||
230 | } | 238 | } |
231 | } | 239 | } |
232 | } | 240 | } |
@@ -359,7 +367,7 @@ public class BSShapeMesh : BSShape | |||
359 | 367 | ||
360 | // Check to see if mesh was created (might require an asset). | 368 | // Check to see if mesh was created (might require an asset). |
361 | newShape = VerifyMeshCreated(physicsScene, newShape, prim); | 369 | newShape = VerifyMeshCreated(physicsScene, newShape, prim); |
362 | if (newShape.shapeType == BSPhysicsShapeType.SHAPE_MESH) | 370 | if (!newShape.isNativeShape) |
363 | { | 371 | { |
364 | // If a mesh was what was created, remember the built shape for later sharing. | 372 | // If a mesh was what was created, remember the built shape for later sharing. |
365 | Meshes.Add(newMeshKey, retMesh); | 373 | Meshes.Add(newMeshKey, retMesh); |
@@ -408,7 +416,7 @@ public class BSShapeMesh : BSShape | |||
408 | private BulletShape CreatePhysicalMesh(BSScene physicsScene, BSPhysObject prim, System.UInt64 newMeshKey, | 416 | private BulletShape CreatePhysicalMesh(BSScene physicsScene, BSPhysObject prim, System.UInt64 newMeshKey, |
409 | PrimitiveBaseShape pbs, OMV.Vector3 size, float lod) | 417 | PrimitiveBaseShape pbs, OMV.Vector3 size, float lod) |
410 | { | 418 | { |
411 | BulletShape newShape = null; | 419 | BulletShape newShape = new BulletShape(); |
412 | 420 | ||
413 | IMesh meshData = physicsScene.mesher.CreateMesh(prim.PhysObjectName, pbs, size, lod, | 421 | IMesh meshData = physicsScene.mesher.CreateMesh(prim.PhysObjectName, pbs, size, lod, |
414 | false, // say it is not physical so a bounding box is not built | 422 | false, // say it is not physical so a bounding box is not built |
@@ -507,7 +515,7 @@ public class BSShapeHull : BSShape | |||
507 | 515 | ||
508 | // Check to see if hull was created (might require an asset). | 516 | // Check to see if hull was created (might require an asset). |
509 | newShape = VerifyMeshCreated(physicsScene, newShape, prim); | 517 | newShape = VerifyMeshCreated(physicsScene, newShape, prim); |
510 | if (newShape.shapeType == BSPhysicsShapeType.SHAPE_HULL) | 518 | if (!newShape.isNativeShape) |
511 | { | 519 | { |
512 | // If a mesh was what was created, remember the built shape for later sharing. | 520 | // If a mesh was what was created, remember the built shape for later sharing. |
513 | Hulls.Add(newHullKey, retHull); | 521 | Hulls.Add(newHullKey, retHull); |
@@ -731,7 +739,7 @@ public class BSShapeCompound : BSShape | |||
731 | { | 739 | { |
732 | lock (physShapeInfo) | 740 | lock (physShapeInfo) |
733 | { | 741 | { |
734 | Dereference(physicsScene); | 742 | this.DecrementReference(); |
735 | if (referenceCount <= 0) | 743 | if (referenceCount <= 0) |
736 | { | 744 | { |
737 | if (!physicsScene.PE.IsCompound(physShapeInfo)) | 745 | if (!physicsScene.PE.IsCompound(physShapeInfo)) |