@@ -705,6 +705,10 @@ void W3DTreeBuffer::loadTreesInVertexAndIndexBuffers(RefRenderObjListIterator *p
705705 m_shadow = TheW3DProjectedShadowManager->createDecalShadow (&shadowInfo);
706706 }
707707
708+ // TheSuperHackers @bugfix Reset bufferNdx so updateVertexBuffer skips trees absent from this rebuild.
709+ for (Int t = 0 ; t < m_numTrees; t++) {
710+ m_trees[t].bufferNdx = -1 ;
711+ }
708712 m_anythingChanged = false ;
709713 Int curTree=0 ;
710714 Int bNdx;
@@ -741,17 +745,14 @@ void W3DTreeBuffer::loadTreesInVertexAndIndexBuffers(RefRenderObjListIterator *p
741745
742746 for ( ;curTree<m_numTrees;curTree++) {
743747 Int type = m_trees[curTree].treeType ;
744- if (type<0 ) {
745- continue ; // Deleted tree. [6/9/2003]
748+ if (type<0 || m_treeTypes[type]. m_mesh == nullptr ) {
749+ continue ; // Deleted tree or missing mesh . [6/9/2003]
746750 }
747751 if (!m_trees[curTree].visible ) continue ;
748752 Real scale = m_trees[curTree].scale ;
749753 Vector3 loc = m_trees[curTree].location ;
750754 Real theSin = m_trees[curTree].sin ;
751755 Real theCos = m_trees[curTree].cos ;
752- if (type<0 || m_treeTypes[type].m_mesh == nullptr ) {
753- continue ;
754- }
755756
756757 Bool doVertexLighting = true ;
757758
@@ -991,6 +992,9 @@ void W3DTreeBuffer::updateVertexBuffer()
991992 DX8VertexBufferClass::WriteLockClass lockVtxBuffer (m_vertexTree[bNdx], D3DLOCK_DISCARD);
992993 #endif
993994 vb=(VertexFormatXYZNDUV1*)lockVtxBuffer.Get_Vertex_Array ();
995+ if (!vb) {
996+ continue ;
997+ }
994998
995999 VertexFormatXYZNDUV1 *curVb;
9961000
@@ -1000,9 +1004,6 @@ void W3DTreeBuffer::updateVertexBuffer()
10001004 continue ;
10011005 }
10021006 Int type = m_trees[curTree].treeType ;
1003- if (type<0 ) {
1004- continue ; // Deleted tree. [6/9/2003]
1005- }
10061007 if (m_trees[curTree].pushAsideDelta ==0 .0f && m_trees[curTree].m_toppleState == TOPPLE_UPRIGHT) {
10071008 continue ; // not toppling or pushed, no need to update. jba [7/11/2003]
10081009 }
@@ -1012,9 +1013,7 @@ void W3DTreeBuffer::updateVertexBuffer()
10121013 Vector3 loc = m_trees[curTree].location ;
10131014 Real theSin = m_trees[curTree].sin ;
10141015 Real theCos = m_trees[curTree].cos ;
1015- if (type<0 || m_treeTypes[type].m_mesh == nullptr ) {
1016- type = 0 ;
1017- }
1016+ DEBUG_ASSERTCRASH (type>=0 && m_treeTypes[type].m_mesh !=nullptr , (" Invalid tree type or mesh." ));
10181017
10191018 Int startVertex = m_trees[curTree].firstIndex ;
10201019 curVb = vb+startVertex;
0 commit comments