feat: solid entity material support & minor refactor

This commit is contained in:
MihailRis 2026-03-05 20:52:45 +03:00
parent 01d46b2690
commit dbc7cd56bd
6 changed files with 91 additions and 63 deletions

View file

@ -229,26 +229,8 @@ PlayerController::PlayerController(
}
void PlayerController::onFootstep(const Hitbox& hitbox) {
const auto& pos = hitbox.position;
const auto& half = hitbox.getHalfSize();
for (int offsetZ = -1; offsetZ <= 1; offsetZ++) {
for (int offsetX = -1; offsetX <= 1; offsetX++) {
int x = std::floor(pos.x + half.x * offsetX);
int y = std::floor(pos.y - half.y * 1.1f);
int z = std::floor(pos.z + half.z * offsetZ);
auto vox = player.chunks->get(x, y, z);
if (vox) {
auto& def = level.content.getIndices()->blocks.require(vox->id);
if (!def.obstacle) {
continue;
}
blocksController.onBlockInteraction(
&player, glm::ivec3(x, y, z), def, BlockInteraction::step
);
return;
}
}
if (footstepCallback) {
footstepCallback(hitbox);
}
}
@ -557,3 +539,7 @@ void PlayerController::updateInteraction(const Input& inputEvents, float delta)
Player& PlayerController::getPlayer() {
return player;
}
void PlayerController::setFootstepCallback(FootstepCallback&& callback) {
footstepCallback = std::move(callback);
}