diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs index 869735c..892c34b 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | |||
@@ -178,7 +178,7 @@ public sealed class BSShapeCollection : IDisposable | |||
178 | bool ret = false; | 178 | bool ret = false; |
179 | switch (shape.type) | 179 | switch (shape.type) |
180 | { | 180 | { |
181 | case PhysicsShapeType.SHAPE_MESH: | 181 | case BSPhysicsShapeType.SHAPE_MESH: |
182 | MeshDesc meshDesc; | 182 | MeshDesc meshDesc; |
183 | if (Meshes.TryGetValue(shape.shapeKey, out meshDesc)) | 183 | if (Meshes.TryGetValue(shape.shapeKey, out meshDesc)) |
184 | { | 184 | { |
@@ -201,7 +201,7 @@ public sealed class BSShapeCollection : IDisposable | |||
201 | meshDesc.lastReferenced = System.DateTime.Now; | 201 | meshDesc.lastReferenced = System.DateTime.Now; |
202 | Meshes[shape.shapeKey] = meshDesc; | 202 | Meshes[shape.shapeKey] = meshDesc; |
203 | break; | 203 | break; |
204 | case PhysicsShapeType.SHAPE_HULL: | 204 | case BSPhysicsShapeType.SHAPE_HULL: |
205 | HullDesc hullDesc; | 205 | HullDesc hullDesc; |
206 | if (Hulls.TryGetValue(shape.shapeKey, out hullDesc)) | 206 | if (Hulls.TryGetValue(shape.shapeKey, out hullDesc)) |
207 | { | 207 | { |
@@ -224,7 +224,7 @@ public sealed class BSShapeCollection : IDisposable | |||
224 | hullDesc.lastReferenced = System.DateTime.Now; | 224 | hullDesc.lastReferenced = System.DateTime.Now; |
225 | Hulls[shape.shapeKey] = hullDesc; | 225 | Hulls[shape.shapeKey] = hullDesc; |
226 | break; | 226 | break; |
227 | case PhysicsShapeType.SHAPE_UNKNOWN: | 227 | case BSPhysicsShapeType.SHAPE_UNKNOWN: |
228 | break; | 228 | break; |
229 | default: | 229 | default: |
230 | // Native shapes are not tracked and they don't go into any list | 230 | // Native shapes are not tracked and they don't go into any list |
@@ -255,16 +255,16 @@ public sealed class BSShapeCollection : IDisposable | |||
255 | { | 255 | { |
256 | switch (shape.type) | 256 | switch (shape.type) |
257 | { | 257 | { |
258 | case PhysicsShapeType.SHAPE_HULL: | 258 | case BSPhysicsShapeType.SHAPE_HULL: |
259 | DereferenceHull(shape, shapeCallback); | 259 | DereferenceHull(shape, shapeCallback); |
260 | break; | 260 | break; |
261 | case PhysicsShapeType.SHAPE_MESH: | 261 | case BSPhysicsShapeType.SHAPE_MESH: |
262 | DereferenceMesh(shape, shapeCallback); | 262 | DereferenceMesh(shape, shapeCallback); |
263 | break; | 263 | break; |
264 | case PhysicsShapeType.SHAPE_COMPOUND: | 264 | case BSPhysicsShapeType.SHAPE_COMPOUND: |
265 | DereferenceCompound(shape, shapeCallback); | 265 | DereferenceCompound(shape, shapeCallback); |
266 | break; | 266 | break; |
267 | case PhysicsShapeType.SHAPE_UNKNOWN: | 267 | case BSPhysicsShapeType.SHAPE_UNKNOWN: |
268 | break; | 268 | break; |
269 | default: | 269 | default: |
270 | break; | 270 | break; |
@@ -352,28 +352,28 @@ public sealed class BSShapeCollection : IDisposable | |||
352 | BulletShape shapeInfo = new BulletShape(cShape); | 352 | BulletShape shapeInfo = new BulletShape(cShape); |
353 | if (TryGetMeshByPtr(cShape, out meshDesc)) | 353 | if (TryGetMeshByPtr(cShape, out meshDesc)) |
354 | { | 354 | { |
355 | shapeInfo.type = PhysicsShapeType.SHAPE_MESH; | 355 | shapeInfo.type = BSPhysicsShapeType.SHAPE_MESH; |
356 | shapeInfo.shapeKey = meshDesc.shapeKey; | 356 | shapeInfo.shapeKey = meshDesc.shapeKey; |
357 | } | 357 | } |
358 | else | 358 | else |
359 | { | 359 | { |
360 | if (TryGetHullByPtr(cShape, out hullDesc)) | 360 | if (TryGetHullByPtr(cShape, out hullDesc)) |
361 | { | 361 | { |
362 | shapeInfo.type = PhysicsShapeType.SHAPE_HULL; | 362 | shapeInfo.type = BSPhysicsShapeType.SHAPE_HULL; |
363 | shapeInfo.shapeKey = hullDesc.shapeKey; | 363 | shapeInfo.shapeKey = hullDesc.shapeKey; |
364 | } | 364 | } |
365 | else | 365 | else |
366 | { | 366 | { |
367 | if (BulletSimAPI.IsCompound2(cShape)) | 367 | if (BulletSimAPI.IsCompound2(cShape)) |
368 | { | 368 | { |
369 | shapeInfo.type = PhysicsShapeType.SHAPE_COMPOUND; | 369 | shapeInfo.type = BSPhysicsShapeType.SHAPE_COMPOUND; |
370 | } | 370 | } |
371 | else | 371 | else |
372 | { | 372 | { |
373 | if (BulletSimAPI.IsNativeShape2(cShape)) | 373 | if (BulletSimAPI.IsNativeShape2(cShape)) |
374 | { | 374 | { |
375 | shapeInfo.isNativeShape = true; | 375 | shapeInfo.isNativeShape = true; |
376 | shapeInfo.type = PhysicsShapeType.SHAPE_BOX; // (technically, type doesn't matter) | 376 | shapeInfo.type = BSPhysicsShapeType.SHAPE_BOX; // (technically, type doesn't matter) |
377 | } | 377 | } |
378 | } | 378 | } |
379 | } | 379 | } |
@@ -381,7 +381,7 @@ public sealed class BSShapeCollection : IDisposable | |||
381 | 381 | ||
382 | DetailLog("{0},BSShapeCollection.DereferenceAnonCollisionShape,shape={1}", BSScene.DetailLogZero, shapeInfo); | 382 | DetailLog("{0},BSShapeCollection.DereferenceAnonCollisionShape,shape={1}", BSScene.DetailLogZero, shapeInfo); |
383 | 383 | ||
384 | if (shapeInfo.type != PhysicsShapeType.SHAPE_UNKNOWN) | 384 | if (shapeInfo.type != BSPhysicsShapeType.SHAPE_UNKNOWN) |
385 | { | 385 | { |
386 | DereferenceShape(shapeInfo, true, null); | 386 | DereferenceShape(shapeInfo, true, null); |
387 | } | 387 | } |
@@ -405,10 +405,10 @@ public sealed class BSShapeCollection : IDisposable | |||
405 | bool ret = false; | 405 | bool ret = false; |
406 | bool haveShape = false; | 406 | bool haveShape = false; |
407 | 407 | ||
408 | if (!haveShape && prim.PreferredPhysicalShape == PhysicsShapeType.SHAPE_CAPSULE) | 408 | if (!haveShape && prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_CAPSULE) |
409 | { | 409 | { |
410 | // an avatar capsule is close to a native shape (it is not shared) | 410 | // an avatar capsule is close to a native shape (it is not shared) |
411 | ret = GetReferenceToNativeShape(prim, PhysicsShapeType.SHAPE_CAPSULE, | 411 | ret = GetReferenceToNativeShape(prim, BSPhysicsShapeType.SHAPE_CAPSULE, |
412 | FixedShapeKey.KEY_CAPSULE, shapeCallback); | 412 | FixedShapeKey.KEY_CAPSULE, shapeCallback); |
413 | DetailLog("{0},BSShapeCollection.CreateGeom,avatarCapsule,shape={1}", prim.LocalID, prim.PhysShape); | 413 | DetailLog("{0},BSShapeCollection.CreateGeom,avatarCapsule,shape={1}", prim.LocalID, prim.PhysShape); |
414 | ret = true; | 414 | ret = true; |
@@ -417,7 +417,7 @@ public sealed class BSShapeCollection : IDisposable | |||
417 | 417 | ||
418 | // Compound shapes are handled special as they are rebuilt from scratch. | 418 | // Compound shapes are handled special as they are rebuilt from scratch. |
419 | // This isn't too great a hardship since most of the child shapes will already been created. | 419 | // This isn't too great a hardship since most of the child shapes will already been created. |
420 | if (!haveShape && prim.PreferredPhysicalShape == PhysicsShapeType.SHAPE_COMPOUND) | 420 | if (!haveShape && prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_COMPOUND) |
421 | { | 421 | { |
422 | ret = GetReferenceToCompoundShape(prim, shapeCallback); | 422 | ret = GetReferenceToCompoundShape(prim, shapeCallback); |
423 | DetailLog("{0},BSShapeCollection.CreateGeom,compoundShape,shape={1}", prim.LocalID, prim.PhysShape); | 423 | DetailLog("{0},BSShapeCollection.CreateGeom,compoundShape,shape={1}", prim.LocalID, prim.PhysShape); |
@@ -460,10 +460,10 @@ public sealed class BSShapeCollection : IDisposable | |||
460 | haveShape = true; | 460 | haveShape = true; |
461 | if (forceRebuild | 461 | if (forceRebuild |
462 | || prim.Scale != prim.Size | 462 | || prim.Scale != prim.Size |
463 | || prim.PhysShape.type != PhysicsShapeType.SHAPE_SPHERE | 463 | || prim.PhysShape.type != BSPhysicsShapeType.SHAPE_SPHERE |
464 | ) | 464 | ) |
465 | { | 465 | { |
466 | ret = GetReferenceToNativeShape(prim, PhysicsShapeType.SHAPE_SPHERE, | 466 | ret = GetReferenceToNativeShape(prim, BSPhysicsShapeType.SHAPE_SPHERE, |
467 | FixedShapeKey.KEY_SPHERE, shapeCallback); | 467 | FixedShapeKey.KEY_SPHERE, shapeCallback); |
468 | DetailLog("{0},BSShapeCollection.CreateGeom,sphere,force={1},shape={2}", | 468 | DetailLog("{0},BSShapeCollection.CreateGeom,sphere,force={1},shape={2}", |
469 | prim.LocalID, forceRebuild, prim.PhysShape); | 469 | prim.LocalID, forceRebuild, prim.PhysShape); |
@@ -474,10 +474,10 @@ public sealed class BSShapeCollection : IDisposable | |||
474 | haveShape = true; | 474 | haveShape = true; |
475 | if (forceRebuild | 475 | if (forceRebuild |
476 | || prim.Scale != prim.Size | 476 | || prim.Scale != prim.Size |
477 | || prim.PhysShape.type != PhysicsShapeType.SHAPE_BOX | 477 | || prim.PhysShape.type != BSPhysicsShapeType.SHAPE_BOX |
478 | ) | 478 | ) |
479 | { | 479 | { |
480 | ret = GetReferenceToNativeShape( prim, PhysicsShapeType.SHAPE_BOX, | 480 | ret = GetReferenceToNativeShape( prim, BSPhysicsShapeType.SHAPE_BOX, |
481 | FixedShapeKey.KEY_BOX, shapeCallback); | 481 | FixedShapeKey.KEY_BOX, shapeCallback); |
482 | DetailLog("{0},BSShapeCollection.CreateGeom,box,force={1},shape={2}", | 482 | DetailLog("{0},BSShapeCollection.CreateGeom,box,force={1},shape={2}", |
483 | prim.LocalID, forceRebuild, prim.PhysShape); | 483 | prim.LocalID, forceRebuild, prim.PhysShape); |
@@ -519,7 +519,7 @@ public sealed class BSShapeCollection : IDisposable | |||
519 | // Creates a native shape and assignes it to prim.BSShape. | 519 | // Creates a native shape and assignes it to prim.BSShape. |
520 | // "Native" shapes are never shared. they are created here and destroyed in DereferenceShape(). | 520 | // "Native" shapes are never shared. they are created here and destroyed in DereferenceShape(). |
521 | private bool GetReferenceToNativeShape(BSPhysObject prim, | 521 | private bool GetReferenceToNativeShape(BSPhysObject prim, |
522 | PhysicsShapeType shapeType, FixedShapeKey shapeKey, | 522 | BSPhysicsShapeType shapeType, FixedShapeKey shapeKey, |
523 | ShapeDestructionCallback shapeCallback) | 523 | ShapeDestructionCallback shapeCallback) |
524 | { | 524 | { |
525 | // release any previous shape | 525 | // release any previous shape |
@@ -535,7 +535,7 @@ public sealed class BSShapeCollection : IDisposable | |||
535 | return true; | 535 | return true; |
536 | } | 536 | } |
537 | 537 | ||
538 | private BulletShape BuildPhysicalNativeShape(BSPhysObject prim, PhysicsShapeType shapeType, | 538 | private BulletShape BuildPhysicalNativeShape(BSPhysObject prim, BSPhysicsShapeType shapeType, |
539 | FixedShapeKey shapeKey) | 539 | FixedShapeKey shapeKey) |
540 | { | 540 | { |
541 | BulletShape newShape; | 541 | BulletShape newShape; |
@@ -548,7 +548,7 @@ public sealed class BSShapeCollection : IDisposable | |||
548 | nativeShapeData.MeshKey = (ulong)shapeKey; | 548 | nativeShapeData.MeshKey = (ulong)shapeKey; |
549 | nativeShapeData.HullKey = (ulong)shapeKey; | 549 | nativeShapeData.HullKey = (ulong)shapeKey; |
550 | 550 | ||
551 | if (shapeType == PhysicsShapeType.SHAPE_CAPSULE) | 551 | if (shapeType == BSPhysicsShapeType.SHAPE_CAPSULE) |
552 | { | 552 | { |
553 | // The proper scale has been calculated in the prim. | 553 | // The proper scale has been calculated in the prim. |
554 | newShape = new BulletShape( | 554 | newShape = new BulletShape( |
@@ -586,7 +586,7 @@ public sealed class BSShapeCollection : IDisposable | |||
586 | System.UInt64 newMeshKey = ComputeShapeKey(prim.Size, prim.BaseShape, out lod); | 586 | System.UInt64 newMeshKey = ComputeShapeKey(prim.Size, prim.BaseShape, out lod); |
587 | 587 | ||
588 | // if this new shape is the same as last time, don't recreate the mesh | 588 | // if this new shape is the same as last time, don't recreate the mesh |
589 | if (newMeshKey == prim.PhysShape.shapeKey && prim.PhysShape.type == PhysicsShapeType.SHAPE_MESH) | 589 | if (newMeshKey == prim.PhysShape.shapeKey && prim.PhysShape.type == BSPhysicsShapeType.SHAPE_MESH) |
590 | return false; | 590 | return false; |
591 | 591 | ||
592 | DetailLog("{0},BSShapeCollection.GetReferenceToMesh,create,oldKey={1},newKey={2}", | 592 | DetailLog("{0},BSShapeCollection.GetReferenceToMesh,create,oldKey={1},newKey={2}", |
@@ -644,7 +644,7 @@ public sealed class BSShapeCollection : IDisposable | |||
644 | indices.GetLength(0), indices, vertices.Count, verticesAsFloats); | 644 | indices.GetLength(0), indices, vertices.Count, verticesAsFloats); |
645 | } | 645 | } |
646 | } | 646 | } |
647 | BulletShape newShape = new BulletShape(meshPtr, PhysicsShapeType.SHAPE_MESH); | 647 | BulletShape newShape = new BulletShape(meshPtr, BSPhysicsShapeType.SHAPE_MESH); |
648 | newShape.shapeKey = newMeshKey; | 648 | newShape.shapeKey = newMeshKey; |
649 | 649 | ||
650 | return newShape; | 650 | return newShape; |
@@ -660,7 +660,7 @@ public sealed class BSShapeCollection : IDisposable | |||
660 | System.UInt64 newHullKey = ComputeShapeKey(prim.Size, prim.BaseShape, out lod); | 660 | System.UInt64 newHullKey = ComputeShapeKey(prim.Size, prim.BaseShape, out lod); |
661 | 661 | ||
662 | // if the hull hasn't changed, don't rebuild it | 662 | // if the hull hasn't changed, don't rebuild it |
663 | if (newHullKey == prim.PhysShape.shapeKey && prim.PhysShape.type == PhysicsShapeType.SHAPE_HULL) | 663 | if (newHullKey == prim.PhysShape.shapeKey && prim.PhysShape.type == BSPhysicsShapeType.SHAPE_HULL) |
664 | return false; | 664 | return false; |
665 | 665 | ||
666 | DetailLog("{0},BSShapeCollection.GetReferenceToHull,create,oldKey={1},newKey={2}", | 666 | DetailLog("{0},BSShapeCollection.GetReferenceToHull,create,oldKey={1},newKey={2}", |
@@ -781,7 +781,7 @@ public sealed class BSShapeCollection : IDisposable | |||
781 | } | 781 | } |
782 | } | 782 | } |
783 | 783 | ||
784 | BulletShape newShape = new BulletShape(hullPtr, PhysicsShapeType.SHAPE_HULL); | 784 | BulletShape newShape = new BulletShape(hullPtr, BSPhysicsShapeType.SHAPE_HULL); |
785 | newShape.shapeKey = newHullKey; | 785 | newShape.shapeKey = newHullKey; |
786 | 786 | ||
787 | return newShape; // 'true' means a new shape has been added to this prim | 787 | return newShape; // 'true' means a new shape has been added to this prim |
@@ -804,7 +804,7 @@ public sealed class BSShapeCollection : IDisposable | |||
804 | // DereferenceShape(prim.PhysShape, true, shapeCallback); | 804 | // DereferenceShape(prim.PhysShape, true, shapeCallback); |
805 | 805 | ||
806 | BulletShape cShape = new BulletShape( | 806 | BulletShape cShape = new BulletShape( |
807 | BulletSimAPI.CreateCompoundShape2(PhysicsScene.World.ptr, false), PhysicsShapeType.SHAPE_COMPOUND); | 807 | BulletSimAPI.CreateCompoundShape2(PhysicsScene.World.ptr, false), BSPhysicsShapeType.SHAPE_COMPOUND); |
808 | 808 | ||
809 | // Create the shape for the root prim and add it to the compound shape. Cannot be a native shape. | 809 | // Create the shape for the root prim and add it to the compound shape. Cannot be a native shape. |
810 | CreateGeomMeshOrHull(prim, shapeCallback); | 810 | CreateGeomMeshOrHull(prim, shapeCallback); |
@@ -895,7 +895,7 @@ public sealed class BSShapeCollection : IDisposable | |||
895 | 895 | ||
896 | // While we figure out the real problem, stick a simple native shape on the object. | 896 | // While we figure out the real problem, stick a simple native shape on the object. |
897 | BulletShape fillinShape = | 897 | BulletShape fillinShape = |
898 | BuildPhysicalNativeShape(prim, PhysicsShapeType.SHAPE_BOX, FixedShapeKey.KEY_BOX); | 898 | BuildPhysicalNativeShape(prim, BSPhysicsShapeType.SHAPE_BOX, FixedShapeKey.KEY_BOX); |
899 | 899 | ||
900 | return fillinShape; | 900 | return fillinShape; |
901 | } | 901 | } |