Universe.Physics.BulletSPlugin.BSShapeCompound.DereferenceAnonCollisionShape C# (CSharp) Method

DereferenceAnonCollisionShape() private method

private DereferenceAnonCollisionShape ( BSScene physicsScene, BulletShape pShape ) : void
physicsScene BSScene
pShape BulletShape
return void
        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 (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);
                                }
                                else
                                {
                                    physicsScene.Logger.WarnFormat(
                                        "{0} DereferenceAnonCollisionShape. Did not find shape. {1}",
                                        LogHeader, pShape);
                                }
                            }
                        }
                    }
                }
            }
        }
    }