From 994f696537a38a443f0de542580762ce5ccc25a7 Mon Sep 17 00:00:00 2001 From: Solant Date: Thu, 16 May 2024 00:57:20 +0200 Subject: [PATCH] feat: add camera offset for aspect ratios --- MechoSoma/RUNTIME/aspect_ratio.cpp | 11 ++++++----- MechoSoma/RUNTIME/aspect_ratio.h | 2 ++ MechoSoma/Xreal/CameraDispatcher.cpp | 3 ++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/MechoSoma/RUNTIME/aspect_ratio.cpp b/MechoSoma/RUNTIME/aspect_ratio.cpp index 8050b0c..408f511 100644 --- a/MechoSoma/RUNTIME/aspect_ratio.cpp +++ b/MechoSoma/RUNTIME/aspect_ratio.cpp @@ -1,19 +1,20 @@ #include "aspect_ratio.h" -AspectRatioInfo createAspectRatio(int sc_width, int sc_height) { +AspectRatioInfo createAspectRatio(int sc_width, int sc_height, int cameraOffset) { int width = 480 / sc_height * sc_width; return AspectRatioInfo { .width = width, .offset = width - 640, + .cameraOffset = cameraOffset, }; } AspectRatioInfo aspectRatios[] = { - createAspectRatio(4, 3), - createAspectRatio(16, 9), - createAspectRatio(16, 10), - createAspectRatio(21, 9), + createAspectRatio(4, 3, 0), + createAspectRatio(16, 9, 100), + createAspectRatio(16, 10, 100), + createAspectRatio(21, 9, 100), }; AspectRatioInfo *AR_CURRENT = &aspectRatios[0]; diff --git a/MechoSoma/RUNTIME/aspect_ratio.h b/MechoSoma/RUNTIME/aspect_ratio.h index 9626171..5e08085 100644 --- a/MechoSoma/RUNTIME/aspect_ratio.h +++ b/MechoSoma/RUNTIME/aspect_ratio.h @@ -13,6 +13,8 @@ struct AspectRatioInfo { int width; // offset for right-aligned elements int offset; + // camera offset + int cameraOffset; }; extern AspectRatioInfo *AR_CURRENT; diff --git a/MechoSoma/Xreal/CameraDispatcher.cpp b/MechoSoma/Xreal/CameraDispatcher.cpp index 29bde78..9991ade 100644 --- a/MechoSoma/Xreal/CameraDispatcher.cpp +++ b/MechoSoma/Xreal/CameraDispatcher.cpp @@ -15,6 +15,7 @@ #include "Statistics.h" #include "MultibodyContact.h" #include "DebugPrm.h" +#include /* ----------------------------- EXTERN SECTION ----------------------------- */ extern cInterfaceVisGeneric *gb_IVisGeneric; @@ -1128,7 +1129,7 @@ void CameraDispatcher::setIvsCamera(const CameraCoords& coords) #ifdef GPX auto zOffset = (aspect - 1.33f) / (2.22f - 1.33f) * 100; #else - auto zOffset = 0; + auto zOffset = AR_CURRENT->cameraOffset; #endif Vect3f camera_position = R*vg + Vect3f(0, -coords.CenteringDelta*coords.cameraDistance, coords.cameraDistance + zOffset); camera_position.negate();