コード例 #1
0
        private void Clear()
        {
            switch (Type)
            {
            case eCollisionType.Sphere:
                pSphere = null;
                break;

            case eCollisionType.Box:
                pBox = null;
                break;

            case eCollisionType.Mesh:
                pMesh = null;
                break;

            case eCollisionType.Cylinder:
                pCylinder = null;
                break;

            case eCollisionType.OOBB:
                pOOBB = null;
                break;

            case eCollisionType.Undefined:
                break;
            }
            ;
            Type = eCollisionType.None;
        }
コード例 #2
0
        //todo: CCollisionPart operator functions
        //CCollisionPart &operator=(const CCollisionPart &b) = delete;
        //CCollisionPart(const CCollisionPart &b) = delete;
        //CCollisionPart(CCollisionPart &&b)
        //CCollisionPart &operator=(CCollisionPart &&b)

        public bool Load(ref CDynMemoryReader r, ref CUberData data)
        {
            Clear();
            string s;

            s = r.ReadPascalStr();
            if (s == "")
            {
                return(false);
            }

            // This is a workaround for Marshal.SizeOf not working with enums. Assign to a temporary variable of the correct byte length first.
            uint typeTemp = 0;

            if (!r.Get(ref typeTemp))
            {
                return(false);
            }
            Type = (eCollisionType)typeTemp;

            if (!r.Get(ref BBoxMin))
            {
                return(false);
            }
            if (!r.Get(ref BBoxMax))
            {
                return(false);
            }

            switch (Type)
            {
            case eCollisionType.Sphere:
                pSphere = new CCollisionPartSphere();
                if (!pSphere.Load(ref r, ref data))
                {
                    return(false);
                }
                break;

            case eCollisionType.Box:
                pBox = new CCollisionPartBox();
                if (!pBox.Load(ref r, ref data))
                {
                    return(false);
                }
                break;

            case eCollisionType.Mesh:
                pMesh = new CCollisionPartMesh();
                if (!pMesh.Load(ref r, ref data))
                {
                    return(false);
                }
                break;

            case eCollisionType.Cylinder:
                pCylinder = new CCollisionPartCylinder();
                if (!pCylinder.Load(ref r, ref data))
                {
                    return(false);
                }
                break;

            case eCollisionType.OOBB:
                pOOBB = new CCollisionPartOOBB();
                if (!pOOBB.Load(ref r, ref data))
                {
                    return(false);
                }
                break;

            case eCollisionType.Undefined:
                break;

            default:
                //Should never happen.
                break;
            }

            return(true);
        }