Light stuff

git-svn-id: https://svn.eduke32.com/eduke32@1402 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2009-06-06 10:20:00 +00:00
parent c3b41ce1cf
commit d4bca26bd9
10 changed files with 425 additions and 304 deletions

View File

@ -42,15 +42,16 @@
#include <limits.h>
// For Visual Studio 6 in C++ mode wrap <wchar.h> include with 'extern "C++" {}'
// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
// or compiler give many errors like this:
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
#if (_MSC_VER < 1300) && defined(__cplusplus)
extern "C++" {
#endif
# include <wchar.h>
#if (_MSC_VER < 1300) && defined(__cplusplus)
}
#ifdef __cplusplus
extern "C" {
#endif
# include <wchar.h>
#ifdef __cplusplus
}
#endif
// Define _W64 macros to mark types changing their size, like intptr_t.
@ -62,17 +63,32 @@
# endif
#endif
// 7.18.1 Integer types
// 7.18.1.1 Exact-width integer types
typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
typedef signed __int32 int32_t;
typedef signed __int64 int64_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
// Visual Studio 6 and Embedded Visual C++ 4 doesn't
// realize that, e.g. char has the same size as __int8
// so we give up on __intX for them.
#if (_MSC_VER < 1300)
typedef signed char int8_t;
typedef short int16_t;
typedef int int32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#else
typedef signed __int8 int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
#endif
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
// 7.18.1.2 Minimum-width integer types
typedef int8_t int_least8_t;

View File

