Skip to content

Commit

Permalink
Fix PATHOS lightmap rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
UnrealKaraulov committed Mar 15, 2024
1 parent 90b764b commit 7f41a04
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/bsp/Bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3536,6 +3536,7 @@ bool Bsp::load_lumps(std::string fpath)

lumps[i] = (unsigned char*)tmpnodes;
bsp_header.lump[i].nLength = nodeCount * sizeof(BSPNODE32);
print_log(get_localized_string(LANG_0093) + "[OLD]");
}
else
{
Expand Down Expand Up @@ -3844,7 +3845,7 @@ bool Bsp::load_lumps(std::string fpath)
int lightmap4_bytes = lightmap1_bytes * sizeof(COLOR4);

is_colored_lightmap = lightdata == NULL || abs(lightmap1_bytes - lightDataLength) > abs(lightmap3_bytes - lightDataLength);

bool is_fuck_rgba_lightmap = false;

if (is_colored_lightmap && lightdata != NULL)
Expand Down
5 changes: 5 additions & 0 deletions src/bsp/bsptypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ enum clean_unused_lump
// maximum x/y hull dimension a pushable can have before it starts using hull 2
#define MAX_HULL1_SIZE_PUSHABLE 34.0f


#define LM_AMBIENT_STYLE 61
#define LM_DIFFUSE_STYLE 62
#define LM_LIGHTVECS_STYLE 63

static const char* g_lump_names[HEADER_LUMPS] = {
"ENTITIES",
"PLANES",
Expand Down
23 changes: 22 additions & 1 deletion src/editor/BspRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,17 @@ void BspRenderer::loadLightmaps()
{
if (face.nStyles[s] == 255)
continue;

if (map->is_bsp_pathos)
{
if (face.nStyles[s] == LM_AMBIENT_STYLE ||
face.nStyles[s] == LM_DIFFUSE_STYLE ||
face.nStyles[s] == LM_LIGHTVECS_STYLE)
{
info.atlasId[s] = 0;
continue;
}
}
size_t atlasId = atlases.size() - 1;

// TODO: Try fitting in earlier atlases before using the latest one
Expand Down Expand Up @@ -961,6 +972,16 @@ int BspRenderer::refreshModel(int modelIdx, bool refreshClipnodes, bool noTriang

for (int s = 0; s < MAX_LIGHTMAPS; s++)
{
if (map->is_bsp_pathos)
{
if (face.nStyles[s] == LM_AMBIENT_STYLE ||
face.nStyles[s] == LM_DIFFUSE_STYLE ||
face.nStyles[s] == LM_LIGHTVECS_STYLE)
{
lightmapAtlas[s] = NULL;
continue;
}
}
lightmapAtlas[s] = hasLighting && lmap ? glLightmapTextures[lmap->atlasId[s]] : NULL;
}

Expand Down Expand Up @@ -2322,7 +2343,7 @@ void BspRenderer::render(bool modelVertsDraw, int clipnodeHull)

static double leafUpdTime = 0.0;

if (map->models && fabs(g_app->curTime - leafUpdTime) > 0.25 )
if (map->models && fabs(g_app->curTime - leafUpdTime) > 0.25)
{
leafUpdTime = g_app->curTime;
std::vector<int> nodeBranch;
Expand Down

0 comments on commit 7f41a04

Please sign in to comment.