//queues all the pieces of the model into the global list void ModelDraw::QueueModelPieces(ModelInstance* pInstance, const ModelHookData& HookData, CDeviceLightList& DeviceLightList) { //get the distance to the model float fDistToModel = 0.0f; if(!(HookData.m_ObjectFlags & FLAG_REALLYCLOSE)) { fDistToModel = (g_ViewParams.m_Pos - pInstance->GetPos()).Mag(); } //Now handle queueing up all of our pieces bool bTexture = g_CV_TextureModels && (HookData.m_HookFlags & MHF_USETEXTURE); //cache the model pointer Model* pModel = pInstance->GetModelDB(); //run through and queue up each piece for (uint32 nCurrPiece = 0; nCurrPiece < pModel->NumPieces(); nCurrPiece++) { //just ignore this piece if it is currently hidden if (pInstance->IsPieceHidden(nCurrPiece)) { continue; } //get the piece and current LOD ModelPiece* pPiece = pModel->GetPiece(nCurrPiece); CDIModelDrawable* pLOD = pPiece->GetLODFromDist( g_CV_ModelLODOffset.m_Val, fDistToModel ); //if it doesn't have an associated LOD to render, we can't do anything if (!pLOD || (pLOD->GetPolyCount() == 0)) continue; // setup the nodes we need to render this mesh. pInstance->SetupLODNodePath(pLOD); CRenderModelPieceList::GetSingleton().QueuePiece(pInstance, pPiece, pLOD, pInstance->GetRenderingTransforms(), &DeviceLightList, bTexture, &HookData); } }