mirror of
https://github.com/yquake2/ref_vk.git
synced 2024-11-10 06:41:45 +00:00
parent
f9ae8da233
commit
4c6bc1a14c
5 changed files with 66 additions and 31 deletions
|
@ -208,6 +208,14 @@ extern void Mod_LoadSurfedges (const char *name, int **surfedges, int *numsurfed
|
|||
const byte *mod_base, const lump_t *l, int extra);
|
||||
extern int Mod_CalcLumpHunkSize(const lump_t *l, int inSize, int outSize, int extra);
|
||||
extern mleaf_t *Mod_PointInLeaf(const vec3_t p, mnode_t *node);
|
||||
|
||||
/* Surface logic */
|
||||
#define DLIGHT_CUTOFF 64
|
||||
|
||||
typedef void (*marksurfacelights_t)(dlight_t *light, int bit, mnode_t *node,
|
||||
int r_dlightframecount);
|
||||
extern void R_MarkLights (dlight_t *light, int bit, mnode_t *node, int r_dlightframecount,
|
||||
marksurfacelights_t mark_surface_lights);
|
||||
extern struct image_s *R_TextureAnimation(const entity_t *currententity,
|
||||
const mtexinfo_t *tex);
|
||||
extern qboolean R_AreaVisible(const byte *areabits, mleaf_t *pleaf);
|
||||
|
|
|
@ -70,3 +70,49 @@ R_AreaVisible(const byte *areabits, mleaf_t *pleaf)
|
|||
|
||||
return false; // not visible
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
R_MarkLights
|
||||
|
||||
bit: 1 << i for light number i, will be or'ed into msurface_t::dlightbits
|
||||
if surface is affected by this light
|
||||
=============
|
||||
*/
|
||||
void
|
||||
R_MarkLights(dlight_t *light, int bit, mnode_t *node, int r_dlightframecount,
|
||||
marksurfacelights_t mark_surface_lights)
|
||||
{
|
||||
cplane_t *splitplane;
|
||||
float dist;
|
||||
int intensity;
|
||||
|
||||
if (node->contents != CONTENTS_NODE)
|
||||
return;
|
||||
|
||||
splitplane = node->plane;
|
||||
dist = DotProduct(light->origin, splitplane->normal) - splitplane->dist;
|
||||
|
||||
intensity = light->intensity;
|
||||
|
||||
if (dist > intensity - DLIGHT_CUTOFF) // (dist > light->intensity)
|
||||
{
|
||||
R_MarkLights (light, bit, node->children[0], r_dlightframecount,
|
||||
mark_surface_lights);
|
||||
return;
|
||||
}
|
||||
|
||||
if (dist < -intensity + DLIGHT_CUTOFF) // (dist < -light->intensity)
|
||||
{
|
||||
R_MarkLights(light, bit, node->children[1], r_dlightframecount,
|
||||
mark_surface_lights);
|
||||
return;
|
||||
}
|
||||
|
||||
mark_surface_lights(light, bit, node, r_dlightframecount);
|
||||
|
||||
R_MarkLights(light, bit, node->children[0], r_dlightframecount,
|
||||
mark_surface_lights);
|
||||
R_MarkLights(light, bit, node->children[1], r_dlightframecount,
|
||||
mark_surface_lights);
|
||||
}
|
||||
|
|
|
@ -189,6 +189,7 @@ extern float r_viewproj_matrix[16];
|
|||
extern vec3_t lightspot;
|
||||
|
||||
extern int registration_sequence;
|
||||
extern int r_dlightframecount;
|
||||
extern qvksampler_t vk_current_sampler;
|
||||
extern qvksampler_t vk_current_lmap_sampler;
|
||||
|
||||
|
@ -220,7 +221,8 @@ void EmitWaterPolys (msurface_t *fa, image_t *texture,
|
|||
void R_AddSkySurface (msurface_t *fa);
|
||||
void R_ClearSkyBox (void);
|
||||
void R_DrawSkyBox (void);
|
||||
void R_MarkLights (dlight_t *light, int bit, mnode_t *node);
|
||||
void R_MarkSurfaceLights(dlight_t *light, int bit, mnode_t *node,
|
||||
int r_dlightframecount);
|
||||
|
||||
struct image_s *RE_Draw_FindPic (char *name);
|
||||
|
||||
|
|
|
@ -22,9 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "header/local.h"
|
||||
|
||||
static int r_dlightframecount;
|
||||
|
||||
#define DLIGHT_CUTOFF 64
|
||||
int r_dlightframecount;
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
@ -115,33 +113,15 @@ DYNAMIC LIGHTS
|
|||
|
||||
/*
|
||||
=============
|
||||
R_MarkLights
|
||||
R_MarkSurfaceLights
|
||||
=============
|
||||
*/
|
||||
void R_MarkLights (dlight_t *light, int bit, mnode_t *node)
|
||||
void
|
||||
R_MarkSurfaceLights(dlight_t *light, int bit, mnode_t *node, int r_dlightframecount)
|
||||
{
|
||||
cplane_t *splitplane;
|
||||
float dist;
|
||||
msurface_t *surf;
|
||||
int i;
|
||||
|
||||
if (node->contents != CONTENTS_NODE)
|
||||
return;
|
||||
|
||||
splitplane = node->plane;
|
||||
dist = DotProduct (light->origin, splitplane->normal) - splitplane->dist;
|
||||
|
||||
if (dist > light->intensity-DLIGHT_CUTOFF)
|
||||
{
|
||||
R_MarkLights (light, bit, node->children[0]);
|
||||
return;
|
||||
}
|
||||
if (dist < -light->intensity+DLIGHT_CUTOFF)
|
||||
{
|
||||
R_MarkLights (light, bit, node->children[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
// mark the polygons
|
||||
surf = r_worldmodel->surfaces + node->firstsurface;
|
||||
for (i=0 ; i<node->numsurfaces ; i++, surf++)
|
||||
|
@ -153,12 +133,8 @@ void R_MarkLights (dlight_t *light, int bit, mnode_t *node)
|
|||
}
|
||||
surf->dlightbits |= bit;
|
||||
}
|
||||
|
||||
R_MarkLights (light, bit, node->children[0]);
|
||||
R_MarkLights (light, bit, node->children[1]);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=============
|
||||
R_PushDlights
|
||||
|
@ -176,7 +152,8 @@ void R_PushDlights (void)
|
|||
// advanced yet for this frame
|
||||
l = r_newrefdef.dlights;
|
||||
for (i=0 ; i<r_newrefdef.num_dlights ; i++, l++)
|
||||
R_MarkLights ( l, 1<<i, r_worldmodel->nodes );
|
||||
R_MarkLights (l, 1<<i, r_worldmodel->nodes, r_dlightframecount,
|
||||
R_MarkSurfaceLights);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -668,7 +668,9 @@ static void R_DrawInlineBModel (entity_t *currententity, model_t *currentmodel,
|
|||
lt = r_newrefdef.dlights;
|
||||
for (k = 0; k<r_newrefdef.num_dlights; k++, lt++)
|
||||
{
|
||||
R_MarkLights(lt, 1 << k, currentmodel->nodes + currentmodel->firstnode);
|
||||
R_MarkLights(lt, 1 << k,
|
||||
currentmodel->nodes + currentmodel->firstnode,
|
||||
r_dlightframecount, R_MarkSurfaceLights);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue