int iModelIndexAlreadyFat[512];
int iModelsMadeFat = 0;
void _cdecl hookStudioDrawPoints(void)
{
int i, j, k;
mstudiobodyparts_t *pBodyPart;
mstudiomodel_t *pSubModel;
model_t *pModel;
studiohdr_t *pStudioHeader;
byte *pvertbone;
Vector *pstudioverts;
cl_entity_t *pEnt;
pEnt = pEngstudio->GetCurrentEntity(); // get the ent currently being rendered
pModel = pEngstudio->SetupPlayerModel(pEnt->index); // then get the model of that ent
pStudioHeader = (studiohdr_t*)pEngstudio->Mod_Extradata(pModel); // ...and the header of that model's data
// then use the header to find the address of the first body part in the model data
pBodyPart = (mstudiobodyparts_t*)((byte*)pStudioHeader + pStudioHeader->bodypartindex);
// check this model hasn't already been made into a fatty -- simple and ugly pointer comparison that can easily be improved
for(i = 0; i < iModelsMadeFat; i++)
{
if(iModelIndexAlreadyFat == (int)pStudioHeader)
{
oEngstudio.StudioDrawPoints();
return;
}
}
if(iModelsMadeFat >= 512)
{
oEngstudio.StudioDrawPoints();
return;
}
add_log("making model with pointer %x big-headed!", pStudioHeader);
iModelIndexAlreadyFat[iModelsMadeFat] = (int)pStudioHeader;
iModelsMadeFat++;
for(k = 0; k < pStudioHeader->numbodyparts; k++) // loop through all bodyparts of the model...
{
pSubModel = (mstudiomodel_t*)((byte*)pStudioHeader + pBodyPart[k].modelindex);
for(i = 0; i < pBodyPart[k].nummodels; i++) // ...and all submodels of the bodyparts
{
pstudioverts = (Vector*)((byte*)pStudioHeader + pSubModel.vertindex);
for(j = 0; j < pSubModel.numverts; j++) // ...and all vertices in the submodel
{
pvertbone = ((byte*)pStudioHeader + pSubModel.vertinfoindex);
if(pvertbone[j] == 7) // if this vertex is attached to the head bone (bighead only, remove this check for fatboy)...
{
pstudioverts[j] = pstudioverts[j] * 3.0f; // make all the vertices in the head 3x as far away from the head bone
}
}
}
}
oEngstudio.StudioDrawPoints();
}