Skip to content

Commit

Permalink
🔧 Ability to hide aeroengines
Browse files Browse the repository at this point in the history
  • Loading branch information
ohlidalp committed Aug 28, 2021
1 parent 3ada165 commit 37c6a32
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 4 deletions.
12 changes: 12 additions & 0 deletions source/main/gfx/GfxActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions source/main/gfx/GfxActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ class GfxActor
void SetCastShadows(bool value);
void SetFlexbodiesVisible(bool visible);
void SetPropsVisible(bool visible);
void SetAeroEnginesVisible(bool visible);


// Visual updates

Expand Down
5 changes: 4 additions & 1 deletion source/main/physics/air/AeroEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
20 changes: 19 additions & 1 deletion source/main/physics/air/TurboJet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion source/main/physics/air/TurboJet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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; };

Expand All @@ -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;

Expand Down
5 changes: 5 additions & 0 deletions source/main/physics/air/TurboProp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion source/main/physics/air/TurboProp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 37c6a32

Please # to comment.