]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
cleaned up almost all direct indexing of matrix4x4_t structures to go through proper...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 6 Nov 2006 06:13:54 +0000 (06:13 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 6 Nov 2006 06:13:54 +0000 (06:13 +0000)
removed some weird scaling code in gettaginfo QC builtin

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6612 d7cf8633-e32d-0410-b094-e92efae38249

cl_main.c
cl_screen.c
clvm_cmds.c
gl_backend.c
matrixlib.c
matrixlib.h
model_alias.c
r_sprites.c
svvm_cmds.c
todo
view.c

index 8db097dbd0a50fd7035cd265c6cdc10e9d430b8c..53b7bace7ed8217eeb4f4138cd9e2091c61a79e2 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -441,6 +441,7 @@ static void CL_PrintEntities_f(void)
        entity_t *ent;
        int i, j;
        char name[32];
        entity_t *ent;
        int i, j;
        char name[32];
+       vec3_t org;
 
        for (i = 0, ent = cl.entities;i < cl.num_entities;i++, ent++)
        {
 
        for (i = 0, ent = cl.entities;i < cl.num_entities;i++, ent++)
        {
@@ -456,7 +457,8 @@ static void CL_PrintEntities_f(void)
                strlcpy(name, modelname, 25);
                for (j = (int)strlen(name);j < 25;j++)
                        name[j] = ' ';
                strlcpy(name, modelname, 25);
                for (j = (int)strlen(name);j < 25;j++)
                        name[j] = ' ';
-               Con_Printf("%3i: %s:%4i (%5i %5i %5i) [%3i %3i %3i] %4.2f %5.3f\n", i, name, ent->render.frame, (int) ent->render.matrix.m[0][3], (int) ent->render.matrix.m[1][3], (int) ent->render.matrix.m[2][3], (int) ent->render.angles[0] % 360, (int) ent->render.angles[1] % 360, (int) ent->render.angles[2] % 360, ent->render.scale, ent->render.alpha);
+               Matrix4x4_OriginFromMatrix(&ent->render.matrix, org);
+               Con_Printf("%3i: %s:%4i (%5i %5i %5i) [%3i %3i %3i] %4.2f %5.3f\n", i, name, ent->render.frame, (int) org[0], (int) org[1], (int) org[2], (int) ent->render.angles[0] % 360, (int) ent->render.angles[1] % 360, (int) ent->render.angles[2] % 360, ent->render.scale, ent->render.alpha);
        }
 }
 
        }
 }
 
@@ -464,57 +466,50 @@ static void CL_PrintEntities_f(void)
 //static const vec3_t nomodelmaxs = {16, 16, 16};
 void CL_BoundingBoxForEntity(entity_render_t *ent)
 {
 //static const vec3_t nomodelmaxs = {16, 16, 16};
 void CL_BoundingBoxForEntity(entity_render_t *ent)
 {
+       vec3_t org;
        model_t *model = ent->model;
        model_t *model = ent->model;
+       Matrix4x4_OriginFromMatrix(&ent->matrix, org);
        if (model)
        {
        if (model)
        {
-               //if (ent->angles[0] || ent->angles[2])
+               // NOTE: this directly extracts vector components from the matrix, which relies on the matrix orientation!
                if (ent->matrix.m[2][0] != 0 || ent->matrix.m[2][1] != 0)
                {
                        // pitch or roll
                if (ent->matrix.m[2][0] != 0 || ent->matrix.m[2][1] != 0)
                {
                        // pitch or roll
-                       ent->mins[0] = ent->matrix.m[0][3] + model->rotatedmins[0];
-                       ent->mins[1] = ent->matrix.m[1][3] + model->rotatedmins[1];
-                       ent->mins[2] = ent->matrix.m[2][3] + model->rotatedmins[2];
-                       ent->maxs[0] = ent->matrix.m[0][3] + model->rotatedmaxs[0];
-                       ent->maxs[1] = ent->matrix.m[1][3] + model->rotatedmaxs[1];
-                       ent->maxs[2] = ent->matrix.m[2][3] + model->rotatedmaxs[2];
-                       //VectorAdd(ent->origin, model->rotatedmins, ent->mins);
-                       //VectorAdd(ent->origin, model->rotatedmaxs, ent->maxs);
+                       ent->mins[0] = org[0] + model->rotatedmins[0];
+                       ent->mins[1] = org[1] + model->rotatedmins[1];
+                       ent->mins[2] = org[2] + model->rotatedmins[2];
+                       ent->maxs[0] = org[0] + model->rotatedmaxs[0];
+                       ent->maxs[1] = org[1] + model->rotatedmaxs[1];
+                       ent->maxs[2] = org[2] + model->rotatedmaxs[2];
                }
                }
-               //else if (ent->angles[1])
                else if (ent->matrix.m[0][1] != 0 || ent->matrix.m[1][0] != 0)
                {
                        // yaw
                else if (ent->matrix.m[0][1] != 0 || ent->matrix.m[1][0] != 0)
                {
                        // yaw
-                       ent->mins[0] = ent->matrix.m[0][3] + model->yawmins[0];
-                       ent->mins[1] = ent->matrix.m[1][3] + model->yawmins[1];
-                       ent->mins[2] = ent->matrix.m[2][3] + model->yawmins[2];
-                       ent->maxs[0] = ent->matrix.m[0][3] + model->yawmaxs[0];
-                       ent->maxs[1] = ent->matrix.m[1][3] + model->yawmaxs[1];
-                       ent->maxs[2] = ent->matrix.m[2][3] + model->yawmaxs[2];
-                       //VectorAdd(ent->origin, model->yawmins, ent->mins);
-                       //VectorAdd(ent->origin, model->yawmaxs, ent->maxs);
+                       ent->mins[0] = org[0] + model->yawmins[0];
+                       ent->mins[1] = org[1] + model->yawmins[1];
+                       ent->mins[2] = org[2] + model->yawmins[2];
+                       ent->maxs[0] = org[0] + model->yawmaxs[0];
+                       ent->maxs[1] = org[1] + model->yawmaxs[1];
+                       ent->maxs[2] = org[2] + model->yawmaxs[2];
                }
                else
                {
                }
                else
                {
-                       ent->mins[0] = ent->matrix.m[0][3] + model->normalmins[0];
-                       ent->mins[1] = ent->matrix.m[1][3] + model->normalmins[1];
-                       ent->mins[2] = ent->matrix.m[2][3] + model->normalmins[2];
-                       ent->maxs[0] = ent->matrix.m[0][3] + model->normalmaxs[0];
-                       ent->maxs[1] = ent->matrix.m[1][3] + model->normalmaxs[1];
-                       ent->maxs[2] = ent->matrix.m[2][3] + model->normalmaxs[2];
-                       //VectorAdd(ent->origin, model->normalmins, ent->mins);
-                       //VectorAdd(ent->origin, model->normalmaxs, ent->maxs);
+                       ent->mins[0] = org[0] + model->normalmins[0];
+                       ent->mins[1] = org[1] + model->normalmins[1];
+                       ent->mins[2] = org[2] + model->normalmins[2];
+                       ent->maxs[0] = org[0] + model->normalmaxs[0];
+                       ent->maxs[1] = org[1] + model->normalmaxs[1];
+                       ent->maxs[2] = org[2] + model->normalmaxs[2];
                }
        }
        else
        {
                }
        }
        else
        {
-               ent->mins[0] = ent->matrix.m[0][3] - 16;
-               ent->mins[1] = ent->matrix.m[1][3] - 16;
-               ent->mins[2] = ent->matrix.m[2][3] - 16;
-               ent->maxs[0] = ent->matrix.m[0][3] + 16;
-               ent->maxs[1] = ent->matrix.m[1][3] + 16;
-               ent->maxs[2] = ent->matrix.m[2][3] + 16;
-               //VectorAdd(ent->origin, nomodelmins, ent->mins);
-               //VectorAdd(ent->origin, nomodelmaxs, ent->maxs);
+               ent->mins[0] = org[0] - 16;
+               ent->mins[1] = org[1] - 16;
+               ent->mins[2] = org[2] - 16;
+               ent->maxs[0] = org[0] + 16;
+               ent->maxs[1] = org[1] + 16;
+               ent->maxs[2] = org[2] + 16;
        }
 }
 
        }
 }
 
