NpMaterial* NpPhysics::addMaterial(NpMaterial* m) { if(!m) return NULL; Ps::Mutex::ScopedLock lock(mSceneAndMaterialMutex); //the handle is set inside the setMaterial method if(mMasterMaterialManager.setMaterial(*m)) { // Let all scenes know of the new material for(PxU32 i=0; i < mSceneArray.size(); i++) { NpScene* s = getScene(i); s->addMaterial(*m); } return m; } else { #ifdef PX_CHECKED #ifdef PX_PS3 Ps::getFoundation().error(PxErrorCode::eDEBUG_WARNING, __FILE__, __LINE__, "Cannot create material: There is a limit of 127 user created materials on PS3."); #endif #endif m->release(); return NULL; } }
bool NpPhysics::sendMaterialTable(NpScene& scene) { // note: no lock here because this method gets only called at scene creation and there we do lock NpMaterialManagerIterator iter(mMasterMaterialManager); NpMaterial* mat; while(iter.getNextMaterial(mat)) scene.addMaterial(*mat); return true; }
NpMaterial* NpPhysics::addMaterial(NpMaterial* m) { if(!m) return NULL; Ps::Mutex::ScopedLock lock(mSceneAndMaterialMutex); //the handle is set inside the setMaterial method if(mMasterMaterialManager.setMaterial(*m)) { // Let all scenes know of the new material for(PxU32 i=0; i < mSceneArray.size(); i++) { NpScene* s = getScene(i); s->addMaterial(*m); } return m; } else { m->release(); return NULL; } }