]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - model_shared.c
Convert \ to / when loading texture from Q3 shader
[xonotic/darkplaces.git] / model_shared.c
index d1a48daee7baebdd52043ec24d26d2eeb563cf01..94da0da8f2659763916399eed581ff2ea52fa2d7 100644 (file)
@@ -174,10 +174,10 @@ void Mod_Init (void)
        Cvar_RegisterVariable(&mod_generatelightmaps_vertexradius);
        Cvar_RegisterVariable(&mod_generatelightmaps_gridradius);
 
-       Cmd_AddCommand(&cmd_client, "modellist", Mod_Print_f, "prints a list of loaded models");
-       Cmd_AddCommand(&cmd_client, "modelprecache", Mod_Precache_f, "load a model");
-       Cmd_AddCommand(&cmd_client, "modeldecompile", Mod_Decompile_f, "exports a model in several formats for editing purposes");
-       Cmd_AddCommand(&cmd_client, "mod_generatelightmaps", Mod_GenerateLightmaps_f, "rebuilds lighting on current worldmodel");
+       Cmd_AddCommand(CMD_CLIENT, "modellist", Mod_Print_f, "prints a list of loaded models");
+       Cmd_AddCommand(CMD_CLIENT, "modelprecache", Mod_Precache_f, "load a model");
+       Cmd_AddCommand(CMD_CLIENT, "modeldecompile", Mod_Decompile_f, "exports a model in several formats for editing purposes");
+       Cmd_AddCommand(CMD_CLIENT, "mod_generatelightmaps", Mod_GenerateLightmaps_f, "rebuilds lighting on current worldmodel");
 }
 
 void Mod_RenderInit(void)
@@ -748,7 +748,7 @@ qboolean Mod_ValidateElements(int *element3i, unsigned short *element3s, int num
        }
        if (invalidintcount || invalidshortcount || invalidmismatchcount)
        {
-               Con_Printf("Mod_ValidateElements(%i, %i, %i, %p, %p) called at %s:%d", numelements, first, last, element3i, element3s, filename, fileline);
+               Con_Printf("Mod_ValidateElements(%i, %i, %i, %p, %p) called at %s:%d", numelements, first, last, (void *)element3i, (void *)element3s, filename, fileline);
                Con_Printf(", %i elements are invalid in element3i (example: element3i[%i] == %i)", invalidintcount, invalidintexample, element3i ? element3i[invalidintexample] : 0);
                Con_Printf(", %i elements are invalid in element3s (example: element3s[%i] == %i)", invalidshortcount, invalidshortexample, element3s ? element3s[invalidshortexample] : 0);
                Con_Printf(", %i elements mismatch between element3i and element3s (example: element3s[%i] is %i and element3i[%i] is %i)", invalidmismatchcount, invalidmismatchexample, element3s ? element3s[invalidmismatchexample] : 0, invalidmismatchexample, element3i ? element3i[invalidmismatchexample] : 0);
@@ -2228,7 +2228,12 @@ texture_shaderpass_t *Mod_CreateShaderPassFromQ3ShaderLayer(mempool_t *mempool,
        for (j = 0; j < Q3MAXTCMODS && layer->tcmods[j].tcmod != Q3TCMOD_NONE; j++)
                shaderpass->tcmods[j] = layer->tcmods[j];
        for (j = 0; j < layer->numframes; j++)
+       {
+               for (int i = 0; layer->texturename[j][i]; i++)
+                       if(layer->texturename[j][i] == '\\')
+                               layer->texturename[j][i] = '/';
                shaderpass->skinframes[j] = R_SkinFrame_LoadExternal(layer->texturename[j], texflags, false, true);
+       }
        return shaderpass;
 }
 
@@ -2599,7 +2604,7 @@ nothing                GL_ZERO GL_ONE
                        }
                        else
                                success = false;
-                       if (!success && warnmissing)
+                       if (!success)
                                Con_Printf("^1%s:^7 could not load texture ^3\"%s\"\n", modelname, texture->name);
                }
        }
@@ -2863,6 +2868,8 @@ void Mod_MakeSortedSurfaces(dp_model_t *mod)
        for (j = 0;j < mod->nummodelsurfaces;j++)
        {
                const msurface_t *surface = mod->data_surfaces + j + mod->firstmodelsurface;
+               if(!surface->texture)
+                       continue;
                t = (int)(surface->texture - mod->data_textures);
                numsurfacesfortexture[t]++;
        }
@@ -2875,6 +2882,8 @@ void Mod_MakeSortedSurfaces(dp_model_t *mod)
        for (j = 0;j < mod->nummodelsurfaces;j++)
        {
                const msurface_t *surface = mod->data_surfaces + j + mod->firstmodelsurface;
+               if (!surface->texture)
+                       continue;
                t = (int)(surface->texture - mod->data_textures);
                mod->sortedmodelsurfaces[firstsurfacefortexture[t]++] = j + mod->firstmodelsurface;
        }
@@ -4410,7 +4419,7 @@ texture_t *Mod_Mesh_GetTexture(dp_model_t *mod, const char *name, int defaultdra
                        mod->data_surfaces[i].texture = mod->data_textures + (mod->data_surfaces[i].texture - oldtextures);
        }
        t = &mod->data_textures[mod->num_textures++];
-       Mod_LoadTextureFromQ3Shader(mod->mempool, mod->name, t, name, false, true, defaulttexflags, defaultmaterialflags);
+       Mod_LoadTextureFromQ3Shader(mod->mempool, mod->name, t, name, true, true, defaulttexflags, defaultmaterialflags);
        t->mesh_drawflag = drawflag;
        t->mesh_defaulttexflags = defaulttexflags;
        t->mesh_defaultmaterialflags = defaultmaterialflags;
@@ -4701,6 +4710,7 @@ void Mod_Mesh_Finalize(dp_model_t *mod)
                Mod_Mesh_Validate(mod);
        Mod_Mesh_ComputeBounds(mod);
        Mod_Mesh_MakeSortedSurfaces(mod);
-       Mod_BuildTextureVectorsFromNormals(0, mod->surfmesh.num_vertices, mod->surfmesh.num_triangles, mod->surfmesh.data_vertex3f, mod->surfmesh.data_texcoordtexture2f, mod->surfmesh.data_normal3f, mod->surfmesh.data_element3i, mod->surfmesh.data_svector3f, mod->surfmesh.data_tvector3f, true);
+       if(!r_refdef.draw2dstage)
+               Mod_BuildTextureVectorsFromNormals(0, mod->surfmesh.num_vertices, mod->surfmesh.num_triangles, mod->surfmesh.data_vertex3f, mod->surfmesh.data_texcoordtexture2f, mod->surfmesh.data_normal3f, mod->surfmesh.data_element3i, mod->surfmesh.data_svector3f, mod->surfmesh.data_tvector3f, true);
        Mod_Mesh_UploadDynamicBuffers(mod);
 }