mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-21 09:59:44 +00:00
feat: variant-based hitboxes
This commit is contained in:
parent
563001351b
commit
b8b2e4f451
16 changed files with 145 additions and 102 deletions
|
|
@ -275,19 +275,19 @@ static inline voxel* raycast_blocks(
|
|||
iend = {ix, iy, iz};
|
||||
|
||||
if (!def.rt.solid) {
|
||||
const std::vector<AABB>& hitboxes =
|
||||
def.rotatable ? def.rt.hitboxes[voxel->state.rotation]
|
||||
: def.hitboxes;
|
||||
|
||||
scalar_t distance = maxDist;
|
||||
Ray ray(start, dir);
|
||||
|
||||
bool hit = false;
|
||||
|
||||
glm::vec3 offset {};
|
||||
if (voxel->state.segment) {
|
||||
offset = seek_origin(chunks, iend, def, voxel->state) - iend;
|
||||
blockstate state = voxel->state;
|
||||
if (state.segment) {
|
||||
auto origin = seek_origin(chunks, iend, def, state);
|
||||
offset = origin - iend;
|
||||
state = hitbox_state(chunks, origin, state);
|
||||
}
|
||||
const auto& hitboxes = def.getHitboxes(state);
|
||||
|
||||
for (auto box : hitboxes) {
|
||||
box.a += offset;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue