Skip to content

Commit 88ffb3f

Browse files
sapierPilzAdam
sapier
authored andcommittedApr 25, 2013
Move player collisionbox to player class
1 parent 386108f commit 88ffb3f

File tree

4 files changed

+15
-19
lines changed

4 files changed

+15
-19
lines changed
 

‎src/content_sao.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -1472,6 +1472,11 @@ std::string PlayerSAO::getPropertyPacket()
14721472
}
14731473

14741474
bool PlayerSAO::getCollisionBox(aabb3f *toset) {
1475-
//player collision handling is already done clientside no need to do it twice
1476-
return false;
1475+
//update collision box
1476+
*toset = m_player->getCollisionbox();
1477+
1478+
toset->MinEdge += m_base_position;
1479+
toset->MaxEdge += m_base_position;
1480+
1481+
return true;
14771482
}

‎src/localplayer.cpp

+1-16
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,6 @@ void LocalPlayer::move(f32 dtime, ClientEnvironment *env, f32 pos_max_d,
154154
// This should always apply, otherwise there are glitches
155155
assert(d > pos_max_d);
156156

157-
float player_radius = BS*0.30;
158-
float player_height = BS*1.55;
159-
160157
// Maximum distance over border for sneaking
161158
f32 sneak_max = BS*0.4;
162159

@@ -184,24 +181,12 @@ void LocalPlayer::move(f32 dtime, ClientEnvironment *env, f32 pos_max_d,
184181
}
185182
}
186183

187-
/*
188-
Calculate player collision box (new and old)
189-
*/
190-
core::aabbox3d<f32> playerbox(
191-
-player_radius,
192-
0.0,
193-
-player_radius,
194-
player_radius,
195-
player_height,
196-
player_radius
197-
);
198-
199184
float player_stepheight = touching_ground ? (BS*0.6) : (BS*0.2);
200185

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

203188
collisionMoveResult result = collisionMoveSimple(env, m_gamedef,
204-
pos_max_d, playerbox, player_stepheight, dtime,
189+
pos_max_d, m_collisionbox, player_stepheight, dtime,
205190
position, m_speed, accel_f);
206191

207192
/*

‎src/player.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ Player::Player(IGameDef *gamedef):
4242
m_pitch(0),
4343
m_yaw(0),
4444
m_speed(0,0,0),
45-
m_position(0,0,0)
45+
m_position(0,0,0),
46+
m_collisionbox(-BS*0.30,0.0,-BS*0.30,BS*0.30,BS*1.55,BS*0.30)
4647
{
4748
updateName("<not set>");
4849
inventory.clear();

‎src/player.h

+5
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ class Player
180180
return m_name;
181181
}
182182

183+
core::aabbox3d<f32> getCollisionbox() {
184+
return m_collisionbox;
185+
}
186+
183187
virtual bool isLocal() const
184188
{ return false; }
185189
virtual PlayerSAO *getPlayerSAO()
@@ -255,6 +259,7 @@ class Player
255259
f32 m_yaw;
256260
v3f m_speed;
257261
v3f m_position;
262+
core::aabbox3d<f32> m_collisionbox;
258263
};
259264

260265

0 commit comments

Comments
 (0)