Skip to content

Commit

Permalink
Actor: added get/setSmokeEnabled() for ad-hoc use.
Browse files Browse the repository at this point in the history
Fixed `m_disable_smoke` field - now valid to be changed in real time, previously mixed - would affect exhausts but not turbojets.
  • Loading branch information
ohlidalp authored and tritonas00 committed Sep 16, 2021
1 parent 1d188f2 commit 1194484
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 24 deletions.
1 change: 1 addition & 0 deletions source/main/gfx/GfxActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1742,6 +1742,7 @@ void RoR::GfxActor::UpdateSimDataBuffer()
m_simbuf.simbuf_node0_velo = m_actor->ar_nodes[0].Velocity;
m_simbuf.simbuf_net_username = m_actor->m_net_username;
m_simbuf.simbuf_net_colornum = m_actor->m_net_color_num;
m_simbuf.simbuf_smoke_enabled = m_actor->getSmokeEnabled();

// General info
m_simbuf.simbuf_actor_state = m_actor->ar_state;
Expand Down
1 change: 1 addition & 0 deletions source/main/gfx/GfxActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class GfxActor
float simbuf_inputshaft_rpm = 0; // Land vehicle only
float simbuf_drive_ratio = 0; // Land vehicle only
bool simbuf_beaconlight_active = false;
bool simbuf_smoke_enabled = false;
float simbuf_hydro_dir_state = 0; // State of steering actuator ('hydro'), for steeringwheel display
float simbuf_hydro_aileron_state = 0;
float simbuf_hydro_elevator_state = 0;
Expand Down
3 changes: 2 additions & 1 deletion source/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ int main(int argc, char *argv[])
actor->GetGfxActor()->SetCastShadows(false);
actor->muteAllSounds(); // Stop sounds
actor->setLightsOff(); // Turn all lights off

actor->setSmokeEnabled(false);
}
break;

Expand All @@ -655,6 +655,7 @@ int main(int argc, char *argv[])
actor->GetGfxActor()->SetAllMeshesVisible(true);
actor->GetGfxActor()->SetCastShadows(true);
actor->unmuteAllSounds(); // Unmute sounds
actor->setSmokeEnabled(true);
}
break;

Expand Down
4 changes: 3 additions & 1 deletion source/main/physics/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class Actor : public ZeroedMemoryAllocator
Ogre::String getTransferCaseName(); //! Gets the current transfer case mode name (4WD Hi, ...)
void displayTransferCaseMode(); //! Writes info to console/notify area
void toggleCustomParticles();
void setSmokeEnabled(bool enabled) { m_disable_smoke = !enabled; }
bool getSmokeEnabled() const { return !m_disable_smoke; }
bool getCustomParticleMode();
void beaconsToggle();
bool getBrakeLightVisible();
Expand Down Expand Up @@ -534,7 +536,7 @@ class Actor : public ZeroedMemoryAllocator
bool m_beam_deform_debug_enabled:1; //!< Logging state
bool m_trigger_debug_enabled:1; //!< Logging state
bool m_disable_default_sounds:1; //!< Spawner context; TODO: remove
bool m_disable_smoke:1; //!< Gfx state
bool m_disable_smoke:1; //!< Stops/starts smoke particles (i.e. exhausts, turbojets).

struct VehicleForceSensors
{
Expand Down
6 changes: 1 addition & 5 deletions source/main/physics/ActorSpawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ void ActorSpawner::ProcessTurbojet(RigDef::Turbojet & def)
std::string propname = this->ComposeName("Turbojet", m_actor->ar_num_aeroengines);
tj->tjet_visual.SetNodes(front, back, ref);
tj->tjet_visual.SetupVisuals(def, m_actor->ar_num_aeroengines,
propname, nozzle_ent, afterburn_ent, m_actor->m_disable_smoke);
propname, nozzle_ent, afterburn_ent);

