Use stepheight from CAO instead of hardcoded value

This commit is contained in:
Sapier 2015-12-19 16:37:13 +01:00 committed by Ekdohibs
parent 5ebf8f9450
commit 45ab62d6a3
4 changed files with 19 additions and 3 deletions

@ -90,6 +90,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
// Maximum hit points of a player
#define PLAYER_MAX_HP 20
// Player weight
#define PLAYER_DEFAULT_WEIGHT 75
// Player step height
#define PLAYER_DEFAULT_STEPHEIGHT 0.6f
// Maximal breath of a player
#define PLAYER_MAX_BREATH 11

@ -154,6 +154,12 @@ public:
scene::IBillboardSceneNode *getSpriteSceneNode();
inline f32 getStepheight() const
{
return m_prop.stepheight;
}
inline bool isPlayer() const
{
return m_is_player;

@ -797,7 +797,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, u16 peer_id
m_prop.hp_max = PLAYER_MAX_HP;
m_prop.physical = false;
m_prop.weight = 75;
m_prop.weight = PLAYER_DEFAULT_WEIGHT;
m_prop.collisionbox = aabb3f(-1/3.,-1.0,-1/3., 1/3.,1.0,1/3.);
// start of default appearance, this should be overwritten by LUA
m_prop.visual = "upright_sprite";
@ -811,6 +811,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, u16 peer_id
// end of default appearance
m_prop.is_visible = true;
m_prop.makes_footstep_sound = true;
m_prop.stepheight = PLAYER_DEFAULT_STEPHEIGHT;
m_hp = PLAYER_MAX_HP;
}

@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "environment.h"
#include "map.h"
#include "client.h"
#include "content_cao.h"
/*
LocalPlayer
@ -343,8 +344,10 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
}
}
// TODO: this shouldn't be hardcoded but transmitted from server
float player_stepheight = touching_ground ? (BS*0.6) : (BS*0.2);
float player_stepheight = (m_cao == 0) ? 0.0 :
(touching_ground ?
(m_cao->getStepheight() * BS) :
(m_cao->getStepheight() -0.4 * BS));
#ifdef __ANDROID__
player_stepheight += (0.6 * BS);