mirror of
https://github.com/rwengine/openrw.git
synced 2024-09-15 15:02:34 +02:00
Improve loading of hard-coded models
This commit is contained in:
parent
a861309936
commit
e31c30efe9
@ -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) {
|
||||
|
@ -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<Model>
|
||||
specialmodels_[SpecialModel::SpecialModelCount];
|
||||
Model* getSpecialModel(SpecialModel usage) const {
|
||||
return specialmodels_[usage].get();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -33,6 +33,11 @@
|
||||
const std::string kBuildStr(kGitSHA1Hash, 8);
|
||||
const std::string kWindowTitle = "RWGame";
|
||||
|
||||
std::map<GameRenderer::SpecialModel, std::string> 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");
|
||||
|
Loading…
Reference in New Issue
Block a user