X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=model_shared.c;h=5064ac4b24189821c84c5cc2d886a50069e3db2e;hp=6addcf6250fc095045d866b9b2cb15e4cf70aa2c;hb=d4c8d7d1f126232f3ed69a97da905d9425a291c2;hpb=777133232afd0d786acf9edf22dcd8744439457b diff --git a/model_shared.c b/model_shared.c index 6addcf62..5064ac4b 100644 --- a/model_shared.c +++ b/model_shared.c @@ -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,24 @@ 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_stainmapsclearonload.integer) + if (!cl_stainmaps_clearonload.integer) return; - for (i=0; itexinfo->texture->flags & SURF_LIGHTMAP) + if (surface->lightmapinfo && surface->lightmapinfo->stainsamples) { - ssize = (surf->extents[0] >> 4) + 1; - tsize = (surf->extents[1] >> 4) + 1; - - if (ssize > 256 || tsize > 256) - Host_Error("Bad surface extents"); - - if (surf->stainsamples) - memset(surf->stainsamples, 255, ssize * tsize * 3); - - surf->cached_dlight = true; + ssize = (surface->lightmapinfo->extents[0] >> 4) + 1; + tsize = (surface->lightmapinfo->extents[1] >> 4) + 1; + memset(surface->lightmapinfo->stainsamples, 255, ssize * tsize * 3); + surface->cached_dlight = true; } } } @@ -340,6 +306,7 @@ static model_t *Mod_LoadModel(model_t *mod, qboolean crash, qboolean checkdisk, else if (!memcmp(buf, "IDP2", 4)) Mod_IDP2_Load(mod, buf); else if (!memcmp(buf, "IDP3", 4)) Mod_IDP3_Load(mod, buf); else if (!memcmp(buf, "IDSP", 4)) Mod_IDSP_Load(mod, buf); + else if (!memcmp(buf, "IDS2", 4)) Mod_IDS2_Load(mod, buf); else if (!memcmp(buf, "IBSP", 4)) Mod_IBSP_Load(mod, buf); else if (!memcmp(buf, "ZYMOTICMODEL", 12)) Mod_ZYMOTICMODEL_Load(mod, buf); else if (strlen(mod->name) >= 4 && !strcmp(mod->name - 4, ".map")) Mod_MAP_Load(mod, buf); @@ -404,6 +371,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; @@ -777,6 +753,38 @@ void Mod_BuildTextureVectorsAndNormals(int numverts, int numtriangles, const flo VectorNormalize(v); } +surfmesh_t *Mod_AllocSurfMesh(mempool_t *mempool, int numvertices, int numtriangles, qboolean detailtexcoords, qboolean lightmapoffsets, qboolean vertexcolors, qboolean neighbors) +{ + surfmesh_t *mesh; + qbyte *data; + mesh = Mem_Alloc(mempool, sizeof(surfmesh_t) + numvertices * (3 + 3 + 3 + 3 + 2 + 2 + (detailtexcoords ? 2 : 0) + (vertexcolors ? 4 : 0)) * sizeof(float) + numvertices * (lightmapoffsets ? 1 : 0) * sizeof(int) + numtriangles * (3 + (neighbors ? 3 : 0)) * sizeof(int)); + mesh->num_vertices = numvertices; + mesh->num_triangles = numtriangles; + data = (qbyte *)(mesh + 1); + if (mesh->num_vertices) + { + mesh->data_vertex3f = (float *)data, data += sizeof(float[3]) * mesh->num_vertices; + mesh->data_svector3f = (float *)data, data += sizeof(float[3]) * mesh->num_vertices; + mesh->data_tvector3f = (float *)data, data += sizeof(float[3]) * mesh->num_vertices; + mesh->data_normal3f = (float *)data, data += sizeof(float[3]) * mesh->num_vertices; + mesh->data_texcoordtexture2f = (float *)data, data += sizeof(float[2]) * mesh->num_vertices; + mesh->data_texcoordlightmap2f = (float *)data, data += sizeof(float[2]) * mesh->num_vertices; + if (detailtexcoords) + mesh->data_texcoorddetail2f = (float *)data, data += sizeof(float[2]) * mesh->num_vertices; + if (vertexcolors) + mesh->data_lightmapcolor4f = (float *)data, data += sizeof(float[4]) * mesh->num_vertices; + if (lightmapoffsets) + mesh->data_lightmapoffsets = (int *)data, data += sizeof(int) * mesh->num_vertices; + } + if (mesh->num_triangles) + { + mesh->data_element3i = (int *)data, data += sizeof(int[3]) * mesh->num_triangles; + if (neighbors) + mesh->data_neighbor3i = (int *)data, data += sizeof(int[3]) * mesh->num_triangles; + } + return mesh; +} + shadowmesh_t *Mod_ShadowMesh_Alloc(mempool_t *mempool, int maxverts, int maxtriangles, rtexture_t *map_diffuse, rtexture_t *map_specular, rtexture_t *map_normal, int light, int neighbors, int expandable) { shadowmesh_t *newmesh;