]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - model_brush.c
Avoid passing NULLs to glBufferSubData.
[xonotic/darkplaces.git] / model_brush.c
index 0cd1e1911d26626fcecc055772fee21065b4275d..9eb87f13caca65e8535a6704c7a8621c543b9bba 100644 (file)
@@ -1636,8 +1636,8 @@ static void R_Q1BSP_LoadSplitSky (unsigned char *src, int width, int height, int
                }
        }
 
-       loadmodel->brush.solidskyskinframe = R_SkinFrame_LoadInternalBGRA("sky_solidtexture", 0         , (unsigned char *) solidpixels, w, h, vid.sRGB3D);
-       loadmodel->brush.alphaskyskinframe = R_SkinFrame_LoadInternalBGRA("sky_alphatexture", TEXF_ALPHA, (unsigned char *) alphapixels, w, h, vid.sRGB3D);
+       loadmodel->brush.solidskyskinframe = R_SkinFrame_LoadInternalBGRA("sky_solidtexture", 0         , (unsigned char *) solidpixels, w, h, 0, 0, 0, vid.sRGB3D);
+       loadmodel->brush.alphaskyskinframe = R_SkinFrame_LoadInternalBGRA("sky_alphatexture", TEXF_ALPHA, (unsigned char *) alphapixels, w, h, 0, 0, 0, vid.sRGB3D);
        Mem_Free(solidpixels);
        Mem_Free(alphapixels);
 }
@@ -1910,7 +1910,7 @@ static void Mod_Q1BSP_LoadTextures(sizebuf_t *sb)
                                                {
                                                        tx->width = image_width;
                                                        tx->height = image_height;
-                                                       skinframe = R_SkinFrame_LoadInternalBGRA(tx->name, TEXF_ALPHA | TEXF_MIPMAP | TEXF_ISWORLD | TEXF_PICMIP, pixels, image_width, image_height, true);
+                                                       skinframe = R_SkinFrame_LoadInternalBGRA(tx->name, TEXF_ALPHA | TEXF_MIPMAP | TEXF_ISWORLD | TEXF_PICMIP, pixels, image_width, image_height, image_width, image_height, CRC_Block(pixels, image_width * image_height * 4), true);
                                                }
                                                if (freepixels)
                                                        Mem_Free(freepixels);
@@ -1924,9 +1924,9 @@ static void Mod_Q1BSP_LoadTextures(sizebuf_t *sb)
                        }
                        // LordHavoc: some Tenebrae textures get replaced by black
                        if (!strncmp(tx->name, "*glassmirror", 12)) // Tenebrae
-                               tx->materialshaderpass->skinframes[0] = R_SkinFrame_LoadInternalBGRA(tx->name, TEXF_MIPMAP | TEXF_ALPHA, zerotrans, 1, 1, false);
+                               tx->materialshaderpass->skinframes[0] = R_SkinFrame_LoadInternalBGRA(tx->name, TEXF_MIPMAP | TEXF_ALPHA, zerotrans, 1, 1, 0, 0, 0, false);
                        else if (!strncmp(tx->name, "mirror", 6)) // Tenebrae
-                               tx->materialshaderpass->skinframes[0] = R_SkinFrame_LoadInternalBGRA(tx->name, 0, zeroopaque, 1, 1, false);
+                               tx->materialshaderpass->skinframes[0] = R_SkinFrame_LoadInternalBGRA(tx->name, 0, zeroopaque, 1, 1, 0, 0, 0, false);
                        tx->currentskinframe = tx->materialshaderpass->skinframes[0];
                }
 
@@ -3852,29 +3852,6 @@ static void Mod_Q1BSP_RoundUpToHullSize(dp_model_t *cmodel, const vec3_t inmins,
        VectorAdd(inmins, hull->clip_size, outmaxs);
 }
 
