diff --git a/source/main/gfx/GfxActor.cpp b/source/main/gfx/GfxActor.cpp index 7cad417554..fbfd4d1f48 100644 --- a/source/main/gfx/GfxActor.cpp +++ b/source/main/gfx/GfxActor.cpp @@ -2351,6 +2351,17 @@ void RoR::GfxActor::SetPropsVisible(bool visible) } } +void RoR::GfxActor::SetAeroEnginesVisible(bool visible) +{ + // For turbojets, this hides meshes (nozzle, abflame) and particles + // For turbo/piston-props, this only hides particles, meshes are in props. + + for (int i = 0; i < m_actor->ar_num_aeroengines; i++) + { + m_actor->ar_aeroengines[i]->setVisible(visible); + } +} + void RoR::GfxActor::SetRenderdashActive(bool active) { if (m_renderdash != nullptr) @@ -3287,6 +3298,7 @@ void RoR::GfxActor::SetAllMeshesVisible(bool visible) this->SetFlexbodyVisible(visible); this->SetWingsVisible(visible); this->SetRodsVisible(visible); + this->SetAeroEnginesVisible(visible); } void RoR::GfxActor::SetWingsVisible(bool visible) diff --git a/source/main/gfx/GfxActor.h b/source/main/gfx/GfxActor.h index c1eb400812..9d5ca92569 100644 --- a/source/main/gfx/GfxActor.h +++ b/source/main/gfx/GfxActor.h @@ -223,6 +223,8 @@ class GfxActor void SetCastShadows(bool value); void SetFlexbodiesVisible(bool visible); void SetPropsVisible(bool visible); + void SetAeroEnginesVisible(bool visible); + // Visual updates diff --git a/source/main/physics/air/AeroEngine.h b/source/main/physics/air/AeroEngine.h index 596b225f87..2f5572b4e4 100644 --- a/source/main/physics/air/AeroEngine.h +++ b/source/main/physics/air/AeroEngine.h @@ -37,7 +37,6 @@ class AeroEngine virtual ~AeroEngine() {} - virtual void updateVisuals(RoR::GfxActor* gfx_actor) =0; virtual void updateForces(float dt, int doUpdate) =0; virtual void setThrottle(float val) =0; @@ -65,6 +64,10 @@ class AeroEngine virtual int getNoderef() =0; virtual bool getWarmup() =0; virtual float getRadius() =0; + + // Visuals + virtual void updateVisuals(RoR::GfxActor* gfx_actor) = 0; + virtual void setVisible(bool visible) = 0; }; } // namespace RoR diff --git a/source/main/physics/air/TurboJet.cpp b/source/main/physics/air/TurboJet.cpp index 74c2b7ceb8..2a1b23122a 100644 --- a/source/main/physics/air/TurboJet.cpp +++ b/source/main/physics/air/TurboJet.cpp @@ -144,7 +144,13 @@ TurbojetVisual::~TurbojetVisual() void Turbojet::updateVisuals(RoR::GfxActor* gfx_actor) { - this->tjet_visual.UpdateVisuals(gfx_actor); + if (this->tjet_visual.IsVisible()) + this->tjet_visual.UpdateVisuals(gfx_actor); +} + +void Turbojet::setVisible(bool visible) +{ + this->tjet_visual.SetVisible(visible); } void TurbojetVisual::UpdateVisuals(RoR::GfxActor* gfx_actor) @@ -206,6 +212,18 @@ void TurbojetVisual::UpdateVisuals(RoR::GfxActor* gfx_actor) } } +void TurbojetVisual::SetVisible(bool visible) +{ + m_visible = visible; + m_smoke_particle->setVisible(visible); + m_nozzle_scenenode->setVisible(visible); + if (!visible) + { + // only hide, regular update will restore visibility if needed. + m_flame_scenenode->setVisible(false); + } +} + void Turbojet::updateForces(float dt, int doUpdate) { if (doUpdate) diff --git a/source/main/physics/air/TurboJet.h b/source/main/physics/air/TurboJet.h index 6e758e7e00..3f0481cc0e 100644 --- a/source/main/physics/air/TurboJet.h +++ b/source/main/physics/air/TurboJet.h @@ -33,6 +33,8 @@ class TurbojetVisual void SetupVisuals(RigDef::Turbojet & def, int num, std::string const& propname, Ogre::Entity* nozzle, Ogre::Entity* afterburner_flame, bool disable_smoke); void SetNodes(int front, int back, int ref); void UpdateVisuals(RoR::GfxActor* gfx_actor); + void SetVisible(bool visible); + bool IsVisible() const { return m_visible; } private: Ogre::SceneNode* m_smoke_scenenode; @@ -42,6 +44,7 @@ class TurbojetVisual Ogre::Entity* m_nozzle_entity; Ogre::SceneNode* m_nozzle_scenenode; + bool m_visible = false; // Needed for flames which are hidden by default. int m_number; float m_radius; uint16_t m_node_back; @@ -65,7 +68,6 @@ class Turbojet: public AeroEngine, public ZeroedMemoryAllocator void setReverse(bool val); bool getReverse() { return m_reverse; }; void updateForces(float dt, int doUpdate); - void updateVisuals(RoR::GfxActor* gfx_actor) override; Ogre::Vector3 getAxis() { return m_axis; }; @@ -84,6 +86,11 @@ class Turbojet: public AeroEngine, public ZeroedMemoryAllocator int getNoderef() { return m_node_back; }; int getType() { return AEROENGINE_TYPE_TURBOJET; }; + // AeroEngine visuals + + void updateVisuals(RoR::GfxActor* gfx_actor) override; + void setVisible(bool visible) override; + bool tjet_afterburnable; TurbojetVisual tjet_visual; diff --git a/source/main/physics/air/TurboProp.cpp b/source/main/physics/air/TurboProp.cpp index 541c6b8fad..d83a72c806 100644 --- a/source/main/physics/air/TurboProp.cpp +++ b/source/main/physics/air/TurboProp.cpp @@ -208,6 +208,11 @@ void Turboprop::updateVisuals(RoR::GfxActor* gfx_actor) #endif } +void Turboprop::setVisible(bool visible) +{ + smokePS->setVisible(visible); +} + void Turboprop::updateForces(float dt, int doUpdate) { if (doUpdate) diff --git a/source/main/physics/air/TurboProp.h b/source/main/physics/air/TurboProp.h index 0b8532a0d7..80993f5b72 100644 --- a/source/main/physics/air/TurboProp.h +++ b/source/main/physics/air/TurboProp.h @@ -55,7 +55,6 @@ class Turboprop: public AeroEngine, public ZeroedMemoryAllocator ); ~Turboprop(); - void updateVisuals(RoR::GfxActor* gfx_actor) override; void updateForces(float dt, int doUpdate); void setThrottle(float val); @@ -83,6 +82,10 @@ class Turboprop: public AeroEngine, public ZeroedMemoryAllocator bool getWarmup() { return warmup; }; float getRadius() { return radius; }; + // Visuals + void updateVisuals(RoR::GfxActor* gfx_actor) override; + void setVisible(bool visible) override; + private: node_t* nodes;