[iortcw] 111/497: All: Make R_LerpTag return qfalse if MDR tag does not exist

Simon McVittie smcv at debian.org
Fri Sep 8 10:36:34 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag 1.42d
in repository iortcw.

commit ea00cf376229ad1a0781d64d7635991cea3a6f10
Author: M4N4T4RMS at gmail.com <M4N4T4RMS at gmail.com@e65d2741-a53d-b2dc-ae96-bb75fa5e4c4a>
Date:   Fri May 9 22:08:22 2014 +0000

    All: Make R_LerpTag return qfalse if MDR tag does not exist
---
 MP/code/rend2/tr_model.c    | 29 ++++++++++-------------------
 MP/code/renderer/tr_model.c | 34 +++++++++++-----------------------
 SP/code/rend2/tr_model.c    | 28 ++++++++++------------------
 SP/code/renderer/tr_model.c | 34 +++++++++++-----------------------
 4 files changed, 42 insertions(+), 83 deletions(-)

diff --git a/MP/code/rend2/tr_model.c b/MP/code/rend2/tr_model.c
index 1e2b2e9..c2cdbf1 100644
--- a/MP/code/rend2/tr_model.c
+++ b/MP/code/rend2/tr_model.c
@@ -2143,7 +2143,7 @@ static int R_GetTag(mdvModel_t * model, int frame, const char *_tagName, int sta
 	return -1;
 }
 
-void R_GetAnimTag( mdrHeader_t *mod, int framenum, const char *tagName, mdvTag_t * dest) 
+mdvTag_t *R_GetAnimTag( mdrHeader_t *mod, int framenum, const char *tagName, mdvTag_t * dest)
 {
 	int				i, j, k;
 	int				frameSize;
@@ -2176,12 +2176,11 @@ void R_GetAnimTag( mdrHeader_t *mod, int framenum, const char *tagName, mdvTag_t
 			dest->origin[1]=frame->bones[tag->boneIndex].matrix[1][3];
 			dest->origin[2]=frame->bones[tag->boneIndex].matrix[2][3];				
 
-			return;
+			return dest;
 		}
 	}
 
