Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTreeBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,10 @@ void W3DTreeBuffer::loadTreesInVertexAndIndexBuffers(RefRenderObjListIterator *p
m_shadow = TheW3DProjectedShadowManager->createDecalShadow(&shadowInfo);
}

// TheSuperHackers @bugfix Reset bufferNdx so updateVertexBuffer skips trees absent from this rebuild.
for (Int t = 0; t < m_numTrees; t++) {
m_trees[t].bufferNdx = -1;
}
m_anythingChanged = false;
Int curTree=0;
Int bNdx;
Expand Down Expand Up @@ -741,17 +745,14 @@ void W3DTreeBuffer::loadTreesInVertexAndIndexBuffers(RefRenderObjListIterator *p

for ( ;curTree<m_numTrees;curTree++) {
Int type = m_trees[curTree].treeType;
if (type<0) {
continue; // Deleted tree. [6/9/2003]
if (type<0 || m_treeTypes[type].m_mesh == nullptr) {
continue; // Deleted tree or missing mesh. [6/9/2003]
}
if (!m_trees[curTree].visible) continue;
Real scale = m_trees[curTree].scale;
Vector3 loc = m_trees[curTree].location;
Real theSin = m_trees[curTree].sin;
Real theCos = m_trees[curTree].cos;
if (type<0 || m_treeTypes[type].m_mesh == nullptr) {
continue;
}

Bool doVertexLighting = true;

Expand Down Expand Up @@ -991,6 +992,9 @@ void W3DTreeBuffer::updateVertexBuffer()
DX8VertexBufferClass::WriteLockClass lockVtxBuffer(m_vertexTree[bNdx], D3DLOCK_DISCARD);
#endif
vb=(VertexFormatXYZNDUV1*)lockVtxBuffer.Get_Vertex_Array();
if (!vb) {
continue;
}

VertexFormatXYZNDUV1 *curVb;

Expand All @@ -1000,9 +1004,6 @@ void W3DTreeBuffer::updateVertexBuffer()
continue;
}
Int type = m_trees[curTree].treeType;
if (type<0) {
continue; // Deleted tree. [6/9/2003]
}
if (m_trees[curTree].pushAsideDelta==0.0f && m_trees[curTree].m_toppleState == TOPPLE_UPRIGHT) {
continue; // not toppling or pushed, no need to update. jba [7/11/2003]
}
Expand All @@ -1012,9 +1013,7 @@ void W3DTreeBuffer::updateVertexBuffer()
Vector3 loc = m_trees[curTree].location;
Real theSin = m_trees[curTree].sin;
Real theCos = m_trees[curTree].cos;
if (type<0 || m_treeTypes[type].m_mesh == nullptr) {
type = 0;
}
DEBUG_ASSERTCRASH(type>=0 && m_treeTypes[type].m_mesh!=nullptr, ("Invalid tree type or mesh."));

Int startVertex = m_trees[curTree].firstIndex;
curVb = vb+startVertex;
Expand Down
Loading