Exemplo n.º 1
0
    // SPHERE TRIANGLE
    public void HandleSphereTriangle()
    {
        float3 spherePos    = posA;
        float  sphereRadius = extentsA.x;
        float3 triPos       = posB;
        float3 triSize      = extentsB;
        float3 triRot       = rotB;

        float3[] triangleVerts            = GetVerticesOfTriangle(triPos, triSize, triRot); // would already be stored
        FixedList128 <float3> triVertices = new FixedList128 <float3>();

        triVertices.Add(triangleVerts[0]);
        triVertices.Add(triangleVerts[1]);
        triVertices.Add(triangleVerts[2]);

        if (ColPhysics.SphereIntersectsOrientedTriangle(spherePos, sphereRadius, triVertices, out float3 closestPoint, out float distance))
        {
            isColliding = true;

            if (drawMarkers)
            {
                display.DrawMarker(closestPoint);
            }

            if (resolveCollisions)
            {
                ColPhysics.ResolveSphereTriangleCollision(ref spherePos, sphereRadius, distance, closestPoint);
            }

            posA = spherePos;
        }

        display.DrawSphereTriangle(posA, posB, rotB, extentsA.x, extentsB);
    }