[quake3-commits] r1963 - in trunk: . code/renderer

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri May 6 07:43:08 EDT 2011


Author: thilo
Date: 2011-05-06 07:43:07 -0400 (Fri, 06 May 2011)
New Revision: 1963

Modified:
   trunk/Makefile
   trunk/code/renderer/tr_local.h
   trunk/code/renderer/tr_model.c
   trunk/code/renderer/tr_model_iqm.c
Log:
IQM skin support and print limit info, make other limit info consistent, patch by Zack Middleton (#4978)


Modified: trunk/Makefile
===================================================================
--- trunk/Makefile	2011-05-05 13:33:43 UTC (rev 1962)
+++ trunk/Makefile	2011-05-06 11:43:07 UTC (rev 1963)
@@ -1423,12 +1423,12 @@
   $(B)/client/tr_image_tga.o \
   $(B)/client/tr_image_pcx.o \
   $(B)/client/tr_init.o \
-  $(B)/client/tr_model_iqm.o \
   $(B)/client/tr_light.o \
   $(B)/client/tr_main.o \
   $(B)/client/tr_marks.o \
   $(B)/client/tr_mesh.o \
   $(B)/client/tr_model.o \
+  $(B)/client/tr_model_iqm.o \
   $(B)/client/tr_noise.o \
   $(B)/client/tr_scene.o \
   $(B)/client/tr_shade.o \

Modified: trunk/code/renderer/tr_local.h
===================================================================
--- trunk/code/renderer/tr_local.h	2011-05-05 13:33:43 UTC (rev 1962)
+++ trunk/code/renderer/tr_local.h	2011-05-06 11:43:07 UTC (rev 1963)
@@ -668,6 +668,7 @@
 // inter-quake-model surface
 typedef struct srfIQModel_s {
 	surfaceType_t	surfaceType;
+	char		name[MAX_QPATH];
 	shader_t	*shader;
 	iqmData_t	*data;
 	int		first_vertex, num_vertexes;

Modified: trunk/code/renderer/tr_model.c
===================================================================
--- trunk/code/renderer/tr_model.c	2011-05-05 13:33:43 UTC (rev 1962)
+++ trunk/code/renderer/tr_model.c	2011-05-06 11:43:07 UTC (rev 1963)
@@ -466,12 +466,14 @@
         LL(surf->ofsEnd);
 		
 		if ( surf->numVerts > SHADER_MAX_VERTEXES ) {
-			ri.Error (ERR_DROP, "R_LoadMD3: %s has more than %i verts on a surface (%i)",
+			ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has more than %i verts on a surface (%i).\n",
 				mod_name, SHADER_MAX_VERTEXES, surf->numVerts );
+			return qfalse;
 		}
 		if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) {
-			ri.Error (ERR_DROP, "R_LoadMD3: %s has more than %i triangles on a surface (%i)",
+			ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has more than %i triangles on a surface (%i).\n",
 				mod_name, SHADER_MAX_INDEXES / 3, surf->numTriangles );
+			return qfalse;
 		}
 	
 		// change to surface identifier
@@ -742,13 +744,13 @@
 			// now do the checks that may fail.
 			if ( surf->numVerts > SHADER_MAX_VERTEXES ) 
 			{
-				ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i verts on a surface (%i)",
+				ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i verts on a surface (%i).\n",
 					  mod_name, SHADER_MAX_VERTEXES, surf->numVerts );
 				return qfalse;
 			}
 			if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) 
 			{
-				ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i triangles on a surface (%i)",
+				ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i triangles on a surface (%i).\n",
 					  mod_name, SHADER_MAX_INDEXES / 3, surf->numTriangles );
 				return qfalse;
 			}
