From c7aaaa23b1551ac5eb2c382079bd6fb8eda220bb Mon Sep 17 00:00:00 2001 From: WAUthethird Date: Wed, 11 Dec 2024 18:43:02 -0700 Subject: [PATCH] Fix camera speedup and update associated files to reflect a new version --- CMakeLists.txt | 6 +-- README.md | 2 +- build_on_windows.md | 4 +- src/Scene.cpp | 100 +++++++++++++++++++++++++------------------- src/Scene.h | 2 +- src/config.h.in | 2 +- 6 files changed, 64 insertions(+), 52 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 17a94a3e..d55b9cca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.8) -project(MarbleMarcher VERSION "1.4.5") +cmake_minimum_required(VERSION 3.10) +project(MarbleMarcher VERSION "1.4.6") set(CMAKE_CXX_STANDARD 17) configure_file(src/config.h.in config.h) @@ -143,7 +143,7 @@ elseif(UNIX) set(CPACK_PACKAGE_VERSION "${MM_VERSION}") set(CPACK_PACKAGE_VERSION_MAJOR "1") set(CPACK_PACKAGE_VERSION_MINOR "4") - set(CPACK_PACKAGE_VERSION_PATCH "7") + set(CPACK_PACKAGE_VERSION_PATCH "6") SET(CPACK_GENERATOR "DEB") SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "KK") #required diff --git a/README.md b/README.md index 9ef3993b..9d904642 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Marble Marcher: Community Edition -### Version 1.4.5 +### Version 1.4.6 ![Logo](https://github.com/WAUthethird/Marble-Marcher-Community-Edition/blob/master/doc/LOGO.PNG) diff --git a/build_on_windows.md b/build_on_windows.md index fa0a8f7a..3e42e5af 100644 --- a/build_on_windows.md +++ b/build_on_windows.md @@ -1,6 +1,6 @@ This is a short and easy tutorial for building Marble Marcher: Community Edition on Windows. This tutorial (the command line parts) can be followed with Git Bash, though you'll need a developer CMD in administrator mode for at least one process. -1. Make sure you have [CMake x64](https://cmake.org/download/), [OpenAL](https://www.openal.org/), and [Visual Studio 2019](https://visualstudio.microsoft.com/vs/) (in addition to the 2015 and/or 2017 VS build tools, if one does not work, try installing the other) installed. +1. Make sure you have [CMake x64](https://cmake.org/download/), [OpenAL](https://www.openal.org/), and [Visual Studio 2022](https://visualstudio.microsoft.com/vs/) installed. 2. Download the CE edition to a folder of your choice and unzip it: [https://github.com/WAUthethird/Marble-Marcher-Community-Edition](https://github.com/WAUthethird/Marble-Marcher-Community-Edition) or `git clone https://github.com/WAUthethird/Marble-Marcher-Community-Edition.git`. @@ -15,7 +15,7 @@ This is a short and easy tutorial for building Marble Marcher: Community Edition 6. Download and unzip AntTweakBar to the `Libraries` folder: [http://anttweakbar.sourceforge.net](http://anttweakbar.sourceforge.net) * Inside the resulting unzipped folder should be just a folder called `AntTweakBar`. Move this folder outside its parent folder, into `Libraries`. Delete the now empty parent folder. -7. Download and unzip GLM to the `Libraries` folder: [https://github.com/g-truc/glm/releases/latest](https://github.com/g-truc/glm/releases/latest) +7. Download and unzip GLM to the `Libraries` folder. I used the .zip version of the 0.9.9.8 release: [https://github.com/g-truc/glm/releases/tag/0.9.9.8](https://github.com/g-truc/glm/releases/tag/0.9.9.8) * Inside the resulting unzipped folder should be just a folder called `glm`. Move this folder outside its parent folder, into `Libraries`. Delete the now empty parent folder. 8. Download and unzip GLEW to the `Libraries` folder. I used the 2.1.0 Windows binaries: [http://glew.sourceforge.net/](http://glew.sourceforge.net/) diff --git a/src/Scene.cpp b/src/Scene.cpp index 279f1532..99855bd4 100644 --- a/src/Scene.cpp +++ b/src/Scene.cpp @@ -505,12 +505,8 @@ void Scene::UpdateCamera(float dx, float dy, float dz, bool speedup) { } } } else if (cam_mode == DEORBIT) { - for (int i = 0; i < iters; i++) { - UpdateDeOrbit(dx, dy, dz); - if (cam_mode != DEORBIT) { - break; - } - } + //For deorbit, speedup is handled by the function called, not by calling the function multiple times + UpdateDeOrbit(dx, dy, dz, iters); } else if (cam_mode == MARBLE) { UpdateNormal(dx, dy, dz); } else if (cam_mode == GOAL || cam_mode == FINAL || cam_mode == MIDPOINT) { @@ -715,48 +711,64 @@ void Scene::UpdateOrbit() { } } -void Scene::UpdateDeOrbit(float dx, float dy, float dz) { - //Update the timer - const float t = timer * orbit_speed; - float b = std::min(float(std::max(timer - frame_orbit, 0)) / float(frame_deorbit - frame_orbit), 1.0f); - b *= b/(2*b*(b - 1) + 1); - timer += 1; - sum_time += 1; - +void Scene::UpdateDeOrbit(float dx, float dy, float dz, int iters) { if (timer > frame_deorbit + 1) { + for (int i = 0; i < iters; i++) { + //Update the timer + timer += 1; + sum_time += 1; + + if (cam_mode != DEORBIT) { + break; + } + } + //Camera during countdown is not sped up UpdateCameraOnly(dx, dy, dz); } else { - //Get marble location and rotational parameters - const float orbit_dist = level_copy.orbit_dist; - const Eigen::Vector3f orbit_pt(0.0f, orbit_dist, 0.0f); - const Eigen::Vector3f perp_vec(std::sin(t), 0.0f, std::cos(t)); - const Eigen::Vector3f orbit_cam_pos = orbit_pt + perp_vec * (orbit_dist * 2.5f); - cam_pos = cam_pos*orbit_smooth + orbit_cam_pos*(1 - orbit_smooth); - - //Solve for the look direction - const float start_look_x = level_copy.start_look_x; - cam_look_x = std::atan2(cam_pos.x(), cam_pos.z()); - ModPi(cam_look_x, start_look_x); - - //Solve for the look direction - cam_look_x_smooth = cam_look_x*(1 - b) + start_look_x*b; - - //Update look smoothing - cam_look_y = -0.3f; - cam_look_y_smooth = cam_look_y_smooth*orbit_smooth + cam_look_y*(1 - orbit_smooth); - - //Update the camera rotation matrix - MakeCameraRotation(); - - //Update the camera position - Eigen::Vector3f marble_cam_pos = marble_pos + cam_mat.block<3, 3>(0, 0) * Eigen::Vector3f(0.0f, 0.0f, marble_rad * cam_dist_smooth); - marble_cam_pos += Eigen::Vector3f(0.0f, marble_rad * cam_dist_smooth * 0.1f, 0.0f); - cam_pos_smooth = cam_pos*(1 - b) + marble_cam_pos*b; - cam_mat.block<3, 1>(0, 3) = cam_pos_smooth; + for (int i = 0; i < iters; i++) { + //Update the timer + const float t = timer * orbit_speed; + float b = std::min(float(std::max(timer - frame_orbit, 0)) / float(frame_deorbit - frame_orbit), 1.0f); + b *= b/(2*b*(b - 1) + 1); + timer += 1; + sum_time += 1; + + //Get marble location and rotational parameters + const float orbit_dist = level_copy.orbit_dist; + const Eigen::Vector3f orbit_pt(0.0f, orbit_dist, 0.0f); + const Eigen::Vector3f perp_vec(std::sin(t), 0.0f, std::cos(t)); + const Eigen::Vector3f orbit_cam_pos = orbit_pt + perp_vec * (orbit_dist * 2.5f); + cam_pos = cam_pos*orbit_smooth + orbit_cam_pos*(1 - orbit_smooth); + + //Solve for the look direction + const float start_look_x = level_copy.start_look_x; + cam_look_x = std::atan2(cam_pos.x(), cam_pos.z()); + ModPi(cam_look_x, start_look_x); + + //Solve for the look direction + cam_look_x_smooth = cam_look_x*(1 - b) + start_look_x*b; + + //Update look smoothing + cam_look_y = -0.3f; + cam_look_y_smooth = cam_look_y_smooth*orbit_smooth + cam_look_y*(1 - orbit_smooth); + + //Update the camera rotation matrix + MakeCameraRotation(); + + //Update the camera position + Eigen::Vector3f marble_cam_pos = marble_pos + cam_mat.block<3, 3>(0, 0) * Eigen::Vector3f(0.0f, 0.0f, marble_rad * cam_dist_smooth); + marble_cam_pos += Eigen::Vector3f(0.0f, marble_rad * cam_dist_smooth * 0.1f, 0.0f); + cam_pos_smooth = cam_pos*(1 - b) + marble_cam_pos*b; + cam_mat.block<3, 1>(0, 3) = cam_pos_smooth; + + //Required for a smooth transition later on + cam_look_x = cam_look_x_smooth; + cam_look_y = cam_look_y_smooth; - //Required for a smooth transition later on - cam_look_x = cam_look_x_smooth; - cam_look_y = cam_look_y_smooth; + if (cam_mode != DEORBIT) { + break; + } + } } //When done deorbiting, transition to play diff --git a/src/Scene.h b/src/Scene.h index 01beb48b..f3a42f39 100644 --- a/src/Scene.h +++ b/src/Scene.h @@ -190,7 +190,7 @@ class Scene { void UpdateIntro(bool ssaver); void UpdateOrbit(); - void UpdateDeOrbit(float dx, float dy, float dz); + void UpdateDeOrbit(float dx, float dy, float dz, int iters); void UpdateNormal(float dx, float dy, float dz); void UpdateCameraOnly(float dx, float dy, float dz); void UpdateGoal(); diff --git a/src/config.h.in b/src/config.h.in index 4442a6d7..1c6365e2 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -6,6 +6,6 @@ #define PROJECT_VER_MAJOR "@PROJECT_VERSION_MAJOR@" #define PROJECT_VER_MINOR "@PROJECT_VERSION_MINOR@" #define PROJECT_VER_PATCH "@PROJECT_VERSION_PATCH@" -#define YEAR "©2021" +#define YEAR "©2024" #endif // INCLUDE_GUARD \ No newline at end of file