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 = {},
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},
{
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",
virtual u8 getType() const = 0;
virtual bool getCollisionBox(aabb3f *toset) = 0;
+ virtual bool collideWithObjects() = 0;
protected:
u16 m_id; // 0 is invalid, "no id"
};
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;}
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");
}
} // tt2
+ if(collideWithObjects)
{
ScopeProfiler sp(g_profiler, "collisionMoveSimple objects avg", SPT_AVG);
//TimeTaker tt3("collisionMoveSimple collect object boxes");
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);
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
return false;
}
+ bool collideWithObjects() {
+ return m_prop.collideWithObjects;
+ }
+
void initialize(const std::string &data)
{
infostream<<"GenericCAO: Got init data"<<std::endl;
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;
return false;
}
+ bool collideWithObjects() {
+ return false;
+ }
+
private:
};
return false;
}
+ bool collideWithObjects() {
+ return false;
+ }
+
private:
float m_timer1;
float m_age;
return false;
}
+ bool collideWithObjects() {
+ return false;
+ }
private:
std::string m_itemstring;
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;
return false;
}
+bool LuaEntitySAO::collideWithObjects(){
+ return m_prop.collideWithObjects;
+}
+
/*
PlayerSAO
*/
return true;
}
+
+bool PlayerSAO::collideWithObjects(){
+ return true;
+}
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);
}
bool getCollisionBox(aabb3f *toset);
+ bool collideWithObjects();
private:
std::string getPropertyPacket();
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"),
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;
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
}
for(u32 i=0; i<color_count; i++){
colors.push_back(readARGB8(is));
}
+ collideWithObjects = readU8(is);
}catch(SerializationError &e){}
}
else
// Values are BS=1
s16 hp_max;
bool physical;
+ bool collideWithObjects;
float weight;
core::aabbox3d<f32> collisionbox;
std::string visual;
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);
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);