Skip to content

Commit

Permalink
Use stepheight from CAO instead of hardcoded value
Browse files Browse the repository at this point in the history
  • Loading branch information
Sapier authored and Ekdohibs committed May 6, 2017
1 parent 5ebf8f9 commit 45ab62d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/constants.h
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions src/content_cao.h
Expand Up @@ -154,6 +154,12 @@ class GenericCAO : public ClientActiveObject

scene::IBillboardSceneNode *getSpriteSceneNode();


inline f32 getStepheight() const
{
return m_prop.stepheight;
}

inline bool isPlayer() const
{
return m_is_player;
Expand Down
3 changes: 2 additions & 1 deletion src/content_sao.cpp
Expand Up @@ -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";
Expand All @@ -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;
}

Expand Down
7 changes: 5 additions & 2 deletions src/localplayer.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 45ab62d

Please sign in to comment.