mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 15:01:41 +00:00
[renderer] Clean up use of vup/vright/vpn
This moves the common camera setup code out of the individual drivers, and completely removes vup/vright/vpn from the non-software renderers. This has highlighted the craziness around AngleVectors with it putting +X forward, -Y right and +Z up. The main issue with this is it requires a 90 degree pre-rotation about the Z axis to get the camera pointing in the right direction, and that's for the native sw renderer (vulkan needs a 90 degree pre-rotation about X, and gl and glsl need to invert an axis, too), though at least it's just a matrix swizzle and vector negation. However, it does mean the camera matrices can't be used directly. Also rename vpn to vfwd (still abbreviated, but fwd is much clearer in meaning (to me, at least) than pn (plane normal, I guess, but which way?)).
This commit is contained in:
parent
f3768e3dfb
commit
bce7d5b832
37 changed files with 172 additions and 176 deletions
|
@ -203,9 +203,17 @@ typedef struct {
|
|||
float xOrigin; // should probably always be 0.5
|
||||
float yOrigin; // between be around 0.3 to 0.5
|
||||
|
||||
//FIXME was vec3_t, need to deal with asm (maybe? is it worth it?)
|
||||
vec4f_t viewposition;
|
||||
vec4f_t viewrotation;
|
||||
union {
|
||||
mat4f_t mat;
|
||||
struct {
|
||||
vec4f_t right;
|
||||
vec4f_t forward;
|
||||
vec4f_t up;
|
||||
vec4f_t position;
|
||||
};
|
||||
} frame;
|
||||
mat4f_t camera;
|
||||
mat4f_t camera_inverse;
|
||||
|
||||
int ambientlight;
|
||||
int drawflat;
|
||||
|
|
|
@ -101,7 +101,7 @@ typedef struct
|
|||
// if the driver wants to duplicate element [0] at
|
||||
// element [nump] to avoid dealing with wrapping
|
||||
mspriteframe_t *pspriteframe;
|
||||
vec3_t vup, vright, vpn; // in worldspace
|
||||
vec3_t vup, vright, vfwd; // in worldspace
|
||||
float nearzi;
|
||||
} spritedesc_t;
|
||||
|
||||
|
|
|
@ -255,7 +255,7 @@
|
|||
|
||||
.extern C(vright)
|
||||
.extern C(vup)
|
||||
.extern C(vpn)
|
||||
.extern C(vfwd)
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ void GL_SetPalette (void *data, const byte *palette);
|
|||
void GLSL_SetPalette (void *data, const byte *palette);
|
||||
|
||||
int R_BillboardFrame (entity_t *ent, int orientation, const vec3_t cameravec,
|
||||
vec3_t bbup, vec3_t bbright, vec3_t bbpn);
|
||||
vec3_t bbup, vec3_t bbright, vec3_t bbfwd);
|
||||
mspriteframe_t *R_GetSpriteFrame (const msprite_t *sprite,
|
||||
const animation_t *animation);
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ extern byte color_white[4];
|
|||
extern byte color_black[4];
|
||||
|
||||
extern vec3_t vup, base_vup;
|
||||
extern vec3_t vpn, base_vpn;
|
||||
extern vec3_t vfwd, base_vfwd;
|
||||
extern vec3_t vright, base_vright;
|
||||
|
||||
#define NUMSTACKEDGES 2400 //2000
|
||||
|
|
|
@ -81,7 +81,7 @@ R_RenderDlight (dlight_t *light)
|
|||
bub_cos = gl_bubble_costable;
|
||||
rad = light->radius * 0.35;
|
||||
|
||||
VectorSubtract (r_refdef.viewposition, light->origin, v);
|
||||
VectorSubtract (r_refdef.frame.position, light->origin, v);
|
||||
if (VectorLength (v) < rad) // view is inside the dlight
|
||||
return;
|
||||
|
||||
|
@ -99,8 +99,8 @@ R_RenderDlight (dlight_t *light)
|
|||
|
||||
for (i = 16; i >= 0; i--) {
|
||||
for (j = 0; j < 3; j++)
|
||||
v[j] = light->origin[j] + (vright[j] * (*bub_cos) +
|
||||
vup[j] * (*bub_sin)) * rad;
|
||||
v[j] = light->origin[j] + (r_refdef.frame.right[j] * (*bub_cos) +
|
||||
r_refdef.frame.up[j] * (*bub_sin)) * rad;
|
||||
bub_sin += 2;
|
||||
bub_cos += 2;
|
||||
qfglVertex3fv (v);
|
||||
|
|
|
@ -131,7 +131,8 @@ gl_R_DrawParticles (void)
|
|||
qfglDepthMask (GL_FALSE);
|
||||
qfglInterleavedArrays (GL_T2F_C4UB_V3F, 0, particleVertexArray);
|
||||
|
||||
minparticledist = DotProduct (r_refdef.viewposition, vpn) +
|
||||
minparticledist = DotProduct (r_refdef.frame.position,
|
||||
r_refdef.frame.forward) +
|
||||
r_particles_nearclip->value;
|
||||
|
||||
vacount = 0;
|
||||
|
@ -141,7 +142,7 @@ gl_R_DrawParticles (void)
|
|||
particle_t *p = &r_psystem.particles[i];
|
||||
// Don't render particles too close to us.
|
||||
// Note, we must still do physics and such on them.
|
||||
if (!(DotProduct (p->pos, vpn) < minparticledist)) {
|
||||
if (!(DotProduct (p->pos, r_refdef.frame.forward) < minparticledist)) {
|
||||
at = (byte *) &d_8to24table[(byte) p->icolor];
|
||||
VA[0].color[0] = at[0];
|
||||
VA[0].color[1] = at[1];
|
||||
|
@ -186,8 +187,8 @@ gl_R_DrawParticles (void)
|
|||
|
||||
scale = p->scale;
|
||||
|
||||
VectorScale (vup, scale, up_scale);
|
||||
VectorScale (vright, scale, right_scale);
|
||||
VectorScale (r_refdef.frame.up, scale, up_scale);
|
||||
VectorScale (r_refdef.frame.right, scale, right_scale);
|
||||
|
||||
VectorAdd (right_scale, up_scale, up_right_scale);
|
||||
VectorSubtract (right_scale, up_scale, down_right_scale);
|
||||
|
|
|
@ -68,7 +68,7 @@ R_DrawSpriteModel_f (entity_t *e)
|
|||
mspriteframe_t *frame;
|
||||
|
||||
origin = Transform_GetWorldPosition (e->transform);
|
||||
cameravec = r_refdef.viewposition - origin;
|
||||
cameravec = r_refdef.frame.position - origin;
|
||||
|
||||
// don't bother culling, it's just a single polygon without a surface cache
|
||||
frame = R_GetSpriteFrame (sprite, &e->animation);
|
||||
|
@ -138,10 +138,10 @@ R_DrawSpriteModel_VA_f (entity_t *e)
|
|||
right = Transform_Right (e->transform);
|
||||
} else if (psprite->type == SPR_VP_PARALLEL_UPRIGHT) {
|
||||
up = (vec4f_t) { 0, 0, 1, 0 };
|
||||
VectorCopy (vright, right);
|
||||
VectorCopy (r_refdef.frame.right, right);
|
||||
} else { // normal sprite
|
||||
VectorCopy (vup, up);
|
||||
VectorCopy (vright, right);
|
||||
VectorCopy (r_refdef.frame.up, up);
|
||||
VectorCopy (r_refdef.frame.right, right);
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
|
|
|
@ -331,11 +331,7 @@ gl_R_SetupFrame (void)
|
|||
EntQueue_Clear (r_ent_queue);
|
||||
r_framecount++;
|
||||
|
||||
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);
|
||||
vec4f_t position = r_refdef.frame.position;
|
||||
|
||||
R_SetFrustum ();
|
||||
|
||||
|
@ -409,11 +405,7 @@ R_SetupGL (void)
|
|||
{ 0, 0, 0, 1},
|
||||
};
|
||||
mat4f_t view;
|
||||
mat4fquat (view, qconjf (r_refdef.viewrotation));
|
||||
mmulf (view, z_up, view);
|
||||
vec4f_t offset = -r_refdef.viewposition;
|
||||
offset[3] = 1;
|
||||
view[3] = mvmulf (view, offset);
|
||||
mmulf (view, z_up, r_refdef.camera_inverse);
|
||||
qfglLoadMatrixf (&view[0][0]);
|
||||
|
||||
qfglGetFloatv (GL_MODELVIEW_MATRIX, gl_r_world_matrix);
|
||||
|
|
|
@ -565,7 +565,7 @@ gl_R_DrawBrushModel (entity_t *e)
|
|||
return;
|
||||
}
|
||||
|
||||
vec4f_t relviewpos = r_refdef.viewposition - worldMatrix[3];
|
||||
vec4f_t relviewpos = r_refdef.frame.position - worldMatrix[3];
|
||||
if (rotated) {
|
||||
vec4f_t temp = relviewpos;
|
||||
|
||||
|
@ -626,7 +626,7 @@ 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;
|
||||
vec4f_t org = r_refdef.frame.position;
|
||||
|
||||
if (plane->type < 3)
|
||||
return (org[plane->type] - plane->dist) < 0;
|
||||
|
|
|
@ -189,9 +189,9 @@ R_DrawSkyBox (void)
|
|||
float *v = (float *) gl_skyvec[i][j];
|
||||
|
||||
qfglTexCoord2fv (v);
|
||||
qfglVertex3f (r_refdef.viewposition[0] + v[2],
|
||||
r_refdef.viewposition[1] + v[3],
|
||||
r_refdef.viewposition[2] + v[4]);
|
||||
qfglVertex3f (r_refdef.frame.position[0] + v[2],
|
||||
r_refdef.frame.position[1] + v[3],
|
||||
r_refdef.frame.position[2] + v[4]);
|
||||
}
|
||||
qfglEnd ();
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ skydome_vertex (const vec3_t v, float speedscale)
|
|||
s = speedscale + dir[0];
|
||||
t = speedscale + dir[1];
|
||||
|
||||
VectorAdd (r_refdef.viewposition, v, point);
|
||||
VectorAdd (r_refdef.frame.position, v, point);
|
||||
|
||||
qfglTexCoord2f (s, t);
|
||||
qfglVertex3fv (point);
|
||||
|
@ -242,7 +242,7 @@ skydome_debug (void)
|
|||
|
||||
h = 1;
|
||||
t = 0;
|
||||
VectorAdd (zenith, r_refdef.viewposition, v[0]);
|
||||
VectorAdd (zenith, r_refdef.frame.position, v[0]);
|
||||
for (b = 1; b <= 8; b++) {
|
||||
x = gl_bubble_costable[b + 8];
|
||||
y = -gl_bubble_sintable[b + 8];
|
||||
|
@ -250,7 +250,7 @@ skydome_debug (void)
|
|||
v[h][0] = a1x * x;
|
||||
v[h][1] = a1y * x;
|
||||
v[h][2] = y * domescale[2];
|
||||
VectorAdd (v[h], r_refdef.viewposition, v[h]);
|
||||
VectorAdd (v[h], r_refdef.frame.position, v[h]);
|
||||
for (i = t; i != h; i = (i + 1) % 3) {
|
||||
qfglVertex3fv (v[i]);
|
||||
qfglVertex3fv (v[h]);
|
||||
|
@ -262,7 +262,7 @@ skydome_debug (void)
|
|||
v[h][0] = a2x * x;
|
||||
v[h][1] = a2y * x;
|
||||
v[h][2] = y * domescale[2];
|
||||
VectorAdd (v[h], r_refdef.viewposition, v[h]);
|
||||
VectorAdd (v[h], r_refdef.frame.position, v[h]);
|
||||
for (i = t; i != h; i = (i + 1) % 3) {
|
||||
qfglVertex3fv (v[i]);
|
||||
qfglVertex3fv (v[h]);
|
||||
|
@ -274,7 +274,7 @@ skydome_debug (void)
|
|||
|
||||
h = 1;
|
||||
t = 0;
|
||||
VectorAdd (nadir, r_refdef.viewposition, v[0]);
|
||||
VectorAdd (nadir, r_refdef.frame.position, v[0]);
|
||||
for (b = 15; b >= 8; b--) {
|
||||
x = gl_bubble_costable[b + 8];
|
||||
y = -gl_bubble_sintable[b + 8];
|
||||
|
@ -282,7 +282,7 @@ skydome_debug (void)
|
|||
v[h][0] = a2x * x;
|
||||
v[h][1] = a2y * x;
|
||||
v[h][2] = y * domescale[2];
|
||||
VectorAdd (v[h], r_refdef.viewposition, v[h]);
|
||||
VectorAdd (v[h], r_refdef.frame.position, v[h]);
|
||||
for (i = t; i != h; i = (i + 1) % 3) {
|
||||
qfglVertex3fv (v[i]);
|
||||
qfglVertex3fv (v[h]);
|
||||
|
@ -294,7 +294,7 @@ skydome_debug (void)
|
|||
v[h][0] = a1x * x;
|
||||
v[h][1] = a1y * x;
|
||||
v[h][2] = y * domescale[2];
|
||||
VectorAdd (v[h], r_refdef.viewposition, v[h]);
|
||||
VectorAdd (v[h], r_refdef.frame.position, v[h]);
|
||||
for (i = t; i != h; i = (i + 1) % 3) {
|
||||
qfglVertex3fv (v[i]);
|
||||
qfglVertex3fv (v[h]);
|
||||
|
|
|
@ -220,14 +220,14 @@ find_cube_vertex (int face1, int face2, int face3, vec3_t v)
|
|||
set_vertex
|
||||
|
||||
add the vertex to the polygon describing the face of the cube. Offsets
|
||||
the vertex relative to r_refdef.viewposition so the cube is always centered
|
||||
the vertex relative to r_refdef.frame.position so the cube is always centered
|
||||
on the player and also calculates the texture coordinates of the vertex
|
||||
(wish I could find a cleaner way of calculating s and t).
|
||||
*/
|
||||
static void
|
||||
set_vertex (struct box_def *box, int face, int ind, const vec3_t v)
|
||||
{
|
||||
VectorAdd (v, r_refdef.viewposition, box->face[face].poly.verts[ind]);
|
||||
VectorAdd (v, r_refdef.frame.position, box->face[face].poly.verts[ind]);
|
||||
switch (face) {
|
||||
case 0:
|
||||
box->face[face].poly.verts[ind][3] = (1024 - v[1] + 4) / BOX_WIDTH;
|
||||
|
@ -601,14 +601,14 @@ R_DrawSkyBoxPoly (const glpoly_t *poly)
|
|||
Sys_Error ("too many verts!");
|
||||
}
|
||||
|
||||
VectorSubtract (poly->verts[poly->numverts - 1], r_refdef.viewposition, last_v);
|
||||
VectorSubtract (poly->verts[poly->numverts - 1], r_refdef.frame.position, last_v);
|
||||
prev_face = determine_face (last_v);
|
||||
|
||||
box.visited_faces[0].face = prev_face;
|
||||
box.face_count = 1;
|
||||
|
||||
for (i = 0; i < poly->numverts; i++) {
|
||||
VectorSubtract (poly->verts[i], r_refdef.viewposition, v);
|
||||
VectorSubtract (poly->verts[i], r_refdef.frame.position, v);
|
||||
face = determine_face (v);
|
||||
if (face != prev_face) {
|
||||
if ((face_axis[face]) == (face_axis[prev_face])) {
|
||||
|
@ -645,7 +645,7 @@ EmitSkyPolys (float speedscale, const instsurf_t *sc)
|
|||
glpoly_t *p;
|
||||
vec3_t dir;
|
||||
msurface_t *surf = sc->surface;
|
||||
vec4f_t origin = r_refdef.viewposition;
|
||||
vec4f_t origin = r_refdef.frame.position;
|
||||
|
||||
//FIXME transform/color
|
||||
for (p = surf->polys; p; p = p->next) {
|
||||
|
@ -865,11 +865,11 @@ gl_R_DrawSkyChain (const instsurf_t *sky_chain)
|
|||
vec3_t x, c = { 0, 0, 0 };
|
||||
|
||||
for (i = 0; i < p->numverts; i++) {
|
||||
VectorSubtract (p->verts[i], r_refdef.viewposition, x);
|
||||
VectorSubtract (p->verts[i], r_refdef.frame.position, x);
|
||||
VectorAdd (x, c, c);
|
||||
}
|
||||
VectorScale (c, 1.0 / p->numverts, c);
|
||||
VectorAdd (c, r_refdef.viewposition, c);
|
||||
VectorAdd (c, r_refdef.frame.position, c);
|
||||
qfglVertex3fv (c);
|
||||
p = p->next;
|
||||
}
|
||||
|
@ -890,7 +890,7 @@ gl_R_DrawSkyChain (const instsurf_t *sky_chain)
|
|||
qfglBegin (GL_LINE_LOOP);
|
||||
for (j = 0; j < 4; j++) {
|
||||
VectorScale (&gl_skyvec[i][j][2], 1.0 / 128.0, v);
|
||||
VectorAdd (v, r_refdef.viewposition, v);
|
||||
VectorAdd (v, r_refdef.frame.position, v);
|
||||
qfglVertex3fv (v);
|
||||
}
|
||||
qfglEnd ();
|
||||
|
|
|
@ -691,7 +691,7 @@ R_DrawBrushModel (entity_t *e)
|
|||
return;
|
||||
}
|
||||
|
||||
org = r_refdef.viewposition - mat[3];
|
||||
org = r_refdef.frame.position - mat[3];
|
||||
if (rotated) {
|
||||
vec4f_t temp = org;
|
||||
|
||||
|
@ -744,7 +744,7 @@ get_side (mnode_t *node)
|
|||
{
|
||||
// find the node side on which we are
|
||||
plane_t *plane = node->plane;
|
||||
vec4f_t org = r_refdef.viewposition;
|
||||
vec4f_t org = r_refdef.frame.position;
|
||||
|
||||
if (plane->type < 3)
|
||||
return (org[plane->type] - plane->dist) < 0;
|
||||
|
@ -1001,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_refdef.viewposition, mat + 12);
|
||||
VectorNegate (r_refdef.frame.position, mat + 12);
|
||||
QuatToMatrix (q, m, 1, 1);
|
||||
Mat4Mult (m, mat, mat);
|
||||
}
|
||||
|
|
|
@ -100,11 +100,7 @@ glsl_R_SetupFrame (void)
|
|||
EntQueue_Clear (r_ent_queue);
|
||||
r_framecount++;
|
||||
|
||||
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);
|
||||
vec4f_t position = r_refdef.frame.position;
|
||||
|
||||
R_SetFrustum ();
|
||||
|
||||
|
@ -121,7 +117,6 @@ R_SetupView (void)
|
|||
{ 0, 1, 0, 0},
|
||||
{ 0, 0, 0, 1},
|
||||
};
|
||||
vec4f_t offset = { 0, 0, 0, 1 };
|
||||
|
||||
x = r_refdef.vrect.x;
|
||||
y = (vid.height - (r_refdef.vrect.y + r_refdef.vrect.height));
|
||||
|
@ -129,11 +124,7 @@ R_SetupView (void)
|
|||
h = r_refdef.vrect.height;
|
||||
qfeglViewport (x, y, w, h);
|
||||
|
||||
mat4fquat (glsl_view, qconjf (r_refdef.viewrotation));
|
||||
mmulf (glsl_view, z_up, glsl_view);
|
||||
offset = -r_refdef.viewposition;
|
||||
offset[3] = 1;
|
||||
glsl_view[3] = mvmulf (glsl_view, offset);
|
||||
mmulf (glsl_view, z_up, r_refdef.camera_inverse);
|
||||
|
||||
qfeglEnable (GL_CULL_FACE);
|
||||
qfeglEnable (GL_DEPTH_TEST);
|
||||
|
|
|
@ -251,7 +251,8 @@ draw_qf_particles (void)
|
|||
// LordHavoc: particles should not affect zbuffer
|
||||
qfeglDepthMask (GL_FALSE);
|
||||
|
||||
minparticledist = DotProduct (r_refdef.viewposition, vpn) +
|
||||
minparticledist = DotProduct (r_refdef.frame.position,
|
||||
r_refdef.frame.forward) +
|
||||
r_particles_nearclip->value;
|
||||
|
||||
vacount = 0;
|
||||
|
@ -261,7 +262,7 @@ draw_qf_particles (void)
|
|||
particle_t *p = &r_psystem.particles[i];
|
||||
// Don't render particles too close to us.
|
||||
// Note, we must still do physics and such on them.
|
||||
if (!(DotProduct (p->pos, vpn) < minparticledist)) {
|
||||
if (!(DotProduct (p->pos, r_refdef.frame.forward) < minparticledist)) {
|
||||
at = (byte *) &d_8to24table[(byte) p->icolor];
|
||||
VA[0].color[0] = at[0];
|
||||
VA[0].color[1] = at[1];
|
||||
|
@ -306,8 +307,8 @@ draw_qf_particles (void)
|
|||
|
||||
scale = p->scale;
|
||||
|
||||
VectorScale (vup, scale, up_scale);
|
||||
VectorScale (vright, scale, right_scale);
|
||||
VectorScale (r_refdef.frame.up, scale, up_scale);
|
||||
VectorScale (r_refdef.frame.right, scale, right_scale);
|
||||
|
||||
VectorAdd (right_scale, up_scale, up_right_scale);
|
||||
VectorSubtract (right_scale, up_scale, down_right_scale);
|
||||
|
@ -370,7 +371,8 @@ draw_id_particles (void)
|
|||
qfeglEnable (GL_TEXTURE_2D);
|
||||
qfeglBindTexture (GL_TEXTURE_2D, glsl_palette);
|
||||
|
||||
minparticledist = DotProduct (r_refdef.viewposition, vpn) +
|
||||
minparticledist = DotProduct (r_refdef.frame.position,
|
||||
r_refdef.frame.forward) +
|
||||
r_particles_nearclip->value;
|
||||
|
||||
vacount = 0;
|
||||
|
@ -380,7 +382,7 @@ draw_id_particles (void)
|
|||
particle_t *p = &r_psystem.particles[i];
|
||||
// Don't render particles too close to us.
|
||||
// Note, we must still do physics and such on them.
|
||||
if (!(DotProduct (p->pos, vpn) < minparticledist)) {
|
||||
if (!(DotProduct (p->pos, r_refdef.frame.forward) < minparticledist)) {
|
||||
VA[0].color[0] = (byte) p->icolor;
|
||||
VectorCopy (p->pos, VA[0].vertex);
|
||||
VA++;
|
||||
|
|
|
@ -229,7 +229,7 @@ glsl_R_DrawSprite (entity_t *ent)
|
|||
};
|
||||
|
||||
vec4f_t origin = Transform_GetWorldPosition (ent->transform);
|
||||
cameravec = r_refdef.viewposition - origin;
|
||||
cameravec = r_refdef.frame.position - origin;
|
||||
|
||||
if (!R_BillboardFrame (ent, sprite->type, &cameravec[0],
|
||||
&svup[0], &svright[0], &svpn[0])) {
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
int
|
||||
R_BillboardFrame (entity_t *ent, int orientation, const vec3_t cameravec,
|
||||
vec3_t bbup, vec3_t bbright, vec3_t bbpn)
|
||||
vec3_t bbup, vec3_t bbright, vec3_t bbfwd)
|
||||
{
|
||||
vec3_t tvec;
|
||||
float dot;
|
||||
|
@ -66,28 +66,26 @@ R_BillboardFrame (entity_t *ent, int orientation, const vec3_t cameravec,
|
|||
//CrossProduct(bbup, -cameravec, bbright)
|
||||
VectorSet (tvec[1], -tvec[0], 0, bbright);
|
||||
VectorNormalize (bbright);
|
||||
//CrossProduct (bbright, bbup, bbpn)
|
||||
VectorSet (-bbright[1], bbright[0], 0, bbpn);
|
||||
//CrossProduct (bbright, bbup, bbfwd)
|
||||
VectorSet (-bbright[1], bbright[0], 0, bbfwd);
|
||||
break;
|
||||
case SPR_VP_PARALLEL:
|
||||
// the billboard always has the same orientation as the camera
|
||||
VectorCopy (vup, bbup);
|
||||
VectorCopy (vright, bbright);
|
||||
VectorCopy (vpn, bbpn);
|
||||
VectorCopy (r_refdef.frame.up, bbup);
|
||||
VectorCopy (r_refdef.frame.right, bbright);
|
||||
VectorCopy (r_refdef.frame.forward, bbfwd);
|
||||
break;
|
||||
case SPR_VP_PARALLEL_UPRIGHT:
|
||||
// the billboar has its up vector parallel with world up, and
|
||||
// its right vector parallel with the view plane.
|
||||
// Undefined if the camera is looking straight up or down.
|
||||
dot = vpn[2]; // DotProduct (vpn, world up)
|
||||
dot = r_refdef.frame.forward[2];
|
||||
if ((dot > 0.999848) || (dot < -0.999848)) // cos(1 degree)
|
||||
return 0;
|
||||
VectorSet (0, 0, 1, bbup);
|
||||
//CrossProduct(bbup, vpn, bbright)
|
||||
VectorSet (vpn[1], -vpn[0], 0, bbright);
|
||||
VectorSet (r_refdef.frame.forward[1], -r_refdef.frame.forward[0], 0, bbright);
|
||||
VectorNormalize (bbright);
|
||||
//CrossProduct (bbright, bbup, bbpn)
|
||||
VectorSet (-bbright[1], bbright[0], 0, bbpn);
|
||||
VectorSet (-bbright[1], bbright[0], 0, bbfwd);
|
||||
break;
|
||||
case SPR_ORIENTED:
|
||||
{
|
||||
|
@ -95,7 +93,7 @@ R_BillboardFrame (entity_t *ent, int orientation, const vec3_t cameravec,
|
|||
// entity's orientation.
|
||||
mat4f_t mat;
|
||||
Transform_GetWorldMatrix (ent->transform, mat);
|
||||
VectorCopy (mat[0], bbpn);
|
||||
VectorCopy (mat[0], bbfwd);
|
||||
VectorNegate (mat[1], bbright);
|
||||
VectorCopy (mat[2], bbup);
|
||||
}
|
||||
|
@ -104,13 +102,15 @@ R_BillboardFrame (entity_t *ent, int orientation, const vec3_t cameravec,
|
|||
{
|
||||
// The billboard is rotated relative to the camera using
|
||||
// the entity's local rotation.
|
||||
vec4f_t rot = Transform_GetLocalRotation (ent->transform);
|
||||
mat4f_t entmat;
|
||||
mat4f_t spmat;
|
||||
Transform_GetLocalMatrix (ent->transform, entmat);
|
||||
// FIXME needs proper testing (need to find, make, or fake a
|
||||
// parallel oriented sprite)
|
||||
rot = qmulf (r_refdef.viewrotation, rot);
|
||||
QuatMultVec (&rot[0], vpn, bbpn);
|
||||
QuatMultVec (&rot[0], vright, bbright);
|
||||
QuatMultVec (&rot[0], vup, bbup);
|
||||
mmulf (spmat, r_refdef.camera, entmat);
|
||||
VectorCopy (spmat[0], bbfwd);
|
||||
VectorNegate (spmat[1], bbright);
|
||||
VectorCopy (spmat[1], bbup);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -95,7 +95,7 @@ R_ZGraph (void)
|
|||
else
|
||||
w = 256;
|
||||
|
||||
height[r_framecount & 255] = ((int) r_refdef.viewposition[2]) & 31;
|
||||
height[r_framecount & 255] = ((int) r_refdef.frame.position[2]) & 31;
|
||||
|
||||
x = 0;
|
||||
vr_funcs->R_LineGraph (x, r_refdef.vrect.height - 2, height,
|
||||
|
|
|
@ -67,11 +67,6 @@ vec3_t r_entorigin; // the currently rendering entity in world
|
|||
// coordinates
|
||||
entity_t r_worldentity;
|
||||
|
||||
// view origin
|
||||
vec3_t vup, base_vup;
|
||||
vec3_t vpn, base_vpn;
|
||||
vec3_t vright, base_vright;
|
||||
|
||||
// screen size info
|
||||
refdef_t r_refdef;
|
||||
|
||||
|
@ -99,21 +94,24 @@ void
|
|||
R_SetFrustum (void)
|
||||
{
|
||||
int i;
|
||||
vec4f_t vright = r_refdef.frame.right;
|
||||
vec4f_t vfwd = r_refdef.frame.forward;
|
||||
vec4f_t vup = r_refdef.frame.up;
|
||||
|
||||
// rotate VPN right by FOV_X/2 degrees
|
||||
RotatePointAroundVector (frustum[0].normal, vup, vpn,
|
||||
RotatePointAroundVector (frustum[0].normal, &vup[0], &vfwd[0],
|
||||
-(90 - r_refdef.fov_x / 2));
|
||||
// rotate VPN left by FOV_X/2 degrees
|
||||
RotatePointAroundVector (frustum[1].normal, vup, vpn,
|
||||
RotatePointAroundVector (frustum[1].normal, &vup[0], &vfwd[0],
|
||||
90 - r_refdef.fov_x / 2);
|
||||
// rotate VPN up by FOV_Y/2 degrees
|
||||
RotatePointAroundVector (frustum[2].normal, vright, vpn,
|
||||
RotatePointAroundVector (frustum[2].normal, &vright[0], &vfwd[0],
|
||||
90 - r_refdef.fov_y / 2);
|
||||
// rotate VPN down by FOV_Y/2 degrees
|
||||
RotatePointAroundVector (frustum[3].normal, vright, vpn,
|
||||
RotatePointAroundVector (frustum[3].normal, &vright[0], &vfwd[0],
|
||||
-(90 - r_refdef.fov_y / 2));
|
||||
|
||||
vec4f_t origin = r_refdef.viewposition;
|
||||
vec4f_t origin = r_refdef.frame.position;
|
||||
for (i = 0; i < 4; i++) {
|
||||
frustum[i].type = PLANE_ANYZ;
|
||||
frustum[i].dist = DotProduct (origin, frustum[i].normal);
|
||||
|
|
|
@ -161,12 +161,23 @@ SCR_UpdateScreen (transform_t *camera, double realtime, SCR_Func *scr_funcs)
|
|||
}
|
||||
|
||||
if (camera) {
|
||||
r_data->refdef->viewposition = Transform_GetWorldPosition (camera);
|
||||
r_data->refdef->viewrotation = Transform_GetWorldRotation (camera);
|
||||
Transform_GetWorldMatrix (camera, r_data->refdef->camera);
|
||||
Transform_GetWorldInverse (camera, r_data->refdef->camera_inverse);
|
||||
} else {
|
||||
r_data->refdef->viewposition = (vec4f_t) { 0, 0, 0, 1 };
|
||||
r_data->refdef->viewrotation = (vec4f_t) { 0, 0, 0, 1 };
|
||||
mat4fidentity (r_data->refdef->camera);
|
||||
mat4fidentity (r_data->refdef->camera_inverse);
|
||||
}
|
||||
// FIXME pre-rotate the camera 90 degrees about the z axis such that the
|
||||
// camera forward vector (camera Y) points along the world +X axis and the
|
||||
// camera right vector (camera X) points along the world -Y axis. This
|
||||
// should not be necessary here but is due to AngleVectors (and thus
|
||||
// AngleQuat for compatibility) treating X as forward and Y as left (or -Y
|
||||
// as right). Fixing this would take an audit of the usage of both, but is
|
||||
// probably worthwhile in the long run.
|
||||
r_data->refdef->frame.mat[0] = -r_data->refdef->camera[1];
|
||||
r_data->refdef->frame.mat[1] = r_data->refdef->camera[0];
|
||||
r_data->refdef->frame.mat[2] = r_data->refdef->camera[2];
|
||||
r_data->refdef->frame.mat[3] = r_data->refdef->camera[3];
|
||||
|
||||
r_data->realtime = realtime;
|
||||
scr_copytop = r_data->scr_copyeverything = 0;
|
||||
|
|
|
@ -151,7 +151,7 @@ D_DrawSurfaces (void)
|
|||
msurface_t *pface;
|
||||
surfcache_t *pcurrentcache;
|
||||
vec3_t world_transformed_modelorg;
|
||||
vec3_t local_modelorg;
|
||||
vec4f_t local_modelorg;
|
||||
|
||||
TransformVector (modelorg, transformed_modelorg);
|
||||
VectorCopy (transformed_modelorg, world_transformed_modelorg);
|
||||
|
@ -208,9 +208,9 @@ D_DrawSurfaces (void)
|
|||
// TODO: store once at start of frame
|
||||
transform_t *transform = s->entity->transform;
|
||||
transform = s->entity->transform;
|
||||
VectorSubtract (r_refdef.viewposition,
|
||||
Transform_GetWorldPosition (transform), local_modelorg);
|
||||
TransformVector (local_modelorg, transformed_modelorg);
|
||||
local_modelorg = r_refdef.frame.position -
|
||||
Transform_GetWorldPosition (transform);
|
||||
TransformVector (&local_modelorg[0], transformed_modelorg);
|
||||
|
||||
R_RotateBmodel (transform); // FIXME: don't mess with the
|
||||
// frustum, make entity passed in
|
||||
|
@ -228,7 +228,7 @@ D_DrawSurfaces (void)
|
|||
|
||||
VectorCopy (world_transformed_modelorg,
|
||||
transformed_modelorg);
|
||||
VectorCopy (base_vpn, vpn);
|
||||
VectorCopy (base_vfwd, vfwd);
|
||||
VectorCopy (base_vup, vup);
|
||||
VectorCopy (base_vright, vright);
|
||||
VectorCopy (base_modelorg, modelorg);
|
||||
|
@ -239,9 +239,9 @@ D_DrawSurfaces (void)
|
|||
// FIXME: we don't want to do all this for every polygon!
|
||||
// TODO: store once at start of frame
|
||||
transform_t *transform = s->entity->transform;
|
||||
VectorSubtract (r_refdef.viewposition,
|
||||
Transform_GetWorldPosition (transform), local_modelorg);
|
||||
TransformVector (local_modelorg, transformed_modelorg);
|
||||
local_modelorg = r_refdef.frame.position -
|
||||
Transform_GetWorldPosition (transform);
|
||||
TransformVector (&local_modelorg[0], transformed_modelorg);
|
||||
|
||||
R_RotateBmodel (transform); // FIXME: don't mess with the
|
||||
// frustum, make entity passed in
|
||||
|
@ -270,7 +270,7 @@ D_DrawSurfaces (void)
|
|||
|
||||
VectorCopy (world_transformed_modelorg,
|
||||
transformed_modelorg);
|
||||
VectorCopy (base_vpn, vpn);
|
||||
VectorCopy (base_vfwd, vfwd);
|
||||
VectorCopy (base_vup, vup);
|
||||
VectorCopy (base_vright, vright);
|
||||
VectorCopy (base_modelorg, modelorg);
|
||||
|
|
|
@ -53,9 +53,9 @@ D_Sky_uv_To_st (int u, int v, fixed16_t *s, fixed16_t *t)
|
|||
wu = 8192.0 * (float) (u - half_width) / temp;
|
||||
wv = 8192.0 * (float) (half_height - v) / temp;
|
||||
|
||||
end[0] = 4096 * vpn[0] + wu * vright[0] + wv * vup[0];
|
||||
end[1] = 4096 * vpn[1] + wu * vright[1] + wv * vup[1];
|
||||
end[2] = 4096 * vpn[2] + wu * vright[2] + wv * vup[2];
|
||||
end[0] = 4096 * vfwd[0] + wu * vright[0] + wv * vup[0];
|
||||
end[1] = 4096 * vfwd[1] + wu * vright[1] + wv * vup[1];
|
||||
end[2] = 4096 * vfwd[2] + wu * vright[2] + wv * vup[2];
|
||||
end[2] *= 3;
|
||||
VectorNormalize (end);
|
||||
|
||||
|
|
|
@ -328,12 +328,12 @@ D_SpriteCalculateGradients (const vec3_t relvieworg)
|
|||
vec3_t p_normal, p_saxis, p_taxis, p_temp1;
|
||||
float distinv;
|
||||
|
||||
TransformVector (r_spritedesc.vpn, p_normal);
|
||||
TransformVector (r_spritedesc.vfwd, p_normal);
|
||||
TransformVector (r_spritedesc.vright, p_saxis);
|
||||
TransformVector (r_spritedesc.vup, p_taxis);
|
||||
VectorNegate (p_taxis, p_taxis);
|
||||
|
||||
distinv = 1.0 / (-DotProduct (relvieworg, r_spritedesc.vpn));
|
||||
distinv = 1.0 / (-DotProduct (relvieworg, r_spritedesc.vfwd));
|
||||
|
||||
d_sdivzstepu = p_saxis[0] * xscaleinv;
|
||||
d_tdivzstepu = p_taxis[0] * xscaleinv;
|
||||
|
|
|
@ -382,9 +382,9 @@ R_AliasSetUpTransform (entity_t *ent, int trivial_accept)
|
|||
t2matrix[i][2] = alias_up[i];
|
||||
}
|
||||
|
||||
t2matrix[0][3] = r_entorigin[0] - r_refdef.viewposition[0];
|
||||
t2matrix[1][3] = r_entorigin[1] - r_refdef.viewposition[1];
|
||||
t2matrix[2][3] = r_entorigin[2] - r_refdef.viewposition[2];
|
||||
t2matrix[0][3] = r_entorigin[0] - r_refdef.frame.position[0];
|
||||
t2matrix[1][3] = r_entorigin[1] - r_refdef.frame.position[1];
|
||||
t2matrix[2][3] = r_entorigin[2] - r_refdef.frame.position[2];
|
||||
|
||||
// FIXME: can do more efficiently than full concatenation
|
||||
R_ConcatTransforms (t2matrix, tmatrix, rotationmatrix);
|
||||
|
@ -393,7 +393,7 @@ R_AliasSetUpTransform (entity_t *ent, int trivial_accept)
|
|||
VectorCopy (vright, viewmatrix[0]);
|
||||
VectorCopy (vup, viewmatrix[1]);
|
||||
VectorNegate (viewmatrix[1], viewmatrix[1]);
|
||||
VectorCopy (vpn, viewmatrix[2]);
|
||||
VectorCopy (vfwd, viewmatrix[2]);
|
||||
|
||||
// viewmatrix[0][3] = 0;
|
||||
// viewmatrix[1][3] = 0;
|
||||
|
|
|
@ -87,7 +87,7 @@ R_RotateBmodel (transform_t *transform)
|
|||
|
||||
// rotate modelorg and the transformation matrix
|
||||
R_EntityRotate (modelorg);
|
||||
R_EntityRotate (vpn);
|
||||
R_EntityRotate (vfwd);
|
||||
R_EntityRotate (vright);
|
||||
R_EntityRotate (vup);
|
||||
|
||||
|
@ -360,7 +360,7 @@ 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;
|
||||
vec4f_t org = r_refdef.frame.position;
|
||||
|
||||
if (plane->type < 3)
|
||||
return (org[plane->type] - plane->dist) < 0;
|
||||
|
|
|
@ -738,7 +738,7 @@ LTransformAndProject:
|
|||
//
|
||||
// lzi0 = 1.0 / transformed[2];
|
||||
fld %st(0) // local[0] | local[0] | local[1] | local[2]
|
||||
fmuls C(vpn)+0 // zm0 | local[0] | local[1] | local[2]
|
||||
fmuls C(vfwd)+0 // zm0 | local[0] | local[1] | local[2]
|
||||
fld %st(1) // local[0] | zm0 | local[0] | local[1] |
|
||||
// local[2]
|
||||
fmuls C(vright)+0 // xm0 | zm0 | local[0] | local[1] | local[2]
|
||||
|
@ -746,7 +746,7 @@ LTransformAndProject:
|
|||
fmuls C(vup)+0 // ym0 | zm0 | xm0 | local[1] | local[2]
|
||||
fld %st(3) // local[1] | ym0 | zm0 | xm0 | local[1] |
|
||||
// local[2]
|
||||
fmuls C(vpn)+4 // zm1 | ym0 | zm0 | xm0 | local[1] |
|
||||
fmuls C(vfwd)+4 // zm1 | ym0 | zm0 | xm0 | local[1] |
|
||||
// local[2]
|
||||
fld %st(4) // local[1] | zm1 | ym0 | zm0 | xm0 |
|
||||
// local[1] | local[2]
|
||||
|
@ -763,7 +763,7 @@ LTransformAndProject:
|
|||
faddp %st(0),%st(4) // ym0 | zm2 | ym1 | xm2 | local[2]
|
||||
faddp %st(0),%st(2) // zm2 | ym2 | xm2 | local[2]
|
||||
fld %st(3) // local[2] | zm2 | ym2 | xm2 | local[2]
|
||||
fmuls C(vpn)+8 // zm3 | zm2 | ym2 | xm2 | local[2]
|
||||
fmuls C(vfwd)+8 // zm3 | zm2 | ym2 | xm2 | local[2]
|
||||
fld %st(4) // local[2] | zm3 | zm2 | ym2 | xm2 | local[2]
|
||||
fmuls C(vright)+8 // xm3 | zm3 | zm2 | ym2 | xm2 | local[2]
|
||||
fxch %st(5) // local[2] | zm3 | zm2 | ym2 | xm2 | xm3
|
||||
|
|
|
@ -263,15 +263,15 @@ R_IQMSetUpTransform (entity_t *ent, int trivial_accept)
|
|||
rotationmatrix[i][2] = up[i];
|
||||
}
|
||||
|
||||
rotationmatrix[0][3] = r_entorigin[0] - r_refdef.viewposition[0];
|
||||
rotationmatrix[1][3] = r_entorigin[1] - r_refdef.viewposition[1];
|
||||
rotationmatrix[2][3] = r_entorigin[2] - r_refdef.viewposition[2];
|
||||
rotationmatrix[0][3] = r_entorigin[0] - r_refdef.frame.position[0];
|
||||
rotationmatrix[1][3] = r_entorigin[1] - r_refdef.frame.position[1];
|
||||
rotationmatrix[2][3] = r_entorigin[2] - r_refdef.frame.position[2];
|
||||
|
||||
// TODO: should be global, set when vright, etc., set
|
||||
VectorCopy (vright, viewmatrix[0]);
|
||||
VectorCopy (vup, viewmatrix[1]);
|
||||
VectorNegate (viewmatrix[1], viewmatrix[1]);
|
||||
VectorCopy (vpn, viewmatrix[2]);
|
||||
VectorCopy (vfwd, viewmatrix[2]);
|
||||
|
||||
// viewmatrix[0][3] = 0;
|
||||
// viewmatrix[1][3] = 0;
|
||||
|
|
|
@ -107,6 +107,10 @@ int r_drawnpolycount;
|
|||
int *pfrustum_indexes[4];
|
||||
int r_frustum_indexes[4 * 6];
|
||||
|
||||
vec3_t vup, base_vup;
|
||||
vec3_t vfwd, base_vfwd;
|
||||
vec3_t vright, base_vright;
|
||||
|
||||
float r_aliastransition, r_resfudge;
|
||||
|
||||
static float dp_time1, dp_time2, db_time1, db_time2, rw_time1, rw_time2;
|
||||
|
@ -581,7 +585,7 @@ R_DrawBrushEntitiesOnList (void)
|
|||
if (clipflags != BMODEL_FULLY_CLIPPED) {
|
||||
mod_brush_t *brush = &clmodel->brush;
|
||||
VectorCopy (origin, r_entorigin);
|
||||
VectorSubtract (r_refdef.viewposition, r_entorigin, modelorg);
|
||||
VectorSubtract (r_refdef.frame.position, r_entorigin, modelorg);
|
||||
|
||||
r_pcurrentvertbase = brush->vertexes;
|
||||
|
||||
|
@ -631,7 +635,7 @@ R_DrawBrushEntitiesOnList (void)
|
|||
|
||||
// put back world rotation and frustum clipping
|
||||
// FIXME: R_RotateBmodel should just work off base_vxx
|
||||
VectorCopy (base_vpn, vpn);
|
||||
VectorCopy (base_vfwd, vfwd);
|
||||
VectorCopy (base_vup, vup);
|
||||
VectorCopy (base_vright, vright);
|
||||
VectorCopy (base_modelorg, modelorg);
|
||||
|
|
|
@ -122,9 +122,9 @@ R_TransformFrustum (void)
|
|||
v[1] = -screenedge[i].normal[0];
|
||||
v[2] = screenedge[i].normal[1];
|
||||
|
||||
v2[0] = v[1] * vright[0] + v[2] * vup[0] + v[0] * vpn[0];
|
||||
v2[1] = v[1] * vright[1] + v[2] * vup[1] + v[0] * vpn[1];
|
||||
v2[2] = v[1] * vright[2] + v[2] * vup[2] + v[0] * vpn[2];
|
||||
v2[0] = v[1] * vright[0] + v[2] * vup[0] + v[0] * vfwd[0];
|
||||
v2[1] = v[1] * vright[1] + v[2] * vup[1] + v[0] * vfwd[1];
|
||||
v2[2] = v[1] * vright[2] + v[2] * vup[2] + v[0] * vfwd[2];
|
||||
|
||||
VectorCopy (v2, view_clipplanes[i].normal);
|
||||
|
||||
|
@ -142,7 +142,7 @@ TransformVector (const vec3_t in, vec3_t out)
|
|||
{
|
||||
out[0] = DotProduct (in, vright);
|
||||
out[1] = DotProduct (in, vup);
|
||||
out[2] = DotProduct (in, vpn);
|
||||
out[2] = DotProduct (in, vfwd);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -183,13 +183,12 @@ R_SetupFrame (void)
|
|||
numbtofpolys = 0;
|
||||
|
||||
// build the transformation matrix for the given view angles
|
||||
VectorCopy (r_refdef.viewposition, modelorg);
|
||||
VectorCopy (r_refdef.frame.position, modelorg);
|
||||
|
||||
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);
|
||||
vec4f_t position = r_refdef.frame.position;
|
||||
VectorCopy (r_refdef.frame.right, vright);
|
||||
VectorCopy (r_refdef.frame.forward, vfwd);
|
||||
VectorCopy (r_refdef.frame.up, vup);
|
||||
R_SetFrustum ();
|
||||
|
||||
// current viewleaf
|
||||
|
@ -248,7 +247,7 @@ R_SetupFrame (void)
|
|||
R_TransformFrustum ();
|
||||
|
||||
// save base values
|
||||
VectorCopy (vpn, base_vpn);
|
||||
VectorCopy (vfwd, base_vfwd);
|
||||
VectorCopy (vright, base_vright);
|
||||
VectorCopy (vup, base_vup);
|
||||
VectorCopy (modelorg, base_modelorg);
|
||||
|
|
|
@ -56,8 +56,8 @@ R_DrawParticles (void)
|
|||
{
|
||||
VectorScale (vright, xscaleshrink, r_pright);
|
||||
VectorScale (vup, yscaleshrink, r_pup);
|
||||
VectorCopy (vpn, r_ppn);
|
||||
VectorCopy (r_refdef.viewposition, r_porigin);
|
||||
VectorCopy (vfwd, r_ppn);
|
||||
VectorCopy (r_refdef.frame.position, r_porigin);
|
||||
|
||||
R_RunParticles (vr_data.frametime);
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ R_RotateSprite (const vec3_t relvieworg, float beamlength, vec3_t org)
|
|||
if (beamlength == 0.0)
|
||||
return;
|
||||
|
||||
VectorScale (r_spritedesc.vpn, -beamlength, vec);
|
||||
VectorScale (r_spritedesc.vfwd, -beamlength, vec);
|
||||
VectorAdd (r_entorigin, vec, r_entorigin);
|
||||
VectorSubtract (relvieworg, vec, org);
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ R_SetupAndDrawSprite (const vec3_t relvieworg)
|
|||
vec3_t left, up, right, down, transformed, local;
|
||||
emitpoint_t outverts[MAXWORKINGVERTS + 1], *pout;
|
||||
|
||||
dot = DotProduct (r_spritedesc.vpn, relvieworg);
|
||||
dot = DotProduct (r_spritedesc.vfwd, relvieworg);
|
||||
|
||||
// backface cull
|
||||
if (dot >= 0)
|
||||
|
@ -211,7 +211,7 @@ R_SetupAndDrawSprite (const vec3_t relvieworg)
|
|||
r_spritedesc.nearzi = -999999;
|
||||
|
||||
for (i = 0; i < nump; i++) {
|
||||
VectorSubtract (pv, r_refdef.viewposition, local);
|
||||
VectorSubtract (pv, r_refdef.frame.position, local);
|
||||
TransformVector (local, transformed);
|
||||
|
||||
if (transformed[2] < NEAR_CLIP)
|
||||
|
@ -246,7 +246,7 @@ R_DrawSprite (entity_t *ent)
|
|||
msprite_t *sprite = ent->renderer.model->cache.data;
|
||||
vec3_t relvieworg;
|
||||
|
||||
VectorSubtract (r_refdef.viewposition, r_entorigin, relvieworg);
|
||||
VectorSubtract (r_refdef.frame.position, r_entorigin, relvieworg);
|
||||
|
||||
r_spritedesc.pspriteframe = R_GetSpriteFrame (sprite, &ent->animation);
|
||||
|
||||
|
@ -256,7 +256,7 @@ R_DrawSprite (entity_t *ent)
|
|||
if (!R_BillboardFrame (ent, sprite->type, relvieworg,
|
||||
r_spritedesc.vup,
|
||||
r_spritedesc.vright,
|
||||
r_spritedesc.vpn)) {
|
||||
r_spritedesc.vfwd)) {
|
||||
// the orientation is undefined so can't draw the sprite
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -77,31 +77,31 @@ C(TransformVector):
|
|||
flds (%eax) // in[0] | in[0]*vright[0]
|
||||
fmuls C(vup) // in[0]*vup[0] | in[0]*vright[0]
|
||||
flds (%eax) // in[0] | in[0]*vup[0] | in[0]*vright[0]
|
||||
fmuls C(vpn) // in[0]*vpn[0] | in[0]*vup[0] | in[0]*vright[0]
|
||||
fmuls C(vfwd) // in[0]*vfwd[0] | in[0]*vup[0] | in[0]*vright[0]
|
||||
|
||||
flds 4(%eax) // in[1] | ...
|
||||
fmuls C(vright)+4 // in[1]*vright[1] | ...
|
||||
flds 4(%eax) // in[1] | in[1]*vright[1] | ...
|
||||
fmuls C(vup)+4 // in[1]*vup[1] | in[1]*vright[1] | ...
|
||||
flds 4(%eax) // in[1] | in[1]*vup[1] | in[1]*vright[1] | ...
|
||||
fmuls C(vpn)+4 // in[1]*vpn[1] | in[1]*vup[1] | in[1]*vright[1] | ...
|
||||
fxch %st(2) // in[1]*vright[1] | in[1]*vup[1] | in[1]*vpn[1] | ...
|
||||
fmuls C(vfwd)+4 // in[1]*vfwd[1] | in[1]*vup[1] | in[1]*vright[1] | ...
|
||||
fxch %st(2) // in[1]*vright[1] | in[1]*vup[1] | in[1]*vfwd[1] | ...
|
||||
|
||||
faddp %st(0),%st(5) // in[1]*vup[1] | in[1]*vpn[1] | ...
|
||||
faddp %st(0),%st(3) // in[1]*vpn[1] | ...
|
||||
faddp %st(0),%st(1) // vpn_accum | vup_accum | vright_accum
|
||||
faddp %st(0),%st(5) // in[1]*vup[1] | in[1]*vfwd[1] | ...
|
||||
faddp %st(0),%st(3) // in[1]*vfwd[1] | ...
|
||||
faddp %st(0),%st(1) // vfwd | vup_accum | vright_accum
|
||||
|
||||
flds 8(%eax) // in[2] | ...
|
||||
fmuls C(vright)+8 // in[2]*vright[2] | ...
|
||||
flds 8(%eax) // in[2] | in[2]*vright[2] | ...
|
||||
fmuls C(vup)+8 // in[2]*vup[2] | in[2]*vright[2] | ...
|
||||
flds 8(%eax) // in[2] | in[2]*vup[2] | in[2]*vright[2] | ...
|
||||
fmuls C(vpn)+8 // in[2]*vpn[2] | in[2]*vup[2] | in[2]*vright[2] | ...
|
||||
fxch %st(2) // in[2]*vright[2] | in[2]*vup[2] | in[2]*vpn[2] | ...
|
||||
fmuls C(vfwd)+8 // in[2]*vfwd[2] | in[2]*vup[2] | in[2]*vright[2] | ...
|
||||
fxch %st(2) // in[2]*vright[2] | in[2]*vup[2] | in[2]*vfwd[2] | ...
|
||||
|
||||
faddp %st(0),%st(5) // in[2]*vup[2] | in[2]*vpn[2] | ...
|
||||
faddp %st(0),%st(3) // in[2]*vpn[2] | ...
|
||||
faddp %st(0),%st(1) // vpn_accum | vup_accum | vright_accum
|
||||
faddp %st(0),%st(5) // in[2]*vup[2] | in[2]*vfwd[2] | ...
|
||||
faddp %st(0),%st(3) // in[2]*vfwd[2] | ...
|
||||
faddp %st(0),%st(1) // vfwd | vup_accum | vright_accum
|
||||
|
||||
fstps 8(%edx) // out[2]
|
||||
fstps 4(%edx) // out[1]
|
||||
|
|
|
@ -615,7 +615,7 @@ R_DrawBrushModel (entity_t *e, vulkan_ctx_t *ctx)
|
|||
return;
|
||||
}
|
||||
|
||||
org = r_refdef.viewposition - mat[3];
|
||||
org = r_refdef.frame.position - mat[3];
|
||||
if (rotated) {
|
||||
vec4f_t temp = org;
|
||||
|
||||
|
@ -653,7 +653,7 @@ get_side (mnode_t *node)
|
|||
{
|
||||
// find the node side on which we are
|
||||
plane_t *plane = node->plane;
|
||||
vec4f_t org = r_refdef.viewposition;
|
||||
vec4f_t org = r_refdef.frame.position;
|
||||
|
||||
if (plane->type < 3)
|
||||
return (org[plane->type] - plane->dist) < 0;
|
||||
|
|
|
@ -160,7 +160,7 @@ update_lights (vulkan_ctx_t *ctx)
|
|||
light_data->distFactor2 = 1 / 16384.0;
|
||||
|
||||
light_data->lightCount = 0;
|
||||
R_FindNearLights (&r_refdef.viewposition[0], MaxLights - 1, lights);
|
||||
R_FindNearLights (&r_refdef.frame.position[0], MaxLights - 1, lights);
|
||||
for (int i = 0; i < MaxLights - 1; i++) {
|
||||
if (!lights[i]) {
|
||||
break;
|
||||
|
|
|
@ -70,14 +70,9 @@ setup_frame (vulkan_ctx_t *ctx)
|
|||
EntQueue_Clear (r_ent_queue);
|
||||
r_framecount++;
|
||||
|
||||
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 ();
|
||||
|
||||
vec4f_t position = r_refdef.frame.position;
|
||||
r_viewleaf = Mod_PointInLeaf (&position[0], r_worldentity.renderer.model);
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,6 @@ setup_view (vulkan_ctx_t *ctx)
|
|||
{ 0,-1, 0, 0},
|
||||
{ 0, 0, 0, 1},
|
||||
};
|
||||
vec4f_t offset = { 0, 0, 0, 1 };
|
||||
|
||||
/*x = r_refdef.vrect.x;
|
||||
y = (vid.height - (r_refdef.vrect.y + r_refdef.vrect.height));
|
||||
|
@ -80,11 +79,7 @@ setup_view (vulkan_ctx_t *ctx)
|
|||
h = r_refdef.vrect.height;
|
||||
qfeglViewport (x, y, w, h);*/
|
||||
|
||||
mat4fquat (view, qconjf (r_refdef.viewrotation));
|
||||
mmulf (view, z_up, view);
|
||||
offset = -r_refdef.viewposition;
|
||||
offset[3] = 1;
|
||||
view[3] = mvmulf (view, offset);
|
||||
mmulf (view, z_up, r_refdef.camera_inverse);
|
||||
Vulkan_SetViewMatrix (ctx, view);
|
||||
}
|
||||
|
||||
|
@ -108,7 +103,7 @@ setup_sky (vulkan_ctx_t *ctx)
|
|||
q = Blend (mctx->sky_rotation[0], mctx->sky_rotation[1], blend);
|
||||
q = normalf (qmulf (mctx->sky_fix, q));
|
||||
mat4fidentity (mat);
|
||||
VectorNegate (r_refdef.viewposition, mat[3]);
|
||||
VectorNegate (r_refdef.frame.position, mat[3]);
|
||||
mat4fquat (m, q);
|
||||
mmulf (mat, m, mat);
|
||||
Vulkan_SetSkyMatrix (ctx, mat);
|
||||
|
|
|
@ -119,7 +119,7 @@ Vulkan_DrawSprite (entity_t *ent, qfv_renderframe_t *rFrame)
|
|||
frame = (ptrdiff_t) R_GetSpriteFrame (sprite, animation);
|
||||
|
||||
mat[3] = Transform_GetWorldPosition (ent->transform);
|
||||
vec4f_t cameravec = r_refdef.viewposition - mat[3];
|
||||
vec4f_t cameravec = r_refdef.frame.position - mat[3];
|
||||
R_BillboardFrame (ent, sprite->type, &cameravec[0],
|
||||
&mat[2][0], &mat[1][0], &mat[0][0]);
|
||||
mat[0] = -mat[0];
|
||||
|
|
Loading…
Reference in a new issue