aboutsummaryrefslogtreecommitdiff
path: root/src/camera.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/camera.cpp')
-rw-r--r--src/camera.cpp61
1 files changed, 50 insertions, 11 deletions
diff --git a/src/camera.cpp b/src/camera.cpp
index 0dd0a767b..f227bd98a 100644
--- a/src/camera.cpp
+++ b/src/camera.cpp
@@ -71,7 +71,12 @@ Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control,
m_digging_anim(0),
m_digging_button(-1),
- m_dummymesh(createCubeMesh(v3f(1,1,1)))
+ m_dummymesh(createCubeMesh(v3f(1,1,1))),
+
+ m_wield_change_timer(0.125),
+ m_wield_mesh_next(NULL),
+ m_previous_playeritem(-1),
+ m_previous_itemname("")
{
//dstream<<__FUNCTION_NAME<<std::endl;
@@ -142,6 +147,21 @@ void Camera::step(f32 dtime)
m_view_bobbing_fall = -1; // Mark the effect as finished
}
+ if(m_wield_change_timer < 0.125)
+ m_wield_change_timer += dtime;
+ if(m_wield_change_timer > 0.125)
+ m_wield_change_timer = 0.125;
+
+ if(m_wield_change_timer >= 0 && m_wield_change_timer - dtime < 0) {
+ if(m_wield_mesh_next) {
+ m_wieldnode->setMesh(m_wield_mesh_next);
+ m_wieldnode->setVisible(true);
+ } else {
+ m_wieldnode->setVisible(false);
+ }
+ m_wield_mesh_next = NULL;
+ }
+
if (m_view_bobbing_state != 0)
{
//f32 offset = dtime * m_view_bobbing_speed * 0.035;
@@ -351,6 +371,10 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize,
v3f wield_position = v3f(55, -35, 65);
//v3f wield_rotation = v3f(-100, 120, -100);
v3f wield_rotation = v3f(-100, 120, -100);
+ if(m_wield_change_timer < 0)
+ wield_position.Y -= 40 + m_wield_change_timer*320;
+ else
+ wield_position.Y -= 40 - m_wield_change_timer*320;
if(m_digging_anim < 0.05 || m_digging_anim > 0.5){
f32 frac = 1.0;
if(m_digging_anim > 0.5)
@@ -559,18 +583,33 @@ void Camera::setDigging(s32 button)
m_digging_button = button;
}
-void Camera::wield(const ItemStack &item)
+void Camera::wield(const ItemStack &item, u16 playeritem)
{
IItemDefManager *idef = m_gamedef->idef();
- scene::IMesh *wield_mesh = idef->getWieldMesh(item.getDefinition(idef).name, m_gamedef);
- if(wield_mesh)
- {
- m_wieldnode->setMesh(wield_mesh);
- m_wieldnode->setVisible(true);
- }
- else
- {
- m_wieldnode->setVisible(false);
+ std::string itemname = item.getDefinition(idef).name;
+ m_wield_mesh_next = idef->getWieldMesh(itemname, m_gamedef);
+ if(playeritem != m_previous_playeritem) {
+ m_previous_playeritem = playeritem;
+ m_previous_itemname = itemname;
+ if(m_wield_change_timer >= 0.125)
+ m_wield_change_timer = -0.125;
+ else if(m_wield_change_timer > 0) {
+ m_wield_change_timer = -m_wield_change_timer;
+ }
+ } else {
+ if(m_wield_mesh_next) {
+ m_wieldnode->setMesh(m_wield_mesh_next);
+ m_wieldnode->setVisible(true);
+ } else {
+ m_wieldnode->setVisible(false);
+ }
+ m_wield_mesh_next = NULL;
+ if(m_previous_itemname != itemname) {
+ m_previous_itemname = itemname;
+ m_wield_change_timer = 0;
+ }
+ else
+ m_wield_change_timer = 0.125;
}
}