-static int Mod_Q1BSP_CreateShadowMesh(dp_model_t *mod)
-{
-       int j;
-       int numshadowmeshtriangles = 0;
-       msurface_t *surface;
-       if (cls.state == ca_dedicated)
-               return 0;
-       // make a single combined shadow mesh to allow optimized shadow volume creation
-
-       for (j = 0, surface = mod->data_surfaces;j < mod->num_surfaces;j++, surface++)
-       {
-               surface->num_firstshadowmeshtriangle = numshadowmeshtriangles;
-               numshadowmeshtriangles += surface->num_triangles;
-       }
-       mod->brush.shadowmesh = Mod_ShadowMesh_Begin(mod->mempool, numshadowmeshtriangles * 3, numshadowmeshtriangles, NULL, NULL, NULL, false, true);
-       for (j = 0, surface = mod->data_surfaces;j < mod->num_surfaces;j++, surface++)
-               if (surface->num_triangles > 0)
-                       Mod_ShadowMesh_AddMesh(mod->mempool, mod->brush.shadowmesh, NULL, NULL, NULL, mod->surfmesh.data_vertex3f, NULL, NULL, NULL, NULL, surface->num_triangles, (mod->surfmesh.data_element3i + 3 * surface->num_firsttriangle));
-       mod->brush.shadowmesh = Mod_ShadowMesh_Finish(mod->mempool, mod->brush.shadowmesh, false, false);
-
-       return numshadowmeshtriangles;
-}
-
 void Mod_CollisionBIH_TraceLineAgainstSurfaces(dp_model_t *model, const frameblend_t *frameblend, const skeleton_t *skeleton, trace_t *trace, const vec3_t start, const vec3_t end, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask);
 
 void Mod_Q1BSP_Load(dp_model_t *mod, void *buffer, void *bufferend)
@@ -4039,9 +4016,6 @@ void Mod_Q1BSP_Load(dp_model_t *mod, void *buffer, void *bufferend)
        mod->numframes = 2;             // regular and alternate animation
        mod->numskins = 1;
 
-       // make a single combined shadow mesh to allow optimized shadow volume creation
-       Mod_Q1BSP_CreateShadowMesh(loadmodel);
-
        if (loadmodel->brush.numsubmodels)
                loadmodel->brush.submodels = (dp_model_t **)Mem_Alloc(loadmodel->mempool, loadmodel->brush.numsubmodels * sizeof(dp_model_t *));
 
@@ -5025,9 +4999,6 @@ static void Mod_Q2BSP_Load(dp_model_t *mod, void *buffer, void *bufferend)
        mod->numframes = 0;             // q2bsp animations are kind of special, frame is unbounded...
        mod->numskins = 1;
 
-       // make a single combined shadow mesh to allow optimized shadow volume creation
-       Mod_Q1BSP_CreateShadowMesh(loadmodel);
-
        if (loadmodel->brush.numsubmodels)
                loadmodel->brush.submodels = (dp_model_t **)Mem_Alloc(loadmodel->mempool, loadmodel->brush.numsubmodels * sizeof(dp_model_t *));
 
@@ -7992,9 +7963,6 @@ static void Mod_Q3BSP_Load(dp_model_t *mod, void *buffer, void *bufferend)
        // FIXME: shader alpha should replace r_wateralpha support in q3bsp
        loadmodel->brush.supportwateralpha = true;
 
-       // make a single combined shadow mesh to allow optimized shadow volume creation
-       Mod_Q1BSP_CreateShadowMesh(loadmodel);
-
        loadmodel->brush.num_leafs = 0;
        Mod_Q3BSP_RecursiveFindNumLeafs(loadmodel->brush.data_nodes);
 
@@ -8611,9 +8579,6 @@ void Mod_OBJ_Load(dp_model_t *mod, void *buffer, void *bufferend)
        Mem_Free(vertexhashtable);
        Mem_Free(vertexhashdata);
 
-       // make a single combined shadow mesh to allow optimized shadow volume creation
-       Mod_Q1BSP_CreateShadowMesh(loadmodel);
-
        // compute all the mesh information that was not loaded from the file
        if (loadmodel->surfmesh.data_element3s)
                for (i = 0;i < loadmodel->surfmesh.num_triangles*3;i++)