2001-02-19 21:15:25 +00:00
|
|
|
/*
|
2001-08-25 02:47:11 +00:00
|
|
|
sw_ralias.c
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-19 23:38:56 +00:00
|
|
|
routines for setting up to draw alias models
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2012-02-14 08:28:09 +00:00
|
|
|
#include <stdlib.h>
|
2022-03-24 03:22:27 +00:00
|
|
|
#include <string.h>
|
2012-02-14 08:28:09 +00:00
|
|
|
|
2003-09-04 18:59:39 +00:00
|
|
|
#include "QF/image.h"
|
2001-05-19 23:38:56 +00:00
|
|
|
#include "QF/render.h"
|
|
|
|
#include "QF/skin.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/sys.h"
|
2001-05-10 06:01:11 +00:00
|
|
|
|
2021-07-24 05:19:52 +00:00
|
|
|
#include "QF/scene/entity.h"
|
|
|
|
|
2001-05-19 23:38:56 +00:00
|
|
|
#include "d_ifacea.h"
|
2012-02-14 08:28:09 +00:00
|
|
|
#include "r_internal.h"
|
2002-01-05 17:56:33 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
#define LIGHT_MIN 5 // lowest light value we'll allow, to
|
2001-05-15 21:13:07 +00:00
|
|
|
// avoid the need for inner-loop light
|
|
|
|
// clamping
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
affinetridesc_t r_affinetridesc;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-29 04:08:58 +00:00
|
|
|
const byte *acolormap; // FIXME: should go away
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
trivertx_t *r_apverts;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// TODO: these probably will go away with optimized rasterization
|
2012-02-18 05:34:14 +00:00
|
|
|
static mdl_t *pmdl;
|
2022-03-17 06:04:30 +00:00
|
|
|
vec3_t r_lightvec;
|
2001-02-26 06:48:02 +00:00
|
|
|
int r_ambientlight;
|
|
|
|
float r_shadelight;
|
2012-02-18 05:34:14 +00:00
|
|
|
static aliashdr_t *paliashdr;
|
2001-02-26 06:48:02 +00:00
|
|
|
finalvert_t *pfinalverts;
|
|
|
|
auxvert_t *pauxverts;
|
2012-05-18 14:31:14 +00:00
|
|
|
float ziscale;
|
2001-02-26 06:48:02 +00:00
|
|
|
static model_t *pmodel;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-14 02:56:10 +00:00
|
|
|
static vec3_t alias_forward, alias_left, alias_up;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
static maliasskindesc_t *pskindesc;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
int r_amodels_drawn;
|
|
|
|
int a_skinwidth;
|
|
|
|
int r_anumverts;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
float aliastransform[3][4];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2001-02-26 06:48:02 +00:00
|
|
|
int index0;
|
|
|
|
int index1;
|
2001-02-19 21:15:25 +00:00
|
|
|
} aedge_t;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
static aedge_t aedges[12] = {
|
|
|
|
{0, 1}, {1, 2}, {2, 3}, {3, 0},
|
|
|
|
{4, 5}, {5, 6}, {6, 7}, {7, 4},
|
|
|
|
{0, 5}, {1, 4}, {2, 7}, {3, 6}
|
2001-02-19 21:15:25 +00:00
|
|
|
};
|
|
|
|
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
static void R_AliasSetUpTransform (entity_t ent, int trivial_accept);
|
2022-03-11 06:07:38 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
qboolean
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
R_AliasCheckBBox (entity_t ent)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i, flags, frame, numv;
|
|
|
|
aliashdr_t *pahdr;
|
|
|
|
float zi, basepts[8][3], v0, v1, frac;
|
|
|
|
finalvert_t *pv0, *pv1, viewpts[16];
|
|
|
|
auxvert_t *pa0, *pa1, viewaux[16];
|
|
|
|
maliasframedesc_t *pframedesc;
|
|
|
|
qboolean zclipped, zfullyclipped;
|
2001-05-15 04:50:53 +00:00
|
|
|
unsigned int anyclip, allclip;
|
2001-02-26 06:48:02 +00:00
|
|
|
int minz;
|
|
|
|
|
2001-05-15 21:13:07 +00:00
|
|
|
// expand, rotate, and translate points into worldspace
|
2022-10-25 03:53:30 +00:00
|
|
|
visibility_t *visibility = Ent_GetComponent (ent.id, scene_visibility,
|
|
|
|
ent.reg);
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
visibility->trivial_accept = 0;
|
2022-10-25 03:53:30 +00:00
|
|
|
|
|
|
|
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
pmodel = renderer->model;
|
2012-01-17 12:00:19 +00:00
|
|
|
if (!(pahdr = pmodel->aliashdr))
|
2012-01-17 02:44:28 +00:00
|
|
|
pahdr = Cache_Get (&pmodel->cache);
|
2001-02-26 06:48:02 +00:00
|
|
|
pmdl = (mdl_t *) ((byte *) pahdr + pahdr->model);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-11 06:07:38 +00:00
|
|
|
R_AliasSetUpTransform (ent, 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-15 21:13:07 +00:00
|
|
|
// construct the base bounding box for this frame
|
2022-10-25 03:53:30 +00:00
|
|
|
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
|
|
|
ent.reg);
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
frame = animation->frame;
|
2001-02-19 21:15:25 +00:00
|
|
|
// TODO: don't repeat this check when drawing?
|
2001-02-26 06:48:02 +00:00
|
|
|
if ((frame >= pmdl->numframes) || (frame < 0)) {
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "No such frame %d %s\n", frame, pmodel->path);
|
2001-02-19 21:15:25 +00:00
|
|
|
frame = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
pframedesc = &pahdr->frames[frame];
|
|
|
|
|
2001-05-15 21:13:07 +00:00
|
|
|
// x worldspace coordinates
|
2001-02-19 21:15:25 +00:00
|
|
|
basepts[0][0] = basepts[1][0] = basepts[2][0] = basepts[3][0] =
|
2001-02-26 06:48:02 +00:00
|
|
|
(float) pframedesc->bboxmin.v[0];
|
2001-02-19 21:15:25 +00:00
|
|
|
basepts[4][0] = basepts[5][0] = basepts[6][0] = basepts[7][0] =
|
2001-02-26 06:48:02 +00:00
|
|
|
(float) pframedesc->bboxmax.v[0];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-15 21:13:07 +00:00
|
|
|
// y worldspace coordinates
|
2001-02-19 21:15:25 +00:00
|
|
|
basepts[0][1] = basepts[3][1] = basepts[5][1] = basepts[6][1] =
|
2001-02-26 06:48:02 +00:00
|
|
|
(float) pframedesc->bboxmin.v[1];
|
2001-02-19 21:15:25 +00:00
|
|
|
basepts[1][1] = basepts[2][1] = basepts[4][1] = basepts[7][1] =
|
2001-02-26 06:48:02 +00:00
|
|
|
(float) pframedesc->bboxmax.v[1];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-15 21:13:07 +00:00
|
|
|
// z worldspace coordinates
|
2001-02-19 21:15:25 +00:00
|
|
|
basepts[0][2] = basepts[1][2] = basepts[4][2] = basepts[5][2] =
|
2001-02-26 06:48:02 +00:00
|
|
|
(float) pframedesc->bboxmin.v[2];
|
2001-02-19 21:15:25 +00:00
|
|
|
basepts[2][2] = basepts[3][2] = basepts[6][2] = basepts[7][2] =
|
2001-02-26 06:48:02 +00:00
|
|
|
(float) pframedesc->bboxmax.v[2];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
zclipped = false;
|
|
|
|
zfullyclipped = true;
|
|
|
|
|
|
|
|
minz = 9999;
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
R_AliasTransformVector (&basepts[i][0], &viewaux[i].fv[0]);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (viewaux[i].fv[2] < ALIAS_Z_CLIP_PLANE) {
|
|
|
|
// we must clip points that are closer than the near clip plane
|
2001-02-19 21:15:25 +00:00
|
|
|
viewpts[i].flags = ALIAS_Z_CLIP;
|
|
|
|
zclipped = true;
|
2001-02-26 06:48:02 +00:00
|
|
|
} else {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (viewaux[i].fv[2] < minz)
|
|
|
|
minz = viewaux[i].fv[2];
|
|
|
|
viewpts[i].flags = 0;
|
|
|
|
zfullyclipped = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (zfullyclipped) {
|
2012-01-17 02:44:28 +00:00
|
|
|
if (!pmodel->aliashdr)
|
|
|
|
Cache_Release (&pmodel->cache);
|
2001-02-26 06:48:02 +00:00
|
|
|
return false; // everything was near-z-clipped
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
numv = 8;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (zclipped) {
|
|
|
|
// organize points by edges, use edges to get new points (possible
|
2001-05-15 21:13:07 +00:00
|
|
|
// trivial reject)
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < 12; i++) {
|
|
|
|
// edge endpoints
|
2001-02-19 21:15:25 +00:00
|
|
|
pv0 = &viewpts[aedges[i].index0];
|
|
|
|
pv1 = &viewpts[aedges[i].index1];
|
|
|
|
pa0 = &viewaux[aedges[i].index0];
|
|
|
|
pa1 = &viewaux[aedges[i].index1];
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
// if one end is clipped and the other isn't, make a new point
|
|
|
|
if (pv0->flags ^ pv1->flags) {
|
2001-02-19 21:15:25 +00:00
|
|
|
frac = (ALIAS_Z_CLIP_PLANE - pa0->fv[2]) /
|
2001-02-26 06:48:02 +00:00
|
|
|
(pa1->fv[2] - pa0->fv[2]);
|
2001-02-19 21:15:25 +00:00
|
|
|
viewaux[numv].fv[0] = pa0->fv[0] +
|
2001-02-26 06:48:02 +00:00
|
|
|
(pa1->fv[0] - pa0->fv[0]) * frac;
|
2001-02-19 21:15:25 +00:00
|
|
|
viewaux[numv].fv[1] = pa0->fv[1] +
|
2001-02-26 06:48:02 +00:00
|
|
|
(pa1->fv[1] - pa0->fv[1]) * frac;
|
2001-02-19 21:15:25 +00:00
|
|
|
viewaux[numv].fv[2] = ALIAS_Z_CLIP_PLANE;
|
|
|
|
viewpts[numv].flags = 0;
|
|
|
|
numv++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-05-15 21:13:07 +00:00
|
|
|
// project the vertices that remain after clipping
|
2001-02-19 21:15:25 +00:00
|
|
|
anyclip = 0;
|
|
|
|
allclip = ALIAS_XY_CLIP_MASK;
|
|
|
|
|
|
|
|
// TODO: probably should do this loop in ASM, especially if we use floats
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < numv; i++) {
|
|
|
|
// we don't need to bother with vertices that were z-clipped
|
2001-02-19 21:15:25 +00:00
|
|
|
if (viewpts[i].flags & ALIAS_Z_CLIP)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
zi = 1.0 / viewaux[i].fv[2];
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
// FIXME: do with chop mode in ASM, or convert to float
|
2001-02-19 21:15:25 +00:00
|
|
|
v0 = (viewaux[i].fv[0] * xscale * zi) + xcenter;
|
|
|
|
v1 = (viewaux[i].fv[1] * yscale * zi) + ycenter;
|
|
|
|
|
|
|
|
flags = 0;
|
|
|
|
|
|
|
|
if (v0 < r_refdef.fvrectx)
|
|
|
|
flags |= ALIAS_LEFT_CLIP;
|
|
|
|
if (v1 < r_refdef.fvrecty)
|
|
|
|
flags |= ALIAS_TOP_CLIP;
|
|
|
|
if (v0 > r_refdef.fvrectright)
|
|
|
|
flags |= ALIAS_RIGHT_CLIP;
|
|
|
|
if (v1 > r_refdef.fvrectbottom)
|
|
|
|
flags |= ALIAS_BOTTOM_CLIP;
|
|
|
|
|
|
|
|
anyclip |= flags;
|
|
|
|
allclip &= flags;
|
|
|
|
}
|
|
|
|
|
2001-08-31 12:22:45 +00:00
|
|
|
if (allclip) {
|
2012-01-17 02:44:28 +00:00
|
|
|
if (!pmodel->aliashdr)
|
|
|
|
Cache_Release (&pmodel->cache);
|
2001-02-26 06:48:02 +00:00
|
|
|
return false; // trivial reject off one side
|
2001-08-31 12:22:45 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
visibility->trivial_accept = !anyclip & !zclipped;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
if (visibility->trivial_accept) {
|
2001-02-26 06:48:02 +00:00
|
|
|
if (minz > (r_aliastransition + (pmdl->size * r_resfudge))) {
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
visibility->trivial_accept |= 2;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-17 02:44:28 +00:00
|
|
|
if (!pmodel->aliashdr)
|
|
|
|
Cache_Release (&pmodel->cache);
|
2001-02-19 21:15:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
R_AliasTransformVector (vec3_t in, vec3_t out)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
out[0] = DotProduct (in, aliastransform[0]) + aliastransform[0][3];
|
|
|
|
out[1] = DotProduct (in, aliastransform[1]) + aliastransform[1][3];
|
|
|
|
out[2] = DotProduct (in, aliastransform[2]) + aliastransform[2][3];
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2012-05-18 14:31:14 +00:00
|
|
|
void
|
2002-01-05 20:00:50 +00:00
|
|
|
R_AliasClipAndProjectFinalVert (finalvert_t *fv, auxvert_t *av)
|
|
|
|
{
|
|
|
|
if (av->fv[2] < ALIAS_Z_CLIP_PLANE) {
|
|
|
|
fv->flags |= ALIAS_Z_CLIP;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
R_AliasProjectFinalVert (fv, av);
|
|
|
|
|
2022-03-27 06:27:35 +00:00
|
|
|
if (fv->v[0] < r_refdef.aliasvrectleft)
|
2002-01-05 20:00:50 +00:00
|
|
|
fv->flags |= ALIAS_LEFT_CLIP;
|
2022-03-27 06:27:35 +00:00
|
|
|
if (fv->v[1] < r_refdef.aliasvrecttop)
|
2002-01-05 20:00:50 +00:00
|
|
|
fv->flags |= ALIAS_TOP_CLIP;
|
|
|
|
if (fv->v[0] > r_refdef.aliasvrectright)
|
|
|
|
fv->flags |= ALIAS_RIGHT_CLIP;
|
|
|
|
if (fv->v[1] > r_refdef.aliasvrectbottom)
|
|
|
|
fv->flags |= ALIAS_BOTTOM_CLIP;
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2012-05-17 12:33:22 +00:00
|
|
|
R_AliasTransformFinalVert16 (auxvert_t *av, trivertx_t *pverts)
|
2002-01-05 20:00:50 +00:00
|
|
|
{
|
|
|
|
trivertx_t * pextra;
|
|
|
|
float vextra[3];
|
|
|
|
|
|
|
|
pextra = pverts + pmdl->numverts;
|
|
|
|
vextra[0] = pverts->v[0] + pextra->v[0] / (float)256;
|
|
|
|
vextra[1] = pverts->v[1] + pextra->v[1] / (float)256;
|
|
|
|
vextra[2] = pverts->v[2] + pextra->v[2] / (float)256;
|
|
|
|
av->fv[0] = DotProduct (vextra, aliastransform[0]) +
|
|
|
|
aliastransform[0][3];
|
|
|
|
av->fv[1] = DotProduct (vextra, aliastransform[1]) +
|
|
|
|
aliastransform[1][3];
|
|
|
|
av->fv[2] = DotProduct (vextra, aliastransform[2]) +
|
|
|
|
aliastransform[2][3];
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2012-05-17 12:33:22 +00:00
|
|
|
R_AliasTransformFinalVert8 (auxvert_t *av, trivertx_t *pverts)
|
2002-01-05 20:00:50 +00:00
|
|
|
{
|
|
|
|
av->fv[0] = DotProduct (pverts->v, aliastransform[0]) +
|
|
|
|
aliastransform[0][3];
|
|
|
|
av->fv[1] = DotProduct (pverts->v, aliastransform[1]) +
|
|
|
|
aliastransform[1][3];
|
|
|
|
av->fv[2] = DotProduct (pverts->v, aliastransform[2]) +
|
|
|
|
aliastransform[2][3];
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
2001-05-15 04:50:53 +00:00
|
|
|
R_AliasPreparePoints
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-15 04:50:53 +00:00
|
|
|
General clipped case
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-26 06:48:02 +00:00
|
|
|
R_AliasPreparePoints (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
|
|
|
stvert_t *pstverts;
|
|
|
|
finalvert_t *fv;
|
|
|
|
auxvert_t *av;
|
|
|
|
mtriangle_t *ptri;
|
|
|
|
finalvert_t *pfv[3];
|
|
|
|
|
|
|
|
pstverts = (stvert_t *) ((byte *) paliashdr + paliashdr->stverts);
|
2001-02-19 21:15:25 +00:00
|
|
|
r_anumverts = pmdl->numverts;
|
2001-02-26 06:48:02 +00:00
|
|
|
fv = pfinalverts;
|
2001-02-19 21:15:25 +00:00
|
|
|
av = pauxverts;
|
|
|
|
|
2004-02-08 02:49:38 +00:00
|
|
|
if (pmdl->ident == HEADER_MDL16) {
|
2002-01-05 20:00:50 +00:00
|
|
|
for (i = 0; i < r_anumverts; i++, fv++, av++, r_apverts++,
|
2004-02-08 02:49:38 +00:00
|
|
|
pstverts++) {
|
2012-05-17 12:33:22 +00:00
|
|
|
R_AliasTransformFinalVert16 (av, r_apverts);
|
|
|
|
R_AliasTransformFinalVert (fv, r_apverts, pstverts);
|
2002-01-05 20:00:50 +00:00
|
|
|
R_AliasClipAndProjectFinalVert (fv, av);
|
|
|
|
}
|
2004-02-08 02:49:38 +00:00
|
|
|
} else {
|
2002-01-05 20:00:50 +00:00
|
|
|
for (i = 0; i < r_anumverts; i++, fv++, av++, r_apverts++,
|
2004-02-08 02:49:38 +00:00
|
|
|
pstverts++) {
|
2012-05-17 12:33:22 +00:00
|
|
|
R_AliasTransformFinalVert8 (av, r_apverts);
|
|
|
|
R_AliasTransformFinalVert (fv, r_apverts, pstverts);
|
2002-01-05 20:00:50 +00:00
|
|
|
R_AliasClipAndProjectFinalVert (fv, av);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-15 21:13:07 +00:00
|
|
|
// clip and draw all triangles
|
2001-02-19 21:15:25 +00:00
|
|
|
r_affinetridesc.numtriangles = 1;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
ptri = (mtriangle_t *) ((byte *) paliashdr + paliashdr->triangles);
|
|
|
|
for (i = 0; i < pmdl->numtris; i++, ptri++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
pfv[0] = &pfinalverts[ptri->vertindex[0]];
|
|
|
|
pfv[1] = &pfinalverts[ptri->vertindex[1]];
|
|
|
|
pfv[2] = &pfinalverts[ptri->vertindex[2]];
|
|
|
|
|
2012-05-18 14:31:14 +00:00
|
|
|
if (pfv[0]->flags & pfv[1]->flags & pfv[2]->flags
|
|
|
|
& (ALIAS_XY_CLIP_MASK | ALIAS_Z_CLIP))
|
2001-02-26 06:48:02 +00:00
|
|
|
continue; // completely clipped
|
|
|
|
|
2012-05-18 14:31:14 +00:00
|
|
|
if (!((pfv[0]->flags | pfv[1]->flags | pfv[2]->flags)
|
|
|
|
& (ALIAS_XY_CLIP_MASK | ALIAS_Z_CLIP))) { // totally unclipped
|
2001-02-19 21:15:25 +00:00
|
|
|
r_affinetridesc.pfinalverts = pfinalverts;
|
|
|
|
r_affinetridesc.ptriangles = ptri;
|
|
|
|
D_PolysetDraw ();
|
2001-02-26 06:48:02 +00:00
|
|
|
} else { // partially clipped
|
2001-02-19 21:15:25 +00:00
|
|
|
R_AliasClipTriangle (ptri);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-11 06:07:38 +00:00
|
|
|
static void
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
R_AliasSetUpTransform (entity_t ent, int trivial_accept)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
2022-03-14 02:56:10 +00:00
|
|
|
float rotationmatrix[3][4];
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
transform_t transform = Entity_Transform (ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
mat4f_t mat;
|
|
|
|
Transform_GetWorldMatrix (transform, mat);
|
2021-03-09 14:52:40 +00:00
|
|
|
VectorCopy (mat[0], alias_forward);
|
2022-03-14 02:56:10 +00:00
|
|
|
VectorCopy (mat[1], alias_left);
|
2021-03-09 14:52:40 +00:00
|
|
|
VectorCopy (mat[2], alias_up);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < 3; i++) {
|
2022-03-14 02:56:10 +00:00
|
|
|
rotationmatrix[i][0] = pmdl->scale[0] * alias_forward[i];
|
|
|
|
rotationmatrix[i][1] = pmdl->scale[1] * alias_left[i];
|
|
|
|
rotationmatrix[i][2] = pmdl->scale[2] * alias_up[i];
|
|
|
|
rotationmatrix[i][3] = pmdl->scale_origin[0] * alias_forward[i]
|
|
|
|
+ pmdl->scale_origin[1] * alias_left[i]
|
|
|
|
+ pmdl->scale_origin[2] * alias_up[i]
|
|
|
|
+ r_entorigin[i] - r_refdef.frame.position[i];
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2022-03-14 02:56:10 +00:00
|
|
|
R_ConcatTransforms (r_viewmatrix, rotationmatrix, aliastransform);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// do the scaling up of x and y to screen coordinates as part of the transform
|
|
|
|
// for the unclipped case (it would mess up clipping in the clipped case).
|
|
|
|
// Also scale down z, so 1/z is scaled 31 bits for free, and scale down x and y
|
|
|
|
// correspondingly so the projected x and y come out right
|
|
|
|
// FIXME: make this work for clipped case too?
|
2002-01-05 03:21:02 +00:00
|
|
|
|
2004-02-08 02:49:38 +00:00
|
|
|
if (trivial_accept && pmdl->ident != HEADER_MDL16) {
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < 4; i++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
aliastransform[0][i] *= aliasxscale *
|
2001-02-26 06:48:02 +00:00
|
|
|
(1.0 / ((float) 0x8000 * 0x10000));
|
2001-02-19 21:15:25 +00:00
|
|
|
aliastransform[1][i] *= aliasyscale *
|
2001-02-26 06:48:02 +00:00
|
|
|
(1.0 / ((float) 0x8000 * 0x10000));
|
|
|
|
aliastransform[2][i] *= 1.0 / ((float) 0x8000 * 0x10000);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-05 20:00:50 +00:00
|
|
|
/*
|
2002-01-07 06:50:41 +00:00
|
|
|
R_AliasTransformFinalVert
|
2002-01-05 20:00:50 +00:00
|
|
|
|
2002-01-07 06:50:41 +00:00
|
|
|
now this function just copies the texture coordinates and calculates
|
|
|
|
lighting actual 3D transform is done by R_AliasTransformFinalVert8/16
|
|
|
|
functions above */
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2012-05-17 12:33:22 +00:00
|
|
|
R_AliasTransformFinalVert (finalvert_t *fv, trivertx_t *pverts,
|
|
|
|
stvert_t *pstverts)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int temp;
|
|
|
|
float lightcos, *plightnormal;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
fv->v[2] = pstverts->s;
|
|
|
|
fv->v[3] = pstverts->t;
|
|
|
|
|
|
|
|
fv->flags = pstverts->onseam;
|
|
|
|
|
2001-05-15 21:13:07 +00:00
|
|
|
// lighting
|
2001-02-19 21:15:25 +00:00
|
|
|
plightnormal = r_avertexnormals[pverts->lightnormalindex];
|
2022-03-17 06:04:30 +00:00
|
|
|
lightcos = DotProduct (plightnormal, r_lightvec);
|
2001-02-19 21:15:25 +00:00
|
|
|
temp = r_ambientlight;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (lightcos < 0) {
|
|
|
|
temp += (int) (r_shadelight * lightcos);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
// clamp; because we limited the minimum ambient and shading light,
|
2001-05-15 21:13:07 +00:00
|
|
|
// we don't have to clamp low light, just bright
|
2001-02-19 21:15:25 +00:00
|
|
|
if (temp < 0)
|
|
|
|
temp = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
fv->v[4] = temp;
|
|
|
|
}
|
|
|
|
|
2001-06-11 20:59:48 +00:00
|
|
|
#ifdef PIC
|
2001-05-25 14:57:31 +00:00
|
|
|
#undef USE_INTEL_ASM //XXX asm pic hack
|
2001-06-11 20:59:48 +00:00
|
|
|
#endif
|
2001-05-25 14:57:31 +00:00
|
|
|
|
2001-05-15 04:50:53 +00:00
|
|
|
#ifndef USE_INTEL_ASM
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
R_AliasTransformAndProjectFinalVerts (finalvert_t *fv, stvert_t *pstverts)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i, temp;
|
|
|
|
float lightcos, *plightnormal, zi;
|
|
|
|
trivertx_t *pverts;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
pverts = r_apverts;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < r_anumverts; i++, fv++, pverts++, pstverts++) {
|
|
|
|
// transform and project
|
|
|
|
zi = 1.0 / (DotProduct (pverts->v, aliastransform[2]) +
|
|
|
|
aliastransform[2][3]);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
// x, y, and z are scaled down by 1/2**31 in the transform, so 1/z is
|
|
|
|
// scaled up by 1/2**31, and the scaling cancels out for x and y in
|
2001-05-19 23:38:56 +00:00
|
|
|
// the projection
|
2001-02-19 21:15:25 +00:00
|
|
|
fv->v[5] = zi;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
fv->v[0] = ((DotProduct (pverts->v, aliastransform[0]) +
|
|
|
|
aliastransform[0][3]) * zi) + aliasxcenter;
|
|
|
|
fv->v[1] = ((DotProduct (pverts->v, aliastransform[1]) +
|
|
|
|
aliastransform[1][3]) * zi) + aliasycenter;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
fv->v[2] = pstverts->s;
|
|
|
|
fv->v[3] = pstverts->t;
|
|
|
|
fv->flags = pstverts->onseam;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
// lighting
|
2001-02-19 21:15:25 +00:00
|
|
|
plightnormal = r_avertexnormals[pverts->lightnormalindex];
|
2022-03-17 06:04:30 +00:00
|
|
|
lightcos = DotProduct (plightnormal, r_lightvec);
|
2001-02-19 21:15:25 +00:00
|
|
|
temp = r_ambientlight;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (lightcos < 0) {
|
|
|
|
temp += (int) (r_shadelight * lightcos);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
// clamp; because we limited the minimum ambient and shading
|
2001-08-28 22:46:02 +00:00
|
|
|
// light, we don't have to clamp low light, just bright
|
2001-02-19 21:15:25 +00:00
|
|
|
if (temp < 0)
|
|
|
|
temp = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
fv->v[4] = temp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
R_AliasProjectFinalVert (finalvert_t *fv, auxvert_t *av)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
float zi;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-15 21:13:07 +00:00
|
|
|
// project points
|
2001-02-19 21:15:25 +00:00
|
|
|
zi = 1.0 / av->fv[2];
|
|
|
|
|
|
|
|
fv->v[5] = zi * ziscale;
|
|
|
|
|
|
|
|
fv->v[0] = (av->fv[0] * aliasxscale * zi) + aliasxcenter;
|
|
|
|
fv->v[1] = (av->fv[1] * aliasyscale * zi) + aliasycenter;
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-26 06:48:02 +00:00
|
|
|
R_AliasPrepareUnclippedPoints (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
stvert_t *pstverts;
|
|
|
|
finalvert_t *fv;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
pstverts = (stvert_t *) ((byte *) paliashdr + paliashdr->stverts);
|
2001-02-19 21:15:25 +00:00
|
|
|
r_anumverts = pmdl->numverts;
|
|
|
|
// FIXME: just use pfinalverts directly?
|
|
|
|
fv = pfinalverts;
|
|
|
|
|
|
|
|
R_AliasTransformAndProjectFinalVerts (fv, pstverts);
|
|
|
|
|
|
|
|
if (r_affinetridesc.drawtype)
|
|
|
|
D_PolysetDrawFinalVerts (fv, r_anumverts);
|
|
|
|
|
|
|
|
r_affinetridesc.pfinalverts = pfinalverts;
|
|
|
|
r_affinetridesc.ptriangles = (mtriangle_t *)
|
2001-02-26 06:48:02 +00:00
|
|
|
((byte *) paliashdr + paliashdr->triangles);
|
2001-02-19 21:15:25 +00:00
|
|
|
r_affinetridesc.numtriangles = pmdl->numtris;
|
|
|
|
|
|
|
|
D_PolysetDraw ();
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
R_AliasSetupSkin (entity_t ent)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-10-25 03:53:30 +00:00
|
|
|
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
|
|
|
int skinnum = renderer->skinnum;
|
2001-02-26 06:48:02 +00:00
|
|
|
if ((skinnum >= pmdl->numskins) || (skinnum < 0)) {
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "R_AliasSetupSkin: no such skin # %d\n",
|
2010-11-23 05:09:30 +00:00
|
|
|
skinnum);
|
2001-02-19 21:15:25 +00:00
|
|
|
skinnum = 0;
|
|
|
|
}
|
|
|
|
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
2022-10-25 03:53:30 +00:00
|
|
|
ent.reg);
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
pskindesc = R_AliasGetSkindesc (animation, skinnum, paliashdr);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2012-01-02 06:57:43 +00:00
|
|
|
a_skinwidth = pmdl->skinwidth;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
r_affinetridesc.pskin = (void *) ((byte *) paliashdr + pskindesc->skin);
|
2001-02-19 21:15:25 +00:00
|
|
|
r_affinetridesc.skinwidth = a_skinwidth;
|
2001-02-26 06:48:02 +00:00
|
|
|
r_affinetridesc.seamfixupX16 = (a_skinwidth >> 1) << 16;
|
2001-02-19 21:15:25 +00:00
|
|
|
r_affinetridesc.skinheight = pmdl->skinheight;
|
2001-05-21 22:25:35 +00:00
|
|
|
|
2022-03-29 04:08:58 +00:00
|
|
|
acolormap = r_colormap;
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
if (renderer->skin) {
|
2001-05-21 22:25:35 +00:00
|
|
|
tex_t *base;
|
|
|
|
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
base = renderer->skin->texels;
|
2001-05-21 22:25:35 +00:00
|
|
|
if (base) {
|
|
|
|
r_affinetridesc.pskin = base->data;
|
|
|
|
r_affinetridesc.skinwidth = base->width;
|
|
|
|
r_affinetridesc.skinheight = base->height;
|
|
|
|
}
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
acolormap = renderer->skin->colormap;
|
2001-05-21 22:25:35 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-15 21:13:07 +00:00
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-03-17 06:04:30 +00:00
|
|
|
R_AliasSetupLighting (alight_t *lighting)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-05-15 21:13:07 +00:00
|
|
|
// guarantee that no vertex will ever be lit below LIGHT_MIN, so we don't
|
|
|
|
// have to clamp off the bottom
|
2022-03-17 06:04:30 +00:00
|
|
|
r_ambientlight = lighting->ambientlight;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (r_ambientlight < LIGHT_MIN)
|
|
|
|
r_ambientlight = LIGHT_MIN;
|
|
|
|
|
|
|
|
r_ambientlight = (255 - r_ambientlight) << VID_CBITS;
|
|
|
|
|
|
|
|
if (r_ambientlight < LIGHT_MIN)
|
|
|
|
r_ambientlight = LIGHT_MIN;
|
|
|
|
|
2022-03-17 06:04:30 +00:00
|
|
|
r_shadelight = lighting->shadelight;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (r_shadelight < 0)
|
|
|
|
r_shadelight = 0;
|
|
|
|
|
|
|
|
r_shadelight *= VID_GRADES;
|
|
|
|
|
2001-05-15 21:13:07 +00:00
|
|
|
// rotate the lighting vector into the model's frame of reference
|
2022-03-17 06:04:30 +00:00
|
|
|
r_lightvec[0] = DotProduct (lighting->lightvec, alias_forward);
|
|
|
|
r_lightvec[1] = DotProduct (lighting->lightvec, alias_left);
|
|
|
|
r_lightvec[2] = DotProduct (lighting->lightvec, alias_up);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-05-15 04:50:53 +00:00
|
|
|
R_AliasSetupFrame
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-15 04:50:53 +00:00
|
|
|
set r_apverts
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
R_AliasSetupFrame (entity_t ent)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2012-01-02 08:47:22 +00:00
|
|
|
maliasframedesc_t *frame;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
2022-10-25 03:53:30 +00:00
|
|
|
ent.reg);
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
frame = R_AliasGetFramedesc (animation, paliashdr);
|
2012-01-02 08:47:22 +00:00
|
|
|
r_apverts = (trivertx_t *) ((byte *) paliashdr + frame->frame);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2002-01-05 17:56:33 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
R_AliasDrawModel (entity_t ent, alight_t *lighting)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2004-02-08 02:49:38 +00:00
|
|
|
int size;
|
2002-01-07 16:43:47 +00:00
|
|
|
finalvert_t *finalverts;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
r_amodels_drawn++;
|
|
|
|
|
2022-10-25 03:53:30 +00:00
|
|
|
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
if (!(paliashdr = renderer->model->aliashdr))
|
|
|
|
paliashdr = Cache_Get (&renderer->model->cache);
|
2002-01-05 17:56:33 +00:00
|
|
|
pmdl = (mdl_t *) ((byte *) paliashdr + paliashdr->model);
|
|
|
|
|
2002-01-07 16:43:47 +00:00
|
|
|
size = (CACHE_SIZE - 1)
|
2004-02-08 02:49:38 +00:00
|
|
|
+ sizeof (finalvert_t) * (pmdl->numverts + 1)
|
|
|
|
+ sizeof (auxvert_t) * pmdl->numverts;
|
2021-07-28 06:01:45 +00:00
|
|
|
finalverts = (finalvert_t *) Hunk_TempAlloc (0, size);
|
2002-01-07 16:43:47 +00:00
|
|
|
if (!finalverts)
|
|
|
|
Sys_Error ("R_AliasDrawModel: out of memory");
|
2002-01-05 17:56:33 +00:00
|
|
|
|
2001-05-15 21:13:07 +00:00
|
|
|
// cache align
|
2001-02-19 21:15:25 +00:00
|
|
|
pfinalverts = (finalvert_t *)
|
2007-04-11 22:03:36 +00:00
|
|
|
(((intptr_t) &finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
|
2002-01-07 16:43:47 +00:00
|
|
|
pauxverts = (auxvert_t *) &pfinalverts[pmdl->numverts + 1];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-07-22 06:39:28 +00:00
|
|
|
R_AliasSetupSkin (ent);
|
2022-10-25 03:53:30 +00:00
|
|
|
visibility_t *visibility = Ent_GetComponent (ent.id, scene_visibility,
|
|
|
|
ent.reg);
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
R_AliasSetUpTransform (ent, visibility->trivial_accept);
|
2022-03-17 06:04:30 +00:00
|
|
|
R_AliasSetupLighting (lighting);
|
2021-07-22 06:39:28 +00:00
|
|
|
R_AliasSetupFrame (ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
r_affinetridesc.drawtype = ((visibility->trivial_accept == 3)
|
2021-03-09 14:52:40 +00:00
|
|
|
&& r_recursiveaffinetriangles);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-02-02 08:32:27 +00:00
|
|
|
if (!acolormap)
|
2022-03-29 04:08:58 +00:00
|
|
|
acolormap = r_colormap;
|
2012-02-02 08:32:27 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (r_affinetridesc.drawtype) {
|
2001-02-19 21:15:25 +00:00
|
|
|
D_PolysetUpdateTables (); // FIXME: precalc...
|
2001-02-26 06:48:02 +00:00
|
|
|
} else {
|
2001-05-15 04:50:53 +00:00
|
|
|
#ifdef USE_INTEL_ASM
|
2012-02-02 08:32:27 +00:00
|
|
|
D_Aff8Patch (acolormap);
|
2001-02-19 21:15:25 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
//FIXME depth hack
|
|
|
|
if (ent.id != vr_data.view_model.id)
|
2001-02-26 06:48:02 +00:00
|
|
|
ziscale = (float) 0x8000 *(float) 0x10000;
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-02-26 06:48:02 +00:00
|
|
|
ziscale = (float) 0x8000 *(float) 0x10000 *3.0;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
if (visibility->trivial_accept && pmdl->ident != HEADER_MDL16) {
|
2001-02-19 21:15:25 +00:00
|
|
|
R_AliasPrepareUnclippedPoints ();
|
2021-03-09 14:52:40 +00:00
|
|
|
} else {
|
2001-02-19 21:15:25 +00:00
|
|
|
R_AliasPreparePoints ();
|
2021-03-09 14:52:40 +00:00
|
|
|
}
|
2001-08-31 12:22:45 +00:00
|
|
|
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
if (!renderer->model->aliashdr) {
|
|
|
|
Cache_Release (&renderer->model->cache);
|
2021-03-09 14:52:40 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|