Merge branch 'main' of https://github.com/MihailRis/VoxelEngine-Cpp
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
#include "Content.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include "../voxels/Block.h"
|
||||
|
||||
using glm::vec3;
|
||||
using std::vector;
|
||||
using std::string;
|
||||
using std::unordered_map;
|
||||
@@ -22,6 +24,24 @@ Content* ContentBuilder::build() {
|
||||
for (const string& name : blockIds) {
|
||||
Block* def = blockDefs[name];
|
||||
def->id = blockDefsIndices.size();
|
||||
def->rt.emissive = *((uint32_t*)def->emission);
|
||||
|
||||
// build 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
blockDefsIndices.push_back(def);
|
||||
if (groups->find(def->drawGroup) == groups->end()) {
|
||||
groups->insert(def->drawGroup);
|
||||
|
||||
Reference in New Issue
Block a user