diff --git a/doc/en/entity-properties.md b/doc/en/entity-properties.md index 8bc4d5d37..b0aee9aea 100644 --- a/doc/en/entity-properties.md +++ b/doc/en/entity-properties.md @@ -61,12 +61,16 @@ Determines how the physics engine will work with it. ### *blocking* -Determines whether the entity blocks installation of blocks. +If true - the entity blocks the placement of a block that intersects with the entity's hitbox. *In the future will also block other entities movement.* Default value: *true*. +### *selectable* + +If set to `false` the cursor will ignore the entity, passing the ray. + ### *sensors* A sensor is an area attached to a physical body that detects the entry of other bodies into it. diff --git a/doc/en/scripting/builtins/libworld.md b/doc/en/scripting/builtins/libworld.md index 54b44fe15..72bfaf8e4 100644 --- a/doc/en/scripting/builtins/libworld.md +++ b/doc/en/scripting/builtins/libworld.md @@ -92,6 +92,8 @@ world.raycast( -- exclusion filtering mode: -- if true, filter_entities defines the list of ignored entity types entities_exclusion: bool = false, + -- include entities with selectable=false + nonselect_entities: bool = false; [==[ additional parameters (blocks) ]==] -- id of the block types used for filtering diff --git a/doc/ru/entity-properties.md b/doc/ru/entity-properties.md index de10cfd32..2f5ca3791 100644 --- a/doc/ru/entity-properties.md +++ b/doc/ru/entity-properties.md @@ -61,12 +61,16 @@ ### Блокирование - *blocking* -Определяет блокирует ли сущность установку блоков. +Определяет, блокирует ли сущность установку блока, пересекающегося с хитбоксом сущности. *В будущем будет также блокировать движение других сущностей.* Значение по-умолчанию: *true*. +### Выделяемость - *selectable* + +При значении в `false` курсор будет игнорировать cущность, пропуская луч далее. + ### Список сенсоров - *sensors* Сенсор - область пространства, привязанная к физическому телу, детектирующее попадание в него других тел. diff --git a/doc/ru/scripting/builtins/libworld.md b/doc/ru/scripting/builtins/libworld.md index 6b945aa76..52812f295 100644 --- a/doc/ru/scripting/builtins/libworld.md +++ b/doc/ru/scripting/builtins/libworld.md @@ -91,6 +91,8 @@ world.raycast( -- исключающий режим фильтрации: -- при значении (true) filter_entities определяет список игнорируемых entities_exclusion: bool = false, + -- учитывать сущности с selectable=false + nonselect_entities: bool = false; [==[ дополнительные параметры (блоки) ]==] -- id типов блоков используемых для фильтрации diff --git a/res/content/base/scripts/components/drop.lua b/res/content/base/scripts/components/drop.lua index 39bd03ceb..335b81d89 100644 --- a/res/content/base/scripts/components/drop.lua +++ b/res/content/base/scripts/components/drop.lua @@ -10,7 +10,7 @@ dropitem = ARGS if dropitem.item then dropitem.id = item.index(dropitem.item) end -if dropitem then +if dropitem then timer = dropitem.pickup_delay or timer end if SAVED_DATA.item then @@ -26,6 +26,7 @@ function on_save() end if vc.is_client() then + local SCALE = 0.3 local scale = {1, 1, 1} local rotation = mat4.rotate({ math.random(), math.random(), math.random() @@ -35,7 +36,7 @@ if vc.is_client() then local matrix = mat4.idt() rig:set_model(0, item.model_name(dropitem.id)) local bodysize = math.min(scale[1], scale[2], scale[3]) - body:set_size({scale[1], bodysize, scale[3]}) + body:set_size(vec3.mul({scale[1], bodysize, scale[3]}, SCALE)) mat4.mul(matrix, rotation, matrix) mat4.scale(matrix, scale, matrix) rig:set_matrix(0, matrix) diff --git a/src/content/ContentBuilder.cpp b/src/content/ContentBuilder.cpp index ce77434ed..25029963b 100644 --- a/src/content/ContentBuilder.cpp +++ b/src/content/ContentBuilder.cpp @@ -26,17 +26,18 @@ std::unique_ptr ContentBuilder::build() { def.rt.tags.insert(tags.add(tag)); } + auto isSolid = [](const Variant& variant) { + return variant.model.type == BlockModelType::BLOCK || + variant.culling == CullingMode::OPTIONAL; + }; + if (def.variants) { for (auto& variant : def.variants->variants) { - variant.rt.solid = - variant.model.type == BlockModelType::BLOCK || - def.explictlySolid; + variant.rt.solid = isSolid(variant) || def.explictlySolid; } def.defaults = def.variants->variants.at(0); } else { - def.defaults.rt.solid = - def.defaults.model.type == BlockModelType::BLOCK || - def.explictlySolid; + def.defaults.rt.solid = isSolid(def.defaults) || def.explictlySolid; } const float EPSILON = 0.01f; diff --git a/src/content/loading/EntityLoader.cpp b/src/content/loading/EntityLoader.cpp index 5741b2079..e785fb0fe 100644 --- a/src/content/loading/EntityLoader.cpp +++ b/src/content/loading/EntityLoader.cpp @@ -89,6 +89,7 @@ template<> void ContentUnitLoader::loadUnit( root.at("skeleton-name").get(def.skeletonName); root.at("material").get(def.material); root.at("blocking").get(def.blocking); + root.at("selectable").get(def.selectable); root.at("solid").get(def.solid); root.at("mass").get(def.mass); root.at("elasticity").get(def.elasticity); diff --git a/src/frontend/ContentGfxCache.cpp b/src/frontend/ContentGfxCache.cpp index b8ce69a5f..9cdcdf70e 100644 --- a/src/frontend/ContentGfxCache.cpp +++ b/src/frontend/ContentGfxCache.cpp @@ -30,6 +30,7 @@ void ContentGfxCache::refreshVariant( uint8_t variantIndex, const Atlas& atlas ) { + std::unordered_map optionalTextures; bool denseRender = settings.denseRender.get(); for (uint side = 0; side < 6; side++) { std::string tex = variant.textureFaces[side]; @@ -43,6 +44,7 @@ void ContentGfxCache::refreshVariant( texOpaque = tex; } else if (variant.culling == CullingMode::OPTIONAL && !denseRender) { tex = texOpaque; + optionalTextures[variant.textureFaces[side]] = texOpaque; } size_t index = getRegionIndex(def.rt.id, variantIndex, side, false); sideregions[index] = atlas.get(tex); @@ -56,7 +58,12 @@ void ContentGfxCache::refreshVariant( if (pos == std::string::npos) { continue; } - if (auto region = atlas.getIf(mesh.texture.substr(pos+1))) { + std::string texture = mesh.texture.substr(pos+1); + const auto& found = optionalTextures.find(texture); + if (found != optionalTextures.end()) { + texture = found->second; + } + if (auto region = atlas.getIf(texture)) { for (auto& vertex : mesh.vertices) { vertex.uv = region->apply(vertex.uv); } diff --git a/src/graphics/render/BlocksRenderer.cpp b/src/graphics/render/BlocksRenderer.cpp index 0aae42010..33ecc8e17 100644 --- a/src/graphics/render/BlocksRenderer.cpp +++ b/src/graphics/render/BlocksRenderer.cpp @@ -538,7 +538,6 @@ void BlocksRenderer::render( break; } case BlockModelType::CUSTOM: { - if (!denseRender) blockCustomModel( {x, y, z}, def, diff --git a/src/logic/scripting/lua/libs/libentity.cpp b/src/logic/scripting/lua/libs/libentity.cpp index 110aee123..4434136ba 100644 --- a/src/logic/scripting/lua/libs/libentity.cpp +++ b/src/logic/scripting/lua/libs/libentity.cpp @@ -311,6 +311,10 @@ static int l_world_raycast(lua::State* L) { entityRaycast.entityFilterExcludeMode = lua::toboolean(L, -1); lua::pop(L); } + if (lua::getfield(L, "nonselect_entities", 1)) { + entityRaycast.includeNonSelectable = lua::toboolean(L, -1); + lua::pop(L); + } if (lua::getfield(L, "filter_blocks", 1)) { load_blocks_filter(L, -1, filteredBlocks); blocksRaycast.filter = &filteredBlocks; diff --git a/src/objects/Entities.cpp b/src/objects/Entities.cpp index fafd99fe5..0902ae85a 100644 --- a/src/objects/Entities.cpp +++ b/src/objects/Entities.cpp @@ -176,7 +176,8 @@ std::optional Entities::rayCast( for (auto [entity, eid, transform, body] : view.each()) { if (eid.uid == settings.ignoredUid || !body.enabled || - (settings.solidEntitiesOnly && !eid.def.solid)) { + (settings.solidEntitiesOnly && !eid.def.solid) || + (!eid.def.selectable && !settings.includeNonSelectable)) { continue; } if (settings.entitiesFilter) { diff --git a/src/objects/Entities.hpp b/src/objects/Entities.hpp index 0d003ffb1..382790b95 100644 --- a/src/objects/Entities.hpp +++ b/src/objects/Entities.hpp @@ -85,6 +85,7 @@ public: bool solidEntitiesOnly = false; bool entityFilterExcludeMode = false; const std::set* entitiesFilter = nullptr; + bool includeNonSelectable = false; }; struct RaycastResult { diff --git a/src/objects/EntityDef.hpp b/src/objects/EntityDef.hpp index 6ecb1c917..59aed2d7e 100644 --- a/src/objects/EntityDef.hpp +++ b/src/objects/EntityDef.hpp @@ -42,6 +42,9 @@ struct EntityDef { /// @brief Solid entity material material std::string material; + /// @brief Can the entity be interacted with cursor (on_attack, on_use) + bool selectable = true; + /// @brief Does entity prevent blocks setup bool blocking = true;