From: TeTpaAka Date: Fri, 29 May 2015 18:30:55 +0000 (+0200) Subject: Player collisionbox: Make settable X-Git-Tag: 5.0.0~1009 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=49920cfe8dc7869bb8235c6fe2b8ef26e2a523ca;p=oweals%2Fminetest.git Player collisionbox: Make settable Breaks compatibility with old clients. --- diff --git a/src/content_cao.cpp b/src/content_cao.cpp index 49c2049eb..2cc675573 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -972,7 +972,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env) if (m_is_visible) { int old_anim = player->last_animation; float old_anim_speed = player->last_animation_speed; - m_position = player->getPosition() + v3f(0,BS,0); + m_position = player->getPosition(); m_velocity = v3f(0,0,0); m_acceleration = v3f(0,0,0); pos_translator.vect_show = m_position; @@ -1512,6 +1512,7 @@ void GenericCAO::processMessage(const std::string &data) if (m_is_local_player) { LocalPlayer *player = m_env->getLocalPlayer(); player->makes_footstep_sound = m_prop.makes_footstep_sound; + player->setCollisionbox(m_selection_box); } if ((m_is_player && !m_is_local_player) && m_prop.nametag == "") diff --git a/src/content_sao.cpp b/src/content_sao.cpp index 5bbbd154d..df5cae34f 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -784,7 +784,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.collisionbox = aabb3f(-0.3f, -1.0f, -0.3f, 0.3f, 0.75f, 0.3f); + m_prop.collisionbox = aabb3f(-0.3f, 0.0f, -0.3f, 0.3f, 1.77f, 0.3f); // start of default appearance, this should be overwritten by LUA m_prop.visual = "upright_sprite"; m_prop.visual_size = v2f(1, 2); @@ -856,7 +856,7 @@ std::string PlayerSAO::getClientInitializationData(u16 protocol_version) os << serializeString(m_player->getName()); // name writeU8(os, 1); // is_player writeS16(os, getId()); //id - writeV3F1000(os, m_base_position + v3f(0,BS*1,0)); + writeV3F1000(os, m_base_position); writeF1000(os, m_yaw); writeS16(os, getHP()); @@ -1009,7 +1009,7 @@ void PlayerSAO::step(float dtime, bool send_recommended) if(isAttached()) // Just in case we ever do send attachment position too pos = m_env->getActiveObject(m_attachment_parent_id)->getBasePosition(); else - pos = m_base_position + v3f(0,BS*1,0); + pos = m_base_position; std::string str = gob_cmd_update_position( pos, v3f(0,0,0), @@ -1414,7 +1414,9 @@ bool PlayerSAO::checkMovementCheat() bool PlayerSAO::getCollisionBox(aabb3f *toset) const { - *toset = aabb3f(-0.3f * BS, 0.0f, -0.3f * BS, 0.3f * BS, 1.75f * BS, 0.3f * BS); + //update collision box + toset->MinEdge = m_prop.collisionbox.MinEdge * BS; + toset->MaxEdge = m_prop.collisionbox.MaxEdge * BS; toset->MinEdge += m_base_position; toset->MaxEdge += m_base_position; diff --git a/src/inventorymanager.cpp b/src/inventorymanager.cpp index fe37bcd83..0d44e9cda 100644 --- a/src/inventorymanager.cpp +++ b/src/inventorymanager.cpp @@ -611,8 +611,8 @@ void IDropAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame // Drop the item ItemStack item1 = list_from->getItem(from_i); item1.count = take_count; - if (PLAYER_TO_SA(player)->item_OnDrop(item1, player, - player->getBasePosition() + v3f(0,1,0))) { + if(PLAYER_TO_SA(player)->item_OnDrop(item1, player, + player->getBasePosition())) { actually_dropped_count = take_count - item1.count; if (actually_dropped_count == 0) { @@ -815,7 +815,7 @@ void ICraftAction::apply(InventoryManager *mgr, u16 count = it->count; do { PLAYER_TO_SA(player)->item_OnDrop(*it, player, - player->getBasePosition() + v3f(0,1,0)); + player->getBasePosition()); if (count >= it->count) { errorstream << "Couldn't drop replacement stack " << it->getItemString() << " because drop loop didn't " diff --git a/src/localplayer.h b/src/localplayer.h index 32714ff32..9f7e92128 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -140,6 +140,8 @@ public: v3f getEyePosition() const { return m_position + getEyeOffset(); } v3f getEyeOffset() const; + void setCollisionbox(const aabb3f &box) { m_collisionbox = box; } + private: void accelerateHorizontal(const v3f &target_speed, const f32 max_increase); void accelerateVertical(const v3f &target_speed, const f32 max_increase);