@@ -634,13 +629,9 @@ dlightsetup:
        memset (dl, 0, sizeof(*dl));
        Matrix4x4_Normalize(&dl->matrix, matrix);
        dl->ent = ent;
        memset (dl, 0, sizeof(*dl));
        Matrix4x4_Normalize(&dl->matrix, matrix);
        dl->ent = ent;
-       dl->origin[0] = dl->matrix.m[0][3];
-       dl->origin[1] = dl->matrix.m[1][3];
-       dl->origin[2] = dl->matrix.m[2][3];
+       Matrix4x4_OriginFromMatrix(&dl->matrix, dl->origin);
        CL_FindNonSolidLocation(dl->origin, dl->origin, 6);
        CL_FindNonSolidLocation(dl->origin, dl->origin, 6);
-       dl->matrix.m[0][3] = dl->origin[0];
-       dl->matrix.m[1][3] = dl->origin[1];
-       dl->matrix.m[2][3] = dl->origin[2];
+       Matrix4x4_SetOrigin(&dl->matrix, dl->origin[0], dl->origin[1], dl->origin[2]);
        dl->radius = radius;
        dl->color[0] = red;
        dl->color[1] = green;
        dl->radius = radius;
        dl->color[0] = red;
        dl->color[1] = green;
@@ -1016,11 +1007,7 @@ void CL_UpdateNetworkEntity(entity_t *e)
                        Matrix4x4_Transform(&e->render.matrix, o, origin);
                }
                else
                        Matrix4x4_Transform(&e->render.matrix, o, origin);
                }
                else
-               {
-                       origin[0] = e->render.matrix.m[0][3];
-                       origin[1] = e->render.matrix.m[1][3];
-                       origin[2] = e->render.matrix.m[2][3];
-               }
+                       Matrix4x4_OriginFromMatrix(&e->render.matrix, origin);
                trailtype = EFFECT_NONE;
                dlightradius = 0;
                dlightcolor[0] = 0;
                trailtype = EFFECT_NONE;
                dlightradius = 0;
                dlightcolor[0] = 0;
@@ -1083,9 +1070,7 @@ void CL_UpdateNetworkEntity(entity_t *e)
                        Matrix4x4_Transform(&e->render.matrix, muzzleflashorigin, v2);
                        trace = CL_TraceBox(origin, vec3_origin, vec3_origin, v2, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_SKY, false);
                        tempmatrix = e->render.matrix;
                        Matrix4x4_Transform(&e->render.matrix, muzzleflashorigin, v2);
                        trace = CL_TraceBox(origin, vec3_origin, vec3_origin, v2, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_SKY, false);
                        tempmatrix = e->render.matrix;
-                       tempmatrix.m[0][3] = trace.endpos[0];
-                       tempmatrix.m[1][3] = trace.endpos[1];
-                       tempmatrix.m[2][3] = trace.endpos[2];
+                       Matrix4x4_SetOrigin(&tempmatrix, trace.endpos[0], trace.endpos[1], trace.endpos[2]);
                        CL_AllocDlight(NULL, &tempmatrix, 100, e->persistent.muzzleflash, e->persistent.muzzleflash, e->persistent.muzzleflash, 0, 0, 0, -1, true, 0, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
                        e->persistent.muzzleflash -= (cl.time - cl.oldtime) * 10;
                }
                        CL_AllocDlight(NULL, &tempmatrix, 100, e->persistent.muzzleflash, e->persistent.muzzleflash, e->persistent.muzzleflash, 0, 0, 0, -1, true, 0, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
                        e->persistent.muzzleflash -= (cl.time - cl.oldtime) * 10;
                }
@@ -1124,7 +1109,7 @@ void CL_UpdateNetworkEntity(entity_t *e)
                        //dlightmatrix = e->render.matrix;
                        // hack to make glowing player light shine on their gun
                        //if (e->state_current.number == cl.viewentity/* && !chase_active.integer*/)
                        //dlightmatrix = e->render.matrix;
                        // hack to make glowing player light shine on their gun
                        //if (e->state_current.number == cl.viewentity/* && !chase_active.integer*/)
-                       //      dlightmatrix.m[2][3] += 30;
+                       //      Matrix4x4_AdjustOrigin(&dlightmatrix, 0, 0, 30);
                        CL_AllocDlight(&e->render, &e->render.matrix, dlightradius, dlightcolor[0], dlightcolor[1], dlightcolor[2], 0, 0, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
                }
                // custom rtlight
                        CL_AllocDlight(&e->render, &e->render.matrix, dlightradius, dlightcolor[0], dlightcolor[1], dlightcolor[2], 0, 0, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
                }
                // custom rtlight
index c01168507eb5803efd58c39a79da772fcd1f58f9..8ab102be0b1eebbc5ec980048ef938ede09a5481 100644 (file)
@@ -1746,9 +1746,9 @@ void CL_UpdateScreen(void)
        if (vid.stereobuffer || r_stereo_redblue.integer || r_stereo_redgreen.integer || r_stereo_redcyan.integer || r_stereo_sidebyside.integer)
        {
                matrix4x4_t originalmatrix = r_view.matrix;
        if (vid.stereobuffer || r_stereo_redblue.integer || r_stereo_redgreen.integer || r_stereo_redcyan.integer || r_stereo_sidebyside.integer)
        {
                matrix4x4_t originalmatrix = r_view.matrix;
-               r_view.matrix.m[0][3] = originalmatrix.m[0][3] + r_stereo_separation.value * -0.5f * r_view.matrix.m[0][1];
-               r_view.matrix.m[1][3] = originalmatrix.m[1][3] + r_stereo_separation.value * -0.5f * r_view.matrix.m[1][1];
-               r_view.matrix.m[2][3] = originalmatrix.m[2][3] + r_stereo_separation.value * -0.5f * r_view.matrix.m[2][1];
+               matrix4x4_t offsetmatrix;
+               Matrix4x4_CreateTranslate(&offsetmatrix, 0, r_stereo_separation.value * -0.5f, 0);
+               Matrix4x4_Concat(&r_view.matrix, &offsetmatrix, &originalmatrix);
 
                if (r_stereo_sidebyside.integer)
                        r_stereo_side = 0;
 
                if (r_stereo_sidebyside.integer)
                        r_stereo_side = 0;
@@ -1765,9 +1765,8 @@ void CL_UpdateScreen(void)
 
                SCR_DrawScreen();
 
 
                SCR_DrawScreen();
 
-               r_view.matrix.m[0][3] = originalmatrix.m[0][3] + r_stereo_separation.value * 0.5f * r_view.matrix.m[0][1];
-               r_view.matrix.m[1][3] = originalmatrix.m[1][3] + r_stereo_separation.value * 0.5f * r_view.matrix.m[1][1];
-               r_view.matrix.m[2][3] = originalmatrix.m[2][3] + r_stereo_separation.value * 0.5f * r_view.matrix.m[2][1];
+               Matrix4x4_CreateTranslate(&offsetmatrix, 0, r_stereo_separation.value * 0.5f, 0);
+               Matrix4x4_Concat(&r_view.matrix, &offsetmatrix, &originalmatrix);
 
                if (r_stereo_sidebyside.integer)
                        r_stereo_side = 1;
 
                if (r_stereo_sidebyside.integer)
                        r_stereo_side = 1;
index 5239a08d30e625ffba4d1ccd1ee0db407a8ca396..4f9f3680f81c77686a4cadb93bed75f1dafceb14 100644 (file)
@@ -2071,16 +2071,10 @@ int CL_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
                                val->_float = 1;
                        Matrix4x4_CreateFromQuakeEntity(&entitymatrix, ent->fields.client->origin[0], ent->fields.client->origin[1], ent->fields.client->origin[2], -ent->fields.client->angles[0], ent->fields.client->angles[1], ent->fields.client->angles[2], val->_float);
                        Matrix4x4_Concat(out, &entitymatrix, &tagmatrix);
                                val->_float = 1;
                        Matrix4x4_CreateFromQuakeEntity(&entitymatrix, ent->fields.client->origin[0], ent->fields.client->origin[1], ent->fields.client->origin[2], -ent->fields.client->angles[0], ent->fields.client->angles[1], ent->fields.client->angles[2], val->_float);
                        Matrix4x4_Concat(out, &entitymatrix, &tagmatrix);
-                       out->m[0][3] = entitymatrix.m[0][3] + val->_float*(entitymatrix.m[0][0]*tagmatrix.m[0][3] + entitymatrix.m[0][1]*tagmatrix.m[1][3] + entitymatrix.m[0][2]*tagmatrix.m[2][3]);
-                       out->m[1][3] = entitymatrix.m[1][3] + val->_float*(entitymatrix.m[1][0]*tagmatrix.m[0][3] + entitymatrix.m[1][1]*tagmatrix.m[1][3] + entitymatrix.m[1][2]*tagmatrix.m[2][3]);
-                       out->m[2][3] = entitymatrix.m[2][3] + val->_float*(entitymatrix.m[2][0]*tagmatrix.m[0][3] + entitymatrix.m[2][1]*tagmatrix.m[1][3] + entitymatrix.m[2][2]*tagmatrix.m[2][3]);
                        Matrix4x4_Copy(&tagmatrix, out);
 
                        // finally transformate by matrix of tag on parent entity
                        Matrix4x4_Concat(out, &attachmatrix, &tagmatrix);
                        Matrix4x4_Copy(&tagmatrix, out);
 
                        // finally transformate by matrix of tag on parent entity
                        Matrix4x4_Concat(out, &attachmatrix, &tagmatrix);
-                       out->m[0][3] = attachmatrix.m[0][3] + attachmatrix.m[0][0]*tagmatrix.m[0][3] + attachmatrix.m[0][1]*tagmatrix.m[1][3] + attachmatrix.m[0][2]*tagmatrix.m[2][3];
-                       out->m[1][3] = attachmatrix.m[1][3] + attachmatrix.m[1][0]*tagmatrix.m[0][3] + attachmatrix.m[1][1]*tagmatrix.m[1][3] + attachmatrix.m[1][2]*tagmatrix.m[2][3];
-                       out->m[2][3] = attachmatrix.m[2][3] + attachmatrix.m[2][0]*tagmatrix.m[0][3] + attachmatrix.m[2][1]*tagmatrix.m[1][3] + attachmatrix.m[2][2]*tagmatrix.m[2][3];
                        Matrix4x4_Copy(&tagmatrix, out);
 
                        ent = attachent;
                        Matrix4x4_Copy(&tagmatrix, out);
 
                        ent = attachent;
@@ -2098,9 +2092,6 @@ int CL_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
        // Alias models have inverse pitch, bmodels can't have tags, so don't check for modeltype...
        Matrix4x4_CreateFromQuakeEntity(&entitymatrix, ent->fields.client->origin[0], ent->fields.client->origin[1], ent->fields.client->origin[2], -ent->fields.client->angles[0], ent->fields.client->angles[1], ent->fields.client->angles[2], val->_float);
        Matrix4x4_Concat(out, &entitymatrix, &tagmatrix);
        // Alias models have inverse pitch, bmodels can't have tags, so don't check for modeltype...
        Matrix4x4_CreateFromQuakeEntity(&entitymatrix, ent->fields.client->origin[0], ent->fields.client->origin[1], ent->fields.client->origin[2], -ent->fields.client->angles[0], ent->fields.client->angles[1], ent->fields.client->angles[2], val->_float);
        Matrix4x4_Concat(out, &entitymatrix, &tagmatrix);
-       out->m[0][3] = entitymatrix.m[0][3] + val->_float*(entitymatrix.m[0][0]*tagmatrix.m[0][3] + entitymatrix.m[0][1]*tagmatrix.m[1][3] + entitymatrix.m[0][2]*tagmatrix.m[2][3]);
-       out->m[1][3] = entitymatrix.m[1][3] + val->_float*(entitymatrix.m[1][0]*tagmatrix.m[0][3] + entitymatrix.m[1][1]*tagmatrix.m[1][3] + entitymatrix.m[1][2]*tagmatrix.m[2][3]);
-       out->m[2][3] = entitymatrix.m[2][3] + val->_float*(entitymatrix.m[2][0]*tagmatrix.m[0][3] + entitymatrix.m[2][1]*tagmatrix.m[1][3] + entitymatrix.m[2][2]*tagmatrix.m[2][3]);
 
        if ((val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_renderflags)) && (RF_VIEWMODEL & (int)val->_float))
        {// RENDER_VIEWMODEL magic
 
        if ((val = PRVM_GETEDICTFIELDVALUE(ent, csqc_fieldoff_renderflags)) && (RF_VIEWMODEL & (int)val->_float))
        {// RENDER_VIEWMODEL magic
@@ -2112,9 +2103,6 @@ int CL_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
 
                Matrix4x4_CreateFromQuakeEntity(&entitymatrix, csqc_origin[0], csqc_origin[1], csqc_origin[2], csqc_angles[0], csqc_angles[1], csqc_angles[2], val->_float);
                Matrix4x4_Concat(out, &entitymatrix, &tagmatrix);
 
                Matrix4x4_CreateFromQuakeEntity(&entitymatrix, csqc_origin[0], csqc_origin[1], csqc_origin[2], csqc_angles[0], csqc_angles[1], csqc_angles[2], val->_float);
                Matrix4x4_Concat(out, &entitymatrix, &tagmatrix);
-               out->m[0][3] = entitymatrix.m[0][3] + val->_float*(entitymatrix.m[0][0]*tagmatrix.m[0][3] + entitymatrix.m[0][1]*tagmatrix.m[1][3] + entitymatrix.m[0][2]*tagmatrix.m[2][3]);
-               out->m[1][3] = entitymatrix.m[1][3] + val->_float*(entitymatrix.m[1][0]*tagmatrix.m[0][3] + entitymatrix.m[1][1]*tagmatrix.m[1][3] + entitymatrix.m[1][2]*tagmatrix.m[2][3]);
-               out->m[2][3] = entitymatrix.m[2][3] + val->_float*(entitymatrix.m[2][0]*tagmatrix.m[0][3] + entitymatrix.m[2][1]*tagmatrix.m[1][3] + entitymatrix.m[2][2]*tagmatrix.m[2][3]);
 
                /*
                // Cl_bob, ported from rendering code
 
                /*
                // Cl_bob, ported from rendering code
@@ -2135,7 +2123,7 @@ int CL_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
                        // (don't count Z, or jumping messes it up)
                        bob = sqrt(ent->fields.client->velocity[0]*ent->fields.client->velocity[0] + ent->fields.client->velocity[1]*ent->fields.client->velocity[1])*cl_bob.value;
                        bob = bob*0.3 + bob*0.7*cycle;
                        // (don't count Z, or jumping messes it up)
                        bob = sqrt(ent->fields.client->velocity[0]*ent->fields.client->velocity[0] + ent->fields.client->velocity[1]*ent->fields.client->velocity[1])*cl_bob.value;
                        bob = bob*0.3 + bob*0.7*cycle;
-                       out->m[2][3] += bound(-7, bob, 4);
+                       Matrix4x4_AdjustOrigin(out, 0, 0, bound(-7, bob, 4));
                }
                */
        }
                }
                */
        }
index 348dd65567082291e4f82062f34d1f69d81dc30c..e6790294e0f0d5c8f32188f407496d5456745007 100644 (file)
@@ -270,22 +270,7 @@ void GL_SetupView_Mode_Perspective (double frustumx, double frustumy, double zNe
        // set view pyramid
        qglFrustum(-frustumx * zNear, frustumx * zNear, -frustumy * zNear, frustumy * zNear, zNear, zFar);CHECKGLERROR
        qglGetDoublev(GL_PROJECTION_MATRIX, m);CHECKGLERROR
        // set view pyramid
        qglFrustum(-frustumx * zNear, frustumx * zNear, -frustumy * zNear, frustumy * zNear, zNear, zFar);CHECKGLERROR
        qglGetDoublev(GL_PROJECTION_MATRIX, m);CHECKGLERROR
-       backend_projectmatrix.m[0][0] = m[0];
-       backend_projectmatrix.m[1][0] = m[1];
-       backend_projectmatrix.m[2][0] = m[2];
-       backend_projectmatrix.m[3][0] = m[3];
-       backend_projectmatrix.m[0][1] = m[4];
-       backend_projectmatrix.m[1][1] = m[5];
-       backend_projectmatrix.m[2][1] = m[6];
-       backend_projectmatrix.m[3][1] = m[7];
-       backend_projectmatrix.m[0][2] = m[8];
-       backend_projectmatrix.m[1][2] = m[9];
-       backend_projectmatrix.m[2][2] = m[10];
-       backend_projectmatrix.m[3][2] = m[11];
-       backend_projectmatrix.m[0][3] = m[12];
-       backend_projectmatrix.m[1][3] = m[13];
-       backend_projectmatrix.m[2][3] = m[14];
-       backend_projectmatrix.m[3][3] = m[15];
+       Matrix4x4_FromArrayDoubleGL(&backend_projectmatrix, m);
        qglMatrixMode(GL_MODELVIEW);CHECKGLERROR
        GL_SetupView_Orientation_Identity();
        CHECKGLERROR
        qglMatrixMode(GL_MODELVIEW);CHECKGLERROR
        GL_SetupView_Orientation_Identity();
        CHECKGLERROR
@@ -321,22 +306,7 @@ void GL_SetupView_Mode_PerspectiveInfiniteFarClip (double frustumx, double frust
        qglMatrixMode(GL_MODELVIEW);CHECKGLERROR
        GL_SetupView_Orientation_Identity();
        CHECKGLERROR
        qglMatrixMode(GL_MODELVIEW);CHECKGLERROR
        GL_SetupView_Orientation_Identity();
        CHECKGLERROR
-       backend_projectmatrix.m[0][0] = m[0];
-       backend_projectmatrix.m[1][0] = m[1];
-       backend_projectmatrix.m[2][0] = m[2];
-       backend_projectmatrix.m[3][0] = m[3];
-       backend_projectmatrix.m[0][1] = m[4];
-       backend_projectmatrix.m[1][1] = m[5];
-       backend_projectmatrix.m[2][1] = m[6];
-       backend_projectmatrix.m[3][1] = m[7];
-       backend_projectmatrix.m[0][2] = m[8];
-       backend_projectmatrix.m[1][2] = m[9];
-       backend_projectmatrix.m[2][2] = m[10];
-       backend_projectmatrix.m[3][2] = m[11];
-       backend_projectmatrix.m[0][3] = m[12];
-       backend_projectmatrix.m[1][3] = m[13];
-       backend_projectmatrix.m[2][3] = m[14];
-       backend_projectmatrix.m[3][3] = m[15];
+       Matrix4x4_FromArrayDoubleGL(&backend_projectmatrix, m);
 }
 
 void GL_SetupView_Mode_Ortho (double x1, double y1, double x2, double y2, double zNear, double zFar)
 }
 
 void GL_SetupView_Mode_Ortho (double x1, double y1, double x2, double y2, double zNear, double zFar)
@@ -349,22 +319,7 @@ void GL_SetupView_Mode_Ortho (double x1, double y1, double x2, double y2, double
        qglLoadIdentity();CHECKGLERROR
        qglOrtho(x1, x2, y2, y1, zNear, zFar);CHECKGLERROR
        qglGetDoublev(GL_PROJECTION_MATRIX, m);CHECKGLERROR
        qglLoadIdentity();CHECKGLERROR
        qglOrtho(x1, x2, y2, y1, zNear, zFar);CHECKGLERROR
        qglGetDoublev(GL_PROJECTION_MATRIX, m);CHECKGLERROR
-       backend_projectmatrix.m[0][0] = m[0];
-       backend_projectmatrix.m[1][0] = m[1];
-       backend_projectmatrix.m[2][0] = m[2];
-       backend_projectmatrix.m[3][0] = m[3];
-       backend_projectmatrix.m[0][1] = m[4];
-       backend_projectmatrix.m[1][1] = m[5];
-       backend_projectmatrix.m[2][1] = m[6];
-       backend_projectmatrix.m[3][1] = m[7];
-       backend_projectmatrix.m[0][2] = m[8];
-       backend_projectmatrix.m[1][2] = m[9];
-       backend_projectmatrix.m[2][2] = m[10];
-       backend_projectmatrix.m[3][2] = m[11];
-       backend_projectmatrix.m[0][3] = m[12];
-       backend_projectmatrix.m[1][3] = m[13];
-       backend_projectmatrix.m[2][3] = m[14];
-       backend_projectmatrix.m[3][3] = m[15];
+       Matrix4x4_FromArrayDoubleGL(&backend_projectmatrix, m);
        qglMatrixMode(GL_MODELVIEW);CHECKGLERROR
        GL_SetupView_Orientation_Identity();
        CHECKGLERROR
        qglMatrixMode(GL_MODELVIEW);CHECKGLERROR
        GL_SetupView_Orientation_Identity();
        CHECKGLERROR
index 26283a3693c988240746b4abd8ec68b72cfb8149..6ba666765af8569d5a446b4e238fb587647c6f24 100644 (file)
@@ -201,7 +201,7 @@ void Matrix4x4_CreateIdentity (matrix4x4_t *out)
        out->m[3][3]=1.0f;
 }
 
        out->m[3][3]=1.0f;
 }
 
-void Matrix4x4_CreateTranslate (matrix4x4_t *out, float x, float y, float z)
+void Matrix4x4_CreateTranslate (matrix4x4_t *out, double x, double y, double z)
 {
        out->m[0][0]=1.0f;
        out->m[0][1]=0.0f;
 {
        out->m[0][0]=1.0f;
        out->m[0][1]=0.0f;
@@ -221,9 +221,9 @@ void Matrix4x4_CreateTranslate (matrix4x4_t *out, float x, float y, float z)
        out->m[3][3]=1.0f;
 }
 
        out->m[3][3]=1.0f;
 }
 
