fix rotated aabb blocking check & refactor PlayerController
This commit is contained in:
parent
4b63bedde4
commit
d15624cd47
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user