@ -148,39 +148,6 @@ typedef struct s_prprogrambit {
char* frag_prog;
} _prprogrambit;
// LIGHTS
#define PR_MAXLIGHTS 128
#define SHADOW_DEPTH_OFFSET 30
#define PR_MAXLIGHTPRIORITY 6
typedef struct s_prlight {
int32_t x, y, z, horiz, range;
int16_t angle, faderadius, radius, sector;
uint8_t color[3], priority;
int8_t minshade, maxshade;
int16_t tilenum;
// internal members
GLfloat proj[16];
GLfloat transform[16];
float frustum[5 * 4];
int32_t rtindex;
struct {
int32_t active : 1;
int32_t invalidate : 1;
int32_t isinview : 1;
} flags;
GLuint lightmap;
} _prlight;
extern _prlight staticlights[PR_MAXLIGHTS];
extern int32_t staticlightcount;
extern _prlight gamelights[PR_MAXLIGHTS];
extern int32_t gamelightcount;
extern _prlight framelights[PR_MAXLIGHTS];
extern int32_t framelightcount;
// RENDER TARGETS
typedef struct s_prrt {
GLenum target;
@ -190,6 +157,12 @@ typedef struct s_prrt {
int32_t xdim, ydim;
} _prrt;
// LIGHTS
#define PR_MAXLIGHTS 128
#define SHADOW_DEPTH_OFFSET 30
#define PR_MAXLIGHTPRIORITY 6
// BUILD DATA
typedef struct s_prplane {
// geometry
@ -211,6 +184,40 @@ typedef struct s_prplane {
int16_t lightcount;
} _prplane;
typedef struct s_prlight {
int32_t x, y, z, horiz, range;
int16_t angle, faderadius, radius, sector;
uint8_t color[3], priority;
int8_t minshade, maxshade;
int16_t tilenum;
// internal members
GLfloat proj[16];
GLfloat transform[16];
float frustum[5 * 4];
int32_t rtindex;
struct {
int32_t active : 1;
int32_t invalidate : 1;
int32_t isinview : 1;
int32_t display : 1;
} flags;
GLuint lightmap;
_prplane* myplanes[PR_MAXLIGHTS];
int32_t planecnt;
} _prlight;
extern _prlight staticlights[PR_MAXLIGHTS];
extern int32_t staticlightcount;
extern _prlight gamelights[PR_MAXLIGHTS];
extern int32_t gamelightcount;
extern _prlight framelights[PR_MAXLIGHTS];
extern int32_t framelightcount;
extern _prlight prlights[PR_MAXLIGHTS];
typedef struct s_prsector {
// polymer data
GLdouble* verts;
@ -334,7 +341,7 @@ static void polymer_updatelights(void);
static void polymer_resetlights(void);
static void polymer_resetplanelights(_prplane* plane);
static void polymer_addplanelight(_prplane* plane, int16_t lighti);
static void polymer_deleteplanelight(_prplane* plane, int16_t lighti);
static inline void polymer_deleteplanelight(_prplane* plane, int16_t lighti);
static int32_t polymer_planeinlight(_prplane* plane, _prlight* light);
static void polymer_invalidateplanelights(_prplane* plane);
static void polymer_invalidatesectorlights(int16_t sectnum);

View File

@ -6225,8 +6225,8 @@ killsprite:
curpolygonoffset = 0;
cullcheckcnt = 0;
#endif
pos.x = globalposx;
pos.y = globalposy;
pos.x = (float)globalposx;
pos.y = (float)globalposy;
while (maskwallcnt)
{
@ -6234,18 +6234,18 @@ killsprite:
#if defined(USE_OPENGL) && defined(POLYMER)
if (rendmode == 4)
{
dot.x = wall[maskwall[maskwallcnt]].x;
dot.y = wall[maskwall[maskwallcnt]].y;
dot2.x = wall[wall[maskwall[maskwallcnt]].point2].x;
dot2.y = wall[wall[maskwall[maskwallcnt]].point2].y;
dot.x = (float)wall[maskwall[maskwallcnt]].x;
dot.y = (float)wall[maskwall[maskwallcnt]].y;
dot2.x = (float)wall[wall[maskwall[maskwallcnt]].point2].x;
dot2.y = (float)wall[wall[maskwall[maskwallcnt]].point2].y;
}
else
#endif
{
dot.x = wall[thewall[maskwall[maskwallcnt]]].x;
dot.y = wall[thewall[maskwall[maskwallcnt]]].y;
dot2.x = wall[wall[thewall[maskwall[maskwallcnt]]].point2].x;
dot2.y = wall[wall[thewall[maskwall[maskwallcnt]]].point2].y;
dot.x = (float)wall[thewall[maskwall[maskwallcnt]]].x;
dot.y = (float)wall[thewall[maskwall[maskwallcnt]]].y;
dot2.x = (float)wall[wall[thewall[maskwall[maskwallcnt]]].point2].x;
dot2.y = (float)wall[wall[thewall[maskwall[maskwallcnt]]].point2].y;
}
maskeq = equation(dot.x, dot.y, dot2.x, dot2.y);
@ -6261,8 +6261,8 @@ killsprite:
i--;
if (tspriteptr[i] != NULL)
{
spr.x = tspriteptr[i]->x;
spr.y = tspriteptr[i]->y;
spr.x = (float)tspriteptr[i]->x;
spr.y = (float)tspriteptr[i]->y;
if ((sameside(&maskeq, &spr, &pos) == 0) && sameside(&p1eq, &middle, &spr) && sameside(&p2eq, &middle, &spr))
{

View File

@ -1071,7 +1071,7 @@ void polymer_drawsprite(int32_t snum)
i = j = 0;
while (j < lightcount)
{
while (prlights[i].flags.active == 0) {
while (prlights[i].flags.active == 0 || prlights[i].flags.display == 0) {
i++;
}
@ -3279,7 +3279,7 @@ static void polymer_drawmdsprite(spritetype *tspr)
i = j = 0;
while (j < lightcount)
{
while (prlights[i].flags.active == 0) {
while (prlights[i].flags.active == 0 || prlights[i].flags.display == 0) {
i++;
}
@ -3608,8 +3608,10 @@ static void polymer_getbuildmaterial(_prmaterial* material, int16_t tile
}
// PR_BIT_GLOW_MAP
/*
if (r_fullbrights && pth && pth->flags & 16)
material->glowmap = pth->ofb->glpic;
*/
if (hicfindsubst(tilenum, GLOWPAL, 0))
{
@ -4121,118 +4123,14 @@ static void polymer_compileprogram(int32_t programbits)
// LIGHTS
static void polymer_removelight(int16_t lighti)
{
int32_t i;
_prsector *s;
_prwall *w;
// XXX: might need to store a list of affected planes in the light record
// if this loop ends up consuming too much cycles
i = 0;
while (i < numsectors)
{
s = prsectors[i];
polymer_deleteplanelight(&s->floor, lighti);
polymer_deleteplanelight(&s->ceil, lighti);
i++;
}
i = 0;
while (i < numwalls)
{
w = prwalls[i];
polymer_deleteplanelight(&w->wall, lighti);
polymer_deleteplanelight(&w->over, lighti);
polymer_deleteplanelight(&w->mask, lighti);
i++;
}
}
static void polymer_updatelights(void)
{
int32_t i;
while (i < PR_MAXLIGHTS)
{
if (prlights[i].flags.active && prlights[i].flags.invalidate) {
// highly suboptimal
polymer_removelight(i);
if (prlights[i].radius)
polymer_processspotlight(&prlights[i]);
polymer_culllight(i);
prlights[i].flags.invalidate = 0;
}
if (prlights[i].flags.active)
prlights[i].rtindex = -1;
i++;
}
}
static void polymer_resetlights(void)
{
int32_t i;
_prsector *s;
_prwall *w;
i = 0;
while (i < numsectors)
{
s = prsectors[i];
polymer_resetplanelights(&s->floor);
polymer_resetplanelights(&s->ceil);
i++;
}
i = 0;
while (i < numwalls)
{
w = prwalls[i];
polymer_resetplanelights(&w->wall);
polymer_resetplanelights(&w->over);
polymer_resetplanelights(&w->mask);
i++;
}
i = 0;
while (i < PR_MAXLIGHTS)
{
prlights[i].flags.active = 0;
i++;
}
lightcount = 0;
}
static void polymer_resetplanelights(_prplane* plane)
{
int32_t i;
i = 0;
while (i < PR_MAXLIGHTS)
{
plane->lights[i] = -1;
i++;
}
plane->lightcount = 0;
}
static void polymer_addplanelight(_prplane* plane, int16_t lighti)
{
int16_t i;
if (prlights[lighti].planecnt >= PR_MAXLIGHTS-1)
return;
i = 0;
while (i < PR_MAXLIGHTS)
{
@ -4240,13 +4138,15 @@ static void polymer_addplanelight(_prplane* plane, int16_t lighti)
{
plane->lights[i] = lighti;
plane->lightcount++;
prlights[lighti].myplanes[prlights[lighti].planecnt] = plane;
prlights[lighti].planecnt++;
return;
}
i++;
}
}
static void polymer_deleteplanelight(_prplane* plane, int16_t lighti)
static inline void polymer_deleteplanelight(_prplane* plane, int16_t lighti)
{
int16_t i;
@ -4314,6 +4214,118 @@ static void polymer_invalidateplanelights(_prplane* plane)
}
}
static void polymer_removelight(int16_t lighti)
{
int32_t i;
// XXX: might need to store a list of affected planes in the light record
// if this loop ends up consuming too much cycles
i = prlights[lighti].planecnt-1;
while (i >= 0)
{
polymer_deleteplanelight(prlights[lighti].myplanes[i], lighti);
i--;
}
}
static void polymer_updatelights(void)
{
int32_t i, curpriority;
i = 0;
while (i < PR_MAXLIGHTS)
prlights[i++].flags.display = 0;
curpriority = 0;
while (curpriority < pr_maxlightpriority)
{
i = 0;
do
{
while (prlights[i].priority != curpriority && i < PR_MAXLIGHTS)
i++;
if (i == PR_MAXLIGHTS)
break;
if (prlights[i].flags.active)
{
prlights[i].flags.display = 1;
if (prlights[i].flags.invalidate)
{
// highly suboptimal
polymer_removelight(i);
if (prlights[i].radius)
polymer_processspotlight(&prlights[i]);
polymer_culllight(i);
prlights[i].flags.invalidate = 0;
prlights[i].rtindex = -1;
}
}
i++;
}
while (1);
curpriority++;
}
}
static void polymer_resetlights(void)
{
int32_t i;
_prsector *s;
_prwall *w;
i = 0;
while (i < numsectors)
{
s = prsectors[i];
polymer_resetplanelights(&s->floor);
polymer_resetplanelights(&s->ceil);
i++;
}
i = 0;
while (i < numwalls)
{
w = prwalls[i];
polymer_resetplanelights(&w->wall);
polymer_resetplanelights(&w->over);
polymer_resetplanelights(&w->mask);
i++;
}
i = 0;
while (i < PR_MAXLIGHTS)
{
prlights[i].flags.active = 0;
i++;
}
lightcount = 0;
}
static void polymer_resetplanelights(_prplane* plane)
{
int32_t i;
i = 0;
while (i < PR_MAXLIGHTS)
{
plane->lights[i] = -1;
i++;
}
plane->lightcount = 0;
}
static void polymer_invalidatesectorlights(int16_t sectnum)
{
int32_t i;
@ -4420,6 +4432,9 @@ static inline void polymer_culllight(int16_t lighti)
Bmemset(drawingstate, 0, sizeof(int16_t) * numsectors);
drawingstate[light->sector] = 1;
prlights[lighti].planecnt = 0;
Bmemset(prlights[lighti].myplanes, 0, sizeof(intptr_t) * PR_MAXLIGHTS);
sectorqueue[0] = light->sector;
while (front != back)
@ -4478,7 +4493,7 @@ static void polymer_prepareshadows(void)
int16_t oviewangle, oglobalang;
int32_t ocosglobalang, osinglobalang;
int32_t ocosviewingrangeglobalang, osinviewingrangeglobalang;
int32_t i, j, k;
int32_t i, j;
int32_t gx, gy, gz;
int32_t oldoverridematerial;
@ -4494,11 +4509,11 @@ static void polymer_prepareshadows(void)
ocosviewingrangeglobalang = cosviewingrangeglobalang;
osinviewingrangeglobalang = sinviewingrangeglobalang;
i = j = k = 0;
i = j = 0;
while ((k < lightcount) && (j < pr_shadowcount))
while ((i < lightcount) && (j < pr_shadowcount))
{
while (prlights[i].flags.active == 0) {
while ((prlights[i].flags.active == 0 || prlights[i].flags.display == 0) && i < lightcount) {
i++;
}
@ -4559,7 +4574,6 @@ static void polymer_prepareshadows(void)
j++;
}
i++;
k++;
}
globalposx = gx;

View File

@ -419,8 +419,12 @@ void A_DeleteSprite(int32_t s)
}
#ifdef POLYMER
if (getrendermode() == 4 && ActorExtra[s].lightId != -1)
if (getrendermode() == 4 && ActorExtra[s].lightptr != NULL)
{
polymer_deletelight(ActorExtra[s].lightId);
ActorExtra[s].lightId = -1;
ActorExtra[s].lightptr = NULL;
}
#endif
deletesprite(s);
@ -578,6 +582,56 @@ static void ms(int32_t i)
}
}
inline void G_AddGameLight(int32_t radius, int32_t srcsprite, int32_t zoffset, int32_t range, int32_t color, int32_t priority)
{
#ifdef POLYMER
spritetype *s = &sprite[srcsprite];
if (ActorExtra[srcsprite].lightptr == NULL)
{
_prlight mylight;
mylight.sector = s->sectnum;
mylight.x = s->x;
mylight.y = s->y;
mylight.z = s->z-zoffset;
mylight.color[0] = color&255;
mylight.color[1] = (color>>8)&255;
mylight.color[2] = (color>>16)&255;
mylight.radius = radius;
mylight.range = range;
mylight.priority = priority;
ActorExtra[srcsprite].lightId = polymer_addlight(&mylight);
ActorExtra[srcsprite].lightptr = &prlights[ActorExtra[srcsprite].lightId];
return;
}
s->z -= zoffset;
if (radius != prlights[ActorExtra[srcsprite].lightId].radius ||
range != prlights[ActorExtra[srcsprite].lightId].range ||
Bmemcmp(&sprite[srcsprite], ActorExtra[srcsprite].lightptr, sizeof(int32_t) * 3))
{
Bmemcpy(ActorExtra[srcsprite].lightptr, &sprite[srcsprite], sizeof(int32_t) * 3);
ActorExtra[srcsprite].lightptr->sector = s->sectnum;
ActorExtra[srcsprite].lightptr->radius = radius;
ActorExtra[srcsprite].lightptr->range = range;
ActorExtra[srcsprite].lightptr->flags.invalidate = 1;
}
s->z += zoffset;
#else
UNREFERENCED_PARAMETER(radius);
UNREFERENCED_PARAMETER(sector);
UNREFERENCED_PARAMETER(x);
UNREFERENCED_PARAMETER(y);
UNREFERENCED_PARAMETER(z);
UNREFERENCED_PARAMETER(range);
UNREFERENCED_PARAMETER(color);
UNREFERENCED_PARAMETER(priority);
#endif
}
// sleeping monsters, etc
static void G_MoveZombieActors(void)
{
@ -605,10 +659,10 @@ static void G_MoveZombieActors(void)
case FLOORFLAME__STATIC:
case FIREBARREL__STATIC:
case FIREVASE__STATIC:
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1), 4096, 255+(95<<8),PR_LIGHT_PRIO_MAX_GAME);
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 4096, 255+(95<<8),PR_LIGHT_PRIO_MAX_GAME);
break;
case ATOMICHEALTH__STATIC:
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1), 2048, 128+(128<<8)+(255<<16),PR_LIGHT_PRIO_HIGH_GAME);
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 2048, 128+(128<<8)+(255<<16),PR_LIGHT_PRIO_HIGH_GAME);
break;
case FIRE__STATIC:
@ -617,7 +671,7 @@ static void G_MoveZombieActors(void)
if (ActorExtra[i].floorz - ActorExtra[i].ceilingz < 128) break;
if (s->z > ActorExtra[i].floorz+2048) break;
*/
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1), 64 * s->xrepeat, 255+(95<<8),PR_LIGHT_PRIO_MAX_GAME);
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 64 * s->xrepeat, 255+(95<<8),PR_LIGHT_PRIO_MAX_GAME);
break;
case BURNING__STATIC:
case BURNING2__STATIC:
@ -625,19 +679,19 @@ static void G_MoveZombieActors(void)
if (ActorExtra[i].floorz - ActorExtra[i].ceilingz < 128) break;
if (s->z > ActorExtra[i].floorz + 2048) break;
*/
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1), 64 * s->xrepeat, 255+(95<<8),PR_LIGHT_PRIO_MAX_GAME);
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 64 * s->xrepeat, 255+(95<<8),PR_LIGHT_PRIO_MAX_GAME);
break;
case EXPLOSION2__STATIC:
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1), 4096, 255+(95<<8),PR_LIGHT_PRIO_HIGH_GAME);
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 4096, 255+(95<<8),PR_LIGHT_PRIO_HIGH_GAME);
break;
case FORCERIPPLE__STATIC:
// case TRANSPORTERSTAR__STATIC:
case TRANSPORTERBEAM__STATIC:
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1), 2048, 80+(80<<8)+(255<<16),PR_LIGHT_PRIO_LOW_GAME);
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 2048, 80+(80<<8)+(255<<16),PR_LIGHT_PRIO_LOW_GAME);
break;
case SHRINKEREXPLOSION__STATIC:
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1), 2048, 128+(255<<8)+(128<<16),PR_LIGHT_PRIO_HIGH_GAME);
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 2048, 128+(255<<8)+(128<<16),PR_LIGHT_PRIO_HIGH_GAME);
break;
}
@ -1763,7 +1817,7 @@ static void G_MoveStandables(void)
if (s->picnum == OOZFILTER || s->picnum == SEENINE || s->picnum == SEENINEDEAD || s->picnum == (SEENINEDEAD+1))
{
if (s->picnum == OOZFILTER && s->xrepeat)
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1), 6144, 128+(255<<8)+(128<<16),PR_LIGHT_PRIO_HIGH_GAME);
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 6144, 128+(255<<8)+(128<<16),PR_LIGHT_PRIO_HIGH_GAME);
if (s->shade != -32 && s->shade != -33)
{
if (s->xrepeat)
@ -2190,7 +2244,7 @@ CLEAR_THE_BOLT:
case FLOORFLAME__STATIC:
case FIREBARREL__STATIC:
case FIREVASE__STATIC:
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1), 4096, 255+(95<<8),PR_LIGHT_PRIO_MAX_GAME);
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 4096, 255+(95<<8),PR_LIGHT_PRIO_MAX_GAME);
case EXPLODINGBARREL__STATIC:
case WOODENHORSE__STATIC:
case HORSEONSIDE__STATIC:
@ -2295,7 +2349,7 @@ static void G_MoveWeapons(void)
Bmemcpy(&davect,s,sizeof(vec3_t));
if (ActorExtra[i].projectile.flashcolor)
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1), 2048, ActorExtra[i].projectile.flashcolor,PR_LIGHT_PRIO_LOW_GAME);
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 2048, ActorExtra[i].projectile.flashcolor,PR_LIGHT_PRIO_LOW_GAME);
if (ActorExtra[i].projectile.workslike & PROJECTILE_BOUNCESOFFWALLS)
{
@ -2741,21 +2795,21 @@ static void G_MoveWeapons(void)
switch (DynamicTileMap[s->picnum])
{
case FREEZEBLAST__STATIC:
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1), 2048, 128+(128<<8)+(255<<16),PR_LIGHT_PRIO_HIGH_GAME);
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 2048, 128+(128<<8)+(255<<16),PR_LIGHT_PRIO_HIGH_GAME);
break;
case COOLEXPLOSION1__STATIC:
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1), 4096, 128+(0<<8)+(255<<16),PR_LIGHT_PRIO_HIGH_GAME);
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 4096, 128+(0<<8)+(255<<16),PR_LIGHT_PRIO_HIGH_GAME);
break;
case SHRINKSPARK__STATIC:
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1), 2048, 128+(255<<8)+(128<<16),PR_LIGHT_PRIO_HIGH_GAME);
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 2048, 128+(255<<8)+(128<<16),PR_LIGHT_PRIO_HIGH_GAME);
break;
case FIRELASER__STATIC:
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1), 64 * s->yrepeat, 255+(95<<8),PR_LIGHT_PRIO_LOW_GAME);
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 64 * s->yrepeat, 255+(95<<8),PR_LIGHT_PRIO_LOW_GAME);
break;
case RPG__STATIC:
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1), 64 * s->yrepeat, 255+(95<<8),PR_LIGHT_PRIO_LOW_GAME);
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 64 * s->yrepeat, 255+(95<<8),PR_LIGHT_PRIO_LOW_GAME);
if (DynamicTileMap[s->picnum] == RPG__STATIC && ActorExtra[i].picnum != BOSS2 &&
s->xrepeat >= 10 && sector[s->sectnum].lotag != 2)
@ -3401,7 +3455,7 @@ static void G_MoveActors(void)
switch (DynamicTileMap[switchpicnum])
{
case ATOMICHEALTH__STATIC:
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1), 2048, 128+(128<<8)+(255<<16),PR_LIGHT_PRIO_HIGH_GAME);
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 2048, 128+(128<<8)+(255<<16),PR_LIGHT_PRIO_HIGH_GAME);
break;
case FIRE__STATIC:
@ -3410,7 +3464,7 @@ static void G_MoveActors(void)
if (ActorExtra[i].floorz - ActorExtra[i].ceilingz < 128) break;
if (s->z > ActorExtra[i].floorz+2048) break;
*/
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1), 64 * s->xrepeat, 255+(95<<8),PR_LIGHT_PRIO_MAX_GAME);
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 64 * s->xrepeat, 255+(95<<8),PR_LIGHT_PRIO_MAX_GAME);
break;
case DUCK__STATIC:
@ -5165,20 +5219,20 @@ static void G_MoveMisc(void) // STATNUM 5
if (ActorExtra[i].floorz - ActorExtra[i].ceilingz < 128) break;
if (s->z > ActorExtra[i].floorz + 2048) break;
*/
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1), 64 * s->yrepeat, 255+(95<<8),PR_LIGHT_PRIO_MAX_GAME);
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 64 * s->yrepeat, 255+(95<<8),PR_LIGHT_PRIO_MAX_GAME);
break;
case EXPLOSION2__STATIC:
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1),
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1),
(512 * s->yrepeat) / (ActorExtra[i].temp_data[2]+1), 255+(95<<8),PR_LIGHT_PRIO_HIGH_GAME);
break;
case FORCERIPPLE__STATIC:
// case TRANSPORTERSTAR__STATIC:
case TRANSPORTERBEAM__STATIC:
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1), 2048, 80+(80<<8)+(255<<16),PR_LIGHT_PRIO_LOW_GAME);
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 2048, 80+(80<<8)+(255<<16),PR_LIGHT_PRIO_LOW_GAME);
break;
case SHRINKEREXPLOSION__STATIC:
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1), 2048, 128+(255<<8)+(128<<16),PR_LIGHT_PRIO_HIGH_GAME);
G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 2048, 128+(255<<8)+(128<<16),PR_LIGHT_PRIO_HIGH_GAME);
break;
}
if (!actorscrptr[sprite[i].picnum])
@ -7535,81 +7589,108 @@ static void G_MoveEffectors(void) //STATNUM 3
#ifdef POLYMER
case 49:
{
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].sector = SECT;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].x = SX;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].y = SY;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].z = SZ;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].range = SHT;
if ((sprite[i].xvel | sprite[i].yvel | sprite[i].zvel) != 0)
if (ActorExtra[i].lightptr == NULL)
{
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].color[0] = sprite[i].xvel;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].color[1] = sprite[i].yvel;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].color[2] = sprite[i].zvel;
}
else
{
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].color[0] = hictinting[PL].r;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].color[1] = hictinting[PL].g;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].color[2] = hictinting[PL].b;
}
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].radius = 0;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].angle = SA;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].horiz = SH;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].minshade = sprite[i].xoffset;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].maxshade = sprite[i].yoffset;
_prlight mylight;
if (CS & 2)
{
if (CS & 512)
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = PR_LIGHT_PRIO_LOW;
mylight.sector = SECT;
mylight.x = SX;
mylight.y = SY;
mylight.z = SZ;
mylight.range = SHT;
if ((sprite[i].xvel | sprite[i].yvel | sprite[i].zvel) != 0)
{
mylight.color[0] = sprite[i].xvel;
mylight.color[1] = sprite[i].yvel;
mylight.color[2] = sprite[i].zvel;
}
else
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = PR_LIGHT_PRIO_HIGH;
}
else
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = PR_LIGHT_PRIO_MAX;
{
mylight.color[0] = hictinting[PL].r;
mylight.color[1] = hictinting[PL].g;
mylight.color[2] = hictinting[PL].b;
}
mylight.radius = 0;
mylight.angle = SA;
mylight.horiz = SH;
mylight.minshade = sprite[i].xoffset;
mylight.maxshade = sprite[i].yoffset;
if (gamelightcount < PR_MAXLIGHTS)
gamelightcount++;
if (CS & 2)
{
if (CS & 512)
mylight.priority = PR_LIGHT_PRIO_LOW;
else
mylight.priority = PR_LIGHT_PRIO_HIGH;
}
else
mylight.priority = PR_LIGHT_PRIO_MAX;
ActorExtra[i].lightId = polymer_addlight(&mylight);
ActorExtra[i].lightptr = &prlights[ActorExtra[i].lightId];
break;
}
if (Bmemcmp(&sprite[i], ActorExtra[i].lightptr, sizeof(int32_t) * 3))
{
Bmemcpy(ActorExtra[i].lightptr, &sprite[i], sizeof(int32_t) * 3);
ActorExtra[i].lightptr->sector = sprite[i].sectnum;
ActorExtra[i].lightptr->flags.invalidate = 1;
}
break;
}
case 50:
{
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].sector = SECT;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].x = SX;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].y = SY;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].z = SZ;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].range = SHT;
if ((sprite[i].xvel | sprite[i].yvel | sprite[i].zvel) != 0)
if (ActorExtra[i].lightptr == NULL)
{
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].color[0] = sprite[i].xvel;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].color[1] = sprite[i].yvel;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].color[2] = sprite[i].zvel;
}
else
{
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].color[0] = hictinting[PL].r;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].color[1] = hictinting[PL].g;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].color[2] = hictinting[PL].b;
}
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].radius = (256-(SS+128))<<1;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].faderadius = gamelights[gamelightcount&(PR_MAXLIGHTS-1)].radius * 0.75;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].angle = SA;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].horiz = SH;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].minshade = sprite[i].xoffset;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].maxshade = sprite[i].yoffset;
_prlight mylight;
if (CS & 2)
{
if (CS & 512)
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = PR_LIGHT_PRIO_LOW;
mylight.sector = SECT;
mylight.x = SX;
mylight.y = SY;
mylight.z = SZ;
mylight.range = SHT;
if ((sprite[i].xvel | sprite[i].yvel | sprite[i].zvel) != 0)
{
mylight.color[0] = sprite[i].xvel;
mylight.color[1] = sprite[i].yvel;
mylight.color[2] = sprite[i].zvel;
}
else
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = PR_LIGHT_PRIO_HIGH;
}
else
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = PR_LIGHT_PRIO_MAX;
{
mylight.color[0] = hictinting[PL].r;
mylight.color[1] = hictinting[PL].g;
mylight.color[2] = hictinting[PL].b;
}
mylight.radius = (256-(SS+128))<<1;
mylight.faderadius = (int16_t)(mylight.radius * 0.75);
mylight.angle = SA;
mylight.horiz = SH;
mylight.minshade = sprite[i].xoffset;
mylight.maxshade = sprite[i].yoffset;
if (CS & 2)
{
if (CS & 512)
mylight.priority = PR_LIGHT_PRIO_LOW;
else
mylight.priority = PR_LIGHT_PRIO_HIGH;
}
else
mylight.priority = PR_LIGHT_PRIO_MAX;
ActorExtra[i].lightId = polymer_addlight(&mylight);
ActorExtra[i].lightptr = &prlights[ActorExtra[i].lightId];
break;
}
if (Bmemcmp(&sprite[i], ActorExtra[i].lightptr, sizeof(int32_t) * 3))
{
Bmemcpy(ActorExtra[i].lightptr, &sprite[i], sizeof(int32_t) * 3);
ActorExtra[i].lightptr->sector = sprite[i].sectnum;
ActorExtra[i].lightptr->flags.invalidate = 1;
}
if (gamelightcount < PR_MAXLIGHTS)
gamelightcount++;
break;
}
#endif // POLYMER

