feat(core): add voxel raycasting for block targeting
This commit is contained in:
1 parent
e84def1b81
commit
f80aa78fc5
2 files changed
+98
No files matched your search
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "World.h"
|
||||
#include "Math.h"
|
||||
|
||||
namespace vf {
|
||||
|
||||
struct RaycastHit {
|
||||
bool hit = false;
|
||||
Vec3i block; // solid voxel that was struck
|
||||
Vec3i normal; // face normal pointing back toward the ray origin
|
||||
float distance = 0.0f;
|
||||
};
|
||||
|
||||
// Amanatides and Woo voxel traversal. Steps the grid from `origin` along
|
||||
// `direction` up to `maxDistance` world units, stopping at the first solid
|
||||
// voxel. `normal` gives the entered face, so `block + normal` is the empty
|
||||
// neighbour where a new block can be placed.
|
||||
RaycastHit raycastVoxels(const World& world, const Vec3& origin, const Vec3& direction,
|
||||
float maxDistance);
|
||||
|
||||
} // namespace vf
|
||||
Reference in new issue
Block a user