m_actor->ar_aeroengines[m_actor->ar_num_aeroengines]=tj;
m_actor->ar_driveable=AIRPLANE;
Expand Down Expand Up @@ -5749,10 +5749,6 @@ void ActorSpawner::AddExhaust(
unsigned int direction_node_idx
)
{
if (m_actor->m_disable_smoke)
{
return;
}
exhaust_t exhaust;
exhaust.emitterNode = emitter_node_idx;
exhaust.directionNode = direction_node_idx;
Expand Down
28 changes: 12 additions & 16 deletions source/main/physics/air/TurboJet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Turbojet::Turbojet(Actor* actor, int tnodefront, int tnodeback, int tnoderef, Ri
reset();
}

void TurbojetVisual::SetupVisuals(RigDef::Turbojet & def, int num, std::string const& propname, Ogre::Entity* nozzle, Ogre::Entity* afterburner_flame, bool disable_smoke)
void TurbojetVisual::SetupVisuals(RigDef::Turbojet & def, int num, std::string const& propname, Ogre::Entity* nozzle, Ogre::Entity* afterburner_flame)
{
m_radius = def.back_diameter / 2.0;
m_number = num;
Expand All @@ -88,23 +88,17 @@ void TurbojetVisual::SetupVisuals(RigDef::Turbojet & def, int num, std::string c
m_flame_scenenode->setScale(1.0, def.back_diameter, def.back_diameter);
m_flame_scenenode->setVisible(false);
}

//smoke visual
if (disable_smoke)
m_smoke_scenenode = App::GetGfxScene()->GetSceneManager()->getRootSceneNode()->createChildSceneNode();
m_smoke_particle = App::GetGfxScene()->GetSceneManager()->createParticleSystem("SmokeParticle-"+propname, "tracks/TurbopropSmoke");
if (m_smoke_particle)
{
m_smoke_scenenode = 0;
m_smoke_particle = 0;
}
else
{
m_smoke_scenenode = App::GetGfxScene()->GetSceneManager()->getRootSceneNode()->createChildSceneNode();
m_smoke_particle = App::GetGfxScene()->GetSceneManager()->createParticleSystem("SmokeParticle-"+propname, "tracks/TurbopropSmoke");
if (m_smoke_particle)
{
m_smoke_particle->setVisibilityFlags(DEPTHMAP_DISABLED); // disable particles in depthmap
m_smoke_scenenode->attachObject(m_smoke_particle);
m_smoke_particle->setCastShadows(false);
}
m_smoke_particle->setVisibilityFlags(DEPTHMAP_DISABLED); // disable particles in depthmap
m_smoke_scenenode->attachObject(m_smoke_particle);
m_smoke_particle->setCastShadows(false);
}

}

void TurbojetVisual::SetNodes(int front, int back, int ref)
Expand Down Expand Up @@ -181,8 +175,10 @@ void TurbojetVisual::UpdateVisuals(RoR::GfxActor* gfx_actor)
}
else
m_flame_scenenode->setVisible(false);

//smoke
if (m_smoke_scenenode)
if (m_smoke_particle &&
gfx_actor->GetSimDataBuffer().simbuf_smoke_enabled)
{
m_smoke_scenenode->setPosition(node_buf[m_node_back].AbsPosition);
ParticleEmitter* emit = m_smoke_particle->getEmitter(0);
Expand Down
2 changes: 1 addition & 1 deletion source/main/physics/air/TurboJet.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TurbojetVisual
{
public:
~TurbojetVisual();
void SetupVisuals(RigDef::Turbojet & def, int num, std::string const& propname, Ogre::Entity* nozzle, Ogre::Entity* afterburner_flame, bool disable_smoke);
void SetupVisuals(RigDef::Turbojet & def, int num, std::string const& propname, Ogre::Entity* nozzle, Ogre::Entity* afterburner_flame);
void SetNodes(int front, int back, int ref);
void UpdateVisuals(RoR::GfxActor* gfx_actor);
void SetVisible(bool visible);
Expand Down

0 comments on commit 1194484

Please # to comment.