View File

@ -548,6 +548,7 @@ typedef struct {
projectile_t projectile;
#ifdef POLYMER
int16_t lightId;
int16_t lightcount; // how many tics until light is killed
_prlight *lightptr;
#endif
} ActorData_t;

View File

@ -276,38 +276,7 @@ static inline int32_t G_GetTeamPalette(int32_t team)
return 0;
}
static inline void G_AddGameLight(int32_t radius, int32_t sector, int32_t x, int32_t y, int32_t z, int32_t range, int32_t color, int32_t priority)
{
#ifdef POLYMER
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].radius = radius;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].sector = sector;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].x = x;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].y = y;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].z = z;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].range = range;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].range -= rand()%((gamelights[gamelightcount&(PR_MAXLIGHTS-1)].range>>3)+1);
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].color[0] = color&255;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].color[1] = (color>>8)&255;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].color[2] = (color>>16)&255;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = priority;
if (gamelightcount < PR_MAXLIGHTS)
gamelightcount++;
#else
UNREFERENCED_PARAMETER(radius);
UNREFERENCED_PARAMETER(sector);
UNREFERENCED_PARAMETER(x);
UNREFERENCED_PARAMETER(y);
UNREFERENCED_PARAMETER(z);
UNREFERENCED_PARAMETER(range);
UNREFERENCED_PARAMETER(color);
UNREFERENCED_PARAMETER(priority);
#endif
}
extern inline void G_AddGameLight(int32_t radius, int32_t srcsprite, int32_t zoffset, int32_t range, int32_t color, int32_t priority);
extern void se40code(int32_t x,int32_t y,int32_t z,int32_t a,int32_t h, int32_t smoothratio);

View File

@ -4541,9 +4541,6 @@ void G_DrawRooms(int32_t snum,int32_t smoothratio)
}
#endif
drawrooms(ud.camerax,ud.cameray,ud.cameraz,ud.cameraang,ud.camerahoriz,ud.camerasect);
#ifdef POLYMER
framelightcount = 0;
#endif
G_DoSpriteAnimations(ud.camerax,ud.cameray,ud.cameraang,smoothratio);
drawmasks();
@ -5541,7 +5538,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
break;
case EXPLOSION2__STATIC:
G_AddGameLight(0, sp->sectnum, sp->x, sp->y, sp->z-((sp->yrepeat*tilesizy[sp->picnum])<<1), 8192, 255+(95<<8),PR_LIGHT_PRIO_MAX_GAME);
G_AddGameLight(0, i, ((sp->yrepeat*tilesizy[sp->picnum])<<1), 8192, 255+(95<<8),PR_LIGHT_PRIO_MAX_GAME);
case EXPLOSION2BOT__STATIC:
case BURNING__STATIC:
case BURNING2__STATIC:

View File

@ -4541,6 +4541,18 @@ void A_Execute(int32_t iActor,int32_t iPlayer,int32_t lDist)
vm.g_t[3] = 0;
}
#ifdef POLYMER
if (getrendermode() == 4 && ActorExtra[vm.g_i].lightptr != NULL && ActorExtra[vm.g_i].lightcount)
{
if (!(--ActorExtra[vm.g_i].lightcount))
{
polymer_deletelight(ActorExtra[vm.g_i].lightId);
ActorExtra[vm.g_i].lightId = -1;
ActorExtra[vm.g_i].lightptr = NULL;
}
}
#endif
while (!X_DoExecute());
if (vm.g_killitFlag == 1)