-	AxisClear( dest->axis );
-	VectorClear( dest->origin );
+	return NULL;
 }
 
 /*
@@ -2214,27 +2213,17 @@ int R_LerpTag( orientation_t *tag, const refEntity_t *refent, const char *tagNam
 	if ( !model->mdv[0] /*&& !model->mdc[0]*/ && !model->mds ) {
 		if(model->type == MOD_MDR)
 		{
-			start = &start_space;
-			end = &end_space;
-			R_GetAnimTag((mdrHeader_t *) model->modelData, startFrame, tagName, start);
-			R_GetAnimTag((mdrHeader_t *) model->modelData, endFrame, tagName, end);
+			start = R_GetAnimTag((mdrHeader_t *) model->modelData, startFrame, tagName, &start_space);
+			end = R_GetAnimTag((mdrHeader_t *) model->modelData, endFrame, tagName, &end_space);
 		}
 		else if( model->type == MOD_IQM ) {
 			return R_IQMLerpTag( tag, model->modelData,
 					startFrame, endFrame,
 					frac, tagName );
 		} else {
-			AxisClear( tag->axis );
-			VectorClear( tag->origin );
-			return -1;
+			start = end = NULL;
 		}
-	}
-
-	frontLerp = frac;
-	backLerp = 1.0f - frac;
-
-	if(model->type == MOD_MESH)
-	{
+	} else if (model->type == MOD_MESH) {
 		// old MD3 style
 		retval = R_GetTag(model->mdv[0], startFrame, tagName, startIndex, &start);
 		retval = R_GetTag(model->mdv[0], endFrame, tagName, startIndex, &end);
@@ -2248,7 +2237,6 @@ int R_LerpTag( orientation_t *tag, const refEntity_t *refent, const char *tagNam
 
 		// failed
 		return -1;
-
 	} else {
 		// failed
 		return -1;
@@ -2260,6 +2248,9 @@ int R_LerpTag( orientation_t *tag, const refEntity_t *refent, const char *tagNam
 		return -1;
 	}
 
+	frontLerp = frac;
+	backLerp = 1.0f - frac;
+
 	for ( i = 0 ; i < 3 ; i++ ) {
 		tag->origin[i] = start->origin[i] * backLerp +  end->origin[i] * frontLerp;
 		tag->axis[0][i] = start->axis[0][i] * backLerp +  end->axis[0][i] * frontLerp;
diff --git a/MP/code/renderer/tr_model.c b/MP/code/renderer/tr_model.c
index cb87efc..74a24dc 100644
--- a/MP/code/renderer/tr_model.c
+++ b/MP/code/renderer/tr_model.c
@@ -2005,7 +2005,7 @@ static int R_GetMDSTag( byte *mod, const char *tagName, int startTagIndex, mdsTa
 }
 */
 
-void R_GetAnimTag( mdrHeader_t *mod, int framenum, const char *tagName, md3Tag_t * dest) 
+md3Tag_t *R_GetAnimTag( mdrHeader_t *mod, int framenum, const char *tagName, md3Tag_t * dest)
 {
 	int				i, j, k;
 	int				frameSize;
@@ -2040,13 +2040,11 @@ void R_GetAnimTag( mdrHeader_t *mod, int framenum, const char *tagName, md3Tag_t
 			dest->origin[1]=frame->bones[tag->boneIndex].matrix[1][3];
 			dest->origin[2]=frame->bones[tag->boneIndex].matrix[2][3];				
 
-			return;
+			return dest;
 		}
 	}
 
-	AxisClear( dest->axis );
-	VectorClear( dest->origin );
-	strcpy(dest->name,"");
+	return NULL;
 }
 
 /*
@@ -2088,30 +2086,20 @@ int R_LerpTag( orientation_t *tag, const refEntity_t *refent, const char *tagNam
 	if ( !model->md3[0] && !model->mdc[0] && !model->mds ) {
 		if(model->type == MOD_MDR)
 		{
-			start = &start_space;
-			end = &end_space;
-			R_GetAnimTag((mdrHeader_t *) model->modelData, startFrame, tagName, start);
-			R_GetAnimTag((mdrHeader_t *) model->modelData, endFrame, tagName, end);
+			start = R_GetAnimTag((mdrHeader_t *) model->modelData, startFrame, tagName, &start_space);
+			end = R_GetAnimTag((mdrHeader_t *) model->modelData, endFrame, tagName, &end_space);
 		}
 		else if ( model->type == MOD_IQM ) {
 			return R_IQMLerpTag( tag, model->modelData,
 					startFrame, endFrame,
 					frac, tagName );
 		} else {
-			AxisClear( tag->axis );
-			VectorClear( tag->origin );
-			return -1;
+			start = end = NULL;
 		}
-	}
-
-	frontLerp = frac;
-	backLerp = 1.0f - frac;
-
-	if ( model->type == MOD_MESH ) {
+	} else if ( model->type == MOD_MESH ) {
 		// old MD3 style
 		retval = R_GetTag( (byte *)model->md3[0], startFrame, tagName, startIndex, &start );
 		retval = R_GetTag( (byte *)model->md3[0], endFrame, tagName, startIndex, &end );
-
 	} else if ( model->type == MOD_MDS ) {    // use bone lerping
 
 		retval = R_GetBoneTag( tag, model->mds, startIndex, refent, tagNameIn );
@@ -2122,7 +2110,6 @@ int R_LerpTag( orientation_t *tag, const refEntity_t *refent, const char *tagNam
 
 		// failed
 		return -1;
-
 	} else {
 		// psuedo-compressed MDC tags
 		mdcTag_t    *cstart, *cend;
@@ -2145,10 +2132,8 @@ int R_LerpTag( orientation_t *tag, const refEntity_t *refent, const char *tagNam
 			start = &ustart;
 			end = &uend;
 		} else {
-			start = NULL;
-			end = NULL;
+			start = end = NULL;
 		}
-
 	}
 
 	if ( !start || !end ) {
@@ -2157,6 +2142,9 @@ int R_LerpTag( orientation_t *tag, const refEntity_t *refent, const char *tagNam
 		return -1;
 	}
 
+	frontLerp = frac;
+	backLerp = 1.0f - frac;
+
 	for ( i = 0 ; i < 3 ; i++ ) {
 		tag->origin[i] = start->origin[i] * backLerp +  end->origin[i] * frontLerp;
 		tag->axis[0][i] = start->axis[0][i] * backLerp +  end->axis[0][i] * frontLerp;
diff --git a/SP/code/rend2/tr_model.c b/SP/code/rend2/tr_model.c
index 0f932f5..fd46d1c 100644
--- a/SP/code/rend2/tr_model.c
+++ b/SP/code/rend2/tr_model.c
@@ -2139,7 +2139,7 @@ static int R_GetTag(mdvModel_t * model, int frame, const char *_tagName, int sta
 	return -1;
 }
 
-void R_GetAnimTag( mdrHeader_t *mod, int framenum, const char *tagName, mdvTag_t * dest)
+mdvTag_t *R_GetAnimTag( mdrHeader_t *mod, int framenum, const char *tagName, mdvTag_t * dest)
 {
 	int				i, j, k;
 	int				frameSize;
@@ -2172,12 +2172,11 @@ void R_GetAnimTag( mdrHeader_t *mod, int framenum, const char *tagName, mdvTag_t
 			dest->origin[1]=frame->bones[tag->boneIndex].matrix[1][3];
 			dest->origin[2]=frame->bones[tag->boneIndex].matrix[2][3];				
 
-			return;
+			return dest;
 		}
 	}
 
-	AxisClear( dest->axis );
-	VectorClear( dest->origin );
+	return NULL;
 }
 
 
@@ -2211,26 +2210,17 @@ int R_LerpTag( orientation_t *tag, const refEntity_t *refent, const char *tagNam
 	if ( !model->mdv[0] /*&& !model->mdc[0]*/ && !model->mds ) {
 		if(model->type == MOD_MDR)
 		{
-			start = &start_space;
-			end = &end_space;
-			R_GetAnimTag((mdrHeader_t *) model->modelData, startFrame, tagName, start);
-			R_GetAnimTag((mdrHeader_t *) model->modelData, endFrame, tagName, end);
+			start = R_GetAnimTag((mdrHeader_t *) model->modelData, startFrame, tagName, &start_space);
+			end = R_GetAnimTag((mdrHeader_t *) model->modelData, endFrame, tagName, &end_space);
 		}
 		else if ( model->type == MOD_IQM ) {
 			return R_IQMLerpTag( tag, model->modelData,
 					startFrame, endFrame,
 					frac, tagName );
 		} else {
-			AxisClear( tag->axis );
-			VectorClear( tag->origin );
-			return -1;
+			start = end = NULL;
 		}
-	}
-
-	frontLerp = frac;
-	backLerp = 1.0f - frac;
-
-	if ( model->type == MOD_MESH ) {
+	} else if ( model->type == MOD_MESH ) {
 		// old MD3 style
 		retval = R_GetTag(model->mdv[0], startFrame, tagName, startIndex, &start);
 		retval = R_GetTag(model->mdv[0], endFrame, tagName, startIndex, &end);
@@ -2244,7 +2234,6 @@ int R_LerpTag( orientation_t *tag, const refEntity_t *refent, const char *tagNam
 
 		// failed
 		return -1;
-
 	} else {
 		// failed
 		return -1;
@@ -2256,6 +2245,9 @@ int R_LerpTag( orientation_t *tag, const refEntity_t *refent, const char *tagNam
 		return -1;
 	}
 
+	frontLerp = frac;
+	backLerp = 1.0f - frac;
+
 	for ( i = 0 ; i < 3 ; i++ ) {
 		tag->origin[i] = start->origin[i] * backLerp +  end->origin[i] * frontLerp;
 		tag->axis[0][i] = start->axis[0][i] * backLerp +  end->axis[0][i] * frontLerp;
diff --git a/SP/code/renderer/tr_model.c b/SP/code/renderer/tr_model.c
index 0953b85..7f09fcc 100644
--- a/SP/code/renderer/tr_model.c
+++ b/SP/code/renderer/tr_model.c
@@ -1998,7 +1998,7 @@ static int R_GetMDSTag( byte *mod, const char *tagName, int startTagIndex, mdsTa
 */
 
 
-void R_GetAnimTag( mdrHeader_t *mod, int framenum, const char *tagName, md3Tag_t * dest) 
+md3Tag_t *R_GetAnimTag( mdrHeader_t *mod, int framenum, const char *tagName, md3Tag_t * dest)
 {
 	int				i, j, k;
 	int				frameSize;
@@ -2033,13 +2033,11 @@ void R_GetAnimTag( mdrHeader_t *mod, int framenum, const char *tagName, md3Tag_t
 			dest->origin[1]=frame->bones[tag->boneIndex].matrix[1][3];
 			dest->origin[2]=frame->bones[tag->boneIndex].matrix[2][3];				
 
-			return;
+			return dest;
 		}
 	}
 
-	AxisClear( dest->axis );
-	VectorClear( dest->origin );
-	strcpy(dest->name,"");
+	return NULL;
 }
 
 
@@ -2082,30 +2080,20 @@ int R_LerpTag( orientation_t *tag, const refEntity_t *refent, const char *tagNam
 	if ( !model->md3[0] && !model->mdc[0] && !model->mds ) {
 		if(model->type == MOD_MDR)
 		{
-			start = &start_space;
-			end = &end_space;
-			R_GetAnimTag((mdrHeader_t *) model->modelData, startFrame, tagName, start);
-			R_GetAnimTag((mdrHeader_t *) model->modelData, endFrame, tagName, end);
+			start = R_GetAnimTag((mdrHeader_t *) model->modelData, startFrame, tagName, &start_space);
+			end = R_GetAnimTag((mdrHeader_t *) model->modelData, endFrame, tagName, &end_space);
 		}
 		else if ( model->type == MOD_IQM ) {
 			return R_IQMLerpTag( tag, model->modelData,
 					startFrame, endFrame,
 					frac, tagName );
 		} else {
-			AxisClear( tag->axis );
-			VectorClear( tag->origin );
-			return -1;
+			start = end = NULL;
 		}
-	}
-
-	frontLerp = frac;
-	backLerp = 1.0f - frac;
-
-	if ( model->type == MOD_MESH ) {
+	} else if ( model->type == MOD_MESH ) {
 		// old MD3 style
 		retval = R_GetTag( (byte *)model->md3[0], startFrame, tagName, startIndex, &start );
 		retval = R_GetTag( (byte *)model->md3[0], endFrame, tagName, startIndex, &end );
-
 	} else if ( model->type == MOD_MDS ) {    // use bone lerping
 
 		retval = R_GetBoneTag( tag, model->mds, startIndex, refent, tagNameIn );
@@ -2116,7 +2104,6 @@ int R_LerpTag( orientation_t *tag, const refEntity_t *refent, const char *tagNam
 
 		// failed
 		return -1;
-
 	} else {
 		// psuedo-compressed MDC tags
 		mdcTag_t    *cstart, *cend;
@@ -2139,10 +2126,8 @@ int R_LerpTag( orientation_t *tag, const refEntity_t *refent, const char *tagNam
 			start = &ustart;
 			end = &uend;
 		} else {
-			start = NULL;
-			end = NULL;
+			start = end = NULL;
 		}
-
 	}
 
 	if ( !start || !end ) {
@@ -2151,6 +2136,9 @@ int R_LerpTag( orientation_t *tag, const refEntity_t *refent, const char *tagNam
 		return -1;
 	}
 
+	frontLerp = frac;
+	backLerp = 1.0f - frac;
+
 	for ( i = 0 ; i < 3 ; i++ ) {
 		tag->origin[i] = start->origin[i] * backLerp +  end->origin[i] * frontLerp;
 		tag->axis[0][i] = start->axis[0][i] * backLerp +  end->axis[0][i] * frontLerp;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git



More information about the Pkg-games-commits mailing list