コード例 #1
0
        void Update()
        {
            if (drawShape)
            {
                DrawShape();
            }

            depenetrationShape.position = transform.position;

            for (int i = 0; i < detectionIterations; i++)
            {
                GetContacts(collisionPointsBuffer, checkOffset);
                if (collisionPointsBuffer.Count > 0)
                {
                    for (int j = 0; j < collisionPointsBuffer.Count; j++)
                    {
                        if (drawContacts)
                        {
                            ExtDebug.DrawPlane(collisionPointsBuffer[j].closestPointOnSurface, collisionPointsBuffer[j].interpolatedNormal, .5f, Color.cyan);
                        }
                    }
                }

                depenetrationShape.position += SphereCollisionDetect.Depenetrate(collisionPointsBuffer, depenetrationInterations);
            }
        }
コード例 #2
0
        void Update()
        {
            if (drawShape)
            {
                DrawShape();
            }

            GetContacts(collisionPointsBuffer);
            if (ignoreBehindPlane)
            {
                SphereCollisionDetect.CleanByIgnoreBehindPlane(collisionPointsBuffer);
            }

            if (collisionPointsBuffer.Count > 0)
            {
                for (int i = 0; i < collisionPointsBuffer.Count; i++)
                {
                    if (drawContacts)
                    {
                        ExtDebug.DrawPlane(collisionPointsBuffer[i].closestPointOnSurface, collisionPointsBuffer[i].interpolatedNormal, .25f, Color.magenta);
                        Debug.DrawLine(collisionPointsBuffer[i].detectionOrigin, collisionPointsBuffer[i].closestPointOnSurface, Color.red);
                        Debug.DrawRay(collisionPointsBuffer[i].closestPointOnSurface, collisionPointsBuffer[i].normal, Color.green);
                    }
                }
            }
        }
 void DrawTriangleSet(IList <int> triangles, Color color, Transform transform)
 {
     for (int i = 0; i < triangles.Count; i++)
     {
         int triangle = triangles[i];
         ExtDebug.DrawTriangle(vertices[tris[triangle]], vertices[tris[triangle + 1]], vertices[tris[triangle + 2]], color, transform);
     }
 }
 void DrawGroundDebug(Vector3 hitPoint, Vector3 normal, float size, Color planeColor, Color rayColor)
 {
     if (infoDebug.drawGrounding)
     {
         ExtDebug.DrawPlane(hitPoint, normal, size, planeColor);
         Debug.DrawRay(hitPoint, normal, rayColor);
     }
 }
        float overrideYMovementConsistency;         //used to keep the position of the movement ray constant so we can properly see the movement consistency

        void DrawContactsDebug(List <SphereCollisionInfo> collisionPoints, float size, Color planeColor, Color rayColor)
        {
            if (infoDebug.drawContacts)
            {
                for (int i = 0; i < collisionPoints.Count; i++)
                {
                    ExtDebug.DrawPlane(collisionPoints[i].closestPointOnSurface, collisionPoints[i].interpolatedNormal, .5f, planeColor, infoDebug.drawContactsDuration);
                    Debug.DrawRay(collisionPoints[i].closestPointOnSurface, collisionPoints[i].normal, rayColor, infoDebug.drawContactsDuration);
                }
            }
        }
コード例 #6
0
        void OnCollisionStay(Collision collisionInfo)
        {
            foreach (ContactPoint contact in collisionInfo.contacts)
            {
                if (drawPhysXContacts)
                {
                    //I set the draw time to Time.fixedDeltaTime since OnCollisionStay is ran every FixedUpdate, which means there would be flickering if we dont keep the draw there long enough until it runs again.
                    ExtDebug.DrawPlane(contact.point, contact.normal, .5f, Color.yellow, Time.fixedDeltaTime);
                }

                if (drawPenetration)
                {
                    float seperation = (reversePenetration) ? -contact.separation : contact.separation;
                    ExtDebug.DrawPlane(contact.point + (contact.normal * seperation), contact.normal, .1f, Color.cyan, Time.fixedDeltaTime);
                }
            }
        }
 void DrawTrianglesOnContact(Node node, Transform transform)
 {
     DrawTriangleSet(node.triangles, ExtDebug.RandomColor(), transform);
 }
 void DrawAABBOnContact(Node node, Transform transform)
 {
     ExtDebug.DrawTransformedBox(node.aabb.origin, node.aabb.halfExtents * 2f, transform.localToWorldMatrix, ExtDebug.RandomColor());
 }
 void DrawAABBTree(Node node, Transform transform)
 {
     //We add a small offset to make it easier to see overlapping AABBs.
     ExtDebug.DrawTransformedBox(node.aabb.origin + (Vector3.one * UnityEngine.Random.Range(0f, .001f)), node.aabb.halfExtents * 2f, transform.localToWorldMatrix, ExtDebug.RandomColor());
 }
コード例 #10
0
 protected override void DrawShape()
 {
     ExtDebug.DrawCapsule(transform.position, transform.up, myCollider.height * transform.localScale.x, myCollider.radius * transform.localScale.x, Color.black);
 }
コード例 #11
0
 protected override void DrawShape()
 {
     ExtDebug.DrawWireSphere(transform.position, myCollider.radius * transform.localScale.x, Color.black);
 }
コード例 #12
0
 public static void DrawVector(Vector3 position, Vector3 direction, float raySize, float markerSize, Color color, float duration, bool depthTest = true)
 {
     Debug.DrawRay(position, direction * raySize, color, 0, false);
     ExtDebug.DrawMarker(position + direction * raySize, markerSize, color, 0, false);
 }