remove third person cameras height limitation

This commit is contained in:
MihailRis
2024-07-17 19:12:59 +03:00
parent b6ceadcee7
commit ec4043bc12
+22 -23
View File
@@ -554,34 +554,33 @@ glm::vec3 Chunks::rayCastToObstacle(glm::vec3 start, glm::vec3 dir, float maxDis
while (t <= maxDist) { while (t <= maxDist) {
voxel* voxel = get(ix, iy, iz); voxel* voxel = get(ix, iy, iz);
if (voxel == nullptr) { if (voxel) {
return glm::vec3(px + t * dx, py + t * dy, pz + t * dz); const auto def = indices->blocks.get(voxel->id);
} if (def->obstacle) {
const auto def = indices->blocks.get(voxel->id); if (!def->rt.solid) {
if (def->obstacle) { const std::vector<AABB>& hitboxes = def->rotatable
if (!def->rt.solid) { ? def->rt.hitboxes[voxel->state.rotation]
const std::vector<AABB>& hitboxes = def->rotatable : def->modelBoxes;
? def->rt.hitboxes[voxel->state.rotation]
: def->modelBoxes;
scalar_t distance; scalar_t distance;
glm::ivec3 norm; glm::ivec3 norm;
Ray ray(start, dir); Ray ray(start, dir);
glm::ivec3 offset {}; glm::ivec3 offset {};
if (voxel->state.segment) { if (voxel->state.segment) {
offset = seekOrigin({ix, iy, iz}, def, voxel->state) - glm::ivec3(ix, iy, iz); offset = seekOrigin({ix, iy, iz}, def, voxel->state) - glm::ivec3(ix, iy, iz);
} }
for (const auto& box : hitboxes) { for (const auto& box : hitboxes) {
// norm is dummy now, can be inefficient // norm is dummy now, can be inefficient
if (ray.intersectAABB(glm::ivec3(ix, iy, iz)+offset, box, maxDist, norm, distance) > RayRelation::None) { if (ray.intersectAABB(glm::ivec3(ix, iy, iz)+offset, box, maxDist, norm, distance) > RayRelation::None) {
return start + (dir * glm::vec3(distance)); return start + (dir * glm::vec3(distance));
}
} }
} }
} else {
else { return glm::vec3(px + t * dx, py + t * dy, pz + t * dz);
return glm::vec3(px + t * dx, py + t * dy, pz + t * dz); }
} }
} }
if (txMax < tyMax) { if (txMax < tyMax) {