Skip to content

Commit b6f4a9c

Browse files
TeTpaAkaShadowNinja
authored andcommittedMay 6, 2017
Make the player collisionbox settable
1 parent 43d1f37 commit b6f4a9c

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed
 

‎doc/lua_api.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -3705,7 +3705,8 @@ Definition tables
37053705
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
37063706
visual = "cube"/"sprite"/"upright_sprite"/"mesh"/"wielditem",
37073707
visual_size = {x=1, y=1},
3708-
mesh = "model",
3708+
mesh = "model", -- for players (0, -1, 0) is ground level,
3709+
-- for all other entities (0, 0, 0) is ground level.
37093710
textures = {}, -- number of required textures depends on visual
37103711
colors = {}, -- number of required colors depends on visual
37113712
spritediv = {x=1, y=1},

‎src/content_cao.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -1585,7 +1585,13 @@ void GenericCAO::processMessage(const std::string &data)
15851585
}
15861586
if (m_is_local_player) {
15871587
LocalPlayer *player = m_env->getLocalPlayer();
1588+
15881589
player->makes_footstep_sound = m_prop.makes_footstep_sound;
1590+
1591+
aabb3f collisionbox = m_selection_box;
1592+
collisionbox.MinEdge += v3f(0, BS, 0);
1593+
collisionbox.MaxEdge += v3f(0, BS, 0);
1594+
player->setCollisionbox(collisionbox);
15891595
}
15901596

15911597
if ((m_is_player && !m_is_local_player) && m_prop.nametag == "")

‎src/content_sao.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,10 @@ bool PlayerSAO::checkMovementCheat()
14291429

14301430
bool PlayerSAO::getCollisionBox(aabb3f *toset) const
14311431
{
1432-
*toset = aabb3f(-BS * 0.30, 0.0, -BS * 0.30, BS * 0.30, BS * 1.75, BS * 0.30);
1432+
//update collision box
1433+
toset->MinEdge = m_prop.collisionbox.MinEdge * BS + v3f(0, BS, 0);
1434+
toset->MaxEdge = m_prop.collisionbox.MaxEdge * BS + v3f(0, BS, 0);
1435+
14331436
toset->MinEdge += m_base_position;
14341437
toset->MaxEdge += m_base_position;
14351438
return true;

‎src/localplayer.h

+2
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ class LocalPlayer : public Player
137137
v3f getEyePosition() const { return m_position + getEyeOffset(); }
138138
v3f getEyeOffset() const;
139139

140+
void setCollisionbox(aabb3f box) { m_collisionbox = box; }
141+
140142
private:
141143
void accelerateHorizontal(const v3f &target_speed, const f32 max_increase);
142144
void accelerateVertical(const v3f &target_speed, const f32 max_increase);

0 commit comments

Comments
 (0)
Please sign in to comment.