Skip to content
Permalink
Browse files

Merge pull request #991 from AJSchat/ghoul2-minor-tweaks

Removed superfluous code to determine the number of compressed bones.
  • Loading branch information...
xycaleth committed Apr 6, 2019
2 parents 8367be0 + 54bca13 commit 212d7d8222875274ed43463ff68e55e1c664e3b1
@@ -432,10 +432,11 @@ typedef struct {
//
// (iFrameNum * mdxaHeader_t->numBones * 3) + (iBoneNum * 3)
//
// then read the int at that location and AND it with 0x00FFFFFF. I use the struct below simply for easy searches
// Then convert the three byte int at that location.
// This struct is used for easy searches.
typedef struct
{
int iIndex; // this struct for pointing purposes, need to and with 0x00FFFFFF to be meaningful
byte iIndex[3];
} mdxaIndex_t;
//
// (note that there's then an alignement-pad here to get the next struct back onto 32-bit alignement)
@@ -925,21 +925,15 @@ void Multiply_3x4Matrix(mdxaBone_t *out,const mdxaBone_t *in2,const mdxaBone_t
out->matrix[2][3] = (in2->matrix[2][0] * in->matrix[0][3]) + (in2->matrix[2][1] * in->matrix[1][3]) + (in2->matrix[2][2] * in->matrix[2][3]) + in2->matrix[2][3];
}

static int G2_GetBonePoolIndex( const mdxaHeader_t *pMDXAHeader, int iFrame, int iBone)
static int G2_GetBonePoolIndex(const mdxaHeader_t *pMDXAHeader, int iFrame, int iBone)
{
assert(iFrame>=0&&iFrame<pMDXAHeader->numFrames);
assert(iBone>=0&&iBone<pMDXAHeader->numBones);
const int iOffsetToIndex = (iFrame * pMDXAHeader->numBones * 3) + (iBone * 3);

mdxaIndex_t *pIndex = (mdxaIndex_t *) ((byte*) pMDXAHeader + pMDXAHeader->ofsFrames + iOffsetToIndex);
const int iOffsetToIndex = (iFrame * pMDXAHeader->numBones * 3) + (iBone * 3);
mdxaIndex_t *pIndex = (mdxaIndex_t *)((byte*)pMDXAHeader + pMDXAHeader->ofsFrames + iOffsetToIndex);

#ifdef Q3_BIG_ENDIAN
int tmp = pIndex->iIndex & 0xFFFFFF00;
LL(tmp);
return tmp;
#else
return pIndex->iIndex & 0x00FFFFFF;
#endif
return (pIndex->iIndex[2] << 16) + (pIndex->iIndex[1] << 8) + (pIndex->iIndex[0]);
}


@@ -3821,6 +3815,7 @@ qboolean R_LoadMDXA( model_t *mod, void *buffer, const char *mod_name, qboolean
mdxaCompQuatBone_t *pCompBonePool;
unsigned short *pwIn;
mdxaIndex_t *pIndex;
int tmp;
#endif

pinmodel = (mdxaHeader_t *)buffer;
@@ -3909,24 +3904,24 @@ 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);
// Determine the amount of compressed bones.

// 3 byte ints, yeah...
int tmp = pIndex->iIndex & 0xFFFFFF00;
LL(tmp);
// Find the largest index by iterating through all frames.
// It is not guaranteed that the compressed bone pool resides
// at the end of the file.
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);
tmp = (pIndex->iIndex[2] << 16) + (pIndex->iIndex[1] << 8) + (pIndex->iIndex[0]);

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

// swap the compressed bones
// Swap the compressed bones.
pCompBonePool = (mdxaCompQuatBone_t *) ((byte *)mdxa + mdxa->ofsCompBonePool);
for ( i = 0 ; i <= maxBoneIndex ; i++ )
{
@@ -417,10 +417,11 @@ typedef struct mdxaHeader_s {
//
// (iFrameNum * mdxaHeader_t->numBones * 3) + (iBoneNum * 3)
//
// then read the int at that location and AND it with 0x00FFFFFF. I use the struct below simply for easy searches
// Then convert the three byte int at that location.
// This struct is used for easy searches.
typedef struct
{
int iIndex; // this struct for pointing purposes, need to and with 0x00FFFFFF to be meaningful
byte iIndex[3];
} mdxaIndex_t;
//
// (note that there's then an alignement-pad here to get the next struct back onto 32-bit alignement)
@@ -915,13 +915,12 @@ void Multiply_3x4Matrix(mdxaBone_t *out, mdxaBone_t *in2, mdxaBone_t *in)
}


static int G2_GetBonePoolIndex( const mdxaHeader_t *pMDXAHeader, int iFrame, int iBone)
static int G2_GetBonePoolIndex(const mdxaHeader_t *pMDXAHeader, int iFrame, int iBone)
{
const int iOffsetToIndex = (iFrame * pMDXAHeader->numBones * 3) + (iBone * 3);
const int iOffsetToIndex = (iFrame * pMDXAHeader->numBones * 3) + (iBone * 3);
mdxaIndex_t *pIndex = (mdxaIndex_t *)((byte*)pMDXAHeader + pMDXAHeader->ofsFrames + iOffsetToIndex);

mdxaIndex_t *pIndex = (mdxaIndex_t *) ((byte*) pMDXAHeader + pMDXAHeader->ofsFrames + iOffsetToIndex);

return pIndex->iIndex & 0x00FFFFFF; // this will cause problems for big-endian machines... ;-)
return (pIndex->iIndex[2] << 16) + (pIndex->iIndex[1] << 8) + (pIndex->iIndex[0]);
}


@@ -1067,19 +1067,12 @@ void Multiply_3x4Matrix(mdxaBone_t *out, mdxaBone_t *in2, mdxaBone_t *in)
}


static int G2_GetBonePoolIndex( const mdxaHeader_t *pMDXAHeader, int iFrame, int iBone)
static int G2_GetBonePoolIndex(const mdxaHeader_t *pMDXAHeader, int iFrame, int iBone)
{
const int iOffsetToIndex = (iFrame * pMDXAHeader->numBones * 3) + (iBone * 3);
const int iOffsetToIndex = (iFrame * pMDXAHeader->numBones * 3) + (iBone * 3);
mdxaIndex_t *pIndex = (mdxaIndex_t *)((byte*)pMDXAHeader + pMDXAHeader->ofsFrames + iOffsetToIndex);

mdxaIndex_t *pIndex = (mdxaIndex_t *) ((byte*) pMDXAHeader + pMDXAHeader->ofsFrames + iOffsetToIndex);

#ifdef Q3_BIG_ENDIAN
int tmp = pIndex->iIndex & 0xFFFFFF00;
LL(tmp);
return tmp;
#else
return pIndex->iIndex & 0x00FFFFFF;
#endif
return (pIndex->iIndex[2] << 16) + (pIndex->iIndex[1] << 8) + (pIndex->iIndex[0]);
}


@@ -4657,6 +4650,7 @@ qboolean R_LoadMDXA( model_t *mod, void *buffer, const char *mod_name, qboolean
mdxaCompQuatBone_t *pCompBonePool;
unsigned short *pwIn;
mdxaIndex_t *pIndex;
int tmp;
#endif

pinmodel = (mdxaHeader_t *)buffer;
@@ -4875,24 +4869,24 @@ 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);
// Determine the amount of compressed bones.

// 3 byte ints, yeah...
int tmp = pIndex->iIndex & 0xFFFFFF00;
LL(tmp);
// Find the largest index by iterating through all frames.
// It is not guaranteed that the compressed bone pool resides
// at the end of the file.
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);
tmp = (pIndex->iIndex[2] << 16) + (pIndex->iIndex[1] << 8) + (pIndex->iIndex[0]);

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

// swap the compressed bones
// Swap the compressed bones.
pCompBonePool = (mdxaCompQuatBone_t *) ((byte *)mdxa + mdxa->ofsCompBonePool);
for ( i = 0 ; i <= maxBoneIndex ; i++ )
{
@@ -682,6 +682,7 @@ qboolean ServerLoadMDXA( model_t *mod, void *buffer, const char *mod_name, qbool
mdxaCompQuatBone_t *pCompBonePool;
unsigned short *pwIn;
mdxaIndex_t *pIndex;
int tmp;
#endif

pinmodel = (mdxaHeader_t *)buffer;
@@ -767,24 +768,24 @@ 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);
// Determine the amount of compressed bones.

// 3 byte ints, yeah...
int tmp = pIndex->iIndex & 0xFFFFFF00;
LL(tmp);
// Find the largest index by iterating through all frames.
// It is not guaranteed that the compressed bone pool resides
// at the end of the file.
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);
tmp = (pIndex->iIndex[2] << 16) + (pIndex->iIndex[1] << 8) + (pIndex->iIndex[0]);

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

// swap the compressed bones
// Swap the compressed bones.
pCompBonePool = (mdxaCompQuatBone_t *) ((byte *)mdxa + mdxa->ofsCompBonePool);
for ( i = 0 ; i <= maxBoneIndex ; i++ )
{

0 comments on commit 212d7d8

Please sign in to comment.
You can’t perform that action at this time.