Merge branch 'main' into particles-first

This commit is contained in:
MihailRis 2024-11-05 03:15:34 +03:00
commit 4cf09aa057
3 changed files with 6 additions and 7 deletions

View File

@ -41,6 +41,7 @@ std::unique_ptr<Content> ContentBuilder::build() {
def.rt.hitboxes[i].reserve(def.hitboxes.size());
for (AABB aabb : def.hitboxes) {
def.rotations.variants[i].transform(aabb);
aabb.fix();
def.rt.hitboxes[i].push_back(aabb);
}
}

View File

@ -429,7 +429,7 @@ void PlayerController::processRightClick(const Block& def, const Block& target)
return;
}
}
auto coord = selection.actualPosition;
glm::ivec3 coord = selection.actualPosition;
if (!target.replaceable) {
coord += selection.normal;
} else if (def.rotations.name == BlockRotProfile::PIPE_NAME) {
@ -437,12 +437,10 @@ void PlayerController::processRightClick(const Block& def, const Block& target)
}
blockid_t chosenBlock = def.rt.id;
if (def.obstacle) {
std::vector<AABB> hitboxes = def.rotatable ? def.rt.hitboxes[state.rotation] : def.hitboxes;
for (AABB blockAABB : hitboxes) {
bool blocked = level->entities->hasBlockingInside(blockAABB.move(coord));
if (blocked) {
const auto& hitboxes = def.rt.hitboxes[state.rotation];
for (const AABB& blockAABB : hitboxes) {
if (level->entities->hasBlockingInside(blockAABB.translated(coord))) {
return;
}
}

View File

@ -34,7 +34,7 @@ struct AABB {
return (a + b) * 0.5f;
}
inline AABB move(glm::vec3 pos) const {
inline AABB translated(const glm::vec3& pos) const {
return AABB(a + pos, b + pos);
}