public MyRBElement CreateRBElement(MyRBElementDesc desc)
        {
            switch (desc.GetElementType())
            {
            case MyRBElementType.ET_SPHERE:
            {
                MyRBSphereElement element = m_RBSphereElementPool.Allocate();

                MyCommonDebugUtils.AssertDebug(element != null);

                if (element.LoadFromDesc(desc))
                {
                    return(element);
                }
                else
                {
                    m_RBSphereElementPool.Deallocate(element);
                    return(null);
                }
            }
            break;

            case MyRBElementType.ET_BOX:
            {
                MyRBBoxElement element = m_RBBoxElementPool.Allocate();

                MyCommonDebugUtils.AssertDebug(element != null);

                if (element.LoadFromDesc(desc))
                {
                    return(element);
                }
                else
                {
                    m_RBBoxElementPool.Deallocate(element);
                    return(null);
                }
            }
            break;

            case MyRBElementType.ET_CAPSULE:
            {
                MyRBCapsuleElement element = m_RBCapsuleElementPool.Allocate();

                MyCommonDebugUtils.AssertDebug(element != null);

                if (element.LoadFromDesc(desc))
                {
                    return(element);
                }
                else
                {
                    m_RBCapsuleElementPool.Deallocate(element);
                    return(null);
                }
            }
            break;

            case MyRBElementType.ET_TRIANGLEMESH:
            {
                MyRBTriangleMeshElement element = m_RBTriangleMeshElementPool.Allocate();

                MyCommonDebugUtils.AssertDebug(element != null);

                if (element.LoadFromDesc(desc))
                {
                    return(element);
                }
                else
                {
                    m_RBTriangleMeshElementPool.Deallocate(element);
                    return(null);
                }
            }
            break;

            case MyRBElementType.ET_VOXEL:
            {
                MyRBVoxelElement element = m_RBVoxelElementPool.Allocate();

                MyCommonDebugUtils.AssertDebug(element != null);

                if (element.LoadFromDesc(desc))
                {
                    return(element);
                }
                else
                {
                    m_RBVoxelElementPool.Deallocate(element);
                    return(null);
                }
            }
            break;

            default:
                // unknown element type
                MyCommonDebugUtils.AssertDebug(false);
                break;
            }
            return(null);
        }
        public MyRBElement CreateRBElement(MyRBElementDesc desc)
        {
            switch (desc.GetElementType())
            {
                case MyRBElementType.ET_SPHERE:
                    {
                        MyRBSphereElement element = m_RBSphereElementPool.Allocate();

                        MyCommonDebugUtils.AssertDebug(element != null);

                        if (element.LoadFromDesc(desc))
                            return element;
                        else
                        {
                            m_RBSphereElementPool.Deallocate(element);
                            return null;
                        }
                    }
                    break;
                case MyRBElementType.ET_BOX:
                    {
                        MyRBBoxElement element = m_RBBoxElementPool.Allocate();

                        MyCommonDebugUtils.AssertDebug(element != null);

                        if (element.LoadFromDesc(desc))
                            return element;
                        else
                        {
                            m_RBBoxElementPool.Deallocate(element);
                            return null;
                        }
                    }
                    break;
                case MyRBElementType.ET_CAPSULE:
                    {
                        MyRBCapsuleElement element = m_RBCapsuleElementPool.Allocate();

                        MyCommonDebugUtils.AssertDebug(element != null);

                        if (element.LoadFromDesc(desc))
                            return element;
                        else
                        {
                            m_RBCapsuleElementPool.Deallocate(element);
                            return null;
                        }
                    }
                    break;
                case MyRBElementType.ET_TRIANGLEMESH:
                    {
                        MyRBTriangleMeshElement element = m_RBTriangleMeshElementPool.Allocate();

                        MyCommonDebugUtils.AssertDebug(element != null);

                        if (element.LoadFromDesc(desc))
                            return element;
                        else
                        {
                            m_RBTriangleMeshElementPool.Deallocate(element);
                            return null;
                        }
                    }
                    break;
                case MyRBElementType.ET_VOXEL:
                    {
                        MyRBVoxelElement element = m_RBVoxelElementPool.Allocate();

                        MyCommonDebugUtils.AssertDebug(element != null);

                        if (element.LoadFromDesc(desc))
                            return element;
                        else
                        {
                            m_RBVoxelElementPool.Deallocate(element);
                            return null;
                        }
                    }
                    break;
                default:
                    // unknown element type
                    MyCommonDebugUtils.AssertDebug(false);
                    break;
            }
            return null;
        }