aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsapier <Sapier at GMX dot net>2013-04-17 00:15:53 +0200
committerPilzAdam <pilzadam@minetest.net>2013-04-25 18:53:50 +0200
commit88ffb3f73bb16c6680ee10a8e804a699e366edd8 (patch)
tree991091a87b4e588c847f14fea7d181560667caa5 /src
parent386108f982e3d0819f6a153d750f967c0b25268c (diff)
downloadminetest-88ffb3f73bb16c6680ee10a8e804a699e366edd8.tar.gz
minetest-88ffb3f73bb16c6680ee10a8e804a699e366edd8.tar.bz2
minetest-88ffb3f73bb16c6680ee10a8e804a699e366edd8.zip
Move player collisionbox to player class
Diffstat (limited to 'src')
-rw-r--r--src/content_sao.cpp9
-rw-r--r--src/localplayer.cpp17
-rw-r--r--src/player.cpp3
-rw-r--r--src/player.h5
4 files changed, 15 insertions, 19 deletions
diff --git a/src/content_sao.cpp b/src/content_sao.cpp
index 3526ecbd2..24a9186f7 100644
--- a/src/content_sao.cpp
+++ b/src/content_sao.cpp
@@ -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;
}
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 6b7b0943c..13117d881 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -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;
@@ -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);
/*
diff --git a/src/player.cpp b/src/player.cpp
index e86b64206..d3e16810f 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -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();
diff --git a/src/player.h b/src/player.h
index 4e5b3af97..fade6de01 100644
--- a/src/player.h
+++ b/src/player.h
@@ -180,6 +180,10 @@ public:
return m_name;
}
+ core::aabbox3d<f32> getCollisionbox() {
+ return m_collisionbox;
+ }
+
virtual bool isLocal() const
{ return false; }
virtual PlayerSAO *getPlayerSAO()
@@ -255,6 +259,7 @@ protected:
f32 m_yaw;
v3f m_speed;
v3f m_position;
+ core::aabbox3d<f32> m_collisionbox;
};