px3World.h

Engine/source/T3D/physics/physx3/px3World.h

More...

Classes:

Public Enumerations

enum
Px3CollisionGroup {
  PX3_DEFAULT = BIT(0)
  PX3_PLAYER = BIT(1)
  PX3_DEBRIS = BIT(2)
  PX3_TRIGGER = BIT(3)
}

Detailed Description

Public Enumerations

Px3CollisionGroup

Enumerator

PX3_DEFAULT = BIT(0)
PX3_PLAYER = BIT(1)
PX3_DEBRIS = BIT(2)
PX3_TRIGGER = BIT(3)
  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _PX3WORLD_H_
 25#define _PX3WORLD_H_
 26
 27#ifndef _PHYSX3_H_
 28#include "T3D/physics/physx3/px3.h"
 29#endif
 30#ifndef _T3D_PHYSICS_PHYSICSWORLD_H_
 31#include "T3D/physics/physicsWorld.h"
 32#endif
 33#ifndef _MMATH_H_
 34#include "math/mMath.h"
 35#endif
 36#ifndef _TVECTOR_H_
 37#include "core/util/tVector.h"
 38#endif
 39
 40class Px3ConsoleStream;
 41class Px3ContactReporter;
 42class FixedStepper;
 43
 44enum Px3CollisionGroup
 45{
 46   PX3_DEFAULT = BIT(0),
 47   PX3_PLAYER = BIT(1),
 48   PX3_DEBRIS = BIT(2),
 49   PX3_TRIGGER = BIT(3),
 50};
 51
 52class Px3World : public PhysicsWorld
 53{
 54protected:
 55   physx::PxScene* mScene;
 56   bool mIsEnabled;
 57   bool mIsSimulating;
 58   bool mIsServer;
 59   bool mIsSceneLocked;   
 60   U32 mTickCount;
 61   ProcessList *mProcessList;
 62   F32 mEditorTimeScale;
 63   bool mErrorReport;
 64   physx::PxControllerManager* mControllerManager;
 65   physx::PxRenderBuffer *mRenderBuffer;
 66   F32 mAccumulator;
 67   static Px3ConsoleStream *smErrorCallback;
 68   static physx::PxDefaultAllocator smMemoryAlloc;
 69   static physx::PxFoundation* smFoundation;
 70   static physx::PxCooking *smCooking;
 71   static physx::PxDefaultCpuDispatcher* smCpuDispatcher;
 72#ifndef TORQUE_OS_MAC
 73   static physx::PxCudaContextManager* smCudaContextManager;
 74#endif
 75   static physx::PxPvd* smPvdConnection;
 76   static physx::PxPvdTransport* smPvdTransport;
 77   
 78   bool _simulate(const F32 dt);
 79
 80public:
 81
 82   Px3World();
 83   virtual ~Px3World();
 84
 85   virtual bool initWorld( bool isServer, ProcessList *processList );
 86   virtual void destroyWorld();
 87   virtual void onDebugDraw( const SceneRenderState *state );
 88   virtual void reset() {}
 89   virtual bool castRay( const Point3F &startPnt, const Point3F &endPnt, RayInfo *ri, const Point3F &impulse );
 90   virtual PhysicsBody* castRay( const Point3F &start, const Point3F &end, U32 bodyTypes = BT_All );
 91   virtual void explosion( const Point3F &pos, F32 radius, F32 forceMagnitude ); 
 92   virtual bool isEnabled() const { return mIsEnabled; }
 93   physx::PxScene* getScene(){ return mScene; }
 94   void setEnabled( bool enabled );
 95   U32 getTick() { return mTickCount; }
 96   void tickPhysics( U32 elapsedMs );
 97   void getPhysicsResults();
 98   void setEditorTimeScale( F32 timeScale ) { mEditorTimeScale = timeScale; }
 99   const F32 getEditorTimeScale() const { return mEditorTimeScale; }
100   bool isServer() { return mIsServer; }
101   
102   physx::PxController* createController( physx::PxControllerDesc &desc );
103   void lockScene();
104   void unlockScene();
105   //static
106   static bool restartSDK( bool destroyOnly = false, Px3World *clientWorld = NULL, Px3World *serverWorld = NULL );
107   static physx::PxCooking *getCooking();
108   static void lockScenes();
109   static void unlockScenes();
110};
111
112#endif // _PX3WORLD_H_
113