Esempio n. 1
0
 public PxClothParticle(PxVec3 pos_, float invWeight_) : this(physxPINVOKE.new_PxClothParticle__SWIG_1(PxVec3.getCPtr(pos_), invWeight_), true)
 {
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 2
0
    // Not applicable for Mochi-flavored snippets
    // class MyTriggerRender : public Snippets::TriggerRender
    // {
    //     public:
    //     virtual bool isTrigger(physx::PxShape* shape) const
    //     {
    //         return ::isTriggerShape(shape);
    //     }
    // };

    static void renderCallback()
    {
        stepPhysics(true);

#if false
        {
            PxVec3 camPos = sCamera.getEye();
            PxVec3 camDir = sCamera.getDir();
            Console.WriteLine($"camPos: ({camPos.x}, {camPos.y}, {camPos.z})");
            Console.WriteLine($"camDir: ({camDir.x}, {camDir.y}, {camDir.z})");
        }
#endif

        SnippetRender.startRender(sCamera.getEye(), sCamera.getDir());
        InitLighting();

        PxScene *scene;
        PxGetPhysics()->getScenes(&scene, 1);
        uint nbActors = scene->getNbActors(PxActorTypeFlags.eRIGID_DYNAMIC | PxActorTypeFlags.eRIGID_STATIC);
        if (nbActors != 0)
        {
            // (Allocating on the heap here is not a good idea performance-wise, we only do it this way to keep close to the original snippet.)
            fixed(PxRigidActor **actors = new PxRigidActor *[nbActors])
            {
                scene->getActors(PxActorTypeFlags.eRIGID_DYNAMIC | PxActorTypeFlags.eRIGID_STATIC, actors, nbActors);

                SnippetRender.renderActors(actors, nbActors, true, new(0.0f, 0.75f, 0.0f), &isTriggerShape);
            }
        }

        SnippetRender.finishRender();
    }
Esempio n. 3
0
 public PxBounds3(PxVec3 minimum, PxVec3 maximum) : this(physxPINVOKE.new_PxBounds3__SWIG_1(PxVec3.getCPtr(minimum), PxVec3.getCPtr(maximum)), true)
 {
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 4
0
 public PxVec3(PxVec3 v) : this(physxPINVOKE.new_PxVec3__SWIG_4(PxVec3.getCPtr(v)), true)
 {
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public PxClothParticleSeparationConstraint(PxVec3 p, float r) : this(physxPINVOKE.new_PxClothParticleSeparationConstraint__SWIG_1(PxVec3.getCPtr(p), r), true)
 {
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 6
0
 public PxPlane(PxVec3 normal, float distance) : this(physxPINVOKE.new_PxPlane__SWIG_2(PxVec3.getCPtr(normal), distance), true)
 {
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 7
0
 public PxPlane(PxVec3 p0, PxVec3 p1, PxVec3 p2) : this(physxPINVOKE.new_PxPlane__SWIG_4(PxVec3.getCPtr(p0), PxVec3.getCPtr(p1), PxVec3.getCPtr(p2)), true)
 {
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 8
0
 public PxPlane(PxVec3 point, PxVec3 normal) : this(physxPINVOKE.new_PxPlane__SWIG_3(PxVec3.getCPtr(point), PxVec3.getCPtr(normal)), true)
 {
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 9
0
 public PxBoxGeometry(PxVec3 halfExtents_) : this(physxPINVOKE.new_PxBoxGeometry__SWIG_2(PxVec3.getCPtr(halfExtents_)), true)
 {
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 10
0
 bool sweep(PxGeometry geometry, PxTransform pose, PxVec3 unitDir, PxReal distance,
            PxSweepCallback hitCall, PxHitFlags hitFlags = PxHitFlags.ePOSITION | PxHitFlags.eNORMAL | PxHitFlags.eDISTANCE,
            PxQueryFilterData filterData = null, PxQueryFilterCallback filterCall = null,
            PxReal inflation             = null)
 {
     return(false);
 }
Esempio n. 11
0
 public PxMat33(PxVec3 col0, PxVec3 col1, PxVec3 col2) : this(physxPINVOKE.new_PxMat33__SWIG_3(PxVec3.getCPtr(col0), PxVec3.getCPtr(col1), PxVec3.getCPtr(col2)), true)
 {
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 12
0
 public PxTransform(PxVec3 position) : this(physxPINVOKE.new_PxTransform__SWIG_1(PxVec3.getCPtr(position)), true)
 {
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 13
0
 public PxTransform(PxVec3 p0, PxQuat q0) : this(physxPINVOKE.new_PxTransform__SWIG_6(PxVec3.getCPtr(p0), PxQuat.getCPtr(q0)), true)
 {
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 14
0
    public static void stepPhysics()
    {
        const float timestep = 1.0f / 60.0f;

        //Cycle through the driving modes to demonstrate how to accelerate/reverse/brake/turn etc.
        incrementDrivingMode(timestep);

        //Raycasts.
        PxVehicleNoDrive **vehicles = stackalloc PxVehicleNoDrive *[1] {
            gVehicleNoDrive
        };
        PxBatchQueryResult <PxRaycastHit> *raycastResults = gVehicleSceneQueryData->getRaycastQueryResultBuffer(0);
        uint raycastResultsSize = gVehicleSceneQueryData->getQueryResultBufferSize();

        PxVehicleSuspensionRaycasts(gBatchQuery, 1, vehicles, raycastResultsSize, raycastResults);

        //Vehicle update.
        PxVec3 grav = gScene->getGravity();
        PxWheelQueryResult *       wheelQueryResults   = stackalloc PxWheelQueryResult[PX_MAX_NB_WHEELS];
        PxVehicleWheelQueryResult *vehicleQueryResults = stackalloc PxVehicleWheelQueryResult[1]
        {
            new() { wheelQueryResults = wheelQueryResults, nbWheelQueryResults = gVehicleNoDrive->mWheelsSimData.getNbWheels() }
        };

        PxVehicleUpdates(timestep, grav, *gFrictionPairs, 1, vehicles, vehicleQueryResults);

        //Scene update.
        gScene->simulate(timestep);
        gScene->fetchResults(true);
    }
Esempio n. 15
0
 public PxQuat(float angleRadians, PxVec3 unitAxis) : this(physxPINVOKE.new_PxQuat__SWIG_4(angleRadians, PxVec3.getCPtr(unitAxis)), true)
 {
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 16
0
    //static void threadExecute(void* data)
    static unsafe void threadExecute(object data)
    {
        //RaycastThread* raycastThread = static_cast<RaycastThread*>(data);
        RaycastThread raycastThread = (RaycastThread)data;

        //// Perform random raycasts against the scene until stop.
        //for(;;)
        for (;;)
        {
            //// Wait here for the sync to be set then reset the sync
            //// to ensure that we only perform raycast work after the
            //// sync has been set again.
            //SnippetUtils::syncWait(raycastThread->mWorkReadySyncHandle);
            //SnippetUtils::syncReset(raycastThread->mWorkReadySyncHandle);
            raycastThread.mWorkReadySyncHandle.WaitOne();
            raycastThread.mWorkReadySyncHandle.Reset();

            //// If the thread has been signaled to quit then exit this function.
            //if (SnippetUtils::threadQuitIsSignalled(raycastThread->mThreadHandle))
            //    break;
            if (raycastThread.quit)
            {
                break;
            }

            //// Perform a fixed number of random raycasts against the scene
            //// and share the work between multiple threads.
            //while (SnippetUtils::atomicDecrement(&gRaysAvailable) >= 0)
            while (Interlocked.Decrement(ref gRaysAvailable) >= 0)
            {
                //PxVec3 dir = randVec3();
                PxVec3 dir = randVec3();

                //PxRaycastBuffer buf;
                //gScene->raycast(PxVec3(0.0f), dir.getNormalized(), 1000.0f, buf, PxHitFlag::eDEFAULT);
                PxRaycastBufferPtr buf = PxRaycastBufferPtr.New();
                gScene.raycast(new PxVec3(0.0f), dir.getNormalized(), 1000f, buf, PxHitFlags.eDEFAULT);

                if (render_)
                {
                    var rayNor = dir.getNormalized() * 1000;
                    DebugRenderer.Current.AddLine(new Vector3(0), new Vector3(rayNor.x, rayNor.y, rayNor.z), 0xff00ffff);
                }

                buf.Free();

                //// If this is the last raycast then signal this to the main thread.
                //if (SnippetUtils::atomicIncrement(&gRaysCompleted) == gRayCount)
                if (Interlocked.Increment(ref gRaysCompleted) == gRayCount)
                {
                    //	SnippetUtils::syncSet(gWorkDoneSyncHandle);
                    gWorkDoneSyncHandle.Set();
                }
            }
        }

        //// Quit the current thread.
        //SnippetUtils::threadQuit(raycastThread->mThreadHandle);
    }
Esempio n. 17
0
 public virtual void addForce(PxVec3 force, PxForceMode.Enum mode, bool autowake)
 {
     physxPINVOKE.PxRigidBody_addForce__SWIG_0(swigCPtr, PxVec3.getCPtr(force), (int)mode, autowake);
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 18
0
 public virtual void sweep(PxGeometry geometry, PxTransform pose, PxVec3 unitDir, float distance, SWIGTYPE_p_uint16_t maxTouchHits, SWIGTYPE_p_physx__PxFlagsT_physx__PxHitFlag__Enum_uint16_t_t hitFlags, PxQueryFilterData filterData, SWIGTYPE_p_void userData, PxQueryCache cache, float inflation)
 {
     physxPINVOKE.PxBatchQuery_sweep__SWIG_0(swigCPtr, PxGeometry.getCPtr(geometry), PxTransform.getCPtr(pose), PxVec3.getCPtr(unitDir), distance, SWIGTYPE_p_uint16_t.getCPtr(maxTouchHits), SWIGTYPE_p_physx__PxFlagsT_physx__PxHitFlag__Enum_uint16_t_t.getCPtr(hitFlags), PxQueryFilterData.getCPtr(filterData), SWIGTYPE_p_void.getCPtr(userData), PxQueryCache.getCPtr(cache), inflation);
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 19
0
 public virtual void raycast(PxVec3 origin, PxVec3 unitDir)
 {
     physxPINVOKE.PxBatchQuery_raycast__SWIG_6(swigCPtr, PxVec3.getCPtr(origin), PxVec3.getCPtr(unitDir));
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 20
0
 public virtual void sweep(PxGeometry geometry, PxTransform pose, PxVec3 unitDir, float distance)
 {
     physxPINVOKE.PxBatchQuery_sweep__SWIG_6(swigCPtr, PxGeometry.getCPtr(geometry), PxTransform.getCPtr(pose), PxVec3.getCPtr(unitDir), distance);
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 21
0
 public virtual void sweep(PxGeometry geometry, PxTransform pose, PxVec3 unitDir, float distance, SWIGTYPE_p_uint16_t maxTouchHits, SWIGTYPE_p_physx__PxFlagsT_physx__PxHitFlag__Enum_uint16_t_t hitFlags)
 {
     physxPINVOKE.PxBatchQuery_sweep__SWIG_4(swigCPtr, PxGeometry.getCPtr(geometry), PxTransform.getCPtr(pose), PxVec3.getCPtr(unitDir), distance, SWIGTYPE_p_uint16_t.getCPtr(maxTouchHits), SWIGTYPE_p_physx__PxFlagsT_physx__PxHitFlag__Enum_uint16_t_t.getCPtr(hitFlags));
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 22
0
 public virtual void getForce(PxVec3 linear, PxVec3 angular)
 {
     physxPINVOKE.PxConstraint_getForce(swigCPtr, PxVec3.getCPtr(linear), PxVec3.getCPtr(angular));
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 23
0
 public void include(PxVec3 v)
 {
     physxPINVOKE.PxBounds3_include__SWIG_0(swigCPtr, PxVec3.getCPtr(v));
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 24
0
 public virtual void setLinearVelocity(PxVec3 linVel, bool autowake)
 {
     physxPINVOKE.PxRigidBody_setLinearVelocity__SWIG_0(swigCPtr, PxVec3.getCPtr(linVel), autowake);
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 25
0
 public virtual void setAngularVelocity(PxVec3 angVel)
 {
     physxPINVOKE.PxRigidBody_setAngularVelocity__SWIG_1(swigCPtr, PxVec3.getCPtr(angVel));
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 26
0
 public virtual void onOriginShift(PxVec3 shift)
 {
     physxPINVOKE.PxConstraintConnector_onOriginShift(swigCPtr, PxVec3.getCPtr(shift));
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 27
0
 public virtual void setMassSpaceInertiaTensor(PxVec3 m)
 {
     physxPINVOKE.PxRigidBody_setMassSpaceInertiaTensor(swigCPtr, PxVec3.getCPtr(m));
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 28
0
 public virtual void addTorque(PxVec3 torque)
 {
     physxPINVOKE.PxRigidBody_addTorque__SWIG_2(swigCPtr, PxVec3.getCPtr(torque));
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 29
0
 public virtual void visualizeLine(PxVec3 p0, PxVec3 p1, SWIGTYPE_p_uint32_t color)
 {
     physxPINVOKE.PxConstraintVisualizer_visualizeLine(swigCPtr, PxVec3.getCPtr(p0), PxVec3.getCPtr(p1), SWIGTYPE_p_uint32_t.getCPtr(color));
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 30
0
 public virtual void addTorque(PxVec3 torque, PxForceMode.Enum mode)
 {
     physxPINVOKE.PxRigidBody_addTorque__SWIG_1(swigCPtr, PxVec3.getCPtr(torque), (int)mode);
     if (physxPINVOKE.SWIGPendingException.Pending)
     {
         throw physxPINVOKE.SWIGPendingException.Retrieve();
     }
 }