@@ -957,12 +959,14 @@
 			LL(surf->ofsEnd);
 			
 			if ( surf->numVerts > SHADER_MAX_VERTEXES ) {
-				ri.Error (ERR_DROP, "R_LoadMD3: %s has more than %i verts on a surface (%i)",
+				ri.Printf(PRINT_WARNING, "R_LoadMD4: %s has more than %i verts on a surface (%i).\n",
 					mod_name, SHADER_MAX_VERTEXES, surf->numVerts );
+				return qfalse;
 			}
 			if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) {
-				ri.Error (ERR_DROP, "R_LoadMD3: %s has more than %i triangles on a surface (%i)",
+				ri.Printf(PRINT_WARNING, "R_LoadMD4: %s has more than %i triangles on a surface (%i).\n",
 					mod_name, SHADER_MAX_INDEXES / 3, surf->numTriangles );
+				return qfalse;
 			}
 
 			// change to surface identifier

Modified: trunk/code/renderer/tr_model_iqm.c
===================================================================
--- trunk/code/renderer/tr_model_iqm.c	2011-05-05 13:33:43 UTC (rev 1962)
+++ trunk/code/renderer/tr_model_iqm.c	2011-05-06 11:43:07 UTC (rev 1963)
@@ -193,6 +193,13 @@
 	LL( header->num_extensions );
 	LL( header->ofs_extensions );
 
+	// check ioq3 joint limit
+	if ( header->num_joints > IQM_MAX_JOINTS ) {
+		ri.Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %d joints (%d).\n",
+				mod_name, IQM_MAX_JOINTS, header->num_joints);
+		return qfalse;
+	}
+
 	// check and swap vertex arrays
 	if( IQM_CheckRange( header, header->ofs_vertexarrays,
 			    header->num_vertexarrays,
@@ -305,7 +312,21 @@
 		LL( mesh->num_vertexes );
 		LL( mesh->first_triangle );
 		LL( mesh->num_triangles );
-		
+
+		// check ioq3 limits
+		if ( mesh->num_vertexes > SHADER_MAX_VERTEXES ) 
+		{
+			ri.Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %i verts on a surface (%i).\n",
+				  mod_name, SHADER_MAX_VERTEXES, mesh->num_vertexes );
+			return qfalse;
+		}
+		if ( mesh->num_triangles*3 > SHADER_MAX_INDEXES ) 
+		{
+			ri.Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %i triangles on a surface (%i).\n",
+				  mod_name, SHADER_MAX_INDEXES / 3, mesh->num_triangles );
+			return qfalse;
+		}
+
 		if( mesh->first_vertex >= header->num_vertexes ||
 		    mesh->first_vertex + mesh->num_vertexes > header->num_vertexes ||
 		    mesh->first_triangle >= header->num_triangles ||
@@ -319,8 +340,7 @@
 	}
 
 	// check and swap joints
-	if( header->num_joints > IQM_MAX_JOINTS ||
-	    IQM_CheckRange( header, header->ofs_joints,
+	if( IQM_CheckRange( header, header->ofs_joints,
 			    header->num_joints, sizeof(iqmJoint_t) ) ) {
 		return qfalse;
 	}
@@ -542,6 +562,7 @@
 	str = (char *)header + header->ofs_text;
 	for( i = 0; i < header->num_meshes; i++, mesh++, surface++ ) {
 		surface->surfaceType = SF_IQM;
+		Q_strncpyz(surface->name, str + mesh->name, sizeof (surface->name));
 		surface->shader = R_FindShader( str + mesh->material, LIGHTMAP_NONE, qtrue );
 		if( surface->shader->defaultShader )
 			surface->shader = tr.defaultShader;
@@ -550,7 +571,7 @@
 		surface->num_vertexes = mesh->num_vertexes;
 		surface->first_triangle = mesh->first_triangle;
 		surface->num_triangles = mesh->num_triangles;
-        }
+	}
 
 	// copy vertexarrays and indexes
 	vertexarray = (iqmVertexArray_t *)((byte *)header + header->ofs_vertexarrays);
@@ -734,11 +755,12 @@
 void R_AddIQMSurfaces( trRefEntity_t *ent ) {
 	iqmData_t		*data;
 	srfIQModel_t		*surface;
-	int			i;
+	int			i, j;
 	qboolean		personalModel;
 	int			cull;
 	int			fogNum;
 	shader_t		*shader;
+	skin_t			*skin;
 
 	data = tr.currentModel->modelData;
 	surface = data->surfaces;
@@ -790,8 +812,21 @@
 	fogNum = R_ComputeIQMFogNum( data, ent );
 
 	for ( i = 0 ; i < data->num_surfaces ; i++ ) {
-		if( ent->e.customShader ) {
+		if(ent->e.customShader)
 			shader = R_GetShaderByHandle( ent->e.customShader );
+		else if(ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins)
+		{
+			skin = R_GetSkinByHandle(ent->e.customSkin);
+			shader = tr.defaultShader;
+
+			for(j = 0; j < skin->numSurfaces; j++)
+			{
+				if (!strcmp(skin->surfaces[j]->name, surface->name))
+				{
+					shader = skin->surfaces[j]->shader;
+					break;
+				}
+			}
 		} else {
 			shader = surface->shader;
 		}
@@ -816,8 +851,7 @@
 		}
 
 		if( !personalModel ) {
-			R_AddDrawSurf( &surface->surfaceType,
-				       shader, fogNum, 0 );
+			R_AddDrawSurf( (void *)surface, shader, fogNum, 0 );
 		}
 
 		surface++;



More information about the quake3-commits mailing list