refactor: Simplify HUD updates
Get camera matrices directly from the Game object.
This commit is contained in:
parent
8f3af5a5b0
commit
2bb0428add
5 changed files with 12 additions and 11 deletions
|
@ -376,11 +376,6 @@ void Game::update() {
|
|||
_module->update(dt);
|
||||
}
|
||||
|
||||
if (_screen == GameScreen::InGame) {
|
||||
Camera *camera = _module->area()->getCamera();
|
||||
_hud->prepare(camera->sceneNode()->projection(), camera->sceneNode()->view());
|
||||
}
|
||||
|
||||
_window.update(dt);
|
||||
}
|
||||
|
||||
|
|
|
@ -147,7 +147,9 @@ void HUD::load() {
|
|||
hideControl("TB_STEALTH");
|
||||
}
|
||||
|
||||
void HUD::prepare(const glm::mat4 &projection, const glm::mat4 &view) {
|
||||
void HUD::update(float dt) {
|
||||
GUI::update(dt);
|
||||
|
||||
Party &party = _game->party();
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
|
@ -165,7 +167,7 @@ void HUD::prepare(const glm::mat4 &projection, const glm::mat4 &view) {
|
|||
}
|
||||
}
|
||||
|
||||
_select.prepare(projection, view);
|
||||
_select.update();
|
||||
}
|
||||
|
||||
void HUD::render() const {
|
||||
|
|
|
@ -34,9 +34,9 @@ public:
|
|||
HUD(Game *game);
|
||||
|
||||
void load() override;
|
||||
void render() const override;
|
||||
|
||||
void prepare(const glm::mat4 &projection, const glm::mat4 &view);
|
||||
void update(float dt) override;
|
||||
void render() const override;
|
||||
|
||||
private:
|
||||
Game *_game { nullptr };
|
||||
|
|
|
@ -44,10 +44,14 @@ void SelectionOverlay::load() {
|
|||
_friendlyReticle2 = Textures::instance().get("friendlyreticle2", TextureType::GUI);
|
||||
}
|
||||
|
||||
void SelectionOverlay::prepare(const glm::mat4 &projection, const glm::mat4 &view) {
|
||||
void SelectionOverlay::update() {
|
||||
shared_ptr<Area> area(_game->module()->area());
|
||||
ObjectSelector &selector = area->objectSelector();
|
||||
|
||||
Camera *camera = area->getCamera();
|
||||
glm::mat4 projection(camera->sceneNode()->projection());
|
||||
glm::mat4 view(camera->sceneNode()->view());
|
||||
|
||||
int hilightedObjectId = selector.hilightedObjectId();
|
||||
if (hilightedObjectId != -1) {
|
||||
_hilightedScreenCoords = area->getSelectableScreenCoords(hilightedObjectId, projection, view);
|
||||
|
|
|
@ -38,8 +38,8 @@ public:
|
|||
SelectionOverlay(Game *game);
|
||||
|
||||
void load();
|
||||
void prepare(const glm::mat4 &projection, const glm::mat4 &view);
|
||||
|
||||
void update();
|
||||
void render() const;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue