v2s16 m_tx_basepos;
bool m_initial_tx_basepos_set;
bool m_tx_select_horiz_by_yawpitch;
- v2f m_animation_range;
+ v2s32 m_animation_range;
int m_animation_speed;
int m_animation_blend;
std::map<std::string, core::vector2d<v3f> > m_bone_position; // stores position and rotation for each bone name
m_tx_basepos(0,0),
m_initial_tx_basepos_set(false),
m_tx_select_horiz_by_yawpitch(false),
- m_animation_range(v2f(0,0)),
+ m_animation_range(v2s32(0,0)),
m_animation_speed(15),
m_animation_blend(0),
m_bone_position(std::map<std::string, core::vector2d<v3f> >()),
if(controls.up || controls.down || controls.left || controls.right)
walking = true;
- m_animation_speed = player->local_animation_speed;
+ f32 new_speed = player->local_animation_speed;
+ v2s32 new_anim = v2s32(0,0);
+ bool allow_update = false;
+
if(!player->touching_ground &&
g_settings->getBool("free_move") &&
m_gamedef->checkLocalPrivilege("fly") &&
g_settings->getBool("fast_move") &&
m_gamedef->checkLocalPrivilege("fast"))
- m_animation_speed *= 1.5;
+ new_speed *= 1.5;
if(controls.sneak && walking)
- m_animation_speed /= 2;
-
- player->last_animation_speed = m_animation_speed;
+ new_speed /= 2;
if(walking && (controls.LMB || controls.RMB)) {
- m_animation_range = player->local_animations[3];
+ new_anim = player->local_animations[3];
player->last_animation = WD_ANIM;
} else if(walking) {
- m_animation_range = player->local_animations[1];
+ new_anim = player->local_animations[1];
player->last_animation = WALK_ANIM;
} else if(controls.LMB || controls.RMB) {
- m_animation_range = player->local_animations[2];
+ new_anim = player->local_animations[2];
player->last_animation = DIG_ANIM;
}
+ if ((new_anim.X + new_anim.Y) > 0) {
+ allow_update = true;
+ m_animation_range = new_anim;
+ m_animation_speed = new_speed;
+ player->last_animation_speed = m_animation_speed;
+ } else {
+ player->last_animation = NO_ANIM;
+ }
// reset animation when no input detected
if (!walking && !controls.LMB && !controls.RMB) {
player->last_animation = NO_ANIM;
if (old_anim != NO_ANIM) {
m_animation_range = player->local_animations[0];
- updateAnimation();
+ updateAnimation();
}
}
// Update local player animations
- if ((player->last_animation != old_anim && player->last_animation != NO_ANIM) || m_animation_speed != old_anim_speed)
- updateAnimation();
+ if ((player->last_animation != old_anim || m_animation_speed != old_anim_speed) &&
+ player->last_animation != NO_ANIM && allow_update)
+ updateAnimation();
} else {
m_is_visible = false;
{
if(m_animated_meshnode == NULL)
return;
-
- m_animated_meshnode->setFrameLoop((int)m_animation_range.X, (int)m_animation_range.Y);
+ m_animated_meshnode->setFrameLoop(m_animation_range.X, m_animation_range.Y);
m_animated_meshnode->setAnimationSpeed(m_animation_speed);
m_animated_meshnode->setTransitionTime(m_animation_blend);
}
}
else if(cmd == GENERIC_CMD_SET_ANIMATION)
{
- if (!m_is_local_player) {
- m_animation_range = readV2F1000(is);
+ // TODO: change frames send as v2s32 value
+ v2f range = readV2F1000(is);
+ if (!m_is_local_player) {
+ m_animation_range = v2s32((s32)range.X, (s32)range.Y);
m_animation_speed = readF1000(is);
m_animation_blend = readF1000(is);
updateAnimation();
} else {
LocalPlayer *player = m_env->getLocalPlayer();
if(player->last_animation == NO_ANIM) {
- m_animation_range = readV2F1000(is);
+ m_animation_range = v2s32((s32)range.X, (s32)range.Y);
m_animation_speed = readF1000(is);
m_animation_blend = readF1000(is);
}
- // update animation only if object is not player
- // or the received animation is not registered
- if(m_animation_range.X != player->local_animations[1].X &&
- m_animation_range.X != player->local_animations[2].X &&
- m_animation_range.X != player->local_animations[3].X)
+ // update animation only if local animations present
+ // and received animation is not unknown
+ int frames = 0;
+ for (int i = 0;i<4;i++) {
+ frames += (int)player->local_animations[i].Y;
+ }
+ if(frames < 1) {
+ player->last_animation = NO_ANIM;
updateAnimation();
+ }
}
}
else if(cmd == GENERIC_CMD_SET_BONE_POSITION)
m_clients.send(peer_id, 0, data, true);
}
-void Server::SendLocalPlayerAnimations(u16 peer_id, v2f animation_frames[4], f32 animation_speed)
+void Server::SendLocalPlayerAnimations(u16 peer_id, v2s32 animation_frames[4], f32 animation_speed)
{
std::ostringstream os(std::ios_base::binary);
writeU16(os, TOCLIENT_LOCAL_PLAYER_ANIMATIONS);
- writeV2F1000(os, animation_frames[0]);
- writeV2F1000(os, animation_frames[1]);
- writeV2F1000(os, animation_frames[2]);
- writeV2F1000(os, animation_frames[3]);
+ writeV2S32(os, animation_frames[0]);
+ writeV2S32(os, animation_frames[1]);
+ writeV2S32(os, animation_frames[2]);
+ writeV2S32(os, animation_frames[3]);
writeF1000(os, animation_speed);
// Make data buffer
SendHUDSetParam(player->peer_id, HUD_PARAM_HOTBAR_SELECTED_IMAGE, name);
}
-bool Server::setLocalPlayerAnimations(Player *player, v2f animation_frames[4], f32 frame_speed)
+bool Server::setLocalPlayerAnimations(Player *player, v2s32 animation_frames[4], f32 frame_speed)
{
if (!player)
return false;
inline Address getPeerAddress(u16 peer_id)
{ return m_con.GetPeerAddress(peer_id); }
- bool setLocalPlayerAnimations(Player *player, v2f animation_frames[4], f32 frame_speed);
+ bool setLocalPlayerAnimations(Player *player, v2s32 animation_frames[4], f32 frame_speed);
bool setPlayerEyeOffset(Player *player, v3f first, v3f third);
bool setSky(Player *player, const video::SColor &bgcolor,
void SendPlayerHP(u16 peer_id);
void SendPlayerBreath(u16 peer_id);
void SendMovePlayer(u16 peer_id);
- void SendLocalPlayerAnimations(u16 peer_id, v2f animation_frames[4], f32 animation_speed);
+ void SendLocalPlayerAnimations(u16 peer_id, v2s32 animation_frames[4], f32 animation_speed);
void SendEyeOffset(u16 peer_id, v3f first, v3f third);
void SendPlayerPrivileges(u16 peer_id);
void SendPlayerInventoryFormspec(u16 peer_id);