Ejemplo n.º 1
0
        // public float distance { get; private set; }

        // public Transform transform { get; private set; }

        internal void PopulateFields(IntPtr vehicle, int wheelNum)
        {
            IntPtr    hitActor = PhysXLib.GetGroundHitActor(vehicle, wheelNum);
            PhysXBody body     = PhysXSceneManager.GetBodyFromPointer(hitActor);

            IntPtr shape = PhysXLib.GetGroundHitShape(vehicle, wheelNum);

            collider = body.GetColliderFromShape(shape);

            PhysXLib.GetGroundHitPosition(vehicle, wheelNum, _pxpoint);
            _pxpoint.ToVector(ref _point);
        }
Ejemplo n.º 2
0
        internal void PopulateFields()
        {
            IntPtr    hitActor = PhysXLib.GetRaycastHitActor(physXRaycastHit);
            PhysXBody body     = PhysXSceneManager.GetBodyFromPointer(hitActor);

            transform = body.transform;

            IntPtr shape = PhysXLib.GetRaycastHitShape(physXRaycastHit);

            collider = body.GetColliderFromShape(shape);

            distance = PhysXLib.GetRaycastHitDistance(physXRaycastHit);

            PhysXLib.GetRaycastHitNormal(physXRaycastHit, _pxnormal);
            _pxnormal.ToVector(ref _normal);

            PhysXLib.GetRaycastHitPoint(physXRaycastHit, _pxpoint);
            _pxpoint.ToVector(ref _point);
        }
Ejemplo n.º 3
0
        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;
        }