Ejemplo n.º 1
0
        private static void onCCDContactModify(PxCCDContactModifyCallback * @this, PxContactModifyPair *pairs, uint count)
        {
            for (uint i = 0; i < count; i++)
            {
                PxRigidActor **actors = (PxRigidActor **)&pairs[i].actor; //BIOQUIRK: Unobvious cast.
                PxShape **     shapes = (PxShape **)&pairs[i].shape;      //BIOQUIRK: Unobvious cast

                //Search for actors that represent vehicles and shapes that represent wheels.
                for (uint j = 0; j < 2; j++)
                {
                    PxRigidActor *actor = actors[j];
                    if (actor->userData != null && ((ActorUserData *)(actor->userData))->vehicle != null)
                    {
                        PxVehicleWheels *vehicle = ((ActorUserData *)(actor->userData))->vehicle;
                        Debug.Assert(vehicle->getRigidDynamicActor() == actors[j]);

                        PxShape *shape = shapes[j];
                        if (shape->userData != null && ((ShapeUserData *)(shape->userData))->isWheel)
                        {
                            uint wheelId = ((ShapeUserData *)(shape->userData))->wheelId;
                            Debug.Assert(wheelId < vehicle->mWheelsSimData.getNbWheels());

                            //Modify wheel contacts.
                            PxVehicleModifyWheelContacts(*vehicle, wheelId, WHEEL_TANGENT_VELOCITY_MULTIPLIER, MAX_IMPULSE, ref pairs[i]);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static void onContactModify(PxContactModifyCallback * @this, PxContactModifyPair *pairs, uint count)
        {
            for (uint i = 0; i < count; i++)
            {
                //BIOQUIRK: Probably the "more correct" thing to do here is to use the generated constant array type, but these types currently have long confusing names.
                // A Span<PxRigidActor*> would also be nice, but isn't possible in C# today.
                // Could be improved by https://github.com/MochiLibraries/Biohazrd/issues/139
                PxRigidActor **actors = (PxRigidActor **)&pairs[i].actor; //BIOQUIRK: Unobvious cast.
                PxShape **     shapes = (PxShape **)&pairs[i].shape;      //BIOQUIRK: Unobvious cast

                //Search for actors that represent vehicles and shapes that represent wheels.
                for (int j = 0; j < 2; j++)
                {
                    PxRigidActor *actor = actors[j];
                    if (actor->userData != null && ((ActorUserData *)(actor->userData))->vehicle != null)
                    {
                        PxVehicleWheels *vehicle = ((ActorUserData *)(actor->userData))->vehicle;
                        Debug.Assert(vehicle->getRigidDynamicActor() == actors[j]);

                        PxShape *shape = shapes[j];
                        if (shape->userData != null && ((ShapeUserData *)(shape->userData))->isWheel)
                        {
                            uint wheelId = ((ShapeUserData *)(shape->userData))->wheelId;
                            Debug.Assert(wheelId < vehicle->mWheelsSimData.getNbWheels());

                            //Modify wheel contacts.
                            PxVehicleModifyWheelContacts(*vehicle, wheelId, WHEEL_TANGENT_VELOCITY_MULTIPLIER, MAX_IMPULSE, ref pairs[i]);
                        }
                    }
                }
            }
        }