Model::Model(Graphics::Renderer *r, const std::string &name) : m_boundingRadius(10.f) , m_renderer(r) , m_name(name) , m_curPattern(0) { m_root.Reset(new Group(m_renderer)); m_root->SetName(name); ClearDecals(); }
Model::Model(const Model &model) : m_boundingRadius(model.m_boundingRadius) , m_materials(model.m_materials) , m_patterns(model.m_patterns) , m_collMesh(model.m_collMesh) //might have to make this per-instance at some point , m_renderer(model.m_renderer) , m_name(model.m_name) , m_curPattern(model.m_curPattern) { //selective copying of node structure CopyVisitor cv; model.m_root->Accept(cv); assert(cv.root); m_root.Reset(cv.root); //materials are shared by meshes for (unsigned int i=0; i<MAX_DECAL_MATERIALS; i++) m_decalMaterials[i] = model.m_decalMaterials[i]; ClearDecals(); //create unique color texture, if used //patterns are shared if (SupportsPatterns()) { std::vector<Color4ub> colors; colors.push_back(Color4ub::RED); colors.push_back(Color4ub::GREEN); colors.push_back(Color4ub::BLUE); SetColors(colors); SetPattern(0); } //animations need to be copied and retargeted for (AnimationContainer::const_iterator it = model.m_animations.begin(); it != model.m_animations.end(); ++it) { const Animation *anim = *it; m_animations.push_back(new Animation(*anim)); m_animations.back()->UpdateChannelTargets(m_root.Get()); } //m_tags needs to be updated for (TagContainer::const_iterator it = model.m_tags.begin(); it != model.m_tags.end(); ++it) { MatrixTransform *t = dynamic_cast<MatrixTransform*>(m_root->FindNode((*it)->GetName())); assert(t != 0); m_tags.push_back(t); } }
///////////////////////////////////// // Name: // Purpose: // Output: // Return: ///////////////////////////////////// IgfxQBSP::~IgfxQBSP() { u32 i; GFXDestroyVtxBuff(m_vtx); if(m_faces) { //destroy the patches for(i = 0; i < m_numFaces; i++) QBSPPatchDestroy(m_faces[i].patch); MemFree(m_faces); } if(m_textures) { //release all textures for(i = 0; i < m_numTxt; i++) { SAFE_RELEASE(m_textures[i].fx); SAFE_RELEASE(m_textures[i].texture); } MemFree(m_textures); } if(m_lightmaps) { //release all textures for(u32 i = 0; i < m_numLightMap; i++) SAFE_RELEASE(m_lightmaps[i]); MemFree(m_lightmaps); } if(m_nodes) MemFree(m_nodes); if(m_leaves) { MemFree(m_leaves); } if(m_leafFaces) MemFree(m_leafFaces); if(m_planes) MemFree(m_planes); if(m_clusters.pBitsets) MemFree(m_clusters.pBitsets); if(m_clustersPHS.pBitsets) MemFree(m_clustersPHS.pBitsets); SAFE_RELEASE(m_meshIndBuff); if(m_models) { for(u32 i = 1; i < m_numModels; i++) { if(m_models[i].brushes) { for(s32 j = 0; j < m_models[i].numOfBrushes; j++) { if(m_models[i].brushes[j].planes) MemFree(m_models[i].brushes[j].planes); if(m_models[i].brushes[j].tPlanes) MemFree(m_models[i].brushes[j].tPlanes); if(m_models[i].brushes[j].txtID) MemFree(m_models[i].brushes[j].txtID); } MemFree(m_models[i].brushes); } } MemFree(m_models); } if(m_brushes) MemFree(m_brushes); if(m_brushVis) MemFree(m_brushVis); if(m_leafBrushes) MemFree(m_leafBrushes); if(m_brushSides) MemFree(m_brushSides); //destroy default fxs SAFE_RELEASE(m_dfltFX); //destroy decals ClearDecals(); //destroy shadow informations if(m_shVtxBuff) MemFree(m_shVtxBuff); if(m_shIndBuff) MemFree(m_shIndBuff); }