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.cs42
1 files changed, 21 insertions, 21 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
index 72c6df5..b428ba3 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
@@ -102,7 +102,7 @@ public class BSShapeCollection : IDisposable
102 bool newBody = CreateBody((newGeom || forceRebuild), prim, PhysicsScene.World, prim.BSShape, shapeData); 102 bool newBody = CreateBody((newGeom || forceRebuild), prim, PhysicsScene.World, prim.BSShape, shapeData);
103 ret = newGeom || newBody; 103 ret = newGeom || newBody;
104 } 104 }
105 DetailLog("{0},BSShapeCollection.GetBodyAndShape,force={1},ret={2},body={3},shape={4}", 105 DetailLog("{0},BSShapeCollection.GetBodyAndShape,force={1},ret={2},body={3},shape={4}",
106 prim.LocalID, forceRebuild, ret, prim.BSBody, prim.BSShape); 106 prim.LocalID, forceRebuild, ret, prim.BSBody, prim.BSShape);
107 107
108 return ret; 108 return ret;
@@ -149,14 +149,14 @@ public class BSShapeCollection : IDisposable
149 bodyDesc.lastReferenced = System.DateTime.Now; 149 bodyDesc.lastReferenced = System.DateTime.Now;
150 Bodies[shape.ID] = bodyDesc; 150 Bodies[shape.ID] = bodyDesc;
151 DetailLog("{0},BSShapeCollection.DereferenceBody,ref={1}", shape.ID, bodyDesc.referenceCount); 151 DetailLog("{0},BSShapeCollection.DereferenceBody,ref={1}", shape.ID, bodyDesc.referenceCount);
152 152
153 // If body is no longer being used, free it -- bodies are never shared. 153 // If body is no longer being used, free it -- bodies are never shared.
154 if (bodyDesc.referenceCount == 0) 154 if (bodyDesc.referenceCount == 0)
155 { 155 {
156 Bodies.Remove(shape.ID); 156 Bodies.Remove(shape.ID);
157 BSScene.TaintCallback removeOperation = delegate() 157 BSScene.TaintCallback removeOperation = delegate()
158 { 158 {
159 DetailLog("{0},BSShapeCollection.DereferenceBody,DestroyingBody. ptr={1}", 159 DetailLog("{0},BSShapeCollection.DereferenceBody,DestroyingBody. ptr={1}",
160 shape.ID, shape.ptr.ToString("X")); 160 shape.ID, shape.ptr.ToString("X"));
161 // Zero any reference to the shape so it is not freed when the body is deleted. 161 // Zero any reference to the shape so it is not freed when the body is deleted.
162 BulletSimAPI.SetCollisionShape2(PhysicsScene.World.ptr, shape.ptr, IntPtr.Zero); 162 BulletSimAPI.SetCollisionShape2(PhysicsScene.World.ptr, shape.ptr, IntPtr.Zero);
@@ -344,28 +344,28 @@ public class BSShapeCollection : IDisposable
344 if (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1) 344 if (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1)
345 { 345 {
346 haveShape = true; 346 haveShape = true;
347 if (forceRebuild 347 if (forceRebuild
348 || prim.Scale != shapeData.Size 348 || prim.Scale != shapeData.Size
349 || prim.BSShape.type != ShapeData.PhysicsShapeType.SHAPE_SPHERE 349 || prim.BSShape.type != ShapeData.PhysicsShapeType.SHAPE_SPHERE
350 ) 350 )
351 { 351 {
352 ret = GetReferenceToNativeShape(prim, shapeData, 352 ret = GetReferenceToNativeShape(prim, shapeData,
353 ShapeData.PhysicsShapeType.SHAPE_SPHERE, ShapeData.FixedShapeKey.KEY_SPHERE); 353 ShapeData.PhysicsShapeType.SHAPE_SPHERE, ShapeData.FixedShapeKey.KEY_SPHERE);
354 DetailLog("{0},BSShapeCollection.CreateGeom,sphere,force={1},shape={2}", 354 DetailLog("{0},BSShapeCollection.CreateGeom,sphere,force={1},shape={2}",
355 prim.LocalID, forceRebuild, prim.BSShape); 355 prim.LocalID, forceRebuild, prim.BSShape);
356 } 356 }
357 } 357 }
358 else 358 else
359 { 359 {
360 haveShape = true; 360 haveShape = true;
361 if (forceRebuild 361 if (forceRebuild
362 || prim.Scale != shapeData.Size 362 || prim.Scale != shapeData.Size
363 || prim.BSShape.type != ShapeData.PhysicsShapeType.SHAPE_BOX 363 || prim.BSShape.type != ShapeData.PhysicsShapeType.SHAPE_BOX
364 ) 364 )
365 { 365 {
366 ret = GetReferenceToNativeShape( 366 ret = GetReferenceToNativeShape(
367 prim, shapeData, ShapeData.PhysicsShapeType.SHAPE_BOX, ShapeData.FixedShapeKey.KEY_BOX); 367 prim, shapeData, ShapeData.PhysicsShapeType.SHAPE_BOX, ShapeData.FixedShapeKey.KEY_BOX);
368 DetailLog("{0},BSShapeCollection.CreateGeom,box,force={1},shape={2}", 368 DetailLog("{0},BSShapeCollection.CreateGeom,box,force={1},shape={2}",
369 prim.LocalID, forceRebuild, prim.BSShape); 369 prim.LocalID, forceRebuild, prim.BSShape);
370 } 370 }
371 } 371 }
@@ -379,13 +379,13 @@ public class BSShapeCollection : IDisposable
379 { 379 {
380 // Update prim.BSShape to reference a hull of this shape. 380 // Update prim.BSShape to reference a hull of this shape.
381 ret = GetReferenceToHull(prim, shapeData, pbs); 381 ret = GetReferenceToHull(prim, shapeData, pbs);
382 DetailLog("{0},BSShapeCollection.CreateGeom,hull,shape={1},key={2}", 382 DetailLog("{0},BSShapeCollection.CreateGeom,hull,shape={1},key={2}",
383 shapeData.ID, prim.BSShape, prim.BSShape.shapeKey.ToString("X")); 383 shapeData.ID, prim.BSShape, prim.BSShape.shapeKey.ToString("X"));
384 } 384 }
385 else 385 else
386 { 386 {
387 ret = GetReferenceToMesh(prim, shapeData, pbs); 387 ret = GetReferenceToMesh(prim, shapeData, pbs);
388 DetailLog("{0},BSShapeCollection.CreateGeom,mesh,shape={1},key={2}", 388 DetailLog("{0},BSShapeCollection.CreateGeom,mesh,shape={1},key={2}",
389 shapeData.ID, prim.BSShape, prim.BSShape.shapeKey.ToString("X")); 389 shapeData.ID, prim.BSShape, prim.BSShape.shapeKey.ToString("X"));
390 } 390 }
391 } 391 }
@@ -393,7 +393,7 @@ public class BSShapeCollection : IDisposable
393 } 393 }
394 394
395 // Creates a native shape and assignes it to prim.BSShape 395 // Creates a native shape and assignes it to prim.BSShape
396 private bool GetReferenceToNativeShape( BSPrim prim, ShapeData shapeData, 396 private bool GetReferenceToNativeShape( BSPrim prim, ShapeData shapeData,
397 ShapeData.PhysicsShapeType shapeType, ShapeData.FixedShapeKey shapeKey) 397 ShapeData.PhysicsShapeType shapeType, ShapeData.FixedShapeKey shapeKey)
398 { 398 {
399 BulletShape newShape; 399 BulletShape newShape;
@@ -432,7 +432,7 @@ public class BSShapeCollection : IDisposable
432 // if this new shape is the same as last time, don't recreate the mesh 432 // if this new shape is the same as last time, don't recreate the mesh
433 if (prim.BSShape.shapeKey == newMeshKey) return false; 433 if (prim.BSShape.shapeKey == newMeshKey) return false;
434 434
435 DetailLog("{0},BSShapeCollection.CreateGeomMesh,create,oldKey={1},newKey={2}", 435 DetailLog("{0},BSShapeCollection.CreateGeomMesh,create,oldKey={1},newKey={2}",
436 prim.LocalID, prim.BSShape.shapeKey.ToString("X"), newMeshKey.ToString("X")); 436 prim.LocalID, prim.BSShape.shapeKey.ToString("X"), newMeshKey.ToString("X"));
437 437
438 // Since we're recreating new, get rid of the reference to the previous shape 438 // Since we're recreating new, get rid of the reference to the previous shape
@@ -476,10 +476,10 @@ public class BSShapeCollection : IDisposable
476 verticesAsFloats[vi++] = vv.Z; 476 verticesAsFloats[vi++] = vv.Z;
477 } 477 }
478 478
479 // m_log.DebugFormat("{0}: CreateGeomMesh: calling CreateMesh. lid={1}, key={2}, indices={3}, vertices={4}", 479 // m_log.DebugFormat("{0}: CreateGeomMesh: calling CreateMesh. lid={1}, key={2}, indices={3}, vertices={4}",
480 // LogHeader, prim.LocalID, newMeshKey, indices.Length, vertices.Count); 480 // LogHeader, prim.LocalID, newMeshKey, indices.Length, vertices.Count);
481 481
482 meshPtr = BulletSimAPI.CreateMeshShape2(PhysicsScene.World.ptr, 482 meshPtr = BulletSimAPI.CreateMeshShape2(PhysicsScene.World.ptr,
483 indices.GetLength(0), indices, vertices.Count, verticesAsFloats); 483 indices.GetLength(0), indices, vertices.Count, verticesAsFloats);
484 } 484 }
485 BulletShape newShape = new BulletShape(meshPtr, ShapeData.PhysicsShapeType.SHAPE_MESH); 485 BulletShape newShape = new BulletShape(meshPtr, ShapeData.PhysicsShapeType.SHAPE_MESH);
@@ -501,14 +501,14 @@ public class BSShapeCollection : IDisposable
501 if (newHullKey == prim.BSShape.shapeKey && prim.BSShape.type == ShapeData.PhysicsShapeType.SHAPE_HULL) 501 if (newHullKey == prim.BSShape.shapeKey && prim.BSShape.type == ShapeData.PhysicsShapeType.SHAPE_HULL)
502 return false; 502 return false;
503 503
504 DetailLog("{0},BSShapeCollection.CreateGeomHull,create,oldKey={1},newKey={2}", 504 DetailLog("{0},BSShapeCollection.CreateGeomHull,create,oldKey={1},newKey={2}",
505 prim.LocalID, prim.BSShape.shapeKey.ToString("X"), newHullKey.ToString("X")); 505 prim.LocalID, prim.BSShape.shapeKey.ToString("X"), newHullKey.ToString("X"));
506 506
507 // Remove usage of the previous shape. Also removes reference to underlying mesh if it is a hull. 507 // Remove usage of the previous shape. Also removes reference to underlying mesh if it is a hull.
508 DereferenceShape(prim.BSShape, true); 508 DereferenceShape(prim.BSShape, true);
509 509
510 newShape = CreatePhysicalHull(prim.PhysObjectName, newHullKey, pbs, shapeData.Size, lod); 510 newShape = CreatePhysicalHull(prim.PhysObjectName, newHullKey, pbs, shapeData.Size, lod);
511 511
512 ReferenceShape(newShape); 512 ReferenceShape(newShape);
513 513
514 // hulls are already scaled by the meshmerizer 514 // hulls are already scaled by the meshmerizer
@@ -559,7 +559,7 @@ public class BSShapeCollection : IDisposable
559 convexBuilder.process(dcomp); 559 convexBuilder.process(dcomp);
560 560
561 // Convert the vertices and indices for passing to unmanaged. 561 // Convert the vertices and indices for passing to unmanaged.
562 // The hull information is passed as a large floating point array. 562 // The hull information is passed as a large floating point array.
563 // The format is: 563 // The format is:
564 // convHulls[0] = number of hulls 564 // convHulls[0] = number of hulls
565 // convHulls[1] = number of vertices in first hull 565 // convHulls[1] = number of vertices in first hull
@@ -635,11 +635,11 @@ public class BSShapeCollection : IDisposable
635 { 635 {
636 // level of detail based on size and type of the object 636 // level of detail based on size and type of the object
637 float lod = PhysicsScene.MeshLOD; 637 float lod = PhysicsScene.MeshLOD;
638 if (pbs.SculptEntry) 638 if (pbs.SculptEntry)
639 lod = PhysicsScene.SculptLOD; 639 lod = PhysicsScene.SculptLOD;
640 640
641 float maxAxis = Math.Max(shapeData.Size.X, Math.Max(shapeData.Size.Y, shapeData.Size.Z)); 641 float maxAxis = Math.Max(shapeData.Size.X, Math.Max(shapeData.Size.Y, shapeData.Size.Z));
642 if (maxAxis > PhysicsScene.MeshMegaPrimThreshold) 642 if (maxAxis > PhysicsScene.MeshMegaPrimThreshold)
643 lod = PhysicsScene.MeshMegaPrimLOD; 643 lod = PhysicsScene.MeshMegaPrimLOD;
644 644
645 retLod = lod; 645 retLod = lod;
@@ -685,13 +685,13 @@ public class BSShapeCollection : IDisposable
685 IntPtr bodyPtr = IntPtr.Zero; 685 IntPtr bodyPtr = IntPtr.Zero;
686 if (prim.IsSolid) 686 if (prim.IsSolid)
687 { 687 {
688 bodyPtr = BulletSimAPI.CreateBodyFromShape2(sim.ptr, shape.ptr, 688 bodyPtr = BulletSimAPI.CreateBodyFromShape2(sim.ptr, shape.ptr,
689 shapeData.ID, shapeData.Position, shapeData.Rotation); 689 shapeData.ID, shapeData.Position, shapeData.Rotation);
690 // DetailLog("{0},BSShapeCollection.CreateBody,mesh,ptr={1}", prim.LocalID, bodyPtr.ToString("X")); 690 // DetailLog("{0},BSShapeCollection.CreateBody,mesh,ptr={1}", prim.LocalID, bodyPtr.ToString("X"));
691 } 691 }
692 else 692 else
693 { 693 {
694 bodyPtr = BulletSimAPI.CreateGhostFromShape2(sim.ptr, shape.ptr, 694 bodyPtr = BulletSimAPI.CreateGhostFromShape2(sim.ptr, shape.ptr,
695 shapeData.ID, shapeData.Position, shapeData.Rotation); 695 shapeData.ID, shapeData.Position, shapeData.Rotation);
696 // DetailLog("{0},BSShapeCollection.CreateBody,ghost,ptr={1}", prim.LocalID, bodyPtr.ToString("X")); 696 // DetailLog("{0},BSShapeCollection.CreateBody,ghost,ptr={1}", prim.LocalID, bodyPtr.ToString("X"));
697 } 697 }