]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
transform matrix is now separate from R_Mesh_State, a new function called R_Mesh_Matr...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 6 Sep 2002 11:48:47 +0000 (11:48 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 6 Sep 2002 11:48:47 +0000 (11:48 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2340 d7cf8633-e32d-0410-b094-e92efae38249

13 files changed:
cl_particles.c
gl_backend.c
gl_backend.h
gl_models.c
gl_rmain.c
gl_rsurf.c
makefile
r_crosshairs.c
r_explosion.c
r_light.c
r_sky.c
r_sprites.c
render.h

index 20bb95de09cabc38a7a4d90733f0a444a1c5efab..962f9cfa58ea44d6e5517b887dc22ff167dae2f0 100644 (file)
@@ -1202,7 +1202,7 @@ void R_DrawParticleCallback(const void *calldata1, int calldata2)
        else
                m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
        m.tex[0] = R_GetTexture(particlefonttexture);
        else
                m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
        m.tex[0] = R_GetTexture(particlefonttexture);
-       Matrix4x4_CreateIdentity(&m.matrix);
+       R_Mesh_Matrix(&r_identitymatrix);
        R_Mesh_State(&m);
 
        varray_element[0] = 0;
        R_Mesh_State(&m);
 
        varray_element[0] = 0;
index 8702cbf40eb0402d89fc797f61bdbc5048992087..b89fdaf962e3e11ba5ab243363babdc5dc94ad2d 100644 (file)
@@ -606,7 +606,7 @@ void GL_DrawRangeElements(int firstvert, int endvert, int indexcount, GLuint *in
                                qglColor4ub(c[0], c[1], c[2], c[3]);
                                if (gl_state.texture[0])
                                {
                                qglColor4ub(c[0], c[1], c[2], c[3]);
                                if (gl_state.texture[0])
                                {
-                                       v = varray_texcoord[j] + in * 2;
+                                       v = varray_texcoord[0] + in * 2;
                                        qglTexCoord2f(v[0], v[1]);
                                }
                                v = varray_vertex + in * 4;
                                        qglTexCoord2f(v[0], v[1]);
                                }
                                v = varray_vertex + in * 4;
@@ -712,6 +712,17 @@ void R_Mesh_ClearDepth(void)
        R_Mesh_Start(r_mesh_farclip);
 }
 
        R_Mesh_Start(r_mesh_farclip);
 }
 
+void R_Mesh_Matrix(const matrix4x4_t *matrix)
+{
+       if (memcmp(matrix, &backend_modelmatrix, sizeof(matrix4x4_t)))
+       {
+               backend_modelmatrix = *matrix;
+               Matrix4x4_Concat(&backend_modelviewmatrix, &backend_viewmatrix, matrix);
+               Matrix4x4_Transpose(&backend_glmodelviewmatrix, &backend_modelviewmatrix);
+               qglLoadMatrixf(&backend_glmodelviewmatrix.m[0][0]);
+       }
+}
+
 // sets up the requested state
 void R_Mesh_State(const rmeshstate_t *m)
 {
 // sets up the requested state
 void R_Mesh_State(const rmeshstate_t *m)
 {
@@ -727,15 +738,6 @@ void R_Mesh_State(const rmeshstate_t *m)
                GL_SetupTextureState();
        }
 
                GL_SetupTextureState();
        }
 
-       //backendmatrix = m->matrix; // this copies the struct
-       if (memcmp(&m->matrix, &backend_modelmatrix, sizeof(matrix4x4_t)))
-       {
-               backend_modelmatrix = m->matrix;
-               Matrix4x4_Concat(&backend_modelviewmatrix, &backend_viewmatrix, &m->matrix);
-               Matrix4x4_Transpose(&backend_glmodelviewmatrix, &backend_modelviewmatrix);
-               qglLoadMatrixf(&backend_glmodelviewmatrix.m[0][0]);
-       }
-
        overbright = false;
        scaler = 1;
        if (m->blendfunc1 == GL_DST_COLOR)
        overbright = false;
        scaler = 1;
        if (m->blendfunc1 == GL_DST_COLOR)
index 075d2bdf94f907660305eacc03819f19647e5c1e..1752635f6303a408d653855bc48a18efeed1d171 100644 (file)
@@ -16,7 +16,6 @@ typedef struct
        int wantoverbright;
        int tex[MAX_TEXTUREUNITS];
        int texrgbscale[MAX_TEXTUREUNITS]; // used only if COMBINE is present
        int wantoverbright;
        int tex[MAX_TEXTUREUNITS];
        int texrgbscale[MAX_TEXTUREUNITS]; // used only if COMBINE is present
-       matrix4x4_t matrix; // model to world transform matrix
 }
 rmeshstate_t;
 
 }
 rmeshstate_t;
 
