]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - model_shared.c
implemented tag attachments on skeletal .zym models and centralized the code dealing...
[xonotic/darkplaces.git] / model_shared.c
index d1b4ecd07f49824cb4affbe0fac2f37806410d10..50fb26998462c43ab0094a3e8f915435b200a232 100644 (file)
@@ -35,7 +35,7 @@ model_t *loadmodel;
 static model_t mod_known[MAX_MOD_KNOWN];
 
 rtexturepool_t *mod_shared_texturepool;
-rtexture_t *r_notexture;
+rtexture_t *r_texture_notexture;
 rtexture_t *mod_shared_detailtextures[NUM_DETAILTEXTURES];
 rtexture_t *mod_shared_distorttexture[64];
 
@@ -136,36 +136,8 @@ void Mod_BuildDistortTexture (void)
        return;
 }
 
-texture_t r_surf_notexture;
-
 void Mod_SetupNoTexture(void)
 {
-       int x, y;
-       qbyte pix[16][16][4];
-
-       // this makes a light grey/dark grey checkerboard texture
-       for (y = 0;y < 16;y++)
-       {
-               for (x = 0;x < 16;x++)
-               {
-                       if ((y < 8) ^ (x < 8))
-                       {
-                               pix[y][x][0] = 128;
-                               pix[y][x][1] = 128;
-                               pix[y][x][2] = 128;
-                               pix[y][x][3] = 255;
-                       }
-                       else
-                       {
-                               pix[y][x][0] = 64;
-                               pix[y][x][1] = 64;
-                               pix[y][x][2] = 64;
-                               pix[y][x][3] = 255;
-                       }
-               }
-       }
-
-       r_notexture = R_LoadTexture2D(mod_shared_texturepool, "notexture", 16, 16, &pix[0][0][0], TEXTYPE_RGBA, TEXF_MIPMAP, NULL);
 }
 
 static void mod_start(void)
@@ -194,30 +166,30 @@ static void mod_shutdown(void)
 
 static void mod_newmap(void)
 {
-       msurface_t *surf;
-       int i, surfnum, ssize, tsize;
+       msurface_t *surface;
+       int i, surfacenum, ssize, tsize;
 
        if (!cl_stainmaps_clearonload.integer)
                return;
 
-       for (i=0; i<MAX_MOD_KNOWN; i++)
+       for (i = 0;i < MAX_MOD_KNOWN;i++)
        {
-               if (mod_known[i].name[0] && mod_known[i].type == mod_brushq1)
+               if (mod_known[i].name[0])
                {
-                       for (surfnum=0, surf=mod_known[i].brushq1.surfaces; surfnum<mod_known[i].brushq1.numsurfaces;surfnum++, surf++)
+                       for (surfacenum = 0, surface = mod_known[i].brush.data_surfaces;surfacenum < mod_known[i].brush.num_surfaces;surfacenum++, surface++)
                        {
-                               if (surf->texinfo->texture->flags & SURF_LIGHTMAP)
+                               if (surface->stainsamples)
                                {
-                                       ssize = (surf->extents[0] >> 4) + 1;
-                                       tsize = (surf->extents[1] >> 4) + 1;
+                                       ssize = (surface->extents[0] >> 4) + 1;
+                                       tsize = (surface->extents[1] >> 4) + 1;
 
                                        if (ssize > 256 || tsize > 256)
                                                Host_Error("Bad surface extents");
 
-                                       if (surf->stainsamples)
-                                               memset(surf->stainsamples, 255, ssize * tsize * 3);
+                                       if (surface->stainsamples)
+                                               memset(surface->stainsamples, 255, ssize * tsize * 3);
 
-                                       surf->cached_dlight = true;
+                                       surface->cached_dlight = true;
                                }
                        }
                }
@@ -308,14 +280,6 @@ static model_t *Mod_LoadModel(model_t *mod, qboolean crash, qboolean checkdisk,
        Con_DPrintf("loading model %s\n", mod->name);
        // LordHavoc: unload the existing model in this slot (if there is one)
        Mod_UnloadModel(mod);
-       if (isworldmodel)
-       {
-               // clear out any stale submodels lying around, as well as the old world model itself
-               int i;
-               for (i = 0;i < MAX_MOD_KNOWN;i++)
-                       if (mod_known[i].isworldmodel)
-                               Mod_UnloadModel(mod_known + i);
-       }
 
        // load the model
        mod->isworldmodel = isworldmodel;
@@ -412,6 +376,15 @@ void Mod_PurgeUnused(void)
                                Mod_FreeModel(mod);
 }
 
+// only used during loading!
+void Mod_RemoveStaleWorldModels(model_t *skip)
+{
+       int i;
+       for (i = 0;i < MAX_MOD_KNOWN;i++)
+               if (mod_known[i].isworldmodel && skip != &mod_known[i])
+                       Mod_UnloadModel(mod_known + i);
+}
+
 void Mod_LoadModels(void)
 {
        int i;