void CCmpPathfinder::Deinit() { SetDebugOverlay(false); // cleans up memory SAFE_DELETE(m_Grid); SAFE_DELETE(m_TerrainOnlyGrid); }
void CCmpPathfinder::Deinit() { SetDebugOverlay(false); // cleans up memory ResetDebugPath(); delete m_Grid; delete m_ObstructionGrid; }
CPhysicsEnvironment::CPhysicsEnvironment() { m_deleteQuick = false; m_bUseDeleteQueue = false; m_inSimulation = false; m_bConstraintNotify = false; m_pDebugOverlay = NULL; m_pConstraintEvent = NULL; m_pObjectEvent = NULL; m_pObjectTracker = NULL; m_pCollisionEvent = NULL; m_pBulletBroadphase = NULL; m_pBulletConfiguration = NULL; m_pBulletDispatcher = NULL; m_pBulletEnvironment = NULL; m_pBulletGhostCallback = NULL; m_pBulletSolver = NULL; m_timestep = 0.f; m_invPSIScale = 0.f; m_simPSICurrent = 0; m_simPSI = 0; #ifdef MULTITHREADED // Maximum number of parallel tasks (number of threads in the thread support) // Good to set it to the same amount of CPU cores on the system. // TODO: The game dev needs to be able to configure this value. Expose it in the interface. int maxTasks = vphysics_numthreads.GetInt(); maxTasks = max(maxTasks, 1); maxTasks = min(maxTasks, 8); // Shared thread pool (used by both solver and dispatcher) m_pSharedThreadPool = new btThreadPool; m_pSharedThreadPool->startThreads(maxTasks); #endif btDefaultCollisionConstructionInfo cci; m_pBulletConfiguration = new btSoftBodyRigidBodyCollisionConfiguration(cci); #ifdef USE_PARALLEL_DISPATCHER m_pBulletDispatcher = new btParallelCollisionDispatcher(m_pBulletConfiguration, m_pSharedThreadPool); #else m_pBulletDispatcher = new btCollisionDispatcher(m_pBulletConfiguration); #endif #ifdef USE_PARALLEL_SOLVER m_pBulletSolver = new btParallelConstraintSolver(m_pSharedThreadPool); #else m_pBulletSolver = new btSequentialImpulseConstraintSolver; #endif m_pBulletBroadphase = new btDbvtBroadphase; // Note: The soft body solver (last default-arg in the constructor) is used for OpenCL stuff (as per the Soft Body Demo) m_pBulletEnvironment = new btSoftRigidDynamicsWorld(m_pBulletDispatcher, m_pBulletBroadphase, m_pBulletSolver, m_pBulletConfiguration); m_pBulletGhostCallback = new btGhostPairCallback; m_pCollisionSolver = new CCollisionSolver(this); m_pBulletEnvironment->getPairCache()->setOverlapFilterCallback(m_pCollisionSolver); m_pBulletBroadphase->getOverlappingPairCache()->setInternalGhostPairCallback(m_pBulletGhostCallback); m_pDeleteQueue = new CDeleteQueue; m_pPhysicsDragController = new CPhysicsDragController; m_pObjectTracker = new CObjectTracker(this, NULL); m_perfparams.Defaults(); memset(&m_stats, 0, sizeof(m_stats)); // Soft body stuff m_softBodyWorldInfo.m_broadphase = m_pBulletBroadphase; m_softBodyWorldInfo.m_dispatcher = m_pBulletDispatcher; m_softBodyWorldInfo.m_sparsesdf.Initialize(); m_pBulletEnvironment->getSolverInfo().m_solverMode |= SOLVER_SIMD; // TODO: Threads solve any oversized batches (>32?), otherwise solving done on main thread. m_pBulletEnvironment->getSolverInfo().m_minimumSolverBatchSize = 128; // Combine islands up to this many constraints m_pBulletEnvironment->getDispatchInfo().m_allowedCcdPenetration = 0.0001f; m_pBulletEnvironment->setApplySpeculativeContactRestitution(true); //m_pBulletEnvironment->getDispatchInfo().m_dispatchFunc = btDispatcherInfo::DISPATCH_CONTINUOUS; //m_simPSIs = 0; //m_invPSIscale = 0; m_pBulletEnvironment->setInternalTickCallback(TickCallback, (void *)this); m_pCollisionListener = new CCollisionEventListener(this); m_pBulletSolver->setSolveCallback(m_pCollisionListener); #if DEBUG_DRAW m_debugdraw = new CDebugDrawer(m_pBulletEnvironment); #endif // HACK: Get ourselves a debug overlay on the client CreateInterfaceFn engine = Sys_GetFactory("engine"); SetDebugOverlay(engine); }