fixed oriented sprite problems (no longer uses entity angles for them) by rewriting...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 19 Nov 2003 10:07:39 +0000 (10:07 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 19 Nov 2003 10:07:39 +0000 (10:07 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3659 d7cf8633-e32d-0410-b094-e92efae38249

r_sprites.c
todo

index 4e3df26..5529c24 100644 (file)
@@ -3,36 +3,35 @@
 
 static int R_SpriteSetup (const entity_render_t *ent, int type, float org[3], float left[3], float up[3])
 {
-       float matrix1[3][3], matrix2[3][3], matrix3[3][3];
+       float scale;
 
-       VectorCopy(ent->origin, org);
+       // nudge it toward the view to make sure it isn't in a wall
+       org[0] = ent->matrix.m[0][3] - r_viewforward[0];
+       org[1] = ent->matrix.m[1][3] - r_viewforward[1];
+       org[2] = ent->matrix.m[2][3] - r_viewforward[2];
        switch(type)
        {
        case SPR_VP_PARALLEL_UPRIGHT:
                // flames and such
                // vertical beam sprite, faces view plane
-               VectorNegate(r_viewforward, matrix3[0]);
-               matrix3[0][2] = 0;
-               VectorNormalizeFast(matrix3[0]);
-               matrix3[1][0] = matrix3[0][1];
-               matrix3[1][1] = -matrix3[0][0];
-               matrix3[1][2] = 0;
-               matrix3[2][0] = 0;
-               matrix3[2][1] = 0;
-               matrix3[2][2] = 1;
+               scale = ent->scale / sqrt(r_viewforward[0]*r_viewforward[0]+r_viewforward[1]*r_viewforward[1]);
+               left[0] = -r_viewforward[1] * scale;
+               left[1] = r_viewforward[0] * scale;
+               left[2] = 0;
+               up[0] = 0;
+               up[1] = 0;
+               up[2] = ent->scale;
                break;
        case SPR_FACING_UPRIGHT:
                // flames and such
                // vertical beam sprite, faces viewer's origin (not the view plane)
-               VectorSubtract(ent->origin, r_vieworigin, matrix3[0]);
-               matrix3[0][2] = 0;
-               VectorNormalizeFast(matrix3[0]);
-               matrix3[1][0] = matrix3[0][1];
-               matrix3[1][1] = -matrix3[0][0];
-               matrix3[1][2] = 0;
-               matrix3[2][0] = 0;
-               matrix3[2][1] = 0;
-               matrix3[2][2] = 1;
+               scale = ent->scale / sqrt((org[0] - r_vieworigin[0])*(org[0] - r_vieworigin[0])+(org[1] - r_vieworigin[1])*(org[1] - r_vieworigin[1]));
+               left[0] = (org[1] - r_vieworigin[1]) * scale;
+               left[1] = -(org[0] - r_vieworigin[0]) * scale;
+               left[2] = 0;
+               up[0] = 0;
+               up[1] = 0;
+               up[2] = ent->scale;
                break;
        default:
                Con_Printf("R_SpriteSetup: unknown sprite type %i\n", type);
@@ -40,39 +39,35 @@ static int R_SpriteSetup (const entity_render_t *ent, int type, float org[3], fl
        case SPR_VP_PARALLEL:
                // normal sprite
                // faces view plane
-               VectorCopy(r_viewforward, matrix3[0]);
-               VectorCopy(r_viewleft, matrix3[1]);
-               VectorCopy(r_viewup, matrix3[2]);
+               left[0] = r_viewleft[0] * ent->scale;
+               left[1] = r_viewleft[1] * ent->scale;
+               left[2] = r_viewleft[2] * ent->scale;
+               up[0] = r_viewup[0] * ent->scale;
+               up[1] = r_viewup[1] * ent->scale;
+               up[2] = r_viewup[2] * ent->scale;
                break;
        case SPR_ORIENTED:
                // bullet marks on walls
                // ignores viewer entirely
-               AngleVectorsFLU (ent->angles, matrix3[0], matrix3[1], matrix3[2]);
-               // nudge it toward the view, so it will be infront of the wall
-               VectorSubtract(org, r_viewforward, org);
+               left[0] = ent->matrix.m[0][1];
+               left[1] = ent->matrix.m[1][1];
+               left[2] = ent->matrix.m[2][1];
+               up[0] = ent->matrix.m[0][2];
+               up[1] = ent->matrix.m[1][2];
+               up[2] = ent->matrix.m[2][2];
                break;
        case SPR_VP_PARALLEL_ORIENTED:
-               // I have no idea what people would use this for
+               // I have no idea what people would use this for...
                // oriented relative to view space
                // FIXME: test this and make sure it mimicks software
-               AngleVectorsFLU (ent->angles, matrix1[0], matrix1[1], matrix1[2]);
-               VectorCopy(r_viewforward, matrix2[0]);
-               VectorCopy(r_viewleft, matrix2[1]);
-               VectorCopy(r_viewup, matrix2[2]);
-               R_ConcatRotations (matrix1[0], matrix2[0], matrix3[0]);
+               left[0] = ent->matrix.m[0][1] * r_viewforward[0] + ent->matrix.m[1][1] * r_viewleft[0] + ent->matrix.m[2][1] * r_viewup[0];
+               left[1] = ent->matrix.m[0][1] * r_viewforward[1] + ent->matrix.m[1][1] * r_viewleft[1] + ent->matrix.m[2][1] * r_viewup[1];
+               left[2] = ent->matrix.m[0][1] * r_viewforward[2] + ent->matrix.m[1][1] * r_viewleft[2] + ent->matrix.m[2][1] * r_viewup[2];
+               up[0] = ent->matrix.m[0][2] * r_viewforward[0] + ent->matrix.m[1][2] * r_viewleft[0] + ent->matrix.m[2][2] * r_viewup[0];
+               up[1] = ent->matrix.m[0][2] * r_viewforward[1] + ent->matrix.m[1][2] * r_viewleft[1] + ent->matrix.m[2][2] * r_viewup[1];
+               up[2] = ent->matrix.m[0][2] * r_viewforward[2] + ent->matrix.m[1][2] * r_viewleft[2] + ent->matrix.m[2][2] * r_viewup[2];
                break;
        }
-
-       if (ent->scale != 1)
-       {
-               VectorScale(matrix3[1], ent->scale, left);
-               VectorScale(matrix3[2], ent->scale, up);
-       }
-       else
-       {
-               VectorCopy(matrix3[1], left);
-               VectorCopy(matrix3[2], up);
-       }
        return false;
 }
 
diff --git a/todo b/todo
index 0036105..c89c2b7 100644 (file)
--- a/todo
+++ b/todo
@@ -63,6 +63,7 @@
 0 darkplaces: add sv_gameplayfix_swiminbmodels cvar (default 1)
 0 darkplaces: add svc_setanglefloat and DP_SVC_SETANGLEFLOAT extension (FrikaC, SeienAbunae)
 0 darkplaces: add te_flamejet builtin and add extension (Supajoe)
+0 darkplaces: add vid_vsync cvar and also to options menu (metlslime)
 0 darkplaces: alias layers should have a shadow volume pass so that nodraw textures don't cast a shadow (Electro)
 0 darkplaces: can't move when stuck in a monster (SeienAbunae)
 0 darkplaces: change particle() macro in cl_particles.c to have a do{}while(0) to eat the ;
@@ -89,6 +90,7 @@
 0 darkplaces: make dedicated server not load images (maybe all fail?)
 0 darkplaces: make fopen builtin check / as well as data/ when reading (writing would always go in data/)
 0 darkplaces: make fopen have the ability to disable fopen builtin access to read /, read data/, write data/, or disable fopen builtin entirely
+0 darkplaces: make gl_texture_anisotropy changes take effect immediately (by modifying all texparams accordingly, like gl_texturemode does).
 0 darkplaces: make lightning work without bolt models persent (Vermeulen)
 0 darkplaces: make memory pools have a flag to print them as temporary pools (I.E. consider them leaks if anything is in them) (Vicious)
 0 darkplaces: make server queries use a queue to avoid flooding out queries too fast (Willis)
@@ -409,4 +411,5 @@ f dpmod: make tarbabies have a self.resist_explosive = 3; like zombies (SeienAbu
 resolvedbug darkplaces: intermission: origin and angles are wrong: probably not getting them from entity correctly (resolved: rewrote view setup and fixed timerefresh and envmap command bugs in the process, and also fixed listener positioning during intermissions)
 resolvedbug darkplaces: intermission: statusbar disappears (resolved: not fixed, people seem to kind of prefer it this way)
 resolvedbug darkplaces: intermission: view model isn't disappearing (resolved: fixed)
+resolvedbug darkplaces: oriented sprites are not responding to angles properly (yummyluv)