eliminated calls to Matrix4x4_CreateIdentity (now copies from the already existing...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 4 Mar 2006 10:47:37 +0000 (10:47 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 4 Mar 2006 10:47:37 +0000 (10:47 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6059 d7cf8633-e32d-0410-b094-e92efae38249

18 files changed:
cl_main.c
cl_particles.c
clvm_cmds.c
collision.c
gl_backend.c
gl_draw.c
gl_rmain.c
gl_rsurf.c
model_alias.c
model_brush.c
model_shared.c
r_explosion.c
r_light.c
r_lightning.c
r_sprites.c
render.h
svvm_cmds.c
view.c

index 9a651db..0ef8768 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -1240,8 +1240,8 @@ void CL_RelinkWorld(void)
        entity_t *ent = &cl_entities[0];
        cl_brushmodel_entities[cl_num_brushmodel_entities++] = 0;
        // FIXME: this should be done at load
-       Matrix4x4_CreateIdentity(&ent->render.matrix);
-       Matrix4x4_CreateIdentity(&ent->render.inversematrix);
+       ent->render.matrix = identitymatrix;
+       ent->render.inversematrix = identitymatrix;
        R_LerpAnimation(&ent->render);
        CL_BoundingBoxForEntity(&ent->render);
        ent->render.flags = RENDER_SHADOW;
@@ -1259,8 +1259,8 @@ void CL_RelinkCSQCWorld(void)     //[515]: csqc
                return;
 //     cl_brushmodel_entities[cl_num_brushmodel_entities++] = 0;
        // FIXME: this should be done at load
-       Matrix4x4_CreateIdentity(&ent->render.matrix);
-       Matrix4x4_CreateIdentity(&ent->render.inversematrix);
+       ent->render.matrix = identitymatrix;
+       ent->render.inversematrix = identitymatrix;
        R_LerpAnimation(&ent->render);
        CL_BoundingBoxForEntity(&ent->render);
        ent->render.flags = RENDER_SHADOW;
@@ -1625,7 +1625,7 @@ int CL_ReadFromServer(void)
        r_refdef.time = cl.time;
        r_refdef.extraupdate = !r_speeds.integer;
        r_refdef.numentities = 0;
-       Matrix4x4_CreateIdentity(&r_refdef.viewentitymatrix);
+       r_refdef.viewentitymatrix = identitymatrix;
        cl_num_brushmodel_entities = 0;
 
        if (cls.state == ca_connected && cls.signon == SIGNONS)
index a7ea214..94e6e58 100644 (file)
@@ -2119,7 +2119,7 @@ void R_DrawParticle_TransparentCallback(const entity_render_t *ent, int surfacen
                }
        }
 
-       R_Mesh_Matrix(&r_identitymatrix);
+       R_Mesh_Matrix(&identitymatrix);
 
        memset(&m, 0, sizeof(m));
        m.tex[0] = R_GetTexture(tex->texture);
index e828cdc..a588189 100644 (file)
@@ -800,8 +800,8 @@ static const int particleeffects_num = sizeof(particleeffect_names)/sizeof(char*
 static void CSQC_R_RecalcView (void)
 {
        extern matrix4x4_t viewmodelmatrix;
-       Matrix4x4_CreateIdentity(&viewmodelmatrix);
-       Matrix4x4_CreateIdentity(&r_refdef.viewentitymatrix);
+       viewmodelmatrix = identitymatrix;
+       r_refdef.viewentitymatrix = identitymatrix;
        Matrix4x4_CreateFromQuakeEntity(&r_refdef.viewentitymatrix, csqc_origin[0], csqc_origin[1], csqc_origin[2], csqc_angles[0], csqc_angles[1], csqc_angles[2], 1);
        Matrix4x4_CreateFromQuakeEntity(&viewmodelmatrix, csqc_origin[0], csqc_origin[1], csqc_origin[2], csqc_angles[0], csqc_angles[1], csqc_angles[2], 0.3);
 }
@@ -2248,7 +2248,7 @@ int CL_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
        prvm_edict_t *attachent;
        model_t *model;
 
-       Matrix4x4_CreateIdentity(out); // warnings and errors return identical matrix
+       out = identitymatrix; // warnings and errors return identical matrix
 
        if (ent == prog->edicts)
                return 1;
@@ -2285,7 +2285,7 @@ int CL_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
                        return ret;
        }
        else
-               Matrix4x4_CreateIdentity(&tagmatrix);
+               tagmatrix = identitymatrix;
 
        if ((val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_tag_entity)) && val->edict)
        { // DP_GFX_QUAKE3MODELTAGS, scan all chain and stop on unattached entity
@@ -2310,7 +2310,7 @@ int CL_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
                        if (model && val->_float >= 1 && model->animscenes && attachent->fields.client->frame >= 0 && attachent->fields.client->frame < model->numframes)
                                Mod_Alias_GetTagMatrix(model, model->animscenes[(int)attachent->fields.client->frame].firstframe, val->_float - 1, &attachmatrix);
                        else
-                               Matrix4x4_CreateIdentity(&attachmatrix);
+                               attachmatrix = identitymatrix;
 
                        // apply transformation by child entity matrix
                        val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_scale);
index 225caab..02ccb46 100644 (file)
@@ -1035,7 +1035,6 @@ colbrushf_t *Collision_BrushForBox(const matrix4x4_t *matrix, const vec3_t mins,
 void Collision_ClipTrace_BrushBox(trace_t *trace, const vec3_t cmins, const vec3_t cmaxs, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int hitsupercontentsmask)
 {
        colbrushf_t *boxbrush, *thisbrush_start, *thisbrush_end;
-       matrix4x4_t identitymatrix;
        vec3_t startmins, startmaxs, endmins, endmaxs;
 
        // create brushes for the collision
@@ -1043,7 +1042,6 @@ void Collision_ClipTrace_BrushBox(trace_t *trace, const vec3_t cmins, const vec3
        VectorAdd(start, maxs, startmaxs);
        VectorAdd(end, mins, endmins);
        VectorAdd(end, maxs, endmaxs);
-       Matrix4x4_CreateIdentity(&identitymatrix);
        boxbrush = Collision_BrushForBox(&identitymatrix, cmins, cmaxs);
        thisbrush_start = Collision_BrushForBox(&identitymatrix, startmins, startmaxs);
        thisbrush_end = Collision_BrushForBox(&identitymatrix, endmins, endmaxs);
index 439ec64..5d63a28 100644 (file)
@@ -256,7 +256,7 @@ void gl_backend_init(void)
 
 void GL_SetupView_Orientation_Identity (void)
 {
-       Matrix4x4_CreateIdentity(&backend_viewmatrix);
+       backend_viewmatrix = identitymatrix;
        memset(&backend_modelmatrix, 0, sizeof(backend_modelmatrix));
 }
 
@@ -445,7 +445,7 @@ void GL_SetupTextureState(void)
                unit->combinergb = GL_MODULATE;
                unit->combinealpha = GL_MODULATE;
                unit->texmatrixenabled = false;
-               unit->matrix = r_identitymatrix;
+               unit->matrix = identitymatrix;
        }
 
        for (i = 0;i < backendimageunits;i++)
@@ -1845,7 +1845,7 @@ void SCR_UpdateLoadingScreen (void)
        R_Textures_Frame();
        GL_SetupView_Mode_Ortho(0, 0, vid_conwidth.integer, vid_conheight.integer, -10, 100);
        R_Mesh_Start();
-       R_Mesh_Matrix(&r_identitymatrix);
+       R_Mesh_Matrix(&identitymatrix);
        // draw the loading plaque
        pic = Draw_CachePic("gfx/loading", false);
        x = (vid_conwidth.integer - pic->width)/2;
index aecd321..b908a24 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -536,7 +536,7 @@ void R_DrawQueue(void)
        qglViewport(r_view_x, vid.height - (r_view_y + r_view_height), r_view_width, r_view_height);
        GL_SetupView_Mode_Ortho(0, 0, vid_conwidth.integer, vid_conheight.integer, -10, 100);
        qglDepthFunc(GL_LEQUAL);
-       R_Mesh_Matrix(&r_identitymatrix);
+       R_Mesh_Matrix(&identitymatrix);
 
        chartexnum = R_GetTexture(char_texture);
 
index 3e6c5d6..e22cf40 100644 (file)
@@ -28,7 +28,7 @@ int r_framecount;
 
 mplane_t frustum[5];
 
-matrix4x4_t r_identitymatrix;
+matrix4x4_t identitymatrix;
 
 renderstats_t renderstats;
 
@@ -450,7 +450,6 @@ void gl_main_newmap(void)
 
 void GL_Main_Init(void)
 {
-       Matrix4x4_CreateIdentity(&r_identitymatrix);
 // FIXME: move this to client?
        FOG_registercvars();
        Cvar_RegisterVariable(&r_showtris);
@@ -862,7 +861,7 @@ static void R_BlendView(void)
        GL_SetupView_Mode_Ortho(0, 0, 1, 1, -10, 100);
        GL_DepthMask(true);
        GL_DepthTest(false);
-       R_Mesh_Matrix(&r_identitymatrix);
+       R_Mesh_Matrix(&identitymatrix);
        // vertex coordinates for a quad that covers the screen exactly
        varray_vertex3f[0] = 0;varray_vertex3f[1] = 0;varray_vertex3f[2] = 0;
        varray_vertex3f[3] = 1;varray_vertex3f[4] = 0;varray_vertex3f[5] = 0;
@@ -1333,7 +1332,7 @@ void R_DrawBBoxMesh(vec3_t mins, vec3_t maxs, float cr, float cg, float cb, floa
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        GL_DepthMask(false);
        GL_DepthTest(true);
-       R_Mesh_Matrix(&r_identitymatrix);
+       R_Mesh_Matrix(&identitymatrix);
 
        vertex3f[ 0] = mins[0];vertex3f[ 1] = mins[1];vertex3f[ 2] = mins[2];
        vertex3f[ 3] = maxs[0];vertex3f[ 4] = mins[1];vertex3f[ 5] = mins[2];
@@ -1498,7 +1497,7 @@ void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, rtexture_
                fog = VERTEXFOGTABLE(VectorDistance(origin, r_vieworigin));
        ifog = 1 - fog;
 
-       R_Mesh_Matrix(&r_identitymatrix);
+       R_Mesh_Matrix(&identitymatrix);
        GL_BlendFunc(blendfunc1, blendfunc2);
        GL_DepthMask(false);
        GL_DepthTest(!depthdisable);
@@ -1656,17 +1655,17 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t)
        if (t->currentmaterialflags & MATERIALFLAG_WATER && r_waterscroll.value != 0)
                t->currenttexmatrix = r_waterscrollmatrix;
        else
-               t->currenttexmatrix = r_identitymatrix;
+               t->currenttexmatrix = identitymatrix;
        t->currentnumlayers = 0;
        if (!(t->currentmaterialflags & MATERIALFLAG_NODRAW))
        {
                if (gl_lightmaps.integer)
-                       R_Texture_AddLayer(t, true, GL_ONE, GL_ZERO, TEXTURELAYERTYPE_LITTEXTURE_MULTIPASS, r_texture_white, &r_identitymatrix, 1, 1, 1, 1);
+                       R_Texture_AddLayer(t, true, GL_ONE, GL_ZERO, TEXTURELAYERTYPE_LITTEXTURE_MULTIPASS, r_texture_white, &identitymatrix, 1, 1, 1, 1);
                else if (t->currentmaterialflags & MATERIALFLAG_SKY)
                {
                        // transparent sky would be ridiculous
                        if (!(t->currentmaterialflags & MATERIALFLAG_TRANSPARENT))
-                               R_Texture_AddLayer(t, true, GL_ONE, GL_ZERO, TEXTURELAYERTYPE_SKY, r_texture_white, &r_identitymatrix, fogcolor[0], fogcolor[1], fogcolor[2], 1);
+                               R_Texture_AddLayer(t, true, GL_ONE, GL_ZERO, TEXTURELAYERTYPE_SKY, r_texture_white, &identitymatrix, fogcolor[0], fogcolor[1], fogcolor[2], 1);
                }
                else
                {
@@ -1751,7 +1750,7 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t)
                                        // were darkened by fog already, and we should not add fog color
                                        // (because the background was not darkened, there is no fog color
                                        // that was lost behind it).
-                                       R_Texture_AddLayer(t, false, GL_SRC_ALPHA, (t->currentmaterialflags & MATERIALFLAG_TRANSPARENT) ? GL_ONE : GL_ONE_MINUS_SRC_ALPHA, TEXTURELAYERTYPE_FOG, t->skin.fog, &r_identitymatrix, fogcolor[0], fogcolor[1], fogcolor[2], t->currentalpha);
+                                       R_Texture_AddLayer(t, false, GL_SRC_ALPHA, (t->currentmaterialflags & MATERIALFLAG_TRANSPARENT) ? GL_ONE : GL_ONE_MINUS_SRC_ALPHA, TEXTURELAYERTYPE_FOG, t->skin.fog, &identitymatrix, fogcolor[0], fogcolor[1], fogcolor[2], t->currentalpha);
                                }
                        }
                }
index 065e770..69164fb 100644 (file)
@@ -301,7 +301,7 @@ static void R_DrawPortal_Callback(const entity_render_t *ent, int surfacenumber,
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        GL_DepthMask(false);
        GL_DepthTest(true);
-       R_Mesh_Matrix(&r_identitymatrix);
+       R_Mesh_Matrix(&identitymatrix);
 
        memset(&m, 0, sizeof(m));
        m.pointer_vertex = varray_vertex3f;
index b27d805..4159cd2 100644 (file)
@@ -126,7 +126,7 @@ int Mod_Alias_GetTagMatrix(const model_t *model, int poseframe, int tagindex, ma
 {
        const float *boneframe;
        float tempbonematrix[12], bonematrix[12];
-       Matrix4x4_CreateIdentity(outmatrix);
+       *outmatrix = identitymatrix;
        if (model->num_bones)
        {
                if (tagindex < 0 || tagindex >= model->num_bones)
@@ -221,8 +221,8 @@ static void Mod_MDLMD2MD3_TraceBox(model_t *model, int frame, trace_t *trace, co
        if (!linetrace)
        {
                // box trace, performed as brush trace
-               Matrix4x4_CreateIdentity(&startmatrix);
-               Matrix4x4_CreateIdentity(&endmatrix);
+               startmatrix = identitymatrix;
+               endmatrix = identitymatrix;
                thisbrush_start = Collision_BrushForBox(&startmatrix, boxstartmins, boxstartmaxs);
                thisbrush_end = Collision_BrushForBox(&endmatrix, boxendmins, boxendmaxs);
        }
@@ -1069,7 +1069,7 @@ void Mod_IDP3_Load(model_t *mod, void *buffer, void *bufferend)
        for (i = 0, pintag = (md3tag_t *)((unsigned char *)pinmodel + LittleLong(pinmodel->lump_tags));i < loadmodel->num_tagframes * loadmodel->num_tags;i++, pintag++)
        {
                strcpy(loadmodel->data_tags[i].name, pintag->name);
-               Matrix4x4_CreateIdentity(&loadmodel->data_tags[i].matrix);
+               loadmodel->data_tags[i].matrix = identitymatrix;
                for (j = 0;j < 3;j++)
                {
                        for (k = 0;k < 3;k++)
@@ -2143,7 +2143,7 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend)
                                mesh->data_vertexboneweights[mesh->num_vertexboneweights].vertexindex = index;
                                mesh->data_vertexboneweights[mesh->num_vertexboneweights].boneindex = rawweights[j].boneindex;
                                mesh->data_vertexboneweights[mesh->num_vertexboneweights].weight = rawweights[j].weight;
-                               Matrix4x4_CreateIdentity(&matrix);
+                               matrix = identitymatrix;
                                for (i = rawweights[j].boneindex;i >= 0;i = loadmodel->data_bones[i].parent)
                                {
                                        matrix4x4_t childmatrix, tempmatrix;
index a6ca9c0..ecbe140 100644 (file)
@@ -5359,8 +5359,8 @@ static void Mod_Q3BSP_TraceBox(model_t *model, int frame, trace_t *trace, const
        trace->fraction = 1;
        trace->realfraction = 1;
        trace->hitsupercontentsmask = hitsupercontentsmask;
-       Matrix4x4_CreateIdentity(&startmatrix);
-       Matrix4x4_CreateIdentity(&endmatrix);
+       startmatrix = identitymatrix;
+       endmatrix = identitymatrix;
        segmentmins[0] = min(boxstartmins[0], boxendmins[0]);
        segmentmins[1] = min(boxstartmins[1], boxendmins[1]);
        segmentmins[2] = min(boxstartmins[2], boxendmins[2]);
index 2b9f947..558e0de 100644 (file)
@@ -593,6 +593,8 @@ void Mod_BuildTextureVectorsAndNormals(int firstvertex, int numvertices, int num
 {
        int i, tnum;
        float sdir[3], tdir[3], normal[3], *v;
+       const float *v0, *v1, *v2, *tc0, *tc1, *tc2;
+       float f, tangentcross[3], v10[3], v20[3], tc10[2], tc20[2];
        const int *e;
        // clear the vectors
        if (svector3f)
@@ -604,7 +606,59 @@ void Mod_BuildTextureVectorsAndNormals(int firstvertex, int numvertices, int num
        // process each vertex of each triangle and accumulate the results
        for (tnum = 0, e = elements;tnum < numtriangles;tnum++, e += 3)
        {
-               Mod_BuildBumpVectors(vertex3f + e[0] * 3, vertex3f + e[1] * 3, vertex3f + e[2] * 3, texcoord2f + e[0] * 2, texcoord2f + e[1] * 2, texcoord2f + e[2] * 2, sdir, tdir, normal);
+               v0 = vertex3f + e[0] * 3;
+               v1 = vertex3f + e[1] * 3;
+               v2 = vertex3f + e[2] * 3;
+               tc0 = texcoord2f + e[0] * 2;
+               tc1 = texcoord2f + e[1] * 2;
+               tc2 = texcoord2f + e[2] * 2;
+
+               // 79 add/sub/negate/multiply (1 cycle), 1 compare (3 cycle?), total cycles not counting load/store/exchange roughly 82 cycles
+               // 6 add, 28 subtract, 39 multiply, 1 compare, 50% chance of 6 negates
+
+               // calculate the edge directions and surface normal
+               // 6 multiply, 9 subtract
+               VectorSubtract(v1, v0, v10);
+               VectorSubtract(v2, v0, v20);
+               normal[0] = v20[1] * v10[2] - v20[2] * v10[1];
+               normal[1] = v20[2] * v10[0] - v20[0] * v10[2];
+               normal[2] = v20[0] * v10[1] - v20[1] * v10[0];
+
+               // calculate the tangents
+               // 12 multiply, 10 subtract
+               tc10[1] = tc1[1] - tc0[1];
+               tc20[1] = tc2[1] - tc0[1];
+               sdir[0] = tc10[1] * v20[0] - tc20[1] * v10[0];
+               sdir[1] = tc10[1] * v20[1] - tc20[1] * v10[1];
+               sdir[2] = tc10[1] * v20[2] - tc20[1] * v10[2];
+               tc10[0] = tc1[0] - tc0[0];
+               tc20[0] = tc2[0] - tc0[0];
+               tdir[0] = tc10[0] * v20[0] - tc20[0] * v10[0];
+               tdir[1] = tc10[0] * v20[1] - tc20[0] * v10[1];
+               tdir[2] = tc10[0] * v20[2] - tc20[0] * v10[2];
+
+               // make the tangents completely perpendicular to the surface normal
+               // 12 multiply, 4 add, 6 subtract
+               f = DotProduct(sdir, normal);
+               sdir[0] -= f * normal[0];
+               sdir[1] -= f * normal[1];
+               sdir[2] -= f * normal[2];
+               f = DotProduct(tdir, normal);
+               tdir[0] -= f * normal[0];
+               tdir[1] -= f * normal[1];
+               tdir[2] -= f * normal[2];
+
+               // if texture is mapped the wrong way (counterclockwise), the tangents
+               // have to be flipped, this is detected by calculating a normal from the
+               // two tangents, and seeing if it is opposite the surface normal
+               // 9 multiply, 2 add, 3 subtract, 1 compare, 50% chance of: 6 negates
+               CrossProduct(tdir, sdir, tangentcross);
+               if (DotProduct(tangentcross, normal) < 0)
+               {
+                       VectorNegate(sdir, sdir);
+                       VectorNegate(tdir, tdir);
+               }
+
                if (!areaweighting)
                {
                        VectorNormalize(sdir);
index d1e51b9..28f8bae 100644 (file)
@@ -190,7 +190,7 @@ static void R_DrawExplosion_TransparentCallback(const entity_render_t *ent, int
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
        GL_DepthMask(false);
        GL_DepthTest(true);
-       R_Mesh_Matrix(&r_identitymatrix);
+       R_Mesh_Matrix(&identitymatrix);
 
        numtriangles = EXPLOSIONTRIS;
        numverts = EXPLOSIONVERTS;
index f06c41e..572d6ed 100644 (file)
--- a/r_light.c
+++ b/r_light.c
@@ -81,7 +81,7 @@ void R_DrawCoronas(void)
        dlight_t *light;
        if (r_coronas.value < 0.01)
                return;
-       R_Mesh_Matrix(&r_identitymatrix);
+       R_Mesh_Matrix(&identitymatrix);
        viewdist = DotProduct(r_vieworigin, r_viewforward);
        flag = r_rtworld ? LIGHTFLAG_REALTIMEMODE : LIGHTFLAG_NORMALMODE;
        for (lnum = 0, light = r_shadow_worldlightchain;light;light = light->next, lnum++)
index bc4efbb..f6b5bd3 100644 (file)
@@ -236,7 +236,7 @@ void R_DrawLightningBeam_TransparentCallback(const entity_render_t *ent, int sur
        vec3_t beamdir, right, up, offset;
        float length, t1, t2;
 
-       R_Mesh_Matrix(&r_identitymatrix);
+       R_Mesh_Matrix(&identitymatrix);
 
        // calculate beam direction (beamdir) vector and beam length
        // get difference vector
index 70169e1..af4bbfd 100644 (file)
@@ -73,7 +73,7 @@ void R_Model_Sprite_Draw_TransparentCallback(const entity_render_t *ent, int sur
                break;
        }
 
-       R_Mesh_Matrix(&r_identitymatrix);
+       R_Mesh_Matrix(&identitymatrix);
 
        if (!(ent->flags & RENDER_LIGHT))
                color[0] = color[1] = color[2] = 1;
index 5646c66..ee06c0f 100644 (file)
--- a/render.h
+++ b/render.h
@@ -30,8 +30,6 @@ extern unsigned char r_worldleafvisible[32768];
 // TODO: dynamic resize according to r_refdef.worldmodel->num_surfaces
 extern unsigned char r_worldsurfacevisible[262144];
 
-extern matrix4x4_t r_identitymatrix;
-
 // 1.0f / N table
 extern float ixtable[4096];
 
index 7758ed4..c178bab 100644 (file)
@@ -2258,7 +2258,7 @@ int SV_GetEntityLocalTagMatrix(prvm_edict_t *ent, int tagindex, matrix4x4_t *out
                        frame = 0;
                return Mod_Alias_GetTagMatrix(model, model->animscenes[frame].firstframe, tagindex, out);
        }
-       Matrix4x4_CreateIdentity(out);
+       *out = identitymatrix;
        return 0;
 }
 
@@ -2280,7 +2280,7 @@ int SV_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
        matrix4x4_t entitymatrix, tagmatrix, attachmatrix;
        model_t *model;
 
-       Matrix4x4_CreateIdentity(out); // warnings and errors return identical matrix
+       *out = identitymatrix; // warnings and errors return identical matrix
 
        if (ent == prog->edicts)
                return 1;
@@ -2293,7 +2293,7 @@ int SV_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
 
        model = sv.models[modelindex];
 
-       Matrix4x4_CreateIdentity(&tagmatrix);
+       tagmatrix = identitymatrix;
        // DP_GFX_QUAKE3MODELTAGS, scan all chain and stop on unattached entity
        attachloop = 0;
        for (;;)
diff --git a/view.c b/view.c
index 2a9629c..28fe764 100644 (file)
--- a/view.c
+++ b/view.c
@@ -325,8 +325,8 @@ void V_CalcRefdef (void)
        if(csqc_loaded)
                return;
        VectorClear(gunorg);
-       Matrix4x4_CreateIdentity(&viewmodelmatrix);
-       Matrix4x4_CreateIdentity(&r_refdef.viewentitymatrix);
+       viewmodelmatrix = identitymatrix;
+       r_refdef.viewentitymatrix = identitymatrix;
        if (cls.state == ca_connected && cls.signon == SIGNONS)
        {
                // ent is the view entity (visible when out of body)