Basic hl2bsp support.

This commit is contained in:
Shpoike 2021-04-25 19:31:08 +01:00
parent 3e81fdef8a
commit 955e9d3fb6
7 changed files with 1417 additions and 21 deletions

View File

@ -643,6 +643,25 @@ static void Surf_BuildDeluxMap (model_t *wmodel, msurface_t *surf, qbyte *dest,
{
switch(wmodel->lightmaps.fmt)
{
#ifdef HL2BSPS
case LM_E8BGR8: //FIXME
deluxmap = ((surf->samples - wmodel->lightdata)/4)*3 + wmodel->deluxdata;
for (maps = 0 ; maps < MAXCPULIGHTMAPS && surf->styles[maps] != INVALID_LIGHTSTYLE ; maps++)
{
scale = d_lightstylevalue[surf->styles[maps]];
for (i=0 ; i<size ; i++)
{
unsigned lm = ((unsigned int*)lightmap)[i];
intensity = max3(((lm>>0)&0xff),((lm>>8)&0xff),((lm>>16)&0xff)) * scale * pow(2, (signed char)(lm>>24));
blocknormals[i][0] += intensity*(deluxmap[i*3+0]-127);
blocknormals[i][1] += intensity*(deluxmap[i*3+1]-127);
blocknormals[i][2] += intensity*(deluxmap[i*3+2]-127);
}
lightmap += size*4; // skip to next lightmap
deluxmap += size*3;
}
break;
#endif
case LM_E5BGR9:
deluxmap = ((surf->samples - wmodel->lightdata)/4)*3 + wmodel->deluxdata;
for (maps = 0 ; maps < MAXCPULIGHTMAPS && surf->styles[maps] != INVALID_LIGHTSTYLE ; maps++)
@ -1484,6 +1503,28 @@ static void Surf_BuildLightMap (model_t *model, msurface_t *surf, int map, int s
Sys_Error("Surf_BuildLightMap: q3bsp");
switch(model->lightmaps.fmt)
{
#ifdef HL2BSPS
case LM_E8BGR8:
for (maps = 0 ; maps < MAXCPULIGHTMAPS && surf->styles[maps] != INVALID_LIGHTSTYLE ; maps++)
{
surf->cached_light[maps] = scale = d_lightstylevalue[surf->styles[maps]]; // 8.8 fraction
surf->cached_colour[maps] = cl_lightstyle[surf->styles[maps]].colourkey;
if (scale)
{
VectorScale(cl_lightstyle[surf->styles[maps]].colours, scale, scalergb);
for (i=0 ; i<size ; i++)
{
unsigned int l = ((unsigned int*)src)[i];
float e = pow(2, (signed char)(l>>24));
blocklights[i*3+0] += scalergb[0] * e * ((l>> 0)&0xff);
blocklights[i*3+1] += scalergb[1] * e * ((l>> 8)&0xff);
blocklights[i*3+2] += scalergb[2] * e * ((l>>16)&0xff);
}
}
src += size*4; // skip to next lightmap
}
break;
#endif
case LM_E5BGR9:
for (maps = 0 ; maps < MAXCPULIGHTMAPS && surf->styles[maps] != INVALID_LIGHTSTYLE ; maps++)
{
@ -1615,6 +1656,23 @@ static void Surf_BuildLightMap (model_t *model, msurface_t *surf, int map, int s
{
switch(model->lightmaps.fmt)
{
#ifdef HL2BSPS
case LM_E8BGR8: //FIXME
for (maps = 0 ; maps < MAXCPULIGHTMAPS && surf->styles[maps] != INVALID_LIGHTSTYLE ; maps++)
{
scale = d_lightstylevalue[surf->styles[maps]];
surf->cached_light[maps] = scale; // 8.8 fraction
surf->cached_colour[maps] = cl_lightstyle[surf->styles[maps]].colourkey;
for (i=0 ; i<size ; i++)
{
unsigned int lm = ((unsigned int *)src)[i];
blocklights[i] += max3(((lm>>0)&0xff),((lm>>8)&0xff),((lm>>16)&0xff)) * scale *
pow(2, (signed char)(lm>>24));
}
src += size*4; // skip to next lightmap
}
break;
#endif
case LM_E5BGR9:
for (maps = 0 ; maps < MAXCPULIGHTMAPS && surf->styles[maps] != INVALID_LIGHTSTYLE ; maps++)
{
@ -1781,6 +1839,28 @@ static void Surf_BuildLightMap_Worker (model_t *wmodel, msurface_t *surf, int sh
}
else switch(wmodel->lightmaps.fmt)
{
#ifdef HL2BSPS
case LM_E8BGR8: //FIXME
for (maps = 0 ; maps < MAXCPULIGHTMAPS && surf->styles[maps] != INVALID_LIGHTSTYLE ; maps++)
{
surf->cached_light[maps] = scale = d_lightstylevalue[surf->styles[maps]]; // 8.8 fraction
surf->cached_colour[maps] = cl_lightstyle[surf->styles[maps]].colourkey;
if (scale)
{
VectorScale(cl_lightstyle[surf->styles[maps]].colours, scale, scalergb);
for (i=0 ; i<size ; i++)
{
unsigned int l = ((unsigned int*)src)[i];
float e = pow(2, (signed char)(l>>24));
blocklights[i*3+0] += scalergb[0] * e * ((l>> 0)&0xff);
blocklights[i*3+1] += scalergb[1] * e * ((l>> 8)&0xff);
blocklights[i*3+2] += scalergb[2] * e * ((l>>16)&0xff);
}
}
src += size*4; // skip to next lightmap
}
break;
#endif
case LM_E5BGR9:
for (maps = 0 ; maps < MAXCPULIGHTMAPS && surf->styles[maps] != INVALID_LIGHTSTYLE ; maps++)
{
@ -1881,6 +1961,23 @@ static void Surf_BuildLightMap_Worker (model_t *wmodel, msurface_t *surf, int sh
{
switch(wmodel->lightmaps.fmt)
{
#ifdef HL2BSPS
case LM_E8BGR8: //FIXME
for (maps = 0 ; maps < MAXCPULIGHTMAPS && surf->styles[maps] != INVALID_LIGHTSTYLE ; maps++)
{
scale = d_lightstylevalue[surf->styles[maps]];
surf->cached_light[maps] = scale; // 8.8 fraction
surf->cached_colour[maps] = cl_lightstyle[surf->styles[maps]].colourkey;
for (i=0 ; i<size ; i++)
{
unsigned int lm = ((unsigned int *)lightmap)[i];
blocklights[i] += max3(((lm>>0)&0x1ff),((lm>>9)&0x1ff),((lm>>18)&0x1ff)) * scale *
pow(2, (signed char)(lm>>24));
}
lightmap += size*4; // skip to next lightmap
}
break;
#endif
case LM_E5BGR9:
for (maps = 0 ; maps < MAXCPULIGHTMAPS && surf->styles[maps] != INVALID_LIGHTSTYLE ; maps++)
{
@ -2441,6 +2538,117 @@ static void Surf_RecursiveQ2WorldNode (mnode_t *node)
}
#endif
#ifdef HL2BSPS
static void Surf_RecursiveHL2WorldNode (mnode_t *node)
{
int c, side;
mplane_t *plane;
msurface_t *surf, **mark;
mleaf_t *pleaf;
double dot;
int sidebit;
if (node->contents == Q2CONTENTS_SOLID)
return; // solid
if (node->visframe != r_visframecount)
return;
if (R_CullBox (node->minmaxs, node->minmaxs+3))
return;
// if a leaf node, draw stuff
if (node->contents != -1)
{
pleaf = (mleaf_t *)node;
// check for door connected areas
if (! (r_refdef.areabits[pleaf->area>>3] & (1<<(pleaf->area&7)) ) )
return; // not visible
c = pleaf->cluster;
if (c >= 0)
frustumvis[c>>3] |= 1<<(c&7);
mark = pleaf->firstmarksurface;
c = pleaf->nummarksurfaces;
if (c)
{
do
{
surf = *mark;
if (surf->flags & SURF_ONNODE)
surf->visframe = r_framecount;
else if (surf->visframe != r_framecount)
{
surf->visframe = r_framecount;
Surf_RenderDynamicLightmaps (surf);
surf->sbatch->mesh[surf->sbatch->meshes++] = surf->mesh;
}
mark++;
} while (--c);
}
return;
}
// node is just a decision point, so go down the apropriate sides
// find which side of the node we are on
plane = node->plane;
switch (plane->type)
{
case PLANE_X:
dot = modelorg[0] - plane->dist;
break;
case PLANE_Y:
dot = modelorg[1] - plane->dist;
break;
case PLANE_Z:
dot = modelorg[2] - plane->dist;
break;
default:
dot = DotProduct (modelorg, plane->normal) - plane->dist;
break;
}
if (dot >= 0)
{
side = 0;
sidebit = 0;
}
else
{
side = 1;
sidebit = SURF_PLANEBACK;
}
// recurse down the children, front side first
Surf_RecursiveHL2WorldNode (node->children[side]);
// draw stuff
for ( c = node->numsurfaces, surf = currentmodel->surfaces + node->firstsurface; c ; c--, surf++)
{
if (surf->visframe != r_framecount)
continue;
if ( (surf->flags & SURF_PLANEBACK) != sidebit )
continue; // wrong side
surf->visframe = 0;//r_framecount+1;//-1;
Surf_RenderDynamicLightmaps (surf);
surf->sbatch->mesh[surf->sbatch->meshes++] = surf->mesh;
}
// recurse down the back side
Surf_RecursiveHL2WorldNode (node->children[!side]);
}
#endif
#ifdef Q3BSPS
#if 0
static void Surf_LeafWorldNode (void)
@ -2726,7 +2934,11 @@ void Surf_SetupFrame(void)
r_viewcluster2 = -1;
}
#if defined(Q2BSPS) || defined(Q3BSPS)
else if (cl.worldmodel->fromgame == fg_quake2 || cl.worldmodel->fromgame == fg_quake3)
else if (cl.worldmodel->fromgame == fg_quake2 || cl.worldmodel->fromgame == fg_quake3
#ifdef HL2BSPS
|| cl.worldmodel->fromgame == fg_halflife2
#endif
)
{
leaf = Mod_PointInLeaf (cl.worldmodel, pvsorg);
r_viewarea = leaf->area;
@ -3513,7 +3725,11 @@ void R_GenWorldEBO(void *ctx, void *data, size_t a, size_t b)
pvs = es->wmodel->funcs.ClusterPVS(es->wmodel, es->cluster[0], &es->pvs, PVM_REPLACE);
#if defined(Q2BSPS) || defined(Q3BSPS)
if (es->wmodel->fromgame == fg_quake2 || es->wmodel->fromgame == fg_quake3)
if (es->wmodel->fromgame == fg_quake2 || es->wmodel->fromgame == fg_quake3
#ifdef HL2BSPS
|| es->wmodel->fromgame == fg_halflife2
#endif
)
Surf_SimpleWorld_Q3BSP(es, pvs);
else
#endif
@ -3784,7 +4000,11 @@ void Surf_DrawWorld (void)
entvis = surfvis = NULL;
}
#if defined(Q2BSPS) || defined(Q3BSPS)
else if (currentmodel->fromgame == fg_quake2 || currentmodel->fromgame == fg_quake3)
else if (currentmodel->fromgame == fg_quake2 || currentmodel->fromgame == fg_quake3
#ifdef HL2BSPS
|| currentmodel->fromgame == fg_halflife2
#endif
)
{
pvsbuffer_t *vis = &surf_frustumvis[r_refdef.recurse];
if (vis->buffersize < currentmodel->pvsbytes)
@ -3808,6 +4028,30 @@ void Surf_DrawWorld (void)
}
else
#endif
#ifdef HL2BSPS
if (currentmodel->fromgame == fg_halflife2)
{
entvis = surfvis = R_MarkLeaves_Q2 ();
VectorCopy (r_refdef.vieworg, modelorg);
if (!surfvis)
{
size_t i;
msurface_t *surf;
for (i = 0; i < currentmodel->nummodelsurfaces; i++)
{
surf = &currentmodel->surfaces[i];
Surf_RenderDynamicLightmaps (surf);
surf->sbatch->mesh[surf->sbatch->meshes++] = surf->mesh;
}
}
else
{
areas[0] = 1;
areas[1] = r_viewarea;
Surf_RecursiveHL2WorldNode (currentmodel->nodes);
}
}
#endif
#ifdef Q2BSPS
if (currentmodel->fromgame == fg_quake2)
{
@ -4055,6 +4299,9 @@ uploadfmt_t Surf_LightmapMode(model_t *model)
{
switch (model->lightmaps.fmt)
{
#ifdef HL2BSPS
case LM_E8BGR8:
#endif
case LM_E5BGR9:
hdr = rgb = true;
break;

View File

@ -2766,7 +2766,7 @@ qbyte *R_MarkLeaves_Q2 (void)
vis = cvis[portal];
if (!portal)
{
if (r_oldviewcluster == r_viewcluster && r_oldviewcluster2 == r_viewcluster2)
if (r_oldviewcluster == r_viewcluster && r_oldviewcluster2 == r_viewcluster2 && vis)
return vis;
r_oldviewcluster = r_viewcluster;

View File

@ -458,7 +458,7 @@ typedef struct
{
int ident;
int version;
lump_t lumps[50];
lump_t lumps[64];
} q2dheader_t;
typedef struct
@ -604,6 +604,42 @@ typedef struct
#define Q3CONTENTS_TRIGGER 0x40000000
#define Q3CONTENTS_NODROP FTECONTENTS_SKY //0x80000000
#ifdef HL2BSPS
//this is more for documentation, hence why the q2 values where the match
#define HL2CONTENTS_SOLID FTECONTENTS_SOLID //0x00000001
#define HL2CONTENTS_WINDOW Q2CONTENTS_WINDOW //0x00000002
#define HL2CONTENTS_AUX Q2CONTENTS_AUX //0x00000004
#define HL2CONTENTS_GRATE /*FTECONTENTS_LAVA*/ 0x00000008 //Surprise...
#define HL2CONTENTS_SLIME FTECONTENTS_SLIME //0x00000010
#define HL2CONTENTS_WATER FTECONTENTS_WATER //0x00000020
#define HL2CONTENTS_MIST Q2CONTENTS_MIST //0x00000040
#define HL2CONTENTS_OPAQUE 0x00000080
#define HL2CONTENTS_TESTFOGVOLUME 0x00000100
//0x00000200
//0x00000400
#define HL2CONTENTS_TEAM1 0x00000800
#define HL2CONTENTS_TEAM2 0x00001000
#define HL2CONTENTS_IGNORE_NODRAW_OPAQUE 0x00002000
#define HL2CONTENTS_MOVEABLE /*FTECONTENTS_LADDER*/ 0x00004000
#define HL2CONTENTS_AREAPORTAL Q2CONTENTS_AREAPORTAL //0x00008000
#define HL2CONTENTS_PLAYERCLIP FTECONTENTS_PLAYERCLIP //0x00010000
#define HL2CONTENTS_MONSTERCLIP FTECONTENTS_MONSTERCLIP //0x00020000
#define HL2CONTENTS_CURRENT_0 Q2CONTENTS_CURRENT_0 //0x00040000
#define HL2CONTENTS_CURRENT_90 Q2CONTENTS_CURRENT_90 //0x00080000
#define HL2CONTENTS_CURRENT_180 Q2CONTENTS_CURRENT_180 //0x00100000
#define HL2CONTENTS_CURRENT_270 Q2CONTENTS_CURRENT_270 //0x00200000
#define HL2CONTENTS_CURRENT_UP Q2CONTENTS_CURRENT_UP //0x00400000
#define HL2CONTENTS_CURRENT_DWN Q2CONTENTS_CURRENT_DOWN //0x00800000
#define HL2CONTENTS_ORIGIN Q2CONTENTS_ORIGIN //0x01000000 // removed before bsping an entity
#define HL2CONTENTS_MONSTER FTECONTENTS_BODY //0x02000000 // should never be on a brush, only in game
#define HL2CONTENTS_DEADMONSTER FTECONTENTS_CORPSE //0x04000000
#define HL2CONTENTS_DETAIL Q2CONTENTS_DETAIL //0x08000000 // brushes to be added after vis leafs
#define HL2CONTENTS_TRANSLUCENT Q2CONTENTS_TRANSLUCENT //0x10000000 // auto set if any surface has trans
#define HL2CONTENTS_LADDER Q2CONTENTS_LADDER //0x20000000
#define HL2CONTENTS_HITBOX 0x40000000
/*FTECONTENTS_SKY*/ //0x80000000
#endif
//qc compat only. not used internally.
#define DPCONTENTS_SOLID 1 // hit a bmodel, not a bounding box
#define DPCONTENTS_WATER 2

File diff suppressed because it is too large Load Diff

View File

@ -683,6 +683,9 @@ void Mod_Init (qboolean initial)
Mod_RegisterModelFormatMagic(NULL, "Raven Map (bsp)", ('R'<<0)+('B'<<8)+('S'<<16)+('P'<<24), Mod_LoadQ2BrushModel);
Mod_RegisterModelFormatMagic(NULL, "QFusion Map (bsp)", ('F'<<0)+('B'<<8)+('S'<<16)+('P'<<24), Mod_LoadQ2BrushModel);
#endif
#ifdef HL2BSPS
Mod_RegisterModelFormatMagic(NULL, "HL2/'Source' Map (bsp)", ('V'<<0)+('B'<<8)+('S'<<16)+('P'<<24), Mod_LoadQ2BrushModel);
#endif
//doom maps
#ifdef MAP_DOOM
@ -774,7 +777,11 @@ mleaf_t *Mod_PointInLeaf (model_t *model, vec3_t p)
if (!model->nodes)
return NULL;
#if defined(Q2BSPS) || defined(Q3BSPS)
if (model->fromgame == fg_quake2 || model->fromgame == fg_quake3)
if (model->fromgame == fg_quake2 || model->fromgame == fg_quake3
#ifdef HL2BSPS
|| model->fromgame == fg_halflife2
#endif
)
{
return model->leafs + CM_PointLeafnum(model, p);
}
@ -2463,6 +2470,20 @@ void ModQ1_Batches_BuildQ1Q2Poly(model_t *mod, msurface_t *surf, builddata_t *co
}
}
#ifdef HL2BSPS
if (mod->fromgame == fg_halflife2)
{
s = DotProduct (vec, surf->texinfo->lmvecs[0]) + surf->texinfo->lmvecs[0][3];
t = DotProduct (vec, surf->texinfo->lmvecs[1]) + surf->texinfo->lmvecs[1][3];
for (sty = 0; sty < 1; sty++)
{
mesh->lmst_array[sty][i][0] = (s - surf->texturemins[0] + surf->light_s[sty] + 0.5) / (mod->lightmaps.width);
mesh->lmst_array[sty][i][1] = (t - surf->texturemins[1] + surf->light_t[sty] + 0.5) / (mod->lightmaps.height);
}
}
#endif
//figure out the texture directions, for bumpmapping and stuff
if (mod->normals && (surf->texinfo->flags & 0x800) && (mod->normals[vertidx][0] || mod->normals[vertidx][1] || mod->normals[vertidx][2]))
{
@ -2820,6 +2841,9 @@ static int Mod_Batches_Generate(model_t *mod)
{
#ifdef Q2BSPS
case fg_quake2:
#ifdef HL2BSPS
case fg_halflife2:
#endif
batch->buildmeshes = Mod_UpdateBatchShader_Q2;
break;
#endif
@ -4074,6 +4098,9 @@ static qboolean Mod_LoadFaces (model_t *loadmodel, bspx_header_t *bspx, qbyte *m
switch(loadmodel->lightmaps.fmt)
{
#ifdef HL2BSPS
case LM_E8BGR8:
#endif
case LM_E5BGR9:
lofsscale = 4;
break;
@ -5022,7 +5049,12 @@ void ModBrush_LoadGLStuff(void *ctx, void *data, size_t a, size_t b)
else
#endif
#ifdef Q2BSPS
if (mod->fromgame == fg_quake2)
if (mod->fromgame == fg_quake2
#ifdef HL2BSPS
|| mod->fromgame == fg_halflife2
#endif
)
{
COM_FileBase (mod->name, loadname, sizeof(loadname));
for(a = 0; a < mod->numtextures; a++)

View File

@ -389,6 +389,9 @@ typedef struct
#define SURF_NOFLAT 0x08000
#define SURF_DRAWALPHA 0x10000
#define SURF_NODRAW 0x20000 //set on non-vertical halflife water submodel surfaces
#ifdef HL2BSPS
#define SURF_ONNODE 0x40000 //o.O
#endif
// !!! if this is changed, it must be changed in asm_draw.h too !!!
typedef struct
@ -403,8 +406,12 @@ typedef struct mtexinfo_s
texture_t *texture;
int flags;
#ifdef HL2BSPS
float lmvecs[2][4];
#endif
//it's a q2 thing.
int numframes;
// int numframes;
struct mtexinfo_s *next;
} mtexinfo_t;
@ -874,7 +881,12 @@ typedef struct {
//
typedef enum {mod_brush, mod_sprite, mod_alias, mod_dummy, mod_halflife, mod_heightmap} modtype_t;
typedef enum {fg_quake, fg_quake2, fg_quake3, fg_halflife, fg_new, fg_doom, fg_doom3} fromgame_t; //useful when we have very similar model types. (eg quake/halflife bsps)
typedef enum {fg_quake, fg_quake2, fg_quake3, fg_halflife,
#ifdef HL2BSPS
fg_halflife2, //these should probably be switched to bits, so that I can easily check multiple (and define to 0 to easily no-op code).
#endif
fg_new, fg_doom, fg_doom3} fromgame_t; //useful when we have very similar model types. (eg quake/halflife bsps)
#define MF_ROCKET (1u<<0) // leave a trail
#define MF_GRENADE (1u<<1) // leave a trail
@ -1068,7 +1080,10 @@ typedef struct model_s
//internally, we still use integers for lighting, with .7 bits of extra precision.
LM_L8,
LM_RGB8,
LM_E5BGR9
LM_E5BGR9,
#ifdef HL2BSPS
LM_E8BGR8, //erk?
#endif
} fmt;
qboolean deluxemapping; //lightmaps are interleaved with deluxemap data (lightmap indicies should only be even values)
qboolean deluxemapping_modelspace; //deluxemaps are in modelspace - we need different glsl.
@ -1183,5 +1198,9 @@ qofs_t CM_ReadPortalState (model_t *mod, qbyte *ptr, qofs_t ptrsize);
#endif //Q2BSPS
#ifdef HL2BSPS
void CModHL2_DrawAreaPortals(model_t *mod);
#endif
void CategorizePlane ( mplane_t *plane );
void CalcSurfaceExtents (model_t *mod, msurface_t *s);

View File

@ -2543,6 +2543,21 @@ static int GLRecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end)
{
switch(cl.worldmodel->lightmaps.fmt)
{
#ifdef HL2BSPS
case LM_E8BGR8:
lightmap += (dt * ((surf->extents[0]>>surf->lmshift)+1) + ds)<<2;
for (maps = 0 ; maps < MAXCPULIGHTMAPS && surf->styles[maps] != INVALID_LIGHTSTYLE ; maps++)
{
unsigned int l = *(unsigned int*)lightmap;
scale = d_lightstylevalue[surf->styles[maps]];
scale *= pow(2, (signed char)(l>>24));
r += max3(((l>> 0)&0xff), ((l>> 8)&0xff), ((l>>16)&0xff)) * scale;
lightmap += ((surf->extents[0]>>surf->lmshift)+1) * ((surf->extents[1]>>surf->lmshift)+1)<<2;
}
break;
#endif
case LM_E5BGR9:
lightmap += (dt * ((surf->extents[0]>>surf->lmshift)+1) + ds)<<2;
for (maps = 0 ; maps < MAXCPULIGHTMAPS && surf->styles[maps] != INVALID_LIGHTSTYLE ; maps++)
@ -2637,7 +2652,11 @@ static float *GLRecursiveLightPoint3C (model_t *mod, mnode_t *node, const vec3_t
float scale, overbright;
int maps;
if (mod->fromgame == fg_quake2)
if (mod->fromgame == fg_quake2
#ifdef HL2BSPS
|| mod->fromgame == fg_halflife2
#endif
)
{
if (node->contents != -1)
return NULL; // solid
@ -2681,8 +2700,18 @@ static float *GLRecursiveLightPoint3C (model_t *mod, mnode_t *node, const vec3_t
tex = surf->texinfo;
s = DotProduct (mid, tex->vecs[0]) + tex->vecs[0][3];
t = DotProduct (mid, tex->vecs[1]) + tex->vecs[1][3];
#ifdef HL2BSPS
if (mod->fromgame == fg_halflife2)
{
s = DotProduct (mid, tex->lmvecs[0]) + tex->lmvecs[0][3];
t = DotProduct (mid, tex->lmvecs[1]) + tex->lmvecs[1][3];
}
else
#endif
{
s = DotProduct (mid, tex->vecs[0]) + tex->vecs[0][3];
t = DotProduct (mid, tex->vecs[1]) + tex->vecs[1][3];
}
if (s < surf->texturemins[0] ||
t < surf->texturemins[1])
@ -2714,6 +2743,34 @@ static float *GLRecursiveLightPoint3C (model_t *mod, mnode_t *node, const vec3_t
{
switch(mod->lightmaps.fmt)
{
#ifdef HL2BSPS
case LM_E8BGR8: //FIXME
deluxmap = ((surf->samples - mod->lightdata)>>2)*3 + mod->deluxdata;
lightmap += (dt * ((surf->extents[0]>>surf->lmshift)+1) + ds)<<2;
deluxmap += (dt * ((surf->extents[0]>>surf->lmshift)+1) + ds)<<4;
for (maps = 0 ; maps < MAXCPULIGHTMAPS && surf->styles[maps] != INVALID_LIGHTSTYLE ; maps++)
{
unsigned int lm = *(unsigned int*)lightmap;
scale = d_lightstylevalue[surf->styles[maps]]*overbright;
//scale *= pow(2, (int)(lm>>27)-15-9+8);
scale *= pow(2, (signed char)(lm>>24));
l[0] += ((lm>> 0)&0xff) * scale * cl_lightstyle[surf->styles[maps]].colours[0];
l[1] += ((lm>> 8)&0xff) * scale * cl_lightstyle[surf->styles[maps]].colours[1];
l[2] += ((lm>>16)&0xff) * scale * cl_lightstyle[surf->styles[maps]].colours[2];
l[3] += (deluxmap[0]-127)*scale;
l[4] += (deluxmap[1]-127)*scale;
l[5] += (deluxmap[2]-127)*scale;
lightmap += ((surf->extents[0]>>surf->lmshift)+1) *
((surf->extents[1]>>surf->lmshift)+1)<<2;
deluxmap += ((surf->extents[0]>>surf->lmshift)+1) *
((surf->extents[1]>>surf->lmshift)+1) * 3;
}
break;
#endif
case LM_E5BGR9:
deluxmap = ((surf->samples - mod->lightdata)>>2)*3 + mod->deluxdata;
@ -2792,6 +2849,25 @@ static float *GLRecursiveLightPoint3C (model_t *mod, mnode_t *node, const vec3_t
{
switch(mod->lightmaps.fmt)
{
#ifdef HL2BSPS
case LM_E8BGR8: //FIXME
lightmap += (dt * ((surf->extents[0]>>surf->lmshift)+1) + ds)<<2;
for (maps = 0 ; maps < MAXCPULIGHTMAPS && surf->styles[maps] != INVALID_LIGHTSTYLE ; maps++)
{
unsigned int lm = *(unsigned int*)lightmap;
scale = d_lightstylevalue[surf->styles[maps]]*overbright;
//scale *= pow(2, (int)(lm>>27)-15-9+8);
scale *= pow(2, (signed char)(lm>>24));
l[0] += ((lm>> 0)&0xff) * scale * cl_lightstyle[surf->styles[maps]].colours[0];
l[1] += ((lm>> 8)&0xff) * scale * cl_lightstyle[surf->styles[maps]].colours[1];
l[2] += ((lm>>16)&0xff) * scale * cl_lightstyle[surf->styles[maps]].colours[2];
lightmap += ((surf->extents[0]>>surf->lmshift)+1) *
((surf->extents[1]>>surf->lmshift)+1)<<2;
}
break;
#endif
case LM_E5BGR9:
lightmap += (dt * ((surf->extents[0]>>surf->lmshift)+1) + ds)<<2;
for (maps = 0 ; maps < MAXCPULIGHTMAPS && surf->styles[maps] != INVALID_LIGHTSTYLE ; maps++)