Minimap Re-draw enhancement
by Guy Allard · in RTS Starter Kit · 10/16/2006 (3:36 am) · 1 replies
I've encountered a situation with the project I'm working on that requires the minimap to be re-drawn occasionally in order to update it with respect to certain game environment changes.
Currently, forcing a re-draw after a game session has started often results in artifacts being created on the mini-map due to the units selection circles being rendered to the mini-map.
Fortunately, it only requires a few engine changes to disable the selection circle rendering during mini-map re-draws.
firstly, we need to add a static member variable to the terrainRender struct that defines whether the selections should be rendered, and create 2 functions to turn the selection rendering on/off.
At the end of the terrainRender struct in engine\terrain\terrrender.h add:
and at the top of engine\terrain\terrrender.cc, add the following line at the end of the variable declarations (before the line that begins: namespace { )
then add the following line to the end of the terrainRender::init() function
Now, in the renderBlock function in terrRender.cc, change:
to
so that the selection indicators will only be drawn if mRenderSelections is true.
Finally, we need to disable the selection rendering before a minimap re-draw, and re-enable the selection rendering after the minimap re-draw.
In engine\game\RTS\GuiMapHudGen.cc, change the function GuiMapHud::renderWorld
from
to
And hopefully, that's it!
Courtesy of the Sixth Extinction RTS demo team
Currently, forcing a re-draw after a game session has started often results in artifacts being created on the mini-map due to the units selection circles being rendered to the mini-map.
Fortunately, it only requires a few engine changes to disable the selection circle rendering during mini-map re-draws.
firstly, we need to add a static member variable to the terrainRender struct that defines whether the selections should be rendered, and create 2 functions to turn the selection rendering on/off.
At the end of the terrainRender struct in engine\terrain\terrrender.h add:
// enable / disable the rendering of the unit selection indicators
// to allow for minimap re-draws without selection circle artifacts
static bool mRenderSelections;
static void enableSelectionRender() { mRenderSelections = true; }
static void disableSelectionRender() {mRenderSelections = false; }and at the top of engine\terrain\terrrender.cc, add the following line at the end of the variable declarations (before the line that begins: namespace { )
bool TerrainRender::mRenderSelections;
then add the following line to the end of the terrainRender::init() function
mRenderSelections = true;
Now, in the renderBlock function in terrRender.cc, change:
//selections...
if (sgCurrSelectionTris) {to
//selections...
if (sgCurrSelectionTris && TerrainRender::mRenderSelections) {so that the selection indicators will only be drawn if mRenderSelections is true.
Finally, we need to disable the selection rendering before a minimap re-draw, and re-enable the selection rendering after the minimap re-draw.
In engine\game\RTS\GuiMapHudGen.cc, change the function GuiMapHud::renderWorld
from
void GuiMapHud::renderWorld(const RectI &updateRect)
{
setupRender();
gClientSceneGraph->renderScene(TerrainObjectType | WaterObjectType);
cleanupRender();
}to
void GuiMapHud::renderWorld(const RectI &updateRect)
{
setupRender();
// turn off selection circle rendering so they don't show on the minimap
TerrainRender::disableSelectionRender();
gClientSceneGraph->renderScene(TerrainObjectType | WaterObjectType);
// re-enable selection circle rendering
TerrainRender::enableSelectionRender();
cleanupRender();
}And hopefully, that's it!
Courtesy of the Sixth Extinction RTS demo team
About the author
Torque Owner Gavin Bunney