diff options
-rw-r--r-- | builtin/falling.lua | 1 | ||||
-rw-r--r-- | builtin/item_entity.lua | 1 | ||||
-rw-r--r-- | doc/lua_api.txt | 1 | ||||
-rw-r--r-- | src/activeobject.h | 1 | ||||
-rw-r--r-- | src/clientobject.h | 1 | ||||
-rw-r--r-- | src/collision.cpp | 8 | ||||
-rw-r--r-- | src/collision.h | 4 | ||||
-rw-r--r-- | src/content_cao.cpp | 7 | ||||
-rw-r--r-- | src/content_sao.cpp | 22 | ||||
-rw-r--r-- | src/content_sao.h | 2 | ||||
-rw-r--r-- | src/object_properties.cpp | 4 | ||||
-rw-r--r-- | src/object_properties.h | 1 | ||||
-rw-r--r-- | src/script/common/c_content.cpp | 1 | ||||
-rw-r--r-- | src/script/cpp_api/s_entity.cpp | 1 |
14 files changed, 50 insertions, 5 deletions
diff --git a/builtin/falling.lua b/builtin/falling.lua index 5ee693298..73087803f 100644 --- a/builtin/falling.lua +++ b/builtin/falling.lua @@ -7,6 +7,7 @@ minetest.register_entity("__builtin:falling_node", { initial_properties = { physical = true, + collide_with_objects = false, collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, visual = "wielditem", textures = {}, diff --git a/builtin/item_entity.lua b/builtin/item_entity.lua index c682db2fa..95affe3da 100644 --- a/builtin/item_entity.lua +++ b/builtin/item_entity.lua @@ -12,6 +12,7 @@ minetest.register_entity("__builtin:item", { initial_properties = { hp_max = 1, physical = true, + collide_with_objects = false, collisionbox = {-0.17,-0.17,-0.17, 0.17,0.17,0.17}, visual = "sprite", visual_size = {x=0.5, y=0.5}, diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 1e6d3ffc6..0ee3b2d91 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -1812,6 +1812,7 @@ Object Properties { hp_max = 1, physical = true, + collide_with_objects = true, -- collide with other objects if physical=true weight = 5, collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, visual = "cube"/"sprite"/"upright_sprite"/"mesh", diff --git a/src/activeobject.h b/src/activeobject.h index 1a75fba2e..f4d721a55 100644 --- a/src/activeobject.h +++ b/src/activeobject.h @@ -62,6 +62,7 @@ public: virtual u8 getType() const = 0; virtual bool getCollisionBox(aabb3f *toset) = 0; + virtual bool collideWithObjects() = 0; protected: u16 m_id; // 0 is invalid, "no id" }; diff --git a/src/clientobject.h b/src/clientobject.h index 8cbf3d60b..fb5cb29f4 100644 --- a/src/clientobject.h +++ b/src/clientobject.h @@ -56,6 +56,7 @@ public: virtual v3s16 getLightPosition(){return v3s16(0,0,0);} virtual core::aabbox3d<f32>* getSelectionBox(){return NULL;} virtual core::aabbox3d<f32>* getCollisionBox(){return NULL;} + virtual bool collideWithObjects(){return false;} virtual v3f getPosition(){return v3f(0,0,0);} virtual scene::IMeshSceneNode *getMeshSceneNode(){return NULL;} virtual scene::IAnimatedMeshSceneNode *getAnimatedMeshSceneNode(){return NULL;} diff --git a/src/collision.cpp b/src/collision.cpp index 0c67abe8c..76696e90d 100644 --- a/src/collision.cpp +++ b/src/collision.cpp @@ -196,7 +196,9 @@ bool wouldCollideWithCeiling( collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef, f32 pos_max_d, const aabb3f &box_0, f32 stepheight, f32 dtime, - v3f &pos_f, v3f &speed_f, v3f &accel_f,ActiveObject* self) + v3f &pos_f, v3f &speed_f, + v3f &accel_f,ActiveObject* self, + bool collideWithObjects) { Map *map = &env->getMap(); //TimeTaker tt("collisionMoveSimple"); @@ -287,6 +289,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef, } } // tt2 + if(collideWithObjects) { ScopeProfiler sp(g_profiler, "collisionMoveSimple objects avg", SPT_AVG); //TimeTaker tt3("collisionMoveSimple collect object boxes"); @@ -334,7 +337,8 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef, if (object != NULL) { aabb3f object_collisionbox; - if (object->getCollisionBox(&object_collisionbox)) + if (object->getCollisionBox(&object_collisionbox) && + object->collideWithObjects()) { cboxes.push_back(object_collisionbox); is_unloaded.push_back(false); diff --git a/src/collision.h b/src/collision.h index 77bf1f15d..32086aae3 100644 --- a/src/collision.h +++ b/src/collision.h @@ -71,7 +71,9 @@ struct collisionMoveResult collisionMoveResult collisionMoveSimple(Environment *env,IGameDef *gamedef, f32 pos_max_d, const aabb3f &box_0, f32 stepheight, f32 dtime, - v3f &pos_f, v3f &speed_f, v3f &accel_f,ActiveObject* self=0); + v3f &pos_f, v3f &speed_f, + v3f &accel_f,ActiveObject* self=0, + bool collideWithObjects=true); #if 0 // This doesn't seem to work and isn't used diff --git a/src/content_cao.cpp b/src/content_cao.cpp index 7c7699242..925855288 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -661,6 +661,10 @@ public: return false; } + bool collideWithObjects() { + return m_prop.collideWithObjects; + } + void initialize(const std::string &data) { infostream<<"GenericCAO: Got init data"<<std::endl; @@ -1152,7 +1156,8 @@ public: v3f p_acceleration = m_acceleration; moveresult = collisionMoveSimple(env,env->getGameDef(), pos_max_d, box, stepheight, dtime, - p_pos, p_velocity, p_acceleration,this); + p_pos, p_velocity, p_acceleration, + this, m_prop.collideWithObjects); // Apply results m_position = p_pos; m_velocity = p_velocity; diff --git a/src/content_sao.cpp b/src/content_sao.cpp index 993859f1c..6b3593ec7 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -68,6 +68,10 @@ public: return false; } + bool collideWithObjects() { + return false; + } + private: }; @@ -140,6 +144,10 @@ public: return false; } + bool collideWithObjects() { + return false; + } + private: float m_timer1; float m_age; @@ -325,6 +333,9 @@ public: return false; } + bool collideWithObjects() { + return false; + } private: std::string m_itemstring; @@ -500,7 +511,8 @@ void LuaEntitySAO::step(float dtime, bool send_recommended) v3f p_acceleration = m_acceleration; moveresult = collisionMoveSimple(m_env,m_env->getGameDef(), pos_max_d, box, stepheight, dtime, - p_pos, p_velocity, p_acceleration,this); + p_pos, p_velocity, p_acceleration, + this, m_prop.collideWithObjects); // Apply results m_base_position = p_pos; m_velocity = p_velocity; @@ -905,6 +917,10 @@ bool LuaEntitySAO::getCollisionBox(aabb3f *toset) { return false; } +bool LuaEntitySAO::collideWithObjects(){ + return m_prop.collideWithObjects; +} + /* PlayerSAO */ @@ -1496,3 +1512,7 @@ bool PlayerSAO::getCollisionBox(aabb3f *toset) { return true; } + +bool PlayerSAO::collideWithObjects(){ + return true; +} diff --git a/src/content_sao.h b/src/content_sao.h index bfce83d02..140211cf6 100644 --- a/src/content_sao.h +++ b/src/content_sao.h @@ -79,6 +79,7 @@ public: bool select_horiz_by_yawpitch); std::string getName(); bool getCollisionBox(aabb3f *toset); + bool collideWithObjects(); private: std::string getPropertyPacket(); void sendPosition(bool do_interpolate, bool is_movement_end); @@ -238,6 +239,7 @@ public: } bool getCollisionBox(aabb3f *toset); + bool collideWithObjects(); private: std::string getPropertyPacket(); diff --git a/src/object_properties.cpp b/src/object_properties.cpp index 6086bf09f..c2debf328 100644 --- a/src/object_properties.cpp +++ b/src/object_properties.cpp @@ -29,6 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc., ObjectProperties::ObjectProperties(): hp_max(1), physical(false), + collideWithObjects(true), weight(5), collisionbox(-0.5,-0.5,-0.5, 0.5,0.5,0.5), visual("sprite"), @@ -49,6 +50,7 @@ std::string ObjectProperties::dump() std::ostringstream os(std::ios::binary); os<<"hp_max="<<hp_max; os<<", physical="<<physical; + os<<", collideWithObjects="<<collideWithObjects; os<<", weight="<<weight; os<<", collisionbox="<<PP(collisionbox.MinEdge)<<","<<PP(collisionbox.MaxEdge); os<<", visual="<<visual; @@ -97,6 +99,7 @@ void ObjectProperties::serialize(std::ostream &os) const for(u32 i=0; i<colors.size(); i++){ writeARGB8(os, colors[i]); } + writeU8(os, collideWithObjects); // Add stuff only at the bottom. // Never remove anything, because we don't want new versions of this } @@ -129,6 +132,7 @@ void ObjectProperties::deSerialize(std::istream &is) for(u32 i=0; i<color_count; i++){ colors.push_back(readARGB8(is)); } + collideWithObjects = readU8(is); }catch(SerializationError &e){} } else diff --git a/src/object_properties.h b/src/object_properties.h index eeb397efa..a0f5618d6 100644 --- a/src/object_properties.h +++ b/src/object_properties.h @@ -31,6 +31,7 @@ struct ObjectProperties // Values are BS=1 s16 hp_max; bool physical; + bool collideWithObjects; float weight; core::aabbox3d<f32> collisionbox; std::string visual; diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index 7d18454fd..dcffabb8b 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -123,6 +123,7 @@ void read_object_properties(lua_State *L, int index, prop->hp_max = getintfield_default(L, -1, "hp_max", 10); getboolfield(L, -1, "physical", prop->physical); + getboolfield(L, -1, "collide_with_objects", prop->collideWithObjects); getfloatfield(L, -1, "weight", prop->weight); diff --git a/src/script/cpp_api/s_entity.cpp b/src/script/cpp_api/s_entity.cpp index 2a5a6066d..c494e8232 100644 --- a/src/script/cpp_api/s_entity.cpp +++ b/src/script/cpp_api/s_entity.cpp @@ -169,6 +169,7 @@ void ScriptApiEntity::luaentity_GetProperties(u16 id, prop->hp_max = getintfield_default(L, -1, "hp_max", 10); getboolfield(L, -1, "physical", prop->physical); + getboolfield(L, -1, "collide_with_objects", prop->collideWithObjects); getfloatfield(L, -1, "weight", prop->weight); |