diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2024-01-17 10:01:51 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2024-01-17 10:01:51 -0500 |
| commit | 2e680ebd77236f7b62b9ded1b083c86f9e13b1c8 (patch) | |
| tree | fe41366a6f2825b609c5a32eb11e3a597befd5f3 | |
| parent | 44664650a1b0660be769946cd132ef53573bbc32 (diff) | |
rename camera orientation to view
| -rw-r--r-- | editor/editor.cpp | 18 | ||||
| -rw-r--r-- | src/camera.cpp | 6 | ||||
| -rw-r--r-- | src/camera.hpp | 8 | ||||
| -rw-r--r-- | src/game.cpp | 10 | ||||
| -rw-r--r-- | src/window.cpp | 4 |
5 files changed, 23 insertions, 23 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp index 882b5f5..f22c3dd 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -52,7 +52,7 @@ PkeCamera cameraDbg { .rot = glm::quat(1.f, 0.f, 0.f, 0.f), .target = glm::vec3(0.f), .type = PKE_CAMERA_TYPE_PERSPECTIVE, - .orientation = PKE_CAMERA_ORIENTATION_FREE, + .view = PKE_CAMERA_VIEW_FREE, .stale = PKE_CAMERA_STALE_ALL, }; @@ -292,7 +292,7 @@ void PkeEditor_Tick(double delta) { selectedCamera = CameraHandle_MAX; if (ActiveCamera != &cameraDbg) { cameraDbg.pos = ActiveCamera->pos; - if (ActiveCamera->orientation == cameraDbg.orientation) { + if (ActiveCamera->view == cameraDbg.view) { cameraDbg.rot = ActiveCamera->rot; } else { cameraDbg.rot = glm::quat(UBO.view); @@ -692,7 +692,7 @@ void RecordImGuiCameras() { auto &cam = PkeCamera_Register(instPos); cam.target = ActiveCamera->target; cam.type = ActiveCamera->type; - cam.orientation = ActiveCamera->orientation; + cam.view = ActiveCamera->view; cam.isPrimary = false; } @@ -746,7 +746,7 @@ void RecordImGuiCameras() { ImGui::TableSetColumnIndex(5); ImGui::Text("%hhu", cam.type); ImGui::TableSetColumnIndex(6); - ImGui::Text("%hhu", cam.orientation); + ImGui::Text("%hhu", cam.view); ImGui::TableSetColumnIndex(7); ImGui::Text("%hhu", cam.stale); ImGui::TableSetColumnIndex(8); @@ -762,8 +762,8 @@ void RecordImGuiCameras() { int inputTextFlags = ImGuiInputTextFlags_ReadOnly; auto *cam = PkeCamera_Get(selectedCamera); if (cam) { - bool isOrientTarget{bool(static_cast<PkeCameraOrientation_T>(cam->orientation & PKE_CAMERA_ORIENTATION_TARGET))}; - bool isOrientFree{bool(static_cast<PkeCameraOrientation_T>(cam->orientation & PKE_CAMERA_ORIENTATION_FREE))}; + bool isOrientTarget{bool(static_cast<PkeCameraView_T>(cam->view & PKE_CAMERA_VIEW_TARGET))}; + bool isOrientFree{bool(static_cast<PkeCameraView_T>(cam->view & PKE_CAMERA_VIEW_FREE))}; if (ImGui::InputScalarN("Pos", ImGuiDataType_Float, &cam->pos, 3, nullptr, nullptr, nullptr)) cam->stale = cam->stale | PKE_CAMERA_STALE_POS; if (ImGui::InputScalarN("Rot", ImGuiDataType_Float, &cam->rot, 4, nullptr, nullptr, nullptr, isOrientFree ? 0 : inputTextFlags)) @@ -787,13 +787,13 @@ void RecordImGuiCameras() { ImGui::BeginDisabled(isOrientTarget); if (ImGui::Button("Target")) { - cam->orientation = PKE_CAMERA_ORIENTATION_TARGET; + cam->view = PKE_CAMERA_VIEW_TARGET; } ImGui::EndDisabled(); ImGui::SameLine(); ImGui::BeginDisabled(isOrientFree); if (ImGui::Button("Free")) { - cam->orientation = PKE_CAMERA_ORIENTATION_FREE; + cam->view = PKE_CAMERA_VIEW_FREE; } ImGui::EndDisabled(); @@ -1393,7 +1393,7 @@ void PkeEditor_Init() { NullCamera.rot = glm::quat(1.f, 0.f, 0.f, 0.f), NullCamera.target = glm::vec3(0.f), NullCamera.type = PKE_CAMERA_TYPE_PERSPECTIVE, - NullCamera.orientation = PKE_CAMERA_ORIENTATION_TARGET, + NullCamera.view = PKE_CAMERA_VIEW_TARGET, NullCamera.stale = PKE_CAMERA_STALE_ALL, threadPoolHandle = PkeThreads_Init(1, 1); diff --git a/src/camera.cpp b/src/camera.cpp index d22f4e4..984f106 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -14,7 +14,7 @@ PkeCamera NullCamera { .rot = glm::quat(1.f, 0.f, 0.f, 0.f), .target = glm::vec3(0.f), .type = PKE_CAMERA_TYPE_ORTHOGONAL, - .orientation = PKE_CAMERA_ORIENTATION_TARGET, + .view = PKE_CAMERA_VIEW_TARGET, .stale = PKE_CAMERA_STALE_ALL, .phys = { .inst = nullptr, @@ -96,7 +96,7 @@ void PkeCamera_AttachToInstance(CameraHandle cameraHandle, CompInstance *inst) { new (cam.phys.constraint) btPoint2PointConstraint(*cam.phys.inst->bt.rigidBody, *inst->bt.rigidBody, btVector3(0.f, 0.f, 0.f), cameraOffset); BtDynamicsWorld->addConstraint(cam.phys.constraint); - cam.orientation = PKE_CAMERA_ORIENTATION_TARGET; + cam.view = PKE_CAMERA_VIEW_TARGET; cam.stale = PKE_CAMERA_STALE_POSROT; } @@ -126,7 +126,7 @@ void PkeCamera_Destroy(CameraHandle cameraHandle) { cam.rot = glm::quat{}; cam.target = glm::vec3(0); cam.type = PkeCameraType_MAX; - cam.orientation = PkeCameraOrientation_MAX; + cam.view = PkeCameraView_MAX; cam.stale = PkeCameraStaleFlags_MAX; cam.phys.inst = CAFE_BABE(CompInstance); cam.phys.constraint = CAFE_BABE(btTypedConstraint); diff --git a/src/camera.hpp b/src/camera.hpp index ed21185..19e9da8 100644 --- a/src/camera.hpp +++ b/src/camera.hpp @@ -9,7 +9,7 @@ #include <cstdint> TypeSafeInt_Const_Expr(PkeCameraType, uint8_t, 0xFF); -TypeSafeInt_Const_Expr(PkeCameraOrientation, uint8_t, 0xFF); +TypeSafeInt_Const_Expr(PkeCameraView, uint8_t, 0xFF); TypeSafeInt_Const_Expr(PkeCameraStaleFlags, uint8_t, 0xFF); struct CameraHandle : public PkeHandle {}; @@ -19,8 +19,8 @@ constexpr CameraHandle CameraHandle_MAX = CameraHandle{}; constexpr PkeCameraType PKE_CAMERA_TYPE_PERSPECTIVE = PkeCameraType{1 << 0}; constexpr PkeCameraType PKE_CAMERA_TYPE_ORTHOGONAL = PkeCameraType{1 << 1}; -constexpr PkeCameraOrientation PKE_CAMERA_ORIENTATION_TARGET = PkeCameraOrientation{1 << 0}; -constexpr PkeCameraOrientation PKE_CAMERA_ORIENTATION_FREE = PkeCameraOrientation{1 << 1}; +constexpr PkeCameraView PKE_CAMERA_VIEW_TARGET = PkeCameraView{1 << 0}; +constexpr PkeCameraView PKE_CAMERA_VIEW_FREE = PkeCameraView{1 << 1}; constexpr PkeCameraStaleFlags PKE_CAMERA_STALE_POS = PkeCameraStaleFlags{1 << 0}; constexpr PkeCameraStaleFlags PKE_CAMERA_STALE_ROT = PkeCameraStaleFlags{1 << 1}; @@ -34,7 +34,7 @@ struct PkeCamera : public Entity_Base { glm::quat rot = glm::quat{}; glm::vec3 target = glm::vec3(0); PkeCameraType type = PkeCameraType_MAX; - PkeCameraOrientation orientation = PkeCameraOrientation_MAX; + PkeCameraView view = PkeCameraView_MAX; PkeCameraStaleFlags stale = PkeCameraStaleFlags_MAX; struct Phys { CompInstance *inst = nullptr; diff --git a/src/game.cpp b/src/game.cpp index 00e7edc..4390202 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -83,8 +83,8 @@ void SerializeCamera(std::ostringstream &stream, const PkeCamera &cam) { if (cam.type != c.type) { stream << PKE_FILE_CAMERA_TYPE << int(static_cast<PkeCameraType_T>(cam.type)) << std::endl; } - if (cam.orientation != c.orientation) { - stream << PKE_FILE_CAMERA_ORIENTATION << int(static_cast<PkeCameraOrientation_T>(cam.orientation)) << std::endl; + if (cam.view != c.view) { + stream << PKE_FILE_CAMERA_ORIENTATION << int(static_cast<PkeCameraView_T>(cam.view)) << std::endl; } if (cam.isPrimary != c.isPrimary) { stream << PKE_FILE_CAMERA_IS_PRIMARY << cam.isPrimary << std::endl; @@ -161,7 +161,7 @@ void ParseCamera(PkeLevel *level, std::ifstream &stream) { auto &rCam = PkeCamera_Register(instPos); rCam.target = cam.target; rCam.type = cam.type; - rCam.orientation = cam.orientation; + rCam.view = cam.view; rCam.isPrimary = cam.isPrimary; PkeLevel_RegisterCamera(level->levelHandle, rCam.camHandle); if (rCam.isPrimary == true) { @@ -221,10 +221,10 @@ void ParseCamera(PkeLevel *level, std::ifstream &stream) { } if (strncmp(readLine, PKE_FILE_CAMERA_ORIENTATION, strlen(PKE_FILE_CAMERA_ORIENTATION)) == 0) { uint64_t prefixLen = strlen(PKE_FILE_CAMERA_ORIENTATION); - PkeCameraOrientation_T handle_t; + PkeCameraView_T handle_t; STR2NUM_ERROR result = str2num(handle_t, readLine + prefixLen); assert(result == STR2NUM_ERROR::SUCCESS); - cam.orientation = PkeCameraOrientation{handle_t}; + cam.view = PkeCameraView{handle_t}; continue; } if (strncmp(readLine, PKE_FILE_CAMERA_IS_PRIMARY, strlen(PKE_FILE_CAMERA_IS_PRIMARY)) == 0) { diff --git a/src/window.cpp b/src/window.cpp index 61e7098..1d27664 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -911,9 +911,9 @@ void UpdateCamera() { UBO.model = glm::translate(glm::mat4(1.f), ActiveCamera->pos); } if (bool(ActiveCamera->stale & PKE_CAMERA_STALE_ROT)) { - if (bool(ActiveCamera->orientation == PKE_CAMERA_ORIENTATION_FREE)) { + if (bool(ActiveCamera->view == PKE_CAMERA_VIEW_FREE)) { UBO.view = glm::mat4_cast(ActiveCamera->rot); - } else if (bool(ActiveCamera->orientation == PKE_CAMERA_ORIENTATION_TARGET)) { + } else if (bool(ActiveCamera->view == PKE_CAMERA_VIEW_TARGET)) { UBO.view = glm::lookAt(glm::vec3(0), ActiveCamera->pos - ActiveCamera->target, glm::vec3(0.f, 1.f, 0.f)); } } |
