mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[renderer] Remove currententity from non-sw renderers
Really needed only for vulkan, but removing currententity from gl and glsl made testing easier.
This commit is contained in:
parent
41de8c9187
commit
f1ac8f2460
33 changed files with 304 additions and 225 deletions
|
@ -50,6 +50,8 @@ void gl_lightmap_init (void);
|
||||||
void GL_BuildLightmaps (struct model_s **models, int num_models);
|
void GL_BuildLightmaps (struct model_s **models, int num_models);
|
||||||
void R_BlendLightmaps (void);
|
void R_BlendLightmaps (void);
|
||||||
void R_CalcLightmaps (void);
|
void R_CalcLightmaps (void);
|
||||||
extern void (*R_BuildLightMap) (mod_brush_t *brush, msurface_t *surf);
|
struct transform_s;
|
||||||
|
extern void (*gl_R_BuildLightMap) (const struct transform_s *transform,
|
||||||
|
mod_brush_t *brush, msurface_t *surf);
|
||||||
|
|
||||||
#endif // __QF_GL_lightmap_h
|
#endif // __QF_GL_lightmap_h
|
||||||
|
|
|
@ -39,7 +39,8 @@ typedef struct aliasvrt_s {
|
||||||
} aliasvrt_t;
|
} aliasvrt_t;
|
||||||
|
|
||||||
void glsl_R_InitAlias (void);
|
void glsl_R_InitAlias (void);
|
||||||
void glsl_R_DrawAlias (void);
|
struct entity_s;
|
||||||
|
void glsl_R_DrawAlias (struct entity_s *ent);
|
||||||
void glsl_R_AliasBegin (void);
|
void glsl_R_AliasBegin (void);
|
||||||
void glsl_R_AliasEnd (void);
|
void glsl_R_AliasEnd (void);
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,8 @@ typedef struct glsliqm_s {
|
||||||
} glsliqm_t;
|
} glsliqm_t;
|
||||||
|
|
||||||
void glsl_R_InitIQM (void);
|
void glsl_R_InitIQM (void);
|
||||||
void glsl_R_DrawIQM (void);
|
struct entity_s;
|
||||||
|
void glsl_R_DrawIQM (struct entity_s *ent);
|
||||||
void glsl_R_IQMBegin (void);
|
void glsl_R_IQMBegin (void);
|
||||||
void glsl_R_IQMEnd (void);
|
void glsl_R_IQMEnd (void);
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,11 @@
|
||||||
#define BLOCK_HEIGHT 64
|
#define BLOCK_HEIGHT 64
|
||||||
|
|
||||||
void glsl_lightmap_init (void);
|
void glsl_lightmap_init (void);
|
||||||
|
struct transform_s;
|
||||||
void glsl_R_BuildLightmaps (struct model_s **models, int num_models);
|
void glsl_R_BuildLightmaps (struct model_s **models, int num_models);
|
||||||
void glsl_R_CalcLightmaps (void);
|
void glsl_R_CalcLightmaps (void);
|
||||||
extern void (*glsl_R_BuildLightMap) (mod_brush_t *brush, msurface_t *surf);
|
extern void (*glsl_R_BuildLightMap) (const struct transform_s *transform,
|
||||||
|
mod_brush_t *brush, msurface_t *surf);
|
||||||
int glsl_R_LightmapTexture (void) __attribute__((pure));
|
int glsl_R_LightmapTexture (void) __attribute__((pure));
|
||||||
void glsl_R_FlushLightmaps (void);
|
void glsl_R_FlushLightmaps (void);
|
||||||
|
|
||||||
|
|
36
include/QF/GLSL/qf_sprite.h
Normal file
36
include/QF/GLSL/qf_sprite.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
qf_sprite.h
|
||||||
|
|
||||||
|
GLSL specific sprite model stuff
|
||||||
|
|
||||||
|
Copyright (C) 2021 Bill Currie <bill@taniwha.org>
|
||||||
|
|
||||||
|
Author: Bill Currie <bill@taniwha.org>
|
||||||
|
Date: 2021/7/22
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
*/
|
||||||
|
#ifndef __QF_GLSL_qf_sprite_h
|
||||||
|
#define __QF_GLSL_qf_sprite_h
|
||||||
|
|
||||||
|
struct entity_s;
|
||||||
|
void glsl_R_DrawSprite (struct entity_s *ent);
|
||||||
|
|
||||||
|
#endif//__QF_GLSL_qf_sprite_h
|
|
@ -104,6 +104,7 @@ include_qf_glsl = \
|
||||||
include/QF/GLSL/qf_iqm.h \
|
include/QF/GLSL/qf_iqm.h \
|
||||||
include/QF/GLSL/qf_lightmap.h \
|
include/QF/GLSL/qf_lightmap.h \
|
||||||
include/QF/GLSL/qf_particles.h \
|
include/QF/GLSL/qf_particles.h \
|
||||||
|
include/QF/GLSL/qf_sprite.h \
|
||||||
include/QF/GLSL/qf_textures.h \
|
include/QF/GLSL/qf_textures.h \
|
||||||
include/QF/GLSL/qf_vid.h \
|
include/QF/GLSL/qf_vid.h \
|
||||||
include/QF/GLSL/types.h
|
include/QF/GLSL/types.h
|
||||||
|
|
|
@ -113,6 +113,10 @@ typedef struct texchainset_s
|
||||||
DARRAY_TYPE (vulktex_t *) texchainset_t;
|
DARRAY_TYPE (vulktex_t *) texchainset_t;
|
||||||
|
|
||||||
typedef struct bspctx_s {
|
typedef struct bspctx_s {
|
||||||
|
struct entity_s *entity;
|
||||||
|
vec_t *transform;
|
||||||
|
float *color;
|
||||||
|
|
||||||
instsurf_t *waterchain;
|
instsurf_t *waterchain;
|
||||||
instsurf_t **waterchain_tail;
|
instsurf_t **waterchain_tail;
|
||||||
instsurf_t *sky_chain;
|
instsurf_t *sky_chain;
|
||||||
|
|
|
@ -152,7 +152,7 @@ void R_TransformPlane (plane_t *p, float *normal, float *dist);
|
||||||
void R_TransformFrustum (void);
|
void R_TransformFrustum (void);
|
||||||
void R_SetSkyFrame (void);
|
void R_SetSkyFrame (void);
|
||||||
void R_DrawSurfaceBlock (void);
|
void R_DrawSurfaceBlock (void);
|
||||||
texture_t *R_TextureAnimation (msurface_t *surf) __attribute__((pure));
|
texture_t *R_TextureAnimation (const entity_t *entity, msurface_t *surf) __attribute__((pure));
|
||||||
|
|
||||||
void R_GenSkyTile (void *pdest);
|
void R_GenSkyTile (void *pdest);
|
||||||
void R_SurfPatch (void);
|
void R_SurfPatch (void);
|
||||||
|
@ -164,16 +164,16 @@ surf_t *R_GetSurf (void);
|
||||||
void R_AliasClipAndProjectFinalVert (finalvert_t *fv, auxvert_t *av);
|
void R_AliasClipAndProjectFinalVert (finalvert_t *fv, auxvert_t *av);
|
||||||
void R_AliasDrawModel (alight_t *plighting);
|
void R_AliasDrawModel (alight_t *plighting);
|
||||||
void R_IQMDrawModel (alight_t *plighting);
|
void R_IQMDrawModel (alight_t *plighting);
|
||||||
maliasskindesc_t *R_AliasGetSkindesc (int skinnum, aliashdr_t *hdr);
|
maliasskindesc_t *R_AliasGetSkindesc (animation_t *animation, int skinnum, aliashdr_t *hdr);
|
||||||
maliasframedesc_t *R_AliasGetFramedesc (int framenum, aliashdr_t *hdr);
|
maliasframedesc_t *R_AliasGetFramedesc (animation_t *animation, aliashdr_t *hdr);
|
||||||
float R_AliasGetLerpedFrames (entity_t *ent, aliashdr_t *hdr);
|
float R_AliasGetLerpedFrames (animation_t *animation, aliashdr_t *hdr);
|
||||||
float R_IQMGetLerpedFrames (entity_t *ent, iqm_t *hdr);
|
float R_IQMGetLerpedFrames (entity_t *ent, iqm_t *hdr);
|
||||||
iqmframe_t *R_IQMBlendFrames (const iqm_t *iqm, int frame1, int frame2,
|
iqmframe_t *R_IQMBlendFrames (const iqm_t *iqm, int frame1, int frame2,
|
||||||
float blend, int extra);
|
float blend, int extra);
|
||||||
iqmframe_t *R_IQMBlendPalette (const iqm_t *iqm, int frame1, int frame2,
|
iqmframe_t *R_IQMBlendPalette (const iqm_t *iqm, int frame1, int frame2,
|
||||||
float blend, int extra,
|
float blend, int extra,
|
||||||
iqmblend_t *blend_palette, int palette_size);
|
iqmblend_t *blend_palette, int palette_size);
|
||||||
float R_EntityBlend (entity_t *ent, int pose, float interval);
|
float R_EntityBlend (animation_t *animation, int pose, float interval);
|
||||||
void R_BeginEdgeFrame (void);
|
void R_BeginEdgeFrame (void);
|
||||||
void R_ScanEdges (void);
|
void R_ScanEdges (void);
|
||||||
void D_DrawSurfaces (void);
|
void D_DrawSurfaces (void);
|
||||||
|
|
|
@ -75,7 +75,8 @@ glRect_t gl_lightmap_rectchange[MAX_LIGHTMAPS];
|
||||||
|
|
||||||
static int lmshift = 7;
|
static int lmshift = 7;
|
||||||
|
|
||||||
void (*gl_R_BuildLightMap) (mod_brush_t *brush, msurface_t *surf);
|
void (*gl_R_BuildLightMap) (const transform_t *transform, mod_brush_t *brush,
|
||||||
|
msurface_t *surf);
|
||||||
|
|
||||||
extern void gl_multitexture_f (cvar_t *var);
|
extern void gl_multitexture_f (cvar_t *var);
|
||||||
|
|
||||||
|
@ -108,7 +109,7 @@ R_RecursiveLightUpdate (mnode_t *node)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void
|
||||||
R_AddDynamicLights_1 (msurface_t *surf)
|
R_AddDynamicLights_1 (const transform_t *transform, msurface_t *surf)
|
||||||
{
|
{
|
||||||
float dist;
|
float dist;
|
||||||
unsigned int maxdist, maxdist2, maxdist3;
|
unsigned int maxdist, maxdist2, maxdist3;
|
||||||
|
@ -124,9 +125,9 @@ R_AddDynamicLights_1 (msurface_t *surf)
|
||||||
smax_bytes = smax * gl_internalformat;
|
smax_bytes = smax * gl_internalformat;
|
||||||
tmax = (surf->extents[1] >> 4) + 1;
|
tmax = (surf->extents[1] >> 4) + 1;
|
||||||
|
|
||||||
if (currententity->transform) {
|
if (transform) {
|
||||||
//FIXME give world entity a transform
|
//FIXME give world entity a transform
|
||||||
entorigin = Transform_GetWorldPosition (currententity->transform);
|
entorigin = Transform_GetWorldPosition (transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (lnum = 0; lnum < r_maxdlights; lnum++) {
|
for (lnum = 0; lnum < r_maxdlights; lnum++) {
|
||||||
|
@ -179,7 +180,7 @@ R_AddDynamicLights_1 (msurface_t *surf)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
R_AddDynamicLights_3 (msurface_t *surf)
|
R_AddDynamicLights_3 (const transform_t *transform, msurface_t *surf)
|
||||||
{
|
{
|
||||||
float dist;
|
float dist;
|
||||||
unsigned int maxdist, maxdist2, maxdist3;
|
unsigned int maxdist, maxdist2, maxdist3;
|
||||||
|
@ -195,8 +196,8 @@ R_AddDynamicLights_3 (msurface_t *surf)
|
||||||
smax_bytes = smax * gl_internalformat;
|
smax_bytes = smax * gl_internalformat;
|
||||||
tmax = (surf->extents[1] >> 4) + 1;
|
tmax = (surf->extents[1] >> 4) + 1;
|
||||||
|
|
||||||
if (currententity->transform) {
|
if (transform) {
|
||||||
entorigin = Transform_GetWorldPosition (currententity->transform);
|
entorigin = Transform_GetWorldPosition (transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (lnum = 0; lnum < r_maxdlights; lnum++) {
|
for (lnum = 0; lnum < r_maxdlights; lnum++) {
|
||||||
|
@ -252,7 +253,8 @@ R_AddDynamicLights_3 (msurface_t *surf)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
R_BuildLightMap_1 (mod_brush_t *brush, msurface_t *surf)
|
R_BuildLightMap_1 (const transform_t *transform, mod_brush_t *brush,
|
||||||
|
msurface_t *surf)
|
||||||
{
|
{
|
||||||
byte *dest;
|
byte *dest;
|
||||||
int maps, size, stride, smax, tmax, i, j;
|
int maps, size, stride, smax, tmax, i, j;
|
||||||
|
@ -291,7 +293,7 @@ R_BuildLightMap_1 (mod_brush_t *brush, msurface_t *surf)
|
||||||
}
|
}
|
||||||
// add all the dynamic lights
|
// add all the dynamic lights
|
||||||
if (surf->dlightframe == r_framecount)
|
if (surf->dlightframe == r_framecount)
|
||||||
R_AddDynamicLights_1 (surf);
|
R_AddDynamicLights_1 (transform, surf);
|
||||||
|
|
||||||
store:
|
store:
|
||||||
// bound and shift
|
// bound and shift
|
||||||
|
@ -312,7 +314,8 @@ R_BuildLightMap_1 (mod_brush_t *brush, msurface_t *surf)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
R_BuildLightMap_3 (mod_brush_t *brush, msurface_t *surf)
|
R_BuildLightMap_3 (const transform_t *transform, mod_brush_t *brush,
|
||||||
|
msurface_t *surf)
|
||||||
{
|
{
|
||||||
byte *dest;
|
byte *dest;
|
||||||
int maps, size, stride, smax, tmax, i, j;
|
int maps, size, stride, smax, tmax, i, j;
|
||||||
|
@ -353,7 +356,7 @@ R_BuildLightMap_3 (mod_brush_t *brush, msurface_t *surf)
|
||||||
}
|
}
|
||||||
// add all the dynamic lights
|
// add all the dynamic lights
|
||||||
if (surf->dlightframe == r_framecount)
|
if (surf->dlightframe == r_framecount)
|
||||||
R_AddDynamicLights_3 (surf);
|
R_AddDynamicLights_3 (transform, surf);
|
||||||
|
|
||||||
store:
|
store:
|
||||||
// bound and shift
|
// bound and shift
|
||||||
|
@ -377,7 +380,8 @@ R_BuildLightMap_3 (mod_brush_t *brush, msurface_t *surf)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
R_BuildLightMap_4 (mod_brush_t *brush, msurface_t *surf)
|
R_BuildLightMap_4 (const transform_t *transform, mod_brush_t *brush,
|
||||||
|
msurface_t *surf)
|
||||||
{
|
{
|
||||||
byte *dest;
|
byte *dest;
|
||||||
int maps, size, smax, tmax, i, j, stride;
|
int maps, size, smax, tmax, i, j, stride;
|
||||||
|
@ -418,7 +422,7 @@ R_BuildLightMap_4 (mod_brush_t *brush, msurface_t *surf)
|
||||||
}
|
}
|
||||||
// add all the dynamic lights
|
// add all the dynamic lights
|
||||||
if (surf->dlightframe == r_framecount)
|
if (surf->dlightframe == r_framecount)
|
||||||
R_AddDynamicLights_3 (surf);
|
R_AddDynamicLights_3 (transform, surf);
|
||||||
|
|
||||||
store:
|
store:
|
||||||
// bound and shift
|
// bound and shift
|
||||||
|
@ -614,7 +618,7 @@ gl_overbright_f (cvar_t *var)
|
||||||
gl_lightmap_rectchange[num].w = BLOCK_WIDTH;
|
gl_lightmap_rectchange[num].w = BLOCK_WIDTH;
|
||||||
gl_lightmap_rectchange[num].h = BLOCK_HEIGHT;
|
gl_lightmap_rectchange[num].h = BLOCK_HEIGHT;
|
||||||
|
|
||||||
gl_R_BuildLightMap (brush, surf);
|
gl_R_BuildLightMap (0, brush, surf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -631,7 +635,7 @@ gl_overbright_f (cvar_t *var)
|
||||||
gl_lightmap_rectchange[num].w = BLOCK_WIDTH;
|
gl_lightmap_rectchange[num].w = BLOCK_WIDTH;
|
||||||
gl_lightmap_rectchange[num].h = BLOCK_HEIGHT;
|
gl_lightmap_rectchange[num].h = BLOCK_HEIGHT;
|
||||||
|
|
||||||
gl_R_BuildLightMap (brush, surf);
|
gl_R_BuildLightMap (0, brush, surf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,7 +696,7 @@ GL_CreateSurfaceLightmap (mod_brush_t *brush, msurface_t *surf)
|
||||||
|
|
||||||
surf->lightmaptexturenum =
|
surf->lightmaptexturenum =
|
||||||
AllocBlock (smax, tmax, &surf->light_s, &surf->light_t);
|
AllocBlock (smax, tmax, &surf->light_s, &surf->light_t);
|
||||||
gl_R_BuildLightMap (brush, surf);
|
gl_R_BuildLightMap (0, brush, surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -188,7 +188,8 @@ GL_DrawAliasFrameMulti (vert_order_t *vo)
|
||||||
Standard shadow drawing (triangles version)
|
Standard shadow drawing (triangles version)
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
GL_DrawAliasShadowTri (const aliashdr_t *paliashdr, const vert_order_t *vo)
|
GL_DrawAliasShadowTri (const transform_t *transform,
|
||||||
|
const aliashdr_t *paliashdr, const vert_order_t *vo)
|
||||||
{
|
{
|
||||||
int count = vo->count;
|
int count = vo->count;
|
||||||
const blended_vert_t *verts = vo->verts;
|
const blended_vert_t *verts = vo->verts;
|
||||||
|
@ -198,7 +199,7 @@ GL_DrawAliasShadowTri (const aliashdr_t *paliashdr, const vert_order_t *vo)
|
||||||
const vec_t *scale_origin = paliashdr->mdl.scale_origin;
|
const vec_t *scale_origin = paliashdr->mdl.scale_origin;
|
||||||
vec4f_t entorigin;
|
vec4f_t entorigin;
|
||||||
|
|
||||||
entorigin = Transform_GetWorldPosition (currententity->transform);
|
entorigin = Transform_GetWorldPosition (transform);
|
||||||
lheight = entorigin[2] - lightspot[2];
|
lheight = entorigin[2] - lightspot[2];
|
||||||
height = -lheight + 1.0;
|
height = -lheight + 1.0;
|
||||||
|
|
||||||
|
@ -227,7 +228,8 @@ GL_DrawAliasShadowTri (const aliashdr_t *paliashdr, const vert_order_t *vo)
|
||||||
Standard shadow drawing
|
Standard shadow drawing
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
GL_DrawAliasShadow (const aliashdr_t *paliashdr, const vert_order_t *vo)
|
GL_DrawAliasShadow (const transform_t *transform, const aliashdr_t *paliashdr,
|
||||||
|
const vert_order_t *vo)
|
||||||
{
|
{
|
||||||
float height, lheight;
|
float height, lheight;
|
||||||
int count;
|
int count;
|
||||||
|
@ -236,7 +238,7 @@ GL_DrawAliasShadow (const aliashdr_t *paliashdr, const vert_order_t *vo)
|
||||||
const blended_vert_t *verts = vo->verts;
|
const blended_vert_t *verts = vo->verts;
|
||||||
vec4f_t entorigin;
|
vec4f_t entorigin;
|
||||||
|
|
||||||
entorigin = Transform_GetWorldPosition (currententity->transform);
|
entorigin = Transform_GetWorldPosition (transform);
|
||||||
lheight = entorigin[2] - lightspot[2];
|
lheight = entorigin[2] - lightspot[2];
|
||||||
height = -lheight + 1.0;
|
height = -lheight + 1.0;
|
||||||
|
|
||||||
|
@ -276,13 +278,14 @@ GL_DrawAliasShadow (const aliashdr_t *paliashdr, const vert_order_t *vo)
|
||||||
static inline vert_order_t *
|
static inline vert_order_t *
|
||||||
GL_GetAliasFrameVerts16 (aliashdr_t *paliashdr, entity_t *e)
|
GL_GetAliasFrameVerts16 (aliashdr_t *paliashdr, entity_t *e)
|
||||||
{
|
{
|
||||||
|
animation_t *animation = &e->animation;
|
||||||
float blend;
|
float blend;
|
||||||
int count, i;
|
int count, i;
|
||||||
trivertx16_t *verts;
|
trivertx16_t *verts;
|
||||||
vert_order_t *vo;
|
vert_order_t *vo;
|
||||||
blended_vert_t *vo_v;
|
blended_vert_t *vo_v;
|
||||||
|
|
||||||
blend = R_AliasGetLerpedFrames (e, paliashdr);
|
blend = R_AliasGetLerpedFrames (animation, paliashdr);
|
||||||
|
|
||||||
verts = (trivertx16_t *) ((byte *) paliashdr + paliashdr->posedata);
|
verts = (trivertx16_t *) ((byte *) paliashdr + paliashdr->posedata);
|
||||||
|
|
||||||
|
@ -341,13 +344,14 @@ GL_GetAliasFrameVerts16 (aliashdr_t *paliashdr, entity_t *e)
|
||||||
static inline vert_order_t *
|
static inline vert_order_t *
|
||||||
GL_GetAliasFrameVerts (aliashdr_t *paliashdr, entity_t *e)
|
GL_GetAliasFrameVerts (aliashdr_t *paliashdr, entity_t *e)
|
||||||
{
|
{
|
||||||
|
animation_t *animation = &e->animation;
|
||||||
float blend;
|
float blend;
|
||||||
int count, i;
|
int count, i;
|
||||||
trivertx_t *verts;
|
trivertx_t *verts;
|
||||||
vert_order_t *vo;
|
vert_order_t *vo;
|
||||||
blended_vert_t *vo_v;
|
blended_vert_t *vo_v;
|
||||||
|
|
||||||
blend = R_AliasGetLerpedFrames (e, paliashdr);
|
blend = R_AliasGetLerpedFrames (animation, paliashdr);
|
||||||
|
|
||||||
verts = (trivertx_t *) ((byte *) paliashdr + paliashdr->posedata);
|
verts = (trivertx_t *) ((byte *) paliashdr + paliashdr->posedata);
|
||||||
|
|
||||||
|
@ -566,8 +570,10 @@ gl_R_DrawAliasModel (entity_t *e)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
maliasskindesc_t *skindesc;
|
maliasskindesc_t *skindesc;
|
||||||
|
animation_t *animation = &e->animation;
|
||||||
|
|
||||||
skindesc = R_AliasGetSkindesc (e->renderer.skinnum, paliashdr);
|
skindesc = R_AliasGetSkindesc (animation, e->renderer.skinnum,
|
||||||
|
paliashdr);
|
||||||
texture = skindesc->texnum;
|
texture = skindesc->texnum;
|
||||||
if (gl_fb_models->int_val && !is_fullbright) {
|
if (gl_fb_models->int_val && !is_fullbright) {
|
||||||
fb_texture = skindesc->fb_texnum;
|
fb_texture = skindesc->fb_texnum;
|
||||||
|
@ -718,9 +724,9 @@ gl_R_DrawAliasModel (entity_t *e)
|
||||||
vec = m3vmulf (shadow_mat, vec);
|
vec = m3vmulf (shadow_mat, vec);
|
||||||
VectorCopy (vec, shadevector);
|
VectorCopy (vec, shadevector);
|
||||||
if (vo->tex_coord)
|
if (vo->tex_coord)
|
||||||
GL_DrawAliasShadowTri (paliashdr, vo);
|
GL_DrawAliasShadowTri (e->transform, paliashdr, vo);
|
||||||
else
|
else
|
||||||
GL_DrawAliasShadow (paliashdr, vo);
|
GL_DrawAliasShadow (e->transform, paliashdr, vo);
|
||||||
|
|
||||||
qfglDepthMask (GL_TRUE);
|
qfglDepthMask (GL_TRUE);
|
||||||
qfglEnable (GL_TEXTURE_2D);
|
qfglEnable (GL_TEXTURE_2D);
|
||||||
|
|
|
@ -58,7 +58,7 @@ void (*gl_R_DrawSpriteModel) (struct entity_s *ent);
|
||||||
|
|
||||||
|
|
||||||
static mspriteframe_t *
|
static mspriteframe_t *
|
||||||
R_GetSpriteFrame (entity_t *currententity)
|
R_GetSpriteFrame (entity_t *ent)
|
||||||
{
|
{
|
||||||
float fullinterval, targettime, time;
|
float fullinterval, targettime, time;
|
||||||
float *pintervals;
|
float *pintervals;
|
||||||
|
@ -67,8 +67,8 @@ R_GetSpriteFrame (entity_t *currententity)
|
||||||
mspriteframe_t *pspriteframe;
|
mspriteframe_t *pspriteframe;
|
||||||
mspritegroup_t *pspritegroup;
|
mspritegroup_t *pspritegroup;
|
||||||
|
|
||||||
psprite = currententity->renderer.model->cache.data;
|
psprite = ent->renderer.model->cache.data;
|
||||||
frame = currententity->animation.frame;
|
frame = ent->animation.frame;
|
||||||
|
|
||||||
if ((frame >= psprite->numframes) || (frame < 0)) {
|
if ((frame >= psprite->numframes) || (frame < 0)) {
|
||||||
Sys_MaskPrintf (SYS_dev, "R_DrawSprite: no such frame %d\n", frame);
|
Sys_MaskPrintf (SYS_dev, "R_DrawSprite: no such frame %d\n", frame);
|
||||||
|
@ -83,7 +83,7 @@ R_GetSpriteFrame (entity_t *currententity)
|
||||||
numframes = pspritegroup->numframes;
|
numframes = pspritegroup->numframes;
|
||||||
fullinterval = pintervals[numframes - 1];
|
fullinterval = pintervals[numframes - 1];
|
||||||
|
|
||||||
time = vr_data.realtime + currententity->animation.syncbase;
|
time = vr_data.realtime + ent->animation.syncbase;
|
||||||
|
|
||||||
// when loading in Mod_LoadSpriteGroup, we guaranteed all interval
|
// when loading in Mod_LoadSpriteGroup, we guaranteed all interval
|
||||||
// values are positive, so we don't have to worry about division by 0
|
// values are positive, so we don't have to worry about division by 0
|
||||||
|
|
|
@ -221,9 +221,7 @@ R_DrawEntitiesOnList (void)
|
||||||
for (ent = r_ent_queue; ent; ent = ent->next) {
|
for (ent = r_ent_queue; ent; ent = ent->next) {
|
||||||
if (ent->renderer.model->type != mod_alias)
|
if (ent->renderer.model->type != mod_alias)
|
||||||
continue;
|
continue;
|
||||||
currententity = ent;
|
gl_R_DrawAliasModel (ent);
|
||||||
|
|
||||||
gl_R_DrawAliasModel (currententity);
|
|
||||||
}
|
}
|
||||||
qfglColor3ubv (color_white);
|
qfglColor3ubv (color_white);
|
||||||
|
|
||||||
|
@ -253,9 +251,7 @@ R_DrawEntitiesOnList (void)
|
||||||
for (ent = r_ent_queue; ent; ent = ent->next) {
|
for (ent = r_ent_queue; ent; ent = ent->next) {
|
||||||
if (ent->renderer.model->type != mod_iqm)
|
if (ent->renderer.model->type != mod_iqm)
|
||||||
continue;
|
continue;
|
||||||
currententity = ent;
|
gl_R_DrawIQMModel (ent);
|
||||||
|
|
||||||
gl_R_DrawIQMModel (currententity);
|
|
||||||
}
|
}
|
||||||
qfglColor3ubv (color_white);
|
qfglColor3ubv (color_white);
|
||||||
|
|
||||||
|
@ -266,9 +262,7 @@ R_DrawEntitiesOnList (void)
|
||||||
for (ent = r_ent_queue; ent; ent = ent->next) {
|
for (ent = r_ent_queue; ent; ent = ent->next) {
|
||||||
if (ent->renderer.model->type != mod_sprite)
|
if (ent->renderer.model->type != mod_sprite)
|
||||||
continue;
|
continue;
|
||||||
currententity = ent;
|
R_DrawSpriteModel (ent);
|
||||||
|
|
||||||
R_DrawSpriteModel (currententity);
|
|
||||||
}
|
}
|
||||||
qfglDisable (GL_ALPHA_TEST);
|
qfglDisable (GL_ALPHA_TEST);
|
||||||
}
|
}
|
||||||
|
@ -276,12 +270,12 @@ R_DrawEntitiesOnList (void)
|
||||||
static void
|
static void
|
||||||
R_DrawViewModel (void)
|
R_DrawViewModel (void)
|
||||||
{
|
{
|
||||||
currententity = vr_data.view_model;
|
entity_t *ent = vr_data.view_model;
|
||||||
if (vr_data.inhibit_viewmodel
|
if (vr_data.inhibit_viewmodel
|
||||||
|| !r_drawviewmodel->int_val
|
|| !r_drawviewmodel->int_val
|
||||||
|| gl_envmap
|
|| gl_envmap
|
||||||
|| !r_drawentities->int_val
|
|| !r_drawentities->int_val
|
||||||
|| !currententity->renderer.model)
|
|| !ent->renderer.model)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// hack the depth range to prevent view model from poking into walls
|
// hack the depth range to prevent view model from poking into walls
|
||||||
|
@ -305,7 +299,7 @@ R_DrawViewModel (void)
|
||||||
qglActiveTexture (gl_mtex_enum + 0);
|
qglActiveTexture (gl_mtex_enum + 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_R_DrawAliasModel (currententity);
|
gl_R_DrawAliasModel (ent);
|
||||||
|
|
||||||
qfglColor3ubv (color_white);
|
qfglColor3ubv (color_white);
|
||||||
if (gl_mtex_active_tmus >= 2) { // FIXME: Ugly, but faster than cleaning
|
if (gl_mtex_active_tmus >= 2) { // FIXME: Ugly, but faster than cleaning
|
||||||
|
|
|
@ -65,6 +65,13 @@ static instsurf_t **waterchain_tail = &waterchain;
|
||||||
static instsurf_t *sky_chain;
|
static instsurf_t *sky_chain;
|
||||||
static instsurf_t **sky_chain_tail;
|
static instsurf_t **sky_chain_tail;
|
||||||
|
|
||||||
|
typedef struct glbspctx_s {
|
||||||
|
mod_brush_t *brush;
|
||||||
|
entity_t *entity;
|
||||||
|
vec_t *transform;
|
||||||
|
float *color;
|
||||||
|
} glbspctx_t;
|
||||||
|
|
||||||
#define CHAIN_SURF_F2B(surf,chain) \
|
#define CHAIN_SURF_F2B(surf,chain) \
|
||||||
({ \
|
({ \
|
||||||
instsurf_t *inst = (surf)->instsurf; \
|
instsurf_t *inst = (surf)->instsurf; \
|
||||||
|
@ -270,7 +277,7 @@ R_RenderBrushPoly_1 (msurface_t *surf)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
R_AddToLightmapChain (mod_brush_t *brush, msurface_t *surf, instsurf_t *sc)
|
R_AddToLightmapChain (glbspctx_t *bctx, msurface_t *surf, instsurf_t *sc)
|
||||||
{
|
{
|
||||||
int maps, smax, tmax;
|
int maps, smax, tmax;
|
||||||
glRect_t *theRect;
|
glRect_t *theRect;
|
||||||
|
@ -305,7 +312,7 @@ R_AddToLightmapChain (mod_brush_t *brush, msurface_t *surf, instsurf_t *sc)
|
||||||
theRect->w = (surf->light_s - theRect->l) + smax;
|
theRect->w = (surf->light_s - theRect->l) + smax;
|
||||||
if ((theRect->h + theRect->t) < (surf->light_t + tmax))
|
if ((theRect->h + theRect->t) < (surf->light_t + tmax))
|
||||||
theRect->h = (surf->light_t - theRect->t) + tmax;
|
theRect->h = (surf->light_t - theRect->t) + tmax;
|
||||||
gl_R_BuildLightMap (brush, surf);
|
gl_R_BuildLightMap (bctx->entity->transform, bctx->brush, surf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -489,8 +496,7 @@ clear_texture_chains (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
chain_surface (mod_brush_t *brush, msurface_t *surf, vec_t *transform,
|
chain_surface (glbspctx_t *bctx, msurface_t *surf)
|
||||||
float *color)
|
|
||||||
{
|
{
|
||||||
instsurf_t *sc;
|
instsurf_t *sc;
|
||||||
|
|
||||||
|
@ -505,14 +511,14 @@ chain_surface (mod_brush_t *brush, msurface_t *surf, vec_t *transform,
|
||||||
if (!surf->texinfo->texture->anim_total)
|
if (!surf->texinfo->texture->anim_total)
|
||||||
tx = surf->texinfo->texture;
|
tx = surf->texinfo->texture;
|
||||||
else
|
else
|
||||||
tx = R_TextureAnimation (surf);
|
tx = R_TextureAnimation (bctx->entity, surf);
|
||||||
tex = tx->render;
|
tex = tx->render;
|
||||||
sc = CHAIN_SURF_F2B (surf, tex->tex_chain);
|
sc = CHAIN_SURF_F2B (surf, tex->tex_chain);
|
||||||
|
|
||||||
R_AddToLightmapChain (brush, surf, sc);
|
R_AddToLightmapChain (bctx, surf, sc);
|
||||||
}
|
}
|
||||||
sc->transform = transform;
|
sc->transform = bctx->transform;
|
||||||
sc->color = color;
|
sc->color = bctx->color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -521,15 +527,18 @@ gl_R_DrawBrushModel (entity_t *e)
|
||||||
float dot, radius;
|
float dot, radius;
|
||||||
int i;
|
int i;
|
||||||
unsigned int k;
|
unsigned int k;
|
||||||
model_t *model;
|
|
||||||
msurface_t *surf;
|
msurface_t *surf;
|
||||||
qboolean rotated;
|
qboolean rotated;
|
||||||
vec3_t mins, maxs;
|
vec3_t mins, maxs;
|
||||||
mod_brush_t *brush;
|
|
||||||
mat4f_t worldMatrix;
|
mat4f_t worldMatrix;
|
||||||
|
model_t *model = e->renderer.model;
|
||||||
model = e->renderer.model;
|
mod_brush_t *brush = &model->brush;
|
||||||
brush = &model->brush;
|
glbspctx_t bspctx = {
|
||||||
|
brush,
|
||||||
|
e,
|
||||||
|
e->renderer.full_transform,
|
||||||
|
e->renderer.colormod,
|
||||||
|
};
|
||||||
|
|
||||||
Transform_GetWorldMatrix (e->transform, worldMatrix);
|
Transform_GetWorldMatrix (e->transform, worldMatrix);
|
||||||
if (worldMatrix[0][0] != 1 || worldMatrix[1][1] != 1
|
if (worldMatrix[0][0] != 1 || worldMatrix[1][1] != 1
|
||||||
|
@ -598,8 +607,7 @@ gl_R_DrawBrushModel (entity_t *e)
|
||||||
// draw the polygon
|
// draw the polygon
|
||||||
if (((surf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
|
if (((surf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
|
||||||
(!(surf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) {
|
(!(surf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) {
|
||||||
chain_surface (brush, surf, e->renderer.full_transform,
|
chain_surface (&bspctx, surf);
|
||||||
e->renderer.colormod);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -626,7 +634,7 @@ get_side (mnode_t *node)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
visit_node (mod_brush_t *brush, mnode_t *node, int side)
|
visit_node (glbspctx_t *bctx, mnode_t *node, int side)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
msurface_t *surf;
|
msurface_t *surf;
|
||||||
|
@ -635,7 +643,7 @@ visit_node (mod_brush_t *brush, mnode_t *node, int side)
|
||||||
side = (~side + 1) & SURF_PLANEBACK;
|
side = (~side + 1) & SURF_PLANEBACK;
|
||||||
// draw stuff
|
// draw stuff
|
||||||
if ((c = node->numsurfaces)) {
|
if ((c = node->numsurfaces)) {
|
||||||
surf = brush->surfaces + node->firstsurface;
|
surf = bctx->brush->surfaces + node->firstsurface;
|
||||||
for (; c; c--, surf++) {
|
for (; c; c--, surf++) {
|
||||||
if (surf->visframe != r_visframecount)
|
if (surf->visframe != r_visframecount)
|
||||||
continue;
|
continue;
|
||||||
|
@ -644,7 +652,7 @@ visit_node (mod_brush_t *brush, mnode_t *node, int side)
|
||||||
if (side ^ (surf->flags & SURF_PLANEBACK))
|
if (side ^ (surf->flags & SURF_PLANEBACK))
|
||||||
continue; // wrong side
|
continue; // wrong side
|
||||||
|
|
||||||
chain_surface (brush, surf, 0, 0);
|
chain_surface (bctx, surf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -662,12 +670,13 @@ test_node (mnode_t *node)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
R_VisitWorldNodes (mod_brush_t *brush)
|
R_VisitWorldNodes (glbspctx_t *bctx)
|
||||||
{
|
{
|
||||||
typedef struct {
|
typedef struct {
|
||||||
mnode_t *node;
|
mnode_t *node;
|
||||||
int side;
|
int side;
|
||||||
} rstack_t;
|
} rstack_t;
|
||||||
|
mod_brush_t *brush = bctx->brush;
|
||||||
rstack_t *node_ptr;
|
rstack_t *node_ptr;
|
||||||
rstack_t *node_stack;
|
rstack_t *node_stack;
|
||||||
mnode_t *node;
|
mnode_t *node;
|
||||||
|
@ -692,7 +701,7 @@ R_VisitWorldNodes (mod_brush_t *brush)
|
||||||
}
|
}
|
||||||
if (front->contents < 0 && front->contents != CONTENTS_SOLID)
|
if (front->contents < 0 && front->contents != CONTENTS_SOLID)
|
||||||
visit_leaf ((mleaf_t *) front);
|
visit_leaf ((mleaf_t *) front);
|
||||||
visit_node (brush, node, side);
|
visit_node (bctx, node, side);
|
||||||
node = node->children[!side];
|
node = node->children[!side];
|
||||||
}
|
}
|
||||||
if (node->contents < 0 && node->contents != CONTENTS_SOLID)
|
if (node->contents < 0 && node->contents != CONTENTS_SOLID)
|
||||||
|
@ -701,7 +710,7 @@ R_VisitWorldNodes (mod_brush_t *brush)
|
||||||
node_ptr--;
|
node_ptr--;
|
||||||
node = node_ptr->node;
|
node = node_ptr->node;
|
||||||
side = node_ptr->side;
|
side = node_ptr->side;
|
||||||
visit_node (brush, node, side);
|
visit_node (bctx, node, side);
|
||||||
node = node->children[!side];
|
node = node->children[!side];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -715,30 +724,30 @@ void
|
||||||
gl_R_DrawWorld (void)
|
gl_R_DrawWorld (void)
|
||||||
{
|
{
|
||||||
entity_t worldent;
|
entity_t worldent;
|
||||||
|
glbspctx_t bctx = { };
|
||||||
|
|
||||||
memset (&worldent, 0, sizeof (worldent));
|
memset (&worldent, 0, sizeof (worldent));
|
||||||
worldent.renderer.model = r_worldentity.renderer.model;
|
worldent.renderer.model = r_worldentity.renderer.model;
|
||||||
|
|
||||||
VectorCopy (r_refdef.viewposition, modelorg);
|
VectorCopy (r_refdef.viewposition, modelorg);
|
||||||
|
|
||||||
currententity = &worldent;
|
|
||||||
|
|
||||||
sky_chain = 0;
|
sky_chain = 0;
|
||||||
sky_chain_tail = &sky_chain;
|
sky_chain_tail = &sky_chain;
|
||||||
if (!gl_sky_clip->int_val) {
|
if (!gl_sky_clip->int_val) {
|
||||||
gl_R_DrawSky ();
|
gl_R_DrawSky ();
|
||||||
}
|
}
|
||||||
|
|
||||||
R_VisitWorldNodes (&r_worldentity.renderer.model->brush);
|
bctx.brush = &worldent.renderer.model->brush;
|
||||||
|
bctx.entity = &r_worldentity;
|
||||||
|
|
||||||
|
R_VisitWorldNodes (&bctx);
|
||||||
if (r_drawentities->int_val) {
|
if (r_drawentities->int_val) {
|
||||||
entity_t *ent;
|
entity_t *ent;
|
||||||
for (ent = r_ent_queue; ent; ent = ent->next) {
|
for (ent = r_ent_queue; ent; ent = ent->next) {
|
||||||
if (ent->renderer.model->type != mod_brush) {
|
if (ent->renderer.model->type != mod_brush) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
currententity = ent;
|
gl_R_DrawBrushModel (ent);
|
||||||
|
|
||||||
gl_R_DrawBrushModel (currententity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
#define Fog_Update gl_Fog_Update
|
#define Fog_Update gl_Fog_Update
|
||||||
#define R_AddTexture gl_R_AddTexture
|
#define R_AddTexture gl_R_AddTexture
|
||||||
#define R_BlendLightmaps gl_R_BlendLightmaps
|
#define R_BlendLightmaps gl_R_BlendLightmaps
|
||||||
#define R_BuildLightMap gl_R_BuildLightMap
|
|
||||||
#define R_CalcLightmaps gl_R_CalcLightmaps
|
#define R_CalcLightmaps gl_R_CalcLightmaps
|
||||||
#define R_ClearParticles gl_R_ClearParticles
|
#define R_ClearParticles gl_R_ClearParticles
|
||||||
#define R_ClearState gl_R_ClearState
|
#define R_ClearState gl_R_ClearState
|
||||||
|
@ -88,7 +87,6 @@
|
||||||
#undef Fog_Update
|
#undef Fog_Update
|
||||||
#undef R_AddTexture
|
#undef R_AddTexture
|
||||||
#undef R_BlendLightmaps
|
#undef R_BlendLightmaps
|
||||||
#undef R_BuildLightMap
|
|
||||||
#undef R_CalcLightmaps
|
#undef R_CalcLightmaps
|
||||||
#undef R_ClearParticles
|
#undef R_ClearParticles
|
||||||
#undef R_ClearState
|
#undef R_ClearState
|
||||||
|
|
|
@ -210,7 +210,7 @@ set_arrays (const shaderparam_t *vert, const shaderparam_t *norm,
|
||||||
}
|
}
|
||||||
//#define TETRAHEDRON
|
//#define TETRAHEDRON
|
||||||
void
|
void
|
||||||
glsl_R_DrawAlias (void)
|
glsl_R_DrawAlias (entity_t *ent)
|
||||||
{
|
{
|
||||||
#ifdef TETRAHEDRON
|
#ifdef TETRAHEDRON
|
||||||
static aliasvrt_t debug_verts[] = {
|
static aliasvrt_t debug_verts[] = {
|
||||||
|
@ -232,7 +232,7 @@ glsl_R_DrawAlias (void)
|
||||||
float shadelight;
|
float shadelight;
|
||||||
float skin_size[2];
|
float skin_size[2];
|
||||||
float blend;
|
float blend;
|
||||||
entity_t *ent = currententity;
|
animation_t *animation = &ent->animation;
|
||||||
model_t *model = ent->renderer.model;
|
model_t *model = ent->renderer.model;
|
||||||
aliashdr_t *hdr;
|
aliashdr_t *hdr;
|
||||||
vec_t norm_mat[9];
|
vec_t norm_mat[9];
|
||||||
|
@ -272,13 +272,13 @@ glsl_R_DrawAlias (void)
|
||||||
skin_tex = skin->texnum;
|
skin_tex = skin->texnum;
|
||||||
} else {
|
} else {
|
||||||
maliasskindesc_t *skindesc;
|
maliasskindesc_t *skindesc;
|
||||||
skindesc = R_AliasGetSkindesc (ent->renderer.skinnum, hdr);
|
skindesc = R_AliasGetSkindesc (animation, ent->renderer.skinnum, hdr);
|
||||||
skin_tex = skindesc->texnum;
|
skin_tex = skindesc->texnum;
|
||||||
}
|
}
|
||||||
blend = R_AliasGetLerpedFrames (ent, hdr);
|
blend = R_AliasGetLerpedFrames (animation, hdr);
|
||||||
|
|
||||||
pose1 += ent->animation.pose1 * hdr->poseverts;
|
pose1 += animation->pose1 * hdr->poseverts;
|
||||||
pose2 += ent->animation.pose2 * hdr->poseverts;
|
pose2 += animation->pose2 * hdr->poseverts;
|
||||||
|
|
||||||
skin_size[0] = hdr->mdl.skinwidth;
|
skin_size[0] = hdr->mdl.skinwidth;
|
||||||
skin_size[1] = hdr->mdl.skinheight;
|
skin_size[1] = hdr->mdl.skinheight;
|
||||||
|
|
|
@ -237,6 +237,14 @@ static struct {
|
||||||
shaderparam_t *fog;
|
shaderparam_t *fog;
|
||||||
} sky_params;
|
} sky_params;
|
||||||
|
|
||||||
|
typedef struct glslbspctx_s {
|
||||||
|
mod_brush_t *brush;
|
||||||
|
entity_t *entity;
|
||||||
|
vec_t *transform;
|
||||||
|
float *color;
|
||||||
|
} glslbspctx_t;
|
||||||
|
|
||||||
|
|
||||||
#define CHAIN_SURF_F2B(surf,chain) \
|
#define CHAIN_SURF_F2B(surf,chain) \
|
||||||
({ \
|
({ \
|
||||||
instsurf_t *inst = (surf)->instsurf; \
|
instsurf_t *inst = (surf)->instsurf; \
|
||||||
|
@ -360,7 +368,7 @@ glsl_R_ClearElements (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_lightmap (mod_brush_t *brush, msurface_t *surf)
|
update_lightmap (glslbspctx_t *bctx, msurface_t *surf)
|
||||||
{
|
{
|
||||||
int maps;
|
int maps;
|
||||||
|
|
||||||
|
@ -371,19 +379,19 @@ update_lightmap (mod_brush_t *brush, msurface_t *surf)
|
||||||
if ((surf->dlightframe == r_framecount) || surf->cached_dlight) {
|
if ((surf->dlightframe == r_framecount) || surf->cached_dlight) {
|
||||||
dynamic:
|
dynamic:
|
||||||
if (r_dynamic->int_val)
|
if (r_dynamic->int_val)
|
||||||
glsl_R_BuildLightMap (brush, surf);
|
glsl_R_BuildLightMap (bctx->entity->transform, bctx->brush, surf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
chain_surface (mod_brush_t *brush, msurface_t *surf, vec_t *transform,
|
chain_surface (glslbspctx_t *bctx, msurface_t *surf)
|
||||||
float *color)
|
|
||||||
{
|
{
|
||||||
instsurf_t *is;
|
instsurf_t *is;
|
||||||
|
|
||||||
if (surf->flags & SURF_DRAWSKY) {
|
if (surf->flags & SURF_DRAWSKY) {
|
||||||
is = CHAIN_SURF_F2B (surf, sky_chain);
|
is = CHAIN_SURF_F2B (surf, sky_chain);
|
||||||
} else if ((surf->flags & SURF_DRAWTURB) || (color && color[3] < 1.0)) {
|
} else if ((surf->flags & SURF_DRAWTURB)
|
||||||
|
|| (bctx->color && bctx->color[3] < 1.0)) {
|
||||||
is = CHAIN_SURF_B2F (surf, waterchain);
|
is = CHAIN_SURF_B2F (surf, waterchain);
|
||||||
} else {
|
} else {
|
||||||
texture_t *tx;
|
texture_t *tx;
|
||||||
|
@ -392,14 +400,14 @@ chain_surface (mod_brush_t *brush, msurface_t *surf, vec_t *transform,
|
||||||
if (!surf->texinfo->texture->anim_total)
|
if (!surf->texinfo->texture->anim_total)
|
||||||
tx = surf->texinfo->texture;
|
tx = surf->texinfo->texture;
|
||||||
else
|
else
|
||||||
tx = R_TextureAnimation (surf);
|
tx = R_TextureAnimation (bctx->entity, surf);
|
||||||
tex = tx->render;
|
tex = tx->render;
|
||||||
is = CHAIN_SURF_F2B (surf, tex->tex_chain);
|
is = CHAIN_SURF_F2B (surf, tex->tex_chain);
|
||||||
|
|
||||||
update_lightmap (brush, surf);
|
update_lightmap (bctx, surf);
|
||||||
}
|
}
|
||||||
is->transform = transform;
|
is->transform = bctx->transform;
|
||||||
is->color = color;
|
is->color = bctx->color;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -656,16 +664,20 @@ R_DrawBrushModel (entity_t *e)
|
||||||
float dot, radius;
|
float dot, radius;
|
||||||
int i;
|
int i;
|
||||||
unsigned k;
|
unsigned k;
|
||||||
model_t *model;
|
model_t *model = e->renderer.model;
|
||||||
|
mod_brush_t *brush = &model->brush;
|
||||||
plane_t *plane;
|
plane_t *plane;
|
||||||
msurface_t *surf;
|
msurface_t *surf;
|
||||||
qboolean rotated;
|
qboolean rotated;
|
||||||
vec3_t mins, maxs;
|
vec3_t mins, maxs;
|
||||||
vec4f_t org;
|
vec4f_t org;
|
||||||
mod_brush_t *brush;
|
glslbspctx_t bctx = {
|
||||||
|
brush,
|
||||||
|
e,
|
||||||
|
e->renderer.full_transform,
|
||||||
|
e->renderer.colormod,
|
||||||
|
};
|
||||||
|
|
||||||
model = e->renderer.model;
|
|
||||||
brush = &model->brush;
|
|
||||||
mat4f_t mat;
|
mat4f_t mat;
|
||||||
Transform_GetWorldMatrix (e->transform, mat);
|
Transform_GetWorldMatrix (e->transform, mat);
|
||||||
memcpy (e->renderer.full_transform, mat, sizeof (mat));//FIXME
|
memcpy (e->renderer.full_transform, mat, sizeof (mat));//FIXME
|
||||||
|
@ -718,8 +730,7 @@ R_DrawBrushModel (entity_t *e)
|
||||||
// enqueue the polygon
|
// enqueue the polygon
|
||||||
if (((surf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON))
|
if (((surf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON))
|
||||||
|| (!(surf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) {
|
|| (!(surf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) {
|
||||||
chain_surface (brush, surf, e->renderer.full_transform,
|
chain_surface (&bctx, surf);
|
||||||
e->renderer.colormod);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -744,7 +755,7 @@ get_side (mnode_t *node)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
visit_node (mod_brush_t *brush, mnode_t *node, int side)
|
visit_node (glslbspctx_t *bctx, mnode_t *node, int side)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
msurface_t *surf;
|
msurface_t *surf;
|
||||||
|
@ -753,7 +764,7 @@ visit_node (mod_brush_t *brush, mnode_t *node, int side)
|
||||||
side = (~side + 1) & SURF_PLANEBACK;
|
side = (~side + 1) & SURF_PLANEBACK;
|
||||||
// draw stuff
|
// draw stuff
|
||||||
if ((c = node->numsurfaces)) {
|
if ((c = node->numsurfaces)) {
|
||||||
surf = brush->surfaces + node->firstsurface;
|
surf = bctx->brush->surfaces + node->firstsurface;
|
||||||
for (; c; c--, surf++) {
|
for (; c; c--, surf++) {
|
||||||
if (surf->visframe != r_visframecount)
|
if (surf->visframe != r_visframecount)
|
||||||
continue;
|
continue;
|
||||||
|
@ -762,7 +773,7 @@ visit_node (mod_brush_t *brush, mnode_t *node, int side)
|
||||||
if (side ^ (surf->flags & SURF_PLANEBACK))
|
if (side ^ (surf->flags & SURF_PLANEBACK))
|
||||||
continue; // wrong side
|
continue; // wrong side
|
||||||
|
|
||||||
chain_surface (brush, surf, 0, 0);
|
chain_surface (bctx, surf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -780,12 +791,13 @@ test_node (mnode_t *node)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
R_VisitWorldNodes (mod_brush_t *brush)
|
R_VisitWorldNodes (glslbspctx_t *bctx)
|
||||||
{
|
{
|
||||||
typedef struct {
|
typedef struct {
|
||||||
mnode_t *node;
|
mnode_t *node;
|
||||||
int side;
|
int side;
|
||||||
} rstack_t;
|
} rstack_t;
|
||||||
|
mod_brush_t *brush = bctx->brush;
|
||||||
rstack_t *node_ptr;
|
rstack_t *node_ptr;
|
||||||
rstack_t *node_stack;
|
rstack_t *node_stack;
|
||||||
mnode_t *node;
|
mnode_t *node;
|
||||||
|
@ -810,7 +822,7 @@ R_VisitWorldNodes (mod_brush_t *brush)
|
||||||
}
|
}
|
||||||
if (front->contents < 0 && front->contents != CONTENTS_SOLID)
|
if (front->contents < 0 && front->contents != CONTENTS_SOLID)
|
||||||
visit_leaf ((mleaf_t *) front);
|
visit_leaf ((mleaf_t *) front);
|
||||||
visit_node (brush, node, side);
|
visit_node (bctx, node, side);
|
||||||
node = node->children[!side];
|
node = node->children[!side];
|
||||||
}
|
}
|
||||||
if (node->contents < 0 && node->contents != CONTENTS_SOLID)
|
if (node->contents < 0 && node->contents != CONTENTS_SOLID)
|
||||||
|
@ -819,7 +831,7 @@ R_VisitWorldNodes (mod_brush_t *brush)
|
||||||
node_ptr--;
|
node_ptr--;
|
||||||
node = node_ptr->node;
|
node = node_ptr->node;
|
||||||
side = node_ptr->side;
|
side = node_ptr->side;
|
||||||
visit_node (brush, node, side);
|
visit_node (bctx, node, side);
|
||||||
node = node->children[!side];
|
node = node->children[!side];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1128,6 +1140,7 @@ void
|
||||||
glsl_R_DrawWorld (void)
|
glsl_R_DrawWorld (void)
|
||||||
{
|
{
|
||||||
entity_t worldent;
|
entity_t worldent;
|
||||||
|
glslbspctx_t bctx = { };
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
clear_texture_chains (); // do this first for water and skys
|
clear_texture_chains (); // do this first for water and skys
|
||||||
|
@ -1135,16 +1148,15 @@ glsl_R_DrawWorld (void)
|
||||||
memset (&worldent, 0, sizeof (worldent));
|
memset (&worldent, 0, sizeof (worldent));
|
||||||
worldent.renderer.model = r_worldentity.renderer.model;
|
worldent.renderer.model = r_worldentity.renderer.model;
|
||||||
|
|
||||||
currententity = &worldent;
|
bctx.brush = &worldent.renderer.model->brush;
|
||||||
|
bctx.entity = &r_worldentity;
|
||||||
|
|
||||||
R_VisitWorldNodes (&worldent.renderer.model->brush);
|
R_VisitWorldNodes (&bctx);
|
||||||
if (r_drawentities->int_val) {
|
if (r_drawentities->int_val) {
|
||||||
entity_t *ent;
|
entity_t *ent;
|
||||||
for (ent = r_ent_queue; ent; ent = ent->next) {
|
for (ent = r_ent_queue; ent; ent = ent->next) {
|
||||||
if (ent->renderer.model->type != mod_brush)
|
if (ent->renderer.model->type != mod_brush)
|
||||||
continue;
|
continue;
|
||||||
currententity = ent;
|
|
||||||
|
|
||||||
R_DrawBrushModel (ent);
|
R_DrawBrushModel (ent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,10 +204,9 @@ set_arrays (iqm_t *iqm)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glsl_R_DrawIQM (void)
|
glsl_R_DrawIQM (entity_t *ent)
|
||||||
{
|
{
|
||||||
static quat_t color = { 1, 1, 1, 1};
|
static quat_t color = { 1, 1, 1, 1};
|
||||||
entity_t *ent = currententity;
|
|
||||||
model_t *model = ent->renderer.model;
|
model_t *model = ent->renderer.model;
|
||||||
iqm_t *iqm = (iqm_t *) model->aliashdr;
|
iqm_t *iqm = (iqm_t *) model->aliashdr;
|
||||||
glsliqm_t *glsl = (glsliqm_t *) iqm->extra_data;
|
glsliqm_t *glsl = (glsliqm_t *) iqm->extra_data;
|
||||||
|
|
|
@ -62,10 +62,11 @@ static scrap_t *light_scrap;
|
||||||
static unsigned *blocklights;
|
static unsigned *blocklights;
|
||||||
static int bl_extents[2];
|
static int bl_extents[2];
|
||||||
|
|
||||||
void (*glsl_R_BuildLightMap) (mod_brush_t *brush, msurface_t *surf);
|
void (*glsl_R_BuildLightMap) (const transform_t *transform, mod_brush_t *brush,
|
||||||
|
msurface_t *surf);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
R_AddDynamicLights_1 (msurface_t *surf)
|
R_AddDynamicLights_1 (const transform_t *transform, msurface_t *surf)
|
||||||
{
|
{
|
||||||
unsigned lnum;
|
unsigned lnum;
|
||||||
int sd, td;
|
int sd, td;
|
||||||
|
@ -80,9 +81,9 @@ R_AddDynamicLights_1 (msurface_t *surf)
|
||||||
tmax = (surf->extents[1] >> 4) + 1;
|
tmax = (surf->extents[1] >> 4) + 1;
|
||||||
tex = surf->texinfo;
|
tex = surf->texinfo;
|
||||||
|
|
||||||
if (currententity->transform) {
|
if (transform) {
|
||||||
//FIXME give world entity a transform
|
//FIXME give world entity a transform
|
||||||
entorigin = Transform_GetWorldPosition (currententity->transform);
|
entorigin = Transform_GetWorldPosition (transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (lnum = 0; lnum < r_maxdlights; lnum++) {
|
for (lnum = 0; lnum < r_maxdlights; lnum++) {
|
||||||
|
@ -127,7 +128,8 @@ R_AddDynamicLights_1 (msurface_t *surf)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
R_BuildLightMap_1 (mod_brush_t *brush, msurface_t *surf)
|
R_BuildLightMap_1 (const transform_t *transform, mod_brush_t *brush,
|
||||||
|
msurface_t *surf)
|
||||||
{
|
{
|
||||||
int smax, tmax, size;
|
int smax, tmax, size;
|
||||||
unsigned scale;
|
unsigned scale;
|
||||||
|
@ -168,7 +170,7 @@ R_BuildLightMap_1 (mod_brush_t *brush, msurface_t *surf)
|
||||||
}
|
}
|
||||||
// add all the dynamic lights
|
// add all the dynamic lights
|
||||||
if (surf->dlightframe == r_framecount)
|
if (surf->dlightframe == r_framecount)
|
||||||
R_AddDynamicLights_1 (surf);
|
R_AddDynamicLights_1 (transform, surf);
|
||||||
|
|
||||||
// bound, invert, and shift
|
// bound, invert, and shift
|
||||||
out = (byte *) blocklights;
|
out = (byte *) blocklights;
|
||||||
|
@ -248,7 +250,7 @@ glsl_R_BuildLightmaps (model_t **models, int num_models)
|
||||||
for (i = 0; i < brush->numsurfaces; i++) {
|
for (i = 0; i < brush->numsurfaces; i++) {
|
||||||
msurface_t *surf = brush->surfaces + i;
|
msurface_t *surf = brush->surfaces + i;
|
||||||
if (surf->lightpic)
|
if (surf->lightpic)
|
||||||
glsl_R_BuildLightMap (brush, surf);
|
glsl_R_BuildLightMap (0, brush, surf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
#include "QF/GLSL/qf_bsp.h"
|
#include "QF/GLSL/qf_bsp.h"
|
||||||
#include "QF/GLSL/qf_iqm.h"
|
#include "QF/GLSL/qf_iqm.h"
|
||||||
#include "QF/GLSL/qf_lightmap.h"
|
#include "QF/GLSL/qf_lightmap.h"
|
||||||
|
#include "QF/GLSL/qf_sprite.h"
|
||||||
#include "QF/GLSL/qf_textures.h"
|
#include "QF/GLSL/qf_textures.h"
|
||||||
|
|
||||||
#include "mod_internal.h"
|
#include "mod_internal.h"
|
||||||
|
@ -145,8 +146,7 @@ R_RenderEntities (void)
|
||||||
glsl_R_##Type##Begin (); \
|
glsl_R_##Type##Begin (); \
|
||||||
begun = 1; \
|
begun = 1; \
|
||||||
} \
|
} \
|
||||||
currententity = ent; \
|
glsl_R_Draw##Type (ent); \
|
||||||
glsl_R_Draw##Type (); \
|
|
||||||
} \
|
} \
|
||||||
if (begun) \
|
if (begun) \
|
||||||
glsl_R_##Type##End (); \
|
glsl_R_##Type##End (); \
|
||||||
|
@ -160,17 +160,17 @@ R_RenderEntities (void)
|
||||||
static void
|
static void
|
||||||
R_DrawViewModel (void)
|
R_DrawViewModel (void)
|
||||||
{
|
{
|
||||||
currententity = vr_data.view_model;
|
entity_t *ent = vr_data.view_model;
|
||||||
if (vr_data.inhibit_viewmodel
|
if (vr_data.inhibit_viewmodel
|
||||||
|| !r_drawviewmodel->int_val
|
|| !r_drawviewmodel->int_val
|
||||||
|| !r_drawentities->int_val
|
|| !r_drawentities->int_val
|
||||||
|| !currententity->renderer.model)
|
|| !ent->renderer.model)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// hack the depth range to prevent view model from poking into walls
|
// hack the depth range to prevent view model from poking into walls
|
||||||
qfeglDepthRangef (0, 0.3);
|
qfeglDepthRangef (0, 0.3);
|
||||||
glsl_R_AliasBegin ();
|
glsl_R_AliasBegin ();
|
||||||
glsl_R_DrawAlias ();
|
glsl_R_DrawAlias (ent);
|
||||||
glsl_R_AliasEnd ();
|
glsl_R_AliasEnd ();
|
||||||
qfeglDepthRangef (0, 1);
|
qfeglDepthRangef (0, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
|
|
||||||
#include "QF/GLSL/defines.h"
|
#include "QF/GLSL/defines.h"
|
||||||
#include "QF/GLSL/funcs.h"
|
#include "QF/GLSL/funcs.h"
|
||||||
|
#include "QF/GLSL/qf_sprite.h"
|
||||||
#include "QF/GLSL/qf_textures.h"
|
#include "QF/GLSL/qf_textures.h"
|
||||||
#include "QF/GLSL/qf_vid.h"
|
#include "QF/GLSL/qf_vid.h"
|
||||||
|
|
||||||
|
@ -132,7 +133,8 @@ static void
|
||||||
R_GetSpriteFrames (entity_t *ent, msprite_t *sprite, mspriteframe_t **frame1,
|
R_GetSpriteFrames (entity_t *ent, msprite_t *sprite, mspriteframe_t **frame1,
|
||||||
mspriteframe_t **frame2, float *blend)
|
mspriteframe_t **frame2, float *blend)
|
||||||
{
|
{
|
||||||
int framenum = currententity->animation.frame;
|
animation_t *animation = &ent->animation;
|
||||||
|
int framenum = animation->frame;
|
||||||
int pose;
|
int pose;
|
||||||
int i, numframes;
|
int i, numframes;
|
||||||
float *intervals;
|
float *intervals;
|
||||||
|
@ -154,7 +156,7 @@ R_GetSpriteFrames (entity_t *ent, msprite_t *sprite, mspriteframe_t **frame1,
|
||||||
numframes = group->numframes;
|
numframes = group->numframes;
|
||||||
fullinterval = intervals[numframes - 1];
|
fullinterval = intervals[numframes - 1];
|
||||||
|
|
||||||
time = vr_data.realtime + currententity->animation.syncbase;
|
time = vr_data.realtime + animation->syncbase;
|
||||||
targettime = time - ((int) (time / fullinterval)) * fullinterval;
|
targettime = time - ((int) (time / fullinterval)) * fullinterval;
|
||||||
|
|
||||||
for (i = 0; i < numframes - 1; i++) {
|
for (i = 0; i < numframes - 1; i++) {
|
||||||
|
@ -169,23 +171,22 @@ R_GetSpriteFrames (entity_t *ent, msprite_t *sprite, mspriteframe_t **frame1,
|
||||||
|
|
||||||
//FIXME this will break if the sprite changes between single frames and
|
//FIXME this will break if the sprite changes between single frames and
|
||||||
//group frames.
|
//group frames.
|
||||||
*blend = R_EntityBlend (ent, pose, frame_interval);
|
*blend = R_EntityBlend (animation, pose, frame_interval);
|
||||||
if (group) {
|
if (group) {
|
||||||
*frame1 = group->frames[ent->animation.pose1];
|
*frame1 = group->frames[animation->pose1];
|
||||||
*frame2 = group->frames[ent->animation.pose2];
|
*frame2 = group->frames[animation->pose2];
|
||||||
} else {
|
} else {
|
||||||
*frame1 = sprite->frames[ent->animation.pose1].frameptr;
|
*frame1 = sprite->frames[animation->pose1].frameptr;
|
||||||
*frame2 = sprite->frames[ent->animation.pose2].frameptr;
|
*frame2 = sprite->frames[animation->pose2].frameptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
make_quad (mspriteframe_t *frame, vec4f_t vpn, vec4f_t vright,
|
make_quad (mspriteframe_t *frame, vec4f_t origin, vec4f_t vpn, vec4f_t vright,
|
||||||
vec4f_t vup, float verts[6][3])
|
vec4f_t vup, float verts[6][3])
|
||||||
{
|
{
|
||||||
vec4f_t left, up, right, down;
|
vec4f_t left, up, right, down;
|
||||||
vec4f_t ul, ur, ll, lr;
|
vec4f_t ul, ur, ll, lr;
|
||||||
vec4f_t origin = Transform_GetWorldPosition (currententity->transform);
|
|
||||||
|
|
||||||
// build the sprite poster in worldspace
|
// build the sprite poster in worldspace
|
||||||
// first, rotate the sprite axes into world space
|
// first, rotate the sprite axes into world space
|
||||||
|
@ -208,9 +209,8 @@ make_quad (mspriteframe_t *frame, vec4f_t vpn, vec4f_t vright,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
R_DrawSprite (void)
|
glsl_R_DrawSprite (entity_t *ent)
|
||||||
{
|
{
|
||||||
entity_t *ent = currententity;
|
|
||||||
msprite_t *sprite = (msprite_t *) ent->renderer.model->cache.data;
|
msprite_t *sprite = (msprite_t *) ent->renderer.model->cache.data;
|
||||||
mspriteframe_t *frame1, *frame2;
|
mspriteframe_t *frame1, *frame2;
|
||||||
float blend, sr, cr, dot;
|
float blend, sr, cr, dot;
|
||||||
|
@ -276,16 +276,16 @@ R_DrawSprite (void)
|
||||||
case SPR_ORIENTED:
|
case SPR_ORIENTED:
|
||||||
// generate the prite's axes according to the sprite's world
|
// generate the prite's axes according to the sprite's world
|
||||||
// orientation
|
// orientation
|
||||||
svup = Transform_Up (currententity->transform);
|
svup = Transform_Up (ent->transform);
|
||||||
svright = Transform_Right (currententity->transform);
|
svright = Transform_Right (ent->transform);
|
||||||
svpn = Transform_Forward (currententity->transform);
|
svpn = Transform_Forward (ent->transform);
|
||||||
break;
|
break;
|
||||||
case SPR_VP_PARALLEL_ORIENTED:
|
case SPR_VP_PARALLEL_ORIENTED:
|
||||||
// generate the sprite's axes parallel to the viewplane, but
|
// generate the sprite's axes parallel to the viewplane, but
|
||||||
// rotated in that plane round the center according to the sprite
|
// rotated in that plane round the center according to the sprite
|
||||||
// entity's roll angle. Thus svpn stays the same, but svright and
|
// entity's roll angle. Thus svpn stays the same, but svright and
|
||||||
// svup rotate
|
// svup rotate
|
||||||
rot = Transform_GetLocalRotation (currententity->transform);
|
rot = Transform_GetLocalRotation (ent->transform);
|
||||||
//FIXME assumes the entity is only rolled
|
//FIXME assumes the entity is only rolled
|
||||||
sr = 2 * rot[0] * rot[3];
|
sr = 2 * rot[0] * rot[3];
|
||||||
cr = rot[3] * rot[3] - rot[0] * rot[0];
|
cr = rot[3] * rot[3] - rot[0] * rot[0];
|
||||||
|
@ -311,8 +311,9 @@ R_DrawSprite (void)
|
||||||
qfeglVertexAttrib4fv (quake_sprite.colorb.location, color);
|
qfeglVertexAttrib4fv (quake_sprite.colorb.location, color);
|
||||||
qfeglVertexAttrib1f (quake_sprite.blend.location, blend);
|
qfeglVertexAttrib1f (quake_sprite.blend.location, blend);
|
||||||
|
|
||||||
make_quad (frame1, svpn, svright, svup, vertsa);
|
vec4f_t origin = Transform_GetWorldPosition (ent->transform);
|
||||||
make_quad (frame2, svpn, svright, svup, vertsb);
|
make_quad (frame1, origin, svpn, svright, svup, vertsa);
|
||||||
|
make_quad (frame2, origin, svpn, svright, svup, vertsb);
|
||||||
|
|
||||||
qfeglVertexAttribPointer (quake_sprite.vertexa.location, 3, GL_FLOAT,
|
qfeglVertexAttribPointer (quake_sprite.vertexa.location, 3, GL_FLOAT,
|
||||||
0, 0, vertsa);
|
0, 0, vertsa);
|
||||||
|
|
|
@ -43,7 +43,6 @@
|
||||||
#define R_DrawParticles glsl_R_DrawParticles
|
#define R_DrawParticles glsl_R_DrawParticles
|
||||||
#define R_DrawSky glsl_R_DrawSky
|
#define R_DrawSky glsl_R_DrawSky
|
||||||
#define R_DrawSkyChain glsl_R_DrawSkyChain
|
#define R_DrawSkyChain glsl_R_DrawSkyChain
|
||||||
#define R_DrawSprite glsl_R_DrawSprite
|
|
||||||
#define R_DrawSpriteModel glsl_R_DrawSpriteModel
|
#define R_DrawSpriteModel glsl_R_DrawSpriteModel
|
||||||
#define R_DrawWaterSurfaces glsl_R_DrawWaterSurfaces
|
#define R_DrawWaterSurfaces glsl_R_DrawWaterSurfaces
|
||||||
#define R_DrawWorld glsl_R_DrawWorld
|
#define R_DrawWorld glsl_R_DrawWorld
|
||||||
|
|
|
@ -37,7 +37,7 @@ float r_avertexnormals[NUMVERTEXNORMALS][3] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
maliasskindesc_t *
|
maliasskindesc_t *
|
||||||
R_AliasGetSkindesc (int skinnum, aliashdr_t *ahdr)
|
R_AliasGetSkindesc (animation_t *animation, int skinnum, aliashdr_t *ahdr)
|
||||||
{
|
{
|
||||||
maliasskindesc_t *pskindesc;
|
maliasskindesc_t *pskindesc;
|
||||||
maliasskingroup_t *paliasskingroup;
|
maliasskingroup_t *paliasskingroup;
|
||||||
|
@ -63,7 +63,7 @@ R_AliasGetSkindesc (int skinnum, aliashdr_t *ahdr)
|
||||||
numskins = paliasskingroup->numskins;
|
numskins = paliasskingroup->numskins;
|
||||||
fullskininterval = pskinintervals[numskins - 1];
|
fullskininterval = pskinintervals[numskins - 1];
|
||||||
|
|
||||||
skintime = vr_data.realtime + currententity->animation.syncbase;
|
skintime = vr_data.realtime + animation->syncbase;
|
||||||
|
|
||||||
// when loading in Mod_LoadAliasSkinGroup, we guaranteed all interval
|
// when loading in Mod_LoadAliasSkinGroup, we guaranteed all interval
|
||||||
// values are positive, so we don't have to worry about division by 0
|
// values are positive, so we don't have to worry about division by 0
|
||||||
|
@ -81,8 +81,10 @@ R_AliasGetSkindesc (int skinnum, aliashdr_t *ahdr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static maliasframedesc_t *
|
static maliasframedesc_t *
|
||||||
alias_get_frame (int framenum, aliashdr_t *hdr, float *frame_interval)
|
alias_get_frame (const animation_t *animation, aliashdr_t *hdr,
|
||||||
|
float *frame_interval)
|
||||||
{
|
{
|
||||||
|
int framenum = animation->frame;
|
||||||
float *intervals;
|
float *intervals;
|
||||||
float fullinterval, time, targettime;
|
float fullinterval, time, targettime;
|
||||||
maliasframedesc_t *frame;
|
maliasframedesc_t *frame;
|
||||||
|
@ -118,7 +120,7 @@ alias_get_frame (int framenum, aliashdr_t *hdr, float *frame_interval)
|
||||||
numframes = group->numframes;
|
numframes = group->numframes;
|
||||||
fullinterval = intervals[numframes - 1];
|
fullinterval = intervals[numframes - 1];
|
||||||
|
|
||||||
time = vr_data.realtime + currententity->animation.syncbase;
|
time = vr_data.realtime + animation->syncbase;
|
||||||
|
|
||||||
// when loading in Mod_LoadAliasGroup, we guaranteed all interval values
|
// when loading in Mod_LoadAliasGroup, we guaranteed all interval values
|
||||||
// are positive, so we don't have to worry about division by 0
|
// are positive, so we don't have to worry about division by 0
|
||||||
|
@ -137,17 +139,17 @@ alias_get_frame (int framenum, aliashdr_t *hdr, float *frame_interval)
|
||||||
}
|
}
|
||||||
|
|
||||||
maliasframedesc_t *
|
maliasframedesc_t *
|
||||||
R_AliasGetFramedesc (int framenum, aliashdr_t *hdr)
|
R_AliasGetFramedesc (animation_t *animation, aliashdr_t *hdr)
|
||||||
{
|
{
|
||||||
return alias_get_frame (framenum, hdr, 0);
|
return alias_get_frame (animation, hdr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
R_AliasGetLerpedFrames (entity_t *ent, aliashdr_t *hdr)
|
R_AliasGetLerpedFrames (animation_t *animation, aliashdr_t *hdr)
|
||||||
{
|
{
|
||||||
maliasframedesc_t *frame;
|
maliasframedesc_t *frame;
|
||||||
float interval;
|
float interval;
|
||||||
|
|
||||||
frame = alias_get_frame (ent->animation.frame, hdr, &interval);
|
frame = alias_get_frame (animation, hdr, &interval);
|
||||||
return R_EntityBlend (ent, frame->firstpose, interval);
|
return R_EntityBlend (animation, frame->firstpose, interval);
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,12 +100,12 @@ R_MarkLeaves (void)
|
||||||
Returns the proper texture for a given time and base texture
|
Returns the proper texture for a given time and base texture
|
||||||
*/
|
*/
|
||||||
texture_t *
|
texture_t *
|
||||||
R_TextureAnimation (msurface_t *surf)
|
R_TextureAnimation (const entity_t *entity, msurface_t *surf)
|
||||||
{
|
{
|
||||||
texture_t *base = surf->texinfo->texture;
|
texture_t *base = surf->texinfo->texture;
|
||||||
int count, relative;
|
int count, relative;
|
||||||
|
|
||||||
if (currententity->animation.frame) {
|
if (entity->animation.frame) {
|
||||||
if (base->alternate_anims)
|
if (base->alternate_anims)
|
||||||
base = base->alternate_anims;
|
base = base->alternate_anims;
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,31 +131,31 @@ R_EnqueueEntity (entity_t *ent)
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
R_EntityBlend (entity_t *ent, int pose, float interval)
|
R_EntityBlend (animation_t *animation, int pose, float interval)
|
||||||
{
|
{
|
||||||
float blend;
|
float blend;
|
||||||
|
|
||||||
if (ent->animation.nolerp) {
|
if (animation->nolerp) {
|
||||||
ent->animation.nolerp = 0;
|
animation->nolerp = 0;
|
||||||
ent->animation.pose1 = pose;
|
animation->pose1 = pose;
|
||||||
ent->animation.pose2 = pose;
|
animation->pose2 = pose;
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
ent->animation.frame_interval = interval;
|
animation->frame_interval = interval;
|
||||||
if (ent->animation.pose2 != pose) {
|
if (animation->pose2 != pose) {
|
||||||
ent->animation.frame_start_time = vr_data.realtime;
|
animation->frame_start_time = vr_data.realtime;
|
||||||
if (ent->animation.pose2 == -1) {
|
if (animation->pose2 == -1) {
|
||||||
ent->animation.pose1 = pose;
|
animation->pose1 = pose;
|
||||||
} else {
|
} else {
|
||||||
ent->animation.pose1 = ent->animation.pose2;
|
animation->pose1 = animation->pose2;
|
||||||
}
|
}
|
||||||
ent->animation.pose2 = pose;
|
animation->pose2 = pose;
|
||||||
blend = 0.0;
|
blend = 0.0;
|
||||||
} else if (vr_data.paused) {
|
} else if (vr_data.paused) {
|
||||||
blend = 1.0;
|
blend = 1.0;
|
||||||
} else {
|
} else {
|
||||||
blend = (vr_data.realtime - ent->animation.frame_start_time)
|
blend = (vr_data.realtime - animation->frame_start_time)
|
||||||
/ ent->animation.frame_interval;
|
/ animation->frame_interval;
|
||||||
blend = min (blend, 1.0);
|
blend = min (blend, 1.0);
|
||||||
}
|
}
|
||||||
return blend;
|
return blend;
|
||||||
|
|
|
@ -49,12 +49,13 @@
|
||||||
float
|
float
|
||||||
R_IQMGetLerpedFrames (entity_t *ent, iqm_t *iqm)
|
R_IQMGetLerpedFrames (entity_t *ent, iqm_t *iqm)
|
||||||
{
|
{
|
||||||
|
animation_t *animation = &ent->animation;
|
||||||
int frame = ent->animation.frame;
|
int frame = ent->animation.frame;
|
||||||
float time, fullinterval;
|
float time, fullinterval;
|
||||||
iqmanim *anim;
|
iqmanim *anim;
|
||||||
|
|
||||||
if (!iqm->num_anims)
|
if (!iqm->num_anims)
|
||||||
return R_EntityBlend (ent, 0, 1.0 / 25.0);
|
return R_EntityBlend (animation, 0, 1.0 / 25.0);
|
||||||
if (frame >= iqm->num_anims || frame < 0) {
|
if (frame >= iqm->num_anims || frame < 0) {
|
||||||
Sys_MaskPrintf (SYS_dev, "R_IQMGetLerpedFrames: no such frame %d\n",
|
Sys_MaskPrintf (SYS_dev, "R_IQMGetLerpedFrames: no such frame %d\n",
|
||||||
frame);
|
frame);
|
||||||
|
@ -62,10 +63,10 @@ R_IQMGetLerpedFrames (entity_t *ent, iqm_t *iqm)
|
||||||
}
|
}
|
||||||
anim = &iqm->anims[frame];
|
anim = &iqm->anims[frame];
|
||||||
fullinterval = anim->num_frames / anim->framerate;
|
fullinterval = anim->num_frames / anim->framerate;
|
||||||
time = vr_data.realtime + currententity->animation.syncbase;
|
time = vr_data.realtime + ent->animation.syncbase;
|
||||||
time -= ((int) (time / fullinterval)) * fullinterval;
|
time -= ((int) (time / fullinterval)) * fullinterval;
|
||||||
frame = (int) (time * anim->framerate) + anim->first_frame;
|
frame = (int) (time * anim->framerate) + anim->first_frame;
|
||||||
return R_EntityBlend (ent, frame, 1.0 / anim->framerate);
|
return R_EntityBlend (animation, frame, 1.0 / anim->framerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
iqmframe_t *
|
iqmframe_t *
|
||||||
|
|
|
@ -57,8 +57,6 @@ int r_lineadj;
|
||||||
qboolean r_active;
|
qboolean r_active;
|
||||||
int r_init;
|
int r_init;
|
||||||
|
|
||||||
entity_t *currententity;
|
|
||||||
|
|
||||||
int r_visframecount; // bumped when going to a new PVS
|
int r_visframecount; // bumped when going to a new PVS
|
||||||
int r_framecount = 1; // so frame counts initialized to 0 don't match
|
int r_framecount = 1; // so frame counts initialized to 0 don't match
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,7 @@ D_CacheSurface (msurface_t *surface, int miplevel)
|
||||||
surfcache_t *cache;
|
surfcache_t *cache;
|
||||||
|
|
||||||
// if the surface is animating or flashing, flush the cache
|
// if the surface is animating or flashing, flush the cache
|
||||||
r_drawsurf.texture = R_TextureAnimation (surface);
|
r_drawsurf.texture = R_TextureAnimation (currententity, surface);
|
||||||
r_drawsurf.lightadj[0] = d_lightstylevalue[surface->styles[0]];
|
r_drawsurf.lightadj[0] = d_lightstylevalue[surface->styles[0]];
|
||||||
r_drawsurf.lightadj[1] = d_lightstylevalue[surface->styles[1]];
|
r_drawsurf.lightadj[1] = d_lightstylevalue[surface->styles[1]];
|
||||||
r_drawsurf.lightadj[2] = d_lightstylevalue[surface->styles[2]];
|
r_drawsurf.lightadj[2] = d_lightstylevalue[surface->styles[2]];
|
||||||
|
|
|
@ -541,18 +541,18 @@ R_AliasPrepareUnclippedPoints (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
R_AliasSetupSkin (void)
|
R_AliasSetupSkin (entity_t *ent)
|
||||||
{
|
{
|
||||||
int skinnum;
|
int skinnum;
|
||||||
|
|
||||||
skinnum = currententity->renderer.skinnum;
|
skinnum = ent->renderer.skinnum;
|
||||||
if ((skinnum >= pmdl->numskins) || (skinnum < 0)) {
|
if ((skinnum >= pmdl->numskins) || (skinnum < 0)) {
|
||||||
Sys_MaskPrintf (SYS_dev, "R_AliasSetupSkin: no such skin # %d\n",
|
Sys_MaskPrintf (SYS_dev, "R_AliasSetupSkin: no such skin # %d\n",
|
||||||
skinnum);
|
skinnum);
|
||||||
skinnum = 0;
|
skinnum = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pskindesc = R_AliasGetSkindesc (skinnum, paliashdr);
|
pskindesc = R_AliasGetSkindesc (&ent->animation, skinnum, paliashdr);
|
||||||
|
|
||||||
a_skinwidth = pmdl->skinwidth;
|
a_skinwidth = pmdl->skinwidth;
|
||||||
|
|
||||||
|
@ -562,16 +562,16 @@ R_AliasSetupSkin (void)
|
||||||
r_affinetridesc.skinheight = pmdl->skinheight;
|
r_affinetridesc.skinheight = pmdl->skinheight;
|
||||||
|
|
||||||
acolormap = vid.colormap8;
|
acolormap = vid.colormap8;
|
||||||
if (currententity->renderer.skin) {
|
if (ent->renderer.skin) {
|
||||||
tex_t *base;
|
tex_t *base;
|
||||||
|
|
||||||
base = currententity->renderer.skin->texels;
|
base = ent->renderer.skin->texels;
|
||||||
if (base) {
|
if (base) {
|
||||||
r_affinetridesc.pskin = base->data;
|
r_affinetridesc.pskin = base->data;
|
||||||
r_affinetridesc.skinwidth = base->width;
|
r_affinetridesc.skinwidth = base->width;
|
||||||
r_affinetridesc.skinheight = base->height;
|
r_affinetridesc.skinheight = base->height;
|
||||||
}
|
}
|
||||||
acolormap = currententity->renderer.skin->colormap;
|
acolormap = ent->renderer.skin->colormap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -610,11 +610,11 @@ R_AliasSetupLighting (alight_t *plighting)
|
||||||
set r_apverts
|
set r_apverts
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
R_AliasSetupFrame (void)
|
R_AliasSetupFrame (entity_t *ent)
|
||||||
{
|
{
|
||||||
maliasframedesc_t *frame;
|
maliasframedesc_t *frame;
|
||||||
|
|
||||||
frame = R_AliasGetFramedesc (currententity->animation.frame, paliashdr);
|
frame = R_AliasGetFramedesc (&ent->animation, paliashdr);
|
||||||
r_apverts = (trivertx_t *) ((byte *) paliashdr + frame->frame);
|
r_apverts = (trivertx_t *) ((byte *) paliashdr + frame->frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,13 +622,14 @@ R_AliasSetupFrame (void)
|
||||||
void
|
void
|
||||||
R_AliasDrawModel (alight_t *plighting)
|
R_AliasDrawModel (alight_t *plighting)
|
||||||
{
|
{
|
||||||
|
entity_t *ent = currententity;
|
||||||
int size;
|
int size;
|
||||||
finalvert_t *finalverts;
|
finalvert_t *finalverts;
|
||||||
|
|
||||||
r_amodels_drawn++;
|
r_amodels_drawn++;
|
||||||
|
|
||||||
if (!(paliashdr = currententity->renderer.model->aliashdr))
|
if (!(paliashdr = ent->renderer.model->aliashdr))
|
||||||
paliashdr = Cache_Get (¤tentity->renderer.model->cache);
|
paliashdr = Cache_Get (&ent->renderer.model->cache);
|
||||||
pmdl = (mdl_t *) ((byte *) paliashdr + paliashdr->model);
|
pmdl = (mdl_t *) ((byte *) paliashdr + paliashdr->model);
|
||||||
|
|
||||||
size = (CACHE_SIZE - 1)
|
size = (CACHE_SIZE - 1)
|
||||||
|
@ -643,12 +644,12 @@ R_AliasDrawModel (alight_t *plighting)
|
||||||
(((intptr_t) &finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
|
(((intptr_t) &finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
|
||||||
pauxverts = (auxvert_t *) &pfinalverts[pmdl->numverts + 1];
|
pauxverts = (auxvert_t *) &pfinalverts[pmdl->numverts + 1];
|
||||||
|
|
||||||
R_AliasSetupSkin ();
|
R_AliasSetupSkin (ent);
|
||||||
R_AliasSetUpTransform (currententity->visibility.trivial_accept);
|
R_AliasSetUpTransform (ent->visibility.trivial_accept);
|
||||||
R_AliasSetupLighting (plighting);
|
R_AliasSetupLighting (plighting);
|
||||||
R_AliasSetupFrame ();
|
R_AliasSetupFrame (ent);
|
||||||
|
|
||||||
r_affinetridesc.drawtype = ((currententity->visibility.trivial_accept == 3)
|
r_affinetridesc.drawtype = ((ent->visibility.trivial_accept == 3)
|
||||||
&& r_recursiveaffinetriangles);
|
&& r_recursiveaffinetriangles);
|
||||||
|
|
||||||
if (!acolormap)
|
if (!acolormap)
|
||||||
|
@ -662,19 +663,19 @@ R_AliasDrawModel (alight_t *plighting)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currententity != vr_data.view_model)
|
if (ent != vr_data.view_model)
|
||||||
ziscale = (float) 0x8000 *(float) 0x10000;
|
ziscale = (float) 0x8000 *(float) 0x10000;
|
||||||
else
|
else
|
||||||
ziscale = (float) 0x8000 *(float) 0x10000 *3.0;
|
ziscale = (float) 0x8000 *(float) 0x10000 *3.0;
|
||||||
|
|
||||||
if (currententity->visibility.trivial_accept
|
if (ent->visibility.trivial_accept
|
||||||
&& pmdl->ident != HEADER_MDL16) {
|
&& pmdl->ident != HEADER_MDL16) {
|
||||||
R_AliasPrepareUnclippedPoints ();
|
R_AliasPrepareUnclippedPoints ();
|
||||||
} else {
|
} else {
|
||||||
R_AliasPreparePoints ();
|
R_AliasPreparePoints ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!currententity->renderer.model->aliashdr) {
|
if (!ent->renderer.model->aliashdr) {
|
||||||
Cache_Release (¤tentity->renderer.model->cache);
|
Cache_Release (&ent->renderer.model->cache);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,7 +230,7 @@ sw32_D_CacheSurface (msurface_t *surface, int miplevel)
|
||||||
surfcache_t *cache;
|
surfcache_t *cache;
|
||||||
|
|
||||||
// if the surface is animating or flashing, flush the cache
|
// if the surface is animating or flashing, flush the cache
|
||||||
sw32_r_drawsurf.texture = R_TextureAnimation (surface);
|
sw32_r_drawsurf.texture = R_TextureAnimation (currententity, surface);
|
||||||
sw32_r_drawsurf.lightadj[0] = d_lightstylevalue[surface->styles[0]];
|
sw32_r_drawsurf.lightadj[0] = d_lightstylevalue[surface->styles[0]];
|
||||||
sw32_r_drawsurf.lightadj[1] = d_lightstylevalue[surface->styles[1]];
|
sw32_r_drawsurf.lightadj[1] = d_lightstylevalue[surface->styles[1]];
|
||||||
sw32_r_drawsurf.lightadj[2] = d_lightstylevalue[surface->styles[2]];
|
sw32_r_drawsurf.lightadj[2] = d_lightstylevalue[surface->styles[2]];
|
||||||
|
|
|
@ -543,18 +543,18 @@ R_AliasPrepareUnclippedPoints (void)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
R_AliasSetupSkin (void)
|
R_AliasSetupSkin (entity_t *ent)
|
||||||
{
|
{
|
||||||
int skinnum;
|
int skinnum;
|
||||||
|
|
||||||
skinnum = currententity->renderer.skinnum;
|
skinnum = ent->renderer.skinnum;
|
||||||
if ((skinnum >= pmdl->numskins) || (skinnum < 0)) {
|
if ((skinnum >= pmdl->numskins) || (skinnum < 0)) {
|
||||||
Sys_MaskPrintf (SYS_dev, "R_AliasSetupSkin: no such skin # %d\n",
|
Sys_MaskPrintf (SYS_dev, "R_AliasSetupSkin: no such skin # %d\n",
|
||||||
skinnum);
|
skinnum);
|
||||||
skinnum = 0;
|
skinnum = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pskindesc = R_AliasGetSkindesc (skinnum, paliashdr);
|
pskindesc = R_AliasGetSkindesc (&ent->animation, skinnum, paliashdr);
|
||||||
a_skinwidth = pmdl->skinwidth;
|
a_skinwidth = pmdl->skinwidth;
|
||||||
|
|
||||||
sw32_r_affinetridesc.pskin = (void *) ((byte *) paliashdr + pskindesc->skin);
|
sw32_r_affinetridesc.pskin = (void *) ((byte *) paliashdr + pskindesc->skin);
|
||||||
|
@ -563,16 +563,16 @@ R_AliasSetupSkin (void)
|
||||||
sw32_r_affinetridesc.skinheight = pmdl->skinheight;
|
sw32_r_affinetridesc.skinheight = pmdl->skinheight;
|
||||||
|
|
||||||
sw32_acolormap = vid.colormap8;
|
sw32_acolormap = vid.colormap8;
|
||||||
if (currententity->renderer.skin) {
|
if (ent->renderer.skin) {
|
||||||
tex_t *base;
|
tex_t *base;
|
||||||
|
|
||||||
base = currententity->renderer.skin->texels;
|
base = ent->renderer.skin->texels;
|
||||||
if (base) {
|
if (base) {
|
||||||
sw32_r_affinetridesc.pskin = base->data;
|
sw32_r_affinetridesc.pskin = base->data;
|
||||||
sw32_r_affinetridesc.skinwidth = base->width;
|
sw32_r_affinetridesc.skinwidth = base->width;
|
||||||
sw32_r_affinetridesc.skinheight = base->height;
|
sw32_r_affinetridesc.skinheight = base->height;
|
||||||
}
|
}
|
||||||
sw32_acolormap = currententity->renderer.skin->colormap;
|
sw32_acolormap = ent->renderer.skin->colormap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -611,11 +611,11 @@ R_AliasSetupLighting (alight_t *plighting)
|
||||||
set sw32_r_apverts
|
set sw32_r_apverts
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
R_AliasSetupFrame (void)
|
R_AliasSetupFrame (entity_t *ent)
|
||||||
{
|
{
|
||||||
maliasframedesc_t *frame;
|
maliasframedesc_t *frame;
|
||||||
|
|
||||||
frame = R_AliasGetFramedesc (currententity->animation.frame, paliashdr);
|
frame = R_AliasGetFramedesc (&ent->animation, paliashdr);
|
||||||
sw32_r_apverts = (trivertx_t *) ((byte *) paliashdr + frame->frame);
|
sw32_r_apverts = (trivertx_t *) ((byte *) paliashdr + frame->frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,13 +623,14 @@ R_AliasSetupFrame (void)
|
||||||
void
|
void
|
||||||
sw32_R_AliasDrawModel (alight_t *plighting)
|
sw32_R_AliasDrawModel (alight_t *plighting)
|
||||||
{
|
{
|
||||||
|
entity_t *ent = currententity;
|
||||||
int size;
|
int size;
|
||||||
finalvert_t *finalverts;
|
finalvert_t *finalverts;
|
||||||
|
|
||||||
sw32_r_amodels_drawn++;
|
sw32_r_amodels_drawn++;
|
||||||
|
|
||||||
if (!(paliashdr = currententity->renderer.model->aliashdr))
|
if (!(paliashdr = ent->renderer.model->aliashdr))
|
||||||
paliashdr = Cache_Get (¤tentity->renderer.model->cache);
|
paliashdr = Cache_Get (&ent->renderer.model->cache);
|
||||||
pmdl = (mdl_t *) ((byte *) paliashdr + paliashdr->model);
|
pmdl = (mdl_t *) ((byte *) paliashdr + paliashdr->model);
|
||||||
|
|
||||||
size = (CACHE_SIZE - 1)
|
size = (CACHE_SIZE - 1)
|
||||||
|
@ -644,10 +645,10 @@ sw32_R_AliasDrawModel (alight_t *plighting)
|
||||||
(((intptr_t) &finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
|
(((intptr_t) &finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
|
||||||
sw32_pauxverts = (auxvert_t *) &pfinalverts[pmdl->numverts + 1];
|
sw32_pauxverts = (auxvert_t *) &pfinalverts[pmdl->numverts + 1];
|
||||||
|
|
||||||
R_AliasSetupSkin ();
|
R_AliasSetupSkin (ent);
|
||||||
sw32_R_AliasSetUpTransform (currententity->visibility.trivial_accept);
|
sw32_R_AliasSetUpTransform (ent->visibility.trivial_accept);
|
||||||
R_AliasSetupLighting (plighting);
|
R_AliasSetupLighting (plighting);
|
||||||
R_AliasSetupFrame ();
|
R_AliasSetupFrame (ent);
|
||||||
|
|
||||||
if (!sw32_acolormap)
|
if (!sw32_acolormap)
|
||||||
sw32_acolormap = vid.colormap8;
|
sw32_acolormap = vid.colormap8;
|
||||||
|
@ -662,18 +663,18 @@ sw32_R_AliasDrawModel (alight_t *plighting)
|
||||||
sw32_ctx->pixbytes);
|
sw32_ctx->pixbytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currententity != vr_data.view_model)
|
if (ent != vr_data.view_model)
|
||||||
sw32_ziscale = (float) 0x8000 *(float) 0x10000;
|
sw32_ziscale = (float) 0x8000 *(float) 0x10000;
|
||||||
else
|
else
|
||||||
sw32_ziscale = (float) 0x8000 *(float) 0x10000 *3.0;
|
sw32_ziscale = (float) 0x8000 *(float) 0x10000 *3.0;
|
||||||
|
|
||||||
if (currententity->visibility.trivial_accept) {
|
if (ent->visibility.trivial_accept) {
|
||||||
R_AliasPrepareUnclippedPoints ();
|
R_AliasPrepareUnclippedPoints ();
|
||||||
} else {
|
} else {
|
||||||
R_AliasPreparePoints ();
|
R_AliasPreparePoints ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!currententity->renderer.model->aliashdr) {
|
if (!ent->renderer.model->aliashdr) {
|
||||||
Cache_Release (¤tentity->renderer.model->cache);
|
Cache_Release (&ent->renderer.model->cache);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,6 +129,7 @@ Vulkan_DrawAlias (entity_t *ent, vulkan_ctx_t *ctx)
|
||||||
model_t *model = ent->renderer.model;
|
model_t *model = ent->renderer.model;
|
||||||
aliashdr_t *hdr;
|
aliashdr_t *hdr;
|
||||||
qfv_alias_skin_t *skin;
|
qfv_alias_skin_t *skin;
|
||||||
|
animation_t *animation = &ent->animation;
|
||||||
struct {
|
struct {
|
||||||
mat4f_t mat;
|
mat4f_t mat;
|
||||||
float blend;
|
float blend;
|
||||||
|
@ -140,13 +141,13 @@ Vulkan_DrawAlias (entity_t *ent, vulkan_ctx_t *ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform_GetWorldMatrix (ent->transform, vertex_constants.mat);
|
Transform_GetWorldMatrix (ent->transform, vertex_constants.mat);
|
||||||
vertex_constants.blend = R_AliasGetLerpedFrames (ent, hdr);
|
vertex_constants.blend = R_AliasGetLerpedFrames (animation, hdr);
|
||||||
|
|
||||||
if (0/*XXX ent->skin && ent->skin->tex*/) {
|
if (0/*XXX ent->skin && ent->skin->tex*/) {
|
||||||
//skin = ent->skin->tex;
|
//skin = ent->skin->tex;
|
||||||
} else {
|
} else {
|
||||||
maliasskindesc_t *skindesc;
|
maliasskindesc_t *skindesc;
|
||||||
skindesc = R_AliasGetSkindesc (ent->renderer.skinnum, hdr);
|
skindesc = R_AliasGetSkindesc (animation, ent->renderer.skinnum, hdr);
|
||||||
skin = (qfv_alias_skin_t *) ((byte *) hdr + skindesc->skin);
|
skin = (qfv_alias_skin_t *) ((byte *) hdr + skindesc->skin);
|
||||||
}
|
}
|
||||||
QuatScale (ent->renderer.colormod, 255, fragment_constants[0]);
|
QuatScale (ent->renderer.colormod, 255, fragment_constants[0]);
|
||||||
|
|
|
@ -213,15 +213,15 @@ Vulkan_ClearElements (vulkan_ctx_t *ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
chain_surface (mod_brush_t *brush, msurface_t *surf, vec_t *transform,
|
chain_surface (msurface_t *surf, vulkan_ctx_t *ctx)
|
||||||
float *color, vulkan_ctx_t *ctx)
|
|
||||||
{
|
{
|
||||||
bspctx_t *bctx = ctx->bsp_context;
|
bspctx_t *bctx = ctx->bsp_context;
|
||||||
instsurf_t *is;
|
instsurf_t *is;
|
||||||
|
|
||||||
if (surf->flags & SURF_DRAWSKY) {
|
if (surf->flags & SURF_DRAWSKY) {
|
||||||
is = CHAIN_SURF_F2B (surf, bctx->sky_chain);
|
is = CHAIN_SURF_F2B (surf, bctx->sky_chain);
|
||||||
} else if ((surf->flags & SURF_DRAWTURB) || (color && color[3] < 1.0)) {
|
} else if ((surf->flags & SURF_DRAWTURB)
|
||||||
|
|| (bctx->color && bctx->color[3] < 1.0)) {
|
||||||
is = CHAIN_SURF_B2F (surf, bctx->waterchain);
|
is = CHAIN_SURF_B2F (surf, bctx->waterchain);
|
||||||
} else {
|
} else {
|
||||||
texture_t *tx;
|
texture_t *tx;
|
||||||
|
@ -230,12 +230,12 @@ chain_surface (mod_brush_t *brush, msurface_t *surf, vec_t *transform,
|
||||||
if (!surf->texinfo->texture->anim_total)
|
if (!surf->texinfo->texture->anim_total)
|
||||||
tx = surf->texinfo->texture;
|
tx = surf->texinfo->texture;
|
||||||
else
|
else
|
||||||
tx = R_TextureAnimation (surf);
|
tx = R_TextureAnimation (bctx->entity, surf);
|
||||||
tex = tx->render;
|
tex = tx->render;
|
||||||
is = CHAIN_SURF_F2B (surf, tex->tex_chain);
|
is = CHAIN_SURF_F2B (surf, tex->tex_chain);
|
||||||
}
|
}
|
||||||
is->transform = transform;
|
is->transform = bctx->transform;
|
||||||
is->color = color;
|
is->color = bctx->color;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -588,6 +588,11 @@ R_DrawBrushModel (entity_t *e, vulkan_ctx_t *ctx)
|
||||||
vec3_t mins, maxs;
|
vec3_t mins, maxs;
|
||||||
vec4f_t org;
|
vec4f_t org;
|
||||||
mod_brush_t *brush;
|
mod_brush_t *brush;
|
||||||
|
bspctx_t *bctx = ctx->bsp_context;
|
||||||
|
|
||||||
|
bctx->entity = e;
|
||||||
|
bctx->transform = e->renderer.full_transform;
|
||||||
|
bctx->color = e->renderer.colormod;
|
||||||
|
|
||||||
model = e->renderer.model;
|
model = e->renderer.model;
|
||||||
brush = &model->brush;
|
brush = &model->brush;
|
||||||
|
@ -628,8 +633,7 @@ R_DrawBrushModel (entity_t *e, vulkan_ctx_t *ctx)
|
||||||
// enqueue the polygon
|
// enqueue the polygon
|
||||||
if (((surf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON))
|
if (((surf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON))
|
||||||
|| (!(surf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) {
|
|| (!(surf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) {
|
||||||
chain_surface (brush, surf, e->renderer.full_transform,
|
chain_surface (surf, ctx);
|
||||||
e->renderer.colormod, ctx);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -672,7 +676,7 @@ visit_node (mod_brush_t *brush, mnode_t *node, int side, vulkan_ctx_t *ctx)
|
||||||
if (side ^ (surf->flags & SURF_PLANEBACK))
|
if (side ^ (surf->flags & SURF_PLANEBACK))
|
||||||
continue; // wrong side
|
continue; // wrong side
|
||||||
|
|
||||||
chain_surface (brush, surf, 0, 0, ctx);
|
chain_surface (surf, ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1078,7 +1082,9 @@ Vulkan_DrawWorld (vulkan_ctx_t *ctx)
|
||||||
worldent.renderer.model = r_worldentity.renderer.model;
|
worldent.renderer.model = r_worldentity.renderer.model;
|
||||||
brush = &r_worldentity.renderer.model->brush;
|
brush = &r_worldentity.renderer.model->brush;
|
||||||
|
|
||||||
currententity = &worldent;
|
bctx->entity = &r_worldentity;
|
||||||
|
bctx->transform = 0;
|
||||||
|
bctx->color = 0;
|
||||||
|
|
||||||
R_VisitWorldNodes (brush, ctx);
|
R_VisitWorldNodes (brush, ctx);
|
||||||
if (r_drawentities->int_val) {
|
if (r_drawentities->int_val) {
|
||||||
|
@ -1086,8 +1092,6 @@ Vulkan_DrawWorld (vulkan_ctx_t *ctx)
|
||||||
for (ent = r_ent_queue; ent; ent = ent->next) {
|
for (ent = r_ent_queue; ent; ent = ent->next) {
|
||||||
if (ent->renderer.model->type != mod_brush)
|
if (ent->renderer.model->type != mod_brush)
|
||||||
continue;
|
continue;
|
||||||
currententity = ent;
|
|
||||||
|
|
||||||
R_DrawBrushModel (ent, ctx);
|
R_DrawBrushModel (ent, ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,11 +132,11 @@ R_RenderEntities (vulkan_ctx_t *ctx)
|
||||||
static void
|
static void
|
||||||
R_DrawViewModel (void)
|
R_DrawViewModel (void)
|
||||||
{
|
{
|
||||||
currententity = vr_data.view_model;
|
entity_t *ent = vr_data.view_model;
|
||||||
if (vr_data.inhibit_viewmodel
|
if (vr_data.inhibit_viewmodel
|
||||||
|| !r_drawviewmodel->int_val
|
|| !r_drawviewmodel->int_val
|
||||||
|| !r_drawentities->int_val
|
|| !r_drawentities->int_val
|
||||||
|| !currententity->renderer.model)
|
|| !ent->renderer.model)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// hack the depth range to prevent view model from poking into walls
|
// hack the depth range to prevent view model from poking into walls
|
||||||
|
|
Loading…
Reference in a new issue