///////////////////////////////////////////////////////////////////////////////////////////////////////////// // ReleaseData: delete anything allocated by the model void CModel::ReleaseData() { rtl_FreeAligned(m_BoneMatrices); for (size_t i = 0; i < m_Props.size(); ++i) delete m_Props[i].m_Model; m_Props.clear(); m_pModelDef = CModelDefPtr(); }
// Free all resources on destruction or when a layout parameter changes void VertexArray::Free() { rtl_FreeAligned(m_BackingStore); m_BackingStore = 0; if (m_VB) { g_VBMan.Release(m_VB); m_VB = 0; } }
// Updated transforms void PolygonSortModelRenderer::UpdateModelData(CModel* model, void* data, int updateflags) { PSModel* psmdl = (PSModel*)data; if (updateflags & (RENDERDATA_UPDATE_VERTICES|RENDERDATA_UPDATE_COLOR)) { CModelDefPtr mdef = model->GetModelDef(); size_t numVertices = mdef->GetNumVertices(); // build vertices // allocate working space for computing normals if (numVertices > m->normalsNumVertices) { rtl_FreeAligned(m->normals); size_t newSize = round_up_to_pow2(numVertices); m->normals = (char*)rtl_AllocateAligned(newSize*16, 16); m->normalsNumVertices = newSize; } VertexArrayIterator<CVector3D> Position = psmdl->m_Position.GetIterator<CVector3D>(); VertexArrayIterator<CVector3D> Normal = VertexArrayIterator<CVector3D>(m->normals, 16); ModelRenderer::BuildPositionAndNormals(model, Position, Normal); VertexArrayIterator<SColor4ub> Color = psmdl->m_Color.GetIterator<SColor4ub>(); ModelRenderer::BuildColor4ub(model, Normal, Color); // upload everything to vertex buffer psmdl->m_Array.Upload(); } // resort model indices from back to front, according to the view camera position - and store // the returned sqrd distance to the centre of the nearest triangle // Use the view camera instead of the cull camera because: // a) polygon sorting implicitly uses the view camera (and changing that would be costly) // b) using the cull camera is likely not interesting from a debugging POV PROFILE_START( "sorting transparent" ); CMatrix3D worldToCam; g_Renderer.GetViewCamera().m_Orientation.GetInverse(worldToCam); psmdl->BackToFrontIndexSort(worldToCam); PROFILE_END( "sorting transparent" ); }
static void FreeAligned(void* pointer, size_t UNUSED(size)) { return rtl_FreeAligned(pointer); }
// Free the backing store to save some memory void VertexArray::FreeBackingStore() { rtl_FreeAligned(m_BackingStore); m_BackingStore = 0; }
PolygonSortModelRenderer::~PolygonSortModelRenderer() { rtl_FreeAligned(m->normals); delete m; }
static void UniqueRangeDeleterAligned(void* pointer, size_t UNUSED(size)) { return rtl_FreeAligned(pointer); }