View File

@ -353,9 +353,17 @@ int32_t A_Shoot(int32_t i,int32_t atwith)
case CHAINGUN__STATIC:
case RPG__STATIC:
case MORTER__STATIC:
G_AddGameLight(0, s->sectnum, s->x+((sintable[(s->ang+512)&2047])>>7),
s->y+((sintable[(s->ang)&2047])>>7), s->z-PHEIGHT, 8192, 255+(95<<8),PR_LIGHT_PRIO_MAX_GAME);
{
int32_t x = ((sintable[(s->ang+512)&2047])>>7), y = ((sintable[(s->ang)&2047])>>7);
s-> x += x;
s-> y += y;
G_AddGameLight(0, i, PHEIGHT, 8192, 255+(95<<8),PR_LIGHT_PRIO_MAX_GAME);
ActorExtra[i].lightcount = 2;
s-> x -= x;
s-> y -= y;
}
/*
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].sector = s->sectnum;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].x = s->x+((sintable[(s->ang+512)&2047])>>4);
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].y = s->y+((sintable[(s->ang)&2047])>>4);
@ -376,6 +384,7 @@ int32_t A_Shoot(int32_t i,int32_t atwith)
if (gamelightcount < PR_MAXLIGHTS)
gamelightcount++;
*/
break;
}
#endif // POLYMER
@ -388,8 +397,16 @@ int32_t A_Shoot(int32_t i,int32_t atwith)
#ifdef POLYMER
if (ProjectileData[atwith].flashcolor)
{
G_AddGameLight(0, s->sectnum, s->x+((sintable[(s->ang+512)&2047])>>7),
s->y+((sintable[(s->ang)&2047])>>7), s->z-PHEIGHT, 8192, ProjectileData[atwith].flashcolor,PR_LIGHT_PRIO_MAX_GAME);
int32_t x = ((sintable[(s->ang+512)&2047])>>7), y = ((sintable[(s->ang)&2047])>>7);
s-> x += x;
s-> y += y;
G_AddGameLight(0, i, PHEIGHT, 8192, ProjectileData[atwith].flashcolor,PR_LIGHT_PRIO_MAX_GAME);
ActorExtra[i].lightcount = 2;
s-> x -= x;
s-> y -= y;
/*
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].sector = s->sectnum;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].x = s->x+((sintable[(s->ang+512)&2047])>>4);
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].y = s->y+((sintable[(s->ang)&2047])>>4);
@ -410,6 +427,7 @@ int32_t A_Shoot(int32_t i,int32_t atwith)
if (gamelightcount < PR_MAXLIGHTS)
gamelightcount++;
*/
}
#endif // POLYMER
@ -2176,6 +2194,7 @@ void P_FireWeapon(DukePlayer_t *p)
{
#ifdef POLYMER
spritetype *s = &sprite[p->i];
int32_t x = ((sintable[(s->ang+512)&2047])>>7), y = ((sintable[(s->ang)&2047])>>7);
#endif // POLYMER
@ -2183,9 +2202,13 @@ void P_FireWeapon(DukePlayer_t *p)
p->visibility = 0;
#ifdef POLYMER
G_AddGameLight(0, s->sectnum, s->x+((sintable[(p->ang+512)&2047])>>7), s->y+((sintable[(p->ang)&2047])>>7),
s->z-PHEIGHT, 8192, aplWeaponFlashColor[p->curr_weapon][snum],PR_LIGHT_PRIO_MAX_GAME);
s->x += x;
s->y += y;
G_AddGameLight(0, p->i, PHEIGHT, 8192, aplWeaponFlashColor[p->curr_weapon][snum],PR_LIGHT_PRIO_MAX_GAME);
ActorExtra[p->i].lightcount = 2;
s->x -= x;
s->y -= y;
/*
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].sector = s->sectnum;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].x = s->x+((sintable[(p->ang+512)&2047])>>4);
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].y = s->y+((sintable[(p->ang)&2047])>>4);
@ -2206,6 +2229,7 @@ void P_FireWeapon(DukePlayer_t *p)
if (gamelightcount < PR_MAXLIGHTS)
gamelightcount++;
*/
#endif // POLYMER
}