mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-07 03:12:36 +01: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
|
// This is sequential at the moment, it should be easy to make it
|
||||||
// run in parallel with a good threading system.
|
// run in parallel with a good threading system.
|
||||||
RenderList renderList;
|
RenderList renderList;
|
||||||
// Naive optimisation, assume 10% hitrate
|
// Naive optimisation, assume 50% hitrate
|
||||||
renderList.reserve(world->allObjects.size() * 0.5f);
|
renderList.reserve(world->allObjects.size() * 0.5f);
|
||||||
|
|
||||||
RW_PROFILE_BEGIN("Build");
|
RW_PROFILE_BEGIN("Build");
|
||||||
@ -311,9 +311,7 @@ void GameRenderer::renderWorld(GameWorld* world, const ViewCamera& camera,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Area indicators
|
// Area indicators
|
||||||
/// @todo this shouldn't be static here
|
auto sphereModel = getSpecialModel(ZoneCylinderA);
|
||||||
/// @todo what are zonecyla / zonecylb for?
|
|
||||||
static auto sphereModel = world->data->loadClump("zonecyla.dff");
|
|
||||||
for (auto& i : world->getAreaIndicators()) {
|
for (auto& i : world->getAreaIndicators()) {
|
||||||
glm::mat4 m(1.f);
|
glm::mat4 m(1.f);
|
||||||
m = glm::translate(m, i.position);
|
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,
|
objectRenderer.renderFrame(sphereModel, sphereModel->frames[0], m,
|
||||||
nullptr, 1.f, renderList);
|
nullptr, 1.f, renderList);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render arrows above anything that isn't radar only (or hidden)
|
// Render arrows above anything that isn't radar only (or hidden)
|
||||||
/// @todo this shouldn't be static here
|
auto arrowModel = getSpecialModel(Arrow);
|
||||||
static auto arrowModel = world->data->loadClump("arrow.dff");
|
|
||||||
for (auto& blip : world->state->radarBlips) {
|
for (auto& blip : world->state->radarBlips) {
|
||||||
auto dm = blip.second.display;
|
auto dm = blip.second.display;
|
||||||
if (dm == BlipData::Hide || dm == BlipData::RadarOnly) {
|
if (dm == BlipData::Hide || dm == BlipData::RadarOnly) {
|
||||||
|
@ -190,6 +190,31 @@ public:
|
|||||||
Renderer::ProfileInfo profSky;
|
Renderer::ProfileInfo profSky;
|
||||||
Renderer::ProfileInfo profWater;
|
Renderer::ProfileInfo profWater;
|
||||||
Renderer::ProfileInfo profEffects;
|
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
|
#endif
|
||||||
|
@ -33,6 +33,11 @@
|
|||||||
const std::string kBuildStr(kGitSHA1Hash, 8);
|
const std::string kBuildStr(kGitSHA1Hash, 8);
|
||||||
const std::string kWindowTitle = "RWGame";
|
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
|
#define MOUSE_SENSITIVITY_SCALE 2.5f
|
||||||
|
|
||||||
DebugDraw* debug = nullptr;
|
DebugDraw* debug = nullptr;
|
||||||
@ -124,6 +129,11 @@ RWGame::RWGame(int argc, char* argv[]) {
|
|||||||
// Initialize renderer
|
// Initialize renderer
|
||||||
renderer = new GameRenderer(&log, data);
|
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
|
// Set up text renderer
|
||||||
renderer->text.setFontTexture(0, "pager");
|
renderer->text.setFontTexture(0, "pager");
|
||||||
renderer->text.setFontTexture(1, "font1");
|
renderer->text.setFontTexture(1, "font1");
|
||||||
|
Loading…
Reference in New Issue
Block a user