예제 #1
0
        //! test for a triangle, with edges
        public bool CollideTriangleExact(ref IndexedVector3 p1, ref IndexedVector3 p2, ref IndexedVector3 p3, ref Vector4 triangle_plane)
        {
            if (!CollidePlane(ref triangle_plane))
            {
                return(false);
            }

            IndexedVector3 center, extends;

            GetCenterExtend(out center, out extends);

            IndexedVector3 v1 = (p1 - center);
            IndexedVector3 v2 = (p2 - center);
            IndexedVector3 v3 = (p3 - center);

            //First axis
            IndexedVector3 diff     = (v2 - v1);
            IndexedVector3 abs_diff = diff.Absolute();

            //Test With X axis
            BoxCollision.TEST_CROSS_EDGE_BOX_X_AXIS_MCR(ref diff, ref abs_diff, ref v1, ref v3, ref extends);
            //Test With Y axis
            BoxCollision.TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(ref diff, ref abs_diff, ref v1, ref v3, ref extends);
            //Test With Z axis
            BoxCollision.TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(ref diff, ref abs_diff, ref v1, ref v3, ref extends);


            diff     = v3 - v2;
            abs_diff = diff.Absolute();
            //Test With X axis
            BoxCollision.TEST_CROSS_EDGE_BOX_X_AXIS_MCR(ref diff, ref abs_diff, ref v2, ref v1, ref extends);
            //Test With Y axis
            BoxCollision.TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(ref diff, ref abs_diff, ref v2, ref v1, ref extends);
            //Test With Z axis
            BoxCollision.TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(ref diff, ref abs_diff, ref v2, ref v1, ref extends);

            diff     = v1 - v3;
            abs_diff = diff.Absolute();

            //Test With X axis
            BoxCollision.TEST_CROSS_EDGE_BOX_X_AXIS_MCR(ref diff, ref abs_diff, ref v3, ref v2, ref extends);
            //Test With Y axis
            BoxCollision.TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(ref diff, ref abs_diff, ref v3, ref v2, ref extends);
            //Test With Z axis
            BoxCollision.TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(ref diff, ref abs_diff, ref v3, ref v2, ref extends);

            return(true);
        }
예제 #2
0
        public void ProjectionInterval(ref IndexedVector3 direction, out float vmin, out float vmax)
        {
            IndexedVector3 center = (m_max + m_min) * 0.5f;
            IndexedVector3 extend = m_max - center;

            float _fOrigin        = direction.Dot(ref center);
            float _fMaximumExtent = extend.Dot(direction.Absolute());

            vmin = _fOrigin - _fMaximumExtent;
            vmax = _fOrigin + _fMaximumExtent;
        }
예제 #3
0
 public override void SetLocalScaling(ref IndexedVector3 scaling)
 {
     m_localScaling = scaling.Absolute();
 }