@@ -43,6 +42,9 @@ void R_Mesh_Finish(void);
 // (only valid between R_Mesh_Start and R_Mesh_Finish)
 void R_Mesh_ClearDepth(void);
 
 // (only valid between R_Mesh_Start and R_Mesh_Finish)
 void R_Mesh_ClearDepth(void);
 
+// sets up the requested transform matrix
+void R_Mesh_Matrix(const matrix4x4_t *matrix);
+
 // sets up the requested state
 void R_Mesh_State(const rmeshstate_t *m);
 
 // sets up the requested state
 void R_Mesh_State(const rmeshstate_t *m);
 
index 76ad6458d3ca1374e13f42638434ddf2a34bde0c..38064f11425ccf43dd950384777f89f1e3190e2a 100644 (file)
@@ -251,6 +251,7 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
        int blendfunc1, blendfunc2;
 
 //     softwaretransformforentity(ent);
        int blendfunc1, blendfunc2;
 
 //     softwaretransformforentity(ent);
+       R_Mesh_Matrix(&ent->matrix);
 
        fog = 0;
        if (fogenabled)
 
        fog = 0;
        if (fogenabled)
@@ -298,7 +299,6 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                m.blendfunc2 = blendfunc2;
                m.wantoverbright = true;
                m.tex[0] = R_GetTexture(r_notexture);
                m.blendfunc2 = blendfunc2;
                m.wantoverbright = true;
                m.tex[0] = R_GetTexture(r_notexture);
-               m.matrix = ent->matrix;
                R_Mesh_State(&m);
 
                c_alias_polys += model->numtris;
                R_Mesh_State(&m);
 
                c_alias_polys += model->numtris;
@@ -324,7 +324,6 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                m.blendfunc2 = blendfunc2;
                m.wantoverbright = true;
                m.tex[0] = R_GetTexture(skinframe->merged);
                m.blendfunc2 = blendfunc2;
                m.wantoverbright = true;
                m.tex[0] = R_GetTexture(skinframe->merged);
-               m.matrix = ent->matrix;
                R_Mesh_State(&m);
 
                c_alias_polys += model->numtris;
                R_Mesh_State(&m);
 
                c_alias_polys += model->numtris;
@@ -363,7 +362,6 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
        m.blendfunc1 = blendfunc1;
        m.blendfunc2 = blendfunc2;
        m.wantoverbright = true;
        m.blendfunc1 = blendfunc1;
        m.blendfunc2 = blendfunc2;
        m.wantoverbright = true;