-void Matrix4x4_CreateRotate (matrix4x4_t *out, float angle, float x, float y, float z)
+void Matrix4x4_CreateRotate (matrix4x4_t *out, double angle, double x, double y, double z)
 {
 {
-       float len, c, s;
+       double len, c, s;
 
        len = x*x+y*y+z*z;
        if (len != 0.0f)
 
        len = x*x+y*y+z*z;
        if (len != 0.0f)
@@ -254,7 +254,7 @@ void Matrix4x4_CreateRotate (matrix4x4_t *out, float angle, float x, float y, fl
        out->m[3][3]=1.0f;
 }
 
        out->m[3][3]=1.0f;
 }
 
-void Matrix4x4_CreateScale (matrix4x4_t *out, float x)
+void Matrix4x4_CreateScale (matrix4x4_t *out, double x)
 {
        out->m[0][0]=x;
        out->m[0][1]=0.0f;
 {
        out->m[0][0]=x;
        out->m[0][1]=0.0f;
@@ -274,7 +274,7 @@ void Matrix4x4_CreateScale (matrix4x4_t *out, float x)
        out->m[3][3]=1.0f;
 }
 
        out->m[3][3]=1.0f;
 }
 
-void Matrix4x4_CreateScale3 (matrix4x4_t *out, float x, float y, float z)
+void Matrix4x4_CreateScale3 (matrix4x4_t *out, double x, double y, double z)
 {
        out->m[0][0]=x;
        out->m[0][1]=0.0f;
 {
        out->m[0][0]=x;
        out->m[0][1]=0.0f;
@@ -294,7 +294,7 @@ void Matrix4x4_CreateScale3 (matrix4x4_t *out, float x, float y, float z)
        out->m[3][3]=1.0f;
 }
 
        out->m[3][3]=1.0f;
 }
 
-void Matrix4x4_CreateFromQuakeEntity(matrix4x4_t *out, float x, float y, float z, float pitch, float yaw, float roll, float scale)
+void Matrix4x4_CreateFromQuakeEntity(matrix4x4_t *out, double x, double y, double z, double pitch, double yaw, double roll, double scale)
 {
        double angle, sr, sp, sy, cr, cp, cy;
 
 {
        double angle, sr, sp, sy, cr, cp, cy;
 
@@ -430,9 +430,141 @@ void Matrix4x4_FromVectors(matrix4x4_t *out, const float vx[3], const float vy[3
        out->m[3][3] = 1.0f;
 }
 
        out->m[3][3] = 1.0f;
 }
 
-void Matrix4x4_Blend (matrix4x4_t *out, const matrix4x4_t *in1, const matrix4x4_t *in2, float blend)
+void Matrix4x4_FromArrayDoubleGL (matrix4x4_t *out, const double in[16])
 {
 {
-       float iblend = 1 - blend;
+       out->m[0][0] = in[0];
+       out->m[1][0] = in[1];
+       out->m[2][0] = in[2];
+       out->m[3][0] = in[3];
+       out->m[0][1] = in[4];
+       out->m[1][1] = in[5];
+       out->m[2][1] = in[6];
+       out->m[3][1] = in[7];
+       out->m[0][2] = in[8];
+       out->m[1][2] = in[9];
+       out->m[2][2] = in[10];
+       out->m[3][2] = in[11];
+       out->m[0][3] = in[12];
+       out->m[1][3] = in[13];
+       out->m[2][3] = in[14];
+       out->m[3][3] = in[15];
+}
+
+void Matrix4x4_FromArrayDoubleD3D (matrix4x4_t *out, const double in[16])
+{
+       out->m[0][0] = in[0];
+       out->m[0][1] = in[1];
+       out->m[0][2] = in[2];
+       out->m[0][3] = in[3];
+       out->m[1][0] = in[4];
+       out->m[1][1] = in[5];
+       out->m[1][2] = in[6];
+       out->m[1][3] = in[7];
+       out->m[2][0] = in[8];
+       out->m[2][1] = in[9];
+       out->m[2][2] = in[10];
+       out->m[2][3] = in[11];
+       out->m[3][0] = in[12];
+       out->m[3][1] = in[13];
+       out->m[3][2] = in[14];
+       out->m[3][3] = in[15];
+}
+
+void Matrix4x4_ToArray12FloatGL(const matrix4x4_t *in, float out[12])
+{
+       out[ 0] = in->m[0][0];
+       out[ 1] = in->m[1][0];
+       out[ 2] = in->m[2][0];
+       out[ 3] = in->m[0][1];
+       out[ 4] = in->m[1][1];
+       out[ 5] = in->m[2][1];
+       out[ 6] = in->m[0][2];
+       out[ 7] = in->m[1][2];
+       out[ 8] = in->m[2][2];
+       out[ 9] = in->m[0][3];
+       out[10] = in->m[1][3];
+       out[11] = in->m[2][3];
+}
+
+void Matrix4x4_FromArray12FloatGL(matrix4x4_t *out, const float in[12])
+{
+       out->m[0][0] = in[0];
+       out->m[1][0] = in[1];
+       out->m[2][0] = in[2];
+       out->m[3][0] = 0;
+       out->m[0][1] = in[3];
+       out->m[1][1] = in[4];
+       out->m[2][1] = in[5];
+       out->m[3][1] = 0;
+       out->m[0][2] = in[6];
+       out->m[1][2] = in[7];
+       out->m[2][2] = in[8];
+       out->m[3][2] = 0;
+       out->m[0][3] = in[9];
+       out->m[1][3] = in[10];
+       out->m[2][3] = in[11];
+       out->m[3][3] = 1;
+}
+
+void Matrix4x4_ToArray12FloatD3D(const matrix4x4_t *in, float out[12])
+{
+       out[ 0] = in->m[0][0];
+       out[ 1] = in->m[0][1];
+       out[ 2] = in->m[0][2];
+       out[ 3] = in->m[0][3];
+       out[ 4] = in->m[1][0];
+       out[ 5] = in->m[1][1];
+       out[ 6] = in->m[1][2];
+       out[ 7] = in->m[1][3];
+       out[ 8] = in->m[2][0];
+       out[ 9] = in->m[2][1];
+       out[10] = in->m[2][2];
+       out[11] = in->m[2][3];
+}
+
+void Matrix4x4_FromArray12FloatD3D(matrix4x4_t *out, const float in[12])
+{
+       out->m[0][0] = in[0];
+       out->m[0][1] = in[1];
+       out->m[0][2] = in[2];
+       out->m[0][3] = in[3];
+       out->m[1][0] = in[4];
+       out->m[1][1] = in[5];
+       out->m[1][2] = in[6];
+       out->m[1][3] = in[7];
+       out->m[2][0] = in[8];
+       out->m[2][1] = in[9];
+       out->m[2][2] = in[10];
+       out->m[2][3] = in[11];
+       out->m[3][0] = 0;
+       out->m[3][1] = 0;
+       out->m[3][2] = 0;
+       out->m[3][3] = 1;
+}
+
+void Matrix4x4_FromOriginQuat(matrix4x4_t *m, double ox, double oy, double oz, double x, double y, double z, double w)
+{
+       m->m[0][0]=1-2*(y*y+z*z);m->m[0][1]=  2*(x*y-z*w);m->m[0][2]=  2*(x*z+y*w);m->m[0][3]=ox;
+       m->m[1][0]=  2*(x*y+z*w);m->m[1][1]=1-2*(x*x+z*z);m->m[1][2]=  2*(y*z-x*w);m->m[1][3]=oy;
+       m->m[2][0]=  2*(x*z-y*w);m->m[2][1]=  2*(y*z+x*w);m->m[2][2]=1-2*(x*x+y*y);m->m[2][3]=oz;
+       m->m[3][0]=  0          ;m->m[3][1]=  0          ;m->m[3][2]=  0          ;m->m[3][3]=1;
+}
+
+// LordHavoc: I got this code from:
+//http://www.doom3world.org/phpbb2/viewtopic.php?t=2884
+void Matrix4x4_FromDoom3Joint(matrix4x4_t *m, double ox, double oy, double oz, double x, double y, double z)
+{
+       double w = 1.0 - (x*x+y*y+z*z);
+       w = w > 0.0 ? -sqrt(w) : 0.0;
+       m->m[0][0]=1-2*(y*y+z*z);m->m[0][1]=  2*(x*y-z*w);m->m[0][2]=  2*(x*z+y*w);m->m[0][3]=ox;
+       m->m[1][0]=  2*(x*y+z*w);m->m[1][1]=1-2*(x*x+z*z);m->m[1][2]=  2*(y*z-x*w);m->m[1][3]=oy;
+       m->m[2][0]=  2*(x*z-y*w);m->m[2][1]=  2*(y*z+x*w);m->m[2][2]=1-2*(x*x+y*y);m->m[2][3]=oz;
+       m->m[3][0]=  0          ;m->m[3][1]=  0          ;m->m[3][2]=  0          ;m->m[3][3]=1;
+}
+
+void Matrix4x4_Blend (matrix4x4_t *out, const matrix4x4_t *in1, const matrix4x4_t *in2, double blend)
+{
+       double iblend = 1 - blend;
        out->m[0][0] = in1->m[0][0] * iblend + in2->m[0][0] * blend;
        out->m[0][1] = in1->m[0][1] * iblend + in2->m[0][1] * blend;
        out->m[0][2] = in1->m[0][2] * iblend + in2->m[0][2] * blend;
        out->m[0][0] = in1->m[0][0] * iblend + in2->m[0][0] * blend;
        out->m[0][1] = in1->m[0][1] * iblend + in2->m[0][1] * blend;
        out->m[0][2] = in1->m[0][2] * iblend + in2->m[0][2] * blend;
@@ -477,7 +609,7 @@ void Matrix4x4_Transform3x3 (const matrix4x4_t *in, const float v[3], float out[
 /*
 void Matrix4x4_SimpleUntransform (const matrix4x4_t *in, const float v[3], float out[3])
 {
 /*
 void Matrix4x4_SimpleUntransform (const matrix4x4_t *in, const float v[3], float out[3])
 {
-       float t[3];
+       double t[3];
        t[0] = v[0] - in->m[0][3];
        t[1] = v[1] - in->m[1][3];
        t[2] = v[2] - in->m[2][3];
        t[0] = v[0] - in->m[0][3];
        t[1] = v[1] - in->m[1][3];
        t[2] = v[2] - in->m[2][3];
@@ -488,7 +620,7 @@ void Matrix4x4_SimpleUntransform (const matrix4x4_t *in, const float v[3], float
 */
 
 // FIXME: optimize
 */
 
 // FIXME: optimize
-void Matrix4x4_ConcatTranslate (matrix4x4_t *out, float x, float y, float z)
+void Matrix4x4_ConcatTranslate (matrix4x4_t *out, double x, double y, double z)
 {
        matrix4x4_t base, temp;
        base = *out;
 {
        matrix4x4_t base, temp;
        base = *out;
@@ -497,7 +629,7 @@ void Matrix4x4_ConcatTranslate (matrix4x4_t *out, float x, float y, float z)
 }
 
 // FIXME: optimize
 }
 
 // FIXME: optimize
-void Matrix4x4_ConcatRotate (matrix4x4_t *out, float angle, float x, float y, float z)
+void Matrix4x4_ConcatRotate (matrix4x4_t *out, double angle, double x, double y, double z)
 {
        matrix4x4_t base, temp;
        base = *out;
 {
        matrix4x4_t base, temp;
        base = *out;
@@ -506,7 +638,7 @@ void Matrix4x4_ConcatRotate (matrix4x4_t *out, float angle, float x, float y, fl
 }
 
 // FIXME: optimize
 }
 
 // FIXME: optimize
-void Matrix4x4_ConcatScale (matrix4x4_t *out, float x)
+void Matrix4x4_ConcatScale (matrix4x4_t *out, double x)
 {
        matrix4x4_t base, temp;
        base = *out;
 {
        matrix4x4_t base, temp;
        base = *out;
@@ -515,7 +647,7 @@ void Matrix4x4_ConcatScale (matrix4x4_t *out, float x)
 }
 
 // FIXME: optimize
 }
 
 // FIXME: optimize
-void Matrix4x4_ConcatScale3 (matrix4x4_t *out, float x, float y, float z)
+void Matrix4x4_ConcatScale3 (matrix4x4_t *out, double x, double y, double z)
 {
        matrix4x4_t base, temp;
        base = *out;
 {
        matrix4x4_t base, temp;
        base = *out;
@@ -530,9 +662,23 @@ void Matrix4x4_OriginFromMatrix (const matrix4x4_t *in, float *out)
        out[2] = in->m[2][3];
 }
 
        out[2] = in->m[2][3];
 }
 
-float Matrix4x4_ScaleFromMatrix (const matrix4x4_t *in)
+double Matrix4x4_ScaleFromMatrix (const matrix4x4_t *in)
 {
        // we only support uniform scaling, so assume the first row is enough
        return (float)sqrt(in->m[0][0] * in->m[0][0] + in->m[0][1] * in->m[0][1] + in->m[0][2] * in->m[0][2]);
 }
 
 {
        // we only support uniform scaling, so assume the first row is enough
        return (float)sqrt(in->m[0][0] * in->m[0][0] + in->m[0][1] * in->m[0][1] + in->m[0][2] * in->m[0][2]);
 }
 
+void Matrix4x4_SetOrigin (matrix4x4_t *out, double x, double y, double z)
+{
+       out->m[0][3] = x;
+       out->m[1][3] = y;
+       out->m[2][3] = z;
+}
+
+void Matrix4x4_AdjustOrigin (matrix4x4_t *out, double x, double y, double z)
+{
+       out->m[0][3] += x;
+       out->m[1][3] += y;
+       out->m[2][3] += z;
+}
+
index d3d29ed1303316a2ce9e2873d459ecf485e7adfe..af2555dd1fbe9b67a4f65c503b57807b3de26fc4 100644 (file)
@@ -43,29 +43,48 @@ void Matrix4x4_Normalize (matrix4x4_t *out, matrix4x4_t *in1);
 void Matrix4x4_CreateIdentity (matrix4x4_t *out);
 // creates a translate matrix
 // (moves vectors)
 void Matrix4x4_CreateIdentity (matrix4x4_t *out);
 // creates a translate matrix
 // (moves vectors)
-void Matrix4x4_CreateTranslate (matrix4x4_t *out, float x, float y, float z);
+void Matrix4x4_CreateTranslate (matrix4x4_t *out, double x, double y, double z);
 // creates a rotate matrix
 // (rotates vectors)
 // creates a rotate matrix
 // (rotates vectors)
-void Matrix4x4_CreateRotate (matrix4x4_t *out, float angle, float x, float y, float z);
+void Matrix4x4_CreateRotate (matrix4x4_t *out, double angle, double x, double y, double z);
 // creates a scaling matrix
 // (expands or contracts vectors)
 // (warning: do not apply this kind of matrix to direction vectors)
 // creates a scaling matrix
 // (expands or contracts vectors)
 // (warning: do not apply this kind of matrix to direction vectors)
-void Matrix4x4_CreateScale (matrix4x4_t *out, float x);
+void Matrix4x4_CreateScale (matrix4x4_t *out, double x);
 // creates a squishing matrix
 // (expands or contracts vectors differently in different axis)
 // (warning: this is not reversed by Invert_Simple)
 // (warning: do not apply this kind of matrix to direction vectors)
 // creates a squishing matrix
 // (expands or contracts vectors differently in different axis)
 // (warning: this is not reversed by Invert_Simple)
 // (warning: do not apply this kind of matrix to direction vectors)
-void Matrix4x4_CreateScale3 (matrix4x4_t *out, float x, float y, float z);
+void Matrix4x4_CreateScale3 (matrix4x4_t *out, double x, double y, double z);
 // creates a matrix for a quake entity
 // creates a matrix for a quake entity
-void Matrix4x4_CreateFromQuakeEntity(matrix4x4_t *out, float x, float y, float z, float pitch, float yaw, float roll, float scale);
+void Matrix4x4_CreateFromQuakeEntity(matrix4x4_t *out, double x, double y, double z, double pitch, double yaw, double roll, double scale);
 
 // converts a matrix4x4 to a set of 3D vectors for the 3 axial directions, and the translate
 void Matrix4x4_ToVectors(const matrix4x4_t *in, float vx[3], float vy[3], float vz[3], float t[3]);
 // creates a matrix4x4 from a set of 3D vectors for axial directions, and translate
 void Matrix4x4_FromVectors(matrix4x4_t *out, const float vx[3], const float vy[3], const float vz[3], const float t[3]);
 
 
 // converts a matrix4x4 to a set of 3D vectors for the 3 axial directions, and the translate
 void Matrix4x4_ToVectors(const matrix4x4_t *in, float vx[3], float vy[3], float vz[3], float t[3]);
 // creates a matrix4x4 from a set of 3D vectors for axial directions, and translate
 void Matrix4x4_FromVectors(matrix4x4_t *out, const float vx[3], const float vy[3], const float vz[3], const float t[3]);
 
+// creates a matrix4x4 from a float[16] array in the OpenGL orientation
+void Matrix4x4_FromArrayDoubleGL(matrix4x4_t *out, const double in[16]);
+// creates a matrix4x4 from a float[16] array in the Direct3D orientation
+void Matrix4x4_FromArrayDoubleD3D(matrix4x4_t *out, const double in[16]);
+
+// converts a matrix4x4 to a float[12] array in the OpenGL orientation
+void Matrix4x4_ToArray12FloatGL(const matrix4x4_t *in, float out[12]);
+// creates a matrix4x4 from a float[12] array in the OpenGL orientation
+void Matrix4x4_FromArray12FloatGL(matrix4x4_t *out, const float in[12]);
+// converts a matrix4x4 to a float[12] array in the Direct3D orientation
+void Matrix4x4_ToArray12FloatD3D(const matrix4x4_t *in, float out[12]);
+// creates a matrix4x4 from a float[12] array in the Direct3D orientation
+void Matrix4x4_FromArray12FloatD3D(matrix4x4_t *out, const float in[12]);
+
+// creates a matrix4x4 from an origin and quaternion (used mostly with skeletal model formats such as PSK)
+void Matrix4x4_FromOriginQuat(matrix4x4_t *m, double ox, double oy, double oz, double x, double y, double z, double w);
+// creates a matrix4x4 from an origin and canonical unit-length quaternion (used mostly with skeletal model formats such as MD5)
+void Matrix4x4_FromDoom3Joint(matrix4x4_t *m, double ox, double oy, double oz, double x, double y, double z);
+
 // blends two matrices together, at a given percentage (blend controls percentage of in2)
 // blends two matrices together, at a given percentage (blend controls percentage of in2)
-void Matrix4x4_Blend (matrix4x4_t *out, const matrix4x4_t *in1, const matrix4x4_t *in2, float blend);
+void Matrix4x4_Blend (matrix4x4_t *out, const matrix4x4_t *in1, const matrix4x4_t *in2, double blend);
 
 // transforms a 3D vector through a matrix4x4
 void Matrix4x4_Transform (const matrix4x4_t *in, const float v[3], float out[3]);
 
 // transforms a 3D vector through a matrix4x4
 void Matrix4x4_Transform (const matrix4x4_t *in, const float v[3], float out[3]);
@@ -82,17 +101,22 @@ void Matrix4x4_Transform3x3 (const matrix4x4_t *in, const float v[3], float out[
 
 // ease of use functions
 // immediately applies a Translate to the matrix
 
 // ease of use functions
 // immediately applies a Translate to the matrix
-void Matrix4x4_ConcatTranslate (matrix4x4_t *out, float x, float y, float z);
+void Matrix4x4_ConcatTranslate (matrix4x4_t *out, double x, double y, double z);
 // immediately applies a Rotate to the matrix
 // immediately applies a Rotate to the matrix
-void Matrix4x4_ConcatRotate (matrix4x4_t *out, float angle, float x, float y, float z);
+void Matrix4x4_ConcatRotate (matrix4x4_t *out, double angle, double x, double y, double z);
 // immediately applies a Scale to the matrix
 // immediately applies a Scale to the matrix
-void Matrix4x4_ConcatScale (matrix4x4_t *out, float x);
+void Matrix4x4_ConcatScale (matrix4x4_t *out, double x);
 // immediately applies a Scale3 to the matrix
 // immediately applies a Scale3 to the matrix
-void Matrix4x4_ConcatScale3 (matrix4x4_t *out, float x, float y, float z);
+void Matrix4x4_ConcatScale3 (matrix4x4_t *out, double x, double y, double z);
 
 // extracts origin vector (translate) from matrix
 void Matrix4x4_OriginFromMatrix (const matrix4x4_t *in, float *out);
 // extracts scaling factor from matrix (only works for uniform scaling)
 
 // extracts origin vector (translate) from matrix
 void Matrix4x4_OriginFromMatrix (const matrix4x4_t *in, float *out);
 // extracts scaling factor from matrix (only works for uniform scaling)
-float Matrix4x4_ScaleFromMatrix (const matrix4x4_t *in);
+double Matrix4x4_ScaleFromMatrix (const matrix4x4_t *in);
+
+// replaces origin vector (translate) in matrix
+void Matrix4x4_SetOrigin (matrix4x4_t *out, double x, double y, double z);
+// moves origin vector (translate) in matrix by a simple translate
+void Matrix4x4_AdjustOrigin (matrix4x4_t *out, double x, double y, double z);
 
 #endif
 
 #endif
index d1cf3c91605a45959f539d351687d55b423bd9e4..c90dd72030fecba1296ff2b63ad428c347052ce6 100644 (file)
@@ -269,22 +269,7 @@ int Mod_Alias_GetTagMatrix(const model_t *model, int poseframe, int tagindex, ma
                        R_ConcatTransforms(boneframe + model->data_bones[tagindex].parent * 12, tempbonematrix, bonematrix);
                        tagindex = model->data_bones[tagindex].parent;
                }
                        R_ConcatTransforms(boneframe + model->data_bones[tagindex].parent * 12, tempbonematrix, bonematrix);
                        tagindex = model->data_bones[tagindex].parent;
                }
-               outmatrix->m[0][0] = bonematrix[0];
-               outmatrix->m[0][1] = bonematrix[1];
-               outmatrix->m[0][2] = bonematrix[2];
-               outmatrix->m[0][3] = bonematrix[3];
-               outmatrix->m[1][0] = bonematrix[4];
-               outmatrix->m[1][1] = bonematrix[5];
-               outmatrix->m[1][2] = bonematrix[6];
-               outmatrix->m[1][3] = bonematrix[7];
-               outmatrix->m[2][0] = bonematrix[8];
-               outmatrix->m[2][1] = bonematrix[9];
-               outmatrix->m[2][2] = bonematrix[10];
-               outmatrix->m[2][3] = bonematrix[11];
-               outmatrix->m[3][0] = 0;
-               outmatrix->m[3][1] = 0;
-               outmatrix->m[3][2] = 0;
-               outmatrix->m[3][3] = 1;
+               Matrix4x4_FromArray12FloatD3D(outmatrix, bonematrix);
        }
        else if (model->num_tags)
        {
        }
        else if (model->num_tags)
        {
@@ -1948,15 +1933,6 @@ void Mod_DARKPLACESMODEL_Load(model_t *mod, void *buffer, void *bufferend)
        loadmodel->surfmesh.isanimated = loadmodel->numframes > 1 || loadmodel->animscenes[0].framecount > 1;
 }
 
        loadmodel->surfmesh.isanimated = loadmodel->numframes > 1 || loadmodel->animscenes[0].framecount > 1;
 }
 
-static void Mod_PSKMODEL_AnimKeyToMatrix(float *origin, float *quat, matrix4x4_t *m)
-{
-       float x = quat[0], y = quat[1], z = quat[2], w = quat[3];
-       m->m[0][0]=1-2*(y*y+z*z);m->m[0][1]=  2*(x*y-z*w);m->m[0][2]=  2*(x*z+y*w);m->m[0][3]=origin[0];
-       m->m[1][0]=  2*(x*y+z*w);m->m[1][1]=1-2*(x*x+z*z);m->m[1][2]=  2*(y*z-x*w);m->m[1][3]=origin[1];
-       m->m[2][0]=  2*(x*z-y*w);m->m[2][1]=  2*(y*z+x*w);m->m[2][2]=1-2*(x*x+y*y);m->m[2][3]=origin[2];
-       m->m[3][0]=  0          ;m->m[3][1]=  0          ;m->m[3][2]=  0          ;m->m[3][3]=1;
-}
-
 // no idea why PSK/PSA files contain weird quaternions but they do...
 #define PSKQUATNEGATIONS
 void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend)
 // no idea why PSK/PSA files contain weird quaternions but they do...
 #define PSKQUATNEGATIONS
 void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend)
@@ -2476,20 +2452,10 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend)
        // load the poses from the animkeys
        for (index = 0;index < numanimkeys;index++)
        {
        // load the poses from the animkeys
        for (index = 0;index < numanimkeys;index++)
        {
+               pskanimkeys_t *k = animkeys + index;
                matrix4x4_t matrix;
                matrix4x4_t matrix;
-               Mod_PSKMODEL_AnimKeyToMatrix(animkeys[index].origin, animkeys[index].quat, &matrix);
-               loadmodel->data_poses[index*12+0] = matrix.m[0][0];
-               loadmodel->data_poses[index*12+1] = matrix.m[0][1];
-               loadmodel->data_poses[index*12+2] = matrix.m[0][2];
-               loadmodel->data_poses[index*12+3] = matrix.m[0][3];
-               loadmodel->data_poses[index*12+4] = matrix.m[1][0];
-               loadmodel->data_poses[index*12+5] = matrix.m[1][1];
-               loadmodel->data_poses[index*12+6] = matrix.m[1][2];
-               loadmodel->data_poses[index*12+7] = matrix.m[1][3];
-               loadmodel->data_poses[index*12+8] = matrix.m[2][0];
-               loadmodel->data_poses[index*12+9] = matrix.m[2][1];
-               loadmodel->data_poses[index*12+10] = matrix.m[2][2];
-               loadmodel->data_poses[index*12+11] = matrix.m[2][3];
+               Matrix4x4_FromOriginQuat(&matrix, k->origin[0], k->origin[1], k->origin[2], k->quat[0], k->quat[1], k->quat[2], k->quat[3]);
+               Matrix4x4_ToArray12FloatD3D(&matrix, loadmodel->data_poses + index*12);
        }
        Mod_FreeSkinFiles(skinfiles);
        Mem_Free(animfilebuffer);
        }
        Mod_FreeSkinFiles(skinfiles);
        Mem_Free(animfilebuffer);
index 5530a591be9f98ea92fd352257828d2aa67169f9..46a54ded5e03e141d78eba8a37af16a32f9c3e93 100644 (file)
@@ -11,9 +11,8 @@ void R_Model_Sprite_Draw_TransparentCallback(const entity_render_t *ent, const r
        float scale;
 
        // nudge it toward the view to make sure it isn't in a wall
        float scale;
 
        // nudge it toward the view to make sure it isn't in a wall
-       org[0] = ent->matrix.m[0][3] - r_view.forward[0];
-       org[1] = ent->matrix.m[1][3] - r_view.forward[1];
-       org[2] = ent->matrix.m[2][3] - r_view.forward[2];
+       Matrix4x4_OriginFromMatrix(&ent->matrix, org);
+       VectorSubtract(org, r_view.forward, org);
        switch(model->sprite.sprnum_type)
        {
        case SPR_VP_PARALLEL_UPRIGHT:
        switch(model->sprite.sprnum_type)
        {
        case SPR_VP_PARALLEL_UPRIGHT:
index 863944a3b76bfdd5f711ae5fb47bd85d9e900e38..524eb60038604cafd8a797109d809b0353f1a2fa 100644 (file)
@@ -2492,7 +2492,7 @@ int SV_GetTagMatrix (matrix4x4_t *out, prvm_edict_t *ent, int tagindex)
                        // (don't count Z, or jumping messes it up)
                        bob = sqrt(ent->fields.server->velocity[0]*ent->fields.server->velocity[0] + ent->fields.server->velocity[1]*ent->fields.server->velocity[1])*cl_bob.value;
                        bob = bob*0.3 + bob*0.7*cycle;
                        // (don't count Z, or jumping messes it up)
                        bob = sqrt(ent->fields.server->velocity[0]*ent->fields.server->velocity[0] + ent->fields.server->velocity[1]*ent->fields.server->velocity[1])*cl_bob.value;
                        bob = bob*0.3 + bob*0.7*cycle;
-                       out->m[2][3] += bound(-7, bob, 4);
+                       Matrix4x4_AdjustOrigin(out, 0, 0, bound(-7, bob, 4));
                }
                */
        }
                }
                */
        }
diff --git a/todo b/todo
index 0aea8ffb0392f7908f0866ea631e2fd94344c4fc..9a7198099c16bba49c7b6f4dc39305a7f17f7785 100644 (file)
--- a/todo
+++ b/todo
 0 feature darkplaces renderer: add rtlight "avelocity" parameter to make lights that spin, useful with cubemaps (romi)
 0 feature darkplaces renderer: make showfps display GL renderer string and CPU - figure out how to detect this from the OS
 0 feature darkplaces renderer: save r_shadow_glsl* cvars (and possibly a few others) to config because they are useful user settings (SavageX)
 0 feature darkplaces renderer: add rtlight "avelocity" parameter to make lights that spin, useful with cubemaps (romi)
 0 feature darkplaces renderer: make showfps display GL renderer string and CPU - figure out how to detect this from the OS
 0 feature darkplaces renderer: save r_shadow_glsl* cvars (and possibly a few others) to config because they are useful user settings (SavageX)
+0 feature darkplaces renderer: support tcgen in q3 shaders (ob3lisk)
 0 feature darkplaces server: DP_SV_FINDPVS
 0 feature darkplaces server: add .maxspeed field to control player movement speed in engine code, call it QW_SV_MAXSPEED (Carni)
 0 feature darkplaces server: add DP_QC_STRTOKEN extension with these functions: float strtokens(string s, string separator) = #;string strtoken(string s, string separator, float index) = #; (FrikaC)
 0 feature darkplaces server: DP_SV_FINDPVS
 0 feature darkplaces server: add .maxspeed field to control player movement speed in engine code, call it QW_SV_MAXSPEED (Carni)
 0 feature darkplaces server: add DP_QC_STRTOKEN extension with these functions: float strtokens(string s, string separator) = #;string strtoken(string s, string separator, float index) = #; (FrikaC)
diff --git a/view.c b/view.c
index 737cfdd4b36891de66d9cc2d3727bf92a62e4b3d..9506c9483bb51c58afaacaaf1b93e67eb791330f 100644 (file)
--- a/view.c
+++ b/view.c
@@ -394,7 +394,7 @@ void V_CalcRefdef (void)
                        else
                        {
                                r_view.matrix = ent->render.matrix;
                        else
                        {
                                r_view.matrix = ent->render.matrix;
-                               r_view.matrix.m[2][3] += cl.stats[STAT_VIEWHEIGHT];
+                               Matrix4x4_AdjustOrigin(&r_view.matrix, 0, 0, cl.stats[STAT_VIEWHEIGHT]);
                        }
                        viewmodelmatrix = r_view.matrix;
                }
                        }
                        viewmodelmatrix = r_view.matrix;
                }