mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
[renderer] Clean up r_origin and modelorg
So far, in gl and glsl, but viewposition is much clearer than r_origin (despite being the same thing), and modelorg is just confusing (I think it's the view position relative to the current model).
This commit is contained in:
parent
48c225da89
commit
075a0fe326
13 changed files with 29 additions and 43 deletions
|
@ -135,10 +135,6 @@ typedef struct vid_render_data_s {
|
|||
double frametime;
|
||||
double realtime;
|
||||
lightstyle_t *lightstyle;
|
||||
vec_t *origin;
|
||||
vec_t *vpn;
|
||||
vec_t *vright;
|
||||
vec_t *vup;
|
||||
} vid_render_data_t;
|
||||
|
||||
#endif // __QF_plugin_vid_render_h
|
||||
|
|
|
@ -81,7 +81,7 @@ R_RenderDlight (dlight_t *light)
|
|||
bub_cos = gl_bubble_costable;
|
||||
rad = light->radius * 0.35;
|
||||
|
||||
VectorSubtract (light->origin, r_origin, v);
|
||||
VectorSubtract (r_refdef.viewposition, light->origin, v);
|
||||
if (VectorLength (v) < rad) // view is inside the dlight
|
||||
return;
|
||||
|
||||
|
@ -89,7 +89,6 @@ R_RenderDlight (dlight_t *light)
|
|||
|
||||
qfglColor4fv (light->color);
|
||||
|
||||
VectorSubtract (r_origin, light->origin, v);
|
||||
VectorNormalize (v);
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
|
|
|
@ -440,8 +440,6 @@ gl_R_DrawAliasModel (entity_t *e)
|
|||
return;
|
||||
}
|
||||
|
||||
VectorSubtract (r_origin, origin, modelorg);
|
||||
|
||||
gl_modelalpha = e->renderer.colormod[3];
|
||||
|
||||
is_fullbright = (model->fullbright || e->renderer.fullbright);
|
||||
|
|
|
@ -68,8 +68,7 @@ R_DrawSpriteModel_f (entity_t *e)
|
|||
mspriteframe_t *frame;
|
||||
|
||||
origin = Transform_GetWorldPosition (e->transform);
|
||||
VectorCopy (r_origin, cameravec);
|
||||
cameravec -= origin;
|
||||
cameravec = r_refdef.viewposition - origin;
|
||||
|
||||
// don't bother culling, it's just a single polygon without a surface cache
|
||||
frame = R_GetSpriteFrame (sprite, &e->animation);
|
||||
|
|
|
@ -331,20 +331,15 @@ gl_R_SetupFrame (void)
|
|||
EntQueue_Clear (r_ent_queue);
|
||||
r_framecount++;
|
||||
|
||||
// build the transformation matrix for the given view angles
|
||||
VectorCopy (r_refdef.viewposition, r_origin);
|
||||
|
||||
VectorCopy (qvmulf (r_refdef.viewrotation, (vec4f_t) { 1, 0, 0, 0 }), vpn);
|
||||
VectorCopy (qvmulf (r_refdef.viewrotation, (vec4f_t) { 0, -1, 0, 0 }), vright);
|
||||
VectorCopy (qvmulf (r_refdef.viewrotation, (vec4f_t) { 0, 0, 1, 0 }), vup);
|
||||
|
||||
vec4f_t position = r_refdef.viewposition;
|
||||
vec4f_t rotation = r_refdef.viewrotation;
|
||||
VectorCopy (qvmulf (rotation, (vec4f_t) { 1, 0, 0, 0 }), vpn);
|
||||
VectorCopy (qvmulf (rotation, (vec4f_t) { 0, -1, 0, 0 }), vright);
|
||||
VectorCopy (qvmulf (rotation, (vec4f_t) { 0, 0, 1, 0 }), vup);
|
||||
|
||||
R_SetFrustum ();
|
||||
|
||||
// current viewleaf
|
||||
r_viewleaf = Mod_PointInLeaf (r_origin, r_worldentity.renderer.model);
|
||||
|
||||
r_cache_thrash = false;
|
||||
r_viewleaf = Mod_PointInLeaf (&position[0], r_worldentity.renderer.model);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -565,13 +565,13 @@ gl_R_DrawBrushModel (entity_t *e)
|
|||
return;
|
||||
}
|
||||
|
||||
VectorSubtract (r_refdef.viewposition, worldMatrix[3], modelorg);
|
||||
vec4f_t relviewpos = r_refdef.viewposition - worldMatrix[3];
|
||||
if (rotated) {
|
||||
vec4f_t temp = { modelorg[0], modelorg[1], modelorg[2], 0 };
|
||||
vec4f_t temp = relviewpos;
|
||||
|
||||
modelorg[0] = dotf (temp, worldMatrix[0])[0];
|
||||
modelorg[1] = dotf (temp, worldMatrix[1])[0];
|
||||
modelorg[2] = dotf (temp, worldMatrix[2])[0];
|
||||
relviewpos[0] = dotf (temp, worldMatrix[0])[0];
|
||||
relviewpos[1] = dotf (temp, worldMatrix[1])[0];
|
||||
relviewpos[2] = dotf (temp, worldMatrix[2])[0];
|
||||
}
|
||||
|
||||
// calculate dynamic lighting for bmodel if it's not an instanced model
|
||||
|
@ -601,7 +601,7 @@ gl_R_DrawBrushModel (entity_t *e)
|
|||
// find which side of the node we are on
|
||||
plane_t *plane = surf->plane;
|
||||
|
||||
dot = DotProduct (modelorg, plane->normal) - plane->dist;
|
||||
dot = DotProduct (relviewpos, plane->normal) - plane->dist;
|
||||
|
||||
// draw the polygon
|
||||
if (((surf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
|
||||
|
@ -626,10 +626,11 @@ get_side (mnode_t *node)
|
|||
{
|
||||
// find which side of the node we are on
|
||||
plane_t *plane = node->plane;
|
||||
vec4f_t org = r_refdef.viewposition;
|
||||
|
||||
if (plane->type < 3)
|
||||
return (modelorg[plane->type] - plane->dist) < 0;
|
||||
return (DotProduct (modelorg, plane->normal) - plane->dist) < 0;
|
||||
return (org[plane->type] - plane->dist) < 0;
|
||||
return (DotProduct (org, plane->normal) - plane->dist) < 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -728,8 +729,6 @@ gl_R_DrawWorld (void)
|
|||
memset (&worldent, 0, sizeof (worldent));
|
||||
worldent.renderer.model = r_worldentity.renderer.model;
|
||||
|
||||
VectorCopy (r_refdef.viewposition, modelorg);
|
||||
|
||||
sky_chain = 0;
|
||||
sky_chain_tail = &sky_chain;
|
||||
if (!gl_sky_clip->int_val) {
|
||||
|
|
|
@ -645,12 +645,13 @@ EmitSkyPolys (float speedscale, const instsurf_t *sc)
|
|||
glpoly_t *p;
|
||||
vec3_t dir;
|
||||
msurface_t *surf = sc->surface;
|
||||
vec4f_t origin = r_refdef.viewposition;
|
||||
|
||||
//FIXME transform/color
|
||||
for (p = surf->polys; p; p = p->next) {
|
||||
qfglBegin (GL_POLYGON);
|
||||
for (i = 0, v = p->verts[0]; i < p->numverts; i++, v += VERTEXSIZE) {
|
||||
VectorSubtract (v, r_origin, dir);
|
||||
VectorSubtract (v, origin, dir);
|
||||
dir[2] *= 3.0; // flatten the sphere
|
||||
|
||||
length = DotProduct (dir, dir);
|
||||
|
|
|
@ -744,10 +744,11 @@ get_side (mnode_t *node)
|
|||
{
|
||||
// find the node side on which we are
|
||||
plane_t *plane = node->plane;
|
||||
vec4f_t org = r_refdef.viewposition;
|
||||
|
||||
if (plane->type < 3)
|
||||
return (r_origin[plane->type] - plane->dist) < 0;
|
||||
return (DotProduct (r_origin, plane->normal) - plane->dist) < 0;
|
||||
return (org[plane->type] - plane->dist) < 0;
|
||||
return (DotProduct (org, plane->normal) - plane->dist) < 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -1000,7 +1001,7 @@ spin (mat4_t mat)
|
|||
QuatBlend (sky_rotation[0], sky_rotation[1], blend, q);
|
||||
QuatMult (sky_fix, q, q);
|
||||
Mat4Identity (mat);
|
||||
VectorNegate (r_origin, mat + 12);
|
||||
VectorNegate (r_refdef.viewposition, mat + 12);
|
||||
QuatToMatrix (q, m, 1, 1);
|
||||
Mat4Mult (m, mat, mat);
|
||||
}
|
||||
|
|
|
@ -100,16 +100,15 @@ glsl_R_SetupFrame (void)
|
|||
EntQueue_Clear (r_ent_queue);
|
||||
r_framecount++;
|
||||
|
||||
VectorCopy (r_refdef.viewposition, r_origin);
|
||||
vec4f_t position = r_refdef.viewposition;
|
||||
vec4f_t rotation = r_refdef.viewrotation;
|
||||
VectorCopy (qvmulf (rotation, (vec4f_t) { 1, 0, 0, 0 }), vpn);
|
||||
VectorCopy (qvmulf (rotation, (vec4f_t) { 0,-1, 0, 0 }), vright);
|
||||
VectorCopy (qvmulf (rotation, (vec4f_t) { 0, 0, 1, 0 }), vup);
|
||||
|
||||
|
||||
R_SetFrustum ();
|
||||
|
||||
r_viewleaf = Mod_PointInLeaf (r_origin, r_worldentity.renderer.model);
|
||||
r_viewleaf = Mod_PointInLeaf (&position[0], r_worldentity.renderer.model);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -229,8 +229,7 @@ glsl_R_DrawSprite (entity_t *ent)
|
|||
};
|
||||
|
||||
vec4f_t origin = Transform_GetWorldPosition (ent->transform);
|
||||
VectorCopy (r_origin, cameravec);
|
||||
cameravec -= origin;
|
||||
cameravec = r_refdef.viewposition - origin;
|
||||
|
||||
if (!R_BillboardFrame (ent, sprite->type, &cameravec[0],
|
||||
&svup[0], &svright[0], &svpn[0])) {
|
||||
|
|
|
@ -95,7 +95,7 @@ R_ZGraph (void)
|
|||
else
|
||||
w = 256;
|
||||
|
||||
height[r_framecount & 255] = ((int) r_origin[2]) & 31;
|
||||
height[r_framecount & 255] = ((int) r_refdef.viewposition[2]) & 31;
|
||||
|
||||
x = 0;
|
||||
vr_funcs->R_LineGraph (x, r_refdef.vrect.height - 2, height,
|
||||
|
|
|
@ -115,9 +115,10 @@ R_SetFrustum (void)
|
|||
RotatePointAroundVector (frustum[3].normal, vright, vpn,
|
||||
-(90 - r_refdef.fov_y / 2));
|
||||
|
||||
vec4f_t origin = r_refdef.viewposition;
|
||||
for (i = 0; i < 4; i++) {
|
||||
frustum[i].type = PLANE_ANYZ;
|
||||
frustum[i].dist = DotProduct (r_origin, frustum[i].normal);
|
||||
frustum[i].dist = DotProduct (origin, frustum[i].normal);
|
||||
frustum[i].signbits = SignbitsForPlane (&frustum[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,6 @@ vid_render_data_t vid_render_data = {
|
|||
0,
|
||||
0.0, 0.0,
|
||||
0,
|
||||
r_origin, vpn, vright, vup
|
||||
};
|
||||
|
||||
vid_render_funcs_t *vid_render_funcs;
|
||||
|
|
Loading…
Reference in a new issue