-       m.matrix = ent->matrix;
        m.tex[0] = colormapped ? R_GetTexture(skinframe->base) : R_GetTexture(skinframe->merged);
        if (m.tex[0])
        {
        m.tex[0] = colormapped ? R_GetTexture(skinframe->base) : R_GetTexture(skinframe->merged);
        if (m.tex[0])
        {
@@ -387,7 +385,6 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                        m.blendfunc1 = blendfunc1;
                        m.blendfunc2 = blendfunc2;
                        m.wantoverbright = true;
                        m.blendfunc1 = blendfunc1;
                        m.blendfunc2 = blendfunc2;
                        m.wantoverbright = true;
-                       m.matrix = ent->matrix;
                        m.tex[0] = R_GetTexture(skinframe->pants);
                        if (m.tex[0])
                        {
                        m.tex[0] = R_GetTexture(skinframe->pants);
                        if (m.tex[0])
                        {
@@ -412,7 +409,6 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                        m.blendfunc1 = blendfunc1;
                        m.blendfunc2 = blendfunc2;
                        m.wantoverbright = true;
                        m.blendfunc1 = blendfunc1;
                        m.blendfunc2 = blendfunc2;
                        m.wantoverbright = true;
-                       m.matrix = ent->matrix;
                        m.tex[0] = R_GetTexture(skinframe->shirt);
                        if (m.tex[0])
                        {
                        m.tex[0] = R_GetTexture(skinframe->shirt);
                        if (m.tex[0])
                        {
@@ -438,7 +434,6 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                m.blendfunc1 = blendfunc1;
                m.blendfunc2 = blendfunc2;
                m.wantoverbright = true;
                m.blendfunc1 = blendfunc1;
                m.blendfunc2 = blendfunc2;
                m.wantoverbright = true;
-               m.matrix = ent->matrix;
                m.tex[0] = R_GetTexture(skinframe->glow);
                if (m.tex[0])
                {
                m.tex[0] = R_GetTexture(skinframe->glow);
                if (m.tex[0])
                {
@@ -460,7 +455,6 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                m.blendfunc1 = GL_SRC_ALPHA;
                m.blendfunc2 = GL_ONE;
                m.wantoverbright = false;
                m.blendfunc1 = GL_SRC_ALPHA;
                m.blendfunc2 = GL_ONE;
                m.wantoverbright = false;
-               m.matrix = ent->matrix;
                m.tex[0] = R_GetTexture(skinframe->fog);
                R_Mesh_State(&m);
 
                m.tex[0] = R_GetTexture(skinframe->fog);
                R_Mesh_State(&m);
 
@@ -760,6 +754,8 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2)
        int shadernum = calldata2;
        int numverts, numtriangles;
 
        int shadernum = calldata2;
        int numverts, numtriangles;
 
+       R_Mesh_Matrix(&ent->matrix);
+
        // find the vertex index list and texture
        m = ent->model->zymdata_header;
        renderlist = (int *)(m->lump_render.start + (int) m);
        // find the vertex index list and texture
        m = ent->model->zymdata_header;
        renderlist = (int *)(m->lump_render.start + (int) m);
@@ -812,7 +808,6 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2)
                mstate.blendfunc2 = GL_ZERO;
        }
        mstate.tex[0] = R_GetTexture(texture);
                mstate.blendfunc2 = GL_ZERO;
        }
        mstate.tex[0] = R_GetTexture(texture);
-       mstate.matrix = ent->matrix;
        R_Mesh_State(&mstate);
 
        c_alias_polys += numtriangles;
        R_Mesh_State(&mstate);
 
        c_alias_polys += numtriangles;
@@ -830,7 +825,6 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2)
                mstate.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
                // FIXME: need alpha mask for fogging...
                //mstate.tex[0] = R_GetTexture(texture);
                mstate.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
                // FIXME: need alpha mask for fogging...
                //mstate.tex[0] = R_GetTexture(texture);
-               mstate.matrix = ent->matrix;
                R_Mesh_State(&mstate);
 
                c_alias_polys += numtriangles;
                R_Mesh_State(&mstate);
 
                c_alias_polys += numtriangles;
index de052f0f93ed9a8be8f2d0404e297f1177ec7b68..6a177423ad3b9a288deaf23069a50f4291096c5e 100644 (file)
@@ -26,6 +26,8 @@ int r_framecount;
 
 mplane_t frustum[4];
 
 
 mplane_t frustum[4];
 
+matrix4x4_t r_identitymatrix;
+
 int c_alias_polys, c_light_polys, c_faces, c_nodes, c_leafs, c_models, c_bmodels, c_sprites, c_particles, c_dlights;
 
 // true during envmap command capture
 int c_alias_polys, c_light_polys, c_faces, c_nodes, c_leafs, c_models, c_bmodels, c_sprites, c_particles, c_dlights;
 
 // true during envmap command capture
@@ -210,6 +212,7 @@ void gl_main_newmap(void)
 
 void GL_Main_Init(void)
 {
 
 void GL_Main_Init(void)
 {
+       Matrix4x4_CreateIdentity(&r_identitymatrix);
 // FIXME: move this to client?
        FOG_registercvars();
        Cmd_AddCommand ("timerefresh", R_TimeRefresh_f);
 // FIXME: move this to client?
        FOG_registercvars();
        Cmd_AddCommand ("timerefresh", R_TimeRefresh_f);
@@ -511,7 +514,7 @@ static void R_BlendView(void)
        m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
        m.wantoverbright = false;
        m.depthdisable = true; // magic
        m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
        m.wantoverbright = false;
        m.depthdisable = true; // magic
-       Matrix4x4_CreateIdentity(&m.matrix);
+       R_Mesh_Matrix(&r_identitymatrix);
        R_Mesh_State(&m);
 
        varray_element[0] = 0;
        R_Mesh_State(&m);
 
        varray_element[0] = 0;
@@ -617,7 +620,7 @@ void R_DrawBBoxMesh(vec3_t mins, vec3_t maxs, float cr, float cg, float cb, floa
        m.blendfunc1 = GL_SRC_ALPHA;
        m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
        m.wantoverbright = false;
        m.blendfunc1 = GL_SRC_ALPHA;
        m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
        m.wantoverbright = false;
-       Matrix4x4_CreateIdentity(&m.matrix);
+       R_Mesh_Matrix(&r_identitymatrix);
        R_Mesh_State(&m);
 
        varray_element
        R_Mesh_State(&m);
 
        varray_element
@@ -673,7 +676,7 @@ void R_DrawNoModelCallback(const void *calldata1, int calldata2)
                m.blendfunc2 = GL_ZERO;
        }
        m.wantoverbright = false;
                m.blendfunc2 = GL_ZERO;
        }
        m.wantoverbright = false;
-       m.matrix = ent->matrix;
+       R_Mesh_Matrix(&ent->matrix);
        R_Mesh_State(&m);
 
        varray_element[ 0] = 5;varray_element[ 1] = 2;varray_element[ 2] = 0;
        R_Mesh_State(&m);
 
        varray_element[ 0] = 5;varray_element[ 1] = 2;varray_element[ 2] = 0;
index 4ea06b40315f2791dd1c2d07f73a6cfde3f0929b..d1c0c38d6a51a5554d6aeae22071fe0467c9caac 100644 (file)
@@ -801,6 +801,8 @@ static void RSurfShader_Sky(const entity_render_t *ent, const msurface_t *firsts
                        R_Sky();
        }
 
                        R_Sky();
        }
 
+       R_Mesh_Matrix(&ent->matrix);
+
        // draw depth-only polys
        memset(&m, 0, sizeof(m));
        if (skyrendermasked)
        // draw depth-only polys
        memset(&m, 0, sizeof(m));
        if (skyrendermasked)
@@ -816,7 +818,6 @@ static void RSurfShader_Sky(const entity_render_t *ent, const msurface_t *firsts
        }
        m.wantoverbright = false;
        m.depthwrite = true;
        }
        m.wantoverbright = false;
        m.depthwrite = true;
-       m.matrix = ent->matrix;
        R_Mesh_State(&m);
        for (surf = firstsurf;surf;surf = surf->chain)
        {
        R_Mesh_State(&m);
        for (surf = firstsurf;surf;surf = surf->chain)
        {
@@ -845,6 +846,8 @@ static void RSurfShader_Water_Callback(const void *calldata1, int calldata2)
        float modelorg[3];
        Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
 
        float modelorg[3];
        Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
 
+       R_Mesh_Matrix(&ent->matrix);
+
        memset(&m, 0, sizeof(m));
        if (ent->effects & EF_ADDITIVE)
        {
        memset(&m, 0, sizeof(m));
        if (ent->effects & EF_ADDITIVE)
        {
@@ -863,7 +866,6 @@ static void RSurfShader_Water_Callback(const void *calldata1, int calldata2)
        }
        m.wantoverbright = true;
        m.tex[0] = R_GetTexture(surf->currenttexture->texture);
        }
        m.wantoverbright = true;
        m.tex[0] = R_GetTexture(surf->currenttexture->texture);
-       m.matrix = ent->matrix;
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
@@ -891,7 +893,6 @@ static void RSurfShader_Water_Callback(const void *calldata1, int calldata2)
                m.blendfunc2 = GL_ONE;
                m.wantoverbright = false;
                m.tex[0] = R_GetTexture(surf->currenttexture->fogtexture);
                m.blendfunc2 = GL_ONE;
                m.wantoverbright = false;
                m.tex[0] = R_GetTexture(surf->currenttexture->fogtexture);
-               m.matrix = ent->matrix;
                R_Mesh_State(&m);
                for (mesh = surf->mesh;mesh;mesh = mesh->chain)
                {
                R_Mesh_State(&m);
                for (mesh = surf->mesh;mesh;mesh = mesh->chain)
                {
@@ -918,7 +919,7 @@ static void RSurfShader_Water(const entity_render_t *ent, const msurface_t *firs
                        R_MeshQueue_AddTransparent(center, RSurfShader_Water_Callback, ent, surf - ent->model->surfaces);
                }
                else
                        R_MeshQueue_AddTransparent(center, RSurfShader_Water_Callback, ent, surf - ent->model->surfaces);
                }
                else
-                       R_MeshQueue_Add(RSurfShader_Water_Callback, ent, surf - ent->model->surfaces);
+                       RSurfShader_Water_Callback(ent, surf - ent->model->surfaces);
        }
 }
 
        }
 }
 
@@ -948,7 +949,6 @@ static void RSurfShader_Wall_Pass_BaseVertex(const entity_render_t *ent, const m
        m.wantoverbright = true;
        m.tex[0] = R_GetTexture(surf->currenttexture->texture);
        base = ent->effects & EF_FULLBRIGHT ? 2.0f : r_ambient.value * (1.0f / 64.0f);
        m.wantoverbright = true;
        m.tex[0] = R_GetTexture(surf->currenttexture->texture);
        base = ent->effects & EF_FULLBRIGHT ? 2.0f : r_ambient.value * (1.0f / 64.0f);
-       m.matrix = ent->matrix;
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
@@ -993,7 +993,6 @@ static void RSurfShader_Wall_Pass_BaseFullbright(const entity_render_t *ent, con
        }
        m.wantoverbright = false;
        m.tex[0] = R_GetTexture(surf->currenttexture->texture);
        }
        m.wantoverbright = false;
        m.tex[0] = R_GetTexture(surf->currenttexture->texture);
-       m.matrix = ent->matrix;
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
@@ -1017,7 +1016,6 @@ static void RSurfShader_Wall_Pass_Glow(const entity_render_t *ent, const msurfac
        m.blendfunc2 = GL_ONE;
        m.wantoverbright = false;
        m.tex[0] = R_GetTexture(surf->currenttexture->glowtexture);
        m.blendfunc2 = GL_ONE;
        m.wantoverbright = false;
        m.tex[0] = R_GetTexture(surf->currenttexture->glowtexture);
-       m.matrix = ent->matrix;
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
@@ -1040,7 +1038,6 @@ static void RSurfShader_Wall_Pass_Fog(const entity_render_t *ent, const msurface
        m.blendfunc1 = GL_SRC_ALPHA;
        m.blendfunc2 = GL_ONE;
        m.wantoverbright = false;
        m.blendfunc1 = GL_SRC_ALPHA;
        m.blendfunc2 = GL_ONE;
        m.wantoverbright = false;
-       m.matrix = ent->matrix;
        m.tex[0] = R_GetTexture(surf->currenttexture->fogtexture);
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        m.tex[0] = R_GetTexture(surf->currenttexture->fogtexture);
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
@@ -1070,7 +1067,6 @@ static void RSurfShader_OpaqueWall_Pass_TripleTexCombine(const entity_render_t *
        m.texrgbscale[1] = 4.0f;
        m.tex[2] = R_GetTexture(surf->currenttexture->detailtexture);
        m.texrgbscale[2] = 2.0f;
        m.texrgbscale[1] = 4.0f;
        m.tex[2] = R_GetTexture(surf->currenttexture->detailtexture);
        m.texrgbscale[2] = 2.0f;
-       m.matrix = ent->matrix;
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
@@ -1097,7 +1093,6 @@ static void RSurfShader_OpaqueWall_Pass_BaseMTex(const entity_render_t *ent, con
        m.wantoverbright = true;
        m.tex[0] = R_GetTexture(surf->currenttexture->texture);
        m.tex[1] = R_GetTexture(surf->lightmaptexture);
        m.wantoverbright = true;
        m.tex[0] = R_GetTexture(surf->currenttexture->texture);
        m.tex[1] = R_GetTexture(surf->lightmaptexture);
-       m.matrix = ent->matrix;
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
@@ -1122,7 +1117,6 @@ static void RSurfShader_OpaqueWall_Pass_BaseTexture(const entity_render_t *ent,
        m.blendfunc2 = GL_ZERO;
        m.wantoverbright = false;
        m.tex[0] = R_GetTexture(surf->currenttexture->texture);
        m.blendfunc2 = GL_ZERO;
        m.wantoverbright = false;
        m.tex[0] = R_GetTexture(surf->currenttexture->texture);
-       m.matrix = ent->matrix;
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
@@ -1146,7 +1140,6 @@ static void RSurfShader_OpaqueWall_Pass_BaseLightmap(const entity_render_t *ent,
        m.blendfunc2 = GL_SRC_COLOR;
        m.wantoverbright = true;
        m.tex[0] = R_GetTexture(surf->lightmaptexture);
        m.blendfunc2 = GL_SRC_COLOR;
        m.wantoverbright = true;
        m.tex[0] = R_GetTexture(surf->lightmaptexture);
-       m.matrix = ent->matrix;
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
@@ -1175,7 +1168,6 @@ static void RSurfShader_OpaqueWall_Pass_Light(const entity_render_t *ent, const
        m.blendfunc2 = GL_ONE;
        m.wantoverbright = true;
        m.tex[0] = R_GetTexture(surf->currenttexture->texture);
        m.blendfunc2 = GL_ONE;
        m.wantoverbright = true;
        m.tex[0] = R_GetTexture(surf->currenttexture->texture);
-       m.matrix = ent->matrix;
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
@@ -1204,7 +1196,6 @@ static void RSurfShader_OpaqueWall_Pass_Fog(const entity_render_t *ent, const ms
        m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
        m.wantoverbright = false;
        m.tex[0] = R_GetTexture(surf->currenttexture->fogtexture);
        m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
        m.wantoverbright = false;
        m.tex[0] = R_GetTexture(surf->currenttexture->fogtexture);
-       m.matrix = ent->matrix;
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
@@ -1227,7 +1218,6 @@ static void RSurfShader_OpaqueWall_Pass_BaseDetail(const entity_render_t *ent, c
        m.blendfunc2 = GL_SRC_COLOR;
        m.wantoverbright = false;
        m.tex[0] = R_GetTexture(surf->currenttexture->detailtexture);
        m.blendfunc2 = GL_SRC_COLOR;
        m.wantoverbright = false;
        m.tex[0] = R_GetTexture(surf->currenttexture->detailtexture);
-       m.matrix = ent->matrix;
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
@@ -1249,7 +1239,6 @@ static void RSurfShader_OpaqueWall_Pass_Glow(const entity_render_t *ent, const m
        m.blendfunc2 = GL_ONE;
        m.wantoverbright = false;
        m.tex[0] = R_GetTexture(surf->currenttexture->glowtexture);
        m.blendfunc2 = GL_ONE;
        m.wantoverbright = false;
        m.tex[0] = R_GetTexture(surf->currenttexture->glowtexture);
-       m.matrix = ent->matrix;
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
        R_Mesh_State(&m);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
@@ -1266,6 +1255,7 @@ static void RSurfShader_Wall_Fullbright_Callback(const void *calldata1, int call
 {
        const entity_render_t *ent = calldata1;
        const msurface_t *surf = ent->model->surfaces + calldata2;
 {
        const entity_render_t *ent = calldata1;
        const msurface_t *surf = ent->model->surfaces + calldata2;
+       R_Mesh_Matrix(&ent->matrix);
        RSurfShader_Wall_Pass_BaseFullbright(ent, surf);
        if (surf->currenttexture->glowtexture)
                RSurfShader_Wall_Pass_Glow(ent, surf);
        RSurfShader_Wall_Pass_BaseFullbright(ent, surf);
        if (surf->currenttexture->glowtexture)
                RSurfShader_Wall_Pass_Glow(ent, surf);
@@ -1312,6 +1302,7 @@ static void RSurfShader_Wall_Vertex_Callback(const void *calldata1, int calldata
 {
        const entity_render_t *ent = calldata1;
        const msurface_t *surf = ent->model->surfaces + calldata2;
 {
        const entity_render_t *ent = calldata1;
        const msurface_t *surf = ent->model->surfaces + calldata2;
+       R_Mesh_Matrix(&ent->matrix);
        RSurfShader_Wall_Pass_BaseVertex(ent, surf);
        if (surf->currenttexture->glowtexture)
                RSurfShader_Wall_Pass_Glow(ent, surf);
        RSurfShader_Wall_Pass_BaseVertex(ent, surf);
        if (surf->currenttexture->glowtexture)
                RSurfShader_Wall_Pass_Glow(ent, surf);
@@ -1486,6 +1477,8 @@ void R_DrawSurfaces(entity_render_t *ent, int sky, int normal)
        if (!ent->model)
                return;
 
        if (!ent->model)
                return;
 
+       R_Mesh_Matrix(&ent->matrix);
+
        for (i = 0;i < Cshader_count;i++)
                Cshaders[i]->chain = NULL;
 
        for (i = 0;i < Cshader_count;i++)
                Cshaders[i]->chain = NULL;
 
@@ -1595,7 +1588,7 @@ static void R_DrawPortal_Callback(const void *calldata1, int calldata2)
        m.blendfunc1 = GL_SRC_ALPHA;
        m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
        m.wantoverbright = false;
        m.blendfunc1 = GL_SRC_ALPHA;
        m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
        m.wantoverbright = false;
-       m.matrix = ent->matrix;
+       R_Mesh_Matrix(&ent->matrix);
        R_Mesh_State(&m);
        R_Mesh_ResizeCheck(portal->numpoints, portal->numpoints - 2);
        for (i = 0;i < mesh->numtriangles;i++)
        R_Mesh_State(&m);
        R_Mesh_ResizeCheck(portal->numpoints, portal->numpoints - 2);
        for (i = 0;i < mesh->numtriangles;i++)
index ec3105c2766eaf735a2cbb09f1487f16e6176242..fff672e45fb2990f6a1881991216f76c63979afc 100644 (file)
--- a/makefile
+++ b/makefile
@@ -50,11 +50,11 @@ NOPROFILEOPTIMIZATIONS=
 #this is used to ensure that all released versions are free of warnings.
 
 #normal compile
 #this is used to ensure that all released versions are free of warnings.
 
 #normal compile
-#OPTIMIZATIONS= -O6 -fno-strict-aliasing -ffast-math -funroll-loops $(NOPROFILEOPTIMIZATIONS) -fexpensive-optimizations $(CPUOPTIMIZATIONS)
-#CFLAGS= -MD -Wall -Werror -I/usr/X11R6/include $(OPTIMIZATIONS) $(PROFILEOPTION)
+OPTIMIZATIONS= -O6 -fno-strict-aliasing -ffast-math -funroll-loops $(NOPROFILEOPTIMIZATIONS) -fexpensive-optimizations $(CPUOPTIMIZATIONS)
+CFLAGS= -MD -Wall -Werror -I/usr/X11R6/include $(OPTIMIZATIONS) $(PROFILEOPTION)
 #debug compile
 #debug compile
-OPTIMIZATIONS=
-CFLAGS= -MD -Wall -Werror -I/usr/X11R6/include -ggdb $(OPTIMIZATIONS) $(PROFILEOPTION)
+#OPTIMIZATIONS=
+#CFLAGS= -MD -Wall -Werror -I/usr/X11R6/include -ggdb $(OPTIMIZATIONS) $(PROFILEOPTION)
 
 LDFLAGS= -L/usr/X11R6/lib -lm -lX11 -lXext -lXxf86dga -lXxf86vm -ldl $(SOUNDLIB) $(PROFILEOPTION)
 
 
 LDFLAGS= -L/usr/X11R6/lib -lm -lX11 -lXext -lXxf86dga -lXxf86vm -ldl $(SOUNDLIB) $(PROFILEOPTION)
 
index d287070122cc4c6673f6acd9ac4ee0d6b3f1d008..6e141754ff4426fec1135824d4f0ad931b89792a 100644 (file)
@@ -171,7 +171,7 @@ void R_DrawCrosshairSprite(rtexture_t *texture, vec3_t origin, vec_t scale, floa
        m.wantoverbright = false;
        m.depthdisable = true;
        m.tex[0] = R_GetTexture(texture);
        m.wantoverbright = false;
        m.depthdisable = true;
        m.tex[0] = R_GetTexture(texture);
-       Matrix4x4_CreateIdentity(&m.matrix);
+       R_Mesh_Matrix(&r_identitymatrix);
        R_Mesh_State(&m);
 
        varray_element[0] = 0;
        R_Mesh_State(&m);
 
        varray_element[0] = 0;
index d8151188201fec866041d2821f56cfe90b8f2fc3..15212ccd97a02709f28c224c4d3b545633233cf2 100644 (file)
@@ -186,7 +186,7 @@ void R_DrawExplosionCallback(const void *calldata1, int calldata2)
        m.blendfunc2 = GL_ONE;
        m.wantoverbright = false;
        m.tex[0] = R_GetTexture(explosiontexture);
        m.blendfunc2 = GL_ONE;
        m.wantoverbright = false;
        m.tex[0] = R_GetTexture(explosiontexture);
-       Matrix4x4_CreateIdentity(&m.matrix);
+       R_Mesh_Matrix(&r_identitymatrix);
        R_Mesh_State(&m);
 
        numtriangles = EXPLOSIONTRIS;
        R_Mesh_State(&m);
 
        numtriangles = EXPLOSIONTRIS;
index 11b4619b2d39653017e23da8835349d46f8a628e..57b9cc689609667c969b1484bb95707894032029 100644 (file)
--- a/r_light.c
+++ b/r_light.c
@@ -151,7 +151,7 @@ void R_DrawCoronas(void)
        m.wantoverbright = false;
        m.depthdisable = true; // magic
        m.tex[0] = R_GetTexture(lightcorona);
        m.wantoverbright = false;
        m.depthdisable = true; // magic
        m.tex[0] = R_GetTexture(lightcorona);
-       Matrix4x4_CreateIdentity(&m.matrix);
+       R_Mesh_Matrix(&r_identitymatrix);
        R_Mesh_State(&m);
        viewdist = DotProduct(r_origin, vpn);
        for (i = 0;i < r_numdlights;i++)
        R_Mesh_State(&m);
        viewdist = DotProduct(r_origin, vpn);
        for (i = 0;i < r_numdlights;i++)
diff --git a/r_sky.c b/r_sky.c
index d971edefbaa46451a95ca7076ad0d1b4d595f11c..367428c4664d3af6330532007c878775407a0550 100644 (file)
--- a/r_sky.c
+++ b/r_sky.c
@@ -134,7 +134,6 @@ static void R_SkyBox(void)
        m.wantoverbright = false;
        m.depthdisable = true; // don't modify or read zbuffer
        m.tex[0] = R_GetTexture(skyboxside[3]); // front
        m.wantoverbright = false;
        m.depthdisable = true; // don't modify or read zbuffer
        m.tex[0] = R_GetTexture(skyboxside[3]); // front
-       Matrix4x4_CreateTranslate(&m.matrix, r_origin[0], r_origin[1], r_origin[2]);
        R_Mesh_State(&m);
 
        memcpy(varray_element, skyboxindex, sizeof(int[6]));
        R_Mesh_State(&m);
 
        memcpy(varray_element, skyboxindex, sizeof(int[6]));
@@ -304,7 +303,6 @@ static void R_SkySphere(void)
        m.wantoverbright = false;
        m.depthdisable = true; // don't modify or read zbuffer
        m.tex[0] = R_GetTexture(solidskytexture);
        m.wantoverbright = false;
        m.depthdisable = true; // don't modify or read zbuffer
        m.tex[0] = R_GetTexture(solidskytexture);
-       Matrix4x4_CreateTranslate(&m.matrix, r_origin[0], r_origin[1], r_origin[2]);
        R_Mesh_State(&m);
 
        memcpy(varray_element, skysphereindices, numtriangles * sizeof(int[3]));
        R_Mesh_State(&m);
 
        memcpy(varray_element, skysphereindices, numtriangles * sizeof(int[3]));
@@ -323,8 +321,11 @@ static void R_SkySphere(void)
 
 void R_Sky(void)
 {
 
 void R_Sky(void)
 {
+       matrix4x4_t skymatrix;
        if (skyrendermasked)
        {
        if (skyrendermasked)
        {
+               Matrix4x4_CreateTranslate(&skymatrix, r_origin[0], r_origin[1], r_origin[2]);
+               R_Mesh_Matrix(&skymatrix);
                if (skyrendersphere)
                {
                        // this does not modify depth buffer
                if (skyrendersphere)
                {
                        // this does not modify depth buffer
index 168c4cfd8d3a0dace7a4cb693ab1066725cb1b1d..577102632daff86deb88d3d202a1fcf72e99766f 100644 (file)
@@ -88,7 +88,6 @@ static void R_DrawSpriteImage (int wantoverbright, int additive, mspriteframe_t
                m.blendfunc2 = GL_ONE;
        m.wantoverbright = wantoverbright;
        m.tex[0] = texture;
                m.blendfunc2 = GL_ONE;
        m.wantoverbright = wantoverbright;
        m.tex[0] = texture;
-       Matrix4x4_CreateIdentity(&m.matrix);
        R_Mesh_State(&m);
 
        varray_element[0] = 0;
        R_Mesh_State(&m);
 
        varray_element[0] = 0;
@@ -137,6 +136,8 @@ void R_DrawSpriteModelCallback(const void *calldata1, int calldata2)
        if (R_SpriteSetup(ent, ent->model->sprnum_type, org, left, up))
                return;
 
        if (R_SpriteSetup(ent, ent->model->sprnum_type, org, left, up))
                return;
 
+       R_Mesh_Matrix(&r_identitymatrix);
+
        if ((ent->model->flags & EF_FULLBRIGHT) || (ent->effects & EF_FULLBRIGHT))
        {
                color[0] = color[1] = color[2] = 1;
        if ((ent->model->flags & EF_FULLBRIGHT) || (ent->effects & EF_FULLBRIGHT))
        {
                color[0] = color[1] = color[2] = 1;
index 7aa31b7af4218fb0bcdf2778d74c8d8db44d832c..b4e7c3a32a5ac5dba0d742420fa73527a4ce7daf 100644 (file)
--- a/render.h
+++ b/render.h
@@ -21,6 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #ifndef RENDER_H
 #define RENDER_H
 
 #ifndef RENDER_H
 #define RENDER_H
 
+extern matrix4x4_t r_identitymatrix;
+
 // 1.0f / N table
 extern float ixtable[4096];
 
 // 1.0f / N table
 extern float ixtable[4096];