summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThilo Schulz <arny@ats.s.bawue.de>2011-05-06 11:43:07 +0000
committerTim Angus <tim@ngus.net>2013-01-09 21:36:39 +0000
commite0a6aceec0f66b5fd1f72705f27d3d50695bebe7 (patch)
treee8c7510fdc4105f2e3fe8028621f1eb684caca3c /src
parentc5701c9d79c1e6d74205844c06b3211f5f11a189 (diff)
IQM skin support and print limit info, make other limit info consistent, patch by Zack Middleton (#4978)
Diffstat (limited to 'src')
-rw-r--r--src/renderer/tr_local.h1
-rw-r--r--src/renderer/tr_model.c16
-rw-r--r--src/renderer/tr_model_iqm.c50
3 files changed, 53 insertions, 14 deletions
diff --git a/src/renderer/tr_local.h b/src/renderer/tr_local.h
index 922dca21..ef49e217 100644
--- a/src/renderer/tr_local.h
+++ b/src/renderer/tr_local.h
@@ -669,6 +669,7 @@ typedef struct {
// 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;
diff --git a/src/renderer/tr_model.c b/src/renderer/tr_model.c
index af42db3a..8f992cf5 100644
--- a/src/renderer/tr_model.c
+++ b/src/renderer/tr_model.c
@@ -467,12 +467,14 @@ static qboolean R_LoadMD3 (model_t *mod, int lod, void *buffer, const char *mod_
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
@@ -743,13 +745,13 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char
// 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;
}
@@ -958,12 +960,14 @@ static qboolean R_LoadMD4( model_t *mod, void *buffer, const char *mod_name ) {
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
diff --git a/src/renderer/tr_model_iqm.c b/src/renderer/tr_model_iqm.c
index 51d5516e..ea2a903d 100644
--- a/src/renderer/tr_model_iqm.c
+++ b/src/renderer/tr_model_iqm.c
@@ -193,6 +193,13 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
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 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
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 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
}
// 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 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
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 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
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 @@ Add all surfaces of this model
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 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) {
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 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) {
}
if( !personalModel ) {
- R_AddDrawSurf( &surface->surfaceType,
- shader, fogNum, 0 );
+ R_AddDrawSurf( (void *)surface, shader, fogNum, 0 );
}
surface++;