]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
check if a model's textures have deforms that need normals/tangents at load-time...
authoreihrul <eihrul@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 1 Feb 2010 10:15:46 +0000 (10:15 +0000)
committereihrul <eihrul@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 1 Feb 2010 10:15:46 +0000 (10:15 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9918 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c
model_shared.c
model_shared.h

index 04b58483d06656df52ff864123951609a2c2525f..68ca03a4147178af28370f15219de047c3168a72 100644 (file)
@@ -12287,7 +12287,19 @@ void R_DrawModelSurfaces(entity_render_t *ent, qboolean skysurfaces, qboolean wr
        else if (prepass)
                RSurf_ActiveModelEntity(ent, true, true, true);
        else if (depthonly)
-               RSurf_ActiveModelEntity(ent, false, false, false);
+       {
+               switch (vid.renderpath)
+               {
+               case RENDERPATH_GL20:
+               case RENDERPATH_CGGL:
+                       RSurf_ActiveModelEntity(ent, model->wantnormals, model->wanttangents, false);
+                       break;
+               case RENDERPATH_GL13:
+               case RENDERPATH_GL11:
+                       RSurf_ActiveModelEntity(ent, model->wantnormals, false, false);
+                       break;
+               }
+       }
        else
        {
                switch (vid.renderpath)
index 45fd314344eae43c4ac3a9d65d130587a0271508..74485ec12e0a8a82286be0eae415fbef2fc3aea7 100644 (file)
@@ -311,6 +311,31 @@ void Mod_FrameGroupify(dp_model_t *mod, const char *buf)
        Mod_FrameGroupify_ParseGroups(buf, Mod_FrameGroupify_ParseGroups_Store, mod);
 }
 
+void Mod_FindPotentialDeforms(dp_model_t *mod)
+{
+       int i, j;
+       texture_t *texture;
+       mod->wantnormals = false;
+       mod->wanttangents = false;
+       for (i = 0;i < mod->num_textures;i++)
+       {
+               texture = mod->data_textures + i;
+               if (texture->tcgen.tcgen == Q3TCGEN_ENVIRONMENT)
+                       mod->wantnormals = true;
+               for (j = 0;j < Q3MAXDEFORMS;j++)
+               {
+                       if (texture->deforms[j].deform == Q3DEFORM_AUTOSPRITE)
+                       {
+                               mod->wanttangents = true;
+                               mod->wantnormals = true;
+                               break;
+                       }
+                       if (texture->deforms[j].deform != Q3DEFORM_NONE)
+                               mod->wantnormals = true;
+               }
+       }
+}
+
 /*
 ==================
 Mod_LoadModel
@@ -447,6 +472,8 @@ dp_model_t *Mod_LoadModel(dp_model_t *mod, qboolean crash, qboolean checkdisk)
                else Con_Printf("Mod_LoadModel: model \"%s\" is of unknown/unsupported type\n", mod->name);
                Mem_Free(buf);
 
+               Mod_FindPotentialDeforms(mod);
+                                       
                buf = FS_LoadFile (va("%s.framegroups", mod->name), tempmempool, false, &filesize);
                if(buf)
                {
index 1e0c7794d35920a136cbb90fe525b6cc0354df57..8256dc713fc213699a4d381b46ebb18d664d2649 100644 (file)
@@ -882,6 +882,8 @@ typedef struct model_s
        int                             num_textures;
        int                             num_texturesperskin;
        texture_t               *data_textures;
+       qboolean                wantnormals;
+       qboolean                wanttangents;
        // surfaces of this model
        int                             num_surfaces;
        msurface_t              *data_surfaces;