mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-14 15:31:49 +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);
|
entityRaycast.ignoredUid = lua::tointeger(L, -1);
|
||||||
lua::pop(L);
|
lua::pop(L);
|
||||||
}
|
}
|
||||||
if (lua::getfield(L, "ignore_entities")) {
|
if (lua::getfield(L, "filter_entities")) {
|
||||||
load_entities_filter(L, -1, filteredEntities);
|
load_entities_filter(L, -1, filteredEntities);
|
||||||
blocksRaycast.filter = &filteredEntities;
|
blocksRaycast.filter = &filteredEntities;
|
||||||
lua::pop(L);
|
lua::pop(L);
|
||||||
|
|
@ -301,6 +301,10 @@ static int l_world_raycast(lua::State* L) {
|
||||||
blocksRaycast.filter = &filteredBlocks;
|
blocksRaycast.filter = &filteredBlocks;
|
||||||
lua::pop(L);
|
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)) {
|
if (lua::getfield(L, "nonselect_blocks", 1)) {
|
||||||
blocksRaycast.includeNonSelectable = lua::toboolean(L, -1);
|
blocksRaycast.includeNonSelectable = lua::toboolean(L, -1);
|
||||||
lua::pop(L);
|
lua::pop(L);
|
||||||
|
|
|
||||||
|
|
@ -267,10 +267,10 @@ static inline voxel* raycast_blocks(
|
||||||
|
|
||||||
auto filter = settings.filter;
|
auto filter = settings.filter;
|
||||||
const auto& def = blocks.require(voxel->id);
|
const auto& def = blocks.require(voxel->id);
|
||||||
if (voxel->id != BLOCK_AIR
|
if (voxel->id != BLOCK_AIR &&
|
||||||
&& (def.selectable || includeNonSelectable)
|
(def.selectable || includeNonSelectable) &&
|
||||||
&& (filter == nullptr || filter->empty() ||
|
(filter == nullptr || (filter->find(def.rt.id) == filter->end()) ==
|
||||||
filter->find(def.rt.id) == filter->end())) {
|
settings.blocksFilterExcludeMode)) {
|
||||||
end = start + t * dir;
|
end = start + t * dir;
|
||||||
iend = {ix, iy, iz};
|
iend = {ix, iy, iz};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -414,6 +414,7 @@ inline void set_rotation(
|
||||||
|
|
||||||
struct RaycastSettings {
|
struct RaycastSettings {
|
||||||
const std::set<blockid_t>* filter = nullptr;
|
const std::set<blockid_t>* filter = nullptr;
|
||||||
|
bool blocksFilterExcludeMode = true;
|
||||||
bool includeNonSelectable = false;
|
bool includeNonSelectable = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue