Esempio n. 1
0
 public void GetBulletTriangle(int prim_index, TriangleShapeEx triangle)
 {
     GetIndices(prim_index, out indicesHolder[0], out indicesHolder[1], out indicesHolder[2]);
     GetVertex(indicesHolder[0], out triangle.m_vertices1[0]);
     GetVertex(indicesHolder[1], out triangle.m_vertices1[1]);
     GetVertex(indicesHolder[2], out triangle.m_vertices1[2]);
     triangle.SetMargin(m_margin);
 }
        public virtual void ProcessTriangle(IndexedVector3[] triangle, int partId, int triangleIndex)
        {
            TriangleShapeEx tri1 = new TriangleShapeEx(ref triangle[0], ref triangle[1], ref triangle[2]);

            tri1.SetMargin(margin);
            if (swapped)
            {
                algorithm.SetPart0(partId);
                algorithm.SetFace0(triangleIndex);
            }
            else
            {
                algorithm.SetPart1(partId);
                algorithm.SetFace1(triangleIndex);
            }
            algorithm.GImpactVsShape(body0, body1, gimpactshape0, tri1, swapped);
        }
        //! Collision routines
        //!@{

        protected void CollideGjkTriangles(CollisionObject body0,
                                           CollisionObject body1,
                                           GImpactMeshShapePart shape0,
                                           GImpactMeshShapePart shape1,
                                           ObjectArray <int> pairs, int pair_count)
        {
            TriangleShapeEx tri0 = new TriangleShapeEx();
            TriangleShapeEx tri1 = new TriangleShapeEx();

            shape0.LockChildShapes();
            shape1.LockChildShapes();

            int pair_pointer = 0;

#if DEBUG
            if (BulletGlobals.g_streamWriter != null && BulletGlobals.debugGimpactAlgo)
            {
                BulletGlobals.g_streamWriter.WriteLine("GImpactAglo::CollideGjkTriangles [{0}]", pair_count);
            }
#endif
            while (pair_count-- != 0)
            {
                m_triface0    = pairs[pair_pointer];
                m_triface1    = pairs[pair_pointer + 1];
                pair_pointer += 2;



                shape0.GetBulletTriangle(m_triface0, tri0);
                shape1.GetBulletTriangle(m_triface1, tri1);


                //collide two convex shapes
                if (tri0.OverlapTestConservative(tri1))
                {
                    ConvexVsConvexCollision(body0, body1, tri0, tri1);
                }
            }

            shape0.UnlockChildShapes();
            shape1.UnlockChildShapes();
        }
Esempio n. 4
0
        public bool OverlapTestConservative(TriangleShapeEx other)
        {
            float total_margin = GetMargin() + other.GetMargin();

            IndexedVector4 plane0;

            BuildTriPlane(out plane0);
            IndexedVector4 plane1;

            other.BuildTriPlane(out plane1);

            // classify points on other triangle
            float dis0 = ClipPolygon.DistancePointPlane(ref plane0, ref other.m_vertices1[0]) - total_margin;

            float dis1 = ClipPolygon.DistancePointPlane(ref plane0, ref other.m_vertices1[1]) - total_margin;

            float dis2 = ClipPolygon.DistancePointPlane(ref plane0, ref other.m_vertices1[2]) - total_margin;

            if (dis0 > 0.0f && dis1 > 0.0f && dis2 > 0.0f)
            {
                return(false);
            }

            // classify points on this triangle
            dis0 = ClipPolygon.DistancePointPlane(ref plane1, ref m_vertices1[0]) - total_margin;

            dis1 = ClipPolygon.DistancePointPlane(ref plane1, ref m_vertices1[1]) - total_margin;

            dis2 = ClipPolygon.DistancePointPlane(ref plane1, ref m_vertices1[2]) - total_margin;

            if (dis0 > 0.0f && dis1 > 0.0f && dis2 > 0.0f)
            {
                return(false);
            }

            return(true);
        }
 public virtual void ProcessTriangle(IndexedVector3[] triangle, int partId, int triangleIndex)
 {
     TriangleShapeEx tri1 = new TriangleShapeEx(ref triangle[0], ref triangle[1], ref triangle[2]);
     tri1.SetMargin(margin);
     if (swapped)
     {
         algorithm.SetPart0(partId);
         algorithm.SetFace0(triangleIndex);
     }
     else
     {
         algorithm.SetPart1(partId);
         algorithm.SetFace1(triangleIndex);
     }
     algorithm.GImpactVsShape(body0, body1, gimpactshape0, tri1, swapped);
 }
        //! Collision routines
        //!@{

        protected void CollideGjkTriangles(CollisionObject body0,
                      CollisionObject body1,
                      GImpactMeshShapePart shape0,
                      GImpactMeshShapePart shape1,
                      ObjectArray<int> pairs, int pair_count)
        {
            TriangleShapeEx tri0 = new TriangleShapeEx();
            TriangleShapeEx tri1 = new TriangleShapeEx();

            shape0.LockChildShapes();
            shape1.LockChildShapes();

            int pair_pointer = 0;

            if (BulletGlobals.g_streamWriter != null && BulletGlobals.debugGimpactAlgo)
            {
                BulletGlobals.g_streamWriter.WriteLine("GImpactAglo::CollideGjkTriangles [{0}]", pair_count);
            }

            while (pair_count-- != 0)
            {

                m_triface0 = pairs[pair_pointer];
                m_triface1 = pairs[pair_pointer + 1];
                pair_pointer += 2;



                shape0.GetBulletTriangle(m_triface0, tri0);
                shape1.GetBulletTriangle(m_triface1, tri1);


                //collide two convex shapes
                if (tri0.OverlapTestConservative(tri1))
                {
                    ConvexVsConvexCollision(body0, body1, tri0, tri1);
                }

            }

            shape0.UnlockChildShapes();
            shape1.UnlockChildShapes();

        }
Esempio n. 7
0
 public override void GetBulletTriangle(int prim_index, TriangleShapeEx triangle)
 {
     m_primitive_manager.GetBulletTriangle(prim_index, triangle);
 }
Esempio n. 8
0
 public override void GetBulletTriangle(int prim_index, TriangleShapeEx triangle)
 {
     Debug.Assert(false);
 }
Esempio n. 9
0
 public abstract void GetBulletTriangle(int prim_index, TriangleShapeEx triangle);
Esempio n. 10
0
 public override void GetBulletTriangle(int prim_index, TriangleShapeEx triangle)
 {
     m_primitive_manager.GetBulletTriangle(prim_index, triangle);
 }
Esempio n. 11
0
 public void GetBulletTriangle(int prim_index, TriangleShapeEx triangle)
 {
     GetIndices(prim_index, out indicesHolder[0], out indicesHolder[1], out indicesHolder[2]);
     GetVertex(indicesHolder[0], out triangle.m_vertices1[0]);
     GetVertex(indicesHolder[1], out triangle.m_vertices1[1]);
     GetVertex(indicesHolder[2], out triangle.m_vertices1[2]);
     triangle.SetMargin(m_margin);
 }
Esempio n. 12
0
 public override void GetBulletTriangle(int prim_index, TriangleShapeEx triangle)
 {
     Debug.Assert(false);
 }
Esempio n. 13
0
 public abstract void GetBulletTriangle(int prim_index, TriangleShapeEx triangle);
        public bool OverlapTestConservative(TriangleShapeEx other)
        {
            float total_margin = GetMargin() + other.GetMargin();

            IndexedVector4 plane0;
            BuildTriPlane(out plane0);
            IndexedVector4 plane1;
            other.BuildTriPlane(out plane1);

            // classify points on other triangle
            float dis0 = ClipPolygon.DistancePointPlane(ref plane0, ref other.m_vertices1[0]) - total_margin;

            float dis1 = ClipPolygon.DistancePointPlane(ref plane0, ref other.m_vertices1[1]) - total_margin;

            float dis2 = ClipPolygon.DistancePointPlane(ref plane0, ref other.m_vertices1[2]) - total_margin;

            if (dis0 > 0.0f && dis1 > 0.0f && dis2 > 0.0f) return false;

            // classify points on this triangle
            dis0 = ClipPolygon.DistancePointPlane(ref plane1, ref m_vertices1[0]) - total_margin;

            dis1 = ClipPolygon.DistancePointPlane(ref plane1, ref m_vertices1[1]) - total_margin;

            dis2 = ClipPolygon.DistancePointPlane(ref plane1, ref m_vertices1[2]) - total_margin;

            if (dis0 > 0.0f && dis1 > 0.0f && dis2 > 0.0f) return false;

            return true;

        }
 public TriangleShapeEx(TriangleShapeEx other)
     : base(ref other.m_vertices1[0], ref other.m_vertices1[1], ref other.m_vertices1[2])
 {
 }
Esempio n. 16
0
 public TriangleShapeEx(TriangleShapeEx other)
     : base(ref other.m_vertices1[0], ref other.m_vertices1[1], ref other.m_vertices1[2])
 {
 }