mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 19:41:51 +00:00
fix integer raycast filters & add simple raycast test
This commit is contained in:
parent
f6e1f23c84
commit
39a4236553
4 changed files with 85 additions and 9 deletions
|
|
@ -230,10 +230,14 @@ static void load_blocks_filter(lua::State* L, int idx, std::set<blockid_t>& dst)
|
|||
int count = lua::objlen(L, idx);
|
||||
for (int i = 0; i < count; i++) {
|
||||
lua::rawgeti(L, i + 1, idx);
|
||||
auto blockName = std::string(lua::tostring(L, -1));
|
||||
const Block* block = content->blocks.find(blockName);
|
||||
if (block != nullptr) {
|
||||
dst.insert(block->rt.id);
|
||||
if (lua::isnumber(L, -1)) {
|
||||
dst.insert(lua::touinteger(L, -1));
|
||||
} else {
|
||||
auto blockName = std::string(lua::tostring(L, -1));
|
||||
const Block* block = content->blocks.find(blockName);
|
||||
if (block != nullptr) {
|
||||
dst.insert(block->rt.id);
|
||||
}
|
||||
}
|
||||
lua::pop(L);
|
||||
}
|
||||
|
|
@ -243,10 +247,14 @@ static void load_entities_filter(lua::State* L, int idx, std::set<entitydefid_t>
|
|||
int count = lua::objlen(L, idx);
|
||||
for (int i = 0; i < count; i++) {
|
||||
lua::rawgeti(L, i + 1, idx);
|
||||
auto entityName = std::string(lua::tostring(L, -1));
|
||||
const EntityDef* entity = content->entities.find(entityName);
|
||||
if (entity != nullptr) {
|
||||
dst.insert(entity->rt.id);
|
||||
if (lua::isnumber(L, -1)) {
|
||||
dst.insert(lua::touinteger(L, -1));
|
||||
} else {
|
||||
auto entityName = std::string(lua::tostring(L, -1));
|
||||
const EntityDef* entity = content->entities.find(entityName);
|
||||
if (entity != nullptr) {
|
||||
dst.insert(entity->rt.id);
|
||||
}
|
||||
}
|
||||
lua::pop(L);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ static inline voxel* raycast_blocks(
|
|||
const auto& def = blocks.require(voxel->id);
|
||||
if (voxel->id != BLOCK_AIR &&
|
||||
(def.selectable || includeNonSelectable) &&
|
||||
(filter == nullptr || (filter->find(def.rt.id) == filter->end()) ==
|
||||
((filter == nullptr || filter->find(def.rt.id) == filter->end()) ==
|
||||
settings.blocksFilterExcludeMode)) {
|
||||
end = start + t * dir;
|
||||
iend = {ix, iy, iz};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue