Index: binaries/data/config/default.cfg =================================================================== --- binaries/data/config/default.cfg +++ binaries/data/config/default.cfg @@ -75,6 +75,9 @@ silhouettes = true showsky = true +[renderer] +aurarange = true + nos3tc = false noautomipmap = true novbo = false @@ -161,6 +164,7 @@ session.showstatusbars = Tab ; Toggle display of status bars session.highlightguarding = PgDn ; Toggle highlight of guarding units session.highlightguarded = PgUp ; Toggle highlight of guarded units +session.toggleauraoverlays = "Alt+V" ; Toggle rendering of aura range overlays ; > HOTKEYS ONLY chat = Return ; Toggle chat window Index: binaries/data/mods/public/gui/manual/intro.txt =================================================================== --- binaries/data/mods/public/gui/manual/intro.txt +++ binaries/data/mods/public/gui/manual/intro.txt @@ -106,6 +106,7 @@ Alt + W: Toggle wireframe mode (press once to get wireframes overlaid over the textured models, twice to get just the wireframes colored by the textures, thrice to get back to normal textured mode) Alt + S: Toggle unit silhouettes (might give a small performance boost) Alt + Z: Toggle sky +Alt + V: Toggle aura range visualizations [font="sans-bold-14"]Camera manipulation [font="sans-14"]W or \[up]: Pan screen up Index: binaries/data/mods/public/gui/options/options.json =================================================================== --- binaries/data/mods/public/gui/options/options.json +++ binaries/data/mods/public/gui/options/options.json @@ -209,6 +209,12 @@ "label": "Limit FPS in Menus", "tooltip": "Limit FPS to 50 in all menus, to save power.", "parameters": { "config": "gui.menu.limitfps" } + }, + { + "type": "boolean", + "label": "Aura Range Visualization", + "tooltip": "Display the range of auras (can also be toggled in-game with the hotkey).", + "parameters": { "config": "renderer.aurarange" } } ], "soundSetting": Index: binaries/data/mods/public/gui/session/hotkeys/misc.xml =================================================================== --- binaries/data/mods/public/gui/session/hotkeys/misc.xml +++ binaries/data/mods/public/gui/session/hotkeys/misc.xml @@ -96,4 +96,8 @@ clearSelection(); + + toggleRangeOverlay("Aura"); + + Index: binaries/data/mods/public/gui/session/input.js =================================================================== --- binaries/data/mods/public/gui/session/input.js +++ binaries/data/mods/public/gui/session/input.js @@ -1841,3 +1841,16 @@ preSelectedAction = ACTION_NONE; } +function toggleRangeOverlay(type) +{ + let configString = "renderer." + type.toLowerCase() + "range"; + let enabled = String(Engine.ConfigDB_GetValue("user", configString) != "true"); + + Engine.GuiInterfaceCall("EnableVisualRangeOverlayType", { + "type": type, "enabled": enabled == "true" + }); + + recalculateRangeOverlays(enabled == "true"); + Engine.ConfigDB_CreateValue("user", configString, enabled); + Engine.ConfigDB_WriteValueToFile("user", configString, enabled, "config/user.cfg"); +} Index: binaries/data/mods/public/gui/session/session.js =================================================================== --- binaries/data/mods/public/gui/session/session.js +++ binaries/data/mods/public/gui/session/session.js @@ -323,6 +323,10 @@ onSimulationUpdate(); setTimeout(displayGamestateNotifications, 1000); + Engine.GuiInterfaceCall("SetVisualRangeOverlayTypes", { + "Aura": Engine.ConfigDB_GetValue("user", "renderer.aurarange") == "true" + }); + // Report the performance after 5 seconds (when we're still near // the initial camera view) and a minute (when the profiler will // have settled down if framerates as very low), to give some @@ -1232,6 +1236,21 @@ }); } +/** + * Toggles the display of range overlays for selected entities. + */ +function recalculateRangeOverlays(remove = false) +{ + let selected = g_Selection.toList(); + for (let ent in g_Selection.highlighted) + selected.push(g_Selection.highlighted[ent]); + + Engine.GuiInterfaceCall("SetRangeOverlays", { + "entities": selected, + "enabled": remove + }); +} + // Update the additional list of entities to be highlighted. function updateAdditionalHighlight() { Index: binaries/data/mods/public/simulation/components/Auras.js =================================================================== --- binaries/data/mods/public/simulation/components/Auras.js +++ binaries/data/mods/public/simulation/components/Auras.js @@ -63,6 +63,29 @@ return undefined; }; +/** + * Return the names of any range auras - used to render their ranges. + */ +Auras.prototype.GetVisualAuraRangeNames = function() +{ + return this.GetAuraNames().filter(auraName => this.IsRangeAura(auraName)); +}; + +Auras.prototype.GetLineTexture = function(name) +{ + return this.auras[name].rangeOverlay ? this.auras[name].rangeOverlay.lineTexture : "outline_border.png"; +}; + +Auras.prototype.GetLineTextureMask = function(name) +{ + return this.auras[name].rangeOverlay ? this.auras[name].rangeOverlay.lineTextureMask : "outline_border_mask.png"; +}; + +Auras.prototype.GetLineThickness = function(name) +{ + return this.auras[name].rangeOverlay ? this.auras[name].rangeOverlay.lineThickness : 0.2; +}; + Auras.prototype.GetClasses = function(name) { return this.auras[name].affects; Index: binaries/data/mods/public/simulation/components/GuiInterface.js =================================================================== --- binaries/data/mods/public/simulation/components/GuiInterface.js +++ binaries/data/mods/public/simulation/components/GuiInterface.js @@ -33,6 +33,7 @@ this.timeNotifications = []; this.entsRallyPointsDisplayed = []; this.entsWithAuraAndStatusBars = new Set(); + this.enabledVisualRangeOverlayTypes = {}; }; /* @@ -894,9 +895,25 @@ } cmpSelectable.SetSelectionHighlight({ "r": color.r, "g": color.g, "b": color.b, "a": cmd.alpha }, cmd.selected); + + let cmpRangeVisualization = Engine.QueryInterface(ent, IID_RangeVisualization); + if (!cmpRangeVisualization) + continue; + + cmpRangeVisualization.SetEnabled(cmd.selected, this.enabledVisualRangeOverlayTypes); } }; +GuiInterface.prototype.SetVisualRangeOverlayTypes = function(player, overlayTypes) +{ + this.enabledVisualRangeOverlayTypes = overlayTypes; +}; + +GuiInterface.prototype.EnableVisualRangeOverlayType = function(player, data) +{ + this.enabledVisualRangeOverlayTypes[data.type] = data.enabled; +}; + GuiInterface.prototype.GetEntitiesWithStatusBars = function() { return [...this.entsWithAuraAndStatusBars]; @@ -937,6 +954,17 @@ } }; +GuiInterface.prototype.SetRangeOverlays = function(player, cmd) +{ + for (let ent of cmd.entities) + { + let cmpRangeVisualization = Engine.QueryInterface(ent, IID_RangeVisualization); + if (!cmpRangeVisualization) + continue; + cmpRangeVisualization.SetEnabled(cmd.enabled, this.enabledVisualRangeOverlayTypes); + } +}; + GuiInterface.prototype.GetPlayerEntities = function(player) { return Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager).GetEntitiesByPlayer(player); @@ -2016,6 +2044,9 @@ "SetObstructionDebugOverlay": 1, "SetMotionDebugOverlay": 1, "SetRangeDebugOverlay": 1, + "EnableVisualRangeOverlayType": 1, + "SetVisualRangeOverlayTypes": 1, + "SetRangeOverlays": 1, "GetTraderNumber": 1, "GetTradingGoods": 1, Index: binaries/data/mods/public/simulation/components/RangeVisualization.js =================================================================== --- binaries/data/mods/public/simulation/components/RangeVisualization.js +++ binaries/data/mods/public/simulation/components/RangeVisualization.js @@ -0,0 +1,76 @@ +function RangeVisualization() {} + +RangeVisualization.prototype.Schema = ""; + +RangeVisualization.prototype.Init = function() +{ + this.enabled = false; + // Keep track of the enabled aura types for this entity + this.enabledRangeTypes = { + "Aura": false + }; + + this.rangeVisualizations = new Map(); + for (let type in this.enabledRangeTypes) + this["GetVisual" + type + "Ranges"](type); +}; + +// The GUI enables visualizations +RangeVisualization.prototype.Serialize = null; + +RangeVisualization.prototype.Deserialize = function(data) +{ + this.Init(); +}; + +RangeVisualization.prototype.GetVisualAuraRanges = function(type) +{ + let cmpAuras = Engine.QueryInterface(this.entity, IID_Auras); + if (!cmpAuras) + return; + + this.rangeVisualizations.set(type, []); + + for (let auraName of cmpAuras.GetVisualAuraRangeNames()) + this.rangeVisualizations.get(type).push({ + "radius": cmpAuras.GetRange(auraName), + "texture": cmpAuras.GetLineTexture(auraName), + "textureMask": cmpAuras.GetLineTextureMask(auraName), + "thickness": cmpAuras.GetLineThickness(auraName), + }); +}; + +RangeVisualization.prototype.SetEnabled = function(enabled, enabledRangeTypes) +{ + this.enabled = enabled; + this.enabledRangeTypes = enabledRangeTypes; + + this.RegenerateRangeVisualizations(); +}; + +RangeVisualization.prototype.RegenerateRangeVisualizations = function() +{ + let cmpSelectable = Engine.QueryInterface(this.entity, IID_Selectable); + if (!cmpSelectable) + return; + + cmpSelectable.ResetRangeOverlays(); + + if (!this.enabled) + return; + + // Only render individual range types that have been enabled + for (let rangeOverlayType of this.rangeVisualizations.keys()) + if (this.enabledRangeTypes[rangeOverlayType]) + for (let rangeOverlay of this.rangeVisualizations.get(rangeOverlayType)) + cmpSelectable.SetRangeOverlay(rangeOverlay.radius, rangeOverlay.texture, + rangeOverlay.textureMask, rangeOverlay.thickness); +}; + +RangeVisualization.prototype.OnOwnershipChanged = function(msg) +{ + if (this.enabled && msg.to != -1) + this.RegenerateRangeVisualizations(); +}; + +Engine.RegisterComponentType(IID_RangeVisualization, "RangeVisualization", RangeVisualization); Index: binaries/data/mods/public/simulation/components/interfaces/RangeVisualization.js =================================================================== --- binaries/data/mods/public/simulation/components/interfaces/RangeVisualization.js +++ binaries/data/mods/public/simulation/components/interfaces/RangeVisualization.js @@ -0,0 +1 @@ +Engine.RegisterInterface("RangeVisualization"); Index: binaries/data/mods/public/simulation/templates/template_structure.xml =================================================================== --- binaries/data/mods/public/simulation/templates/template_structure.xml +++ binaries/data/mods/public/simulation/templates/template_structure.xml @@ -101,6 +101,7 @@ round default + 2.0 Index: binaries/data/mods/public/simulation/templates/template_unit.xml =================================================================== --- binaries/data/mods/public/simulation/templates/template_unit.xml +++ binaries/data/mods/public/simulation/templates/template_unit.xml @@ -65,6 +65,7 @@ false + 2.0 1.0 Index: source/simulation2/components/CCmpSelectable.cpp =================================================================== --- source/simulation2/components/CCmpSelectable.cpp +++ source/simulation2/components/CCmpSelectable.cpp @@ -66,7 +66,7 @@ : m_DebugBoundingBoxOverlay(NULL), m_DebugSelectionBoxOverlay(NULL), m_BuildingOverlay(NULL), m_UnitOverlay(NULL), m_FadeBaselineAlpha(0.f), m_FadeDeltaAlpha(0.f), m_FadeProgress(0.f), - m_Selected(false), m_Cached(false), m_Visible(false) + m_Selected(false), m_Cached(false), m_Visible(false), m_RangeOverlayData() { m_Color = CColor(0, 0, 0, m_FadeBaselineAlpha); } @@ -77,6 +77,8 @@ delete m_DebugSelectionBoxOverlay; delete m_BuildingOverlay; delete m_UnitOverlay; + for (RangeOverlayData& rangeOverlay : m_RangeOverlayData) + delete rangeOverlay.second; } static std::string GetSchema() @@ -126,23 +128,21 @@ const CParamNode& textureNode = paramNode.GetChild("Overlay").GetChild("Texture"); const CParamNode& outlineNode = paramNode.GetChild("Overlay").GetChild("Outline"); - const char* textureBasePath = "art/textures/selection/"; - // Save some memory by using interned file paths in these descriptors (almost all actors and // entities have this component, and many use the same textures). if (textureNode.IsOk()) { // textured quad mode (dynamic, for units) m_OverlayDescriptor.m_Type = ICmpSelectable::DYNAMIC_QUAD; - m_OverlayDescriptor.m_QuadTexture = CStrIntern(textureBasePath + textureNode.GetChild("MainTexture").ToUTF8()); - m_OverlayDescriptor.m_QuadTextureMask = CStrIntern(textureBasePath + textureNode.GetChild("MainTextureMask").ToUTF8()); + m_OverlayDescriptor.m_QuadTexture = CStrIntern(TEXTUREBASEPATH + textureNode.GetChild("MainTexture").ToUTF8()); + m_OverlayDescriptor.m_QuadTextureMask = CStrIntern(TEXTUREBASEPATH + textureNode.GetChild("MainTextureMask").ToUTF8()); } else if (outlineNode.IsOk()) { // textured outline mode (static, for buildings) m_OverlayDescriptor.m_Type = ICmpSelectable::STATIC_OUTLINE; - m_OverlayDescriptor.m_LineTexture = CStrIntern(textureBasePath + outlineNode.GetChild("LineTexture").ToUTF8()); - m_OverlayDescriptor.m_LineTextureMask = CStrIntern(textureBasePath + outlineNode.GetChild("LineTextureMask").ToUTF8()); + m_OverlayDescriptor.m_LineTexture = CStrIntern(TEXTUREBASEPATH + outlineNode.GetChild("LineTexture").ToUTF8()); + m_OverlayDescriptor.m_LineTextureMask = CStrIntern(TEXTUREBASEPATH + outlineNode.GetChild("LineTextureMask").ToUTF8()); m_OverlayDescriptor.m_LineThickness = outlineNode.GetChild("LineThickness").ToFloat(); } @@ -193,6 +193,22 @@ SetSelectionHighlightAlpha(color.a); } + virtual void SetRangeOverlay(float radius, const std::string& texture, const std::string& textureMask, float thickness) + { + if (!CRenderer::IsInitialised()) + return; + + SOverlayDescriptor rangeOverlayDescriptor; + SOverlayTexturedLine* rangeOverlay = nullptr; + + rangeOverlayDescriptor.m_Radius = radius; + rangeOverlayDescriptor.m_LineTexture = CStrIntern(TEXTUREBASEPATH + texture); + rangeOverlayDescriptor.m_LineTextureMask = CStrIntern(TEXTUREBASEPATH + textureMask); + rangeOverlayDescriptor.m_LineThickness = thickness; + + m_RangeOverlayData.emplace_back(std::make_pair(rangeOverlayDescriptor, rangeOverlay)); + } + virtual void SetSelectionHighlightAlpha(float alpha) { alpha = std::max(m_AlphaMin, alpha); @@ -219,11 +235,9 @@ void RenderSubmit(SceneCollector& collector); /** - * Called from RenderSubmit if using a static outline; responsible for ensuring that the static overlay - * is up-to-date before it is rendered. Has no effect unless the static overlay is explicitly marked as - * invalid first (see InvalidateStaticOverlay). - */ - void UpdateStaticOverlay(); + * Draw a textured overlay. The selection overlays for structures are based solely on footprint shape. + */ + void UpdateTexturedOverlay(const SOverlayDescriptor* overlayDescriptor, SOverlayTexturedLine& overlay, float frameOffset, bool buildingOverlay); /** * Called from the interpolation handler; responsible for ensuring the dynamic overlay (provided we're @@ -244,11 +258,20 @@ */ void UpdateMessageSubscriptions(); + /** + * Delete range overlays. + */ + void ResetRangeOverlays(); + private: SOverlayDescriptor m_OverlayDescriptor; SOverlayTexturedLine* m_BuildingOverlay; SOverlayQuad* m_UnitOverlay; + // Holds the data for any range overlays + typedef std::pair RangeOverlayData; + std::vector m_RangeOverlayData; + SOverlayLine* m_DebugBoundingBoxOverlay; SOverlayLine* m_DebugSelectionBoxOverlay; @@ -279,9 +302,11 @@ /// Total duration of a single fade, in seconds. Assumed constant for now; feel free to change this into /// a member variable if you need to adjust it per component. static const double FADE_DURATION; + static const char* TEXTUREBASEPATH; }; const double CCmpSelectable::FADE_DURATION = 0.3; +const char* CCmpSelectable::TEXTUREBASEPATH = "art/textures/selection/"; void CCmpSelectable::HandleMessage(const CMessage& msg, bool UNUSED(global)) { @@ -314,8 +339,18 @@ // update dynamic overlay only when visible if (m_Color.a > 0) + { UpdateDynamicOverlay(msgData.offset); + // Update any range overlays + for (RangeOverlayData& rangeOverlay : m_RangeOverlayData) + { + delete rangeOverlay.second; + rangeOverlay.second = new SOverlayTexturedLine; + UpdateTexturedOverlay(&rangeOverlay.first, *rangeOverlay.second, msgData.offset, false); + } + } + UpdateMessageSubscriptions(); break; @@ -373,6 +408,15 @@ } } +void CCmpSelectable::ResetRangeOverlays() +{ + for (RangeOverlayData& rangeOverlay : m_RangeOverlayData) + delete rangeOverlay.second; + m_RangeOverlayData.clear(); + + UpdateMessageSubscriptions(); +} + void CCmpSelectable::UpdateMessageSubscriptions() { bool needInterpolate = false; @@ -402,15 +446,8 @@ SAFE_DELETE(m_BuildingOverlay); } -void CCmpSelectable::UpdateStaticOverlay() +void CCmpSelectable::UpdateTexturedOverlay(const SOverlayDescriptor* overlayDescriptor, SOverlayTexturedLine& overlay, float frameOffset, bool buildingOverlay) { - // Static overlays are allocated once and not updated until they are explicitly deleted again - // (see InvalidateStaticOverlay). Since they are expected to change rarely (if ever) during - // normal gameplay, this saves us doing all the work below on each frame. - - if (m_BuildingOverlay || m_OverlayDescriptor.m_Type != STATIC_OUTLINE) - return; - if (!CRenderer::IsInitialised()) return; @@ -419,84 +456,69 @@ if (!cmpFootprint || !cmpPosition || !cmpPosition->IsInWorld()) return; - CmpPtr cmpTerrain(GetSystemEntity()); - if (!cmpTerrain) - return; // should never happen - - // grab position/footprint data - CFixedVector2D position = cmpPosition->GetPosition2D(); - CFixedVector3D rotation = cmpPosition->GetRotation(); - ICmpFootprint::EShape fpShape; entity_pos_t fpSize0_fixed, fpSize1_fixed, fpHeight_fixed; cmpFootprint->GetShape(fpShape, fpSize0_fixed, fpSize1_fixed, fpHeight_fixed); - CTextureProperties texturePropsBase(m_OverlayDescriptor.m_LineTexture.c_str()); + float rotY; + CVector2D origin; + cmpPosition->GetInterpolatedPosition2D(frameOffset, origin.X, origin.Y, rotY); + CFixedVector3D rotation = cmpPosition->GetRotation(); + + CTextureProperties texturePropsBase(overlayDescriptor->m_LineTexture.c_str()); texturePropsBase.SetWrap(GL_CLAMP_TO_BORDER, GL_CLAMP_TO_EDGE); texturePropsBase.SetMaxAnisotropy(4.f); - CTextureProperties texturePropsMask(m_OverlayDescriptor.m_LineTextureMask.c_str()); + CTextureProperties texturePropsMask(overlayDescriptor->m_LineTextureMask.c_str()); texturePropsMask.SetWrap(GL_CLAMP_TO_BORDER, GL_CLAMP_TO_EDGE); texturePropsMask.SetMaxAnisotropy(4.f); - // ------------------------------------------------------------------------------------- + overlay.m_AlwaysVisible = false; + overlay.m_Closed = true; + overlay.m_SimContext = &GetSimContext(); + overlay.m_Thickness = overlayDescriptor->m_LineThickness; + overlay.m_TextureBase = g_Renderer.GetTextureManager().CreateTexture(texturePropsBase); + overlay.m_TextureMask = g_Renderer.GetTextureManager().CreateTexture(texturePropsMask); + overlay.m_Color = m_Color; - m_BuildingOverlay = new SOverlayTexturedLine; - m_BuildingOverlay->m_AlwaysVisible = false; - m_BuildingOverlay->m_Closed = true; - m_BuildingOverlay->m_SimContext = &GetSimContext(); - m_BuildingOverlay->m_Thickness = m_OverlayDescriptor.m_LineThickness; - m_BuildingOverlay->m_TextureBase = g_Renderer.GetTextureManager().CreateTexture(texturePropsBase); - m_BuildingOverlay->m_TextureMask = g_Renderer.GetTextureManager().CreateTexture(texturePropsMask); - - CVector2D origin(position.X.ToFloat(), position.Y.ToFloat()); - - switch (fpShape) - { - case ICmpFootprint::SQUARE: - { - float s = sinf(-rotation.Y.ToFloat()); - float c = cosf(-rotation.Y.ToFloat()); - CVector2D unitX(c, s); - CVector2D unitZ(-s, c); - - // add half the line thickness to the radius so that we get an 'outside' stroke of the footprint shape - const float halfSizeX = fpSize0_fixed.ToFloat()/2.f + m_BuildingOverlay->m_Thickness/2.f; - const float halfSizeZ = fpSize1_fixed.ToFloat()/2.f + m_BuildingOverlay->m_Thickness/2.f; - - std::vector points; - points.push_back(CVector2D(origin + unitX * halfSizeX + unitZ *(-halfSizeZ))); - points.push_back(CVector2D(origin + unitX *(-halfSizeX) + unitZ *(-halfSizeZ))); - points.push_back(CVector2D(origin + unitX *(-halfSizeX) + unitZ * halfSizeZ)); - points.push_back(CVector2D(origin + unitX * halfSizeX + unitZ * halfSizeZ)); + if (buildingOverlay && fpShape == ICmpFootprint::SQUARE) + { + float s = sinf(-rotation.Y.ToFloat()); + float c = cosf(-rotation.Y.ToFloat()); + CVector2D unitX(c, s); + CVector2D unitZ(-s, c); - SimRender::SubdividePoints(points, TERRAIN_TILE_SIZE/3.f, m_BuildingOverlay->m_Closed); - m_BuildingOverlay->PushCoords(points); - } - break; - case ICmpFootprint::CIRCLE: - { - const float radius = fpSize0_fixed.ToFloat() + m_BuildingOverlay->m_Thickness/3.f; - if (radius > 0) // prevent catastrophic failure - { - float stepAngle; - unsigned numSteps; - SimRender::AngularStepFromChordLen(TERRAIN_TILE_SIZE/3.f, radius, stepAngle, numSteps); + // Add half the line thickness to the radius so that we get an 'outside' stroke of the footprint shape + const float halfSizeX = fpSize0_fixed.ToFloat() / 2.f + overlay.m_Thickness / 2.f; + const float halfSizeZ = fpSize1_fixed.ToFloat() / 2.f + overlay.m_Thickness / 2.f; - for (unsigned i = 0; i < numSteps; i++) // '<' is sufficient because the line is closed automatically - { - float angle = i * stepAngle; - float px = origin.X + radius * sinf(angle); - float pz = origin.Y + radius * cosf(angle); + std::vector points; + points.push_back(CVector2D(origin + unitX * halfSizeX + unitZ * (-halfSizeZ))); + points.push_back(CVector2D(origin + unitX * (-halfSizeX) + unitZ * (-halfSizeZ))); + points.push_back(CVector2D(origin + unitX * (-halfSizeX) + unitZ * halfSizeZ)); + points.push_back(CVector2D(origin + unitX * halfSizeX + unitZ * halfSizeZ)); - m_BuildingOverlay->PushCoords(px, pz); - } - } + SimRender::SubdividePoints(points, TERRAIN_TILE_SIZE / 3.f, overlay.m_Closed); + overlay.PushCoords(points); + } + else + { + const float radius = (buildingOverlay ? fpSize0_fixed.ToFloat() : overlayDescriptor->m_Radius) + overlay.m_Thickness / 3.f; + float stepAngle; + unsigned numSteps; + SimRender::AngularStepFromChordLen(TERRAIN_TILE_SIZE / 3.f, radius, stepAngle, numSteps); + + for (unsigned i = 0; i < numSteps; ++i) + { + float angle = i * stepAngle; + float px = origin.X + radius * sinf(angle); + float pz = origin.Y + radius * cosf(angle); + + overlay.PushCoords(px, pz); } - break; } - ENSURE(m_BuildingOverlay); + ENSURE(overlay.m_TextureBase); } void CCmpSelectable::UpdateDynamicOverlay(float frameOffset) @@ -625,7 +647,10 @@ { case STATIC_OUTLINE: { - UpdateStaticOverlay(); + if (!m_BuildingOverlay) + m_BuildingOverlay = new SOverlayTexturedLine; + + UpdateTexturedOverlay(&m_OverlayDescriptor, *m_BuildingOverlay, 0, true); m_BuildingOverlay->m_Color = m_Color; // done separately so alpha changes don't require a full update call collector.Submit(m_BuildingOverlay); } @@ -639,6 +664,9 @@ default: break; } + + for (const RangeOverlayData& rangeOverlay : m_RangeOverlayData) + collector.Submit(rangeOverlay.second); } // Render bounding box debug overlays if we have a positive target alpha value. This ensures Index: source/simulation2/components/ICmpSelectable.h =================================================================== --- source/simulation2/components/ICmpSelectable.h +++ source/simulation2/components/ICmpSelectable.h @@ -43,6 +43,7 @@ CStrIntern m_LineTexture; CStrIntern m_LineTextureMask; float m_LineThickness; + int m_Radius; SOverlayDescriptor() : m_LineThickness(0) { } }; @@ -61,6 +62,16 @@ virtual void SetSelectionHighlight(const CColor& color, bool selected) = 0; /** + * Set a range overlay. + */ + virtual void SetRangeOverlay(float radius, const std::string& texture, const std::string& textureMask, float thickness) = 0; + + /** + * Reset any range overlays. + */ + virtual void ResetRangeOverlays() = 0; + + /** * Enables or disables rendering of an entity's selectable. * @param visible Whether the selectable should be visible. */ Index: source/simulation2/components/ICmpSelectable.cpp =================================================================== --- source/simulation2/components/ICmpSelectable.cpp +++ source/simulation2/components/ICmpSelectable.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2017 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -25,6 +25,8 @@ BEGIN_INTERFACE_WRAPPER(Selectable) DEFINE_INTERFACE_METHOD_2("SetSelectionHighlight", void, ICmpSelectable, SetSelectionHighlight, CColor, bool) +DEFINE_INTERFACE_METHOD_4("SetRangeOverlay", void, ICmpSelectable, SetRangeOverlay, float, std::string, std::string, float) +DEFINE_INTERFACE_METHOD_0("ResetRangeOverlays", void, ICmpSelectable, ResetRangeOverlays) END_INTERFACE_WRAPPER(Selectable) bool ICmpSelectable::ms_EnableDebugOverlays = false;