mirror of
https://github.com/nzp-team/glquake.git
synced 2025-02-12 07:04:13 +00:00
Fix for #29 for lightstyles
This commit is contained in:
parent
9ce4438cb5
commit
66884a2876
15 changed files with 172 additions and 96 deletions
BIN
.DS_Store
vendored
BIN
.DS_Store
vendored
Binary file not shown.
1
Makefile
1
Makefile
|
@ -67,6 +67,7 @@ COMMON_OBJS = chase.c \
|
||||||
cl_main.c \
|
cl_main.c \
|
||||||
cl_parse.c \
|
cl_parse.c \
|
||||||
cl_tent.c \
|
cl_tent.c \
|
||||||
|
bsp_strlcpy.c \
|
||||||
cmd.c \
|
cmd.c \
|
||||||
common.c \
|
common.c \
|
||||||
console.c \
|
console.c \
|
||||||
|
|
BIN
nzportable.3dsx
BIN
nzportable.3dsx
Binary file not shown.
BIN
nzportable.elf
BIN
nzportable.elf
Binary file not shown.
54
source/bsp_strlcpy.c
Normal file
54
source/bsp_strlcpy.c
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "strl_fn.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copy src to string dst of size siz. At most siz-1 characters
|
||||||
|
* will be copied. Always NUL terminates (unless siz == 0).
|
||||||
|
* Returns strlen(src); if retval >= siz, truncation occurred.
|
||||||
|
*/
|
||||||
|
|
||||||
|
size_t
|
||||||
|
q_strlcpy (char *dst, const char *src, size_t siz)
|
||||||
|
{
|
||||||
|
char *d = dst;
|
||||||
|
const char *s = src;
|
||||||
|
size_t n = siz;
|
||||||
|
|
||||||
|
/* Copy as many bytes as will fit */
|
||||||
|
if (n != 0) {
|
||||||
|
while (--n != 0) {
|
||||||
|
if ((*d++ = *s++) == '\0')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Not enough room in dst, add NUL and traverse rest of src */
|
||||||
|
if (n == 0) {
|
||||||
|
if (siz != 0)
|
||||||
|
*d = '\0'; /* NUL-terminate dst */
|
||||||
|
while (*s++)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(s - src - 1); /* count does not include NUL */
|
||||||
|
}
|
|
@ -1024,7 +1024,8 @@ void CL_ParseServerMessage (void)
|
||||||
{
|
{
|
||||||
int cmd;
|
int cmd;
|
||||||
int i;
|
int i;
|
||||||
|
int total, j, lastcmd; //johnfitz
|
||||||
|
|
||||||
//
|
//
|
||||||
// if recording demos, copy the message out
|
// if recording demos, copy the message out
|
||||||
//
|
//
|
||||||
|
@ -1130,8 +1131,23 @@ void CL_ParseServerMessage (void)
|
||||||
i = MSG_ReadByte ();
|
i = MSG_ReadByte ();
|
||||||
if (i >= MAX_LIGHTSTYLES)
|
if (i >= MAX_LIGHTSTYLES)
|
||||||
Sys_Error ("svc_lightstyle > MAX_LIGHTSTYLES");
|
Sys_Error ("svc_lightstyle > MAX_LIGHTSTYLES");
|
||||||
Q_strcpy (cl_lightstyle[i].map, MSG_ReadString());
|
q_strlcpy (cl_lightstyle[i].map, MSG_ReadString(), MAX_STYLESTRING);
|
||||||
cl_lightstyle[i].length = Q_strlen(cl_lightstyle[i].map);
|
cl_lightstyle[i].length = Q_strlen(cl_lightstyle[i].map);
|
||||||
|
//johnfitz -- save extra info
|
||||||
|
if (cl_lightstyle[i].length)
|
||||||
|
{
|
||||||
|
total = 0;
|
||||||
|
cl_lightstyle[i].peak = 'a';
|
||||||
|
for (j=0; j<cl_lightstyle[i].length; j++)
|
||||||
|
{
|
||||||
|
total += cl_lightstyle[i].map[j] - 'a';
|
||||||
|
cl_lightstyle[i].peak = max(cl_lightstyle[i].peak, cl_lightstyle[i].map[j]);
|
||||||
|
}
|
||||||
|
cl_lightstyle[i].average = total / cl_lightstyle[i].length + 'a';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cl_lightstyle[i].average = cl_lightstyle[i].peak = 'm';
|
||||||
|
//johnfitz
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case svc_sound:
|
case svc_sound:
|
||||||
|
|
|
@ -36,6 +36,8 @@ typedef struct
|
||||||
{
|
{
|
||||||
int length;
|
int length;
|
||||||
char map[MAX_STYLESTRING];
|
char map[MAX_STYLESTRING];
|
||||||
|
char average; //johnfitz
|
||||||
|
char peak; //johnfitz
|
||||||
} lightstyle_t;
|
} lightstyle_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
|
@ -155,7 +155,8 @@ typedef struct msurface_s
|
||||||
|
|
||||||
// lighting info
|
// lighting info
|
||||||
int dlightframe;
|
int dlightframe;
|
||||||
int dlightbits;
|
unsigned int dlightbits[(MAX_DLIGHTS + 31) >> 5];
|
||||||
|
// int is 32 bits, need an array for MAX_DLIGHTS > 32
|
||||||
|
|
||||||
int lightmaptexturenum;
|
int lightmaptexturenum;
|
||||||
byte styles[MAXLIGHTMAPS];
|
byte styles[MAXLIGHTMAPS];
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 1996-1997 Id Software, Inc.
|
Copyright (C) 1996-2001 Id Software, Inc.
|
||||||
|
Copyright (C) 2002-2009 John Fitzgibbons and others
|
||||||
|
Copyright (C) 2010-2014 QuakeSpasm developers
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
|
@ -8,7 +10,7 @@ of the License, or (at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
See the GNU General Public License for more details.
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
@ -23,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
int r_dlightframecount;
|
int r_dlightframecount;
|
||||||
|
|
||||||
vec3_t lightcolor; //johnfitz -- lit support via lordhavoc
|
extern cvar_t r_flatlightstyles; //johnfitz
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==================
|
==================
|
||||||
|
@ -33,7 +35,7 @@ R_AnimateLight
|
||||||
void R_AnimateLight (void)
|
void R_AnimateLight (void)
|
||||||
{
|
{
|
||||||
int i,j,k;
|
int i,j,k;
|
||||||
|
|
||||||
//
|
//
|
||||||
// light animations
|
// light animations
|
||||||
// 'm' is normal light, 'a' is no light, 'z' is double bright
|
// 'm' is normal light, 'a' is no light, 'z' is double bright
|
||||||
|
@ -45,17 +47,25 @@ void R_AnimateLight (void)
|
||||||
d_lightstylevalue[j] = 256;
|
d_lightstylevalue[j] = 256;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
k = i % cl_lightstyle[j].length;
|
//johnfitz -- r_flatlightstyles
|
||||||
k = cl_lightstyle[j].map[k] - 'a';
|
if (r_flatlightstyles.value == 2)
|
||||||
k = k*22;
|
k = cl_lightstyle[j].peak - 'a';
|
||||||
d_lightstylevalue[j] = k;
|
else if (r_flatlightstyles.value == 1)
|
||||||
}
|
k = cl_lightstyle[j].average - 'a';
|
||||||
|
else
|
||||||
|
{
|
||||||
|
k = i % cl_lightstyle[j].length;
|
||||||
|
k = cl_lightstyle[j].map[k] - 'a';
|
||||||
|
}
|
||||||
|
d_lightstylevalue[j] = k*22;
|
||||||
|
//johnfitz
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============================================================================
|
=============================================================================
|
||||||
|
|
||||||
DYNAMIC LIGHTS BLEND RENDERING
|
DYNAMIC LIGHTS BLEND RENDERING (gl_flashblend 1)
|
||||||
|
|
||||||
=============================================================================
|
=============================================================================
|
||||||
*/
|
*/
|
||||||
|
@ -83,14 +93,14 @@ void R_RenderDlight (dlight_t *light)
|
||||||
rad = light->radius * 0.35;
|
rad = light->radius * 0.35;
|
||||||
|
|
||||||
VectorSubtract (light->origin, r_origin, v);
|
VectorSubtract (light->origin, r_origin, v);
|
||||||
if (Length (v) < rad)
|
if (VectorLength (v) < rad)
|
||||||
{ // view is inside the dlight
|
{ // view is inside the dlight
|
||||||
AddLightBlend (1, 0.5, 0, light->radius * 0.0003);
|
AddLightBlend (1, 0.5, 0, light->radius * 0.0003);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
glBegin (GL_TRIANGLE_FAN);
|
glBegin (GL_TRIANGLE_FAN);
|
||||||
glColor3f (0.2,0.1,0.0);
|
glColor3f (light->color[0],light->color[1],light->color[2]);
|
||||||
for (i=0 ; i<3 ; i++)
|
for (i=0 ; i<3 ; i++)
|
||||||
v[i] = light->origin[i] - vpn[i]*rad;
|
v[i] = light->origin[i] - vpn[i]*rad;
|
||||||
glVertex3fv (v);
|
glVertex3fv (v);
|
||||||
|
@ -153,56 +163,44 @@ DYNAMIC LIGHTS
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============
|
=============
|
||||||
R_MarkLights
|
R_MarkLights -- johnfitz -- rewritten to use LordHavoc's lighting speedup
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
void R_MarkLights (dlight_t *light, int bit, mnode_t *node)
|
void R_MarkLights (dlight_t *light, int num, mnode_t *node)
|
||||||
{
|
{
|
||||||
mplane_t *splitplane;
|
mplane_t *splitplane;
|
||||||
float dist;
|
|
||||||
msurface_t *surf;
|
msurface_t *surf;
|
||||||
int i;
|
|
||||||
// LordHavoc: .lit support begin (actually this is just a major lighting speedup, no relation to color :)
|
|
||||||
float l, maxdist;
|
|
||||||
int j, s, t;
|
|
||||||
vec3_t impact;
|
vec3_t impact;
|
||||||
loc0:
|
float dist, l, maxdist;
|
||||||
// LordHavoc: .lit support end
|
int i, j, s, t;
|
||||||
|
|
||||||
|
start:
|
||||||
|
|
||||||
if (node->contents < 0)
|
if (node->contents < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
splitplane = node->plane; // LordHavoc: original code
|
splitplane = node->plane;
|
||||||
// LordHavoc: .lit support (actually this is just a major lighting speedup, no relation to color :)
|
|
||||||
if (splitplane->type < 3)
|
if (splitplane->type < 3)
|
||||||
dist = light->origin[splitplane->type] - splitplane->dist;
|
dist = light->origin[splitplane->type] - splitplane->dist;
|
||||||
else
|
else
|
||||||
dist = DotProduct (light->origin, splitplane->normal) - splitplane->dist; // LordHavoc: original code
|
dist = DotProduct (light->origin, splitplane->normal) - splitplane->dist;
|
||||||
// LordHavoc: .lit support end
|
|
||||||
|
|
||||||
if (dist > light->radius)
|
if (dist > light->radius)
|
||||||
{
|
{
|
||||||
// LordHavoc: .lit support begin (actually this is just a major lighting speedup, no relation to color :)
|
|
||||||
node = node->children[0];
|
node = node->children[0];
|
||||||
goto loc0;
|
goto start;
|
||||||
// LordHavoc: .lit support end
|
|
||||||
}
|
}
|
||||||
if (dist < -light->radius)
|
if (dist < -light->radius)
|
||||||
{
|
{
|
||||||
// LordHavoc: .lit support begin (actually this is just a major lighting speedup, no relation to color :)
|
|
||||||
node = node->children[1];
|
node = node->children[1];
|
||||||
goto loc0;
|
goto start;
|
||||||
// LordHavoc: .lit support end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
maxdist = light->radius*light->radius; // LordHavoc: .lit support (actually this is just a major lighting speedup, no relation to color :)
|
maxdist = light->radius*light->radius;
|
||||||
// mark the polygons
|
// mark the polygons
|
||||||
surf = cl.worldmodel->surfaces + node->firstsurface;
|
surf = cl.worldmodel->surfaces + node->firstsurface;
|
||||||
for (i=0 ; i<node->numsurfaces ; i++, surf++)
|
for (i=0 ; i<node->numsurfaces ; i++, surf++)
|
||||||
{
|
{
|
||||||
|
|
||||||
// LordHavoc: .lit support begin (actually this is just a major lighting speedup, no relation to color :)
|
|
||||||
// LordHavoc: MAJOR dynamic light speedup here, eliminates marking of surfaces that are too far away from light, thus preventing unnecessary renders and uploads
|
|
||||||
for (j=0 ; j<3 ; j++)
|
for (j=0 ; j<3 ; j++)
|
||||||
impact[j] = light->origin[j] - surf->plane->normal[j]*dist;
|
impact[j] = light->origin[j] - surf->plane->normal[j]*dist;
|
||||||
// clamp center of light to corner and check brightness
|
// clamp center of light to corner and check brightness
|
||||||
|
@ -217,24 +215,20 @@ loc0:
|
||||||
{
|
{
|
||||||
if (surf->dlightframe != r_dlightframecount) // not dynamic until now
|
if (surf->dlightframe != r_dlightframecount) // not dynamic until now
|
||||||
{
|
{
|
||||||
surf->dlightbits = bit;
|
surf->dlightbits[num >> 5] = 1U << (num & 31);
|
||||||
surf->dlightframe = r_dlightframecount;
|
surf->dlightframe = r_dlightframecount;
|
||||||
}
|
}
|
||||||
else // already dynamic
|
else // already dynamic
|
||||||
surf->dlightbits |= bit;
|
surf->dlightbits[num >> 5] |= 1U << (num & 31);
|
||||||
}
|
}
|
||||||
// LordHavoc: .lit support end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// LordHavoc: .lit support begin (actually this is just a major lighting speedup, no relation to color :)
|
|
||||||
if (node->children[0]->contents >= 0)
|
if (node->children[0]->contents >= 0)
|
||||||
R_MarkLights (light, bit, node->children[0]); // LordHavoc: original code
|
R_MarkLights (light, num, node->children[0]);
|
||||||
if (node->children[1]->contents >= 0)
|
if (node->children[1]->contents >= 0)
|
||||||
R_MarkLights (light, bit, node->children[1]); // LordHavoc: original code
|
R_MarkLights (light, num, node->children[1]);
|
||||||
// LordHavoc: .lit support end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============
|
=============
|
||||||
R_PushDlights
|
R_PushDlights
|
||||||
|
@ -256,14 +250,16 @@ void R_PushDlights (void)
|
||||||
{
|
{
|
||||||
if (l->die < cl.time || !l->radius)
|
if (l->die < cl.time || !l->radius)
|
||||||
continue;
|
continue;
|
||||||
R_MarkLights ( l, 1<<i, cl.worldmodel->nodes );
|
R_MarkLights (l, i, cl.worldmodel->nodes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============================================================================
|
=============================================================================
|
||||||
|
|
||||||
LIGHT SAMPLING
|
LIGHT SAMPLING
|
||||||
|
|
||||||
=============================================================================
|
=============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -271,8 +267,11 @@ mplane_t *lightplane;
|
||||||
vec3_t lightspot;
|
vec3_t lightspot;
|
||||||
vec3_t lightcolor; //johnfitz -- lit support via lordhavoc
|
vec3_t lightcolor; //johnfitz -- lit support via lordhavoc
|
||||||
|
|
||||||
// LordHavoc: .lit support begin
|
/*
|
||||||
// LordHavoc: original code replaced entirely
|
=============
|
||||||
|
RecursiveLightPoint -- johnfitz -- replaced entire function for lit support via lordhavoc
|
||||||
|
=============
|
||||||
|
*/
|
||||||
int RecursiveLightPoint (vec3_t color, mnode_t *node, vec3_t start, vec3_t end)
|
int RecursiveLightPoint (vec3_t color, mnode_t *node, vec3_t start, vec3_t end)
|
||||||
{
|
{
|
||||||
float front, back, frac;
|
float front, back, frac;
|
||||||
|
@ -281,7 +280,7 @@ int RecursiveLightPoint (vec3_t color, mnode_t *node, vec3_t start, vec3_t end)
|
||||||
loc0:
|
loc0:
|
||||||
if (node->contents < 0)
|
if (node->contents < 0)
|
||||||
return false; // didn't hit anything
|
return false; // didn't hit anything
|
||||||
|
|
||||||
// calculate mid point
|
// calculate mid point
|
||||||
if (node->plane->type < 3)
|
if (node->plane->type < 3)
|
||||||
{
|
{
|
||||||
|
@ -301,12 +300,12 @@ loc0:
|
||||||
node = node->children[front < 0];
|
node = node->children[front < 0];
|
||||||
goto loc0;
|
goto loc0;
|
||||||
}
|
}
|
||||||
|
|
||||||
frac = front / (front-back);
|
frac = front / (front-back);
|
||||||
mid[0] = start[0] + (end[0] - start[0])*frac;
|
mid[0] = start[0] + (end[0] - start[0])*frac;
|
||||||
mid[1] = start[1] + (end[1] - start[1])*frac;
|
mid[1] = start[1] + (end[1] - start[1])*frac;
|
||||||
mid[2] = start[2] + (end[2] - start[2])*frac;
|
mid[2] = start[2] + (end[2] - start[2])*frac;
|
||||||
|
|
||||||
// go down front side
|
// go down front side
|
||||||
if (RecursiveLightPoint (color, node->children[front < 0], start, mid))
|
if (RecursiveLightPoint (color, node->children[front < 0], start, mid))
|
||||||
return true; // hit something
|
return true; // hit something
|
||||||
|
@ -324,15 +323,18 @@ loc0:
|
||||||
if (surf->flags & SURF_DRAWTILED)
|
if (surf->flags & SURF_DRAWTILED)
|
||||||
continue; // no lightmaps
|
continue; // no lightmaps
|
||||||
|
|
||||||
ds = (int) ((float) DotProduct (mid, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3]);
|
// ericw -- added double casts to force 64-bit precision.
|
||||||
dt = (int) ((float) DotProduct (mid, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3]);
|
// Without them the zombie at the start of jam3_ericw.bsp was
|
||||||
|
// incorrectly being lit up in SSE builds.
|
||||||
|
ds = (int) ((double) DoublePrecisionDotProduct (mid, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3]);
|
||||||
|
dt = (int) ((double) DoublePrecisionDotProduct (mid, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3]);
|
||||||
|
|
||||||
if (ds < surf->texturemins[0] || dt < surf->texturemins[1])
|
if (ds < surf->texturemins[0] || dt < surf->texturemins[1])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ds -= surf->texturemins[0];
|
ds -= surf->texturemins[0];
|
||||||
dt -= surf->texturemins[1];
|
dt -= surf->texturemins[1];
|
||||||
|
|
||||||
if (ds > surf->extents[0] || dt > surf->extents[1])
|
if (ds > surf->extents[0] || dt > surf->extents[1])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -368,10 +370,15 @@ loc0:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3_t lightcolor; // LordHavoc: used by model rendering
|
/*
|
||||||
|
=============
|
||||||
|
R_LightPoint -- johnfitz -- replaced entire function for lit support via lordhavoc
|
||||||
|
=============
|
||||||
|
*/
|
||||||
int R_LightPoint (vec3_t p)
|
int R_LightPoint (vec3_t p)
|
||||||
{
|
{
|
||||||
vec3_t end;
|
vec3_t end;
|
||||||
|
|
||||||
if (!cl.worldmodel->lightdata)
|
if (!cl.worldmodel->lightdata)
|
||||||
{
|
{
|
||||||
lightcolor[0] = lightcolor[1] = lightcolor[2] = 255;
|
lightcolor[0] = lightcolor[1] = lightcolor[2] = 255;
|
||||||
|
@ -381,9 +388,8 @@ int R_LightPoint (vec3_t p)
|
||||||
end[0] = p[0];
|
end[0] = p[0];
|
||||||
end[1] = p[1];
|
end[1] = p[1];
|
||||||
end[2] = p[2] - 8192; //johnfitz -- was 2048
|
end[2] = p[2] - 8192; //johnfitz -- was 2048
|
||||||
|
|
||||||
lightcolor[0] = lightcolor[1] = lightcolor[2] = 0;
|
lightcolor[0] = lightcolor[1] = lightcolor[2] = 0;
|
||||||
RecursiveLightPoint (lightcolor, cl.worldmodel->nodes, p, end);
|
RecursiveLightPoint (lightcolor, cl.worldmodel->nodes, p, end);
|
||||||
return ((lightcolor[0] + lightcolor[1] + lightcolor[2]) * (1.0f / 3.0f));
|
return ((lightcolor[0] + lightcolor[1] + lightcolor[2]) * (1.0f / 3.0f));
|
||||||
}
|
}
|
||||||
// LordHavoc: .lit support end
|
|
||||||
|
|
|
@ -123,6 +123,8 @@ cvar_t r_model_brightness = { "r_model_brightness", "1", qtrue}; // Toggle h
|
||||||
|
|
||||||
cvar_t r_farclip = {"r_farclip", "4096"}; //far cliping for q3 models
|
cvar_t r_farclip = {"r_farclip", "4096"}; //far cliping for q3 models
|
||||||
|
|
||||||
|
cvar_t r_flatlightstyles = {"r_flatlightstyles", "0", qfalse};
|
||||||
|
|
||||||
//johnfitz -- struct for passing lerp information to drawing functions
|
//johnfitz -- struct for passing lerp information to drawing functions
|
||||||
typedef struct {
|
typedef struct {
|
||||||
short pose1;
|
short pose1;
|
||||||
|
|
|
@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "quakedef.h"
|
#include "quakedef.h"
|
||||||
|
|
||||||
|
extern cvar_t r_flatlightstyles;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==================
|
==================
|
||||||
|
@ -230,6 +230,8 @@ void R_Init (void)
|
||||||
Cvar_RegisterVariable (&r_flametype);
|
Cvar_RegisterVariable (&r_flametype);
|
||||||
//Cvar_RegisterVariable (&r_model_brightness);
|
//Cvar_RegisterVariable (&r_model_brightness);
|
||||||
|
|
||||||
|
Cvar_RegisterVariable (&r_flatlightstyles);
|
||||||
|
|
||||||
R_InitParticles ();
|
R_InitParticles ();
|
||||||
R_InitParticleTexture ();
|
R_InitParticleTexture ();
|
||||||
Fog_Init ();
|
Fog_Init ();
|
||||||
|
|
|
@ -67,10 +67,6 @@ R_AddDynamicLights
|
||||||
*/
|
*/
|
||||||
void R_AddDynamicLights (msurface_t *surf)
|
void R_AddDynamicLights (msurface_t *surf)
|
||||||
{
|
{
|
||||||
// LordHavoc: .lit support begin
|
|
||||||
float cred, cgreen, cblue, brightness;
|
|
||||||
unsigned *bl;
|
|
||||||
// LordHavoc: .lit support end
|
|
||||||
int lnum;
|
int lnum;
|
||||||
int sd, td;
|
int sd, td;
|
||||||
float dist, rad, minlight;
|
float dist, rad, minlight;
|
||||||
|
@ -79,6 +75,10 @@ void R_AddDynamicLights (msurface_t *surf)
|
||||||
int i;
|
int i;
|
||||||
int smax, tmax;
|
int smax, tmax;
|
||||||
mtexinfo_t *tex;
|
mtexinfo_t *tex;
|
||||||
|
//johnfitz -- lit support via lordhavoc
|
||||||
|
float cred, cgreen, cblue, brightness;
|
||||||
|
unsigned *bl;
|
||||||
|
//johnfitz
|
||||||
|
|
||||||
smax = (surf->extents[0]>>4)+1;
|
smax = (surf->extents[0]>>4)+1;
|
||||||
tmax = (surf->extents[1]>>4)+1;
|
tmax = (surf->extents[1]>>4)+1;
|
||||||
|
@ -86,7 +86,7 @@ void R_AddDynamicLights (msurface_t *surf)
|
||||||
|
|
||||||
for (lnum=0 ; lnum<MAX_DLIGHTS ; lnum++)
|
for (lnum=0 ; lnum<MAX_DLIGHTS ; lnum++)
|
||||||
{
|
{
|
||||||
if ( !(surf->dlightbits & (1<<lnum) ) )
|
if (! (surf->dlightbits[lnum >> 5] & (1U << (lnum & 31))))
|
||||||
continue; // not lit by this light
|
continue; // not lit by this light
|
||||||
|
|
||||||
rad = cl_dlights[lnum].radius;
|
rad = cl_dlights[lnum].radius;
|
||||||
|
@ -109,14 +109,13 @@ void R_AddDynamicLights (msurface_t *surf)
|
||||||
|
|
||||||
local[0] -= surf->texturemins[0];
|
local[0] -= surf->texturemins[0];
|
||||||
local[1] -= surf->texturemins[1];
|
local[1] -= surf->texturemins[1];
|
||||||
|
|
||||||
// LordHavoc: .lit support begin
|
//johnfitz -- lit support via lordhavoc
|
||||||
bl = blocklights;
|
bl = blocklights;
|
||||||
cred = cl_dlights[lnum].color[0] * 256.0f;
|
cred = cl_dlights[lnum].color[0] * 256.0f;
|
||||||
cgreen = cl_dlights[lnum].color[1] * 256.0f;
|
cgreen = cl_dlights[lnum].color[1] * 256.0f;
|
||||||
cblue = cl_dlights[lnum].color[2] * 256.0f;
|
cblue = cl_dlights[lnum].color[2] * 256.0f;
|
||||||
// LordHavoc: .lit support end
|
//johnfitz
|
||||||
|
|
||||||
for (t = 0 ; t<tmax ; t++)
|
for (t = 0 ; t<tmax ; t++)
|
||||||
{
|
{
|
||||||
td = local[1] - t*16;
|
td = local[1] - t*16;
|
||||||
|
@ -131,33 +130,16 @@ void R_AddDynamicLights (msurface_t *surf)
|
||||||
dist = sd + (td>>1);
|
dist = sd + (td>>1);
|
||||||
else
|
else
|
||||||
dist = td + (sd>>1);
|
dist = td + (sd>>1);
|
||||||
if (dist < minlight){
|
if (dist < minlight)
|
||||||
|
//johnfitz -- lit support via lordhavoc
|
||||||
|
{
|
||||||
brightness = rad - dist;
|
brightness = rad - dist;
|
||||||
if (!cl_dlights[lnum].dark)
|
bl[0] += (int) (brightness * cred);
|
||||||
{
|
bl[1] += (int) (brightness * cgreen);
|
||||||
bl[0] += (int) (brightness * cred);
|
bl[2] += (int) (brightness * cblue);
|
||||||
bl[1] += (int) (brightness * cgreen);
|
|
||||||
bl[2] += (int) (brightness * cblue);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(bl[0] > (int) (brightness * cred))
|
|
||||||
bl[0] -= (int) (brightness * cred);
|
|
||||||
else
|
|
||||||
bl[0] = 0;
|
|
||||||
|
|
||||||
if(bl[1] > (int) (brightness * cgreen))
|
|
||||||
bl[1] -= (int) (brightness * cgreen);
|
|
||||||
else
|
|
||||||
bl[1] = 0;
|
|
||||||
|
|
||||||
if(bl[2] > (int) (brightness * cblue))
|
|
||||||
bl[2] -= (int) (brightness * cblue);
|
|
||||||
else
|
|
||||||
bl[2] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
bl += 3;
|
bl += 3;
|
||||||
|
//johnfitz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ extern int nanmask;
|
||||||
#define Q_rint(x) ((x) > 0 ? (int)((x) + 0.5) : (int)((x) - 0.5)) //johnfitz -- from joequake
|
#define Q_rint(x) ((x) > 0 ? (int)((x) + 0.5) : (int)((x) - 0.5)) //johnfitz -- from joequake
|
||||||
|
|
||||||
#define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])
|
#define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])
|
||||||
|
#define DoublePrecisionDotProduct(x,y) ((double)x[0]*y[0]+(double)x[1]*y[1]+(double)x[2]*y[2])
|
||||||
#define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];}
|
#define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];}
|
||||||
#define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];}
|
#define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];}
|
||||||
#define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];}
|
#define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];}
|
||||||
|
|
|
@ -322,6 +322,7 @@ typedef struct
|
||||||
|
|
||||||
#ifdef GLQUAKE
|
#ifdef GLQUAKE
|
||||||
#include "gl_model.h"
|
#include "gl_model.h"
|
||||||
|
#include "gl_decal.h"
|
||||||
#else
|
#else
|
||||||
#include "model.h"
|
#include "model.h"
|
||||||
#include "d_iface.h"
|
#include "d_iface.h"
|
||||||
|
@ -342,8 +343,6 @@ typedef struct
|
||||||
|
|
||||||
#include "cl_hud.h"
|
#include "cl_hud.h"
|
||||||
|
|
||||||
#include "gl_decal.h"
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
// the host system specifies the base of the directory tree, the
|
// the host system specifies the base of the directory tree, the
|
||||||
|
|
10
source/strl_fn.h
Normal file
10
source/strl_fn.h
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
/* header file for BSD strlcat and strlcpy */
|
||||||
|
|
||||||
|
#ifndef __STRLFUNCS_H
|
||||||
|
#define __STRLFUNCS_H
|
||||||
|
|
||||||
|
/* use our own copies of strlcpy and strlcat taken from OpenBSD */
|
||||||
|
extern size_t q_strlcpy (char *dst, const char *src, size_t size);
|
||||||
|
extern size_t q_strlcat (char *dst, const char *src, size_t size);
|
||||||
|
|
||||||
|
#endif /* __STRLFUNCS_H */
|
Loading…
Reference in a new issue