cvar_t mod_q3shader_default_polygonfactor = {0, "mod_q3shader_default_polygonfactor", "0", "biases depth values of 'polygonoffset' shaders to prevent z-fighting artifacts"};
cvar_t mod_q3shader_default_polygonoffset = {0, "mod_q3shader_default_polygonoffset", "-2", "biases depth values of 'polygonoffset' shaders to prevent z-fighting artifacts"};
cvar_t mod_q3shader_force_addalpha = {0, "mod_q3shader_force_addalpha", "0", "treat GL_ONE GL_ONE (or add) blendfunc as GL_SRC_ALPHA GL_ONE for compatibility with older DarkPlaces releases"};
+cvar_t mod_q3shader_force_terrain_alphaflag = {0, "mod_q3shader_force_terrain_alphaflag", "0", "for multilayered terrain shaders force TEXF_ALPHA flag on both layers"};
+
cvar_t mod_q1bsp_polygoncollisions = {0, "mod_q1bsp_polygoncollisions", "0", "disables use of precomputed cliphulls and instead collides with polygons (uses Bounding Interval Hierarchy optimizations)"};
cvar_t mod_collision_bih = {0, "mod_collision_bih", "1", "enables use of generated Bounding Interval Hierarchy tree instead of compiled bsp tree in collision code"};
cvar_t mod_recalculatenodeboxes = {0, "mod_recalculatenodeboxes", "1", "enables use of generated node bounding boxes based on BSP tree portal reconstruction, rather than the node boxes supplied by the map compiler"};
Cvar_RegisterVariable(&mod_q3shader_default_polygonfactor);
Cvar_RegisterVariable(&mod_q3shader_default_polygonoffset);
Cvar_RegisterVariable(&mod_q3shader_force_addalpha);
+ Cvar_RegisterVariable(&mod_q3shader_force_terrain_alphaflag);
Cvar_RegisterVariable(&mod_q1bsp_polygoncollisions);
Cvar_RegisterVariable(&mod_collision_bih);
Cvar_RegisterVariable(&mod_recalculatenodeboxes);
Mod_Q1BSP_RecursiveHullCheckPoint(&rhc, rhc.hull->firstclipnode);
}
+static void Mod_Q1BSP_TraceLineAgainstSurfaces(struct model_s *model, const frameblend_t *frameblend, const skeleton_t *skeleton, trace_t *trace, const vec3_t start, const vec3_t end, int hitsupercontentsmask);
+
static void Mod_Q1BSP_TraceLine(struct model_s *model, const frameblend_t *frameblend, const skeleton_t *skeleton, trace_t *trace, const vec3_t start, const vec3_t end, int hitsupercontentsmask)
{
RecursiveHullCheckTraceInfo_t rhc;
return;
}
+ // sometimes we want to traceline against polygons so we can report the texture that was hit rather than merely a contents, but using this method breaks one of negke's maps so it must be a cvar check...
+ if (sv_gameplayfix_q1bsptracelinereportstexture.integer)
+ {
+ Mod_Q1BSP_TraceLineAgainstSurfaces(model, frameblend, skeleton, trace, start, end, hitsupercontentsmask);
+ return;
+ }
+
memset(&rhc, 0, sizeof(rhc));
memset(trace, 0, sizeof(trace_t));
rhc.trace = trace;
// check for impact on this node
if (node->numsurfaces)
{
- int i, dsi, dti, lmwidth, lmheight;
+ unsigned int i;
+ int dsi, dti, lmwidth, lmheight;
float ds, dt;
msurface_t *surface;
unsigned char *lightmap;
static const texture_t *Mod_Q1BSP_TraceLineAgainstSurfacesFindTextureOnNode(RecursiveHullCheckTraceInfo_t *t, const dp_model_t *model, const mnode_t *node, double mid[3])
{
- int i;
+ unsigned int i;
int j;
int k;
const msurface_t *surface;
tx->offsetbias = 0;
tx->specularscalemod = 1;
tx->specularpowermod = 1;
+ tx->transparentsort = TRANSPARENTSORT_DISTANCE;
+ // WHEN ADDING DEFAULTS HERE, REMEMBER TO PUT DEFAULTS IN ALL LOADERS
+ // JUST GREP FOR "specularscalemod = 1".
}
if (!sb->cursize)
{
tx->supercontents = mod_q1bsp_texture_sky.supercontents;
tx->surfaceflags = mod_q1bsp_texture_sky.surfaceflags;
- tx->supercontents |= SUPERCONTENTS_SOLID; // for the surface traceline we need to hit this surface as a solid...
+ // for the surface traceline we need to hit this surface as a solid...
+ tx->supercontents |= SUPERCONTENTS_SOLID;
}
else
{
out->v[0] = (unsigned short)MSG_ReadLittleShort(sb);
out->v[1] = (unsigned short)MSG_ReadLittleShort(sb);
}
- if (out->v[0] >= loadmodel->brushq1.numvertexes || out->v[1] >= loadmodel->brushq1.numvertexes)
+ if ((int)out->v[0] >= loadmodel->brushq1.numvertexes || (int)out->v[1] >= loadmodel->brushq1.numvertexes)
{
Con_Printf("Mod_Q1BSP_LoadEdges: %s has invalid vertex indices in edge %i (vertices %i %i >= numvertices %i)\n", loadmodel->name, i, out->v[0], out->v[1], loadmodel->brushq1.numvertexes);
if(!loadmodel->brushq1.numvertexes)
{
int i, j, count, p, child[2];
mnode_t *out;
- size_t structsize = loadmodel->brush.isbsp2 ? 44 : 24;
+ size_t structsize = loadmodel->brush.isbsp2rmqe ? 32 : (loadmodel->brush.isbsp2 ? 44 : 24);
if (sb->cursize % structsize)
Host_Error("Mod_Q1BSP_LoadNodes: funny lump size in %s",loadmodel->name);
p = MSG_ReadLittleLong(sb);
out->plane = loadmodel->brush.data_planes + p;
- if (loadmodel->brush.isbsp2)
+ if (loadmodel->brush.isbsp2rmqe)
+ {
+ child[0] = MSG_ReadLittleLong(sb);
+ child[1] = MSG_ReadLittleLong(sb);
+ out->mins[0] = MSG_ReadLittleShort(sb);
+ out->mins[1] = MSG_ReadLittleShort(sb);
+ out->mins[2] = MSG_ReadLittleShort(sb);
+ out->maxs[0] = MSG_ReadLittleShort(sb);
+ out->maxs[1] = MSG_ReadLittleShort(sb);
+ out->maxs[2] = MSG_ReadLittleShort(sb);
+ out->firstsurface = MSG_ReadLittleLong(sb);
+ out->numsurfaces = MSG_ReadLittleLong(sb);
+ }
+ else if (loadmodel->brush.isbsp2)
{
child[0] = MSG_ReadLittleLong(sb);
child[1] = MSG_ReadLittleLong(sb);
{
mleaf_t *out;
int i, j, count, p, firstmarksurface, nummarksurfaces;
- size_t structsize = loadmodel->brush.isbsp2 ? 44 : 28;
+ size_t structsize = loadmodel->brush.isbsp2rmqe ? 32 : (loadmodel->brush.isbsp2 ? 44 : 28);
if (sb->cursize % structsize)
Host_Error("Mod_Q1BSP_LoadLeafs: funny lump size in %s",loadmodel->name);
Mod_Q1BSP_DecompressVis(loadmodel->brushq1.data_compressedpvs + p, loadmodel->brushq1.data_compressedpvs + loadmodel->brushq1.num_compressedpvs, loadmodel->brush.data_pvsclusters + out->clusterindex * loadmodel->brush.num_pvsclusterbytes, loadmodel->brush.data_pvsclusters + (out->clusterindex + 1) * loadmodel->brush.num_pvsclusterbytes);
}
- if (loadmodel->brush.isbsp2)
+ if (loadmodel->brush.isbsp2rmqe)
+ {
+ out->mins[0] = MSG_ReadLittleShort(sb);
+ out->mins[1] = MSG_ReadLittleShort(sb);
+ out->mins[2] = MSG_ReadLittleShort(sb);
+ out->maxs[0] = MSG_ReadLittleShort(sb);
+ out->maxs[1] = MSG_ReadLittleShort(sb);
+ out->maxs[2] = MSG_ReadLittleShort(sb);
+
+ firstmarksurface = MSG_ReadLittleLong(sb);
+ nummarksurfaces = MSG_ReadLittleLong(sb);
+ }
+ else if (loadmodel->brush.isbsp2)
{
out->mins[0] = MSG_ReadLittleFloat(sb);
out->mins[1] = MSG_ReadLittleFloat(sb);
// TODO: calculate node bounding boxes during recursion and calculate a maximum plane size accordingly to improve precision (as most maps do not need 1 billion unit plane polygons)
PolygonD_QuadForPlane(nodeportal->points, nodeportal->plane.normal[0], nodeportal->plane.normal[1], nodeportal->plane.normal[2], nodeportal->plane.dist, 1024.0*1024.0*1024.0);
nodeportal->numpoints = 4;
- side = 0; // shut up compiler warning
+ // side = 0; // shut up compiler warning -> should be no longer needed, Host_Error is declared noreturn now
for (portal = (portal_t *)node->portals;portal;portal = portal->next[side])
{
clipplane = portal->plane;
side = 1;
}
else
+ {
Host_Error("Mod_Q1BSP_RecursiveNodePortals: mislinked portal");
+ side = 0; // hush warning
+ }
for (i = 0;i < nodeportal->numpoints*3;i++)
frontpoints[i] = nodeportal->points[i];
else if (portal->nodes[1] == node)
side = 1;
else
+ {
Host_Error("Mod_Q1BSP_RecursiveNodePortals: mislinked portal");
+ side = 0; // hush warning
+ }
nextportal = portal->next[side];
if (!portal->numpoints)
continue;
unsigned char *datapointer;
sizebuf_t sb;
- MSG_InitReadBuffer(&sb, buffer, bufferend - buffer);
+ MSG_InitReadBuffer(&sb, (unsigned char *)buffer, (unsigned char *)bufferend - (unsigned char *)buffer);
mod->type = mod_brushq1;
mod->brush.ishlbsp = true;
mod->modeldatatypestring = "HLBSP";
break;
+ case ('2' + 'P' * 256 + 'S' * 65536 + 'B' * 16777216):
+ mod->brush.isbsp2 = true;
+ mod->brush.isbsp2rmqe = true; // like bsp2 except leaf/node bounds are 16bit (unexpanded)
+ mod->modeldatatypestring = "Q1BSP2rmqe";
+ break;
case ('B' + 'S' * 256 + 'P' * 65536 + '2' * 16777216):
mod->brush.isbsp2 = true;
mod->modeldatatypestring = "Q1BSP2";
break;
default:
mod->modeldatatypestring = "Unknown BSP";
- Host_Error("Mod_Q1BSP_Load: %s has wrong version number %i: supported versions are 29 (Quake), 30 (Half-Life), \"BSP2\"", mod->name, i);
+ Host_Error("Mod_Q1BSP_Load: %s has wrong version number %i: supported versions are 29 (Quake), 30 (Half-Life), \"BSP2\" or \"2PSB\" (rmqe)", mod->name, i);
return;
}
mod->soundfromcenter = true;
mod->TraceBox = Mod_Q1BSP_TraceBox;
- if (sv_gameplayfix_q1bsptracelinereportstexture.integer)
- mod->TraceLine = Mod_Q1BSP_TraceLineAgainstSurfaces; // LordHavoc: use the surface-hitting version of TraceLine in all cases
- else
- mod->TraceLine = Mod_Q1BSP_TraceLine;
+ mod->TraceLine = Mod_Q1BSP_TraceLine;
mod->TracePoint = Mod_Q1BSP_TracePoint;
mod->PointSuperContents = Mod_Q1BSP_PointSuperContents;
mod->TraceLineAgainstSurfaces = Mod_Q1BSP_TraceLineAgainstSurfaces;