示例#1
0
        public static bool Fire(Vector3 origin, Vector3 direction, float distance, PhysXCollider.CollisionLayer layers, uint ignoredVehicleId = 0)
        {
            physXOrigin.FromVector(origin);
            physXDirection.FromVector(direction);
            if (defaultPhysXRaycastHit == IntPtr.Zero)
            {
                defaultPhysXRaycastHit = PhysXLib.CreateRaycastHit();
            }

            return(PhysXSceneManager.FireRaycastFiltered(physXOrigin, physXDirection, distance, defaultPhysXRaycastHit, (uint)layers, 0, 0, ignoredVehicleId));
        }
示例#2
0
        public static bool Fire(Vector3 origin, Vector3 direction, float distance)
        {
            physXOrigin.FromVector(origin);
            physXDirection.FromVector(direction);
            if (defaultPhysXRaycastHit == IntPtr.Zero)
            {
                defaultPhysXRaycastHit = PhysXLib.CreateRaycastHit();
            }

            return(PhysXSceneManager.FireRaycast(physXOrigin, physXDirection, distance, defaultPhysXRaycastHit));
        }
示例#3
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);
        }
示例#4
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);
        }
示例#5
0
 internal PhysXRaycastHit()
 {
     physXRaycastHit = PhysXLib.CreateRaycastHit();
 }
        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;
        }