mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 22:11:51 +00:00
Merge branch 'main' into volume-renderer
This commit is contained in:
commit
305f44d1c6
70 changed files with 802 additions and 580 deletions
|
|
@ -125,9 +125,6 @@ Block::Block(std::string name, const std::string& texture)
|
|||
|
||||
void Block::cloneTo(Block& dst) {
|
||||
dst.caption = caption;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
dst.defaults = defaults;
|
||||
}
|
||||
dst.defaults = defaults;
|
||||
if (variants) {
|
||||
dst.variants = std::make_unique<Variants>(*variants);
|
||||
|
|
@ -155,6 +152,7 @@ void Block::cloneTo(Block& dst) {
|
|||
dst.tickInterval = tickInterval;
|
||||
dst.overlayTexture = overlayTexture;
|
||||
dst.translucent = translucent;
|
||||
dst.explictlySolid = explictlySolid;
|
||||
dst.tags = tags;
|
||||
if (particles) {
|
||||
dst.particles = std::make_unique<ParticlesPreset>(*particles);
|
||||
|
|
|
|||
|
|
@ -230,6 +230,9 @@ public:
|
|||
/// @brief Block has semi-transparent texture
|
||||
bool translucent = false;
|
||||
|
||||
/// @brief Explicitly overriding 'solid' property if true assigned
|
||||
bool explictlySolid = false;
|
||||
|
||||
/// @brief Set of block physical hitboxes
|
||||
std::vector<AABB> hitboxes {AABB()};
|
||||
|
||||
|
|
|
|||
|
|
@ -215,10 +215,11 @@ voxel* Chunks::rayCast(
|
|||
glm::vec3& end,
|
||||
glm::ivec3& norm,
|
||||
glm::ivec3& iend,
|
||||
std::set<blockid_t> filter
|
||||
std::set<blockid_t> filter,
|
||||
bool includeNonSelectable
|
||||
) const {
|
||||
return blocks_agent::raycast(
|
||||
*this, start, dir, maxDist, end, norm, iend, std::move(filter)
|
||||
*this, start, dir, maxDist, end, norm, iend, std::move(filter), includeNonSelectable
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,8 @@ public:
|
|||
glm::vec3& end,
|
||||
glm::ivec3& norm,
|
||||
glm::ivec3& iend,
|
||||
std::set<blockid_t> filter = {}
|
||||
std::set<blockid_t> filter = {},
|
||||
bool includeNonSelectable = false
|
||||
) const;
|
||||
|
||||
glm::vec3 rayCastToObstacle(
|
||||
|
|
|
|||
|
|
@ -221,7 +221,8 @@ static inline voxel* raycast_blocks(
|
|||
glm::vec3& end,
|
||||
glm::ivec3& norm,
|
||||
glm::ivec3& iend,
|
||||
std::set<blockid_t> filter
|
||||
std::set<blockid_t> filter,
|
||||
bool includeNonSelectable
|
||||
) {
|
||||
const auto& blocks = chunks.getContentIndices().blocks;
|
||||
float px = start.x;
|
||||
|
|
@ -264,8 +265,8 @@ static inline voxel* raycast_blocks(
|
|||
}
|
||||
|
||||
const auto& def = blocks.require(voxel->id);
|
||||
if ((filter.empty() && def.selectable) ||
|
||||
(!filter.empty() && filter.find(def.rt.id) == filter.end())) {
|
||||
if (voxel->id != BLOCK_AIR && (def.selectable || includeNonSelectable) &&
|
||||
(filter.empty() || filter.find(def.rt.id) == filter.end())) {
|
||||
end.x = px + t * dx;
|
||||
end.y = py + t * dy;
|
||||
end.z = pz + t * dz;
|
||||
|
|
@ -362,9 +363,10 @@ voxel* blocks_agent::raycast(
|
|||
glm::vec3& end,
|
||||
glm::ivec3& norm,
|
||||
glm::ivec3& iend,
|
||||
std::set<blockid_t> filter
|
||||
std::set<blockid_t> filter,
|
||||
bool includeNonSelectable
|
||||
) {
|
||||
return raycast_blocks(chunks, start, dir, maxDist, end, norm, iend, filter);
|
||||
return raycast_blocks(chunks, start, dir, maxDist, end, norm, iend, filter, includeNonSelectable);
|
||||
}
|
||||
|
||||
voxel* blocks_agent::raycast(
|
||||
|
|
@ -375,9 +377,10 @@ voxel* blocks_agent::raycast(
|
|||
glm::vec3& end,
|
||||
glm::ivec3& norm,
|
||||
glm::ivec3& iend,
|
||||
std::set<blockid_t> filter
|
||||
std::set<blockid_t> filter,
|
||||
bool includeNonSelectable
|
||||
) {
|
||||
return raycast_blocks(chunks, start, dir, maxDist, end, norm, iend, filter);
|
||||
return raycast_blocks(chunks, start, dir, maxDist, end, norm, iend, filter, includeNonSelectable);
|
||||
}
|
||||
|
||||
// reduce nesting on next modification
|
||||
|
|
|
|||
|
|
@ -419,6 +419,7 @@ inline void set_rotation(
|
|||
/// @param norm [out] surface normal vector
|
||||
/// @param iend [out] ray end integer position (voxel position + normal)
|
||||
/// @param filter filtered ids
|
||||
/// @param includeNonSelectable will non-selectable blocks be included
|
||||
/// @return voxel pointer or nullptr
|
||||
voxel* raycast(
|
||||
const Chunks& chunks,
|
||||
|
|
@ -428,7 +429,8 @@ voxel* raycast(
|
|||
glm::vec3& end,
|
||||
glm::ivec3& norm,
|
||||
glm::ivec3& iend,
|
||||
std::set<blockid_t> filter
|
||||
std::set<blockid_t> filter,
|
||||
bool includeNonSelectable
|
||||
);
|
||||
|
||||
/// @brief Cast ray to a selectable block with filter based on id.
|
||||
|
|
@ -440,6 +442,7 @@ voxel* raycast(
|
|||
/// @param norm [out] surface normal vector
|
||||
/// @param iend [out] ray end integer position (voxel position + normal)
|
||||
/// @param filter filtered ids
|
||||
/// @param includeNonSelectable will non-selectable blocks be included
|
||||
/// @return voxel pointer or nullptr
|
||||
voxel* raycast(
|
||||
const GlobalChunks& chunks,
|
||||
|
|
@ -449,7 +452,8 @@ voxel* raycast(
|
|||
glm::vec3& end,
|
||||
glm::ivec3& norm,
|
||||
glm::ivec3& iend,
|
||||
std::set<blockid_t> filter
|
||||
std::set<blockid_t> filter,
|
||||
bool includeNonSelectable
|
||||
);
|
||||
|
||||
void get_voxels(const Chunks& chunks, VoxelsVolume* volume, bool backlight=false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue