Skip to content

Commit

Permalink
renderer: introduce tess.bspSurface, ref DaemonEngine#302
Browse files Browse the repository at this point in the history
Make possible to test if a surface comes for a map model,
even if if not world model or there is no lightmap.
  • Loading branch information
illwieckz committed Apr 11, 2020
1 parent a4a2e7e commit 84a9bfd
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/engine/renderer/tr_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,7 @@ static void RB_RenderDrawSurfaces( shaderSort_t fromSort, shaderSort_t toSort,
shader_t *shader, *oldShader;
int lightmapNum, oldLightmapNum;
int fogNum, oldFogNum;
bool bspSurface;
bool depthRange, oldDepthRange;
int i;
drawSurf_t *drawSurf;
Expand All @@ -854,6 +855,7 @@ static void RB_RenderDrawSurfaces( shaderSort_t fromSort, shaderSort_t toSort,
shader = drawSurf->shader;
lightmapNum = drawSurf->lightmapNum();
fogNum = drawSurf->fogNum();
bspSurface = drawSurf->bspSurface;

if( entity == &tr.worldEntity ) {
if( !( drawSurfFilter & DRAWSURFACES_WORLD ) )
Expand Down Expand Up @@ -888,7 +890,7 @@ static void RB_RenderDrawSurfaces( shaderSort_t fromSort, shaderSort_t toSort,
Tess_End();
}

Tess_Begin( Tess_StageIteratorGeneric, nullptr, shader, nullptr, false, false, lightmapNum, fogNum );
Tess_Begin( Tess_StageIteratorGeneric, nullptr, shader, nullptr, false, false, lightmapNum, fogNum, bspSurface );

oldShader = shader;
oldLightmapNum = lightmapNum;
Expand Down
7 changes: 5 additions & 2 deletions src/engine/renderer/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -1595,6 +1595,7 @@ static inline void halfToFloat( const f16vec4_t in, vec4_t out )
surfaceType_t *surface; // any of surface*_t
shader_t *shader;
uint64_t sort;
bool bspSurface;

inline int index() const {
return int( ( sort & SORT_INDEX_MASK ) );
Expand Down Expand Up @@ -3002,7 +3003,7 @@ static inline void halfToFloat( const f16vec4_t in, vec4_t out )

void R_AddPolygonSurfaces();

void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, int lightmapNum, int fogNum );
void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, int lightmapNum, int fogNum, bool bspSurface = false );

void R_LocalNormalToWorld( const vec3_t local, vec3_t world );
void R_LocalPointToWorld( const vec3_t local, vec3_t world );
Expand Down Expand Up @@ -3295,6 +3296,7 @@ static inline void halfToFloat( const f16vec4_t in, vec4_t out )
bool skipVBO;
int16_t lightmapNum;
int16_t fogNum;
bool bspSurface;

uint32_t numIndexes;
uint32_t numVertexes;
Expand Down Expand Up @@ -3342,7 +3344,8 @@ static inline void halfToFloat( const f16vec4_t in, vec4_t out )
bool skipTangentSpaces,
bool skipVBO,
int lightmapNum,
int fogNum );
int fogNum,
bool bspSurface = false );

// *INDENT-ON*
void Tess_End();
Expand Down
5 changes: 3 additions & 2 deletions src/engine/renderer/tr_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1947,7 +1947,7 @@ int R_SpriteFogNum( trRefEntity_t *ent )
R_AddDrawSurf
=================
*/
void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, int lightmapNum, int fogNum )
void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, int lightmapNum, int fogNum, bool bspSurface )
{
int index;
drawSurf_t *drawSurf;
Expand All @@ -1961,6 +1961,7 @@ void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, int lightmapNum, i
drawSurf->entity = tr.currentEntity;
drawSurf->surface = surface;
drawSurf->shader = shader;
drawSurf->bspSurface = bspSurface;

int entityNum;

Expand All @@ -1983,7 +1984,7 @@ void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, int lightmapNum, i
tr.refdef.numDrawSurfs++;

if ( shader->depthShader != nullptr ) {
R_AddDrawSurf( surface, shader->depthShader, 0, 0 );
R_AddDrawSurf( surface, shader->depthShader, 0, 0, bspSurface );
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/engine/renderer/tr_shade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,8 @@ void Tess_Begin( void ( *stageIteratorFunc )(),
bool skipTangentSpaces,
bool skipVBO,
int lightmapNum,
int fogNum )
int fogNum,
bool bspSurface )
{
shader_t *state;

Expand Down Expand Up @@ -535,7 +536,6 @@ void Tess_Begin( void ( *stageIteratorFunc )(),
Tess_MapVBOs( false );
}


bool isSky = ( state != nullptr && state->isSky != false );

tess.lightShader = lightShader;
Expand Down Expand Up @@ -569,6 +569,7 @@ void Tess_Begin( void ( *stageIteratorFunc )(),
tess.skipVBO = skipVBO;
tess.lightmapNum = lightmapNum;
tess.fogNum = fogNum;
tess.bspSurface = bspSurface;

if ( r_logFile->integer )
{
Expand Down
4 changes: 2 additions & 2 deletions src/engine/renderer/tr_surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void Tess_EndBegin()
{
Tess_End();
Tess_Begin( tess.stageIteratorFunc, tess.stageIteratorFunc2, tess.surfaceShader, tess.lightShader, tess.skipTangentSpaces, tess.skipVBO,
tess.lightmapNum, tess.fogNum );
tess.lightmapNum, tess.fogNum, tess.bspSurface );
}

/*
Expand Down Expand Up @@ -113,7 +113,7 @@ void Tess_CheckOverflow( int verts, int indexes )
}

Tess_Begin( tess.stageIteratorFunc, tess.stageIteratorFunc2, tess.surfaceShader, tess.lightShader, tess.skipTangentSpaces, tess.skipVBO,
tess.lightmapNum, tess.fogNum );
tess.lightmapNum, tess.fogNum, tess.bspSurface );
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/engine/renderer/tr_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ static bool R_AddWorldSurface( bspSurface_t *surf, int fogIndex, int planeBits )
return true;
}

R_AddDrawSurf( surf->data, surf->shader, surf->lightmapNum, fogIndex );
R_AddDrawSurf( surf->data, surf->shader, surf->lightmapNum, fogIndex, true );
return true;
}

Expand Down

0 comments on commit 84a9bfd

Please sign in to comment.