void vHavokAiModule::OnHandleCallback(IVisCallbackDataObject_cl *pData) { if (pData->m_pSender == &vHavokPhysicsModule::OnHandleResourceFile) { HandleResourceFile(*((vHavokResourceCallbackData *)pData)); } else if (pData->m_pSender == &vHavokPhysicsModule::OnBeforeWorldCreated) { SetPhysicsWorld(HK_NULL); } else if (pData->m_pSender == &vHavokPhysicsModule::OnAfterWorldCreated) { vHavokPhysicsModuleCallbackData *pHavokData = (vHavokPhysicsModuleCallbackData*)pData; SetPhysicsWorld( pHavokData->GetHavokModule()->GetPhysicsWorld() ); } else if (pData->m_pSender == &VSceneLoader::OnCustomChunkSerialization) { // Note: loading/saving of nav mesh in .vscene file is deprecated but loading is left here for backwards compatibility VCustomSceneChunkDataObject &chunkData(*((VCustomSceneChunkDataObject *)pData)); if (chunkData.m_Loader.IsSaving() || chunkData.m_iChunkID == 'AINM') { chunkData.m_iChunkID = 'AINM'; chunkData.m_bSuccess = chunkData.m_bProcessed = true; GlobalsChunkFileExchange(chunkData.m_Loader, chunkData.m_iChunkID); } } else if (pData->m_pSender == &vHavokVisualDebugger::OnCreatingContexts) { if( m_aiWorld != HK_NULL ) { vHavokVisualDebuggerCallbackData_cl* pVdbData = (vHavokVisualDebuggerCallbackData_cl*)pData; pVdbData->m_contexts->pushBack(m_aiViewerContext); } } else if (pData->m_pSender == &Vision::Callbacks.OnRenderHook) { Render(); } else if (pData->m_pSender == &Vision::Callbacks.OnUpdateSceneFinished) { Update(); } else if(pData->m_pSender==&IVScriptManager::OnRegisterScriptFunctions) { vHavokAiModule::RegisterLua(); } }
//-------------------------------------------------------------- //-------------------------------------------------------------- CSBinaryChunkUPtr CSBinaryInputStream::ReadChunk(const std::string& in_chunkId) { CS_ASSERT(m_isValid == true, "Cannot read chunk from invalid Input stream."); auto chunkInfoIt = m_chunkInfoMap.find(in_chunkId); if (chunkInfoIt != m_chunkInfoMap.end()) { m_fileStream->SeekG(chunkInfoIt->second.m_offset, SeekDir::k_beginning); CS_ASSERT(m_fileStream->TellG() == chunkInfoIt->second.m_offset, "Seek failed."); std::unique_ptr<u8[]> chunkData(new u8[chunkInfoIt->second.m_size]); m_fileStream->Read(reinterpret_cast<s8*>(chunkData.get()), chunkInfoIt->second.m_size); return CSBinaryChunkUPtr(new CSBinaryChunk(std::move(chunkData), chunkInfoIt->second.m_size)); } return nullptr; }