From 0e4b5569d52eb37fdba4caf2306c39afc18adb3f Mon Sep 17 00:00:00 2001 From: Petr Ohlidal Date: Sat, 2 Sep 2023 01:22:01 +0200 Subject: [PATCH] :truck: New prop anim sources: `gear[reverse/neutral/#]`, `autoshifterlin` I had to add `BitMask64_t` and convert enums to constants because C-style `enum` won't work with int64. --- source/main/gfx/GfxActor.cpp | 29 ++++- source/main/gfx/GfxData.h | 111 +++++++++--------- source/main/physics/ActorSpawner.cpp | 29 ++++- .../rig_def_fileformat/RigDef_File.h | 72 ++++++------ .../rig_def_fileformat/RigDef_Parser.cpp | 10 ++ source/main/utils/BitFlags.h | 2 + 6 files changed, 154 insertions(+), 99 deletions(-) diff --git a/source/main/gfx/GfxActor.cpp b/source/main/gfx/GfxActor.cpp index fbc4b1fd54..513ac25446 100644 --- a/source/main/gfx/GfxActor.cpp +++ b/source/main/gfx/GfxActor.cpp @@ -2416,7 +2416,7 @@ void RoR::GfxActor::CalcPropAnimation(PropAnim& anim, float& cstate, int& div, f div++; } - //torque - WRITES + //torque const bool has_engine = (m_actor->ar_engine!= nullptr); if (has_engine && anim.animFlags & PROP_ANIM_FLAG_TORQUE) { @@ -2434,8 +2434,15 @@ void RoR::GfxActor::CalcPropAnimation(PropAnim& anim, float& cstate, int& div, f div++; } + if (has_engine && anim.animFlags & PROP_ANIM_FLAG_GEAR) + { + bool match = static_cast(anim.animOpt3) == m_actor->ar_engine->GetGear(); + cstate += static_cast(match); + div++; + } + //shifterseq, to amimate sequentiell shifting - if (has_engine && (anim.animFlags & PROP_ANIM_FLAG_SHIFTER) && anim.animOpt3 == ShifterPropAnim::SHIFTERSEQ) + if (has_engine && (anim.animFlags & PROP_ANIM_FLAG_SHIFTER) && anim.animOpt3 == SHIFTERSEQ) { float shifterseq_cstate = 0; // opt1 &opt2 = 0 this is a shifter @@ -2487,7 +2494,7 @@ void RoR::GfxActor::CalcPropAnimation(PropAnim& anim, float& cstate, int& div, f } //shifterman1, left/right - if (has_engine && (anim.animFlags & PROP_ANIM_FLAG_SHIFTER) && anim.animOpt3 == ShifterPropAnim::SHIFTERMAN1) + if (has_engine && (anim.animFlags & PROP_ANIM_FLAG_SHIFTER) && anim.animOpt3 == SHIFTERMAN1) { float shifterman1_cstate = 0.f; int shifter = m_simbuf.simbuf_gear; @@ -2509,7 +2516,7 @@ void RoR::GfxActor::CalcPropAnimation(PropAnim& anim, float& cstate, int& div, f } //shifterman2, up/down - if (has_engine && (anim.animFlags & PROP_ANIM_FLAG_SHIFTER) && anim.animOpt3 == ShifterPropAnim::SHIFTERMAN2) + if (has_engine && (anim.animFlags & PROP_ANIM_FLAG_SHIFTER) && anim.animOpt3 == SHIFTERMAN2) { float shifterman2_cstate = 0.f; int shifter = m_simbuf.simbuf_gear; @@ -2528,7 +2535,7 @@ void RoR::GfxActor::CalcPropAnimation(PropAnim& anim, float& cstate, int& div, f } //shifterlinear, to amimate cockpit gearselect gauge and autotransmission stick - if (has_engine && (anim.animFlags & PROP_ANIM_FLAG_SHIFTER) && anim.animOpt3 == ShifterPropAnim::SHIFTERLIN) + if (has_engine && (anim.animFlags & PROP_ANIM_FLAG_SHIFTER) && anim.animOpt3 == SHIFTERLIN) { float shifterlin_cstate = 0.f; int shifter = m_simbuf.simbuf_gear; @@ -2539,6 +2546,18 @@ void RoR::GfxActor::CalcPropAnimation(PropAnim& anim, float& cstate, int& div, f div++; } + //autoshifterlin, autotransmission stick with only R/N/D positions + if (has_engine && (anim.animFlags & PROP_ANIM_FLAG_SHIFTER) && anim.animOpt3 == AUTOSHIFTERLIN) + { + float shifterlin_cstate = 0.f; + int shifter = std::max(m_simbuf.simbuf_gear, 1); // Clamp forward gears to 1 + int numgears = 1; // Number of forward gears + shifterlin_cstate -= (shifter + 2.0) / (numgears + 2.0); + + cstate += UpdateSmoothShift(anim, dt, shifterlin_cstate); + div++; + } + //parking brake if (anim.animFlags & PROP_ANIM_FLAG_PBRAKE) { diff --git a/source/main/gfx/GfxData.h b/source/main/gfx/GfxData.h index 0f3219d48c..a365c37133 100644 --- a/source/main/gfx/GfxData.h +++ b/source/main/gfx/GfxData.h @@ -39,57 +39,54 @@ namespace RoR { /// @addtogroup Gfx /// @{ -enum PropAnimFlag -{ - PROP_ANIM_FLAG_AIRSPEED = BITMASK(1), - PROP_ANIM_FLAG_VVI = BITMASK(2), - PROP_ANIM_FLAG_ALTIMETER = BITMASK(3), - PROP_ANIM_FLAG_AOA = BITMASK(4), - PROP_ANIM_FLAG_FLAP = BITMASK(5), - PROP_ANIM_FLAG_AIRBRAKE = BITMASK(6), - PROP_ANIM_FLAG_ROLL = BITMASK(7), - PROP_ANIM_FLAG_PITCH = BITMASK(8), - PROP_ANIM_FLAG_THROTTLE = BITMASK(9), - PROP_ANIM_FLAG_RPM = BITMASK(10), - PROP_ANIM_FLAG_ACCEL = BITMASK(11), - PROP_ANIM_FLAG_BRAKE = BITMASK(12), - PROP_ANIM_FLAG_CLUTCH = BITMASK(13), - PROP_ANIM_FLAG_TACHO = BITMASK(14), - PROP_ANIM_FLAG_SPEEDO = BITMASK(15), - PROP_ANIM_FLAG_PBRAKE = BITMASK(16), - PROP_ANIM_FLAG_TURBO = BITMASK(17), - PROP_ANIM_FLAG_SHIFTER = BITMASK(18), - PROP_ANIM_FLAG_AETORQUE = BITMASK(19), - PROP_ANIM_FLAG_AEPITCH = BITMASK(20), - PROP_ANIM_FLAG_AESTATUS = BITMASK(21), - PROP_ANIM_FLAG_TORQUE = BITMASK(22), - PROP_ANIM_FLAG_HEADING = BITMASK(23), - PROP_ANIM_FLAG_DIFFLOCK = BITMASK(24), - PROP_ANIM_FLAG_STEERING = BITMASK(25), - PROP_ANIM_FLAG_EVENT = BITMASK(26), - PROP_ANIM_FLAG_AILERONS = BITMASK(27), - PROP_ANIM_FLAG_ARUDDER = BITMASK(28), - PROP_ANIM_FLAG_BRUDDER = BITMASK(29), - PROP_ANIM_FLAG_BTHROTTLE = BITMASK(30), - PROP_ANIM_FLAG_PERMANENT = BITMASK(31), - PROP_ANIM_FLAG_ELEVATORS = BITMASK(32), -}; - -enum PropAnimMode -{ - PROP_ANIM_MODE_ROTA_X = BITMASK(1), - PROP_ANIM_MODE_ROTA_Y = BITMASK(2), - PROP_ANIM_MODE_ROTA_Z = BITMASK(3), - PROP_ANIM_MODE_OFFSET_X = BITMASK(4), - PROP_ANIM_MODE_OFFSET_Y = BITMASK(5), - PROP_ANIM_MODE_OFFSET_Z = BITMASK(6), - PROP_ANIM_MODE_AUTOANIMATE = BITMASK(7), - PROP_ANIM_MODE_NOFLIP = BITMASK(8), - PROP_ANIM_MODE_BOUNCE = BITMASK(9), -}; +typedef BitMask64_t PropAnimFlag_t; + +const PropAnimFlag_t PROP_ANIM_FLAG_AIRSPEED = BITMASK64(1); +const PropAnimFlag_t PROP_ANIM_FLAG_VVI = BITMASK64(2); +const PropAnimFlag_t PROP_ANIM_FLAG_ALTIMETER = BITMASK64(3); +const PropAnimFlag_t PROP_ANIM_FLAG_AOA = BITMASK64(4); +const PropAnimFlag_t PROP_ANIM_FLAG_FLAP = BITMASK64(5); +const PropAnimFlag_t PROP_ANIM_FLAG_AIRBRAKE = BITMASK64(6); +const PropAnimFlag_t PROP_ANIM_FLAG_ROLL = BITMASK64(7); +const PropAnimFlag_t PROP_ANIM_FLAG_PITCH = BITMASK64(8); +const PropAnimFlag_t PROP_ANIM_FLAG_THROTTLE = BITMASK64(9); +const PropAnimFlag_t PROP_ANIM_FLAG_RPM = BITMASK64(10); +const PropAnimFlag_t PROP_ANIM_FLAG_ACCEL = BITMASK64(11); +const PropAnimFlag_t PROP_ANIM_FLAG_BRAKE = BITMASK64(12); +const PropAnimFlag_t PROP_ANIM_FLAG_CLUTCH = BITMASK64(13); +const PropAnimFlag_t PROP_ANIM_FLAG_TACHO = BITMASK64(14); +const PropAnimFlag_t PROP_ANIM_FLAG_SPEEDO = BITMASK64(15); +const PropAnimFlag_t PROP_ANIM_FLAG_PBRAKE = BITMASK64(16); +const PropAnimFlag_t PROP_ANIM_FLAG_TURBO = BITMASK64(17); +const PropAnimFlag_t PROP_ANIM_FLAG_SHIFTER = BITMASK64(18); //!< 'shifterman1, shifterman2, sequential, shifterlin, autoshifterlin'; animOpt3: see `RoR::ShifterPropAnim` +const PropAnimFlag_t PROP_ANIM_FLAG_AETORQUE = BITMASK64(19); +const PropAnimFlag_t PROP_ANIM_FLAG_AEPITCH = BITMASK64(20); +const PropAnimFlag_t PROP_ANIM_FLAG_AESTATUS = BITMASK64(21); +const PropAnimFlag_t PROP_ANIM_FLAG_TORQUE = BITMASK64(22); +const PropAnimFlag_t PROP_ANIM_FLAG_HEADING = BITMASK64(23); +const PropAnimFlag_t PROP_ANIM_FLAG_DIFFLOCK = BITMASK64(24); +const PropAnimFlag_t PROP_ANIM_FLAG_STEERING = BITMASK64(25); +const PropAnimFlag_t PROP_ANIM_FLAG_EVENT = BITMASK64(26); +const PropAnimFlag_t PROP_ANIM_FLAG_AILERONS = BITMASK64(27); +const PropAnimFlag_t PROP_ANIM_FLAG_ARUDDER = BITMASK64(28); +const PropAnimFlag_t PROP_ANIM_FLAG_BRUDDER = BITMASK64(29); +const PropAnimFlag_t PROP_ANIM_FLAG_BTHROTTLE = BITMASK64(30); +const PropAnimFlag_t PROP_ANIM_FLAG_PERMANENT = BITMASK64(31); +const PropAnimFlag_t PROP_ANIM_FLAG_ELEVATORS = BITMASK64(32); +const PropAnimFlag_t PROP_ANIM_FLAG_GEAR = BITMASK64(33); //!< 'gearreverse' (animOpt3=-1), 'gearneutral' (animOpt3=0), 'gear#' (animOpt3=#) + +typedef BitMask_t PropAnimMode_t; + +const PropAnimMode_t PROP_ANIM_MODE_ROTA_X = BITMASK(1); +const PropAnimMode_t PROP_ANIM_MODE_ROTA_Y = BITMASK(2); +const PropAnimMode_t PROP_ANIM_MODE_ROTA_Z = BITMASK(3); +const PropAnimMode_t PROP_ANIM_MODE_OFFSET_X = BITMASK(4); +const PropAnimMode_t PROP_ANIM_MODE_OFFSET_Y = BITMASK(5); +const PropAnimMode_t PROP_ANIM_MODE_OFFSET_Z = BITMASK(6); +const PropAnimMode_t PROP_ANIM_MODE_AUTOANIMATE = BITMASK(7); +const PropAnimMode_t PROP_ANIM_MODE_NOFLIP = BITMASK(8); +const PropAnimMode_t PROP_ANIM_MODE_BOUNCE = BITMASK(9); -inline PropAnimFlag operator|=(PropAnimFlag& dst, PropAnimFlag const& arg) { dst = static_cast(dst|arg); return dst; } -inline PropAnimMode operator|=(PropAnimMode& dst, PropAnimMode const& arg) { dst = static_cast(dst|arg); return dst; } enum class VideoCamState { @@ -117,25 +114,27 @@ static const int CAMERA_MODE_ALWAYS_HIDDEN = -3; static const int CAMERA_MODE_ALWAYS_VISIBLE = -2; static const int CAMERA_MODE_3RDPERSON_ONLY = -1; -enum ShifterPropAnim +enum ShifterPropAnim //!< `PropAnim::animOpt3` values for PROP_ANIM_FLAG_SHIFTER { SHIFTER_INVALID = 0, SHIFTERMAN1 = 1, SHIFTERMAN2 = 2, SHIFTERSEQ = 3, - SHIFTERLIN = 4 + SHIFTERLIN = 4, + AUTOSHIFTERLIN = 5 }; 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_t animFlags = 0; + PropAnimMode_t animMode = 0; /// MULTIPURPOSE - /// * SHIFTER type `ShifterPropAnim` (1 = shifterman1, 2 = shifterman2, 3 = shifterseq, 4 = shifterlin) + /// * SHIFTER type `ShifterPropAnim` (1 = shifterman1, 2 = shifterman2, 3 = shifterseq, 4 = shifterlin, 5 = autoshifterlin) /// * 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) + /// * GEAR number (-1 = reverse, 0 = neutral, 1+ = forward) float animOpt3 = 0; float animOpt5 = 0; float lower_limit = 0; //!< The lower limit for the animation diff --git a/source/main/physics/ActorSpawner.cpp b/source/main/physics/ActorSpawner.cpp index 9d665580bb..8401f323d7 100644 --- a/source/main/physics/ActorSpawner.cpp +++ b/source/main/physics/ActorSpawner.cpp @@ -1821,19 +1821,23 @@ void ActorSpawner::ProcessProp(RigDef::Prop & def) } if (BITMASK_IS_1(anim_def.source, RigDef::Animation::SOURCE_SHIFT_LEFT_RIGHT)) { BITMASK_SET_1(anim.animFlags, PROP_ANIM_FLAG_SHIFTER); - anim.animOpt3 = 1.0f; + anim.animOpt3 = SHIFTERMAN1; } if (BITMASK_IS_1(anim_def.source, RigDef::Animation::SOURCE_SHIFT_BACK_FORTH)) { BITMASK_SET_1(anim.animFlags, PROP_ANIM_FLAG_SHIFTER); - anim.animOpt3 = 2.0f; + anim.animOpt3 = SHIFTERMAN2; } if (BITMASK_IS_1(anim_def.source, RigDef::Animation::SOURCE_SEQUENTIAL_SHIFT)) { BITMASK_SET_1(anim.animFlags, PROP_ANIM_FLAG_SHIFTER); - anim.animOpt3 = 3.0f; + anim.animOpt3 = SHIFTERSEQ; } if (BITMASK_IS_1(anim_def.source, RigDef::Animation::SOURCE_SHIFTERLIN)) { BITMASK_SET_1(anim.animFlags, PROP_ANIM_FLAG_SHIFTER); - anim.animOpt3 = 4.0f; + anim.animOpt3 = SHIFTERLIN; + } + if (BITMASK_IS_1(anim_def.source, RigDef::Animation::SOURCE_AUTOSHIFTERLIN)) { + BITMASK_SET_1(anim.animFlags, PROP_ANIM_FLAG_SHIFTER); + anim.animOpt3 = AUTOSHIFTERLIN; } if (BITMASK_IS_1(anim_def.source, RigDef::Animation::SOURCE_TORQUE)) { BITMASK_SET_1(anim.animFlags, PROP_ANIM_FLAG_TORQUE); @@ -1865,11 +1869,20 @@ void ActorSpawner::ProcessProp(RigDef::Prop & def) if (BITMASK_IS_1(anim_def.source, RigDef::Animation::SOURCE_PERMANENT)) { BITMASK_SET_1(anim.animFlags, PROP_ANIM_FLAG_PERMANENT); } + if (BITMASK_IS_1(anim_def.source, RigDef::Animation::SOURCE_GEAR_REVERSE)) { + BITMASK_SET_1(anim.animFlags, PROP_ANIM_FLAG_GEAR); + anim.animOpt3 = -1; + } + if (BITMASK_IS_1(anim_def.source, RigDef::Animation::SOURCE_GEAR_NEUTRAL)) { + BITMASK_SET_1(anim.animFlags, PROP_ANIM_FLAG_GEAR); + anim.animOpt3 = 0; + } - /* Motor-indexed sources */ + /* Motor/Gear-indexed sources */ std::list::iterator source_itor = anim_def.motor_sources.begin(); for ( ; source_itor != anim_def.motor_sources.end(); source_itor++) { + // aeroengines if (BITMASK_IS_1(source_itor->source, RigDef::Animation::MotorSource::SOURCE_AERO_THROTTLE)) { BITMASK_SET_1(anim.animFlags, PROP_ANIM_FLAG_THROTTLE); anim.animOpt3 = static_cast(source_itor->motor); @@ -1890,6 +1903,12 @@ void ActorSpawner::ProcessProp(RigDef::Prop & def) BITMASK_SET_1(anim.animFlags, PROP_ANIM_FLAG_AESTATUS); anim.animOpt3 = static_cast(source_itor->motor); } + + // gears (hack) + if (BITMASK_IS_1(source_itor->source, RigDef::Animation::MotorSource::SOURCE_GEAR_FORWARD)) { + BITMASK_SET_1(anim.animFlags, PROP_ANIM_FLAG_GEAR); + anim.animOpt3 = static_cast(source_itor->motor); + } } if (anim.animFlags == 0) { diff --git a/source/main/resources/rig_def_fileformat/RigDef_File.h b/source/main/resources/rig_def_fileformat/RigDef_File.h index 09b98df968..09ddda76b8 100644 --- a/source/main/resources/rig_def_fileformat/RigDef_File.h +++ b/source/main/resources/rig_def_fileformat/RigDef_File.h @@ -478,49 +478,55 @@ struct Animation { struct MotorSource { + // > aeroengines static const BitMask_t SOURCE_AERO_THROTTLE = BITMASK(1); static const BitMask_t SOURCE_AERO_RPM = BITMASK(2); static const BitMask_t SOURCE_AERO_TORQUE = BITMASK(3); static const BitMask_t SOURCE_AERO_PITCH = BITMASK(4); static const BitMask_t SOURCE_AERO_STATUS = BITMASK(5); + // > forward gears (hack...) + static const BitMask_t SOURCE_GEAR_FORWARD = BITMASK(6); BitMask_t source = 0; unsigned int motor = 0; }; // Source flags - static const BitMask_t SOURCE_AIRSPEED = BITMASK( 1); - static const BitMask_t SOURCE_VERTICAL_VELOCITY = BITMASK( 2); - static const BitMask_t SOURCE_ALTIMETER_100K = BITMASK( 3); - static const BitMask_t SOURCE_ALTIMETER_10K = BITMASK( 4); - static const BitMask_t SOURCE_ALTIMETER_1K = BITMASK( 5); - static const BitMask_t SOURCE_ANGLE_OF_ATTACK = BITMASK( 6); - static const BitMask_t SOURCE_FLAP = BITMASK( 7); - static const BitMask_t SOURCE_AIR_BRAKE = BITMASK( 8); - static const BitMask_t SOURCE_ROLL = BITMASK( 9); - static const BitMask_t SOURCE_PITCH = BITMASK(10); - static const BitMask_t SOURCE_BRAKES = BITMASK(11); - static const BitMask_t SOURCE_ACCEL = BITMASK(12); - static const BitMask_t SOURCE_CLUTCH = BITMASK(13); - static const BitMask_t SOURCE_SPEEDO = BITMASK(14); - static const BitMask_t SOURCE_TACHO = BITMASK(15); - static const BitMask_t SOURCE_TURBO = BITMASK(16); - static const BitMask_t SOURCE_PARKING = BITMASK(17); - static const BitMask_t SOURCE_SHIFT_LEFT_RIGHT = BITMASK(18); - static const BitMask_t SOURCE_SHIFT_BACK_FORTH = BITMASK(19); - static const BitMask_t SOURCE_SEQUENTIAL_SHIFT = BITMASK(20); - static const BitMask_t SOURCE_SHIFTERLIN = BITMASK(21); - static const BitMask_t SOURCE_TORQUE = BITMASK(22); - static const BitMask_t SOURCE_HEADING = BITMASK(23); - static const BitMask_t SOURCE_DIFFLOCK = BITMASK(24); - static const BitMask_t SOURCE_BOAT_RUDDER = BITMASK(25); - static const BitMask_t SOURCE_BOAT_THROTTLE = BITMASK(26); - static const BitMask_t SOURCE_STEERING_WHEEL = BITMASK(27); - static const BitMask_t SOURCE_AILERON = BITMASK(28); - static const BitMask_t SOURCE_ELEVATOR = BITMASK(29); - static const BitMask_t SOURCE_AIR_RUDDER = BITMASK(30); - static const BitMask_t SOURCE_PERMANENT = BITMASK(31); - static const BitMask_t SOURCE_EVENT = BITMASK(32); + static const BitMask64_t SOURCE_AIRSPEED = BITMASK64( 1); + static const BitMask64_t SOURCE_VERTICAL_VELOCITY = BITMASK64( 2); + static const BitMask64_t SOURCE_ALTIMETER_100K = BITMASK64( 3); + static const BitMask64_t SOURCE_ALTIMETER_10K = BITMASK64( 4); + static const BitMask64_t SOURCE_ALTIMETER_1K = BITMASK64( 5); + static const BitMask64_t SOURCE_ANGLE_OF_ATTACK = BITMASK64( 6); + static const BitMask64_t SOURCE_FLAP = BITMASK64( 7); + static const BitMask64_t SOURCE_AIR_BRAKE = BITMASK64( 8); + static const BitMask64_t SOURCE_ROLL = BITMASK64( 9); + static const BitMask64_t SOURCE_PITCH = BITMASK64(10); + static const BitMask64_t SOURCE_BRAKES = BITMASK64(11); + static const BitMask64_t SOURCE_ACCEL = BITMASK64(12); + static const BitMask64_t SOURCE_CLUTCH = BITMASK64(13); + static const BitMask64_t SOURCE_SPEEDO = BITMASK64(14); + static const BitMask64_t SOURCE_TACHO = BITMASK64(15); + static const BitMask64_t SOURCE_TURBO = BITMASK64(16); + static const BitMask64_t SOURCE_PARKING = BITMASK64(17); + static const BitMask64_t SOURCE_SHIFT_LEFT_RIGHT = BITMASK64(18); + static const BitMask64_t SOURCE_SHIFT_BACK_FORTH = BITMASK64(19); + static const BitMask64_t SOURCE_SEQUENTIAL_SHIFT = BITMASK64(20); + static const BitMask64_t SOURCE_SHIFTERLIN = BITMASK64(21); + static const BitMask64_t SOURCE_TORQUE = BITMASK64(22); + static const BitMask64_t SOURCE_HEADING = BITMASK64(23); + static const BitMask64_t SOURCE_DIFFLOCK = BITMASK64(24); + static const BitMask64_t SOURCE_BOAT_RUDDER = BITMASK64(25); + static const BitMask64_t SOURCE_BOAT_THROTTLE = BITMASK64(26); + static const BitMask64_t SOURCE_STEERING_WHEEL = BITMASK64(27); + static const BitMask64_t SOURCE_AILERON = BITMASK64(28); + static const BitMask64_t SOURCE_ELEVATOR = BITMASK64(29); + static const BitMask64_t SOURCE_AIR_RUDDER = BITMASK64(30); + static const BitMask64_t SOURCE_PERMANENT = BITMASK64(31); + static const BitMask64_t SOURCE_EVENT = BITMASK64(32); + static const BitMask64_t SOURCE_AUTOSHIFTERLIN = BITMASK64(33); + static const BitMask64_t SOURCE_GEAR_NEUTRAL = BITMASK64(34); + static const BitMask64_t SOURCE_GEAR_REVERSE = BITMASK64(35); // Mode flags static const BitMask_t MODE_ROTATION_X = BITMASK(1); @@ -537,7 +543,7 @@ struct Animation float ratio = 0.f; float lower_limit = -1.f; float upper_limit = -1.f; - BitMask_t source = 0; + BitMask64_t source = 0; std::list motor_sources; BitMask_t mode = 0; Ogre::String event_name; diff --git a/source/main/resources/rig_def_fileformat/RigDef_Parser.cpp b/source/main/resources/rig_def_fileformat/RigDef_Parser.cpp index aa5111ad4d..ef6cd504b6 100644 --- a/source/main/resources/rig_def_fileformat/RigDef_Parser.cpp +++ b/source/main/resources/rig_def_fileformat/RigDef_Parser.cpp @@ -1166,6 +1166,7 @@ void Parser::ParseDirectiveAddAnimation() else if (value == "shifterman2") { animation.source |= Animation::SOURCE_SHIFT_BACK_FORTH; } else if (value == "sequential") { animation.source |= Animation::SOURCE_SEQUENTIAL_SHIFT; } else if (value == "shifterlin") { animation.source |= Animation::SOURCE_SHIFTERLIN; } + else if (value == "autoshifterlin"){ animation.source |= Animation::SOURCE_AUTOSHIFTERLIN; } else if (value == "torque") { animation.source |= Animation::SOURCE_TORQUE; } else if (value == "heading") { animation.source |= Animation::SOURCE_HEADING; } else if (value == "difflock") { animation.source |= Animation::SOURCE_DIFFLOCK; } @@ -1177,10 +1178,13 @@ void Parser::ParseDirectiveAddAnimation() else if (value == "rudderair") { animation.source |= Animation::SOURCE_AIR_RUDDER; } else if (value == "permanent") { animation.source |= Animation::SOURCE_PERMANENT; } else if (value == "event") { animation.source |= Animation::SOURCE_EVENT; } + else if (value == "gearreverse") { animation.source |= Animation::SOURCE_GEAR_REVERSE; } + else if (value == "gearneutral") { animation.source |= Animation::SOURCE_GEAR_NEUTRAL; } else { Animation::MotorSource motor_source; + // aeroengines... if (entry[1].compare(0, 8, "throttle") == 0) { motor_source.source = Animation::MotorSource::SOURCE_AERO_THROTTLE; @@ -1206,6 +1210,12 @@ void Parser::ParseDirectiveAddAnimation() motor_source.source = Animation::MotorSource::SOURCE_AERO_STATUS; motor_source.motor = this->ParseArgUint(entry[1].substr(10)); } + // gears... (hack) + else if (entry[1].compare(0, 4, "gear") == 0) + { + motor_source.source = Animation::MotorSource::SOURCE_GEAR_FORWARD; + motor_source.motor = this->ParseArgUint(entry[1].substr(4)); + } else { snprintf(warn_msg, WARN_LEN, "Invalid 'source': %s, ignoring...", entry[1].c_str()); diff --git a/source/main/utils/BitFlags.h b/source/main/utils/BitFlags.h index fab51089ed..84b8875c69 100644 --- a/source/main/utils/BitFlags.h +++ b/source/main/utils/BitFlags.h @@ -5,8 +5,10 @@ /// @file /// @brief Bit operations typedef uint32_t BitMask_t; +typedef uint64_t BitMask64_t; #define BITMASK( OFFSET ) ( 1 << ((OFFSET) - 1) ) +#define BITMASK64( OFFSET ) ( BitMask64_t(1) << BitMask64_t((OFFSET) - 1) ) #define BITMASK_IS_0( VAR, FLAGS ) ( ((VAR) & (FLAGS)) == 0 ) #define BITMASK_IS_1( VAR, FLAGS ) ( ((VAR) & (FLAGS)) == (FLAGS) )