From 223415d17b4f1c9bb780c6730fba566882b5b6ab Mon Sep 17 00:00:00 2001 From: David Min Date: Mon, 3 Jun 2024 21:41:14 -0700 Subject: [PATCH 1/3] Modified animation playback speed to use time between each frame --- include/client/client.hpp | 2 ++ src/client/client.cpp | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/client/client.hpp b/include/client/client.hpp index a1c9a4b5..54cb2ff3 100644 --- a/include/client/client.hpp +++ b/include/client/client.hpp @@ -312,6 +312,8 @@ class Client { float mouse_xpos = 0.0f; float mouse_ypos = 0.0f; + double lastTime = 0.0; + GameConfig config; tcp::resolver resolver; tcp::socket socket; diff --git a/src/client/client.cpp b/src/client/client.cpp index f6a7a71f..5c2dc4f8 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -600,6 +600,10 @@ void Client::geometryPass() { bool is_dm = this->session->getInfo().is_dungeon_master.value(); glm::vec3 my_pos = this->gameState.objects[eid]->physics.corner; + double currentTime = glfwGetTime(); + double timeElapsed = currentTime - lastTime; + lastTime = currentTime; + // draw all objects to g-buffer for (auto& [id, sharedObject] : this->gameState.objects) { if (!sharedObject.has_value()) { @@ -628,6 +632,7 @@ void Client::geometryPass() { glm::vec3 pos = sharedObject->physics.getCenterPosition(); pos.y += PLAYER_EYE_LEVEL; + pos.z += 3.0f; cam->updatePos(pos); // update listener position & facing @@ -643,12 +648,12 @@ void Client::geometryPass() { if (!sharedObject->playerInfo->is_alive) { this->gui_state = GUIState::DEAD_SCREEN; } - break; + // break; } animManager->setAnimation(sharedObject->globalID, sharedObject->type, sharedObject->animState); /* Update model animation */ - animManager->updateAnimation(0.025f); + animManager->updateAnimation(timeElapsed); auto transforms = animManager->getFinalBoneMatrices(); for (int i = 0; i < (transforms.size() < 100 ? transforms.size() : 100); ++i) { From 1685d23215c2cf8a560d19c44a7fc1bbf031ba31 Mon Sep 17 00:00:00 2001 From: David Min Date: Mon, 3 Jun 2024 21:58:55 -0700 Subject: [PATCH 2/3] Modified player render position to be on floor --- src/client/client.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/client/client.cpp b/src/client/client.cpp index 5c2dc4f8..645ac45f 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -630,9 +630,8 @@ void Client::geometryPass() { if (this->session->getInfo().client_eid.has_value() && sharedObject->globalID == this->session->getInfo().client_eid.value()) { // TODO: Update the player eye level to an acceptable level - glm::vec3 pos = sharedObject->physics.getCenterPosition(); + glm::vec3 pos = sharedObject->physics.getCenterPosition() - (sharedObject->physics.dimensions.y / 2.0f); pos.y += PLAYER_EYE_LEVEL; - pos.z += 3.0f; cam->updatePos(pos); // update listener position & facing @@ -648,7 +647,7 @@ void Client::geometryPass() { if (!sharedObject->playerInfo->is_alive) { this->gui_state = GUIState::DEAD_SCREEN; } - // break; + break; } animManager->setAnimation(sharedObject->globalID, sharedObject->type, sharedObject->animState); @@ -662,7 +661,7 @@ void Client::geometryPass() { if (!sharedObject->playerInfo->render) { break; } // dont render while invisible - auto player_pos = sharedObject->physics.getCenterPosition(); + auto player_pos = sharedObject->physics.getCenterPosition() - (sharedObject->physics.dimensions.y / 2.0f); auto player_dir = sharedObject->physics.facing; if (player_dir == glm::vec3(0.0f)) { From 7bdbc3722b5db0ca3923cbc0a7caf835c20a856e Mon Sep 17 00:00:00 2001 From: David Min Date: Mon, 3 Jun 2024 22:16:18 -0700 Subject: [PATCH 3/3] Fixed player position logic --- src/client/client.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/client/client.cpp b/src/client/client.cpp index 645ac45f..e888094a 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -630,7 +630,8 @@ void Client::geometryPass() { if (this->session->getInfo().client_eid.has_value() && sharedObject->globalID == this->session->getInfo().client_eid.value()) { // TODO: Update the player eye level to an acceptable level - glm::vec3 pos = sharedObject->physics.getCenterPosition() - (sharedObject->physics.dimensions.y / 2.0f); + glm::vec3 pos = sharedObject->physics.getCenterPosition(); + pos.y -= (sharedObject->physics.dimensions.y / 2.0f); pos.y += PLAYER_EYE_LEVEL; cam->updatePos(pos); @@ -661,7 +662,9 @@ void Client::geometryPass() { if (!sharedObject->playerInfo->render) { break; } // dont render while invisible - auto player_pos = sharedObject->physics.getCenterPosition() - (sharedObject->physics.dimensions.y / 2.0f); + auto player_pos = sharedObject->physics.getCenterPosition(); + player_pos.y -= (sharedObject->physics.dimensions.y / 2.0f); + auto player_dir = sharedObject->physics.facing; if (player_dir == glm::vec3(0.0f)) {