diff --git a/source/graphics/GameView.cpp b/source/graphics/GameView.cpp index 46d50786b2..e6df84ed51 100644 --- a/source/graphics/GameView.cpp +++ b/source/graphics/GameView.cpp @@ -319,7 +319,36 @@ void CGameView::EnumerateObjects(const CFrustum& frustum, SceneCollector* c) if (!m->Culling || frustum.IsBoxVisible (CVector3D(0,0,0), bounds)) { //c->Submit(patch); - patch->setDrawState(); + + // set the renderstate for this patch + patch->setDrawState(true); + + // set the renderstate for the neighbors + CPatch *nPatch; + + nPatch = pTerrain->GetPatch(i-1,j-1); + if(nPatch) nPatch->setDrawState(true); + + nPatch = pTerrain->GetPatch(i,j-1); + if(nPatch) nPatch->setDrawState(true); + + nPatch = pTerrain->GetPatch(i+1,j-1); + if(nPatch) nPatch->setDrawState(true); + + nPatch = pTerrain->GetPatch(i-1,j); + if(nPatch) nPatch->setDrawState(true); + + nPatch = pTerrain->GetPatch(i+1,j); + if(nPatch) nPatch->setDrawState(true); + + nPatch = pTerrain->GetPatch(i-1,j+1); + if(nPatch) nPatch->setDrawState(true); + + nPatch = pTerrain->GetPatch(i,j+1); + if(nPatch) nPatch->setDrawState(true); + + nPatch = pTerrain->GetPatch(i+1,j+1); + if(nPatch) nPatch->setDrawState(true); } } } @@ -333,7 +362,7 @@ void CGameView::EnumerateObjects(const CFrustum& frustum, SceneCollector* c) if(patch->getDrawState() == true) { c->Submit(patch); - patch->resetDrawState(); + patch->setDrawState(false); } } } diff --git a/source/graphics/Patch.cpp b/source/graphics/Patch.cpp index 84555802cf..9a91e767f3 100644 --- a/source/graphics/Patch.cpp +++ b/source/graphics/Patch.cpp @@ -45,24 +45,6 @@ void CPatch::Initialize(CTerrain* parent,u32 x,u32 z) } InvalidateBounds(); - - // get the neightbors - this->m_Neightbors[CPATCH_NEIGHTBOR_LEFT_TOP] = - this->m_Parent->GetPatch(x-1,z-1); - this->m_Neightbors[CPATCH_NEIGHTBOR_TOP] = - this->m_Parent->GetPatch(x,z-1); - this->m_Neightbors[CPATCH_NEIGHTBOR_RIGHT_TOP] = - this->m_Parent->GetPatch(x+1,z-1); - this->m_Neightbors[CPATCH_NEIGHTBOR_LEFT] = - this->m_Parent->GetPatch(x-1,z); - this->m_Neightbors[CPATCH_NEIGHTBOR_RIGHT] = - this->m_Parent->GetPatch(x+1,z); - this->m_Neightbors[CPATCH_NEIGHTBOR_LEFT_BOTTOM] = - this->m_Parent->GetPatch(x-1,z+1); - this->m_Neightbors[CPATCH_NEIGHTBOR_BOTTOM] = - this->m_Parent->GetPatch(x,z+1); - this->m_Neightbors[CPATCH_NEIGHTBOR_RIGHT_BOTTOM] = - this->m_Parent->GetPatch(x+1,z+1); } /////////////////////////////////////////////////////////////////////////////// @@ -80,4 +62,3 @@ void CPatch::CalcBounds() } } - diff --git a/source/graphics/Patch.h b/source/graphics/Patch.h index 3104eb3fb2..da299b0899 100644 --- a/source/graphics/Patch.h +++ b/source/graphics/Patch.h @@ -21,16 +21,16 @@ class CTerrain; const int PATCH_SIZE = 16; /////////////////////////////////////////////////////////////////////////////// -// CPatchNeightbors: neightbor - IDs for CPatch +// CPatchNeightbors: neighbor - IDs for CPatch -#define CPATCH_NEIGHTBOR_LEFT_TOP 0 -#define CPATCH_NEIGHTBOR_TOP 1 -#define CPATCH_NEIGHTBOR_RIGHT_TOP 2 -#define CPATCH_NEIGHTBOR_LEFT 3 -#define CPATCH_NEIGHTBOR_RIGHT 4 -#define CPATCH_NEIGHTBOR_LEFT_BOTTOM 5 -#define CPATCH_NEIGHTBOR_BOTTOM 6 -#define CPATCH_NEIGHTBOR_RIGHT_BOTTOM 7 +#define CPATCH_NEIGHBOR_LEFT_TOP 0 +#define CPATCH_NEIGHBOR_TOP 1 +#define CPATCH_NEIGHBOR_RIGHT_TOP 2 +#define CPATCH_NEIGHBOR_LEFT 3 +#define CPATCH_NEIGHBOR_RIGHT 4 +#define CPATCH_NEIGHBOR_LEFT_BOTTOM 5 +#define CPATCH_NEIGHBOR_BOTTOM 6 +#define CPATCH_NEIGHBOR_RIGHT_BOTTOM 7 /////////////////////////////////////////////////////////////////////////////// // CPatch: a single terrain patch, PATCH_SIZE tiles square @@ -47,9 +47,6 @@ public: // calculate and store bounds of this patch void CalcBounds(); - // neightbors of this patch - CPatch *m_Neightbors[8]; - // is alread in the DrawList bool m_bWillBeDrawn; @@ -60,18 +57,10 @@ public: u32 m_X,m_Z; // parent terrain CTerrain* m_Parent; + // draw state... - void resetDrawState() { this->m_bWillBeDrawn = false; } - void setDrawState() - { - for(int i=0;i<8;i++) - { - if(m_Neightbors[i]) - m_Neightbors[i]->m_bWillBeDrawn = true; - } - m_bWillBeDrawn = true; - } - bool getDrawState() { return this->m_bWillBeDrawn; } + void setDrawState(bool value) { m_bWillBeDrawn = value; }; + bool getDrawState() { return m_bWillBeDrawn; }; };