// Sometimes we have a pointer to a collision shape but don't know what type it is. // Figure out type and call the correct dereference routine. // Called at taint-time. private void DereferenceAnonCollisionShape(BSScene physicsScene, BulletShape pShape) { // TODO: figure a better way to go through all the shape types and find a possible instance. physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,shape={1}", BSScene.DetailLogZero, pShape); BSShapeMesh meshDesc; if (BSShapeMesh.TryGetMeshByPtr(pShape, out meshDesc)) { meshDesc.Dereference(physicsScene); // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,foundMesh,shape={1}", BSScene.DetailLogZero, pShape); } else { BSShapeHull hullDesc; if (BSShapeHull.TryGetHullByPtr(pShape, out hullDesc)) { hullDesc.Dereference(physicsScene); // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,foundHull,shape={1}", BSScene.DetailLogZero, pShape); } else { BSShapeConvexHull chullDesc; if (BSShapeConvexHull.TryGetConvexHullByPtr(pShape, out chullDesc)) { chullDesc.Dereference(physicsScene); // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,foundConvexHull,shape={1}", BSScene.DetailLogZero, pShape); } else { BSShapeGImpact gImpactDesc; if (BSShapeGImpact.TryGetGImpactByPtr(pShape, out gImpactDesc)) { gImpactDesc.Dereference(physicsScene); // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,foundgImpact,shape={1}", BSScene.DetailLogZero, pShape); } else { // Didn't find it in the lists of specific types. It could be compound. BSShapeCompound compoundDesc; if (BSShapeCompound.TryGetCompoundByPtr(pShape, out compoundDesc)) { compoundDesc.Dereference(physicsScene); // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,recursiveCompoundShape,shape={1}", BSScene.DetailLogZero, pShape); } else { // If none of the above, maybe it is a simple native shape. if (physicsScene.PE.IsNativeShape(pShape)) { // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,assumingNative,shape={1}", BSScene.DetailLogZero, pShape); BSShapeNative nativeShape = new BSShapeNative(pShape); nativeShape.Dereference(physicsScene); } } } } } } }
// Sometimes we have a pointer to a collision shape but don't know what type it is. // Figure out type and call the correct dereference routine. // Called at taint-time. private void DereferenceAnonCollisionShape(BSScene physicsScene, BulletShape pShape) { BSShapeMesh meshDesc; if (BSShapeMesh.TryGetMeshByPtr(pShape, out meshDesc)) { meshDesc.Dereference(physicsScene); } else { BSShapeHull hullDesc; if (BSShapeHull.TryGetHullByPtr(pShape, out hullDesc)) { hullDesc.Dereference(physicsScene); } else { BSShapeConvexHull chullDesc; if (BSShapeConvexHull.TryGetHullByPtr(pShape, out chullDesc)) { chullDesc.Dereference(physicsScene); } else { if (physicsScene.PE.IsCompound(pShape)) { BSShapeCompound recursiveCompound = new BSShapeCompound(pShape); recursiveCompound.Dereference(physicsScene); } else { if (physicsScene.PE.IsNativeShape(pShape)) { BSShapeNative nativeShape = new BSShapeNative(pShape); nativeShape.Dereference(physicsScene); } } } } } }