diff --git a/rwengine/src/render/GameRenderer.cpp b/rwengine/src/render/GameRenderer.cpp index 6798050c..c39603df 100644 --- a/rwengine/src/render/GameRenderer.cpp +++ b/rwengine/src/render/GameRenderer.cpp @@ -296,7 +296,7 @@ void GameRenderer::renderWorld(GameWorld* world, const ViewCamera& camera, // This is sequential at the moment, it should be easy to make it // run in parallel with a good threading system. RenderList renderList; - // Naive optimisation, assume 10% hitrate + // Naive optimisation, assume 50% hitrate renderList.reserve(world->allObjects.size() * 0.5f); RW_PROFILE_BEGIN("Build"); @@ -311,9 +311,7 @@ void GameRenderer::renderWorld(GameWorld* world, const ViewCamera& camera, } // Area indicators - /// @todo this shouldn't be static here - /// @todo what are zonecyla / zonecylb for? - static auto sphereModel = world->data->loadClump("zonecyla.dff"); + auto sphereModel = getSpecialModel(ZoneCylinderA); for (auto& i : world->getAreaIndicators()) { glm::mat4 m(1.f); m = glm::translate(m, i.position); @@ -324,9 +322,9 @@ void GameRenderer::renderWorld(GameWorld* world, const ViewCamera& camera, objectRenderer.renderFrame(sphereModel, sphereModel->frames[0], m, nullptr, 1.f, renderList); } + // Render arrows above anything that isn't radar only (or hidden) - /// @todo this shouldn't be static here - static auto arrowModel = world->data->loadClump("arrow.dff"); + auto arrowModel = getSpecialModel(Arrow); for (auto& blip : world->state->radarBlips) { auto dm = blip.second.display; if (dm == BlipData::Hide || dm == BlipData::RadarOnly) { diff --git a/rwengine/src/render/GameRenderer.hpp b/rwengine/src/render/GameRenderer.hpp index 68a76a9f..a4d51ac7 100644 --- a/rwengine/src/render/GameRenderer.hpp +++ b/rwengine/src/render/GameRenderer.hpp @@ -190,6 +190,31 @@ public: Renderer::ProfileInfo profSky; Renderer::ProfileInfo profWater; Renderer::ProfileInfo profEffects; + + enum SpecialModel { + /// @todo what is the difference between A and B + ZoneCylinderA, + ZoneCylinderB, + Arrow, + SpecialModelCount + }; + + /** + * @brief setSpecialModel Set model to use for each SpecialModel + * + * GameRenderer will take ownership of the Model* pointer + */ + void setSpecialModel(SpecialModel usage, Model* model) { + specialmodels_[usage].reset(model); + } + +private: + /// Hard-coded models to use for each of the special models + std::unique_ptr + specialmodels_[SpecialModel::SpecialModelCount]; + Model* getSpecialModel(SpecialModel usage) const { + return specialmodels_[usage].get(); + } }; #endif diff --git a/rwgame/RWGame.cpp b/rwgame/RWGame.cpp index 9e1ac54d..e35a4a7f 100644 --- a/rwgame/RWGame.cpp +++ b/rwgame/RWGame.cpp @@ -33,6 +33,11 @@ const std::string kBuildStr(kGitSHA1Hash, 8); const std::string kWindowTitle = "RWGame"; +std::map kSpecialModels = { + {GameRenderer::ZoneCylinderA, "zonecyla.dff"}, + {GameRenderer::ZoneCylinderB, "zonecylb.dff"}, + {GameRenderer::Arrow, "arrow.dff"}}; + #define MOUSE_SENSITIVITY_SCALE 2.5f DebugDraw* debug = nullptr; @@ -124,6 +129,11 @@ RWGame::RWGame(int argc, char* argv[]) { // Initialize renderer renderer = new GameRenderer(&log, data); + for (const auto& p : kSpecialModels) { + auto model = data->loadClump(p.second); + renderer->setSpecialModel(p.first, model); + } + // Set up text renderer renderer->text.setFontTexture(0, "pager"); renderer->text.setFontTexture(1, "font1");