diff options
author | Robert Adams | 2013-04-28 17:03:03 -0700 |
---|---|---|
committer | Robert Adams | 2013-04-29 07:38:47 -0700 |
commit | f2d408829ba66792b0763aaf51492e7a0037c2d6 (patch) | |
tree | 805ae92b3f4d4c9d7918488286ea875fc67c2cb6 /OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs | |
parent | BulletSim: code for creating the avatar capsule shape. (diff) | |
download | opensim-SC_OLD-f2d408829ba66792b0763aaf51492e7a0037c2d6.zip opensim-SC_OLD-f2d408829ba66792b0763aaf51492e7a0037c2d6.tar.gz opensim-SC_OLD-f2d408829ba66792b0763aaf51492e7a0037c2d6.tar.bz2 opensim-SC_OLD-f2d408829ba66792b0763aaf51492e7a0037c2d6.tar.xz |
BulletSim: fix crash when creating new hull.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs index a7b3f02..bfc7ae7 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs | |||
@@ -161,7 +161,7 @@ public abstract class BSShape | |||
161 | && prim.BaseShape.SculptTexture != OMV.UUID.Zero | 161 | && prim.BaseShape.SculptTexture != OMV.UUID.Zero |
162 | ) | 162 | ) |
163 | { | 163 | { |
164 | physicsScene.DetailLog("{0},BSShapeCollection.VerifyMeshCreated,fetchAsset", prim.LocalID); | 164 | physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,fetchAsset", prim.LocalID); |
165 | // Multiple requestors will know we're waiting for this asset | 165 | // Multiple requestors will know we're waiting for this asset |
166 | prim.PrimAssetState = BSPhysObject.PrimAssetCondition.Waiting; | 166 | prim.PrimAssetState = BSPhysObject.PrimAssetCondition.Waiting; |
167 | 167 | ||
@@ -196,7 +196,7 @@ public abstract class BSShape | |||
196 | yprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Fetched; | 196 | yprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Fetched; |
197 | else | 197 | else |
198 | yprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Failed; | 198 | yprim.PrimAssetState = BSPhysObject.PrimAssetCondition.Failed; |
199 | physicsScene.DetailLog("{0},BSShapeCollection,fetchAssetCallback,found={1},isSculpt={2},ids={3}", | 199 | physicsScene.DetailLog("{0},BSShape,fetchAssetCallback,found={1},isSculpt={2},ids={3}", |
200 | yprim.LocalID, assetFound, yprim.BaseShape.SculptEntry, mismatchIDs ); | 200 | yprim.LocalID, assetFound, yprim.BaseShape.SculptEntry, mismatchIDs ); |
201 | }); | 201 | }); |
202 | } | 202 | } |
@@ -220,7 +220,7 @@ public abstract class BSShape | |||
220 | 220 | ||
221 | // While we wait for the mesh defining asset to be loaded, stick in a simple box for the object. | 221 | // While we wait for the mesh defining asset to be loaded, stick in a simple box for the object. |
222 | BSShape fillShape = BSShapeNative.GetReference(physicsScene, prim, BSPhysicsShapeType.SHAPE_BOX, FixedShapeKey.KEY_BOX); | 222 | BSShape fillShape = BSShapeNative.GetReference(physicsScene, prim, BSPhysicsShapeType.SHAPE_BOX, FixedShapeKey.KEY_BOX); |
223 | physicsScene.DetailLog("{0},BSShapeCollection.VerifyMeshCreated,boxTempShape", prim.LocalID); | 223 | physicsScene.DetailLog("{0},BSShape.VerifyMeshCreated,boxTempShape", prim.LocalID); |
224 | 224 | ||
225 | return fillShape.physShapeInfo; | 225 | return fillShape.physShapeInfo; |
226 | } | 226 | } |
@@ -318,7 +318,7 @@ public class BSShapeMesh : BSShape | |||
318 | prim.LocalID, prim.PhysShape.physShapeInfo.shapeKey.ToString("X"), | 318 | prim.LocalID, prim.PhysShape.physShapeInfo.shapeKey.ToString("X"), |
319 | newMeshKey.ToString("X"), prim.Size, lod); | 319 | newMeshKey.ToString("X"), prim.Size, lod); |
320 | 320 | ||
321 | BSShapeMesh retMesh = new BSShapeMesh(new BulletShape()); | 321 | BSShapeMesh retMesh = null; |
322 | lock (Meshes) | 322 | lock (Meshes) |
323 | { | 323 | { |
324 | if (Meshes.TryGetValue(newMeshKey, out retMesh)) | 324 | if (Meshes.TryGetValue(newMeshKey, out retMesh)) |
@@ -328,6 +328,7 @@ public class BSShapeMesh : BSShape | |||
328 | } | 328 | } |
329 | else | 329 | else |
330 | { | 330 | { |
331 | retMesh = new BSShapeMesh(new BulletShape()); | ||
331 | // An instance of this mesh has not been created. Build and remember same. | 332 | // An instance of this mesh has not been created. Build and remember same. |
332 | BulletShape newShape = retMesh.CreatePhysicalMesh(physicsScene, prim, newMeshKey, prim.BaseShape, prim.Size, lod); | 333 | BulletShape newShape = retMesh.CreatePhysicalMesh(physicsScene, prim, newMeshKey, prim.BaseShape, prim.Size, lod); |
333 | 334 | ||
@@ -422,7 +423,7 @@ public class BSShapeMesh : BSShape | |||
422 | } | 423 | } |
423 | } | 424 | } |
424 | } | 425 | } |
425 | physicsScene.DetailLog("{0},BSShapeCollection.CreatePhysicalMesh,origTri={1},realTri={2},numVerts={3}", | 426 | physicsScene.DetailLog("{0},BSShapeMesh.CreatePhysicalMesh,origTri={1},realTri={2},numVerts={3}", |
426 | BSScene.DetailLogZero, indices.Length / 3, realIndicesIndex / 3, verticesAsFloats.Length / 3); | 427 | BSScene.DetailLogZero, indices.Length / 3, realIndicesIndex / 3, verticesAsFloats.Length / 3); |
427 | 428 | ||
428 | if (realIndicesIndex != 0) | 429 | if (realIndicesIndex != 0) |
@@ -459,7 +460,7 @@ public class BSShapeHull : BSShape | |||
459 | physicsScene.DetailLog("{0},BSShapeHull,getReference,oldKey={1},newKey={2},size={3},lod={4}", | 460 | physicsScene.DetailLog("{0},BSShapeHull,getReference,oldKey={1},newKey={2},size={3},lod={4}", |
460 | prim.LocalID, prim.PhysShape.physShapeInfo.shapeKey.ToString("X"), newHullKey.ToString("X"), prim.Size, lod); | 461 | prim.LocalID, prim.PhysShape.physShapeInfo.shapeKey.ToString("X"), newHullKey.ToString("X"), prim.Size, lod); |
461 | 462 | ||
462 | BSShapeHull retHull = new BSShapeHull(new BulletShape()); | 463 | BSShapeHull retHull = null; |
463 | lock (Hulls) | 464 | lock (Hulls) |
464 | { | 465 | { |
465 | if (Hulls.TryGetValue(newHullKey, out retHull)) | 466 | if (Hulls.TryGetValue(newHullKey, out retHull)) |
@@ -469,18 +470,18 @@ public class BSShapeHull : BSShape | |||
469 | } | 470 | } |
470 | else | 471 | else |
471 | { | 472 | { |
473 | retHull = new BSShapeHull(new BulletShape()); | ||
472 | // An instance of this mesh has not been created. Build and remember same. | 474 | // An instance of this mesh has not been created. Build and remember same. |
473 | BulletShape newShape = retHull.CreatePhysicalHull(physicsScene, prim, newHullKey, prim.BaseShape, prim.Size, lod); | 475 | BulletShape newShape = retHull.CreatePhysicalHull(physicsScene, prim, newHullKey, prim.BaseShape, prim.Size, lod); |
474 | 476 | ||
475 | // Check to see if mesh was created (might require an asset). | 477 | // Check to see if hull was created (might require an asset). |
476 | newShape = VerifyMeshCreated(physicsScene, newShape, prim); | 478 | newShape = VerifyMeshCreated(physicsScene, newShape, prim); |
477 | if (newShape.shapeType == BSPhysicsShapeType.SHAPE_MESH) | 479 | if (newShape.shapeType == BSPhysicsShapeType.SHAPE_HULL) |
478 | { | 480 | { |
479 | // If a mesh was what was created, remember the built shape for later sharing. | 481 | // If a mesh was what was created, remember the built shape for later sharing. |
480 | Hulls.Add(newHullKey, retHull); | 482 | Hulls.Add(newHullKey, retHull); |
481 | } | 483 | } |
482 | 484 | ||
483 | retHull = new BSShapeHull(newShape); | ||
484 | retHull.physShapeInfo = newShape; | 485 | retHull.physShapeInfo = newShape; |
485 | } | 486 | } |
486 | } | 487 | } |
@@ -498,7 +499,7 @@ public class BSShapeHull : BSShape | |||
498 | 499 | ||
499 | if (BSParam.ShouldUseBulletHACD) | 500 | if (BSParam.ShouldUseBulletHACD) |
500 | { | 501 | { |
501 | physicsScene.DetailLog("{0},BSShapeCollection.CreatePhysicalHull,shouldUseBulletHACD,entry", prim.LocalID); | 502 | physicsScene.DetailLog("{0},BSShapeHull.CreatePhysicalHull,shouldUseBulletHACD,entry", prim.LocalID); |
502 | BSShape meshShape = BSShapeMesh.GetReference(physicsScene, true, prim); | 503 | BSShape meshShape = BSShapeMesh.GetReference(physicsScene, true, prim); |
503 | 504 | ||
504 | if (meshShape.physShapeInfo.HasPhysicalShape) | 505 | if (meshShape.physShapeInfo.HasPhysicalShape) |
@@ -514,13 +515,13 @@ public class BSShapeHull : BSShape | |||
514 | parms.addFacesPoints = BSParam.NumericBool(BSParam.BHullAddFacesPoints); | 515 | parms.addFacesPoints = BSParam.NumericBool(BSParam.BHullAddFacesPoints); |
515 | parms.shouldAdjustCollisionMargin = BSParam.NumericBool(BSParam.BHullShouldAdjustCollisionMargin); | 516 | parms.shouldAdjustCollisionMargin = BSParam.NumericBool(BSParam.BHullShouldAdjustCollisionMargin); |
516 | 517 | ||
517 | physicsScene.DetailLog("{0},BSShapeCollection.CreatePhysicalHull,hullFromMesh,beforeCall", prim.LocalID, newShape.HasPhysicalShape); | 518 | physicsScene.DetailLog("{0},BSShapeHull.CreatePhysicalHull,hullFromMesh,beforeCall", prim.LocalID, newShape.HasPhysicalShape); |
518 | newShape = physicsScene.PE.BuildHullShapeFromMesh(physicsScene.World, meshShape.physShapeInfo, parms); | 519 | newShape = physicsScene.PE.BuildHullShapeFromMesh(physicsScene.World, meshShape.physShapeInfo, parms); |
519 | physicsScene.DetailLog("{0},BSShapeCollection.CreatePhysicalHull,hullFromMesh,hasBody={1}", prim.LocalID, newShape.HasPhysicalShape); | 520 | physicsScene.DetailLog("{0},BSShapeHull.CreatePhysicalHull,hullFromMesh,hasBody={1}", prim.LocalID, newShape.HasPhysicalShape); |
520 | } | 521 | } |
521 | // Now done with the mesh shape. | 522 | // Now done with the mesh shape. |
522 | meshShape.DecrementReference(); | 523 | meshShape.DecrementReference(); |
523 | physicsScene.DetailLog("{0},BSShapeCollection.CreatePhysicalHull,shouldUseBulletHACD,exit,hasBody={1}", prim.LocalID, newShape.HasPhysicalShape); | 524 | physicsScene.DetailLog("{0},BSShapeHull.CreatePhysicalHull,shouldUseBulletHACD,exit,hasBody={1}", prim.LocalID, newShape.HasPhysicalShape); |
524 | } | 525 | } |
525 | if (!newShape.HasPhysicalShape) | 526 | if (!newShape.HasPhysicalShape) |
526 | { | 527 | { |