diff options
author | Robert Adams | 2012-11-20 11:24:25 -0800 |
---|---|---|
committer | Robert Adams | 2012-11-21 16:42:50 -0800 |
commit | d6db0d5740dae03174f65846556f2f06d573b5c4 (patch) | |
tree | 84d3377c6b9e9350ccb6edc64609cb61b9d86c97 /OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | |
parent | BulletSim: change PositionSanityCheck to apply a force to correct position co... (diff) | |
download | opensim-SC-d6db0d5740dae03174f65846556f2f06d573b5c4.zip opensim-SC-d6db0d5740dae03174f65846556f2f06d573b5c4.tar.gz opensim-SC-d6db0d5740dae03174f65846556f2f06d573b5c4.tar.bz2 opensim-SC-d6db0d5740dae03174f65846556f2f06d573b5c4.tar.xz |
BulletSim: uplevel PhysicsShapeType out of ShapeData structure (since it is getting simplified out of existance someday) and update all the references to that enum.
Diffstat (limited to '')
-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 7ef6429..746a52e 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 ShapeData.PhysicsShapeType.SHAPE_MESH: | 181 | case PhysicsShapeType.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 ShapeData.PhysicsShapeType.SHAPE_HULL: | 204 | case PhysicsShapeType.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 ShapeData.PhysicsShapeType.SHAPE_UNKNOWN: | 227 | case PhysicsShapeType.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 ShapeData.PhysicsShapeType.SHAPE_HULL: | 258 | case PhysicsShapeType.SHAPE_HULL: |
259 | DereferenceHull(shape, shapeCallback); | 259 | DereferenceHull(shape, shapeCallback); |
260 | break; | 260 | break; |
261 | case ShapeData.PhysicsShapeType.SHAPE_MESH: | 261 | case PhysicsShapeType.SHAPE_MESH: |
262 | DereferenceMesh(shape, shapeCallback); | 262 | DereferenceMesh(shape, shapeCallback); |
263 | break; | 263 | break; |
264 | case ShapeData.PhysicsShapeType.SHAPE_COMPOUND: | 264 | case PhysicsShapeType.SHAPE_COMPOUND: |
265 | DereferenceCompound(shape, shapeCallback); | 265 | DereferenceCompound(shape, shapeCallback); |
266 | break; | 266 | break; |
267 | case ShapeData.PhysicsShapeType.SHAPE_UNKNOWN: | 267 | case PhysicsShapeType.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 = ShapeData.PhysicsShapeType.SHAPE_MESH; | 355 | shapeInfo.type = PhysicsShapeType.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 = ShapeData.PhysicsShapeType.SHAPE_HULL; | 362 | shapeInfo.type = PhysicsShapeType.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 = ShapeData.PhysicsShapeType.SHAPE_COMPOUND; | 369 | shapeInfo.type = PhysicsShapeType.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 = ShapeData.PhysicsShapeType.SHAPE_BOX; // (technically, type doesn't matter) | 376 | shapeInfo.type = PhysicsShapeType.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 != ShapeData.PhysicsShapeType.SHAPE_UNKNOWN) | 384 | if (shapeInfo.type != PhysicsShapeType.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 == ShapeData.PhysicsShapeType.SHAPE_AVATAR) | 408 | if (!haveShape && prim.PreferredPhysicalShape == PhysicsShapeType.SHAPE_AVATAR) |
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, ShapeData.PhysicsShapeType.SHAPE_AVATAR, | 411 | ret = GetReferenceToNativeShape(prim, PhysicsShapeType.SHAPE_AVATAR, |
412 | ShapeData.FixedShapeKey.KEY_CAPSULE, shapeCallback); | 412 | ShapeData.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 == ShapeData.PhysicsShapeType.SHAPE_COMPOUND) | 420 | if (!haveShape && prim.PreferredPhysicalShape == PhysicsShapeType.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 != ShapeData.PhysicsShapeType.SHAPE_SPHERE | 463 | || prim.PhysShape.type != PhysicsShapeType.SHAPE_SPHERE |
464 | ) | 464 | ) |
465 | { | 465 | { |
466 | ret = GetReferenceToNativeShape(prim, ShapeData.PhysicsShapeType.SHAPE_SPHERE, | 466 | ret = GetReferenceToNativeShape(prim, PhysicsShapeType.SHAPE_SPHERE, |
467 | ShapeData.FixedShapeKey.KEY_SPHERE, shapeCallback); | 467 | ShapeData.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 != ShapeData.PhysicsShapeType.SHAPE_BOX | 477 | || prim.PhysShape.type != PhysicsShapeType.SHAPE_BOX |
478 | ) | 478 | ) |
479 | { | 479 | { |
480 | ret = GetReferenceToNativeShape( prim, ShapeData.PhysicsShapeType.SHAPE_BOX, | 480 | ret = GetReferenceToNativeShape( prim, PhysicsShapeType.SHAPE_BOX, |
481 | ShapeData.FixedShapeKey.KEY_BOX, shapeCallback); | 481 | ShapeData.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 | ShapeData.PhysicsShapeType shapeType, ShapeData.FixedShapeKey shapeKey, | 522 | PhysicsShapeType shapeType, ShapeData.FixedShapeKey shapeKey, |
523 | ShapeDestructionCallback shapeCallback) | 523 | ShapeDestructionCallback shapeCallback) |
524 | { | 524 | { |
525 | // release any previous shape | 525 | // release any previous shape |
@@ -538,7 +538,7 @@ public sealed class BSShapeCollection : IDisposable | |||
538 | return true; | 538 | return true; |
539 | } | 539 | } |
540 | 540 | ||
541 | private BulletShape BuildPhysicalNativeShape(BSPhysObject prim, ShapeData.PhysicsShapeType shapeType, | 541 | private BulletShape BuildPhysicalNativeShape(BSPhysObject prim, PhysicsShapeType shapeType, |
542 | ShapeData.FixedShapeKey shapeKey) | 542 | ShapeData.FixedShapeKey shapeKey) |
543 | { | 543 | { |
544 | BulletShape newShape; | 544 | BulletShape newShape; |
@@ -551,7 +551,7 @@ public sealed class BSShapeCollection : IDisposable | |||
551 | nativeShapeData.MeshKey = (ulong)shapeKey; | 551 | nativeShapeData.MeshKey = (ulong)shapeKey; |
552 | nativeShapeData.HullKey = (ulong)shapeKey; | 552 | nativeShapeData.HullKey = (ulong)shapeKey; |
553 | 553 | ||
554 | if (shapeType == ShapeData.PhysicsShapeType.SHAPE_AVATAR) | 554 | if (shapeType == PhysicsShapeType.SHAPE_AVATAR) |
555 | { | 555 | { |
556 | newShape = new BulletShape( | 556 | newShape = new BulletShape( |
557 | BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 1f, 1f, prim.Scale) | 557 | BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 1f, 1f, prim.Scale) |
@@ -585,7 +585,7 @@ public sealed class BSShapeCollection : IDisposable | |||
585 | System.UInt64 newMeshKey = ComputeShapeKey(prim.Size, prim.BaseShape, out lod); | 585 | System.UInt64 newMeshKey = ComputeShapeKey(prim.Size, prim.BaseShape, out lod); |
586 | 586 | ||
587 | // if this new shape is the same as last time, don't recreate the mesh | 587 | // if this new shape is the same as last time, don't recreate the mesh |
588 | if (newMeshKey == prim.PhysShape.shapeKey && prim.PhysShape.type == ShapeData.PhysicsShapeType.SHAPE_MESH) | 588 | if (newMeshKey == prim.PhysShape.shapeKey && prim.PhysShape.type == PhysicsShapeType.SHAPE_MESH) |
589 | return false; | 589 | return false; |
590 | 590 | ||
591 | DetailLog("{0},BSShapeCollection.GetReferenceToMesh,create,oldKey={1},newKey={2}", | 591 | DetailLog("{0},BSShapeCollection.GetReferenceToMesh,create,oldKey={1},newKey={2}", |
@@ -643,7 +643,7 @@ public sealed class BSShapeCollection : IDisposable | |||
643 | indices.GetLength(0), indices, vertices.Count, verticesAsFloats); | 643 | indices.GetLength(0), indices, vertices.Count, verticesAsFloats); |
644 | } | 644 | } |
645 | } | 645 | } |
646 | BulletShape newShape = new BulletShape(meshPtr, ShapeData.PhysicsShapeType.SHAPE_MESH); | 646 | BulletShape newShape = new BulletShape(meshPtr, PhysicsShapeType.SHAPE_MESH); |
647 | newShape.shapeKey = newMeshKey; | 647 | newShape.shapeKey = newMeshKey; |
648 | 648 | ||
649 | return newShape; | 649 | return newShape; |
@@ -659,7 +659,7 @@ public sealed class BSShapeCollection : IDisposable | |||
659 | System.UInt64 newHullKey = ComputeShapeKey(prim.Size, prim.BaseShape, out lod); | 659 | System.UInt64 newHullKey = ComputeShapeKey(prim.Size, prim.BaseShape, out lod); |
660 | 660 | ||
661 | // if the hull hasn't changed, don't rebuild it | 661 | // if the hull hasn't changed, don't rebuild it |
662 | if (newHullKey == prim.PhysShape.shapeKey && prim.PhysShape.type == ShapeData.PhysicsShapeType.SHAPE_HULL) | 662 | if (newHullKey == prim.PhysShape.shapeKey && prim.PhysShape.type == PhysicsShapeType.SHAPE_HULL) |
663 | return false; | 663 | return false; |
664 | 664 | ||
665 | DetailLog("{0},BSShapeCollection.GetReferenceToHull,create,oldKey={1},newKey={2}", | 665 | DetailLog("{0},BSShapeCollection.GetReferenceToHull,create,oldKey={1},newKey={2}", |
@@ -780,7 +780,7 @@ public sealed class BSShapeCollection : IDisposable | |||
780 | } | 780 | } |
781 | } | 781 | } |
782 | 782 | ||
783 | BulletShape newShape = new BulletShape(hullPtr, ShapeData.PhysicsShapeType.SHAPE_HULL); | 783 | BulletShape newShape = new BulletShape(hullPtr, PhysicsShapeType.SHAPE_HULL); |
784 | newShape.shapeKey = newHullKey; | 784 | newShape.shapeKey = newHullKey; |
785 | 785 | ||
786 | return newShape; // 'true' means a new shape has been added to this prim | 786 | return newShape; // 'true' means a new shape has been added to this prim |
@@ -803,7 +803,7 @@ public sealed class BSShapeCollection : IDisposable | |||
803 | // DereferenceShape(prim.PhysShape, true, shapeCallback); | 803 | // DereferenceShape(prim.PhysShape, true, shapeCallback); |
804 | 804 | ||
805 | BulletShape cShape = new BulletShape( | 805 | BulletShape cShape = new BulletShape( |
806 | BulletSimAPI.CreateCompoundShape2(PhysicsScene.World.ptr, false), ShapeData.PhysicsShapeType.SHAPE_COMPOUND); | 806 | BulletSimAPI.CreateCompoundShape2(PhysicsScene.World.ptr, false), PhysicsShapeType.SHAPE_COMPOUND); |
807 | 807 | ||
808 | // Create the shape for the root prim and add it to the compound shape. Cannot be a native shape. | 808 | // Create the shape for the root prim and add it to the compound shape. Cannot be a native shape. |
809 | CreateGeomMeshOrHull(prim, shapeCallback); | 809 | CreateGeomMeshOrHull(prim, shapeCallback); |
@@ -894,7 +894,7 @@ public sealed class BSShapeCollection : IDisposable | |||
894 | 894 | ||
895 | // While we figure out the real problem, stick a simple native shape on the object. | 895 | // While we figure out the real problem, stick a simple native shape on the object. |
896 | BulletShape fillinShape = | 896 | BulletShape fillinShape = |
897 | BuildPhysicalNativeShape(prim, ShapeData.PhysicsShapeType.SHAPE_BOX, ShapeData.FixedShapeKey.KEY_BOX); | 897 | BuildPhysicalNativeShape(prim, PhysicsShapeType.SHAPE_BOX, ShapeData.FixedShapeKey.KEY_BOX); |
898 | 898 | ||
899 | return fillinShape; | 899 | return fillinShape; |
900 | } | 900 | } |