mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 03:21:49 +00:00
AABB blocks rotation support (WIP part 3)
This commit is contained in:
parent
7f9e87cea2
commit
64f6f17386
5 changed files with 21 additions and 26 deletions
|
|
@ -27,20 +27,14 @@ Content* ContentBuilder::build() {
|
|||
// Generating runtime info
|
||||
def->rt.id = blockDefsIndices.size();
|
||||
def->rt.emissive = *((uint32_t*)def->emission);
|
||||
|
||||
// building hitbox grid 3d for raycasts
|
||||
const AABB& hitbox = def->hitbox;
|
||||
for (uint gy = 0; gy < BLOCK_AABB_GRID; gy++) {
|
||||
for (uint gz = 0; gz < BLOCK_AABB_GRID; gz++) {
|
||||
for (uint gx = 0; gx < BLOCK_AABB_GRID; gx++) {
|
||||
float x = gx / float(BLOCK_AABB_GRID);
|
||||
float y = gy / float(BLOCK_AABB_GRID);
|
||||
float z = gz / float(BLOCK_AABB_GRID);
|
||||
bool flag = hitbox.inside({x, y, z});
|
||||
if (!flag)
|
||||
def->rt.solid = false;
|
||||
def->rt.hitboxGrid[gy][gz][gx] = flag;
|
||||
}
|
||||
def->rt.solid = def->model == BlockModel::block;
|
||||
|
||||
if (def->rotatable) {
|
||||
const AABB& hitbox = def->hitbox;
|
||||
for (uint i = 0; i < BlockRotProfile::MAX_COUNT; i++) {
|
||||
AABB aabb = hitbox;
|
||||
def->rotations.variants[i].transform(aabb);
|
||||
def->rt.hitboxes[i] = aabb;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -48,6 +42,8 @@ Content* ContentBuilder::build() {
|
|||
if (groups->find(def->drawGroup) == groups->end()) {
|
||||
groups->insert(def->drawGroup);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
ContentIndices* indices = new ContentIndices(blockDefsIndices);
|
||||
return new Content(indices, groups, blockDefs);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue