fix renderHands with third person cameras

This commit is contained in:
MihailRis
2024-10-31 21:27:30 +03:00
parent 2c16f986e1
commit e217476e84
7 changed files with 25 additions and 23 deletions
+9 -9
View File
@@ -40,11 +40,11 @@ Player::Player(
position(position),
inventory(std::move(inv)),
eid(eid),
camera(level->getCamera("core:first-person")),
fpCamera(level->getCamera("core:first-person")),
spCamera(level->getCamera("core:third-person-front")),
tpCamera(level->getCamera("core:third-person-back")),
currentCamera(camera) {
camera->setFov(glm::radians(90.0f));
currentCamera(fpCamera) {
fpCamera->setFov(glm::radians(90.0f));
spCamera->setFov(glm::radians(90.0f));
tpCamera->setFov(glm::radians(90.0f));
}
@@ -93,16 +93,16 @@ void Player::updateInput(PlayerInput& input, float delta) {
glm::vec3 dir(0, 0, 0);
if (input.moveForward) {
dir += camera->dir;
dir += fpCamera->dir;
}
if (input.moveBack) {
dir -= camera->dir;
dir -= fpCamera->dir;
}
if (input.moveRight) {
dir += camera->right;
dir += fpCamera->right;
}
if (input.moveLeft) {
dir -= camera->right;
dir -= fpCamera->right;
}
if (glm::length(dir) > 0.0f) {
dir = glm::normalize(dir);
@@ -166,7 +166,7 @@ void Player::postUpdate() {
auto& skeleton = entity->getSkeleton();
skeleton.visible = currentCamera != camera;
skeleton.visible = currentCamera != fpCamera;
auto body = skeleton.config->find("body");
auto head = skeleton.config->find("head");
@@ -289,7 +289,7 @@ void Player::deserialize(const dv::value& src) {
const auto& posarr = src["position"];
dv::get_vec(posarr, position);
camera->position = position;
fpCamera->position = position;
const auto& rotarr = src["rotation"];
dv::get_vec(rotarr, cam);
+1 -1
View File
@@ -52,7 +52,7 @@ class Player : public Object, public Serializable {
entityid_t eid;
entityid_t selectedEid;
public:
std::shared_ptr<Camera> camera, spCamera, tpCamera;
std::shared_ptr<Camera> fpCamera, spCamera, tpCamera;
std::shared_ptr<Camera> currentCamera;
bool debug = false;
glm::vec3 cam {};