Skip to content

Commit

Permalink
FIXUP - fixed idle, walk, run
Browse files Browse the repository at this point in the history
  • Loading branch information
ohlidalp committed Sep 24, 2022
1 parent 88976c3 commit 6e20061
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
18 changes: 16 additions & 2 deletions source/main/gameplay/CharacterFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,29 @@ CharacterFactory::CharacterFactory()
rorbot->anims.push_back(def);
}

{ // walking
{ // walking forward
CharacterAnimDef def;
BITMASK_SET_1(def.except_situations, Character::SITUATION_IN_DEEP_WATER);
BITMASK_SET_1(def.except_situations, Character::SITUATION_DRIVING);
BITMASK_SET_1(def.for_actions, Character::ACTION_MOVE_FORWARD);
BITMASK_SET_1(def.for_actions, Character::ACTION_MOVE_BACKWARD);
BITMASK_SET_1(def.except_actions, Character::ACTION_RUN);
def.anim_name = "Walk";
def.playback_time_ratio = 1.f;
def.playback_h_speed_ratio = 1.f;
rorbot->anims.push_back(def);
}

{ // walking backward
CharacterAnimDef def;
BITMASK_SET_1(def.except_situations, Character::SITUATION_IN_DEEP_WATER);
BITMASK_SET_1(def.except_situations, Character::SITUATION_DRIVING);
BITMASK_SET_1(def.for_actions, Character::ACTION_MOVE_BACKWARD);
def.anim_name = "Walk";
def.playback_time_ratio = -1.f;
def.playback_h_speed_ratio = 1.f;
rorbot->anims.push_back(def);
}

{ // side stepping left (-time)
CharacterAnimDef def;
BITMASK_SET_1(def.except_situations, Character::SITUATION_IN_DEEP_WATER);
Expand All @@ -115,6 +125,8 @@ CharacterFactory::CharacterFactory()
BITMASK_SET_1(def.for_actions, Character::ACTION_SIDESTEP_RIGHT);
BITMASK_SET_1(def.except_actions, Character::ACTION_MOVE_FORWARD);
BITMASK_SET_1(def.except_actions, Character::ACTION_MOVE_BACKWARD);
BITMASK_SET_1(def.except_actions, Character::ACTION_TURN_RIGHT);
BITMASK_SET_1(def.except_actions, Character::ACTION_TURN_LEFT);
BITMASK_SET_1(def.except_actions, Character::ACTION_RUN);
def.anim_name = "Side_step";
def.playback_time_ratio = 1.f;
Expand All @@ -128,6 +140,8 @@ CharacterFactory::CharacterFactory()
BITMASK_SET_1(def.for_actions, Character::ACTION_SIDESTEP_LEFT);
BITMASK_SET_1(def.except_actions, Character::ACTION_MOVE_FORWARD);
BITMASK_SET_1(def.except_actions, Character::ACTION_MOVE_BACKWARD);
BITMASK_SET_1(def.except_actions, Character::ACTION_TURN_RIGHT);
BITMASK_SET_1(def.except_actions, Character::ACTION_TURN_LEFT);
BITMASK_SET_1(def.except_actions, Character::ACTION_RUN);
def.anim_name = "Side_step";
def.playback_time_ratio = -1.f;
Expand Down
18 changes: 13 additions & 5 deletions source/main/gfx/GfxCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,11 @@ void RoR::GfxCharacter::UpdateCharacterInScene(float dt)
void GfxCharacter::EvaluateAnimDef(CharacterAnimDef const& def, float dt)
{
// Test if applicable.
if ((def.for_situations != 0 && BITMASK_IS_0(xc_simbuf.simbuf_situation_flags, def.for_situations)) || // some situations are specified, but none of the situations matches
if (//(def.for_situations != 0 && BITMASK_IS_0(xc_simbuf.simbuf_situation_flags, def.for_situations)) || // some situations are specified, but none of the situations matches
(!BITMASK_IS_1(xc_simbuf.simbuf_situation_flags, def.for_situations)) || // not all situation flags are satisified
(xc_simbuf.simbuf_situation_flags & def.except_situations) || // any of the forbidden situation matches
(def.for_actions != 0 && BITMASK_IS_0(xc_simbuf.simbuf_action_flags, def.for_actions)) || // some actions are specified, but none of the actions matches
//(def.for_actions != 0 && BITMASK_IS_0(xc_simbuf.simbuf_action_flags, def.for_actions)) || // some actions are specified, but none of the actions matches
(!BITMASK_IS_1(xc_simbuf.simbuf_action_flags, def.for_actions)) || // not all action flags are satisfied
(xc_simbuf.simbuf_action_flags & def.except_actions)) // any of the forbidden situation matches
{
return;
Expand All @@ -202,9 +204,15 @@ void GfxCharacter::EvaluateAnimDef(CharacterAnimDef const& def, float dt)

// Query data sources.
float timepos = 1.f;
timepos *= (def.playback_time_ratio * dt);
timepos *= (def.playback_h_speed_ratio * xc_simbuf.simbuf_character_h_speed);
if (xc_simbuf.simbuf_actor_coupling)
if (def.playback_time_ratio > 0.f)
{
timepos *= (def.playback_time_ratio * dt);
}
if (def.playback_h_speed_ratio > 0.f)
{
timepos *= (def.playback_h_speed_ratio * xc_simbuf.simbuf_character_h_speed);
}
if (def.playback_steering_ratio > 0.f && xc_simbuf.simbuf_actor_coupling)
{
timepos *= (def.playback_steering_ratio * xc_simbuf.simbuf_actor_coupling->ar_hydro_dir_wheel_display);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ struct CharacterAnimDef
std::string description; //!< Internal game name.

// Conditions
BitMask_t for_situations = 0; //!< Character::SITUATION_
BitMask_t except_situations = 0; //!< Character::SITUATION_
BitMask_t for_actions = 0; //!< Character::ACTION_
BitMask_t except_actions = 0; //!< Character::ACTION_
BitMask_t for_situations = 0; //!< Character::SITUATION_, all must be satisfied.
BitMask_t except_situations = 0; //!< Character::SITUATION_, none must be satisfied.
BitMask_t for_actions = 0; //!< Character::ACTION_, all must be satisfied.
BitMask_t except_actions = 0; //!< Character::ACTION_, none must be satisfied.

// Anim position calculation
float playback_time_ratio = 0.f; //!< How much elapsed time affects animation position.
Expand Down

0 comments on commit 6e20061

Please sign in to comment.