aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs116
1 files changed, 62 insertions, 54 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
index a38e650..478924a 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
@@ -90,7 +90,6 @@ public sealed class BSShapeCollection : IDisposable
90 // remove the physical constraints before the body is destroyed. 90 // remove the physical constraints before the body is destroyed.
91 // Called at taint-time!! 91 // Called at taint-time!!
92 public bool GetBodyAndShape(bool forceRebuild, BulletSim sim, BSPhysObject prim, 92 public bool GetBodyAndShape(bool forceRebuild, BulletSim sim, BSPhysObject prim,
93 ShapeData shapeData, PrimitiveBaseShape pbs,
94 ShapeDestructionCallback shapeCallback, BodyDestructionCallback bodyCallback) 93 ShapeDestructionCallback shapeCallback, BodyDestructionCallback bodyCallback)
95 { 94 {
96 bool ret = false; 95 bool ret = false;
@@ -101,12 +100,12 @@ public sealed class BSShapeCollection : IDisposable
101 // Do we have the correct geometry for this type of object? 100 // Do we have the correct geometry for this type of object?
102 // Updates prim.BSShape with information/pointers to shape. 101 // Updates prim.BSShape with information/pointers to shape.
103 // CreateGeom returns 'true' of BSShape as changed to a new shape. 102 // CreateGeom returns 'true' of BSShape as changed to a new shape.
104 bool newGeom = CreateGeom(forceRebuild, prim, shapeData, pbs, shapeCallback); 103 bool newGeom = CreateGeom(forceRebuild, prim, shapeCallback);
105 // If we had to select a new shape geometry for the object, 104 // If we had to select a new shape geometry for the object,
106 // rebuild the body around it. 105 // rebuild the body around it.
107 // Updates prim.BSBody with information/pointers to requested body 106 // Updates prim.BSBody with information/pointers to requested body
108 bool newBody = CreateBody((newGeom || forceRebuild), prim, PhysicsScene.World, 107 bool newBody = CreateBody((newGeom || forceRebuild), prim, PhysicsScene.World,
109 prim.PhysShape, shapeData, bodyCallback); 108 prim.PhysShape, bodyCallback);
110 ret = newGeom || newBody; 109 ret = newGeom || newBody;
111 } 110 }
112 DetailLog("{0},BSShapeCollection.GetBodyAndShape,taintExit,force={1},ret={2},body={3},shape={4}", 111 DetailLog("{0},BSShapeCollection.GetBodyAndShape,taintExit,force={1},ret={2},body={3},shape={4}",
@@ -261,6 +260,9 @@ public sealed class BSShapeCollection : IDisposable
261 case ShapeData.PhysicsShapeType.SHAPE_MESH: 260 case ShapeData.PhysicsShapeType.SHAPE_MESH:
262 DereferenceMesh(shape, shapeCallback); 261 DereferenceMesh(shape, shapeCallback);
263 break; 262 break;
263 case ShapeData.PhysicsShapeType.SHAPE_COMPOUND:
264 DereferenceCompound(shape, shapeCallback);
265 break;
264 case ShapeData.PhysicsShapeType.SHAPE_UNKNOWN: 266 case ShapeData.PhysicsShapeType.SHAPE_UNKNOWN:
265 break; 267 break;
266 default: 268 default:
@@ -317,6 +319,13 @@ public sealed class BSShapeCollection : IDisposable
317 } 319 }
318 } 320 }
319 321
322 // Remove a reference to a compound shape.
323 // Called at taint-time.
324 private void DereferenceCompound(BulletShape shape, ShapeDestructionCallback shapeCallback)
325 {
326 // Compound shape is made of a bunch of meshes and natives.
327 }
328
320 // Create the geometry information in Bullet for later use. 329 // Create the geometry information in Bullet for later use.
321 // The objects needs a hull if it's physical otherwise a mesh is enough. 330 // The objects needs a hull if it's physical otherwise a mesh is enough.
322 // if 'forceRebuild' is true, the geometry is unconditionally rebuilt. For meshes and hulls, 331 // if 'forceRebuild' is true, the geometry is unconditionally rebuilt. For meshes and hulls,
@@ -325,17 +334,17 @@ public sealed class BSShapeCollection : IDisposable
325 // Info in prim.BSShape is updated to the new shape. 334 // Info in prim.BSShape is updated to the new shape.
326 // Returns 'true' if the geometry was rebuilt. 335 // Returns 'true' if the geometry was rebuilt.
327 // Called at taint-time! 336 // Called at taint-time!
328 private bool CreateGeom(bool forceRebuild, BSPhysObject prim, ShapeData shapeData, 337 private bool CreateGeom(bool forceRebuild, BSPhysObject prim, ShapeDestructionCallback shapeCallback)
329 PrimitiveBaseShape pbs, ShapeDestructionCallback shapeCallback)
330 { 338 {
331 bool ret = false; 339 bool ret = false;
332 bool haveShape = false; 340 bool haveShape = false;
333 bool nativeShapePossible = true; 341 bool nativeShapePossible = true;
342 PrimitiveBaseShape pbs = prim.BaseShape;
334 343
335 if (shapeData.Type == ShapeData.PhysicsShapeType.SHAPE_AVATAR) 344 if (prim.PreferredPhysicalShape == ShapeData.PhysicsShapeType.SHAPE_AVATAR)
336 { 345 {
337 // an avatar capsule is close to a native shape (it is not shared) 346 // an avatar capsule is close to a native shape (it is not shared)
338 ret = GetReferenceToNativeShape(prim, shapeData, ShapeData.PhysicsShapeType.SHAPE_AVATAR, 347 ret = GetReferenceToNativeShape(prim, ShapeData.PhysicsShapeType.SHAPE_AVATAR,
339 ShapeData.FixedShapeKey.KEY_CAPSULE, shapeCallback); 348 ShapeData.FixedShapeKey.KEY_CAPSULE, shapeCallback);
340 DetailLog("{0},BSShapeCollection.CreateGeom,avatarCapsule,shape={1}", prim.LocalID, prim.PhysShape); 349 DetailLog("{0},BSShapeCollection.CreateGeom,avatarCapsule,shape={1}", prim.LocalID, prim.PhysShape);
341 ret = true; 350 ret = true;
@@ -359,11 +368,11 @@ public sealed class BSShapeCollection : IDisposable
359 { 368 {
360 haveShape = true; 369 haveShape = true;
361 if (forceRebuild 370 if (forceRebuild
362 || prim.Scale != shapeData.Size 371 || prim.Scale != prim.Size
363 || prim.PhysShape.type != ShapeData.PhysicsShapeType.SHAPE_SPHERE 372 || prim.PhysShape.type != ShapeData.PhysicsShapeType.SHAPE_SPHERE
364 ) 373 )
365 { 374 {
366 ret = GetReferenceToNativeShape(prim, shapeData, ShapeData.PhysicsShapeType.SHAPE_SPHERE, 375 ret = GetReferenceToNativeShape(prim, ShapeData.PhysicsShapeType.SHAPE_SPHERE,
367 ShapeData.FixedShapeKey.KEY_SPHERE, shapeCallback); 376 ShapeData.FixedShapeKey.KEY_SPHERE, shapeCallback);
368 DetailLog("{0},BSShapeCollection.CreateGeom,sphere,force={1},shape={2}", 377 DetailLog("{0},BSShapeCollection.CreateGeom,sphere,force={1},shape={2}",
369 prim.LocalID, forceRebuild, prim.PhysShape); 378 prim.LocalID, forceRebuild, prim.PhysShape);
@@ -373,11 +382,11 @@ public sealed class BSShapeCollection : IDisposable
373 { 382 {
374 haveShape = true; 383 haveShape = true;
375 if (forceRebuild 384 if (forceRebuild
376 || prim.Scale != shapeData.Size 385 || prim.Scale != prim.Size
377 || prim.PhysShape.type != ShapeData.PhysicsShapeType.SHAPE_BOX 386 || prim.PhysShape.type != ShapeData.PhysicsShapeType.SHAPE_BOX
378 ) 387 )
379 { 388 {
380 ret = GetReferenceToNativeShape( prim, shapeData, ShapeData.PhysicsShapeType.SHAPE_BOX, 389 ret = GetReferenceToNativeShape( prim, ShapeData.PhysicsShapeType.SHAPE_BOX,
381 ShapeData.FixedShapeKey.KEY_BOX, shapeCallback); 390 ShapeData.FixedShapeKey.KEY_BOX, shapeCallback);
382 DetailLog("{0},BSShapeCollection.CreateGeom,box,force={1},shape={2}", 391 DetailLog("{0},BSShapeCollection.CreateGeom,box,force={1},shape={2}",
383 prim.LocalID, forceRebuild, prim.PhysShape); 392 prim.LocalID, forceRebuild, prim.PhysShape);
@@ -392,15 +401,15 @@ public sealed class BSShapeCollection : IDisposable
392 if (prim.IsPhysical && PhysicsScene.ShouldUseHullsForPhysicalObjects) 401 if (prim.IsPhysical && PhysicsScene.ShouldUseHullsForPhysicalObjects)
393 { 402 {
394 // Update prim.BSShape to reference a hull of this shape. 403 // Update prim.BSShape to reference a hull of this shape.
395 ret = GetReferenceToHull(prim, shapeData, pbs, shapeCallback); 404 ret = GetReferenceToHull(prim,shapeCallback);
396 DetailLog("{0},BSShapeCollection.CreateGeom,hull,shape={1},key={2}", 405 DetailLog("{0},BSShapeCollection.CreateGeom,hull,shape={1},key={2}",
397 shapeData.ID, prim.PhysShape, prim.PhysShape.shapeKey.ToString("X")); 406 prim.LocalID, prim.PhysShape, prim.PhysShape.shapeKey.ToString("X"));
398 } 407 }
399 else 408 else
400 { 409 {
401 ret = GetReferenceToMesh(prim, shapeData, pbs, shapeCallback); 410 ret = GetReferenceToMesh(prim, shapeCallback);
402 DetailLog("{0},BSShapeCollection.CreateGeom,mesh,shape={1},key={2}", 411 DetailLog("{0},BSShapeCollection.CreateGeom,mesh,shape={1},key={2}",
403 shapeData.ID, prim.PhysShape, prim.PhysShape.shapeKey.ToString("X")); 412 prim.LocalID, prim.PhysShape, prim.PhysShape.shapeKey.ToString("X"));
404 } 413 }
405 } 414 }
406 return ret; 415 return ret;
@@ -408,44 +417,45 @@ public sealed class BSShapeCollection : IDisposable
408 417
409 // Creates a native shape and assignes it to prim.BSShape. 418 // Creates a native shape and assignes it to prim.BSShape.
410 // "Native" shapes are never shared. they are created here and destroyed in DereferenceShape(). 419 // "Native" shapes are never shared. they are created here and destroyed in DereferenceShape().
411 private bool GetReferenceToNativeShape(BSPhysObject prim, ShapeData shapeData, 420 private bool GetReferenceToNativeShape(BSPhysObject prim,
412 ShapeData.PhysicsShapeType shapeType, ShapeData.FixedShapeKey shapeKey, 421 ShapeData.PhysicsShapeType shapeType, ShapeData.FixedShapeKey shapeKey,
413 ShapeDestructionCallback shapeCallback) 422 ShapeDestructionCallback shapeCallback)
414 { 423 {
415 // release any previous shape 424 // release any previous shape
416 DereferenceShape(prim.PhysShape, true, shapeCallback); 425 DereferenceShape(prim.PhysShape, true, shapeCallback);
417 426
418 shapeData.Type = shapeType;
419 // Bullet native objects are scaled by the Bullet engine so pass the size in 427 // Bullet native objects are scaled by the Bullet engine so pass the size in
420 prim.Scale = shapeData.Size; 428 prim.Scale = prim.Size;
421 shapeData.Scale = shapeData.Size;
422 429
423 BulletShape newShape = BuildPhysicalNativeShape(shapeType, shapeData, shapeKey); 430 BulletShape newShape = BuildPhysicalNativeShape(prim, shapeType, shapeKey);
424 431
425 // Don't need to do a 'ReferenceShape()' here because native shapes are not shared. 432 // Don't need to do a 'ReferenceShape()' here because native shapes are not shared.
426 DetailLog("{0},BSShapeCollection.AddNativeShapeToPrim,create,newshape={1},scale={2}", 433 DetailLog("{0},BSShapeCollection.AddNativeShapeToPrim,create,newshape={1},scale={2}",
427 shapeData.ID, newShape, shapeData.Scale); 434 prim.LocalID, newShape, prim.Scale);
428 435
429 prim.PhysShape = newShape; 436 prim.PhysShape = newShape;
430 return true; 437 return true;
431 } 438 }
432 439
433 private BulletShape BuildPhysicalNativeShape(ShapeData.PhysicsShapeType shapeType, 440 private BulletShape BuildPhysicalNativeShape(BSPhysObject prim, ShapeData.PhysicsShapeType shapeType,
434 ShapeData shapeData, ShapeData.FixedShapeKey shapeKey) 441 ShapeData.FixedShapeKey shapeKey)
435 { 442 {
436 BulletShape newShape; 443 BulletShape newShape;
437 // Need to make sure the passed shape information is for the native type. 444 // Need to make sure the passed shape information is for the native type.
438 ShapeData nativeShapeData = shapeData; 445 ShapeData nativeShapeData = new ShapeData();
439 nativeShapeData.Type = shapeType; 446 nativeShapeData.Type = shapeType;
447 nativeShapeData.ID = prim.LocalID;
448 nativeShapeData.Scale = prim.Scale;
449 nativeShapeData.Size = prim.Scale;
440 nativeShapeData.MeshKey = (ulong)shapeKey; 450 nativeShapeData.MeshKey = (ulong)shapeKey;
441 nativeShapeData.HullKey = (ulong)shapeKey; 451 nativeShapeData.HullKey = (ulong)shapeKey;
442 452
443 if (shapeType == ShapeData.PhysicsShapeType.SHAPE_AVATAR) 453 if (shapeType == ShapeData.PhysicsShapeType.SHAPE_AVATAR)
444 { 454 {
445 newShape = new BulletShape( 455 newShape = new BulletShape(
446 BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 1f, 1f, nativeShapeData.Scale) 456 BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 1f, 1f, prim.Scale)
447 , shapeType); 457 , shapeType);
448 DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", nativeShapeData.ID, nativeShapeData.Scale); 458 DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", prim.LocalID, prim.Scale);
449 } 459 }
450 else 460 else
451 { 461 {
@@ -454,7 +464,7 @@ public sealed class BSShapeCollection : IDisposable
454 if (newShape.ptr == IntPtr.Zero) 464 if (newShape.ptr == IntPtr.Zero)
455 { 465 {
456 PhysicsScene.Logger.ErrorFormat("{0} BuildPhysicalNativeShape failed. ID={1}, shape={2}", 466 PhysicsScene.Logger.ErrorFormat("{0} BuildPhysicalNativeShape failed. ID={1}, shape={2}",
457 LogHeader, nativeShapeData.ID, nativeShapeData.Type); 467 LogHeader, prim.LocalID, shapeType);
458 } 468 }
459 newShape.shapeKey = (System.UInt64)shapeKey; 469 newShape.shapeKey = (System.UInt64)shapeKey;
460 newShape.isNativeShape = true; 470 newShape.isNativeShape = true;
@@ -466,13 +476,12 @@ public sealed class BSShapeCollection : IDisposable
466 // Dereferences previous shape in BSShape and adds a reference for this new shape. 476 // Dereferences previous shape in BSShape and adds a reference for this new shape.
467 // Returns 'true' of a mesh was actually built. Otherwise . 477 // Returns 'true' of a mesh was actually built. Otherwise .
468 // Called at taint-time! 478 // Called at taint-time!
469 private bool GetReferenceToMesh(BSPhysObject prim, ShapeData shapeData, PrimitiveBaseShape pbs, 479 private bool GetReferenceToMesh(BSPhysObject prim, ShapeDestructionCallback shapeCallback)
470 ShapeDestructionCallback shapeCallback)
471 { 480 {
472 BulletShape newShape = new BulletShape(IntPtr.Zero); 481 BulletShape newShape = new BulletShape(IntPtr.Zero);
473 482
474 float lod; 483 float lod;
475 System.UInt64 newMeshKey = ComputeShapeKey(shapeData, pbs, out lod); 484 System.UInt64 newMeshKey = ComputeShapeKey(prim.Size, prim.BaseShape, out lod);
476 485
477 // if this new shape is the same as last time, don't recreate the mesh 486 // if this new shape is the same as last time, don't recreate the mesh
478 if (newMeshKey == prim.PhysShape.shapeKey && prim.PhysShape.type == ShapeData.PhysicsShapeType.SHAPE_MESH) 487 if (newMeshKey == prim.PhysShape.shapeKey && prim.PhysShape.type == ShapeData.PhysicsShapeType.SHAPE_MESH)
@@ -484,9 +493,9 @@ public sealed class BSShapeCollection : IDisposable
484 // Since we're recreating new, get rid of the reference to the previous shape 493 // Since we're recreating new, get rid of the reference to the previous shape
485 DereferenceShape(prim.PhysShape, true, shapeCallback); 494 DereferenceShape(prim.PhysShape, true, shapeCallback);
486 495
487 newShape = CreatePhysicalMesh(prim.PhysObjectName, newMeshKey, pbs, shapeData.Size, lod); 496 newShape = CreatePhysicalMesh(prim.PhysObjectName, newMeshKey, prim.BaseShape, prim.Size, lod);
488 // Take evasive action if the mesh was not constructed. 497 // Take evasive action if the mesh was not constructed.
489 newShape = VerifyMeshCreated(newShape, prim, shapeData, pbs); 498 newShape = VerifyMeshCreated(newShape, prim);
490 499
491 ReferenceShape(newShape); 500 ReferenceShape(newShape);
492 501
@@ -541,13 +550,12 @@ public sealed class BSShapeCollection : IDisposable
541 550
542 // See that hull shape exists in the physical world and update prim.BSShape. 551 // See that hull shape exists in the physical world and update prim.BSShape.
543 // We could be creating the hull because scale changed or whatever. 552 // We could be creating the hull because scale changed or whatever.
544 private bool GetReferenceToHull(BSPhysObject prim, ShapeData shapeData, PrimitiveBaseShape pbs, 553 private bool GetReferenceToHull(BSPhysObject prim, ShapeDestructionCallback shapeCallback)
545 ShapeDestructionCallback shapeCallback)
546 { 554 {
547 BulletShape newShape; 555 BulletShape newShape;
548 556
549 float lod; 557 float lod;
550 System.UInt64 newHullKey = ComputeShapeKey(shapeData, pbs, out lod); 558 System.UInt64 newHullKey = ComputeShapeKey(prim.Size, prim.BaseShape, out lod);
551 559
552 // if the hull hasn't changed, don't rebuild it 560 // if the hull hasn't changed, don't rebuild it
553 if (newHullKey == prim.PhysShape.shapeKey && prim.PhysShape.type == ShapeData.PhysicsShapeType.SHAPE_HULL) 561 if (newHullKey == prim.PhysShape.shapeKey && prim.PhysShape.type == ShapeData.PhysicsShapeType.SHAPE_HULL)
@@ -559,8 +567,8 @@ public sealed class BSShapeCollection : IDisposable
559 // Remove usage of the previous shape. 567 // Remove usage of the previous shape.
560 DereferenceShape(prim.PhysShape, true, shapeCallback); 568 DereferenceShape(prim.PhysShape, true, shapeCallback);
561 569
562 newShape = CreatePhysicalHull(prim.PhysObjectName, newHullKey, pbs, shapeData.Size, lod); 570 newShape = CreatePhysicalHull(prim.PhysObjectName, newHullKey, prim.BaseShape, prim.Size, lod);
563 newShape = VerifyMeshCreated(newShape, prim, shapeData, pbs); 571 newShape = VerifyMeshCreated(newShape, prim);
564 572
565 ReferenceShape(newShape); 573 ReferenceShape(newShape);
566 574
@@ -687,7 +695,7 @@ public sealed class BSShapeCollection : IDisposable
687 695
688 // Create a hash of all the shape parameters to be used as a key 696 // Create a hash of all the shape parameters to be used as a key
689 // for this particular shape. 697 // for this particular shape.
690 private System.UInt64 ComputeShapeKey(ShapeData shapeData, PrimitiveBaseShape pbs, out float retLod) 698 private System.UInt64 ComputeShapeKey(OMV.Vector3 size, PrimitiveBaseShape pbs, out float retLod)
691 { 699 {
692 // level of detail based on size and type of the object 700 // level of detail based on size and type of the object
693 float lod = PhysicsScene.MeshLOD; 701 float lod = PhysicsScene.MeshLOD;
@@ -695,40 +703,40 @@ public sealed class BSShapeCollection : IDisposable
695 lod = PhysicsScene.SculptLOD; 703 lod = PhysicsScene.SculptLOD;
696 704
697 // Mega prims usually get more detail because one can interact with shape approximations at this size. 705 // Mega prims usually get more detail because one can interact with shape approximations at this size.
698 float maxAxis = Math.Max(shapeData.Size.X, Math.Max(shapeData.Size.Y, shapeData.Size.Z)); 706 float maxAxis = Math.Max(size.X, Math.Max(size.Y, size.Z));
699 if (maxAxis > PhysicsScene.MeshMegaPrimThreshold) 707 if (maxAxis > PhysicsScene.MeshMegaPrimThreshold)
700 lod = PhysicsScene.MeshMegaPrimLOD; 708 lod = PhysicsScene.MeshMegaPrimLOD;
701 709
702 retLod = lod; 710 retLod = lod;
703 return pbs.GetMeshKey(shapeData.Size, lod); 711 return pbs.GetMeshKey(size, lod);
704 } 712 }
705 // For those who don't want the LOD 713 // For those who don't want the LOD
706 private System.UInt64 ComputeShapeKey(ShapeData shapeData, PrimitiveBaseShape pbs) 714 private System.UInt64 ComputeShapeKey(OMV.Vector3 size, PrimitiveBaseShape pbs)
707 { 715 {
708 float lod; 716 float lod;
709 return ComputeShapeKey(shapeData, pbs, out lod); 717 return ComputeShapeKey(size, pbs, out lod);
710 } 718 }
711 719
712 // The creation of a mesh or hull can fail if an underlying asset is not available. 720 // The creation of a mesh or hull can fail if an underlying asset is not available.
713 // There are two cases: 1) the asset is not in the cache and it needs to be fetched; 721 // There are two cases: 1) the asset is not in the cache and it needs to be fetched;
714 // and 2) the asset cannot be converted (like decompressing JPEG2000s). 722 // and 2) the asset cannot be converted (like failed decompression of JPEG2000s).
715 // The first case causes the asset to be fetched. The second case just requires 723 // The first case causes the asset to be fetched. The second case requires
716 // us to not loop forever. 724 // us to not loop forever.
717 // Called after creating a physical mesh or hull. If the physical shape was created, 725 // Called after creating a physical mesh or hull. If the physical shape was created,
718 // just return. 726 // just return.
719 private BulletShape VerifyMeshCreated(BulletShape newShape, BSPhysObject prim, ShapeData shapeData, PrimitiveBaseShape pbs) 727 private BulletShape VerifyMeshCreated(BulletShape newShape, BSPhysObject prim)
720 { 728 {
721 // If the shape was successfully created, nothing more to do 729 // If the shape was successfully created, nothing more to do
722 if (newShape.ptr != IntPtr.Zero) 730 if (newShape.ptr != IntPtr.Zero)
723 return newShape; 731 return newShape;
724 732
725 // If this mesh has an underlying asset and we have not failed getting it before, fetch the asset 733 // If this mesh has an underlying asset and we have not failed getting it before, fetch the asset
726 if (pbs.SculptEntry && !prim.LastAssetBuildFailed && pbs.SculptTexture != OMV.UUID.Zero) 734 if (prim.BaseShape.SculptEntry && !prim.LastAssetBuildFailed && prim.BaseShape.SculptTexture != OMV.UUID.Zero)
727 { 735 {
728 prim.LastAssetBuildFailed = true; 736 prim.LastAssetBuildFailed = true;
729 BSPhysObject xprim = prim; 737 BSPhysObject xprim = prim;
730 DetailLog("{0},BSShapeCollection.VerifyMeshCreated,fetchAsset,lID={1},lastFailed={2}", 738 DetailLog("{0},BSShapeCollection.VerifyMeshCreated,fetchAsset,lID={1},lastFailed={2}",
731 LogHeader, shapeData.ID.ToString("X"), prim.LastAssetBuildFailed); 739 LogHeader, prim.LocalID, prim.LastAssetBuildFailed);
732 Util.FireAndForget(delegate 740 Util.FireAndForget(delegate
733 { 741 {
734 RequestAssetDelegate assetProvider = PhysicsScene.RequestAssetMethod; 742 RequestAssetDelegate assetProvider = PhysicsScene.RequestAssetMethod;
@@ -745,7 +753,7 @@ public sealed class BSShapeCollection : IDisposable
745 yprim.BaseShape.SculptData = asset.Data; 753 yprim.BaseShape.SculptData = asset.Data;
746 // This will cause the prim to see that the filler shape is not the right 754 // This will cause the prim to see that the filler shape is not the right
747 // one and try again to build the object. 755 // one and try again to build the object.
748 // No race condition with the native sphere setting since the rebuild is at taint time. 756 // No race condition with the normal shape setting since the rebuild is at taint time.
749 yprim.ForceBodyShapeRebuild(false); 757 yprim.ForceBodyShapeRebuild(false);
750 758
751 }); 759 });
@@ -757,13 +765,13 @@ public sealed class BSShapeCollection : IDisposable
757 if (prim.LastAssetBuildFailed) 765 if (prim.LastAssetBuildFailed)
758 { 766 {
759 PhysicsScene.Logger.ErrorFormat("{0} Mesh failed to fetch asset. lID={1}, texture={2}", 767 PhysicsScene.Logger.ErrorFormat("{0} Mesh failed to fetch asset. lID={1}, texture={2}",
760 LogHeader, shapeData.ID, pbs.SculptTexture); 768 LogHeader, prim.LocalID, prim.BaseShape.SculptTexture);
761 } 769 }
762 } 770 }
763 771
764 // While we figure out the real problem, stick a simple native shape on the object. 772 // While we figure out the real problem, stick a simple native shape on the object.
765 BulletShape fillinShape = 773 BulletShape fillinShape =
766 BuildPhysicalNativeShape(ShapeData.PhysicsShapeType.SHAPE_BOX, shapeData, ShapeData.FixedShapeKey.KEY_BOX); 774 BuildPhysicalNativeShape(prim, ShapeData.PhysicsShapeType.SHAPE_BOX, ShapeData.FixedShapeKey.KEY_BOX);
767 775
768 return fillinShape; 776 return fillinShape;
769 } 777 }
@@ -773,7 +781,7 @@ public sealed class BSShapeCollection : IDisposable
773 // Returns 'true' if an object was actually created. 781 // Returns 'true' if an object was actually created.
774 // Called at taint-time. 782 // Called at taint-time.
775 private bool CreateBody(bool forceRebuild, BSPhysObject prim, BulletSim sim, BulletShape shape, 783 private bool CreateBody(bool forceRebuild, BSPhysObject prim, BulletSim sim, BulletShape shape,
776 ShapeData shapeData, BodyDestructionCallback bodyCallback) 784 BodyDestructionCallback bodyCallback)
777 { 785 {
778 bool ret = false; 786 bool ret = false;
779 787
@@ -803,16 +811,16 @@ public sealed class BSShapeCollection : IDisposable
803 if (prim.IsSolid) 811 if (prim.IsSolid)
804 { 812 {
805 bodyPtr = BulletSimAPI.CreateBodyFromShape2(sim.ptr, shape.ptr, 813 bodyPtr = BulletSimAPI.CreateBodyFromShape2(sim.ptr, shape.ptr,
806 shapeData.ID, shapeData.Position, shapeData.Rotation); 814 prim.LocalID, prim.ForcePosition, prim.ForceOrientation);
807 DetailLog("{0},BSShapeCollection.CreateBody,mesh,ptr={1}", prim.LocalID, bodyPtr.ToString("X")); 815 DetailLog("{0},BSShapeCollection.CreateBody,mesh,ptr={1}", prim.LocalID, bodyPtr.ToString("X"));
808 } 816 }
809 else 817 else
810 { 818 {
811 bodyPtr = BulletSimAPI.CreateGhostFromShape2(sim.ptr, shape.ptr, 819 bodyPtr = BulletSimAPI.CreateGhostFromShape2(sim.ptr, shape.ptr,
812 shapeData.ID, shapeData.Position, shapeData.Rotation); 820 prim.LocalID, prim.ForcePosition, prim.ForceOrientation);
813 DetailLog("{0},BSShapeCollection.CreateBody,ghost,ptr={1}", prim.LocalID, bodyPtr.ToString("X")); 821 DetailLog("{0},BSShapeCollection.CreateBody,ghost,ptr={1}", prim.LocalID, bodyPtr.ToString("X"));
814 } 822 }
815 aBody = new BulletBody(shapeData.ID, bodyPtr); 823 aBody = new BulletBody(prim.LocalID, bodyPtr);
816 824
817 ReferenceBody(aBody, true); 825 ReferenceBody(aBody, true);
818 826