fix: fatal error when 'body' or 'head' player bone not found

This commit is contained in:
MihailRis 2024-08-09 19:28:18 +03:00
parent 5d81323bd3
commit 0adc13d01a

View File

@ -162,13 +162,19 @@ void Player::postUpdate() {
skeleton.visible = currentCamera != camera;
size_t bodyIndex = skeleton.config->find("body")->getIndex();
size_t headIndex = skeleton.config->find("head")->getIndex();
auto body = skeleton.config->find("body");
auto head = skeleton.config->find("head");
skeleton.pose.matrices[bodyIndex] =
glm::rotate(glm::mat4(1.0f), glm::radians(cam.x), glm::vec3(0, 1, 0));
skeleton.pose.matrices[headIndex] =
glm::rotate(glm::mat4(1.0f), glm::radians(cam.y), glm::vec3(1, 0, 0));
if (body) {
skeleton.pose.matrices[body->getIndex()] = glm::rotate(
glm::mat4(1.0f), glm::radians(cam.x), glm::vec3(0, 1, 0)
);
}
if (head) {
skeleton.pose.matrices[head->getIndex()] = glm::rotate(
glm::mat4(1.0f), glm::radians(cam.y), glm::vec3(1, 0, 0)
);
}
}
void Player::teleport(glm::vec3 position) {