fix: block states cause crash for rotatable blocks

This commit is contained in:
MihailRis
2024-05-30 18:17:21 +03:00
parent c9fb33132f
commit 29ca6e969c
3 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -199,7 +199,7 @@ void WorldRenderer::renderBlockSelection(Camera* camera, Shader* linesShader) {
const glm::vec3 norm = PlayerController::selectedBlockNormal; const glm::vec3 norm = PlayerController::selectedBlockNormal;
const std::vector<AABB>& hitboxes = block->rotatable const std::vector<AABB>& hitboxes = block->rotatable
? block->rt.hitboxes[PlayerController::selectedBlockStates] ? block->rt.hitboxes[PlayerController::selectedBlockRotation]
: block->hitboxes; : block->hitboxes;
linesShader->use(); linesShader->use();
+4 -4
View File
@@ -170,7 +170,7 @@ glm::vec3 PlayerController::selectedBlockPosition;
glm::vec3 PlayerController::selectedPointPosition; glm::vec3 PlayerController::selectedPointPosition;
glm::ivec3 PlayerController::selectedBlockNormal; glm::ivec3 PlayerController::selectedBlockNormal;
int PlayerController::selectedBlockId = -1; int PlayerController::selectedBlockId = -1;
int PlayerController::selectedBlockStates = 0; int PlayerController::selectedBlockRotation = 0;
PlayerController::PlayerController( PlayerController::PlayerController(
Level* level, Level* level,
@@ -250,7 +250,7 @@ void PlayerController::update(float delta, bool input, bool pause) {
updateInteraction(); updateInteraction();
} else { } else {
selectedBlockId = -1; selectedBlockId = -1;
selectedBlockStates = 0; selectedBlockRotation = 0;
} }
} }
@@ -365,7 +365,7 @@ void PlayerController::updateInteraction(){
if (vox != nullptr){ if (vox != nullptr){
player->selectedVoxel = *vox; player->selectedVoxel = *vox;
selectedBlockId = vox->id; selectedBlockId = vox->id;
selectedBlockStates = vox->states; selectedBlockRotation = vox->rotation();
selectedBlockPosition = iend; selectedBlockPosition = iend;
selectedPointPosition = end; selectedPointPosition = end;
selectedBlockNormal = norm; selectedBlockNormal = norm;
@@ -442,7 +442,7 @@ void PlayerController::updateInteraction(){
} }
} else { } else {
selectedBlockId = -1; selectedBlockId = -1;
selectedBlockStates = 0; selectedBlockRotation = 0;
} }
if (rclick) { if (rclick) {
if (item->rt.funcsset.on_use) { if (item->rt.funcsset.on_use) {
+1 -1
View File
@@ -81,7 +81,7 @@ public:
static glm::ivec3 selectedBlockNormal; static glm::ivec3 selectedBlockNormal;
static glm::vec3 selectedPointPosition; static glm::vec3 selectedPointPosition;
static int selectedBlockId; static int selectedBlockId;
static int selectedBlockStates; static int selectedBlockRotation;
PlayerController( PlayerController(
Level* level, Level* level,