mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 20:11:50 +00:00
Merge branch 'main' into physics-upgrade
This commit is contained in:
commit
6676db3525
21 changed files with 249 additions and 53 deletions
|
|
@ -12,6 +12,7 @@
|
|||
#include "presets/ParticlesPreset.hpp"
|
||||
#include "util/stringutil.hpp"
|
||||
#include "voxels/Block.hpp"
|
||||
#include "constants.hpp"
|
||||
|
||||
using namespace data;
|
||||
|
||||
|
|
@ -120,8 +121,8 @@ template<> void ContentUnitLoader<Block>::loadUnit(
|
|||
}
|
||||
|
||||
def.variants = std::make_unique<Variants>();
|
||||
def.variants->offset = 0;
|
||||
def.variants->mask = 0xF;
|
||||
def.variants->offset = offset;
|
||||
def.variants->mask = (1ULL << bitsCount) - 1;
|
||||
def.variants->variants.push_back(def.defaults);
|
||||
for (int i = 0; i < variants.size(); i++) {
|
||||
Variant variant = def.defaults;
|
||||
|
|
@ -184,7 +185,11 @@ template<> void ContentUnitLoader<Block>::loadUnit(
|
|||
if (auto found = root.at("emission")) {
|
||||
const auto& emissionarr = *found;
|
||||
for (size_t i = 0; i < 3; i++) {
|
||||
def.emission[i] = glm::clamp(emissionarr[i].asInteger(), static_cast<integer_t>(0), static_cast<integer_t>(15));
|
||||
def.emission[i] = glm::clamp(
|
||||
emissionarr[i].asInteger(),
|
||||
static_cast<integer_t>(0),
|
||||
static_cast<integer_t>(15)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -199,13 +204,31 @@ template<> void ContentUnitLoader<Block>::loadUnit(
|
|||
"block " + util::quote(def.name) + ": invalid block size"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (def.size.x > EXTENDED_BLOCK_LIMIT ||
|
||||
def.size.y > EXTENDED_BLOCK_LIMIT ||
|
||||
def.size.z > EXTENDED_BLOCK_LIMIT) {
|
||||
throw std::runtime_error(
|
||||
"extended block " + util::quote(def.name) + " size limit " +
|
||||
std::to_string(EXTENDED_BLOCK_LIMIT) + " exceeded"
|
||||
);
|
||||
}
|
||||
|
||||
// should variant modify hitbox?
|
||||
if (def.defaults.model.type == BlockModelType::BLOCK &&
|
||||
(def.size.x != 1 || def.size.y != 1 || def.size.z != 1)) {
|
||||
def.defaults.model.type = BlockModelType::AABB;
|
||||
def.hitboxes = {AABB(def.size)};
|
||||
}
|
||||
|
||||
// grounding behaviour
|
||||
if (root.has("grounding-behaviour")) {
|
||||
std::string groundingBehaviourName = GroundingBehaviourMeta.getNameString(def.groundingBehaviour);
|
||||
root.at("grounding-behaviour").get(groundingBehaviourName);
|
||||
if (!GroundingBehaviourMeta.getItem(groundingBehaviourName, def.groundingBehaviour)) {
|
||||
logger.error() << "unknown grounding behaviour: " << groundingBehaviourName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// primitive properties
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue