MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / PhysicsSolver

Method PhysicsSolver

src/PhysicsSolver.cpp:222–258  ·  view source on GitHub ↗

constructor which configures PhysX

Source from the content-addressed store, hash-verified

220
221//constructor which configures PhysX
222PhysicsSolver::PhysicsSolver(){
223 if (foundation == nullptr){
224 foundation = PxCreateFoundation(PX_PHYSICS_VERSION, gDefaultAllocatorCallback, gDefaultErrorCallback);
225 }
226 if (foundation == nullptr){
227 cerr << "PhysX foundation failed!" << endl;
228 }
229 bool recordMemoryAllocations = true;
230 if (pvd == nullptr) {
231 pvd = PxCreatePvd(*foundation);
232 PxPvdTransport* transport = PxDefaultPvdSocketTransportCreate(PVD_HOST, 5425, 10);
233 pvd->connect(*transport, PxPvdInstrumentationFlag::eALL);
234 if (phys == nullptr) {
235 phys = PxCreatePhysics(PX_PHYSICS_VERSION, *foundation, PxTolerancesScale(), recordMemoryAllocations, pvd);
236 }
237 }
238
239 //create PhysX scene
240 PxSceneDesc desc(phys->getTolerancesScale());
241 desc.gravity = PxVec3(0.0f, -9.81f, 0.0f);
242
243 //set the dispatcher (can be CPU or Multithreaded GPU)
244 auto cpuDispatcher = PxDefaultCpuDispatcherCreate(std::thread::hardware_concurrency());
245 if (!cpuDispatcher) {
246 throw std::runtime_error("PhysX dispatcher failed to create ");
247 }
248 desc.cpuDispatcher = cpuDispatcher;
249
250 desc.filterShader = SampleFilterShader;
251 desc.simulationEventCallback = this;
252
253 //create the scene
254 scene = phys->createScene(desc);
255 if (!scene) {
256 throw std::runtime_error("PhysX scene failed to create");
257 }
258}

Callers

nothing calls this directly

Calls 8

PxCreateFoundationFunction · 0.85
PxCreatePvdFunction · 0.85
getTolerancesScaleMethod · 0.80
PxTolerancesScaleClass · 0.50
PxVec3Class · 0.50
connectMethod · 0.45
createSceneMethod · 0.45

Tested by

no test coverage detected