hkDemo::Result WorldSnapshotWithContactPointsDemo::stepDemo() { Result r = hkDefaultPhysicsDemo::stepDemo(); if( r != DEMO_OK ) { return r; } // The first button in the pad will load the last saved scene if( m_env->m_gamePad->wasButtonPressed( HKG_PAD_BUTTON_1 ) ) { hkString filename = hkAssetManagementUtil::getFilePath( SCRATCH_FILE ); hkIstream in(filename.cString()); if( in.isOk() ) { cleanupWorld(); cleanupGraphics(); hkpWorld::IgnoreForceMultithreadedSimulation ignoreForceMultithreaded; m_world = loadWorld(filename.cString(), &m_physicsData, &m_loadedData); m_debugViewerNames.pushBack( hkpActiveContactPointViewer::getName() ); m_debugViewerNames.pushBack( hkpInactiveContactPointViewer::getName() ); setupGraphics(); } else { m_env->m_textDisplay->outputText("Please save before attempting to load", 20U, m_env->m_window->getHeight()/2, 0xffffffffU, 60); } } else if (m_env->m_gamePad->wasButtonPressed (HKG_PAD_BUTTON_2) ) { // The second button in the pad will save the current scene saveWorld(m_world, SCRATCH_FILE, true); } else if (m_env->m_gamePad->wasButtonPressed (HKG_PAD_BUTTON_3) ) { // The second button in the pad will save the current scene saveWorld(m_world, SCRATCH_FILE, false); } m_world->lock(); m_world->updateCollisionFilterOnWorld( HK_UPDATE_FILTER_ON_WORLD_FULL_CHECK, HK_UPDATE_COLLECTION_FILTER_PROCESS_SHAPE_COLLECTIONS); m_world->unlock(); return DEMO_OK; }
void PackfileImportExport::cleanup() { if( m_world ) { m_world->markForWrite(); const hkArray<hkpPhysicsSystem*>& s = m_physicsData->getPhysicsSystems(); for( int i = 0; i < s.getSize(); ++i ) { m_world->removePhysicsSystem(s[i]); } m_world->removeReference(); m_world = HK_NULL; } m_linker.reset(); cleanupGraphics(); }
hkDefaultDemo::~hkDefaultDemo() { #if HK_CONFIG_THREAD == HK_CONFIG_MULTI_THREADED if (m_jobThreadPool) { m_jobThreadPool->removeReferenceLockUnchecked(); } delete m_jobQueue; if (m_spuUtil) { #if defined (HK_PLATFORM_PS3_PPU) // free resources if necessary int ret = cellSpursFinalize ( hkGetSpursInstance() ); if (ret) { HK_ERROR(0x73e432b3, "cellSpursFinalize failed :" << ret); } void* spurs = hkGetSpursInstance(); hkAlignedDeallocate<char>( (char*)spurs ); #endif } #endif for ( int i = 0; i < m_steppers.getSize(); ++i ) { m_steppers[i]->removeReference(); } if(m_mouseActive) { mouseUp(); } if ( m_lastProgress ) { delete m_lastProgress; } cleanupGraphics(); for( int i = 0; i < m_delayedCleanup.getSize(); ++i ) { m_delayedCleanup[i]->removeReference(); } if (m_forcedShadowsOn) { m_env->m_options->m_enableShadows = false; // reset } else if (m_forcedShadowsOff) { m_env->m_options->m_enableShadows = true;// reset } #if defined (HK_USE_CHARACTER_FACTORY) if (m_characterFactory) { delete m_characterFactory; } #endif }