Skip to content

Commit

Permalink
Codechange: {prop anim -> key state} binding made explicit.
Browse files Browse the repository at this point in the history
  • Loading branch information
ohlidalp committed Mar 31, 2024
1 parent ddd2025 commit 4c5e066
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
7 changes: 2 additions & 5 deletions source/main/gfx/GfxActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2772,8 +2772,6 @@ void RoR::GfxActor::CalcPropAnimation(PropAnim& anim, float& cstate, int& div, f

void RoR::GfxActor::UpdatePropAnimations(float dt)
{
int prop_anim_key_index = 0;

for (Prop& prop: m_props)
{
int animnum = 0;
Expand All @@ -2789,10 +2787,9 @@ void RoR::GfxActor::UpdatePropAnimations(float dt)
this->CalcPropAnimation(anim, cstate, div, dt);

// key triggered animations - state determined in simulation
if (anim.animFlags & ANIM_FLAG_EVENT)
if (anim.animFlags & PROP_ANIM_FLAG_EVENT && anim.animKeyID != PROPANIMKEYID_INVALID)
{
ROR_ASSERT(prop_anim_key_index < (int)m_simbuf.simbuf_prop_anim_keys.size());
const bool anim_active = m_simbuf.simbuf_prop_anim_keys[prop_anim_key_index++].simbuf_anim_active;
const bool anim_active = m_simbuf.simbuf_prop_anim_keys[anim.animKeyID].simbuf_anim_active;
cstate += (float)anim_active;
}

Expand Down
19 changes: 11 additions & 8 deletions source/main/gfx/GfxData.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ static const int CAMERA_MODE_ALWAYS_HIDDEN = -3;
static const int CAMERA_MODE_ALWAYS_VISIBLE = -2;
static const int CAMERA_MODE_3RDPERSON_ONLY = -1;

typedef int PropAnimKeyId_t;
static const int PROPANIMKEYID_INVALID = -1;

enum ShifterPropAnim
{
SHIFTER_INVALID = 0,
Expand All @@ -136,18 +139,18 @@ enum ShifterPropAnim

struct PropAnim
{
float animratio = 0; //!< A coefficient for the animation, prop degree if used with mode: rotation and propoffset if used with mode: offset.
PropAnimFlag animFlags = {};
PropAnimMode animMode = {};

float animratio = 0; //!< A coefficient for the animation, prop degree if used with mode: rotation and propoffset if used with mode: offset.
PropAnimFlag animFlags = {};
PropAnimMode animMode = {};
PropAnimKeyId_t animKeyID = PROPANIMKEYID_INVALID; //!< Only if 'mode: event' is used.
/// MULTIPURPOSE
/// * SHIFTER type `ShifterPropAnim` (1 = shifterman1, 2 = shifterman2, 3 = shifterseq, 4 = shifterlin)
/// * AEROENGINE number (starting from 1), applies to: rpm + throttle + torque ( turboprop ) + pitch ( turboprop ) + status + fire
/// * ALTIMETER type (1 = 100k limited, 2 = 10k oscillating, 3 = 1k oscillating)
float animOpt3 = 0;
float animOpt5 = 0;
float lower_limit = 0; //!< The lower limit for the animation
float upper_limit = 0; //!< The upper limit for the animation
float animOpt3 = 0;
float animOpt5 = 0;
float lower_limit = 0; //!< The lower limit for the animation
float upper_limit = 0; //!< The upper limit for the animation

// Only for SHIFTER
float shifterSmooth = 0.f;
Expand Down
2 changes: 2 additions & 0 deletions source/main/physics/ActorSpawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2061,7 +2061,9 @@ void ActorSpawner::ProcessProp(RigDef::Prop & def)
state.eventlock_present = BITMASK_IS_1(anim_def.mode, RigDef::Animation::MODE_EVENT_LOCK);
state.event_id = static_cast<events>(event_id);
m_actor->m_prop_anim_key_states.push_back(state);

BITMASK_SET_1(anim.animFlags, PROP_ANIM_FLAG_EVENT);
anim.animKeyID = static_cast<PropAnimKeyId_t>(m_actor->m_prop_anim_key_states.size() - 1);
}
}

Expand Down

0 comments on commit 4c5e066

Please sign in to comment.