Skip to content

Commit

Permalink
Removed superfluous code to determine the number of compressed bones.
Browse files Browse the repository at this point in the history
The compressed bone pool of a Ghoul II animation file (MDXA, .gla) is always
stored at the end of the file. It is unnecessary to iterate through all frames
to determine the number of compressed bones present on big-endian machines.

This change is applied to the vanilla renderers of the single- and multiplayer
code of JK:JA.
  • Loading branch information
AJSchat committed Oct 31, 2018
1 parent cc4094c commit b993a8c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 57 deletions.
22 changes: 3 additions & 19 deletions code/rd-vanilla/tr_ghoul2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3909,26 +3909,10 @@ qboolean R_LoadMDXA( model_t *mod, void *buffer, const char *mod_name, qboolean
}
}

// find the largest index, since the actual number of compressed bone pools is not stored anywhere
for ( i = 0 ; i < mdxa->numFrames ; i++ )
{
for ( j = 0 ; j < mdxa->numBones ; j++ )
{
k = (i * mdxa->numBones * 3) + (j * 3); // iOffsetToIndex
pIndex = (mdxaIndex_t *) ((byte*) mdxa + mdxa->ofsFrames + k);

// 3 byte ints, yeah...
int tmp = pIndex->iIndex & 0xFFFFFF00;
LL(tmp);

if (maxBoneIndex < tmp)
maxBoneIndex = tmp;
}
}

// swap the compressed bones
pCompBonePool = (mdxaCompQuatBone_t *) ((byte *)mdxa + mdxa->ofsCompBonePool);
for ( i = 0 ; i <= maxBoneIndex ; i++ )
maxBoneIndex = (mdxa->ofsEnd - mdxa->ofsCompBonePool) / sizeof(mdxaCompQuatBone_t);
pCompBonePool = (mdxaCompQuatBone_t *) ((byte *)mdxa + mdxa->ofsCompBonePool);
for ( i = 0 ; i < maxBoneIndex ; i++ )
{
pwIn = (unsigned short *) pCompBonePool[i].Comp;

Expand Down
22 changes: 3 additions & 19 deletions codemp/rd-vanilla/tr_ghoul2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4875,26 +4875,10 @@ qboolean R_LoadMDXA( model_t *mod, void *buffer, const char *mod_name, qboolean
}
}

// find the largest index, since the actual number of compressed bone pools is not stored anywhere
for ( i = 0 ; i < mdxa->numFrames ; i++ )
{
for ( j = 0 ; j < mdxa->numBones ; j++ )
{
k = (i * mdxa->numBones * 3) + (j * 3); // iOffsetToIndex
pIndex = (mdxaIndex_t *) ((byte*) mdxa + mdxa->ofsFrames + k);

// 3 byte ints, yeah...
int tmp = pIndex->iIndex & 0xFFFFFF00;
LL(tmp);

if (maxBoneIndex < tmp)
maxBoneIndex = tmp;
}
}

// swap the compressed bones
pCompBonePool = (mdxaCompQuatBone_t *) ((byte *)mdxa + mdxa->ofsCompBonePool);
for ( i = 0 ; i <= maxBoneIndex ; i++ )
maxBoneIndex = (mdxa->ofsEnd - mdxa->ofsCompBonePool) / sizeof(mdxaCompQuatBone_t);
pCompBonePool = (mdxaCompQuatBone_t *) ((byte *)mdxa + mdxa->ofsCompBonePool);
for ( i = 0 ; i < maxBoneIndex ; i++ )
{
pwIn = (unsigned short *) pCompBonePool[i].Comp;

Expand Down
22 changes: 3 additions & 19 deletions codemp/rd-vanilla/tr_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,26 +767,10 @@ qboolean ServerLoadMDXA( model_t *mod, void *buffer, const char *mod_name, qbool
}
}

// find the largest index, since the actual number of compressed bone pools is not stored anywhere
for ( i = 0 ; i < mdxa->numFrames ; i++ )
{
for ( j = 0 ; j < mdxa->numBones ; j++ )
{
k = (i * mdxa->numBones * 3) + (j * 3); // iOffsetToIndex
pIndex = (mdxaIndex_t *) ((byte*) mdxa + mdxa->ofsFrames + k);

// 3 byte ints, yeah...
int tmp = pIndex->iIndex & 0xFFFFFF00;
LL(tmp);

if (maxBoneIndex < tmp)
maxBoneIndex = tmp;
}
}

// swap the compressed bones
pCompBonePool = (mdxaCompQuatBone_t *) ((byte *)mdxa + mdxa->ofsCompBonePool);
for ( i = 0 ; i <= maxBoneIndex ; i++ )
maxBoneIndex = (mdxa->ofsEnd - mdxa->ofsCompBonePool) / sizeof(mdxaCompQuatBone_t);
pCompBonePool = (mdxaCompQuatBone_t *) ((byte *)mdxa + mdxa->ofsCompBonePool);
for ( i = 0 ; i < maxBoneIndex ; i++ )
{
pwIn = (unsigned short *) pCompBonePool[i].Comp;

Expand Down

0 comments on commit b993a8c

Please sign in to comment.