collide_with_objects = true, -- collide with other objects if physical = true
weight = 5,
collisionbox = {-0.5, 0.0, -0.5, 0.5, 1.0, 0.5},
+ selectionbox = {-0.5, 0.0, -0.5, 0.5, 1.0, 0.5},
+ -- ^ Default, uses collision box dimensions when not set
+ pointable = true, -- overrides selection box when false
visual = "cube" / "sprite" / "upright_sprite" / "mesh" / "wielditem",
visual_size = {x = 1, y = 1},
mesh = "model",
bool GenericCAO::getSelectionBox(aabb3f *toset) const
{
if (!m_prop.is_visible || !m_is_visible || m_is_local_player
- || getParent() != NULL){
+ || !m_prop.pointable || getParent() != NULL) {
return false;
}
*toset = m_selection_box;
if (cmd == GENERIC_CMD_SET_PROPERTIES) {
m_prop = gob_read_set_properties(is);
- m_selection_box = m_prop.collisionbox;
+ m_selection_box = m_prop.selectionbox;
m_selection_box.MinEdge *= BS;
m_selection_box.MaxEdge *= BS;
if (m_is_local_player) {
LocalPlayer *player = m_env->getLocalPlayer();
player->makes_footstep_sound = m_prop.makes_footstep_sound;
- player->setCollisionbox(m_selection_box);
+ aabb3f collision_box = m_prop.collisionbox;
+ collision_box.MinEdge *= BS;
+ collision_box.MaxEdge *= BS;
+ player->setCollisionbox(collision_box);
}
if ((m_is_player && !m_is_local_player) && m_prop.nametag.empty())
bool LuaEntitySAO::getSelectionBox(aabb3f *toset) const
{
- if (!m_prop.is_visible) {
+ if (!m_prop.is_visible || !m_prop.pointable) {
return false;
}
- toset->MinEdge = m_prop.collisionbox.MinEdge * BS;
- toset->MaxEdge = m_prop.collisionbox.MaxEdge * BS;
+ toset->MinEdge = m_prop.selectionbox.MinEdge * BS;
+ toset->MaxEdge = m_prop.selectionbox.MaxEdge * BS;
return true;
}
m_prop.physical = false;
m_prop.weight = 75;
m_prop.collisionbox = aabb3f(-0.3f, 0.0f, -0.3f, 0.3f, 1.77f, 0.3f);
+ m_prop.selectionbox = aabb3f(-0.3f, 0.0f, -0.3f, 0.3f, 1.77f, 0.3f);
+ m_prop.pointable = true;
// start of default appearance, this should be overwritten by LUA
m_prop.visual = "upright_sprite";
m_prop.visual_size = v2f(1, 2);
bool PlayerSAO::getSelectionBox(aabb3f *toset) const
{
- if (!m_prop.is_visible) {
+ if (!m_prop.is_visible || !m_prop.pointable) {
return false;
}
- toset->MinEdge = m_prop.collisionbox.MinEdge * BS;
- toset->MaxEdge = m_prop.collisionbox.MaxEdge * BS;
+ toset->MinEdge = m_prop.selectionbox.MinEdge * BS;
+ toset->MaxEdge = m_prop.selectionbox.MaxEdge * BS;
return true;
}
os << ", nametag=" << nametag;
os << ", nametag_color=" << "\"" << nametag_color.getAlpha() << "," << nametag_color.getRed()
<< "," << nametag_color.getGreen() << "," << nametag_color.getBlue() << "\" ";
+ os << ", selectionbox=" << PP(selectionbox.MinEdge) << "," << PP(selectionbox.MaxEdge);
+ os << ", pointable=" << pointable;
return os.str();
}
writeF1000(os, automatic_face_movement_max_rotation_per_sec);
os << serializeString(infotext);
os << serializeString(wield_item);
+ writeV3F1000(os, selectionbox.MinEdge);
+ writeV3F1000(os, selectionbox.MaxEdge);
+ writeU8(os, pointable);
// Add stuff only at the bottom.
// Never remove anything, because we don't want new versions of this
automatic_face_movement_max_rotation_per_sec = readF1000(is);
infotext = deSerializeString(is);
wield_item = deSerializeString(is);
+ selectionbox.MinEdge = readV3F1000(is);
+ selectionbox.MaxEdge = readV3F1000(is);
+ pointable = readU8(is);
}catch(SerializationError &e){}
}
else
bool collideWithObjects = true;
float weight = 5.0f;
aabb3f collisionbox = aabb3f(-0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f);
+ aabb3f selectionbox = aabb3f(-0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f);
+ bool pointable = true;
std::string visual = "sprite";
std::string mesh = "";
v2f visual_size = v2f(1, 1);
prop->collisionbox = read_aabb3f(L, -1, 1.0);
lua_pop(L, 1);
+ lua_getfield(L, -1, "selectionbox");
+ if (lua_istable(L, -1))
+ prop->selectionbox = read_aabb3f(L, -1, 1.0);
+ else
+ prop->selectionbox = prop->collisionbox;
+ lua_pop(L, 1);
+ getboolfield(L, -1, "pointable", prop->pointable);
getstringfield(L, -1, "visual", prop->visual);
getstringfield(L, -1, "mesh", prop->mesh);
lua_setfield(L, -2, "weight");
push_aabb3f(L, prop->collisionbox);
lua_setfield(L, -2, "collisionbox");
+ push_aabb3f(L, prop->selectionbox);
+ lua_setfield(L, -2, "selectionbox");
+ lua_pushboolean(L, prop->pointable);
+ lua_setfield(L, -2, "pointable");
lua_pushlstring(L, prop->visual.c_str(), prop->visual.size());
lua_setfield(L, -2, "visual");
lua_pushlstring(L, prop->mesh.c_str(), prop->mesh.size());