From 2b008eecf18ff82581da5111de80891b6f7a351e Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 16 Apr 2006 11:38:37 +0000 Subject: [PATCH] no longer recalculated q3bsp surface normals, this makes q3map2 'phong shading' features work, no more seams on terrain and such git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6298 d7cf8633-e32d-0410-b094-e92efae38249 --- model_brush.c | 22 ++++++++++++++++------ model_shared.h | 3 ++- todo | 2 +- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/model_brush.c b/model_brush.c index 86c761f2..d8e5bdf8 100644 --- a/model_brush.c +++ b/model_brush.c @@ -4371,8 +4371,9 @@ static void Mod_Q3BSP_LoadVertices(lump_t *l) if (l->filelen % sizeof(*in)) Host_Error("Mod_Q3BSP_LoadVertices: funny lump size in %s",loadmodel->name); loadmodel->brushq3.num_vertices = count = l->filelen / sizeof(*in); - loadmodel->brushq3.data_vertex3f = (float *)Mem_Alloc(loadmodel->mempool, count * (sizeof(float) * (3 + 2 + 2 + 4))); - loadmodel->brushq3.data_texcoordtexture2f = loadmodel->brushq3.data_vertex3f + count * 3; + loadmodel->brushq3.data_vertex3f = (float *)Mem_Alloc(loadmodel->mempool, count * (sizeof(float) * (3 + 3 + 2 + 2 + 4))); + loadmodel->brushq3.data_normal3f = loadmodel->brushq3.data_vertex3f + count * 3; + loadmodel->brushq3.data_texcoordtexture2f = loadmodel->brushq3.data_normal3f + count * 3; loadmodel->brushq3.data_texcoordlightmap2f = loadmodel->brushq3.data_texcoordtexture2f + count * 2; loadmodel->brushq3.data_color4f = loadmodel->brushq3.data_texcoordlightmap2f + count * 2; @@ -4381,6 +4382,9 @@ static void Mod_Q3BSP_LoadVertices(lump_t *l) loadmodel->brushq3.data_vertex3f[i * 3 + 0] = LittleFloat(in->origin3f[0]); loadmodel->brushq3.data_vertex3f[i * 3 + 1] = LittleFloat(in->origin3f[1]); loadmodel->brushq3.data_vertex3f[i * 3 + 2] = LittleFloat(in->origin3f[2]); + loadmodel->brushq3.data_normal3f[i * 3 + 0] = LittleFloat(in->normal3f[0]); + loadmodel->brushq3.data_normal3f[i * 3 + 1] = LittleFloat(in->normal3f[1]); + loadmodel->brushq3.data_normal3f[i * 3 + 2] = LittleFloat(in->normal3f[2]); loadmodel->brushq3.data_texcoordtexture2f[i * 2 + 0] = LittleFloat(in->texcoord2f[0]); loadmodel->brushq3.data_texcoordtexture2f[i * 2 + 1] = LittleFloat(in->texcoord2f[1]); loadmodel->brushq3.data_texcoordlightmap2f[i * 2 + 0] = LittleFloat(in->lightmap2f[0]); @@ -4470,7 +4474,7 @@ static void Mod_Q3BSP_LoadFaces(lump_t *l) float *originalvertex3f; //float *originalsvector3f; //float *originaltvector3f; - //float *originalnormal3f; + float *originalnormal3f; float *originalcolor4f; float *originaltexcoordtexture2f; float *originaltexcoordlightmap2f; @@ -4661,6 +4665,9 @@ static void Mod_Q3BSP_LoadFaces(lump_t *l) (loadmodel->surfmesh.data_vertex3f + 3 * out->num_firstvertex)[j * 3 + 0] = loadmodel->brushq3.data_vertex3f[(firstvertex + j) * 3 + 0]; (loadmodel->surfmesh.data_vertex3f + 3 * out->num_firstvertex)[j * 3 + 1] = loadmodel->brushq3.data_vertex3f[(firstvertex + j) * 3 + 1]; (loadmodel->surfmesh.data_vertex3f + 3 * out->num_firstvertex)[j * 3 + 2] = loadmodel->brushq3.data_vertex3f[(firstvertex + j) * 3 + 2]; + (loadmodel->surfmesh.data_normal3f + 3 * out->num_firstvertex)[j * 3 + 0] = loadmodel->brushq3.data_normal3f[(firstvertex + j) * 3 + 0]; + (loadmodel->surfmesh.data_normal3f + 3 * out->num_firstvertex)[j * 3 + 1] = loadmodel->brushq3.data_normal3f[(firstvertex + j) * 3 + 1]; + (loadmodel->surfmesh.data_normal3f + 3 * out->num_firstvertex)[j * 3 + 2] = loadmodel->brushq3.data_normal3f[(firstvertex + j) * 3 + 2]; (loadmodel->surfmesh.data_texcoordtexture2f + 2 * out->num_firstvertex)[j * 2 + 0] = loadmodel->brushq3.data_texcoordtexture2f[(firstvertex + j) * 2 + 0]; (loadmodel->surfmesh.data_texcoordtexture2f + 2 * out->num_firstvertex)[j * 2 + 1] = loadmodel->brushq3.data_texcoordtexture2f[(firstvertex + j) * 2 + 1]; (loadmodel->surfmesh.data_texcoordlightmap2f + 2 * out->num_firstvertex)[j * 2 + 0] = loadmodel->brushq3.data_texcoordlightmap2f[(firstvertex + j) * 2 + 0]; @@ -4677,6 +4684,7 @@ static void Mod_Q3BSP_LoadFaces(lump_t *l) patchsize[0] = LittleLong(in->specific.patch.patchsize[0]); patchsize[1] = LittleLong(in->specific.patch.patchsize[1]); originalvertex3f = loadmodel->brushq3.data_vertex3f + firstvertex * 3; + originalnormal3f = loadmodel->brushq3.data_normal3f + firstvertex * 3; originaltexcoordtexture2f = loadmodel->brushq3.data_texcoordtexture2f + firstvertex * 2; originaltexcoordlightmap2f = loadmodel->brushq3.data_texcoordlightmap2f + firstvertex * 2; originalcolor4f = loadmodel->brushq3.data_color4f + firstvertex * 4; @@ -4705,6 +4713,7 @@ static void Mod_Q3BSP_LoadFaces(lump_t *l) // generate geometry // (note: normals are skipped because they get recalculated) Q3PatchTesselateFloat(3, sizeof(float[3]), (loadmodel->surfmesh.data_vertex3f + 3 * out->num_firstvertex), patchsize[0], patchsize[1], sizeof(float[3]), originalvertex3f, xtess, ytess); + Q3PatchTesselateFloat(3, sizeof(float[3]), (loadmodel->surfmesh.data_normal3f + 3 * out->num_firstvertex), patchsize[0], patchsize[1], sizeof(float[3]), originalnormal3f, xtess, ytess); Q3PatchTesselateFloat(2, sizeof(float[2]), (loadmodel->surfmesh.data_texcoordtexture2f + 2 * out->num_firstvertex), patchsize[0], patchsize[1], sizeof(float[2]), originaltexcoordtexture2f, xtess, ytess); Q3PatchTesselateFloat(2, sizeof(float[2]), (loadmodel->surfmesh.data_texcoordlightmap2f + 2 * out->num_firstvertex), patchsize[0], patchsize[1], sizeof(float[2]), originaltexcoordlightmap2f, xtess, ytess); Q3PatchTesselateFloat(4, sizeof(float[4]), (loadmodel->surfmesh.data_lightmapcolor4f + 4 * out->num_firstvertex), patchsize[0], patchsize[1], sizeof(float[4]), originalcolor4f, xtess, ytess); @@ -4775,9 +4784,6 @@ static void Mod_Q3BSP_LoadFaces(lump_t *l) } Con_Print("\n"); } - // for per pixel lighting - Mod_BuildNormals(out->num_firstvertex, out->num_vertices, out->num_triangles, loadmodel->surfmesh.data_vertex3f, (loadmodel->surfmesh.data_element3i + 3 * out->num_firsttriangle), loadmodel->surfmesh.data_normal3f, true); - Mod_BuildTextureVectorsFromNormals(out->num_firstvertex, out->num_vertices, out->num_triangles, loadmodel->surfmesh.data_vertex3f, loadmodel->surfmesh.data_texcoordtexture2f, loadmodel->surfmesh.data_normal3f, (loadmodel->surfmesh.data_element3i + 3 * out->num_firsttriangle), loadmodel->surfmesh.data_svector3f, loadmodel->surfmesh.data_tvector3f, true); // calculate a bounding box VectorClear(out->mins); VectorClear(out->maxs); @@ -4808,10 +4814,14 @@ static void Mod_Q3BSP_LoadFaces(lump_t *l) //out->lightmapinfo->styles[3] = 255; } + // for per pixel lighting + Mod_BuildTextureVectorsFromNormals(0, loadmodel->surfmesh.num_vertices, loadmodel->surfmesh.num_triangles, loadmodel->surfmesh.data_vertex3f, loadmodel->surfmesh.data_texcoordtexture2f, loadmodel->surfmesh.data_normal3f, loadmodel->surfmesh.data_element3i, loadmodel->surfmesh.data_svector3f, loadmodel->surfmesh.data_tvector3f, true); + // free the no longer needed vertex data loadmodel->brushq3.num_vertices = 0; Mem_Free(loadmodel->brushq3.data_vertex3f); loadmodel->brushq3.data_vertex3f = NULL; + loadmodel->brushq3.data_normal3f = NULL; loadmodel->brushq3.data_texcoordtexture2f = NULL; loadmodel->brushq3.data_texcoordlightmap2f = NULL; loadmodel->brushq3.data_color4f = NULL; diff --git a/model_shared.h b/model_shared.h index 94619937..bde7bf84 100644 --- a/model_shared.h +++ b/model_shared.h @@ -447,9 +447,10 @@ typedef struct model_brushq3_s int num_models; q3dmodel_t *data_models; - // freed after loading! + // used only during loading - freed after loading! int num_vertices; float *data_vertex3f; + float *data_normal3f; float *data_texcoordtexture2f; float *data_texcoordlightmap2f; float *data_color4f; diff --git a/todo b/todo index 5da50827..31c9008d 100644 --- a/todo +++ b/todo @@ -123,7 +123,7 @@ 0 feature darkplaces protocol: add DP_SENSITIVITYSCALE extension which scales sensitivity on client like viewzoom does, but without affecting fov, note if this is non-zero it overrides viewzoom sensitivity entirely, it does not scale it (Urre) 0 feature darkplaces protocol: add DP_TE_BUBBLES to make a burst of bubbles underwater (Supa, shadowalker) 0 feature darkplaces protocol: add DP_WEAPONSKIN extension which would add a .float weaponskin field (protoplasmatic, Kazashi) -0 feature darkplaces protocol: add EF_NOLERP effect for mods to use to prevent interpolation across teleports (Kinn) +0 feature darkplaces protocol: add EF_NOLERP effect for mods to use to prevent interpolation across teleports (Kinn, CuBe0wL) 0 feature darkplaces protocol: add TE_LASER effect with values Entity owner Vector start Vector end Byte palettecolor Byte startalpha Byte endalpha Byte beam width (in quake units) Byte lifetime (0-255 for 0-1 seconds), skin index (looking up a gfx/particles/beam%03i.tga), it fades from startalpha to endalpha over time (Wazat, Vermeulen) 0 feature darkplaces protocol: add a new TE_ explosion effect with RGB color choice for particle color and another choice for light color (VorteX) 0 feature darkplaces protocol: add an EF_BULLETTRACER trail effect which can be used to make an invisible entity into a tracer, a bright streak leaving a faint smoke trail (Carni) -- 2.39.2