mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-15 18:57:08 +00:00
Support floating-point animation frame numbers
This commit is contained in:
parent
323fc0a798
commit
06907aa99b
22 changed files with 111 additions and 105 deletions
|
@ -1052,7 +1052,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
|
|||
walking = true;
|
||||
}
|
||||
|
||||
v2s32 new_anim = v2s32(0,0);
|
||||
v2f new_anim(0,0);
|
||||
bool allow_update = false;
|
||||
|
||||
// increase speed if using fast or flying fast
|
||||
|
@ -1799,10 +1799,9 @@ void GenericCAO::processMessage(const std::string &data)
|
|||
phys.speed_walk = override_speed_walk;
|
||||
}
|
||||
} else if (cmd == AO_CMD_SET_ANIMATION) {
|
||||
// TODO: change frames send as v2s32 value
|
||||
v2f range = readV2F32(is);
|
||||
if (!m_is_local_player) {
|
||||
m_animation_range = v2s32((s32)range.X, (s32)range.Y);
|
||||
m_animation_range = range;
|
||||
m_animation_speed = readF32(is);
|
||||
m_animation_blend = readF32(is);
|
||||
// these are sent inverted so we get true when the server sends nothing
|
||||
|
@ -1812,7 +1811,7 @@ void GenericCAO::processMessage(const std::string &data)
|
|||
LocalPlayer *player = m_env->getLocalPlayer();
|
||||
if(player->last_animation == LocalPlayerAnimation::NO_ANIM)
|
||||
{
|
||||
m_animation_range = v2s32((s32)range.X, (s32)range.Y);
|
||||
m_animation_range = range;
|
||||
m_animation_speed = readF32(is);
|
||||
m_animation_blend = readF32(is);
|
||||
// these are sent inverted so we get true when the server sends nothing
|
||||
|
|
|
@ -99,7 +99,7 @@ private:
|
|||
v2s16 m_tx_basepos;
|
||||
bool m_initial_tx_basepos_set = false;
|
||||
bool m_tx_select_horiz_by_yawpitch = false;
|
||||
v2s32 m_animation_range;
|
||||
v2f m_animation_range;
|
||||
float m_animation_speed = 15.0f;
|
||||
float m_animation_blend = 0.0f;
|
||||
bool m_animation_loop = true;
|
||||
|
|
|
@ -157,7 +157,7 @@ void GUIScene::setStyles(const std::array<StyleSpec, StyleSpec::NUM_STATES> &sty
|
|||
/**
|
||||
* Sets the frame loop range for the mesh
|
||||
*/
|
||||
void GUIScene::setFrameLoop(s32 begin, s32 end)
|
||||
void GUIScene::setFrameLoop(f32 begin, f32 end)
|
||||
{
|
||||
if (m_mesh->getStartFrame() != begin || m_mesh->getEndFrame() != end)
|
||||
m_mesh->setFrameLoop(begin, end);
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
scene::IAnimatedMeshSceneNode *setMesh(scene::IAnimatedMesh *mesh = nullptr);
|
||||
void setTexture(u32 idx, video::ITexture *texture);
|
||||
void setBackgroundColor(const video::SColor &color) noexcept { m_bgcolor = color; };
|
||||
void setFrameLoop(s32 begin, s32 end);
|
||||
void setFrameLoop(f32 begin, f32 end);
|
||||
void setAnimationSpeed(f32 speed);
|
||||
void enableMouseControl(bool enable) noexcept { m_mouse_ctrl = enable; };
|
||||
void setRotation(v2f rot) noexcept { m_custom_rot = rot; };
|
||||
|
|
|
@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
|
||||
#include "client/client.h"
|
||||
|
||||
#include "irr_v2d.h"
|
||||
#include "util/base64.h"
|
||||
#include "client/camera.h"
|
||||
#include "client/mesh_generator_thread.h"
|
||||
|
@ -1516,11 +1517,15 @@ void Client::handleCommand_LocalPlayerAnimations(NetworkPacket* pkt)
|
|||
LocalPlayer *player = m_env.getLocalPlayer();
|
||||
assert(player != NULL);
|
||||
|
||||
*pkt >> player->local_animations[0];
|
||||
*pkt >> player->local_animations[1];
|
||||
*pkt >> player->local_animations[2];
|
||||
*pkt >> player->local_animations[3];
|
||||
*pkt >> player->local_animation_speed;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (getProtoVersion() >= 46) {
|
||||
*pkt >> player->local_animations[i];
|
||||
} else {
|
||||
v2s32 local_animation;
|
||||
*pkt >> local_animation;
|
||||
player->local_animations[i] = v2f::from(local_animation);
|
||||
}
|
||||
}
|
||||
|
||||
player->last_animation = LocalPlayerAnimation::NO_ANIM;
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
old servers.
|
||||
Rename TOCLIENT_DEATHSCREEN to TOCLIENT_DEATHSCREEN_LEGACY
|
||||
Rename TOSERVER_RESPAWN to TOSERVER_RESPAWN_LEGACY
|
||||
Support float animation frame numbers in TOCLIENT_LOCAL_PLAYER_ANIMATIONS
|
||||
[scheduled bump for 5.10.0]
|
||||
*/
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ public:
|
|||
f32 movement_liquid_sink;
|
||||
f32 movement_gravity;
|
||||
|
||||
v2s32 local_animations[4];
|
||||
v2f local_animations[4];
|
||||
float local_animation_speed;
|
||||
|
||||
std::string inventory_formspec;
|
||||
|
|
|
@ -113,14 +113,14 @@ public:
|
|||
|
||||
inline void setModified(const bool x) { m_dirty = x; }
|
||||
|
||||
void setLocalAnimations(v2s32 frames[4], float frame_speed)
|
||||
void setLocalAnimations(v2f frames[4], float frame_speed)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
local_animations[i] = frames[i];
|
||||
local_animation_speed = frame_speed;
|
||||
}
|
||||
|
||||
void getLocalAnimations(v2s32 *frames, float *frame_speed)
|
||||
void getLocalAnimations(v2f *frames, float *frame_speed)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
frames[i] = local_animations[i];
|
||||
|
|
|
@ -433,10 +433,10 @@ int ObjectRef::l_set_local_animation(lua_State *L)
|
|||
if (player == nullptr)
|
||||
return 0;
|
||||
|
||||
v2s32 frames[4];
|
||||
v2f frames[4];
|
||||
for (int i=0;i<4;i++) {
|
||||
if (!lua_isnil(L, 2+1))
|
||||
frames[i] = read_v2s32(L, 2+i);
|
||||
frames[i] = read_v2f(L, 2+i);
|
||||
}
|
||||
float frame_speed = readParam<float>(L, 6, 30.0f);
|
||||
|
||||
|
@ -453,12 +453,12 @@ int ObjectRef::l_get_local_animation(lua_State *L)
|
|||
if (player == nullptr)
|
||||
return 0;
|
||||
|
||||
v2s32 frames[4];
|
||||
v2f frames[4];
|
||||
float frame_speed;
|
||||
player->getLocalAnimations(frames, &frame_speed);
|
||||
|
||||
for (const v2s32 &frame : frames) {
|
||||
push_v2s32(L, frame);
|
||||
for (const v2f &frame : frames) {
|
||||
push_v2f(L, frame);
|
||||
}
|
||||
|
||||
lua_pushnumber(L, frame_speed);
|
||||
|
|
|
@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include <iostream>
|
||||
#include <queue>
|
||||
#include <algorithm>
|
||||
#include "irr_v2d.h"
|
||||
#include "network/connection.h"
|
||||
#include "network/networkprotocol.h"
|
||||
#include "network/serveropcodes.h"
|
||||
|
@ -1987,14 +1988,21 @@ void Server::SendPlayerFov(session_t peer_id)
|
|||
Send(&pkt);
|
||||
}
|
||||
|
||||
void Server::SendLocalPlayerAnimations(session_t peer_id, v2s32 animation_frames[4],
|
||||
void Server::SendLocalPlayerAnimations(session_t peer_id, v2f animation_frames[4],
|
||||
f32 animation_speed)
|
||||
{
|
||||
NetworkPacket pkt(TOCLIENT_LOCAL_PLAYER_ANIMATIONS, 0,
|
||||
peer_id);
|
||||
|
||||
pkt << animation_frames[0] << animation_frames[1] << animation_frames[2]
|
||||
<< animation_frames[3] << animation_speed;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (m_clients.getProtocolVersion(peer_id) >= 46) {
|
||||
pkt << animation_frames[i];
|
||||
} else {
|
||||
pkt << v2s32::from(animation_frames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
pkt << animation_speed;
|
||||
|
||||
Send(&pkt);
|
||||
}
|
||||
|
@ -3424,7 +3432,7 @@ Address Server::getPeerAddress(session_t peer_id)
|
|||
}
|
||||
|
||||
void Server::setLocalPlayerAnimations(RemotePlayer *player,
|
||||
v2s32 animation_frames[4], f32 frame_speed)
|
||||
v2f animation_frames[4], f32 frame_speed)
|
||||
{
|
||||
sanity_check(player);
|
||||
player->setLocalAnimations(animation_frames, frame_speed);
|
||||
|
|
|
@ -344,7 +344,7 @@ public:
|
|||
|
||||
Address getPeerAddress(session_t peer_id);
|
||||
|
||||
void setLocalPlayerAnimations(RemotePlayer *player, v2s32 animation_frames[4],
|
||||
void setLocalPlayerAnimations(RemotePlayer *player, v2f animation_frames[4],
|
||||
f32 frame_speed);
|
||||
void setPlayerEyeOffset(RemotePlayer *player, v3f first, v3f third, v3f third_front);
|
||||
|
||||
|
@ -501,7 +501,7 @@ private:
|
|||
virtual void SendChatMessage(session_t peer_id, const ChatMessage &message);
|
||||
void SendTimeOfDay(session_t peer_id, u16 time, f32 time_speed);
|
||||
|
||||
void SendLocalPlayerAnimations(session_t peer_id, v2s32 animation_frames[4],
|
||||
void SendLocalPlayerAnimations(session_t peer_id, v2f animation_frames[4],
|
||||
f32 animation_speed);
|
||||
void SendEyeOffset(session_t peer_id, v3f first, v3f third, v3f third_front);
|
||||
void SendPlayerPrivileges(session_t peer_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue