move Chunks from Level to Player

This commit is contained in:
MihailRis
2024-12-17 19:40:00 +03:00
parent b7664b4188
commit 1c18c02092
40 changed files with 450 additions and 220 deletions
+1 -1
View File
@@ -459,7 +459,7 @@ void Entities::updatePhysics(float delta) {
float vel = glm::length(prevVel);
int substeps = static_cast<int>(delta * vel * 20);
substeps = std::min(100, std::max(2, substeps));
physics->step(level->chunks.get(), &hitbox, delta, substeps, eid.uid);
physics->step(*level->chunksStorage, &hitbox, delta, substeps, eid.uid);
hitbox.linearDamping = hitbox.grounded * 24;
transform.setPos(hitbox.position);
if (hitbox.grounded && !grounded) {
+3 -3
View File
@@ -205,12 +205,12 @@ void Player::attemptToFindSpawnpoint() {
position.z + (rand() % 200 - 100)
);
while (newpos.y > 0 &&
!level->chunks->isObstacleBlock(newpos.x, newpos.y - 2, newpos.z)) {
!chunks->isObstacleBlock(newpos.x, newpos.y - 2, newpos.z)) {
newpos.y--;
}
voxel* headvox = level->chunks->get(newpos.x, newpos.y + 1, newpos.z);
if (level->chunks->isObstacleBlock(newpos.x, newpos.y, newpos.z) ||
voxel* headvox = chunks->get(newpos.x, newpos.y + 1, newpos.z);
if (chunks->isObstacleBlock(newpos.x, newpos.y, newpos.z) ||
headvox == nullptr || headvox->id != 0) {
return;
}