Skip to content

Commit

Permalink
Move player collisionbox to player class
Browse files Browse the repository at this point in the history
  • Loading branch information
sapier authored and PilzAdam committed Apr 25, 2013
1 parent 386108f commit 88ffb3f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
9 changes: 7 additions & 2 deletions src/content_sao.cpp
Expand Up @@ -1472,6 +1472,11 @@ std::string PlayerSAO::getPropertyPacket()
}

bool PlayerSAO::getCollisionBox(aabb3f *toset) {
//player collision handling is already done clientside no need to do it twice
return false;
//update collision box
*toset = m_player->getCollisionbox();

toset->MinEdge += m_base_position;
toset->MaxEdge += m_base_position;

return true;
}
17 changes: 1 addition & 16 deletions src/localplayer.cpp
Expand Up @@ -154,9 +154,6 @@ void LocalPlayer::move(f32 dtime, ClientEnvironment *env, f32 pos_max_d,
// This should always apply, otherwise there are glitches
assert(d > pos_max_d);

float player_radius = BS*0.30;
float player_height = BS*1.55;

// Maximum distance over border for sneaking
f32 sneak_max = BS*0.4;

Expand Down Expand Up @@ -184,24 +181,12 @@ void LocalPlayer::move(f32 dtime, ClientEnvironment *env, f32 pos_max_d,
}
}

/*
Calculate player collision box (new and old)
*/
core::aabbox3d<f32> playerbox(
-player_radius,
0.0,
-player_radius,
player_radius,
player_height,
player_radius
);

float player_stepheight = touching_ground ? (BS*0.6) : (BS*0.2);

v3f accel_f = v3f(0,0,0);

collisionMoveResult result = collisionMoveSimple(env, m_gamedef,
pos_max_d, playerbox, player_stepheight, dtime,
pos_max_d, m_collisionbox, player_stepheight, dtime,
position, m_speed, accel_f);

/*
Expand Down
3 changes: 2 additions & 1 deletion src/player.cpp
Expand Up @@ -42,7 +42,8 @@ Player::Player(IGameDef *gamedef):
m_pitch(0),
m_yaw(0),
m_speed(0,0,0),
m_position(0,0,0)
m_position(0,0,0),
m_collisionbox(-BS*0.30,0.0,-BS*0.30,BS*0.30,BS*1.55,BS*0.30)
{
updateName("<not set>");
inventory.clear();
Expand Down
5 changes: 5 additions & 0 deletions src/player.h
Expand Up @@ -180,6 +180,10 @@ class Player
return m_name;
}

core::aabbox3d<f32> getCollisionbox() {
return m_collisionbox;
}

virtual bool isLocal() const
{ return false; }
virtual PlayerSAO *getPlayerSAO()
Expand Down Expand Up @@ -255,6 +259,7 @@ class Player
f32 m_yaw;
v3f m_speed;
v3f m_position;
core::aabbox3d<f32> m_collisionbox;
};


Expand Down

0 comments on commit 88ffb3f

Please sign in to comment.