mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
update world.raycast params & add blocks_exclusion parameter
This commit is contained in:
parent
00d6e28208
commit
605b0d63c3
3 changed files with 10 additions and 5 deletions
|
|
@ -287,7 +287,7 @@ static int l_world_raycast(lua::State* L) {
|
|||
entityRaycast.ignoredUid = lua::tointeger(L, -1);
|
||||
lua::pop(L);
|
||||
}
|
||||
if (lua::getfield(L, "ignore_entities")) {
|
||||
if (lua::getfield(L, "filter_entities")) {
|
||||
load_entities_filter(L, -1, filteredEntities);
|
||||
blocksRaycast.filter = &filteredEntities;
|
||||
lua::pop(L);
|
||||
|
|
@ -301,6 +301,10 @@ static int l_world_raycast(lua::State* L) {
|
|||
blocksRaycast.filter = &filteredBlocks;
|
||||
lua::pop(L);
|
||||
}
|
||||
if (lua::getfield(L, "blocks_exclusion")) {
|
||||
blocksRaycast.blocksFilterExcludeMode = lua::toboolean(L, -1);
|
||||
lua::pop(L);
|
||||
}
|
||||
if (lua::getfield(L, "nonselect_blocks", 1)) {
|
||||
blocksRaycast.includeNonSelectable = lua::toboolean(L, -1);
|
||||
lua::pop(L);
|
||||
|
|
|
|||
|
|
@ -267,10 +267,10 @@ static inline voxel* raycast_blocks(
|
|||
|
||||
auto filter = settings.filter;
|
||||
const auto& def = blocks.require(voxel->id);
|
||||
if (voxel->id != BLOCK_AIR
|
||||
&& (def.selectable || includeNonSelectable)
|
||||
&& (filter == nullptr || filter->empty() ||
|
||||
filter->find(def.rt.id) == filter->end())) {
|
||||
if (voxel->id != BLOCK_AIR &&
|
||||
(def.selectable || includeNonSelectable) &&
|
||||
(filter == nullptr || (filter->find(def.rt.id) == filter->end()) ==
|
||||
settings.blocksFilterExcludeMode)) {
|
||||
end = start + t * dir;
|
||||
iend = {ix, iy, iz};
|
||||
|
||||
|
|
|
|||
|
|
@ -414,6 +414,7 @@ inline void set_rotation(
|
|||
|
||||
struct RaycastSettings {
|
||||
const std::set<blockid_t>* filter = nullptr;
|
||||
bool blocksFilterExcludeMode = true;
|
||||
bool includeNonSelectable = false;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue