Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(w3ddevice): draw every selected building's rally line over the building

Olcay Seyganb4ee6b2697cf
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DWaypointBuffer.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DWaypointBuffer.h
index c34c3412d..6866dd1f5 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DWaypointBuffer.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DWaypointBuffer.h
@@ -65,6 +65,7 @@
#include "vertmaterial.h"
#include "Lib/BaseType.h"
#include "common/GameType.h"
+#include <vector>
class SegmentedLineClass;
@@ -82,10 +83,14 @@ public:
private:
void setDefaultLineStyle();
+ void queueLine( Int numPoints, Vector3 *points ); ///< hand the points to a pooled line object (not rendered yet)
+ void renderQueuedLines( RenderInfoClass &rinfo ); ///< render every queued line; all stay deferred on the static sort list together
RenderObjClass *m_waypointNodeRobj;
SegmentedLineClass *m_line;
TextureClass *m_texture;
+ std::vector<SegmentedLineClass *> m_linePool; ///< one line object per line drawn this frame, grown on demand
+ Int m_linesUsed;
};
#endif // end __W3D_WAYPOINT_BUFFER_H
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3dWaypointBuffer.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3dWaypointBuffer.cpp
index aeda5dc65..cb6dd3abf 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3dWaypointBuffer.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3dWaypointBuffer.cpp
@@ -105,6 +105,7 @@ W3DWaypointBuffer::W3DWaypointBuffer(void)
m_line = new SegmentedLineClass;
m_texture = WW3DAssetManager::Get_Instance()->Get_Texture( "EXLaser.tga" );
+ m_linesUsed = 0;
setDefaultLineStyle();
@@ -120,6 +121,30 @@ W3DWaypointBuffer::~W3DWaypointBuffer(void)
REF_PTR_RELEASE( m_waypointNodeRobj );
REF_PTR_RELEASE( m_texture );
REF_PTR_RELEASE( m_line );
+ for( size_t i = 0; i < m_linePool.size(); ++i )
+ REF_PTR_RELEASE( m_linePool[ i ] );
+}
+
+//=============================================================================
+// A SegmentedLineClass renders through the static sort list (deferred to the end of the
+// scene, drawn over the buildings with PASS_ALWAYS), but every WW3D::Render() of a puck
+// flushes that list. Rendering one shared line per selected object therefore drew all but
+// the last line during the terrain pass, where the building meshes then covered the piece
+// coming out of the door. So each line gets its own object and they are rendered together
+// after the last puck, so they all stay deferred.
+//=============================================================================
+void W3DWaypointBuffer::queueLine( Int numPoints, Vector3 *points )
+{
+ if( m_linesUsed >= (Int)m_linePool.size() )
+ m_linePool.push_back( new SegmentedLineClass( *m_line ) ); // copies texture, shader, width, color
+ m_linePool[ m_linesUsed++ ]->Set_Points( numPoints, points );
+}
+
+void W3DWaypointBuffer::renderQueuedLines( RenderInfoClass &rinfo )
+{
+ for( Int i = 0; i < m_linesUsed; ++i )
+ m_linePool[ i ]->Render( rinfo );
+ m_linesUsed = 0;
}
//=============================================================================
@@ -209,11 +234,11 @@ void W3DWaypointBuffer::drawWaypoints(RenderInfoClass &rinfo)
}
}
//Now render the lines in one pass!
- m_line->Set_Points( numPoints, points );
- m_line->Render( localRinfo );
+ queueLine( numPoints, points );
}
}
}
+ renderQueuedLines( localRinfo );
}
else // maybe we want to draw rally points, then?
{
@@ -525,13 +550,13 @@ void W3DWaypointBuffer::drawWaypoints(RenderInfoClass &rinfo)
WW3D::Render(*m_waypointNodeRobj,localRinfo); //The little hockey puck
- m_line->Set_Points( numPoints, points );
- m_line->Render( localRinfo );
+ queueLine( numPoints, points );
}// end if exit interface
}
}
+ renderQueuedLines( localRinfo );
}
}