internal static void ReleaseCollision(PhysXCollision collision) { foreach (PhysXContactPoint contactPoint in collision.contactPoints) { PhysXContactPoint.ReleaseContactPoint(contactPoint); } collision.contactPoints.Clear(); collisions.Enqueue(collision); }
internal static void ReleaseContactPoint(PhysXContactPoint contactPoint) { contactPoints.Enqueue(contactPoint); }
internal void FromPhysXInternalCollision(IntPtr pairHeader, IntPtr pairs, int pairCount, IntPtr self, bool isEnter, bool isStay, bool isExit) { this.self = self; this.isEnter = isEnter; this.isStay = isStay; this.isExit = isExit; otherActor = PhysXLib.GetPairHeaderActor(pairHeader, 0); int otherNum = 0; if (otherActor == self) { otherNum = 1; otherActor = PhysXLib.GetPairHeaderActor(pairHeader, otherNum); } PhysXLib.GetPosition(self, initialPosSelf); ownInitialPosition = initialPosSelf.ToVector(); PhysXLib.GetRotation(self, initialRotSelf); ownInitialRotation = initialRotSelf.ToQuaternion(); impulse = Vector3.zero; for (int i = 0; i < pairCount; i++) { IntPtr colliderShape = PhysXLib.GetContactPairShape(pairs, i, otherNum); IntPtr ownShape = PhysXLib.GetContactPairShape(pairs, i, 1 - otherNum); IntPtr iter = PhysXLib.GetContactPointIterator(pairs, i); int j = 0; while (PhysXLib.NextContactPatch(iter)) { while (PhysXLib.NextContactPoint(iter)) { float separation = PhysXLib.GetContactPointData(iter, j, pairs, i, pointPos, pointNormal, pointImpulse); PhysXContactPoint contactPoint = PhysXContactPoint.GetContactPoint(); contactPoint.colliderShape = colliderShape; contactPoint.ownShape = ownShape; contactPoint.point = pointPos.ToVector(); if (otherNum == 1) { contactPoint.normal = pointNormal.ToVector(); contactPoint.impulse = pointImpulse.ToVector(); } else { contactPoint.normal = -pointNormal.ToVector(); contactPoint.impulse = -pointImpulse.ToVector(); } contactPoint.separation = separation; contactPoints.Add(contactPoint); impulse += contactPoint.impulse; j++; } } } // impulse /= contactCount; }