summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/FileLoader.cpp1
-rw-r--r--src/core/main.cpp9
-rw-r--r--src/extras/custompipes_d3d9.cpp5
-rw-r--r--src/extras/custompipes_gl.cpp5
-rw-r--r--src/render/Renderer.cpp22
-rw-r--r--src/render/Renderer.h8
-rw-r--r--src/rw/VisibilityPlugins.cpp3
7 files changed, 45 insertions, 8 deletions
diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp
index 22e0159c..20e7bd8e 100644
--- a/src/core/FileLoader.cpp
+++ b/src/core/FileLoader.cpp
@@ -670,6 +670,7 @@ char *DoubleSidedNames[] = {
"sbwy_tunl_cstm3",
"sbwy_tunl_cstm2",
"sbwy_tunl_cstm1",
+ "tenmnt6ad",
""
};
diff --git a/src/core/main.cpp b/src/core/main.cpp
index 7d59307c..58db2d34 100644
--- a/src/core/main.cpp
+++ b/src/core/main.cpp
@@ -1333,11 +1333,13 @@ void
RenderEffects_new(void)
{
PUSH_RENDERGROUP("RenderEffects_new");
+/* // stupid to do this before the whole world is drawn!
CShadows::RenderStaticShadows();
// CRenderer::GenerateEnvironmentMap
CShadows::RenderStoredShadows();
CSkidmarks::Render();
CRubbish::Render();
+*/
// these aren't really effects
DefinedState();
@@ -1360,6 +1362,13 @@ if(gbRenderFadingInEntities)
CRenderer::RenderFadingInEntities();
// actual effects here
+
+ // from above
+ CShadows::RenderStaticShadows();
+ CShadows::RenderStoredShadows();
+ CSkidmarks::Render();
+ CRubbish::Render();
+
CGlass::Render();
// CMattRenderer::ResetRenderStates
DefinedState();
diff --git a/src/extras/custompipes_d3d9.cpp b/src/extras/custompipes_d3d9.cpp
index dad42b33..8b984448 100644
--- a/src/extras/custompipes_d3d9.cpp
+++ b/src/extras/custompipes_d3d9.cpp
@@ -568,6 +568,7 @@ struct BuildingInst
{
rw::RawMatrix combinedMat;
rw::d3d9::InstanceDataHeader *instHeader;
+ uint32 cullMode;
uint8 fadeAlpha;
bool lighting;
};
@@ -612,6 +613,7 @@ AtomicFirstPass(RpAtomic *atomic, int pass)
assert(building->instHeader->platform == PLATFORM_D3D9);
building->fadeAlpha = 255;
building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT);
+ building->cullMode = rw::GetRenderState(rw::CULLMODE);
rw::uint32 flags = atomic->geometry->flags;
bool setupDone = false;
@@ -630,6 +632,7 @@ AtomicFirstPass(RpAtomic *atomic, int pass)
// alright we're rendering this atomic
if(!setupDone){
+ rw::SetRenderState(rw::CULLMODE, building->cullMode);
setStreamSource(0, building->instHeader->vertexStream[0].vertexBuffer, 0, building->instHeader->vertexStream[0].stride);
setIndices(building->instHeader->indexBuffer);
setVertexDeclaration(building->instHeader->vertexDeclaration);
@@ -671,6 +674,7 @@ AtomicFullyTransparent(RpAtomic *atomic, int pass, int fadeAlpha)
assert(building->instHeader->platform == PLATFORM_D3D9);
building->fadeAlpha = fadeAlpha;
building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT);
+ building->cullMode = rw::GetRenderState(rw::CULLMODE);
SetMatrix(building, atomic->getFrame()->getLTM());
numBlendInsts[pass]++;
}
@@ -688,6 +692,7 @@ RenderBlendPass(int pass)
for(i = 0; i < numBlendInsts[pass]; i++){
BuildingInst *building = &blendInsts[pass][i];
+ rw::SetRenderState(rw::CULLMODE, building->cullMode);
setStreamSource(0, building->instHeader->vertexStream[0].vertexBuffer, 0, building->instHeader->vertexStream[0].stride);
setIndices(building->instHeader->indexBuffer);
setVertexDeclaration(building->instHeader->vertexDeclaration);
diff --git a/src/extras/custompipes_gl.cpp b/src/extras/custompipes_gl.cpp
index 040bf686..23a2a931 100644
--- a/src/extras/custompipes_gl.cpp
+++ b/src/extras/custompipes_gl.cpp
@@ -595,6 +595,7 @@ struct BuildingInst
{
rw::Matrix matrix;
rw::gl3::InstanceDataHeader *instHeader;
+ uint32 cullMode;
uint8 fadeAlpha;
bool lighting;
};
@@ -627,6 +628,7 @@ AtomicFirstPass(RpAtomic *atomic, int pass)
assert(building->instHeader->platform == PLATFORM_GL3);
building->fadeAlpha = 255;
building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT);
+ building->cullMode = rw::GetRenderState(rw::CULLMODE);
rw::uint32 flags = atomic->geometry->flags;
WorldLights lights;
@@ -654,6 +656,7 @@ AtomicFirstPass(RpAtomic *atomic, int pass)
// alright we're rendering this atomic
if(!setupDone){
+ rw::SetRenderState(rw::CULLMODE, building->cullMode);
defaultShader->use();
setWorldMatrix(&building->matrix);
setupVertexInput(building->instHeader);
@@ -686,6 +689,7 @@ AtomicFullyTransparent(RpAtomic *atomic, int pass, int fadeAlpha)
assert(building->instHeader->platform == PLATFORM_GL3);
building->fadeAlpha = fadeAlpha;
building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT);
+ building->cullMode = rw::GetRenderState(rw::CULLMODE);
building->matrix = *atomic->getFrame()->getLTM();
numBlendInsts[pass]++;
}
@@ -706,6 +710,7 @@ RenderBlendPass(int pass)
for(i = 0; i < numBlendInsts[pass]; i++){
BuildingInst *building = &blendInsts[pass][i];
+ rw::SetRenderState(rw::CULLMODE, building->cullMode);
setupVertexInput(building->instHeader);
setWorldMatrix(&building->matrix);
if(building->lighting)
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 165ef235..b131e6c3 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -82,14 +82,6 @@ CVehicle *CRenderer::m_pFirstPersonVehicle;
bool CRenderer::m_loadingPriority;
float CRenderer::ms_lodDistScale = 1.2f;
-#ifdef EXTRA_MODEL_FLAGS
-#define BACKFACE_CULLING_ON SetCullMode(rwCULLMODECULLBACK)
-#define BACKFACE_CULLING_OFF SetCullMode(rwCULLMODECULLNONE)
-#else
-#define BACKFACE_CULLING_ON
-#define BACKFACE_CULLING_OFF
-#endif
-
// unused
BlockedRange CRenderer::aBlockedRanges[16];
BlockedRange *CRenderer::pFullBlockedRanges;
@@ -442,6 +434,14 @@ CRenderer::RenderOneBuilding(CEntity *ent, float camdist)
RpAtomic *atomic = (RpAtomic*)ent->m_rwObject;
CSimpleModelInfo *mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(ent->GetModelIndex());
+#ifdef EXTRA_MODEL_FLAGS
+ bool resetCull = false;
+ if(!ent->IsBuilding() || mi->RenderDoubleSided()){
+ resetCull = true;
+ BACKFACE_CULLING_OFF;
+ }
+#endif
+
int pass = PASS_BLEND;
if(mi->m_additive) // very questionable
pass = PASS_ADD;
@@ -471,6 +471,11 @@ CRenderer::RenderOneBuilding(CEntity *ent, float camdist)
}else
WorldRender::AtomicFirstPass(atomic, pass);
+#ifdef EXTRA_MODEL_FLAGS
+ if(resetCull)
+ BACKFACE_CULLING_ON;
+#endif
+
ent->bImBeingRendered = false; // TODO: this seems wrong, but do we even need it?
}
@@ -482,6 +487,7 @@ CRenderer::RenderWorld(int pass)
CLink<CVisibilityPlugins::AlphaObjectInfo> *node;
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE);
+ BACKFACE_CULLING_ON;
DeActivateDirectional();
SetAmbientColours();
diff --git a/src/render/Renderer.h b/src/render/Renderer.h
index 35b43a0b..0322939c 100644
--- a/src/render/Renderer.h
+++ b/src/render/Renderer.h
@@ -10,6 +10,14 @@ class CEntity;
#define FADE_DISTANCE 20.0f
#define STREAM_DISTANCE 30.0f
+#ifdef EXTRA_MODEL_FLAGS
+#define BACKFACE_CULLING_ON SetCullMode(rwCULLMODECULLBACK)
+#define BACKFACE_CULLING_OFF SetCullMode(rwCULLMODECULLNONE)
+#else
+#define BACKFACE_CULLING_ON
+#define BACKFACE_CULLING_OFF
+#endif
+
extern bool gbShowPedRoadGroups;
extern bool gbShowCarRoadGroups;
extern bool gbShowCollisionPolys;
diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp
index 9ea5b11c..7ff5c243 100644
--- a/src/rw/VisibilityPlugins.cpp
+++ b/src/rw/VisibilityPlugins.cpp
@@ -303,6 +303,8 @@ CVisibilityPlugins::RenderFadingEntities(void)
#ifdef EXTRA_MODEL_FLAGS
else if(mi->m_bIsTree)
SetAlphaRef(128);
+ if(!e->IsBuilding() || mi->RenderDoubleSided())
+ BACKFACE_CULLING_OFF;
#endif
if(e->bDistanceFade){
@@ -319,6 +321,7 @@ CVisibilityPlugins::RenderFadingEntities(void)
#ifdef EXTRA_MODEL_FLAGS
if(mi->m_bIsTree)
SetAlphaRef(2);
+ BACKFACE_CULLING_ON;
#endif
#ifdef FIX_BUGS
if(mi->GetModelType() == MITYPE_SIMPLE && mi->m_noZwrite)