From 7ad45d1bc253dcaf7deeb7917bd137fe59658dfe Mon Sep 17 00:00:00 2001 From: Ashrindy Date: Sat, 2 Aug 2025 18:18:43 +0200 Subject: [PATCH 01/13] dvscene editor fix --- .../node-inspector/elements/Weather.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ui/operation-modes/modes/dvscene-editor/node-inspector/elements/Weather.h b/src/ui/operation-modes/modes/dvscene-editor/node-inspector/elements/Weather.h index 1fc9803..f2cd119 100644 --- a/src/ui/operation-modes/modes/dvscene-editor/node-inspector/elements/Weather.h +++ b/src/ui/operation-modes/modes/dvscene-editor/node-inspector/elements/Weather.h @@ -2,13 +2,28 @@ #include "../Elements.h" namespace ui::operation_modes::modes::dvscene_editor { +#ifdef DEVTOOLS_TARGET_SDK_rangers + const char* weatherTypeNames[] = { + "SUNNY", + "CLOUDY", + "RAINY", + "SANDSTORM", + "METEOR_SHOWER" + }; +#endif + + template<> bool RenderElementInspector(char* element) { bool changed = false; auto* data = reinterpret_cast(element); +#ifdef DEVTOOLS_TARGET_SDK_miller unsigned int weatherType = static_cast(data->weatherType); if(changed |= Editor("Weather Type", weatherType)) data->weatherType = static_cast(weatherType); +#else + changed |= ComboEnum("Weather Type", data->weatherType, weatherTypeNames); +#endif return changed; } } From 9550390f4e147142c6f3cbb1513234a199698cc1 Mon Sep 17 00:00:00 2001 From: Ashrindy Date: Wed, 27 Aug 2025 17:14:49 +0200 Subject: [PATCH 02/13] resmodel preview, pba debug visual fixed --- sdks/miller-sdk | 2 +- sdks/rangers-sdk | 2 +- sdks/wars-sdk | 2 +- src/CMakeLists.txt | 1 + src/debug-rendering/renderables/Bones.cpp | 29 --- .../renderables/PhysicalAnimation.cpp | 218 +++++++++--------- src/ui/common/editors/Camera.cpp | 32 ++- src/ui/common/editors/Camera.h | 5 +- src/ui/common/editors/Needle.cpp | 4 - .../game-service-inspectors/EventPlayer.cpp | 2 +- .../modes/dvscene-editor/DvNode.cpp | 1 + .../modes/dvscene-editor/SceneSettings.cpp | 2 +- .../dvscene-editor/timeline/Timeline.cpp | 3 +- .../GOCPlayerBlackboard.cpp | 30 ++- .../GOCPlayerKinematicParams.cpp | 2 + .../rangers/GOCColliderQuery.cpp | 10 +- src/ui/resources/ResourceBrowser.cpp | 3 + src/ui/resources/editors/ResEffectEditor.cpp | 4 +- src/ui/resources/editors/ResModelEditor.cpp | 168 ++++++++++++++ src/ui/resources/editors/ResModelEditor.h | 24 ++ 20 files changed, 367 insertions(+), 177 deletions(-) create mode 100644 src/ui/resources/editors/ResModelEditor.cpp create mode 100644 src/ui/resources/editors/ResModelEditor.h diff --git a/sdks/miller-sdk b/sdks/miller-sdk index 9fe3ce8..93647cd 160000 --- a/sdks/miller-sdk +++ b/sdks/miller-sdk @@ -1 +1 @@ -Subproject commit 9fe3ce8fdd7d39ae02a6fd6b9655fa73ea2fcdef +Subproject commit 93647cda6e001bbc0763cea4dc5f19873785c5f9 diff --git a/sdks/rangers-sdk b/sdks/rangers-sdk index c406df9..7125747 160000 --- a/sdks/rangers-sdk +++ b/sdks/rangers-sdk @@ -1 +1 @@ -Subproject commit c406df9bb35388299bf7755b9b154adc60a3d5a9 +Subproject commit 7125747c58b1bba87863b056e7afcd66e3947c61 diff --git a/sdks/wars-sdk b/sdks/wars-sdk index b4128e6..2c45499 160000 --- a/sdks/wars-sdk +++ b/sdks/wars-sdk @@ -1 +1 @@ -Subproject commit b4128e6918dfbde5fdcc13cb94005dcb306f3f61 +Subproject commit 2c4549976fd8fb1c911487dd5ebd733cafd353f6 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 137804a..473c561 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -292,6 +292,7 @@ if(${DEVTOOLS_TARGET_SDK} STREQUAL "rangers") ResGismoConfigPlanEditor ResMirageLightEditor ResVibrationEditor + ResModelEditor ) set(DEVTOOLS_FEATURE_CORE_SERVICE_INSPECTORS MemoryInspector diff --git a/src/debug-rendering/renderables/Bones.cpp b/src/debug-rendering/renderables/Bones.cpp index 9e22b0c..cfd9bcd 100644 --- a/src/debug-rendering/renderables/Bones.cpp +++ b/src/debug-rendering/renderables/Bones.cpp @@ -58,35 +58,6 @@ namespace devtools::debug_rendering::renderables { ctx.DrawPrimitive(hh::gfnd::PrimitiveType::LINE_LIST, &xs[0], &indices[0], totalBoneCount * 2); ctx.DrawPrimitive(hh::gfnd::PrimitiveType::LINE_LIST, &ys[0], &indices[0], totalBoneCount * 2); ctx.DrawPrimitive(hh::gfnd::PrimitiveType::LINE_LIST, &zs[0], &indices[0], totalBoneCount * 2); - - - for (auto* gameObject : gameManager->objects) { - for (auto* goc : gameObject->components) { - if (goc->pStaticClass == hh::pba::GOCPhysicalAnimationBullet::GetClass()) { - if (goc->nameHash != csl::ut::HashString("Cape")) - continue; - - auto* gocPBA = static_cast(goc); - - csl::ut::MoveArray ps{ hh::fnd::MemoryRouter::GetTempAllocator() }; - gocPBA->GetRigidBodyPositions(ps); - - auto animTf = TransformToAffine3f(gocPBA->gocAnimationSingle->GetTransform()); - for (size_t i = 0; i < gocPBA->physSkelRes->rigidbodies.size(); i++) { - auto& rb = gocPBA->physSkelRes->rigidbodies[i]; - auto& p = ps[i]; - - csl::math::Matrix34 tf{}; - tf.fromPositionOrientationScale(p.m_Position, p.m_Rotation, csl::math::Vector3{ 1.0f, 1.0f, 1.0f }); - - if (rb.shape == ucsl::resources::pba::v1::RigidBody::Shape::SPHERE) - ctx.DrawCapsule(animTf * tf, rb.shapeRadius, rb.shapeHeight, { 0, 255, 0, 255 }); - else - ctx.DrawOBB(animTf * tf, { rb.shapeRadius, rb.shapeHeight, rb.shapeDepth }, { 0, 255, 0, 255 }); - } - } - } - } #endif } diff --git a/src/debug-rendering/renderables/PhysicalAnimation.cpp b/src/debug-rendering/renderables/PhysicalAnimation.cpp index f0df5ad..daa8549 100644 --- a/src/debug-rendering/renderables/PhysicalAnimation.cpp +++ b/src/debug-rendering/renderables/PhysicalAnimation.cpp @@ -1,36 +1,9 @@ #ifndef DEVTOOLS_TARGET_SDK_wars #include "PhysicalAnimation.h" #include +#include namespace devtools::debug_rendering::renderables { - struct btCollisionShape { - int64_t vftable; - csl::math::Matrix34 worldTransform; - }; - - struct Node { - char padding0[16]; - csl::math::Vector3 position; - char padding1[224]; - }; - - struct alignas(16) Link { - char padding0[32]; - Node* nodes[2]; - char padding1[32]; - }; - - struct alignas(16) btSoftBody { - char padding0[952]; - int nodeCount; - int nodeCapacity; - Node* nodes; - char padding1[48]; - int linkCount; - int linkCapacity; - Link* links; - }; - csl::math::Matrix34 convertBulletToDirectX(const csl::math::Matrix34& bulletStyle) { csl::math::Matrix34 directXStyle; directXStyle.linear() = bulletStyle.linear().transpose(); @@ -43,98 +16,115 @@ namespace devtools::debug_rendering::renderables { if (!enabled) return; - //auto* gameManager = hh::game::GameManager::GetInstance(); - //if (!gameManager) - // return; - - //for (auto* gameObject : gameManager->objects) { - // for (auto* goc : gameObject->components) { - // if (goc->pStaticClass == hh::pba::GOCPhysicalAnimationBullet::GetClass()) { - // auto* physGoc = static_cast(goc); - // for (auto i = 0; i < physGoc->rigidBodies.size(); i++) { - // const csl::ut::Color8 rigidBodyColor = { 255, 0, 255, 255 }; - // auto* rigidBody = reinterpret_cast(physGoc->rigidBodies[i*2]); - // csl::math::Matrix34 worldTransform = convertBulletToDirectX(rigidBody->worldTransform); - // if (!gameObject->GetComponent()) - // worldTransform.translation() += physGoc->gocAnimator0->visualModel->frame2->fullTransform.position; - // auto& resRigidBody = physGoc->physSkelRes->rigidbodies[i]; - // if (resRigidBody.isShapeBox) - // ctx.DrawOBB(worldTransform, csl::math::Vector3(resRigidBody.shapeRadius, resRigidBody.shapeHeight, resRigidBody.shapeDepth), rigidBodyColor); - // else { - // if (resRigidBody.shapeHeight > 0) - // ctx.DrawCapsule(worldTransform, resRigidBody.shapeRadius, resRigidBody.shapeHeight, rigidBodyColor); - // else - // ctx.DrawSphere(worldTransform, resRigidBody.shapeRadius, rigidBodyColor); - // } - // } - // if (physGoc->hasSoftBody) { - // for (auto i = 0; i < physGoc->softbodies.size(); i++) { - // const csl::ut::Color8 softBodyColor = { 0, 255, 0, 255 }; - // auto* softBody = reinterpret_cast(physGoc->softbodies[i * 2]); - // auto& resSoftBody = physGoc->physSkelRes->softbodies[i]; - // for (auto x = 0; x < softBody->nodeCount; x++) { - // auto& node = softBody->nodes[x]; - // auto transform = csl::math::Matrix34::Identity(); - // transform.translate(node.position); - // ctx.DrawSphere(transform, 0.01f, softBodyColor); - // } - // auto* tempAlloc = hh::fnd::MemoryRouter::GetTempAllocator(); - // hh::gfnd::DrawVertex* vertices = static_cast(tempAlloc->Alloc((2 * softBody->linkCount) * sizeof(hh::gfnd::DrawVertex), 4)); - // unsigned short* indices = static_cast(tempAlloc->Alloc((2 * softBody->linkCount) * sizeof(short), 2)); - // for (auto x = 0; x < softBody->linkCount; x++) { - // auto& link = softBody->links[x]; - // int curVert = x * 2; - // vertices[curVert].x = link.nodes[0]->position.x(); - // vertices[curVert].y = link.nodes[0]->position.y(); - // vertices[curVert].z = link.nodes[0]->position.z(); - // vertices[curVert].color = 0xFF00FF00; - // vertices[curVert + 1].x = link.nodes[1]->position.x(); - // vertices[curVert + 1].y = link.nodes[1]->position.y(); - // vertices[curVert + 1].z = link.nodes[1]->position.z(); - // vertices[curVert + 1].color = 0xFF00FF00; - // indices[curVert] = curVert; - // indices[curVert + 1] = curVert + 1; - // } - // ctx.DrawPrimitive(hh::gfnd::PrimitiveType::LINE_LIST, vertices, indices, softBody->linkCount * 2); - // tempAlloc->Free(vertices); - // tempAlloc->Free(indices); - // } - // } - // } - // } - //} + auto* gameManager = hh::game::GameManager::GetInstance(); + if (!gameManager) + return; + + for (auto* gameObject : gameManager->objects) { + for (auto* goc : gameObject->components) { + if (goc->pStaticClass == hh::pba::GOCPhysicalAnimationBullet::GetClass()) { + auto* gocPBA = static_cast(goc); + + auto animTf = TransformToAffine3f(gocPBA->gocAnimationSingle->GetTransform()); + + csl::ut::MoveArray rigidBodyPositions{ hh::fnd::MemoryRouter::GetTempAllocator() }; + gocPBA->GetRigidBodyPositions(rigidBodyPositions); + + for (size_t i = 0; i < gocPBA->physSkelRes->rigidbodies.size(); i++) { + static const csl::ut::Color8 rigidBodyColor = { 255, 0, 255, 255 }; + auto& rb = gocPBA->physSkelRes->rigidbodies[i]; + auto& pos = rigidBodyPositions[i]; + + csl::math::Matrix34 tf{}; + tf.fromPositionOrientationScale(pos.m_Position, pos.m_Rotation, csl::math::Vector3{ 1.0f, 1.0f, 1.0f }); + + if (rb.shape == ucsl::resources::pba::v1::RigidBody::Shape::SPHERE) { + if (rb.shapeHeight > 0) + ctx.DrawCapsule(animTf * tf, rb.shapeRadius, rb.shapeHeight, rigidBodyColor); + else + ctx.DrawSphere(animTf * tf, rb.shapeRadius, rigidBodyColor); + } + else + ctx.DrawOBB(animTf * tf, { rb.shapeRadius, rb.shapeHeight, rb.shapeDepth }, rigidBodyColor); + } + + if (gocPBA->hasSoftBody) { + for (auto i = 0; i < gocPBA->physSkelRes->softbodies.size(); i++) { + static const csl::ut::Color8 softBodyColor = { 0, 255, 0, 255 }; + auto& sb = gocPBA->physSkelRes->softbodies[i]; + + csl::ut::MoveArray nodePositions{ hh::fnd::MemoryRouter::GetTempAllocator() }; + gocPBA->GetSoftBodyNodePositions(i, nodePositions); + + for (auto x = 0; x < sb.nodes.size(); x++) { + auto transform = csl::math::Matrix34::Identity(); + transform.translate(nodePositions[x]); + ctx.DrawSphere(transform, 0.01f, softBodyColor); + } + + auto* tempAlloc = hh::fnd::MemoryRouter::GetTempAllocator(); + + unsigned int linkCount = sb.links.size(); + unsigned int linkSize = linkCount * 2; + hh::gfnd::DrawVertex* vertices = static_cast(tempAlloc->Alloc(linkSize * sizeof(hh::gfnd::DrawVertex), 4)); + unsigned short* indices = static_cast(tempAlloc->Alloc(linkSize * sizeof(short), 2)); + + for (auto x = 0; x < linkCount; x++) { + auto& link = sb.links[x]; + csl::math::Vector3 nodes[2] = { nodePositions[link.verts[0]], nodePositions[link.verts[1]] }; + int curVert = x * 2; + vertices[curVert].x = nodes[0].x(); + vertices[curVert].y = nodes[0].y(); + vertices[curVert].z = nodes[0].z(); + vertices[curVert].color = 0xFF00FF00; + vertices[curVert + 1].x = nodes[1].x(); + vertices[curVert + 1].y = nodes[1].y(); + vertices[curVert + 1].z = nodes[1].z(); + vertices[curVert + 1].color = 0xFF00FF00; + indices[curVert] = curVert; + indices[curVert + 1] = curVert + 1; + } + ctx.DrawPrimitive(hh::gfnd::PrimitiveType::LINE_LIST, vertices, indices, linkSize); + + tempAlloc->Free(vertices); + tempAlloc->Free(indices); + } + } + } + } + } } void PhysicalAnimation::RenderImGuiDebugVisuals(const ImGuiDrawContext& ctx) { - if (!enabled) + /*if (!enabled) + return; + + auto* gameManager = hh::game::GameManager::GetInstance(); + if (!gameManager) return; - //auto* gameManager = hh::game::GameManager::GetInstance(); - //if (!gameManager) - // return; - - //for (auto* gameObject : gameManager->objects) { - // for (auto* goc : gameObject->components) { - // if (goc->pStaticClass == hh::pba::GOCPhysicalAnimationBullet::GetClass()) { - // auto* physGoc = static_cast(goc); - // for (auto i = 0; i < physGoc->rigidBodies.size(); i++) { - // const csl::ut::Color8 rigidBodyColor = { 255, 0, 255, 255 }; - // auto* rigidBody = reinterpret_cast(physGoc->rigidBodies[i*2]); - // auto& resRigidBody = physGoc->physSkelRes->rigidbodies[i]; - // csl::math::Vector3 translation = csl::math::Vector3{ rigidBody->worldTransform.translation() }; - // if (!gameObject->GetComponent()) - // translation += physGoc->gocAnimator0->visualModel->frame2->fullTransform.position; - // auto maybePos = ctx.WorldCoordsToImGui(translation); - - // if (!maybePos.has_value()) - // continue; - - // OverlayTag(resRigidBody.boneName, false, maybePos.value(), ImVec4(0.0f, 1.0f, 0.0f, 1.0f)); - // } - // } - // } - //} + for (auto* gameObject : gameManager->objects) { + for (auto* goc : gameObject->components) { + if (goc->pStaticClass == hh::pba::GOCPhysicalAnimationBullet::GetClass()) { + auto* physGoc = static_cast(goc); + for (auto i = 0; i < physGoc->rigidBodies.size(); i++) { + const csl::ut::Color8 rigidBodyColor = { 255, 0, 255, 255 }; + auto* rigidBody = reinterpret_cast(physGoc->rigidBodies[i*2]); + auto& resRigidBody = physGoc->physSkelRes->rigidbodies[i]; + csl::math::Vector3 translation = csl::math::Vector3{ rigidBody->worldTransform.translation() }; + if (!gameObject->GetComponent()) + translation += physGoc->gocAnimator0->visualModel->frame2->fullTransform.position; + auto maybePos = ctx.WorldCoordsToImGui(translation); + + if (!maybePos.has_value()) + continue; + + OverlayTag(resRigidBody.boneName, false, maybePos.value(), ImVec4(0.0f, 1.0f, 0.0f, 1.0f)); + } + } + } + }*/ } } #endif diff --git a/src/ui/common/editors/Camera.cpp b/src/ui/common/editors/Camera.cpp index 2f7d885..73e4113 100644 --- a/src/ui/common/editors/Camera.cpp +++ b/src/ui/common/editors/Camera.cpp @@ -3,23 +3,36 @@ using namespace app_cmn::camera; -bool Editor(const char* label, CameraParameter::Target& target) { +bool Editor(const char* label, CameraParameter::Orientation::Target& target) { bool edited{}; ImGui::PushID(label); - edited |= Editor("Position", target.position); - edited |= Editor("Offset", target.offset); - edited |= Editor("Unk3", target.unk3); + edited |= Editor("Up Vector", target.upVector); + edited |= Editor("Unk8b", target.unk8b); ImGui::PopID(); return edited; } -bool Editor(const char* label, CameraParameter::Offset& offset) { +bool Editor(const char* label, CameraParameter::Orientation::Offset& offset) { bool edited{}; ImGui::PushID(label); edited |= Editor("Offset", reinterpret_cast(offset)); + edited |= Editor("Target Position", offset.targetPosition); + edited |= Editor("Use Position", offset.usePosition); + + ImGui::PopID(); + return edited; +} + +bool Editor(const char* label, CameraParameter::Positioning& positioning) { + bool edited{}; + ImGui::PushID(label); + + edited |= Editor("Position", positioning.position); + edited |= Editor("Offset", positioning.offset); + edited |= Editor("Unk3", positioning.unk3); ImGui::PopID(); return edited; @@ -29,10 +42,8 @@ bool Editor(const char* label, CameraParameter::Orientation& orientation) { bool edited{}; ImGui::PushID(label); - edited |= Editor("Unk7", orientation.unk7); - edited |= Editor("Unk8", orientation.unk8); - edited |= Editor("Unk9", orientation.unk9); - edited |= Editor("Unk8b", orientation.unk8b); + edited |= Editor("Offset", orientation.offset); + edited |= Editor("Target", orientation.target); ImGui::PopID(); return edited; @@ -42,8 +53,7 @@ bool Editor(const char* label, CameraParameter& parameter) { bool edited{}; ImGui::PushID(label); - edited |= Editor("Target", parameter.target); - edited |= Editor("Offset", parameter.offset); + edited |= Editor("Positioning", parameter.positioning); edited |= Editor("Orientation", parameter.orientation); ImGui::PopID(); diff --git a/src/ui/common/editors/Camera.h b/src/ui/common/editors/Camera.h index 1bdff12..d0b0dd0 100644 --- a/src/ui/common/editors/Camera.h +++ b/src/ui/common/editors/Camera.h @@ -1,8 +1,9 @@ #pragma once -bool Editor(const char* label, app_cmn::camera::CameraParameter::Target& target); -bool Editor(const char* label, app_cmn::camera::CameraParameter::Offset& offset); +bool Editor(const char* label, app_cmn::camera::CameraParameter::Orientation::Target& target); +bool Editor(const char* label, app_cmn::camera::CameraParameter::Orientation::Offset& offset); bool Editor(const char* label, app_cmn::camera::CameraParameter::Orientation& orientation); +bool Editor(const char* label, app_cmn::camera::CameraParameter::Positioning& positioning); bool Editor(const char* label, app_cmn::camera::CameraParameter& parameter); bool Editor(const char* label, app_cmn::camera::FrustumParameter& parameter); bool Editor(const char* label, app_cmn::camera::CameraPose& pose); diff --git a/src/ui/common/editors/Needle.cpp b/src/ui/common/editors/Needle.cpp index a45c29b..496b8d5 100644 --- a/src/ui/common/editors/Needle.cpp +++ b/src/ui/common/editors/Needle.cpp @@ -401,10 +401,6 @@ bool Editor(const char* label, hh::needle::RenderingPipelineRangers& pipeline) edited |= Editor("qword140", pipeline.qword140); edited |= Editor("qword148", pipeline.qword148); edited |= Editor("qword150", pipeline.qword150); - edited |= Editor("qword178", pipeline.qword178); - edited |= Editor("qword180", pipeline.qword180); - edited |= Editor("qword188", pipeline.qword188); - edited |= Editor("qword190", pipeline.qword190); edited |= Editor("qword198", pipeline.qword198); edited |= Editor("qword1A0", pipeline.qword1A0); edited |= Editor("qword1A8", pipeline.qword1A8); diff --git a/src/ui/game-services/game-service-inspectors/EventPlayer.cpp b/src/ui/game-services/game-service-inspectors/EventPlayer.cpp index cbec1d7..20703f2 100644 --- a/src/ui/game-services/game-service-inspectors/EventPlayer.cpp +++ b/src/ui/game-services/game-service-inspectors/EventPlayer.cpp @@ -14,7 +14,7 @@ void RenderGameServiceInspector(app::evt::EventPlayer& service) } if (ImGui::TreeNode("Event Scenes")) { for (auto* x : service.evtSceneMgr->evtScenes) { - if (ImGui::TreeNode(x->setupData.cutsceneName)) { + if (ImGui::TreeNode(x->setupData.playInfo.cutsceneName)) { Editor("unk2", x->unk2); Editor("unk3", x->unk3); ImGui::TreePop(); diff --git a/src/ui/operation-modes/modes/dvscene-editor/DvNode.cpp b/src/ui/operation-modes/modes/dvscene-editor/DvNode.cpp index 60f6175..58a50a5 100644 --- a/src/ui/operation-modes/modes/dvscene-editor/DvNode.cpp +++ b/src/ui/operation-modes/modes/dvscene-editor/DvNode.cpp @@ -83,6 +83,7 @@ namespace ui::operation_modes::modes::dvscene_editor { return node->nodeType == hh::dv::DvNodeBase::NodeType::PATH; } + //TODO: Fix parent transforms Eigen::Affine3f DvNode::GetTransform() const { if(CanTransform()) diff --git a/src/ui/operation-modes/modes/dvscene-editor/SceneSettings.cpp b/src/ui/operation-modes/modes/dvscene-editor/SceneSettings.cpp index ce3d74e..52ebcd0 100644 --- a/src/ui/operation-modes/modes/dvscene-editor/SceneSettings.cpp +++ b/src/ui/operation-modes/modes/dvscene-editor/SceneSettings.cpp @@ -49,7 +49,7 @@ namespace ui::operation_modes::modes::dvscene_editor { GetBehavior>()->DeselectAll(); context.goDVSC = dvsc; for (auto* evtScn : hh::game::GameManager::GetInstance()->GetService()->evtSceneMgr->evtScenes) - if (strcmp(evtScn->setupData.cutsceneName, dvsc->cutsceneName.c_str()) == 0) + if (strcmp(evtScn->setupData.playInfo.cutsceneName, dvsc->cutsceneName.c_str()) == 0) context.evtScene = evtScn; context.parsedScene = new dv::DvScene; context.parsedScene->read(static_cast(dvsc->resource->binaryData), dvsc->resource->size); diff --git a/src/ui/operation-modes/modes/dvscene-editor/timeline/Timeline.cpp b/src/ui/operation-modes/modes/dvscene-editor/timeline/Timeline.cpp index 46dc6e3..536a745 100644 --- a/src/ui/operation-modes/modes/dvscene-editor/timeline/Timeline.cpp +++ b/src/ui/operation-modes/modes/dvscene-editor/timeline/Timeline.cpp @@ -72,8 +72,9 @@ namespace ui::operation_modes::modes::dvscene_editor { if ((context.evtScene->flags.bits & 0x80) != 0) context.evtScene->SetMovie(play); x->moviePlayer->SetPause(!play); - context.goDVSC->play = play; } + if (changed) + context.goDVSC->play = play; } ImGui::EndChild(); } diff --git a/src/ui/operation-modes/modes/object-inspection/component-inspectors/GOCPlayerBlackboard.cpp b/src/ui/operation-modes/modes/object-inspection/component-inspectors/GOCPlayerBlackboard.cpp index fb01f5f..02c087a 100644 --- a/src/ui/operation-modes/modes/object-inspection/component-inspectors/GOCPlayerBlackboard.cpp +++ b/src/ui/operation-modes/modes/object-inspection/component-inspectors/GOCPlayerBlackboard.cpp @@ -41,7 +41,8 @@ void RenderBlackboardBattleInspector(app::player::BlackboardBattle& blackboard) csl::ut::MoveArray debugArray2; csl::ut::MoveArray unk4; ImGui::DragScalar("Unk5", ImGuiDataType_U32, &blackboard.unk5); - ImGui::DragScalar("unk6", ImGuiDataType_U16, &blackboard.unk6); + ImGui::DragScalar("unk6a", ImGuiDataType_U8, &blackboard.unk6a); + ImGui::DragScalar("unk6b", ImGuiDataType_U8, &blackboard.unk6b); ImGui::DragScalar("unk7", ImGuiDataType_U8, &blackboard.unk7); ImGui::DragScalar("Combo count", ImGuiDataType_U32, &blackboard.comboCount); ImGui::DragFloat("Phantom rush amount", &blackboard.phantomRushAmount); @@ -53,7 +54,8 @@ void RenderBlackboardBattleInspector(app::player::BlackboardBattle& blackboard) ImGui::Text("%zx", blackboard.unk13); ImGui::Text("%zx", blackboard.unk14); ImGui::Text("Unk16: %s", blackboard.unk16.c_str()); - ImGui::DragScalar("unk17", ImGuiDataType_U16, &blackboard.unk17); + ImGui::DragScalar("flags0", ImGuiDataType_U8, &blackboard.flags0); + ImGui::DragScalar("flags1", ImGuiDataType_U8, &blackboard.flags1); } const char* difficultyNames[]{ "EASY", "NORMAL", "HARD", "EXTREME" }; @@ -404,9 +406,24 @@ const char* worldFlagNames[128]{ nullptr, }; +const char* characterIdNames[] = { + "SONIC", + "AMY", + "KNUCKLES", + "TAILS", + "NONE" +}; + +const char* formStateNames[] = { + "NORMAL", + "SUPER", + "UNK0" +}; + void RenderBlackboardStatusInspector(app::player::BlackboardStatus& blackboard) { - ImGui::DragScalar("word20", ImGuiDataType_U16, &blackboard.word20); - ImGui::DragScalar("dword24", ImGuiDataType_U32, &blackboard.dword24); + ImGui::DragScalar("byte20", ImGuiDataType_U8, &blackboard.byte20); + ComboEnum("characterId", blackboard.characterId, characterIdNames); + ComboEnum("formState", blackboard.formState, formStateNames); if (ImGui::TreeNode("Combat flags")) { for (size_t i = 0; i < 64; i++) { @@ -453,13 +470,12 @@ void RenderBlackboardStatusInspector(app::player::BlackboardStatus& blackboard) ImGui::Text("Out of control time: %f", blackboard.outOfControlTime); ImGui::Text("In control time: %f", blackboard.inControlTime); ImGui::Text("%zx", blackboard.qword58); - ImGui::Text("%zx", blackboard.qword60); + ImGui::Text("%zx", blackboard.dword60); + ImGui::Text("%zx", blackboard.dword64); //ut::PriorityList> qword68; //csl::ut::InplaceMoveArray qword90; //csl::ut::InplaceMoveArray qwordC0; //csl::ut::InplaceMoveArray qwordF0; - ImGui::Text("%zx", blackboard.qword120); - ImGui::DragScalar("dword128", ImGuiDataType_U32, &blackboard.dword128); //ut::PriorityList> qword130; Editor("oword160", blackboard.oword160); ImGui::DragScalar("dword170", ImGuiDataType_U32, &blackboard.dword170); diff --git a/src/ui/operation-modes/modes/object-inspection/component-inspectors/GOCPlayerKinematicParams.cpp b/src/ui/operation-modes/modes/object-inspection/component-inspectors/GOCPlayerKinematicParams.cpp index 27028c4..850060c 100644 --- a/src/ui/operation-modes/modes/object-inspection/component-inspectors/GOCPlayerKinematicParams.cpp +++ b/src/ui/operation-modes/modes/object-inspection/component-inspectors/GOCPlayerKinematicParams.cpp @@ -20,8 +20,10 @@ void RenderComponentInspector(app::player::GOCPlayerKinematicParams& component) ImGui::Text("Unk7"); Viewer("Unk7", component.unk7); +#ifdef DEVTOOLS_TARGET_SDK_miller Editor("Unk9.unk1", component.unk9.unk1); Editor("Unk9.unk2", component.unk9.unk2); +#endif Editor("Unk11.unk3", component.unk11.unk3); Editor("Unk14.unk1", component.unk14.unk1); Editor("Unk14.unk2", component.unk14.unk2); diff --git a/src/ui/operation-modes/modes/object-inspection/component-inspectors/rangers/GOCColliderQuery.cpp b/src/ui/operation-modes/modes/object-inspection/component-inspectors/rangers/GOCColliderQuery.cpp index 0916dfc..785ca70 100644 --- a/src/ui/operation-modes/modes/object-inspection/component-inspectors/rangers/GOCColliderQuery.cpp +++ b/src/ui/operation-modes/modes/object-inspection/component-inspectors/rangers/GOCColliderQuery.cpp @@ -5,12 +5,18 @@ void RenderComponentInspector(app::physics::GOCColliderQuery& component) { Editor("Local transform", component.localTransform); Editor("World transform", component.worldTransform); + CheckboxFlags("Enter Flag", component.ownerOverlapFlags, app::physics::GOCColliderQuery::OverlapFlag::ENTER); + CheckboxFlags("Leave Flag", component.ownerOverlapFlags, app::physics::GOCColliderQuery::OverlapFlag::LEAVE); + CheckboxFlags("Stay Flag", component.ownerOverlapFlags, app::physics::GOCColliderQuery::OverlapFlag::STAY); + CheckboxFlags("Enabled", component.flags, app::physics::GOCColliderQuery::Flag::ENABLED); } void RenderComponentInspector(app::physics::GOCMoveSphereColliderQuery& component) { RenderComponentInspector(static_cast(component)); - Editor("unk201", component.unk201); - Editor("unk201", component.unk202); + Editor("Position", component.position); + Editor("Velocity", component.velocity); + Editor("Radius", component.radius); + Editor("unk204", component.unk204); } diff --git a/src/ui/resources/ResourceBrowser.cpp b/src/ui/resources/ResourceBrowser.cpp index 257b260..b92e755 100644 --- a/src/ui/resources/ResourceBrowser.cpp +++ b/src/ui/resources/ResourceBrowser.cpp @@ -7,6 +7,7 @@ #include "editors/ResGismoConfigPlanEditor.h" #include "editors/ResMirageLightEditor.h" #include "editors/ResVibrationEditor.h" +#include "editors/ResModelEditor.h" #endif //#include "editors/ResObjectWorldEditor.h" #include "editors/ResMaterialEditor.h" @@ -242,6 +243,8 @@ void ResourceBrowser::RenderResource(ManagedResource* resource) { ResMirageLightEditor::Create(Desktop::instance->GetAllocator(), static_cast(resource)); else if (typeInfo == hh::hid::ResVibration::GetTypeInfo()) ResVibrationEditor::Create(Desktop::instance->GetAllocator(), static_cast(resource)); + else if (typeInfo == hh::gfx::ResModel::GetTypeInfo()) + ResModelEditor::Create(Desktop::instance->GetAllocator(), static_cast(resource)); #endif } diff --git a/src/ui/resources/editors/ResEffectEditor.cpp b/src/ui/resources/editors/ResEffectEditor.cpp index 1086009..267ed7c 100644 --- a/src/ui/resources/editors/ResEffectEditor.cpp +++ b/src/ui/resources/editors/ResEffectEditor.cpp @@ -1,6 +1,6 @@ #include "ResEffectEditor.h" -bool Editor(const char* label, ucsl::resources::cemt::v100000::Texture& texture); +bool Editor(const char* label, ucsl::resources::cemt::v100000::TextureParam& texture); bool Editor(const char* label, ucsl::resources::cemt::v100000::ChildEffect& effect); bool Editor(const char* label, ucsl::resources::cemt::v100000::ModifierParam::GravityVectorSettings& settings); bool Editor(const char* label, ucsl::resources::cemt::v100000::ModifierParam::GravityOtherSettings& settings); @@ -31,7 +31,7 @@ const char* modifierNames[] = { "FLUCTUATION", }; -bool Editor(const char* label, Texture& texture) { +bool Editor(const char* label, TextureParam& texture) { bool edited{}; ImGui::PushID(label); edited |= Editor("name", texture.name); diff --git a/src/ui/resources/editors/ResModelEditor.cpp b/src/ui/resources/editors/ResModelEditor.cpp new file mode 100644 index 0000000..d7897b7 --- /dev/null +++ b/src/ui/resources/editors/ResModelEditor.cpp @@ -0,0 +1,168 @@ +#include "ResModelEditor.h" +#include +#include + +using namespace hh::gfx; +using namespace hh::needle; + +ResModelEditor::~ResModelEditor() +{ + auto* renderMgr = reinterpret_cast(hh::gfnd::RenderManagerBase::GetInstance()); + auto* renderEngine = renderMgr->GetNeedleResourceDevice(); + + renderEngine->DestroyRenderTextureHandle(renderTexture); +} + +void ResModelEditor::UpdateViewportData() +{ + renderTexture->SetCameraParameter(viewportData.viewMatrix, viewportData.projMatrix); +} + +void ResModelEditor::SetViewMatrix(const csl::math::Matrix34& mat) +{ + viewportData.viewMatrix = mat; + csl::math::Matrix34 invViewMat = viewportData.viewMatrix.inverse(); + viewportData.inverseViewMatrix.translate(invViewMat.translation()); +} + +void ResModelEditor::UpdateViewMatrix() +{ + auto* camera = renderTexture->camera; + SetCameraPositionAndTarget(camera->position, viewportData.lookAtPos); + UpdateViewportData(); +} + +void ResModelEditor::SetCameraPositionAndTarget(const csl::math::Vector3& position, const csl::math::Vector3& target) +{ + SetViewMatrix(csl::math::Matrix34LookAt(position, csl::math::Vector3::UnitY(), target)); + viewportData.lookAtPos = target; +} + +void ResModelEditor::SetCameraPosition(const csl::math::Vector3& position) +{ + if (!renderTexture) return; + + SetViewMatrix(csl::math::Matrix34LookAt(position, csl::math::Vector3::UnitY(), viewportData.lookAtPos)); +} + +void ResModelEditor::SetCameraTarget(const csl::math::Vector3& target) +{ + if (!renderTexture) return; + + SetViewMatrix(csl::math::Matrix34LookAt(renderTexture->camera->position, csl::math::Vector3::UnitY(), target)); + viewportData.lookAtPos = target; +} + +void ResModelEditor::SetCameraFOV(const float fov) +{ + viewportData.SetPerspectiveProjectionMatrix( + fov, + resolution[0] / resolution[1], + .1f, + 10000 + ); +} + +ResModelEditor::ResModelEditor(csl::fnd::IAllocator* allocator, ResModel* resource) : StandaloneWindow{ allocator }, name{ allocator } +{ + char namebuf[500]; + snprintf(namebuf, sizeof(namebuf), "%s - %s @ 0x%zx (file mapped @ 0x%zx)", resource->GetName(), resource->GetClass().pName, (size_t)&resource, (size_t)resource); + SetTitle(namebuf); + + auto* renderMgr = reinterpret_cast(hh::gfnd::RenderManagerBase::GetInstance()); + auto* renderEngine = renderMgr->GetNeedleResourceDevice(); + auto* supportFx = renderEngine->GetSupportFX(); + + hh::gfx::RenderManager::SModelCreationInfo createInfo{ allocator }; + createInfo.meshResource = resource->GetMeshResource(); + + Model* mdl; + renderMgr->CreateModelFromResource2(&mdl, createInfo); + modelInstance = static_cast(renderMgr->CreateModelInstance(mdl, createInfo)); + + RenderTextureCreateArgs::TextureSettings textureSettings{ + .format = SurfaceFormat::R8G8B8A8, + .mipLevels = 1 + }; + + static const char* nameTemplate = "ModelPreview"; + static const size_t nameTemplateLen = strlen(nameTemplate); + + const char* resName = resource->name.c_str(); + const size_t resNameLen = strlen(resName); + + const size_t nameLen = resNameLen + nameTemplateLen + 1; + char* nameRaw = static_cast(allocator->Alloc(nameLen, 4)); + snprintf(nameRaw, nameLen, "%s%s", resName, nameTemplate); + name.Set(nameRaw); + + RenderTextureCreateArgs rtCreateInfo{ + .width = resolution[0], + .height = resolution[1], + .flags = RenderTextureCreateArgs::UNK2, + .clearedTextureCount = 1, + .textureSettings = &textureSettings, + .allocator = allocator, + .name = name.c_str(), + .sceneName = name.c_str(), + .autoCreatePipeline = true + }; + renderTexture = reinterpret_cast(renderEngine->CreateRenderTextureHandle(rtCreateInfo, allocator)); + + csl::geom::Aabb bbox; + modelInstance->GetModelSpaceAabb(&bbox); + + csl::math::Vector3 bboxCenter = bbox.Center(); + csl::math::Vector3 bboxExtent = bbox.Extent(); + float maxDimension = bboxExtent.norm(); + + float distance = maxDimension * 2.5f; + + csl::math::Vector3 direction = { 1, 1, 1 }; + direction.normalize(); + + csl::math::Vector3 camPos = bboxCenter + direction * distance; + csl::math::Vector3 camTargetPos = bboxCenter; + + viewportData.Reset(); + SetCameraPositionAndTarget(camPos, camTargetPos); + viewportData.SetDimensions({ + .resX = static_cast(resolution[0]), + .resY = static_cast(resolution[1]), + .renderResX = static_cast(resolution[0]), + .renderResY = static_cast(resolution[1]) + }); + SetCameraFOV(1.0476f); + + UpdateViewportData(); + + auto* world = renderTexture->GetWorldByIdx(0); + auto* unk0 = world->UnkFunc1(); + world->AddModelInstance(modelInstance, unk0, true, -1, NEEDLE_RESOURCE_MODEL_INSTANCE); +} + +ResModelEditor* ResModelEditor::Create(csl::fnd::IAllocator* allocator, ResModel* resource) { + return new (allocator) ResModelEditor(allocator, resource); +} + +void ResModelEditor::RenderContents() +{ + if (renderTexture) { + if (Editor("Camera Position", renderTexture->camera->position)) + UpdateViewMatrix(); + + if (Editor("Camera Target", viewportData.lookAtPos)) + UpdateViewMatrix(); + + if (auto* texture = renderTexture->GetTexture(0)) { + ImVec2 pos = ImGui::GetCursorScreenPos(); + ImVec2 size = { static_cast(resolution[0]), static_cast(resolution[1]) }; + ImGui::GetWindowDrawList()->AddRectFilled( + pos, + ImVec2(pos.x + size.x, pos.y + size.y), + IM_COL32(0, 0, 0, 255) + ); + ImGui::Image(GetTextureIDFromMIRAGETexture(texture), size); + } + } +} diff --git a/src/ui/resources/editors/ResModelEditor.h b/src/ui/resources/editors/ResModelEditor.h new file mode 100644 index 0000000..c441f68 --- /dev/null +++ b/src/ui/resources/editors/ResModelEditor.h @@ -0,0 +1,24 @@ +#pragma once +#include + +class ResModelEditor : public StandaloneWindow { + hh::needle::PBRModelInstance* modelInstance; + hh::needle::RenderTextureHandle* renderTexture; + unsigned int resolution[2]{ 1024, 1024 }; + hh::gfnd::ViewportData viewportData; + csl::ut::VariableString name; + + void UpdateViewportData(); + void SetViewMatrix(const csl::math::Matrix34& mat); + void UpdateViewMatrix(); + void SetCameraPositionAndTarget(const csl::math::Vector3& position, const csl::math::Vector3& target); + void SetCameraPosition(const csl::math::Vector3& position); + void SetCameraTarget(const csl::math::Vector3& target); + void SetCameraFOV(const float fov); +public: + virtual ~ResModelEditor(); + + ResModelEditor(csl::fnd::IAllocator* allocator, hh::gfx::ResModel* resource); + virtual void RenderContents(); + static ResModelEditor* Create(csl::fnd::IAllocator* allocator, hh::gfx::ResModel* resource); +}; From e4164439a381921e9b1b0e8fa3e4be7d1002b5eb Mon Sep 17 00:00:00 2001 From: Ashrindy Date: Wed, 27 Aug 2025 17:18:27 +0200 Subject: [PATCH 03/13] Update README.md --- README.md | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 8a65148..2475f81 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# Sonic Frontiers DevTools +# HE2 DevTools -This is an in-engine modding toolkit for the SEGA game Sonic Frontiers. -Releases can be found on [GitHub](https://github.com/angryzor/sonic-frontiers-devtools/releases) +This is an in-engine modding toolkit for the Sonic Team Engine Hedgehog Engine 2. +Releases can be found on [GitHub](https://github.com/HE2-SDK/he2-devtools/releases) or on [the project's GameBanana page](https://gamebanana.com/tools/15218). A HMM update server is also available. @@ -10,34 +10,37 @@ A HMM update server is also available. ## Setting up the development environment ### Using Visual Studio 2022's CMake integration + You will need to have the following prerequisites installed: -* Visual Studio 2022 +- Visual Studio 2022 Check out the project and make sure to also check out its submodules: ```sh -git clone --recurse-submodules https://github.com/angryzor/sonic-frontiers-devtools.git +git clone --recurse-submodules https://github.com/HE2-SDK/he2-devtools.git ``` Simply open the project folder in Visual Studio 2022 (File > Open > CMake...) and it should automatically detect the CMakeLists.txt file. The following presets are available: -* x64 Debug: Debug build. -* x64 Debug ImGui Demo: Debug build with ImGui demo window enabled (for editing themes etc.). -* x64 Release: Release build. -* x64 RelWithDebInfo: Release build with debug information. + +- x64 Debug: Debug build. +- x64 Debug ImGui Demo: Debug build with ImGui demo window enabled (for editing themes etc.). +- x64 Release: Release build. +- x64 RelWithDebInfo: Release build with debug information. ### Using CMake with the Visual Studio 2022 generator + You will need to have the following prerequisites installed: -* Visual Studio 2022 -* CMake 3.28 or higher +- Visual Studio 2022 +- CMake 3.28 or higher Check out the project and make sure to also check out its submodules: ```sh -git clone --recurse-submodules https://github.com/angryzor/sonic-frontiers-devtools.git +git clone --recurse-submodules https://github.com/HE2-SDK/he2-devtools.git ``` Now let CMake do its thing: @@ -46,7 +49,7 @@ Now let CMake do its thing: cmake -B build ``` -If you have Sonic Frontiers installed in a non-standard location, you can specify that location +If you have your target game installed in a non-standard location, you can specify that location with the `DEVTOOLS_GAME_FOLDER` variable: ```sh From ca24d6388b684233d3aac234ffcd74bcc4280d56 Mon Sep 17 00:00:00 2001 From: Ashrindy Date: Sat, 6 Sep 2025 22:03:49 +0200 Subject: [PATCH 04/13] more previewer stuff --- src/CMakeLists.txt | 2 + src/ui/common/previewer/Previewer.cpp | 178 ++++++++++++++++++++ src/ui/common/previewer/Previewer.h | 40 +++++ src/ui/resources/editors/ResModelEditor.cpp | 148 ++-------------- src/ui/resources/editors/ResModelEditor.h | 16 +- 5 files changed, 240 insertions(+), 144 deletions(-) create mode 100644 src/ui/common/previewer/Previewer.cpp create mode 100644 src/ui/common/previewer/Previewer.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 473c561..19f7f34 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -44,6 +44,7 @@ target_sources(${DEVTOOLS_TARGET} ui/common/viewers/RflDiff.cpp ui/common/inputs/Basic.cpp ui/common/overlays/Tag.cpp + ui/common/previewer/Previewer.cpp ui/common/icons.cpp ui/common/StandaloneWindow.cpp ui/common/stb_image.cpp @@ -124,6 +125,7 @@ target_sources(${DEVTOOLS_TARGET} ui/common/inputs/Basic.h ui/common/inputs/Needle.h ui/common/overlays/Tag.h + ui/common/previewer/Previewer.h ui/common/icons.h ui/common/NodeEditor.h ui/common/StandaloneWindow.h diff --git a/src/ui/common/previewer/Previewer.cpp b/src/ui/common/previewer/Previewer.cpp new file mode 100644 index 0000000..65e0b83 --- /dev/null +++ b/src/ui/common/previewer/Previewer.cpp @@ -0,0 +1,178 @@ +#include "Previewer.h" +#include + +using namespace hh::gfx; +using namespace hh::needle; + +Previewer::~Previewer() +{ + auto* renderMgr = reinterpret_cast(hh::gfnd::RenderManagerBase::GetInstance()); + auto* renderEngine = renderMgr->GetNeedleResourceDevice(); + + renderEngine->DestroyRenderTextureHandle(renderTexture); +} + +Previewer::Previewer(csl::fnd::IAllocator* allocator) : CompatibleObject{ allocator }, models { allocator }, name{ allocator } +{ +} + +void Previewer::Setup(const Description& desc) +{ + auto* renderMgr = reinterpret_cast(hh::gfnd::RenderManagerBase::GetInstance()); + auto* renderEngine = renderMgr->GetNeedleResourceDevice(); + auto* supportFx = renderEngine->GetSupportFX(); + + RenderTextureCreateArgs::TextureSettings textureSettings{ + .format = SurfaceFormat::R8G8B8A8, + .mipLevels = 1 + }; + + name.Set(desc.name); + + RenderTextureCreateArgs rtCreateInfo{ + .width = desc.resolution[0], + .height = desc.resolution[1], + .flags = RenderTextureCreateArgs::UNK2, + .clearedTextureCount = 1, + .textureSettings = &textureSettings, + .allocator = pAllocator, + .name = name.c_str(), + .sceneName = name.c_str(), + .autoCreatePipeline = true + }; + renderTexture = reinterpret_cast(renderEngine->CreateRenderTextureHandle(rtCreateInfo, pAllocator)); + + viewportData.Reset(); + SetCameraPositionAndTarget({}, {}); + + float resF[2] = {desc.resolution[0], desc.resolution[1]}; + viewportData.SetDimensions({ + .resX = resF[0], + .resY = resF[1], + .renderResX = resF[0], + .renderResY = resF[1] + }); + SetCameraFOV(desc.fov); + + UpdateViewportData(); + + if (desc.modelInstance) + AddModel(desc.modelInstance, desc.setToAabb); +} + +void Previewer::UpdateViewportData() +{ + renderTexture->SetCameraParameter(viewportData.viewMatrix, viewportData.projMatrix); +} + +void Previewer::SetViewMatrix(const csl::math::Matrix34& mat) +{ + viewportData.viewMatrix = mat; + csl::math::Matrix34 invViewMat = viewportData.viewMatrix.inverse(); + viewportData.inverseViewMatrix.translate(invViewMat.translation()); +} + +void Previewer::UpdateViewMatrix() +{ + auto mat = viewportData.viewMatrix.matrix(); + csl::math::Vector3 camPos = { mat(0, 3), mat(1, 3), mat(2, 3) }; + SetCameraPositionAndTarget(camPos, viewportData.lookAtPos); + UpdateViewportData(); +} + +void Previewer::SetCameraToAABB(const csl::geom::Aabb& aabb) +{ + csl::math::Vector3 bboxCenter = aabb.Center(); + csl::math::Vector3 bboxExtent = aabb.Extent(); + float maxDimension = bboxExtent.norm(); + + float distance = maxDimension * 2.5f; + + csl::math::Vector3 direction = { 1, 1, 1 }; + direction.normalize(); + + csl::math::Vector3 camPos = bboxCenter + direction * distance; + csl::math::Vector3 camTargetPos = bboxCenter; + + SetCameraPositionAndTarget(camPos, camTargetPos); + UpdateViewportData(); +} + +void Previewer::SetCameraToAABB(hh::needle::PBRModelInstance* modelAabb) +{ + csl::geom::Aabb bbox; + modelAabb->GetModelSpaceAabb(&bbox); + SetCameraToAABB(bbox); +} + +void Previewer::SetCameraPositionAndTarget(const csl::math::Vector3& position, const csl::math::Vector3& target) +{ + SetViewMatrix(csl::math::Matrix34LookAt(position, csl::math::Vector3::UnitY(), target)); + viewportData.lookAtPos = target; +} + +void Previewer::SetCameraPosition(const csl::math::Vector3& position) +{ + SetViewMatrix(csl::math::Matrix34LookAt(position, csl::math::Vector3::UnitY(), viewportData.lookAtPos)); +} + +void Previewer::SetCameraTarget(const csl::math::Vector3& target) +{ + auto mat = viewportData.viewMatrix.matrix(); + csl::math::Vector3 camPos = { mat(0, 3), mat(1, 3), mat(2, 3) }; + SetViewMatrix(csl::math::Matrix34LookAt(camPos, csl::math::Vector3::UnitY(), target)); + viewportData.lookAtPos = target; +} + +void Previewer::SetCameraFOV(const float fov) +{ + auto& dimensions = viewportData.viewportDimensions; + + float nearZ{ .1f }; + float farZ{ 10000 }; + viewportData.GetClipPlanes(&nearZ, &farZ); + + viewportData.SetPerspectiveProjectionMatrix( + fov, + dimensions.resX / dimensions.resY, + nearZ, + farZ + ); +} + +hh::needle::Texture* Previewer::GetTexture() const +{ + if (!renderTexture) return nullptr; + + return renderTexture->GetTexture(0); +} + +ImTextureID Previewer::GetTextureID() const +{ + auto* texture = GetTexture(); + return texture == nullptr ? nullptr : GetTextureIDFromMIRAGETexture(texture); +} + +void Previewer::AddModel(hh::needle::PBRModelInstance* modelInstance, bool setToAabb) +{ + models.push_back(modelInstance); + auto* world = renderTexture->GetWorldByIdx(0); + auto* unk0 = world->UnkFunc1(); + world->AddModelInstance(modelInstance, unk0, true, -1, NEEDLE_RESOURCE_MODEL_INSTANCE); + + if (setToAabb) + SetCameraToAABB(modelInstance); +} + +void Previewer::AddModel(hh::gfx::ResModel* resModel, bool setToAabb) +{ + auto* renderMgr = reinterpret_cast(hh::gfnd::RenderManagerBase::GetInstance()); + hh::gfx::RenderManager::SModelCreationInfo createInfo{ pAllocator }; + createInfo.meshResource = resModel->GetMeshResource(); + + Model* mdl; + renderMgr->CreateModelFromResource2(&mdl, createInfo); + auto* modelInstance = static_cast(renderMgr->CreateModelInstance(mdl, createInfo)); + + AddModel(modelInstance, setToAabb); +} diff --git a/src/ui/common/previewer/Previewer.h b/src/ui/common/previewer/Previewer.h new file mode 100644 index 0000000..f01f0a6 --- /dev/null +++ b/src/ui/common/previewer/Previewer.h @@ -0,0 +1,40 @@ +#pragma once +#include + +class Previewer : public CompatibleObject { +public: + struct Description { + unsigned int resolution[2]{ 1024, 1024 }; + hh::needle::PBRModelInstance* modelInstance; + const char* name = "Previewer"; + float fov{ 1.0476f }; + bool setToAabb{ false }; + }; + + csl::ut::MoveArray models; + hh::needle::RenderTextureHandle* renderTexture; + hh::gfnd::ViewportData viewportData; + csl::ut::VariableString name; + + virtual ~Previewer(); + Previewer(csl::fnd::IAllocator* allocator); + + void Setup(const Description& desc); + + void UpdateViewportData(); + void SetViewMatrix(const csl::math::Matrix34& mat); + void UpdateViewMatrix(); + + void SetCameraToAABB(const csl::geom::Aabb& aabb); + void SetCameraToAABB(hh::needle::PBRModelInstance* modelAabb); + void SetCameraPositionAndTarget(const csl::math::Vector3& position, const csl::math::Vector3& target); + void SetCameraPosition(const csl::math::Vector3& position); + void SetCameraTarget(const csl::math::Vector3& target); + void SetCameraFOV(const float fov); + + hh::needle::Texture* GetTexture() const; + ImTextureID GetTextureID() const; + + void AddModel(hh::needle::PBRModelInstance* modelInstance, bool setToAabb = false); + void AddModel(hh::gfx::ResModel* resModel, bool setToAabb = false); +}; diff --git a/src/ui/resources/editors/ResModelEditor.cpp b/src/ui/resources/editors/ResModelEditor.cpp index d7897b7..4177d96 100644 --- a/src/ui/resources/editors/ResModelEditor.cpp +++ b/src/ui/resources/editors/ResModelEditor.cpp @@ -7,84 +7,15 @@ using namespace hh::needle; ResModelEditor::~ResModelEditor() { - auto* renderMgr = reinterpret_cast(hh::gfnd::RenderManagerBase::GetInstance()); - auto* renderEngine = renderMgr->GetNeedleResourceDevice(); - - renderEngine->DestroyRenderTextureHandle(renderTexture); -} - -void ResModelEditor::UpdateViewportData() -{ - renderTexture->SetCameraParameter(viewportData.viewMatrix, viewportData.projMatrix); -} - -void ResModelEditor::SetViewMatrix(const csl::math::Matrix34& mat) -{ - viewportData.viewMatrix = mat; - csl::math::Matrix34 invViewMat = viewportData.viewMatrix.inverse(); - viewportData.inverseViewMatrix.translate(invViewMat.translation()); -} - -void ResModelEditor::UpdateViewMatrix() -{ - auto* camera = renderTexture->camera; - SetCameraPositionAndTarget(camera->position, viewportData.lookAtPos); - UpdateViewportData(); -} - -void ResModelEditor::SetCameraPositionAndTarget(const csl::math::Vector3& position, const csl::math::Vector3& target) -{ - SetViewMatrix(csl::math::Matrix34LookAt(position, csl::math::Vector3::UnitY(), target)); - viewportData.lookAtPos = target; -} - -void ResModelEditor::SetCameraPosition(const csl::math::Vector3& position) -{ - if (!renderTexture) return; - - SetViewMatrix(csl::math::Matrix34LookAt(position, csl::math::Vector3::UnitY(), viewportData.lookAtPos)); -} - -void ResModelEditor::SetCameraTarget(const csl::math::Vector3& target) -{ - if (!renderTexture) return; - - SetViewMatrix(csl::math::Matrix34LookAt(renderTexture->camera->position, csl::math::Vector3::UnitY(), target)); - viewportData.lookAtPos = target; + delete previewer; } -void ResModelEditor::SetCameraFOV(const float fov) -{ - viewportData.SetPerspectiveProjectionMatrix( - fov, - resolution[0] / resolution[1], - .1f, - 10000 - ); -} - -ResModelEditor::ResModelEditor(csl::fnd::IAllocator* allocator, ResModel* resource) : StandaloneWindow{ allocator }, name{ allocator } +ResModelEditor::ResModelEditor(csl::fnd::IAllocator* allocator, ResModel* resource) : StandaloneWindow{ allocator } { char namebuf[500]; snprintf(namebuf, sizeof(namebuf), "%s - %s @ 0x%zx (file mapped @ 0x%zx)", resource->GetName(), resource->GetClass().pName, (size_t)&resource, (size_t)resource); SetTitle(namebuf); - auto* renderMgr = reinterpret_cast(hh::gfnd::RenderManagerBase::GetInstance()); - auto* renderEngine = renderMgr->GetNeedleResourceDevice(); - auto* supportFx = renderEngine->GetSupportFX(); - - hh::gfx::RenderManager::SModelCreationInfo createInfo{ allocator }; - createInfo.meshResource = resource->GetMeshResource(); - - Model* mdl; - renderMgr->CreateModelFromResource2(&mdl, createInfo); - modelInstance = static_cast(renderMgr->CreateModelInstance(mdl, createInfo)); - - RenderTextureCreateArgs::TextureSettings textureSettings{ - .format = SurfaceFormat::R8G8B8A8, - .mipLevels = 1 - }; - static const char* nameTemplate = "ModelPreview"; static const size_t nameTemplateLen = strlen(nameTemplate); @@ -92,53 +23,12 @@ ResModelEditor::ResModelEditor(csl::fnd::IAllocator* allocator, ResModel* resour const size_t resNameLen = strlen(resName); const size_t nameLen = resNameLen + nameTemplateLen + 1; - char* nameRaw = static_cast(allocator->Alloc(nameLen, 4)); + char* nameRaw = static_cast(pAllocator->Alloc(nameLen, 4)); snprintf(nameRaw, nameLen, "%s%s", resName, nameTemplate); - name.Set(nameRaw); - - RenderTextureCreateArgs rtCreateInfo{ - .width = resolution[0], - .height = resolution[1], - .flags = RenderTextureCreateArgs::UNK2, - .clearedTextureCount = 1, - .textureSettings = &textureSettings, - .allocator = allocator, - .name = name.c_str(), - .sceneName = name.c_str(), - .autoCreatePipeline = true - }; - renderTexture = reinterpret_cast(renderEngine->CreateRenderTextureHandle(rtCreateInfo, allocator)); - - csl::geom::Aabb bbox; - modelInstance->GetModelSpaceAabb(&bbox); - - csl::math::Vector3 bboxCenter = bbox.Center(); - csl::math::Vector3 bboxExtent = bbox.Extent(); - float maxDimension = bboxExtent.norm(); - - float distance = maxDimension * 2.5f; - - csl::math::Vector3 direction = { 1, 1, 1 }; - direction.normalize(); - csl::math::Vector3 camPos = bboxCenter + direction * distance; - csl::math::Vector3 camTargetPos = bboxCenter; - - viewportData.Reset(); - SetCameraPositionAndTarget(camPos, camTargetPos); - viewportData.SetDimensions({ - .resX = static_cast(resolution[0]), - .resY = static_cast(resolution[1]), - .renderResX = static_cast(resolution[0]), - .renderResY = static_cast(resolution[1]) - }); - SetCameraFOV(1.0476f); - - UpdateViewportData(); - - auto* world = renderTexture->GetWorldByIdx(0); - auto* unk0 = world->UnkFunc1(); - world->AddModelInstance(modelInstance, unk0, true, -1, NEEDLE_RESOURCE_MODEL_INSTANCE); + previewer = new (allocator) Previewer{ allocator }; + previewer->Setup({.name = nameRaw}); + previewer->AddModel(resource, true); } ResModelEditor* ResModelEditor::Create(csl::fnd::IAllocator* allocator, ResModel* resource) { @@ -147,22 +37,18 @@ ResModelEditor* ResModelEditor::Create(csl::fnd::IAllocator* allocator, ResModel void ResModelEditor::RenderContents() { - if (renderTexture) { - if (Editor("Camera Position", renderTexture->camera->position)) - UpdateViewMatrix(); + if (auto* texture = previewer->GetTextureID()) { + ImVec2 pos = ImGui::GetCursorScreenPos(); + + auto& dimensions = previewer->viewportData.viewportDimensions; + ImVec2 size = { static_cast(dimensions.resX), static_cast(dimensions.resY) }; - if (Editor("Camera Target", viewportData.lookAtPos)) - UpdateViewMatrix(); + ImGui::GetWindowDrawList()->AddRectFilled( + pos, + ImVec2(pos.x + size.x, pos.y + size.y), + IM_COL32(0, 0, 0, 255) + ); - if (auto* texture = renderTexture->GetTexture(0)) { - ImVec2 pos = ImGui::GetCursorScreenPos(); - ImVec2 size = { static_cast(resolution[0]), static_cast(resolution[1]) }; - ImGui::GetWindowDrawList()->AddRectFilled( - pos, - ImVec2(pos.x + size.x, pos.y + size.y), - IM_COL32(0, 0, 0, 255) - ); - ImGui::Image(GetTextureIDFromMIRAGETexture(texture), size); - } + ImGui::Image(texture, size); } } diff --git a/src/ui/resources/editors/ResModelEditor.h b/src/ui/resources/editors/ResModelEditor.h index c441f68..7332f0e 100644 --- a/src/ui/resources/editors/ResModelEditor.h +++ b/src/ui/resources/editors/ResModelEditor.h @@ -1,21 +1,11 @@ #pragma once #include +#include class ResModelEditor : public StandaloneWindow { - hh::needle::PBRModelInstance* modelInstance; - hh::needle::RenderTextureHandle* renderTexture; - unsigned int resolution[2]{ 1024, 1024 }; - hh::gfnd::ViewportData viewportData; - csl::ut::VariableString name; - - void UpdateViewportData(); - void SetViewMatrix(const csl::math::Matrix34& mat); - void UpdateViewMatrix(); - void SetCameraPositionAndTarget(const csl::math::Vector3& position, const csl::math::Vector3& target); - void SetCameraPosition(const csl::math::Vector3& position); - void SetCameraTarget(const csl::math::Vector3& target); - void SetCameraFOV(const float fov); public: + hh::fnd::Reference previewer; + virtual ~ResModelEditor(); ResModelEditor(csl::fnd::IAllocator* allocator, hh::gfx::ResModel* resource); From 88fa11797f27716964bbd03f8dd10d65f5f17837 Mon Sep 17 00:00:00 2001 From: Ashrindy Date: Mon, 15 Sep 2025 17:11:24 +0200 Subject: [PATCH 05/13] Update ResEffectEditor.cpp --- src/ui/resources/editors/ResEffectEditor.cpp | 30 +++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/ui/resources/editors/ResEffectEditor.cpp b/src/ui/resources/editors/ResEffectEditor.cpp index 267ed7c..4cea5d1 100644 --- a/src/ui/resources/editors/ResEffectEditor.cpp +++ b/src/ui/resources/editors/ResEffectEditor.cpp @@ -31,6 +31,18 @@ const char* modifierNames[] = { "FLUCTUATION", }; +const char* shapeNames[] = { + "POINT", + "SPHERE", + "DISC", + "CYLINDER", + "LINE", + "TORUS", + "CUBE", + "null", + "FIXED" +}; + bool Editor(const char* label, TextureParam& texture) { bool edited{}; ImGui::PushID(label); @@ -202,9 +214,25 @@ bool Editor(const char* label, ElementParam& element) { bool Editor(const char* label, EmitterParam& emitter) { bool edited{}; ImGui::PushID(label); + edited |= Editor("position", emitter.position); + edited |= Editor("rotation", emitter.rotation); + edited |= Editor("scale", emitter.scale); + edited |= ComboEnum("shape", emitter.shape, shapeNames); + edited |= Editor("useRadialDistribution", emitter.useRadialDistribution); + edited |= Editor("consistentSpreadAngle", emitter.consistentSpreadAngle); + edited |= Editor("useAngularSubdivisions", emitter.useAngularSubdivisions); + edited |= Editor("numSubDivisions", emitter.numSubDivisions); + edited |= Editor("disabled", emitter.disabled); + edited |= Editor("frequency", emitter.frequency); + edited |= Editor("frequencyRandomness", emitter.frequencyRandomness); + edited |= Editor("emitterCount", emitter.emitterCount); + edited |= Editor("emitterCountRandomness", emitter.emitterCountRandomness); edited |= Editor("emitspeed", emitter.emitSpeed); + edited |= Editor("unkShapeRelated0", emitter.unkShapeRelated0); + edited |= Editor("shapeRadius", emitter.shapeRadius); + edited |= Editor("unkShapeRelated1", emitter.unkShapeRelated1); + edited |= Editor("emitSize", emitter.emitSize); edited |= Editor("emitVector", emitter.emitVector); - edited |= Editor("emitVectorUnk", emitter.emitVectorUnk); edited |= Editor("randomSeed", emitter.randomSeed); edited |= Editor("element", emitter.elementParam); ImGui::PopID(); From 1699ff98c39f786eab3f2a4ac8057b22c4a3baa5 Mon Sep 17 00:00:00 2001 From: Ashrindy Date: Wed, 17 Sep 2025 22:58:13 +0200 Subject: [PATCH 06/13] cemt editor updates, previewer widgets --- .gitmodules | 3 + CMakeLists.txt | 5 +- src/CMakeLists.txt | 2 + src/ui/common/Theme.cpp | 15 ++ src/ui/common/editors/Needle.cpp | 10 - src/ui/common/previewer/Previewer.cpp | 44 +++- src/ui/common/previewer/Previewer.h | 4 + src/ui/common/previewer/PreviewerCamera.cpp | 69 +++++++ src/ui/common/previewer/PreviewerCamera.h | 19 ++ src/ui/resources/editors/ResEffectEditor.cpp | 203 +++++++++++++++---- src/ui/resources/editors/ResEffectEditor.h | 4 - src/ui/resources/editors/ResModelEditor.cpp | 5 + src/ui/resources/editors/ResModelEditor.h | 2 + src/utilities/math/MathUtils.cpp | 20 ++ src/utilities/math/MathUtils.h | 7 + vendor/CMakeLists.txt | 1 + vendor/imviewguizmo/CMakeLists.txt | 9 + vendor/imviewguizmo/ImViewGuizmo | 1 + 18 files changed, 359 insertions(+), 64 deletions(-) create mode 100644 src/ui/common/previewer/PreviewerCamera.cpp create mode 100644 src/ui/common/previewer/PreviewerCamera.h create mode 100644 vendor/imviewguizmo/CMakeLists.txt create mode 160000 vendor/imviewguizmo/ImViewGuizmo diff --git a/.gitmodules b/.gitmodules index e548d03..876dfec 100644 --- a/.gitmodules +++ b/.gitmodules @@ -34,3 +34,6 @@ [submodule "vendor/uwebsockets/uWebSockets"] path = vendor/uwebsockets/uWebSockets url = https://github.com/uNetworking/uWebSockets.git +[submodule "vendor/imviewguizmo/ImViewGuizmo"] + path = vendor/imviewguizmo/ImViewGuizmo + url = https://github.com/Ka1serM/ImViewGuizmo.git diff --git a/CMakeLists.txt b/CMakeLists.txt index b9e54f3..d234555 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,8 @@ include(FetchContent) FetchContent_Declare(OGDF GIT_REPOSITORY https://github.com/ogdf/ogdf.git GIT_TAG 8a7b22712929f1cd48c4ed701c52b0c0a69c01c8 EXCLUDE_FROM_ALL FIND_PACKAGE_ARGS) FetchContent_Declare(rip GIT_REPOSITORY https://github.com/angryzor/rip.git GIT_TAG v1.0.34 EXCLUDE_FROM_ALL FIND_PACKAGE_ARGS 1.0.34) FetchContent_Declare(dieventlib GIT_REPOSITORY https://github.com/Ashrindy/DiEventLibCPP.git) -FetchContent_MakeAvailable(ogdf rip dieventlib) +FetchContent_Declare(glm GIT_REPOSITORY https://github.com/g-truc/glm.git) +FetchContent_MakeAvailable(ogdf rip dieventlib glm) add_subdirectory(vendor EXCLUDE_FROM_ALL) # Settings for target sdks @@ -84,7 +85,7 @@ foreach(DEVTOOLS_TARGET_SDK miller rangers wars) add_subdirectory(${SDK_PATH} ${DEVTOOLS_TARGET_SDK}-sdk EXCLUDE_FROM_ALL) add_library(${DEVTOOLS_TARGET} SHARED) - target_link_libraries(${DEVTOOLS_TARGET} PRIVATE ${DEVTOOLS_TARGET_SDK}-sdk filewatch detours imgui imgui-backend-win32 imgui-backend-dx11 imgui-node-editor imgui-memory-editor imguizmo implot imtimeline imbrowser yyjson reflectcpp OGDF rip-hl uwebsockets DiEventLib) + target_link_libraries(${DEVTOOLS_TARGET} PRIVATE ${DEVTOOLS_TARGET_SDK}-sdk filewatch detours imgui imgui-backend-win32 imgui-backend-dx11 imgui-node-editor imgui-memory-editor imguizmo imviewguizmo implot imtimeline imbrowser yyjson reflectcpp OGDF rip-hl uwebsockets DiEventLib) target_compile_features(${DEVTOOLS_TARGET} PRIVATE cxx_std_20) target_compile_options(${DEVTOOLS_TARGET} PRIVATE /permissive- /W4 /wd4100 /wd4458 /wd4324) target_compile_definitions(${DEVTOOLS_TARGET} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5d649ab..8a37093 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -45,6 +45,7 @@ target_sources(${DEVTOOLS_TARGET} ui/common/inputs/Basic.cpp ui/common/overlays/Tag.cpp ui/common/previewer/Previewer.cpp + ui/common/previewer/PreviewerCamera.cpp ui/common/icons.cpp ui/common/StandaloneWindow.cpp ui/common/stb_image.cpp @@ -126,6 +127,7 @@ target_sources(${DEVTOOLS_TARGET} ui/common/inputs/Needle.h ui/common/overlays/Tag.h ui/common/previewer/Previewer.h + ui/common/previewer/PreviewerCamera.h ui/common/icons.h ui/common/NodeEditor.h ui/common/StandaloneWindow.h diff --git a/src/ui/common/Theme.cpp b/src/ui/common/Theme.cpp index 952488f..27e740c 100644 --- a/src/ui/common/Theme.cpp +++ b/src/ui/common/Theme.cpp @@ -1,4 +1,5 @@ #include "Theme.h" +#include void Theme_SonicFrontiers() { ImGuiStyle& style = ImGui::GetStyle(); @@ -105,6 +106,8 @@ void Theme_SonicFrontiers() { style.Colors[ImGuiCol_NavWindowingHighlight] = ImVec4(0.70f, 0.70f, 0.70f, 0.70f); style.Colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.20f); style.Colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f); + + ImViewGuizmo::GetStyle().scale = 0.65f; } void Theme_SonicForces() { @@ -213,6 +216,8 @@ void Theme_SonicForces() { colors[ImGuiCol_NavWindowingHighlight] = ImVec4(0.70f, 0.70f, 0.70f, 0.70f); colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.09f, 0.09f, 0.09f, 0.20f); colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.09f, 0.09f, 0.09f, 0.35f); + + ImViewGuizmo::GetStyle().scale = 0.65f; } void Theme_Gindows() { @@ -319,6 +324,8 @@ void Theme_Gindows() { style.Colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); style.Colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); style.Colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); + + ImViewGuizmo::GetStyle().scale = 0.65f; } void Theme_Sonadow_Generations() { @@ -427,6 +434,8 @@ void Theme_Sonadow_Generations() { colors[ImGuiCol_NavWindowingHighlight] = ImVec4(0.70f, 0.70f, 0.70f, 0.70f); colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.20f); colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f); + + ImViewGuizmo::GetStyle().scale = 0.65f; } void Theme_ImGui() { @@ -480,6 +489,8 @@ void Theme_ImGui() { style.CircleTessellationMaxError = 0.30f; ImGui::StyleColorsDark(&style); + + ImViewGuizmo::GetStyle().scale = 0.65f; } void Theme_ContrastImGui() { @@ -588,6 +599,8 @@ void Theme_ContrastImGui() { colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); + + ImViewGuizmo::GetStyle().scale = 0.65f; } void Theme_ModernContrastImGui() { @@ -668,6 +681,8 @@ void Theme_ModernContrastImGui() { colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); + + ImViewGuizmo::GetStyle().scale = 0.65f; } Theme Theme::themes[themeCount] = { diff --git a/src/ui/common/editors/Needle.cpp b/src/ui/common/editors/Needle.cpp index 496b8d5..1877bfd 100644 --- a/src/ui/common/editors/Needle.cpp +++ b/src/ui/common/editors/Needle.cpp @@ -393,18 +393,8 @@ bool Editor(const char* label, hh::needle::RenderingPipelineRangers& pipeline) if (ImGui::TreeNode(label)) { edited |= Editor("WorldRenderingPipeline", static_cast(pipeline)); Viewer("name", pipeline.name); - edited |= Editor("qword118", pipeline.qword118); - edited |= Editor("qword120", pipeline.qword120); - edited |= Editor("qword128", pipeline.qword128); - edited |= Editor("qword130", pipeline.qword130); edited |= Editor("qword138", pipeline.qword138); - edited |= Editor("qword140", pipeline.qword140); - edited |= Editor("qword148", pipeline.qword148); edited |= Editor("qword150", pipeline.qword150); - edited |= Editor("qword198", pipeline.qword198); - edited |= Editor("qword1A0", pipeline.qword1A0); - edited |= Editor("qword1A8", pipeline.qword1A8); - edited |= Editor("qword1B0", pipeline.qword1B0); ImGui::TreePop(); } return edited; diff --git a/src/ui/common/previewer/Previewer.cpp b/src/ui/common/previewer/Previewer.cpp index 65e0b83..93823c0 100644 --- a/src/ui/common/previewer/Previewer.cpp +++ b/src/ui/common/previewer/Previewer.cpp @@ -6,10 +6,12 @@ using namespace hh::needle; Previewer::~Previewer() { - auto* renderMgr = reinterpret_cast(hh::gfnd::RenderManagerBase::GetInstance()); - auto* renderEngine = renderMgr->GetNeedleResourceDevice(); + if (renderTexture) { + auto* renderMgr = reinterpret_cast(hh::gfnd::RenderManagerBase::GetInstance()); + auto* renderEngine = renderMgr->GetNeedleResourceDevice(); - renderEngine->DestroyRenderTextureHandle(renderTexture); + renderEngine->DestroyRenderTextureHandle(renderTexture); + } } Previewer::Previewer(csl::fnd::IAllocator* allocator) : CompatibleObject{ allocator }, models { allocator }, name{ allocator } @@ -80,17 +82,49 @@ void Previewer::UpdateViewMatrix() UpdateViewportData(); } -void Previewer::SetCameraToAABB(const csl::geom::Aabb& aabb) +float Previewer::GetZoomToAABB(const csl::geom::Aabb& aabb) const { csl::math::Vector3 bboxCenter = aabb.Center(); csl::math::Vector3 bboxExtent = aabb.Extent(); float maxDimension = bboxExtent.norm(); - float distance = maxDimension * 2.5f; + return maxDimension * 2.5f; +} + +float Previewer::GetZoomToAABB(hh::needle::PBRModelInstance* modelAabb) const +{ + csl::geom::Aabb bbox; + modelAabb->GetModelSpaceAabb(&bbox); + return GetZoomToAABB(bbox); +} + +float Previewer::GetZoomToAABB() const +{ + if (models.empty()) return 2.5f; + + float lastDistance = GetZoomToAABB(models[0]); + + if (models.size()) return lastDistance; + + for (auto* model : models) { + if (model == models[0]) continue; + + float distance = GetZoomToAABB(model); + if (distance > lastDistance) + lastDistance = distance; + } + + return lastDistance; +} + +void Previewer::SetCameraToAABB(const csl::geom::Aabb& aabb) +{ + float distance = GetZoomToAABB(aabb); csl::math::Vector3 direction = { 1, 1, 1 }; direction.normalize(); + csl::math::Vector3 bboxCenter = aabb.Center(); csl::math::Vector3 camPos = bboxCenter + direction * distance; csl::math::Vector3 camTargetPos = bboxCenter; diff --git a/src/ui/common/previewer/Previewer.h b/src/ui/common/previewer/Previewer.h index f01f0a6..7263a67 100644 --- a/src/ui/common/previewer/Previewer.h +++ b/src/ui/common/previewer/Previewer.h @@ -25,6 +25,10 @@ class Previewer : public CompatibleObject { void SetViewMatrix(const csl::math::Matrix34& mat); void UpdateViewMatrix(); + float GetZoomToAABB(const csl::geom::Aabb& aabb) const; + float GetZoomToAABB(hh::needle::PBRModelInstance* modelAabb) const; + float GetZoomToAABB() const; + void SetCameraToAABB(const csl::geom::Aabb& aabb); void SetCameraToAABB(hh::needle::PBRModelInstance* modelAabb); void SetCameraPositionAndTarget(const csl::math::Vector3& position, const csl::math::Vector3& target); diff --git a/src/ui/common/previewer/PreviewerCamera.cpp b/src/ui/common/previewer/PreviewerCamera.cpp new file mode 100644 index 0000000..32b9d5e --- /dev/null +++ b/src/ui/common/previewer/PreviewerCamera.cpp @@ -0,0 +1,69 @@ +#include "PreviewerCamera.h" +#include +#define IMVIEWGUIZMO_IMPLEMENTATION +#include + +PreviewerCamera::~PreviewerCamera() +{ +} + +PreviewerCamera::PreviewerCamera(csl::fnd::IAllocator* allocator) : CompatibleObject{ allocator } +{ +} + +void PreviewerCamera::Setup(Previewer* previewer) +{ + this->previewer = previewer; + viewportData = previewer->viewportData; +} + +bool PreviewerCamera::RotateControl(csl::math::Vector3& position, csl::math::Quaternion& rotation) const +{ + glm::vec3 camPos = EigenToGLM(position); + glm::quat camRot = EigenToGLM(rotation); + + const ImVec2 guizmoHRes = ImVec2{ 80, 80 } * ImViewGuizmo::GetStyle().scale; + + ImVec2 guizmoPos = + ImGui::GetWindowContentRegionMin() + ImGui::GetWindowPos() + // base position + ImVec2{ viewportData.viewportDimensions.resX - guizmoHRes.x, guizmoHRes.y }; // offset position + + // dirty hack to stop the window from moving + ImVec2 invisPos = guizmoPos - guizmoHRes; + ImVec2 invisSize = guizmoHRes * 2; + ImGui::SetCursorScreenPos(invisPos); + ImGui::InvisibleButton("unmovable", invisSize); + + bool changed = false; + + if (changed |= ImViewGuizmo::Rotate(camPos, camRot, guizmoPos, previewer->GetZoomToAABB(), controlSpeed)) { + position = GLMToEigen(camPos); + rotation = GLMToEigen(camRot); + } + + return changed; +} + +void PreviewerCamera::Render() +{ + auto& viewMatrix = viewportData.viewMatrix; + + csl::math::Vector3 camPos = viewMatrix.translation(); + csl::math::Quaternion camRot{ viewMatrix.rotation() }; + + if (RotateControl(camPos, camRot)) + UpdateViewMatrix(camPos, camRot); +} + +void PreviewerCamera::UpdateViewMatrix(const csl::math::Vector3& position, const csl::math::Quaternion& rotation) +{ + auto& viewMatrix = viewportData.viewMatrix; + viewMatrix.linear() = rotation.toRotationMatrix(); + viewMatrix.translation() = position; + viewportData.viewMatrix = viewMatrix; + + if (previewer) { + previewer->SetViewMatrix(viewMatrix); + previewer->UpdateViewMatrix(); + } +} diff --git a/src/ui/common/previewer/PreviewerCamera.h b/src/ui/common/previewer/PreviewerCamera.h new file mode 100644 index 0000000..7288c5f --- /dev/null +++ b/src/ui/common/previewer/PreviewerCamera.h @@ -0,0 +1,19 @@ +#pragma once +#include +#include + +class PreviewerCamera : public CompatibleObject { +public: + hh::fnd::Reference previewer{}; + hh::gfnd::ViewportData viewportData; + float controlSpeed = 0.015f; + + virtual ~PreviewerCamera(); + PreviewerCamera(csl::fnd::IAllocator* allocator); + + void Setup(Previewer* previewer); + + bool RotateControl(csl::math::Vector3& position, csl::math::Quaternion& rotation) const; + void Render(); + void UpdateViewMatrix(const csl::math::Vector3& position, const csl::math::Quaternion& rotation); +}; diff --git a/src/ui/resources/editors/ResEffectEditor.cpp b/src/ui/resources/editors/ResEffectEditor.cpp index 4cea5d1..47db8b9 100644 --- a/src/ui/resources/editors/ResEffectEditor.cpp +++ b/src/ui/resources/editors/ResEffectEditor.cpp @@ -2,9 +2,15 @@ bool Editor(const char* label, ucsl::resources::cemt::v100000::TextureParam& texture); bool Editor(const char* label, ucsl::resources::cemt::v100000::ChildEffect& effect); -bool Editor(const char* label, ucsl::resources::cemt::v100000::ModifierParam::GravityVectorSettings& settings); -bool Editor(const char* label, ucsl::resources::cemt::v100000::ModifierParam::GravityOtherSettings& settings); +bool Editor(const char* label, ucsl::resources::cemt::v100000::ModifierParam::GravitySettings& settings); +bool Editor(const char* label, ucsl::resources::cemt::v100000::ModifierParam::SpeedSettings& settings); +bool Editor(const char* label, ucsl::resources::cemt::v100000::ModifierParam::MagnetSettings& settings); +bool Editor(const char* label, ucsl::resources::cemt::v100000::ModifierParam::NewtonSettings& settings); bool Editor(const char* label, ucsl::resources::cemt::v100000::ModifierParam::VortexSettings& settings); +bool Editor(const char* label, ucsl::resources::cemt::v100000::ModifierParam::SpinSettings& settings); +bool Editor(const char* label, ucsl::resources::cemt::v100000::ModifierParam::Spin2Settings& settings); +bool Editor(const char* label, ucsl::resources::cemt::v100000::ModifierParam::RandomSettings& settings); +bool Editor(const char* label, ucsl::resources::cemt::v100000::ModifierParam::TailSettings& settings); bool Editor(const char* label, ucsl::resources::cemt::v100000::ModifierParam::FluctuationSettings& settings); bool Editor(const char* label, ucsl::resources::cemt::v100000::ModifierParam& modifier); bool Editor(const char* label, ucsl::resources::cemt::v100000::Table::Unk1& v); @@ -19,16 +25,17 @@ bool Editor(const char* label, ucsl::resources::cemt::v100000::EmitterParam& emi using namespace ucsl::resources::cemt::v100000; const char* modifierNames[] = { - "GRAVITY_VECTOR", - "GRAVITY_OTHER", - "UNK0", - "UNK1", + "GRAVITY", + "SPEED", + "MAGNET", + "NEWTON", "VORTEX", - "UNK2", - "UNK3", - "UNK4", - "UNK5", + "SPIN", + "SPIN2", + "RANDOM", + "TAIL", "FLUCTUATION", + "UNK0" }; const char* shapeNames[] = { @@ -43,6 +50,21 @@ const char* shapeNames[] = { "FIXED" }; +const char* originNames[] = { + "WORLD", + "EMISSION", + "INHERIT", + "UNK0" +}; + +const char* waveformNames[] = { + "TRIANGLE", + "INVERSE_TRIANGLE", + "SAW", + "STEP", + "SINE" +}; + bool Editor(const char* label, TextureParam& texture) { bool edited{}; ImGui::PushID(label); @@ -55,24 +77,45 @@ bool Editor(const char* label, ChildEffect& effect) { bool edited{}; ImGui::PushID(label); edited |= Editor("flags", effect.flags); + edited |= Editor("unkType", effect.unkType); edited |= Editor("name", effect.name); ImGui::PopID(); return edited; } -bool Editor(const char* label, ModifierParam::GravityVectorSettings& settings) { +bool Editor(const char* label, ModifierParam::GravitySettings& settings) { + bool edited{}; + ImGui::PushID(label); + edited |= Editor("scale", settings.scale); + edited |= Editor("rotation", settings.rotation); + edited |= Editor("usesDirection", settings.usesDirection); + ImGui::PopID(); + return edited; +} + +bool Editor(const char* label, ModifierParam::SpeedSettings& settings) { bool edited{}; ImGui::PushID(label); edited |= Editor("scale", settings.scale); - edited |= Editor("value", settings.value); ImGui::PopID(); return edited; } -bool Editor(const char* label, ModifierParam::GravityOtherSettings& settings) { +bool Editor(const char* label, ModifierParam::MagnetSettings& settings) { bool edited{}; ImGui::PushID(label); - edited |= Editor("value", settings.value); + edited |= Editor("magnetPoint", settings.magnetPoint); + edited |= Editor("scale", settings.scale); + ImGui::PopID(); + return edited; +} + +bool Editor(const char* label, ModifierParam::NewtonSettings& settings) { + bool edited{}; + ImGui::PushID(label); + edited |= Editor("targetPoint", settings.targetPoint); + edited |= Editor("scale", settings.scale); + edited |= Editor("maxDistance", settings.maxDistance); ImGui::PopID(); return edited; } @@ -80,9 +123,58 @@ bool Editor(const char* label, ModifierParam::GravityOtherSettings& settings) { bool Editor(const char* label, ModifierParam::VortexSettings& settings) { bool edited{}; ImGui::PushID(label); - edited |= Editor("unk1", settings.unk1); - edited |= Editor("unk2", settings.unk2); - edited |= Editor("unk3", settings.unk3); + edited |= Editor("max", settings.max); + edited |= Editor("min", settings.min); + edited |= Editor("radius", settings.radius); + edited |= Editor("rotation", settings.rotation); + edited |= Editor("usesDirection", settings.usesDirection); + ImGui::PopID(); + return edited; +} + +bool Editor(const char* label, ModifierParam::SpinSettings& settings) { + bool edited{}; + ImGui::PushID(label); + edited |= Editor("scale", settings.scale); + edited |= Editor("rotation", settings.rotation); + edited |= Editor("usesDirection", settings.usesDirection); + ImGui::PopID(); + return edited; +} + +bool Editor(const char* label, ModifierParam::Spin2Settings& settings) { + bool edited{}; + ImGui::PushID(label); + edited |= Editor("baseStrength", settings.baseStrength); + edited |= Editor("spinStrength", settings.spinStrength); + edited |= Editor("rotationAngle", settings.rotationAngle); + edited |= Editor("axisFalloff", settings.axisFalloff); + edited |= Editor("axisVector", settings.axisVector); + edited |= Editor("useEulerRotation", settings.useEulerRotation); + ImGui::PopID(); + return edited; +} + +bool Editor(const char* label, ModifierParam::RandomSettings& settings) { + bool edited{}; + ImGui::PushID(label); + edited |= Editor("scale", settings.scale); + edited |= Editor("spreadScale", settings.spreadScale); + edited |= Editor("updateInterval", settings.updateInterval); + edited |= CheckboxFlags("RANDOMIZED_SCALE", settings.flags, ModifierParam::RandomSettings::Flags::RANDOMIZED_SCALE); + edited |= CheckboxFlags("X", settings.flags, ModifierParam::RandomSettings::Flags::X); + edited |= CheckboxFlags("Y", settings.flags, ModifierParam::RandomSettings::Flags::Y); + edited |= CheckboxFlags("Z", settings.flags, ModifierParam::RandomSettings::Flags::Z); + edited |= Editor("normalizedSpreadVector", settings.normalizedSpreadVector); + edited |= Editor("randomPerAxis", settings.randomPerAxis); + ImGui::PopID(); + return edited; +} + +bool Editor(const char* label, ModifierParam::TailSettings& settings) { + bool edited{}; + ImGui::PushID(label); + edited |= Editor("multiplier", settings.multiplier); ImGui::PopID(); return edited; } @@ -90,14 +182,9 @@ bool Editor(const char* label, ModifierParam::VortexSettings& settings) { bool Editor(const char* label, ModifierParam::FluctuationSettings& settings) { bool edited{}; ImGui::PushID(label); - edited |= Editor("unk0", settings.unk0); - edited |= Editor("unk1", settings.unk1); - edited |= Editor("unk2", settings.unk2); - edited |= Editor("unk3", settings.unk3); - edited |= Editor("unk4", settings.unk4); - edited |= Editor("unk5", settings.unk5); - edited |= Editor("unk6", settings.unk6); - edited |= Editor("unk7", settings.unk7); + edited |= ComboEnum("waveformType", settings.waveformType, waveformNames); + edited |= Editor("baseOffset", settings.baseOffset); + edited |= Editor("axisFlags", settings.axisFlags); ImGui::PopID(); return edited; } @@ -106,15 +193,22 @@ bool Editor(const char* label, ModifierParam& modifier) { bool edited{}; ImGui::PushID(label); + ImGui::Separator(); edited |= Editor("enabled", modifier.enabled); edited |= ComboEnum("type", modifier.type, modifierNames); - edited |= Editor("option1", modifier.option1); + edited |= ComboEnum("origin", modifier.origin, originNames); edited |= Editor("option2", modifier.option2); switch (modifier.type) { - case ModifierParam::Type::GRAVITY_VECTOR: edited |= Editor("settings", modifier.settings.gravityVector); break; - case ModifierParam::Type::GRAVITY_OTHER: edited |= Editor("settings", modifier.settings.gravityOther); break; + case ModifierParam::Type::GRAVITY: edited |= Editor("settings", modifier.settings.gravity); break; + case ModifierParam::Type::SPEED: edited |= Editor("settings", modifier.settings.speed); break; + case ModifierParam::Type::MAGNET: edited |= Editor("settings", modifier.settings.magnet); break; + case ModifierParam::Type::NEWTON: edited |= Editor("settings", modifier.settings.newton); break; case ModifierParam::Type::VORTEX: edited |= Editor("settings", modifier.settings.vortex); break; + case ModifierParam::Type::SPIN: edited |= Editor("settings", modifier.settings.spin); break; + case ModifierParam::Type::SPIN2: edited |= Editor("settings", modifier.settings.spin2); break; + case ModifierParam::Type::RANDOM: edited |= Editor("settings", modifier.settings.random); break; + case ModifierParam::Type::TAIL: edited |= Editor("settings", modifier.settings.tail); break; case ModifierParam::Type::FLUCTUATION: edited |= Editor("settings", modifier.settings.fluctuation); break; default: ImGui::Text("not yet implemented"); break; } @@ -175,17 +269,23 @@ bool Editor(const char* label, ElementParam& element) { edited |= Editor("unk18a0", element.unk18a0); edited |= Editor("angularVelocity", element.angularVelocity); edited |= Editor("unk18a01", element.unk18a01); - edited |= Editor("emitSpeed2", element.emitSpeed2); - edited |= Editor("unk18a02", element.unk18a02); - edited |= Editor("unkCount2", element.unkCount2); - edited |= Editor("unkCount3", element.unkCount3); + edited |= Editor("sizeX", element.sizeX); + edited |= Editor("sizeXJitter", element.sizeXJitter); + edited |= Editor("sizeY", element.sizeY); + edited |= Editor("sizeYJitter", element.sizeYJitter); + edited |= Editor("sizeZ", element.sizeZ); + edited |= Editor("sizeZJitter", element.sizeZJitter); + edited |= Editor("sizeFlags", element.sizeFlags); + edited |= Editor("scaleX", element.scaleX); + edited |= Editor("scaleXJitter", element.scaleXJitter); + edited |= Editor("scaleY", element.scaleY); + edited |= Editor("scaleYJitter", element.scaleYJitter); + edited |= Editor("scaleZ", element.scaleZ); + edited |= Editor("scaleZJitter", element.scaleZJitter); + edited |= Editor("scaleFlags", element.scaleFlags); edited |= Editor("tables", element.tables); edited |= Editor("fps", element.fps); - edited |= Editor("unk19a23", element.unk19a23); - edited |= Editor("unk18a6", element.unk18a6); - edited |= Editor("unk18a8", element.unk18a8); - edited |= Editor("unk18a1", element.unk18a1); - edited |= Editor("unk18a2", element.unk18a2); + edited |= Editor("fpsJitter", element.fpsJitter); edited |= Editor("unk18a", element.unk18a); edited |= Editor("modelName", element.modelName); edited |= Editor("particleTypeOrSomething", element.particleTypeOrSomething); @@ -218,22 +318,39 @@ bool Editor(const char* label, EmitterParam& emitter) { edited |= Editor("rotation", emitter.rotation); edited |= Editor("scale", emitter.scale); edited |= ComboEnum("shape", emitter.shape, shapeNames); + edited |= Editor("spread", emitter.spread); + edited |= Editor("startAngle", emitter.startAngle); + edited |= Editor("endAngle", emitter.endAngle); edited |= Editor("useRadialDistribution", emitter.useRadialDistribution); - edited |= Editor("consistentSpreadAngle", emitter.consistentSpreadAngle); + edited |= Editor("consistentAngle", emitter.consistentAngle); edited |= Editor("useAngularSubdivisions", emitter.useAngularSubdivisions); edited |= Editor("numSubDivisions", emitter.numSubDivisions); edited |= Editor("disabled", emitter.disabled); edited |= Editor("frequency", emitter.frequency); - edited |= Editor("frequencyRandomness", emitter.frequencyRandomness); + edited |= Editor("frequencyJitter", emitter.frequencyJitter); edited |= Editor("emitterCount", emitter.emitterCount); - edited |= Editor("emitterCountRandomness", emitter.emitterCountRandomness); - edited |= Editor("emitspeed", emitter.emitSpeed); - edited |= Editor("unkShapeRelated0", emitter.unkShapeRelated0); + edited |= Editor("emitterCountJitter", emitter.emitterCountJitter); + edited |= Editor("duration", emitter.duration); + edited |= Editor("startDelay", emitter.startDelay); + edited |= Editor("fadeSpeed", emitter.fadeSpeed); + edited |= Editor("lifeEndTime", emitter.lifeEndTime); + edited |= Editor("accelarationMultiplier", emitter.accelarationMultiplier); + edited |= Editor("accelarationNormalMultiplier", emitter.accelarationNormalMultiplier); + edited |= Editor("initialSpeed", emitter.initialSpeed); + edited |= Editor("velocityMultiplier", emitter.velocityMultiplier); edited |= Editor("shapeRadius", emitter.shapeRadius); - edited |= Editor("unkShapeRelated1", emitter.unkShapeRelated1); + edited |= Editor("velocityScale", emitter.velocityScale); edited |= Editor("emitSize", emitter.emitSize); + edited |= Editor("useEmitVector", emitter.useEmitVector); edited |= Editor("emitVector", emitter.emitVector); + edited |= Editor("emitVectorJitter", emitter.emitVectorJitter); + edited |= Editor("directionJitter", emitter.directionJitter); + edited |= Editor("inheritRatio", emitter.inheritRatio); edited |= Editor("randomSeed", emitter.randomSeed); + edited |= Editor("unkFloat0", emitter.unkFloat0); + edited |= Editor("unkFloat0Jitter", emitter.unkFloat0Jitter); + edited |= Editor("unkFloat1", emitter.unkFloat1); + edited |= Editor("unkFloat1Jitter", emitter.unkFloat1Jitter); edited |= Editor("element", emitter.elementParam); ImGui::PopID(); return edited; diff --git a/src/ui/resources/editors/ResEffectEditor.h b/src/ui/resources/editors/ResEffectEditor.h index 4fed94f..eb08d03 100644 --- a/src/ui/resources/editors/ResEffectEditor.h +++ b/src/ui/resources/editors/ResEffectEditor.h @@ -1,10 +1,6 @@ #pragma once #include -namespace heur::resources { - class ResEffect; -} - class ResEffectEditor : public StandaloneWindow { hh::fnd::Reference resource; public: diff --git a/src/ui/resources/editors/ResModelEditor.cpp b/src/ui/resources/editors/ResModelEditor.cpp index 4177d96..acdb8c7 100644 --- a/src/ui/resources/editors/ResModelEditor.cpp +++ b/src/ui/resources/editors/ResModelEditor.cpp @@ -7,6 +7,7 @@ using namespace hh::needle; ResModelEditor::~ResModelEditor() { + delete previewerCamera; delete previewer; } @@ -29,6 +30,9 @@ ResModelEditor::ResModelEditor(csl::fnd::IAllocator* allocator, ResModel* resour previewer = new (allocator) Previewer{ allocator }; previewer->Setup({.name = nameRaw}); previewer->AddModel(resource, true); + + previewerCamera = new (allocator) PreviewerCamera{ allocator }; + previewerCamera->Setup(previewer); } ResModelEditor* ResModelEditor::Create(csl::fnd::IAllocator* allocator, ResModel* resource) { @@ -51,4 +55,5 @@ void ResModelEditor::RenderContents() ImGui::Image(texture, size); } + previewerCamera->Render(); } diff --git a/src/ui/resources/editors/ResModelEditor.h b/src/ui/resources/editors/ResModelEditor.h index 7332f0e..e0ed96f 100644 --- a/src/ui/resources/editors/ResModelEditor.h +++ b/src/ui/resources/editors/ResModelEditor.h @@ -1,10 +1,12 @@ #pragma once #include #include +#include class ResModelEditor : public StandaloneWindow { public: hh::fnd::Reference previewer; + hh::fnd::Reference previewerCamera; virtual ~ResModelEditor(); diff --git a/src/utilities/math/MathUtils.cpp b/src/utilities/math/MathUtils.cpp index db8d5a7..fa963f7 100644 --- a/src/utilities/math/MathUtils.cpp +++ b/src/utilities/math/MathUtils.cpp @@ -82,3 +82,23 @@ ImVec2 NDCCoordsToImGui(const Eigen::Vector2f& coords) return { (coords.x() + 1.0f) * 0.5f * io.DisplaySize.x, (1.0f - coords.y()) * 0.5f * io.DisplaySize.y }; } + +glm::vec3 EigenToGLM(const Eigen::Vector3f& v) +{ + return glm::vec3(v.x(), v.y(), v.z()); +} + +Eigen::Vector3f GLMToEigen(const glm::vec3& v) +{ + return Eigen::Vector3f(v.x, v.y, v.z); +} + +glm::quat EigenToGLM(const Eigen::Quaternionf& q) +{ + return glm::quat(q.w(), q.x(), q.y(), q.z()); +} + +Eigen::Quaternionf GLMToEigen(const glm::quat& q) +{ + return Eigen::Quaternionf(q.w, q.x, q.y, q.z); +} diff --git a/src/utilities/math/MathUtils.h b/src/utilities/math/MathUtils.h index a8bfb67..47d2c1b 100644 --- a/src/utilities/math/MathUtils.h +++ b/src/utilities/math/MathUtils.h @@ -1,6 +1,8 @@ #pragma once #include "Ray.h" #include "Frustum.h" +#include +#include Eigen::Quaternionf EulerToQuat(const Eigen::Vector3f& vec); Eigen::Vector3f MatrixToEuler(const Eigen::Matrix3f& mat); @@ -15,3 +17,8 @@ Frustum ScreenRectToFrustum(const ImVec2& screenRect1, const ImVec2& screenRect2 Eigen::Vector2f ImGuiCoordsToNDC(const ImVec2& coords); ImVec2 NDCCoordsToImGui(const Eigen::Vector2f& coords); + +glm::vec3 EigenToGLM(const Eigen::Vector3f& v); +Eigen::Vector3f GLMToEigen(const glm::vec3& v); +glm::quat EigenToGLM(const Eigen::Quaternionf& q); +Eigen::Quaternionf GLMToEigen(const glm::quat& q); diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index fb8ab03..4faaae4 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -4,6 +4,7 @@ set(IMGUI_BUILD_BACKEND_DX11 ON) add_subdirectory(detours) add_subdirectory(imgui) add_subdirectory(imguizmo) +add_subdirectory(imviewguizmo) # add_subdirectory(imgui-file-dialog) add_subdirectory(imgui-node-editor) add_subdirectory(imgui_club) diff --git a/vendor/imviewguizmo/CMakeLists.txt b/vendor/imviewguizmo/CMakeLists.txt new file mode 100644 index 0000000..3888bbf --- /dev/null +++ b/vendor/imviewguizmo/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.28) +project(imviewguizmo LANGUAGES CXX) + +add_library(imviewguizmo INTERFACE) +target_link_libraries(imviewguizmo INTERFACE glm::glm) +target_sources(imviewguizmo + INTERFACE FILE_SET HEADERS BASE_DIRS ImViewGuizmo FILES + ImViewGuizmo/ImViewGuizmo.h +) diff --git a/vendor/imviewguizmo/ImViewGuizmo b/vendor/imviewguizmo/ImViewGuizmo new file mode 160000 index 0000000..104a4e1 --- /dev/null +++ b/vendor/imviewguizmo/ImViewGuizmo @@ -0,0 +1 @@ +Subproject commit 104a4e1cf20e87fff1daa264690e0f9f446920e1 From 7b5f50823c3323a68509e099c89a3168fcc0701e Mon Sep 17 00:00:00 2001 From: Ashrindy Date: Thu, 18 Sep 2025 20:08:39 +0200 Subject: [PATCH 07/13] no more memory corruption --- src/ui/common/previewer/PreviewerCamera.cpp | 4 ---- src/ui/common/previewer/PreviewerCamera.h | 5 ++--- src/ui/resources/editors/ResModelEditor.cpp | 8 +------- src/ui/resources/editors/ResModelEditor.h | 2 -- 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/ui/common/previewer/PreviewerCamera.cpp b/src/ui/common/previewer/PreviewerCamera.cpp index 32b9d5e..d253f1e 100644 --- a/src/ui/common/previewer/PreviewerCamera.cpp +++ b/src/ui/common/previewer/PreviewerCamera.cpp @@ -3,10 +3,6 @@ #define IMVIEWGUIZMO_IMPLEMENTATION #include -PreviewerCamera::~PreviewerCamera() -{ -} - PreviewerCamera::PreviewerCamera(csl::fnd::IAllocator* allocator) : CompatibleObject{ allocator } { } diff --git a/src/ui/common/previewer/PreviewerCamera.h b/src/ui/common/previewer/PreviewerCamera.h index 7288c5f..c2957fa 100644 --- a/src/ui/common/previewer/PreviewerCamera.h +++ b/src/ui/common/previewer/PreviewerCamera.h @@ -4,11 +4,10 @@ class PreviewerCamera : public CompatibleObject { public: - hh::fnd::Reference previewer{}; + Previewer* previewer; hh::gfnd::ViewportData viewportData; float controlSpeed = 0.015f; - - virtual ~PreviewerCamera(); + PreviewerCamera(csl::fnd::IAllocator* allocator); void Setup(Previewer* previewer); diff --git a/src/ui/resources/editors/ResModelEditor.cpp b/src/ui/resources/editors/ResModelEditor.cpp index acdb8c7..5b35b23 100644 --- a/src/ui/resources/editors/ResModelEditor.cpp +++ b/src/ui/resources/editors/ResModelEditor.cpp @@ -5,12 +5,6 @@ using namespace hh::gfx; using namespace hh::needle; -ResModelEditor::~ResModelEditor() -{ - delete previewerCamera; - delete previewer; -} - ResModelEditor::ResModelEditor(csl::fnd::IAllocator* allocator, ResModel* resource) : StandaloneWindow{ allocator } { char namebuf[500]; @@ -31,7 +25,7 @@ ResModelEditor::ResModelEditor(csl::fnd::IAllocator* allocator, ResModel* resour previewer->Setup({.name = nameRaw}); previewer->AddModel(resource, true); - previewerCamera = new (allocator) PreviewerCamera{ allocator }; + previewerCamera = new (allocator) PreviewerCamera{allocator}; previewerCamera->Setup(previewer); } diff --git a/src/ui/resources/editors/ResModelEditor.h b/src/ui/resources/editors/ResModelEditor.h index e0ed96f..7fdc091 100644 --- a/src/ui/resources/editors/ResModelEditor.h +++ b/src/ui/resources/editors/ResModelEditor.h @@ -8,8 +8,6 @@ class ResModelEditor : public StandaloneWindow { hh::fnd::Reference previewer; hh::fnd::Reference previewerCamera; - virtual ~ResModelEditor(); - ResModelEditor(csl::fnd::IAllocator* allocator, hh::gfx::ResModel* resource); virtual void RenderContents(); static ResModelEditor* Create(csl::fnd::IAllocator* allocator, hh::gfx::ResModel* resource); From 15dc9e43d583964aa73ca28615f04e38bc10adc9 Mon Sep 17 00:00:00 2001 From: Ashrindy Date: Fri, 19 Sep 2025 19:49:47 +0200 Subject: [PATCH 08/13] fixes --- src/CMakeLists.txt | 12 +- .../renderables/PhysicalAnimation.cpp | 22 ++-- src/ui/common/previewer/PreviewerCamera.cpp | 65 ---------- src/ui/common/previewer/PreviewerCamera.h | 18 --- .../common/viewport/InteractiveViewport.cpp | 58 +++++++++ src/ui/common/viewport/InteractiveViewport.h | 14 +++ src/ui/common/viewport/Scene.cpp | 1 + src/ui/common/viewport/Scene.h | 7 ++ .../Previewer.cpp => viewport/Viewport.cpp} | 116 +++++++++--------- .../Previewer.h => viewport/Viewport.h} | 19 +-- .../GOCPlayerBlackboard.cpp | 1 + src/ui/resources/editors/ResModelEditor.cpp | 38 ++---- src/ui/resources/editors/ResModelEditor.h | 6 +- src/utilities/math/GLMUtils.cpp | 17 +++ src/utilities/math/GLMUtils.h | 8 ++ src/utilities/math/MathUtils.cpp | 20 --- src/utilities/math/MathUtils.h | 7 -- 17 files changed, 202 insertions(+), 227 deletions(-) delete mode 100644 src/ui/common/previewer/PreviewerCamera.cpp delete mode 100644 src/ui/common/previewer/PreviewerCamera.h create mode 100644 src/ui/common/viewport/InteractiveViewport.cpp create mode 100644 src/ui/common/viewport/InteractiveViewport.h create mode 100644 src/ui/common/viewport/Scene.cpp create mode 100644 src/ui/common/viewport/Scene.h rename src/ui/common/{previewer/Previewer.cpp => viewport/Viewport.cpp} (57%) rename src/ui/common/{previewer/Previewer.h => viewport/Viewport.h} (85%) create mode 100644 src/utilities/math/GLMUtils.cpp create mode 100644 src/utilities/math/GLMUtils.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8a37093..7b4abac 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -44,8 +44,9 @@ target_sources(${DEVTOOLS_TARGET} ui/common/viewers/RflDiff.cpp ui/common/inputs/Basic.cpp ui/common/overlays/Tag.cpp - ui/common/previewer/Previewer.cpp - ui/common/previewer/PreviewerCamera.cpp + ui/common/viewport/Viewport.cpp + ui/common/viewport/Scene.cpp + ui/common/viewport/InteractiveViewport.cpp ui/common/icons.cpp ui/common/StandaloneWindow.cpp ui/common/stb_image.cpp @@ -74,6 +75,7 @@ target_sources(${DEVTOOLS_TARGET} utilities/math/EulerTransform.cpp utilities/math/Frustum.cpp utilities/math/MathUtils.cpp + utilities/math/GLMUtils.cpp utilities/ObjectDataUtils.cpp utilities/GameObjectUtils.cpp utilities/ResourceTypes.cpp @@ -126,8 +128,9 @@ target_sources(${DEVTOOLS_TARGET} ui/common/inputs/Basic.h ui/common/inputs/Needle.h ui/common/overlays/Tag.h - ui/common/previewer/Previewer.h - ui/common/previewer/PreviewerCamera.h + ui/common/viewport/Viewport.h + ui/common/viewport/Scene.h + ui/common/viewport/InteractiveViewport.h ui/common/icons.h ui/common/NodeEditor.h ui/common/StandaloneWindow.h @@ -170,6 +173,7 @@ target_sources(${DEVTOOLS_TARGET} utilities/Helpers.h utilities/math/EulerTransform.h utilities/math/MathUtils.h + utilities/math/GLMUtils.h utilities/math/Frustum.h utilities/math/Ray.h utilities/ObjectDataUtils.h diff --git a/src/debug-rendering/renderables/PhysicalAnimation.cpp b/src/debug-rendering/renderables/PhysicalAnimation.cpp index daa8549..4bf64f4 100644 --- a/src/debug-rendering/renderables/PhysicalAnimation.cpp +++ b/src/debug-rendering/renderables/PhysicalAnimation.cpp @@ -31,7 +31,7 @@ namespace devtools::debug_rendering::renderables { gocPBA->GetRigidBodyPositions(rigidBodyPositions); for (size_t i = 0; i < gocPBA->physSkelRes->rigidbodies.size(); i++) { - static const csl::ut::Color8 rigidBodyColor = { 255, 0, 255, 255 }; + static const csl::ut::Color8 rigidBodyColor{ 255, 0, 255, 255 }; auto& rb = gocPBA->physSkelRes->rigidbodies[i]; auto& pos = rigidBodyPositions[i]; @@ -50,14 +50,14 @@ namespace devtools::debug_rendering::renderables { if (gocPBA->hasSoftBody) { for (auto i = 0; i < gocPBA->physSkelRes->softbodies.size(); i++) { - static const csl::ut::Color8 softBodyColor = { 0, 255, 0, 255 }; + static const csl::ut::Color8 softBodyColor{ 0, 255, 0, 255 }; auto& sb = gocPBA->physSkelRes->softbodies[i]; csl::ut::MoveArray nodePositions{ hh::fnd::MemoryRouter::GetTempAllocator() }; gocPBA->GetSoftBodyNodePositions(i, nodePositions); for (auto x = 0; x < sb.nodes.size(); x++) { - auto transform = csl::math::Matrix34::Identity(); + auto transform{ csl::math::Matrix34::Identity() }; transform.translate(nodePositions[x]); ctx.DrawSphere(transform, 0.01f, softBodyColor); } @@ -66,21 +66,15 @@ namespace devtools::debug_rendering::renderables { unsigned int linkCount = sb.links.size(); unsigned int linkSize = linkCount * 2; - hh::gfnd::DrawVertex* vertices = static_cast(tempAlloc->Alloc(linkSize * sizeof(hh::gfnd::DrawVertex), 4)); - unsigned short* indices = static_cast(tempAlloc->Alloc(linkSize * sizeof(short), 2)); + hh::gfnd::DrawVertex* vertices = new (tempAlloc) hh::gfnd::DrawVertex[linkSize]; + unsigned short* indices = new (tempAlloc) unsigned short[linkSize]; for (auto x = 0; x < linkCount; x++) { auto& link = sb.links[x]; - csl::math::Vector3 nodes[2] = { nodePositions[link.verts[0]], nodePositions[link.verts[1]] }; + csl::math::Vector3 nodes[2]{ nodePositions[link.verts[0]], nodePositions[link.verts[1]] }; int curVert = x * 2; - vertices[curVert].x = nodes[0].x(); - vertices[curVert].y = nodes[0].y(); - vertices[curVert].z = nodes[0].z(); - vertices[curVert].color = 0xFF00FF00; - vertices[curVert + 1].x = nodes[1].x(); - vertices[curVert + 1].y = nodes[1].y(); - vertices[curVert + 1].z = nodes[1].z(); - vertices[curVert + 1].color = 0xFF00FF00; + vertices[curVert] = { .x = nodes[0].x(), .y = nodes[0].y(), .z = nodes[0].z(), .color = 0xFF00FF00 }; + vertices[curVert + 1] = { .x = nodes[1].x(), .y = nodes[1].y(), .z = nodes[1].z(), .color = 0xFF00FF00 }; indices[curVert] = curVert; indices[curVert + 1] = curVert + 1; } diff --git a/src/ui/common/previewer/PreviewerCamera.cpp b/src/ui/common/previewer/PreviewerCamera.cpp deleted file mode 100644 index d253f1e..0000000 --- a/src/ui/common/previewer/PreviewerCamera.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "PreviewerCamera.h" -#include -#define IMVIEWGUIZMO_IMPLEMENTATION -#include - -PreviewerCamera::PreviewerCamera(csl::fnd::IAllocator* allocator) : CompatibleObject{ allocator } -{ -} - -void PreviewerCamera::Setup(Previewer* previewer) -{ - this->previewer = previewer; - viewportData = previewer->viewportData; -} - -bool PreviewerCamera::RotateControl(csl::math::Vector3& position, csl::math::Quaternion& rotation) const -{ - glm::vec3 camPos = EigenToGLM(position); - glm::quat camRot = EigenToGLM(rotation); - - const ImVec2 guizmoHRes = ImVec2{ 80, 80 } * ImViewGuizmo::GetStyle().scale; - - ImVec2 guizmoPos = - ImGui::GetWindowContentRegionMin() + ImGui::GetWindowPos() + // base position - ImVec2{ viewportData.viewportDimensions.resX - guizmoHRes.x, guizmoHRes.y }; // offset position - - // dirty hack to stop the window from moving - ImVec2 invisPos = guizmoPos - guizmoHRes; - ImVec2 invisSize = guizmoHRes * 2; - ImGui::SetCursorScreenPos(invisPos); - ImGui::InvisibleButton("unmovable", invisSize); - - bool changed = false; - - if (changed |= ImViewGuizmo::Rotate(camPos, camRot, guizmoPos, previewer->GetZoomToAABB(), controlSpeed)) { - position = GLMToEigen(camPos); - rotation = GLMToEigen(camRot); - } - - return changed; -} - -void PreviewerCamera::Render() -{ - auto& viewMatrix = viewportData.viewMatrix; - - csl::math::Vector3 camPos = viewMatrix.translation(); - csl::math::Quaternion camRot{ viewMatrix.rotation() }; - - if (RotateControl(camPos, camRot)) - UpdateViewMatrix(camPos, camRot); -} - -void PreviewerCamera::UpdateViewMatrix(const csl::math::Vector3& position, const csl::math::Quaternion& rotation) -{ - auto& viewMatrix = viewportData.viewMatrix; - viewMatrix.linear() = rotation.toRotationMatrix(); - viewMatrix.translation() = position; - viewportData.viewMatrix = viewMatrix; - - if (previewer) { - previewer->SetViewMatrix(viewMatrix); - previewer->UpdateViewMatrix(); - } -} diff --git a/src/ui/common/previewer/PreviewerCamera.h b/src/ui/common/previewer/PreviewerCamera.h deleted file mode 100644 index c2957fa..0000000 --- a/src/ui/common/previewer/PreviewerCamera.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include -#include - -class PreviewerCamera : public CompatibleObject { -public: - Previewer* previewer; - hh::gfnd::ViewportData viewportData; - float controlSpeed = 0.015f; - - PreviewerCamera(csl::fnd::IAllocator* allocator); - - void Setup(Previewer* previewer); - - bool RotateControl(csl::math::Vector3& position, csl::math::Quaternion& rotation) const; - void Render(); - void UpdateViewMatrix(const csl::math::Vector3& position, const csl::math::Quaternion& rotation); -}; diff --git a/src/ui/common/viewport/InteractiveViewport.cpp b/src/ui/common/viewport/InteractiveViewport.cpp new file mode 100644 index 0000000..986fe98 --- /dev/null +++ b/src/ui/common/viewport/InteractiveViewport.cpp @@ -0,0 +1,58 @@ +#include "InteractiveViewport.h" +#include +#define IMVIEWGUIZMO_IMPLEMENTATION +#include + +InteractiveViewport::InteractiveViewport(csl::fnd::IAllocator* allocator) : Viewport{ allocator } {} + +bool InteractiveViewport::RotateControl(csl::math::Vector3& position, csl::math::Quaternion& rotation) const { + glm::vec3 camPos = EigenToGLM(position); + glm::quat camRot = EigenToGLM(rotation); + + const ImVec2 guizmoHRes = ImVec2{ 80, 80 } * ImViewGuizmo::GetStyle().scale; + const ImVec2 guizmoRes = guizmoHRes * 2; + + ImVec2 guizmoPos = + ImGui::GetWindowContentRegionMin() + ImGui::GetWindowPos() + // base position + ImVec2{ viewportData.viewportDimensions.resX - guizmoHRes.x, guizmoHRes.y }; // offset position + + ImGui::Dummy(guizmoRes); + + auto id = ImGui::GetID("hover"); + + if (ImGui::ItemHoverable(ImRect(guizmoPos - guizmoHRes, guizmoPos + guizmoHRes), id, ImGuiItemFlags_None)) { + if (ImGui::IsMouseDown(ImGuiMouseButton_Left) && ImGui::IsMouseHoveringRect(guizmoPos - guizmoHRes, guizmoPos + guizmoHRes)) + ImGui::SetActiveID(id, ImGui::GetCurrentWindow()); + if (ImGui::IsMouseReleased(ImGuiMouseButton_Left) && ImGui::IsMouseHoveringRect(guizmoPos - guizmoHRes, guizmoPos + guizmoHRes)) + ImGui::ClearActiveID(); + } + + bool changed = false; + + if (changed |= ImViewGuizmo::Rotate(camPos, camRot, guizmoPos, GetZoomToAABB(), controlSpeed)) { + position = GLMToEigen(camPos); + rotation = GLMToEigen(camRot); + } + + return changed; +} + +void InteractiveViewport::Render() { + Viewport::Render(); + + auto& viewMatrix = viewportData.viewMatrix; + + csl::math::Vector3 camPos{ viewMatrix.translation() }; + csl::math::Quaternion camRot{ viewMatrix.rotation() }; + + if (RotateControl(camPos, camRot)) + UpdateMatrix(camPos, camRot); +} + +void InteractiveViewport::UpdateMatrix(const csl::math::Vector3& position, const csl::math::Quaternion& rotation) { + auto& viewMatrix = viewportData.viewMatrix; + viewMatrix.linear() = rotation.toRotationMatrix(); + viewMatrix.translation() = position; + viewportData.inverseViewMatrix = viewMatrix.inverse(); + UpdateViewportData(); +} diff --git a/src/ui/common/viewport/InteractiveViewport.h b/src/ui/common/viewport/InteractiveViewport.h new file mode 100644 index 0000000..0a6337a --- /dev/null +++ b/src/ui/common/viewport/InteractiveViewport.h @@ -0,0 +1,14 @@ +#pragma once +#include +#include + +class InteractiveViewport : public Viewport { +public: + float controlSpeed{ 0.015f }; + + InteractiveViewport(csl::fnd::IAllocator* allocator); + + bool RotateControl(csl::math::Vector3& position, csl::math::Quaternion& rotation) const; + virtual void Render() override; + void UpdateMatrix(const csl::math::Vector3& position, const csl::math::Quaternion& rotation); +}; diff --git a/src/ui/common/viewport/Scene.cpp b/src/ui/common/viewport/Scene.cpp new file mode 100644 index 0000000..333cc85 --- /dev/null +++ b/src/ui/common/viewport/Scene.cpp @@ -0,0 +1 @@ +#include "Scene.h" diff --git a/src/ui/common/viewport/Scene.h b/src/ui/common/viewport/Scene.h new file mode 100644 index 0000000..2509437 --- /dev/null +++ b/src/ui/common/viewport/Scene.h @@ -0,0 +1,7 @@ +#pragma once +#include + +class Scene : public CompatibleObject { +public: + +}; diff --git a/src/ui/common/previewer/Previewer.cpp b/src/ui/common/viewport/Viewport.cpp similarity index 57% rename from src/ui/common/previewer/Previewer.cpp rename to src/ui/common/viewport/Viewport.cpp index 93823c0..760a1dc 100644 --- a/src/ui/common/previewer/Previewer.cpp +++ b/src/ui/common/viewport/Viewport.cpp @@ -1,11 +1,10 @@ -#include "Previewer.h" +#include "Viewport.h" #include using namespace hh::gfx; using namespace hh::needle; -Previewer::~Previewer() -{ +Viewport::~Viewport() { if (renderTexture) { auto* renderMgr = reinterpret_cast(hh::gfnd::RenderManagerBase::GetInstance()); auto* renderEngine = renderMgr->GetNeedleResourceDevice(); @@ -14,12 +13,27 @@ Previewer::~Previewer() } } -Previewer::Previewer(csl::fnd::IAllocator* allocator) : CompatibleObject{ allocator }, models { allocator }, name{ allocator } +Viewport::Viewport(csl::fnd::IAllocator* allocator) : CompatibleObject{ allocator }, models { GetAllocator() }, name{ GetAllocator() } {} + +void Viewport::Render() { + if (auto* texture = GetTextureID()) { + ImVec2 pos = ImGui::GetCursorScreenPos(); + + auto& dimensions = viewportData.viewportDimensions; + ImVec2 size{ static_cast(dimensions.resX), static_cast(dimensions.resY) }; + + ImGui::GetWindowDrawList()->AddRectFilled( + pos, + ImVec2(pos.x + size.x, pos.y + size.y), + IM_COL32(0, 0, 0, 255) + ); + + ImGui::Image(texture, size); + } } -void Previewer::Setup(const Description& desc) -{ +void Viewport::Setup(const Description& desc) { auto* renderMgr = reinterpret_cast(hh::gfnd::RenderManagerBase::GetInstance()); auto* renderEngine = renderMgr->GetNeedleResourceDevice(); auto* supportFx = renderEngine->GetSupportFX(); @@ -37,7 +51,7 @@ void Previewer::Setup(const Description& desc) .flags = RenderTextureCreateArgs::UNK2, .clearedTextureCount = 1, .textureSettings = &textureSettings, - .allocator = pAllocator, + .allocator = GetAllocator(), .name = name.c_str(), .sceneName = name.c_str(), .autoCreatePipeline = true @@ -62,54 +76,46 @@ void Previewer::Setup(const Description& desc) AddModel(desc.modelInstance, desc.setToAabb); } -void Previewer::UpdateViewportData() -{ +void Viewport::UpdateViewportData() { renderTexture->SetCameraParameter(viewportData.viewMatrix, viewportData.projMatrix); } -void Previewer::SetViewMatrix(const csl::math::Matrix34& mat) -{ +void Viewport::SetViewMatrix(const csl::math::Matrix34& mat) { viewportData.viewMatrix = mat; - csl::math::Matrix34 invViewMat = viewportData.viewMatrix.inverse(); - viewportData.inverseViewMatrix.translate(invViewMat.translation()); + viewportData.inverseViewMatrix = viewportData.viewMatrix.inverse(); } -void Previewer::UpdateViewMatrix() -{ - auto mat = viewportData.viewMatrix.matrix(); - csl::math::Vector3 camPos = { mat(0, 3), mat(1, 3), mat(2, 3) }; +void Viewport::UpdateViewMatrix() { + auto mat = viewportData.viewMatrix; + csl::math::Vector3 camPos{ mat.translation() }; SetCameraPositionAndTarget(camPos, viewportData.lookAtPos); UpdateViewportData(); } -float Previewer::GetZoomToAABB(const csl::geom::Aabb& aabb) const -{ - csl::math::Vector3 bboxCenter = aabb.Center(); - csl::math::Vector3 bboxExtent = aabb.Extent(); - float maxDimension = bboxExtent.norm(); +float Viewport::GetZoomToAABB(const csl::geom::Aabb& aabb) const { + csl::math::Vector3 bboxExtent{ aabb.Extent() }; + float maxDimension{ bboxExtent.norm() }; return maxDimension * 2.5f; } -float Previewer::GetZoomToAABB(hh::needle::PBRModelInstance* modelAabb) const -{ +float Viewport::GetZoomToAABB(hh::needle::PBRModelInstance* modelAabb) const { csl::geom::Aabb bbox; modelAabb->GetModelSpaceAabb(&bbox); return GetZoomToAABB(bbox); } -float Previewer::GetZoomToAABB() const -{ +float Viewport::GetZoomToAABB() const { if (models.empty()) return 2.5f; - float lastDistance = GetZoomToAABB(models[0]); + float lastDistance{ GetZoomToAABB(models[0]) }; if (models.size()) return lastDistance; for (auto* model : models) { if (model == models[0]) continue; - float distance = GetZoomToAABB(model); + float distance{ GetZoomToAABB(model) }; if (distance > lastDistance) lastDistance = distance; } @@ -117,50 +123,44 @@ float Previewer::GetZoomToAABB() const return lastDistance; } -void Previewer::SetCameraToAABB(const csl::geom::Aabb& aabb) -{ - float distance = GetZoomToAABB(aabb); +void Viewport::SetCameraToAABB(const csl::geom::Aabb& aabb) { + float distance{ GetZoomToAABB(aabb) }; - csl::math::Vector3 direction = { 1, 1, 1 }; + csl::math::Vector3 direction{ 1, 1, 1 }; direction.normalize(); - csl::math::Vector3 bboxCenter = aabb.Center(); - csl::math::Vector3 camPos = bboxCenter + direction * distance; - csl::math::Vector3 camTargetPos = bboxCenter; + csl::math::Vector3 bboxCenter{ aabb.Center() }; + csl::math::Vector3 camPos{ bboxCenter + direction * distance }; + csl::math::Vector3 camTargetPos{ bboxCenter }; SetCameraPositionAndTarget(camPos, camTargetPos); UpdateViewportData(); } -void Previewer::SetCameraToAABB(hh::needle::PBRModelInstance* modelAabb) -{ +void Viewport::SetCameraToAABB(hh::needle::PBRModelInstance* modelAabb) { csl::geom::Aabb bbox; modelAabb->GetModelSpaceAabb(&bbox); SetCameraToAABB(bbox); } -void Previewer::SetCameraPositionAndTarget(const csl::math::Vector3& position, const csl::math::Vector3& target) -{ +void Viewport::SetCameraPositionAndTarget(const csl::math::Vector3& position, const csl::math::Vector3& target) { SetViewMatrix(csl::math::Matrix34LookAt(position, csl::math::Vector3::UnitY(), target)); viewportData.lookAtPos = target; } -void Previewer::SetCameraPosition(const csl::math::Vector3& position) -{ +void Viewport::SetCameraPosition(const csl::math::Vector3& position) { SetViewMatrix(csl::math::Matrix34LookAt(position, csl::math::Vector3::UnitY(), viewportData.lookAtPos)); } -void Previewer::SetCameraTarget(const csl::math::Vector3& target) -{ - auto mat = viewportData.viewMatrix.matrix(); - csl::math::Vector3 camPos = { mat(0, 3), mat(1, 3), mat(2, 3) }; +void Viewport::SetCameraTarget(const csl::math::Vector3& target) { + auto& mat{ viewportData.viewMatrix }; + csl::math::Vector3 camPos{ mat.translation() }; SetViewMatrix(csl::math::Matrix34LookAt(camPos, csl::math::Vector3::UnitY(), target)); viewportData.lookAtPos = target; } -void Previewer::SetCameraFOV(const float fov) -{ - auto& dimensions = viewportData.viewportDimensions; +void Viewport::SetCameraFOV(const float fov) { + auto& dimensions{ viewportData.viewportDimensions }; float nearZ{ .1f }; float farZ{ 10000 }; @@ -174,32 +174,28 @@ void Previewer::SetCameraFOV(const float fov) ); } -hh::needle::Texture* Previewer::GetTexture() const -{ +hh::needle::Texture* Viewport::GetTexture() const { if (!renderTexture) return nullptr; return renderTexture->GetTexture(0); } -ImTextureID Previewer::GetTextureID() const -{ - auto* texture = GetTexture(); +ImTextureID Viewport::GetTextureID() const { + auto* texture{ GetTexture() }; return texture == nullptr ? nullptr : GetTextureIDFromMIRAGETexture(texture); } -void Previewer::AddModel(hh::needle::PBRModelInstance* modelInstance, bool setToAabb) -{ +void Viewport::AddModel(hh::needle::PBRModelInstance* modelInstance, bool setToAabb) { models.push_back(modelInstance); - auto* world = renderTexture->GetWorldByIdx(0); - auto* unk0 = world->UnkFunc1(); - world->AddModelInstance(modelInstance, unk0, true, -1, NEEDLE_RESOURCE_MODEL_INSTANCE); + auto* world{ renderTexture->GetWorldByIdx(0) }; + auto* entryLink{ world->GetReferWorld() }; + world->AddModelInstanceNode(modelInstance, entryLink, true, -1, NEEDLE_RESOURCE_MODEL_INSTANCE); if (setToAabb) SetCameraToAABB(modelInstance); } -void Previewer::AddModel(hh::gfx::ResModel* resModel, bool setToAabb) -{ +void Viewport::AddModel(hh::gfx::ResModel* resModel, bool setToAabb) { auto* renderMgr = reinterpret_cast(hh::gfnd::RenderManagerBase::GetInstance()); hh::gfx::RenderManager::SModelCreationInfo createInfo{ pAllocator }; createInfo.meshResource = resModel->GetMeshResource(); diff --git a/src/ui/common/previewer/Previewer.h b/src/ui/common/viewport/Viewport.h similarity index 85% rename from src/ui/common/previewer/Previewer.h rename to src/ui/common/viewport/Viewport.h index 7263a67..ef56291 100644 --- a/src/ui/common/previewer/Previewer.h +++ b/src/ui/common/viewport/Viewport.h @@ -1,23 +1,25 @@ #pragma once #include -class Previewer : public CompatibleObject { +class Viewport : public CompatibleObject { public: struct Description { unsigned int resolution[2]{ 1024, 1024 }; hh::needle::PBRModelInstance* modelInstance; - const char* name = "Previewer"; + const char* name{ "Viewport" }; float fov{ 1.0476f }; bool setToAabb{ false }; }; csl::ut::MoveArray models; hh::needle::RenderTextureHandle* renderTexture; - hh::gfnd::ViewportData viewportData; + hh::gfnd::ViewportData viewportData{}; csl::ut::VariableString name; - virtual ~Previewer(); - Previewer(csl::fnd::IAllocator* allocator); + virtual ~Viewport(); + Viewport(csl::fnd::IAllocator* allocator); + + virtual void Render(); void Setup(const Description& desc); @@ -36,9 +38,10 @@ class Previewer : public CompatibleObject { void SetCameraTarget(const csl::math::Vector3& target); void SetCameraFOV(const float fov); - hh::needle::Texture* GetTexture() const; - ImTextureID GetTextureID() const; - void AddModel(hh::needle::PBRModelInstance* modelInstance, bool setToAabb = false); void AddModel(hh::gfx::ResModel* resModel, bool setToAabb = false); + +protected: + hh::needle::Texture* GetTexture() const; + ImTextureID GetTextureID() const; }; diff --git a/src/ui/operation-modes/modes/object-inspection/component-inspectors/GOCPlayerBlackboard.cpp b/src/ui/operation-modes/modes/object-inspection/component-inspectors/GOCPlayerBlackboard.cpp index 02c087a..023e791 100644 --- a/src/ui/operation-modes/modes/object-inspection/component-inspectors/GOCPlayerBlackboard.cpp +++ b/src/ui/operation-modes/modes/object-inspection/component-inspectors/GOCPlayerBlackboard.cpp @@ -476,6 +476,7 @@ void RenderBlackboardStatusInspector(app::player::BlackboardStatus& blackboard) //csl::ut::InplaceMoveArray qword90; //csl::ut::InplaceMoveArray qwordC0; //csl::ut::InplaceMoveArray qwordF0; + Editor("dword120", blackboard.dword120); //ut::PriorityList> qword130; Editor("oword160", blackboard.oword160); ImGui::DragScalar("dword170", ImGuiDataType_U32, &blackboard.dword170); diff --git a/src/ui/resources/editors/ResModelEditor.cpp b/src/ui/resources/editors/ResModelEditor.cpp index 5b35b23..4f54de4 100644 --- a/src/ui/resources/editors/ResModelEditor.cpp +++ b/src/ui/resources/editors/ResModelEditor.cpp @@ -1,53 +1,37 @@ #include "ResModelEditor.h" #include #include +#include using namespace hh::gfx; using namespace hh::needle; -ResModelEditor::ResModelEditor(csl::fnd::IAllocator* allocator, ResModel* resource) : StandaloneWindow{ allocator } -{ +ResModelEditor::ResModelEditor(csl::fnd::IAllocator* allocator, ResModel* resource) : StandaloneWindow{ allocator } { char namebuf[500]; snprintf(namebuf, sizeof(namebuf), "%s - %s @ 0x%zx (file mapped @ 0x%zx)", resource->GetName(), resource->GetClass().pName, (size_t)&resource, (size_t)resource); SetTitle(namebuf); - static const char* nameTemplate = "ModelPreview"; + static const char* nameTemplate = "ModelViewport"; static const size_t nameTemplateLen = strlen(nameTemplate); const char* resName = resource->name.c_str(); const size_t resNameLen = strlen(resName); const size_t nameLen = resNameLen + nameTemplateLen + 1; - char* nameRaw = static_cast(pAllocator->Alloc(nameLen, 4)); + char* nameRaw = new (GetAllocator()) char[nameLen]; snprintf(nameRaw, nameLen, "%s%s", resName, nameTemplate); - previewer = new (allocator) Previewer{ allocator }; - previewer->Setup({.name = nameRaw}); - previewer->AddModel(resource, true); + viewport = new (allocator) InteractiveViewport{ allocator }; + viewport->Setup({.name = nameRaw}); + viewport->AddModel(resource, true); - previewerCamera = new (allocator) PreviewerCamera{allocator}; - previewerCamera->Setup(previewer); + GetAllocator()->Free(nameRaw); } ResModelEditor* ResModelEditor::Create(csl::fnd::IAllocator* allocator, ResModel* resource) { - return new (allocator) ResModelEditor(allocator, resource); + return new (allocator) ResModelEditor{ allocator, resource }; } -void ResModelEditor::RenderContents() -{ - if (auto* texture = previewer->GetTextureID()) { - ImVec2 pos = ImGui::GetCursorScreenPos(); - - auto& dimensions = previewer->viewportData.viewportDimensions; - ImVec2 size = { static_cast(dimensions.resX), static_cast(dimensions.resY) }; - - ImGui::GetWindowDrawList()->AddRectFilled( - pos, - ImVec2(pos.x + size.x, pos.y + size.y), - IM_COL32(0, 0, 0, 255) - ); - - ImGui::Image(texture, size); - } - previewerCamera->Render(); +void ResModelEditor::RenderContents() { + viewport->Render(); } diff --git a/src/ui/resources/editors/ResModelEditor.h b/src/ui/resources/editors/ResModelEditor.h index 7fdc091..e22304d 100644 --- a/src/ui/resources/editors/ResModelEditor.h +++ b/src/ui/resources/editors/ResModelEditor.h @@ -1,12 +1,10 @@ #pragma once #include -#include -#include +#include class ResModelEditor : public StandaloneWindow { public: - hh::fnd::Reference previewer; - hh::fnd::Reference previewerCamera; + hh::fnd::Reference viewport; ResModelEditor(csl::fnd::IAllocator* allocator, hh::gfx::ResModel* resource); virtual void RenderContents(); diff --git a/src/utilities/math/GLMUtils.cpp b/src/utilities/math/GLMUtils.cpp new file mode 100644 index 0000000..3dd7527 --- /dev/null +++ b/src/utilities/math/GLMUtils.cpp @@ -0,0 +1,17 @@ +#include "GLMUtils.h" + +glm::vec3 EigenToGLM(const Eigen::Vector3f& v) { + return glm::vec3(v.x(), v.y(), v.z()); +} + +Eigen::Vector3f GLMToEigen(const glm::vec3& v) { + return Eigen::Vector3f(v.x, v.y, v.z); +} + +glm::quat EigenToGLM(const Eigen::Quaternionf& q) { + return glm::quat(q.w(), q.x(), q.y(), q.z()); +} + +Eigen::Quaternionf GLMToEigen(const glm::quat& q) { + return Eigen::Quaternionf(q.w, q.x, q.y, q.z); +} diff --git a/src/utilities/math/GLMUtils.h b/src/utilities/math/GLMUtils.h new file mode 100644 index 0000000..122ee7c --- /dev/null +++ b/src/utilities/math/GLMUtils.h @@ -0,0 +1,8 @@ +#pragma once +#include +#include + +glm::vec3 EigenToGLM(const Eigen::Vector3f& v); +Eigen::Vector3f GLMToEigen(const glm::vec3& v); +glm::quat EigenToGLM(const Eigen::Quaternionf& q); +Eigen::Quaternionf GLMToEigen(const glm::quat& q); diff --git a/src/utilities/math/MathUtils.cpp b/src/utilities/math/MathUtils.cpp index fa963f7..db8d5a7 100644 --- a/src/utilities/math/MathUtils.cpp +++ b/src/utilities/math/MathUtils.cpp @@ -82,23 +82,3 @@ ImVec2 NDCCoordsToImGui(const Eigen::Vector2f& coords) return { (coords.x() + 1.0f) * 0.5f * io.DisplaySize.x, (1.0f - coords.y()) * 0.5f * io.DisplaySize.y }; } - -glm::vec3 EigenToGLM(const Eigen::Vector3f& v) -{ - return glm::vec3(v.x(), v.y(), v.z()); -} - -Eigen::Vector3f GLMToEigen(const glm::vec3& v) -{ - return Eigen::Vector3f(v.x, v.y, v.z); -} - -glm::quat EigenToGLM(const Eigen::Quaternionf& q) -{ - return glm::quat(q.w(), q.x(), q.y(), q.z()); -} - -Eigen::Quaternionf GLMToEigen(const glm::quat& q) -{ - return Eigen::Quaternionf(q.w, q.x, q.y, q.z); -} diff --git a/src/utilities/math/MathUtils.h b/src/utilities/math/MathUtils.h index 47d2c1b..a8bfb67 100644 --- a/src/utilities/math/MathUtils.h +++ b/src/utilities/math/MathUtils.h @@ -1,8 +1,6 @@ #pragma once #include "Ray.h" #include "Frustum.h" -#include -#include Eigen::Quaternionf EulerToQuat(const Eigen::Vector3f& vec); Eigen::Vector3f MatrixToEuler(const Eigen::Matrix3f& mat); @@ -17,8 +15,3 @@ Frustum ScreenRectToFrustum(const ImVec2& screenRect1, const ImVec2& screenRect2 Eigen::Vector2f ImGuiCoordsToNDC(const ImVec2& coords); ImVec2 NDCCoordsToImGui(const Eigen::Vector2f& coords); - -glm::vec3 EigenToGLM(const Eigen::Vector3f& v); -Eigen::Vector3f GLMToEigen(const glm::vec3& v); -glm::quat EigenToGLM(const Eigen::Quaternionf& q); -Eigen::Quaternionf GLMToEigen(const glm::quat& q); From 9dc4e2312b5ea03eecc6e1564ea0a9f6360bbdfc Mon Sep 17 00:00:00 2001 From: Ashrindy Date: Mon, 13 Oct 2025 16:41:11 +0200 Subject: [PATCH 09/13] uvanim editor wip, effdb editor --- src/CMakeLists.txt | 4 + src/ui/common/editors/ParticleLocation.cpp | 95 +++++++++++++++++++ src/ui/common/editors/ParticleLocation.h | 5 + .../common/viewport/InteractiveViewport.cpp | 4 +- src/ui/common/viewport/Viewport.cpp | 38 ++++++++ src/ui/common/viewport/Viewport.h | 4 + src/ui/resources/ResourceBrowser.cpp | 6 ++ .../resources/editors/ResAnimTexSrtEditor.cpp | 76 +++++++++++++++ .../resources/editors/ResAnimTexSrtEditor.h | 17 ++++ .../editors/ResParticleLocationEditor.cpp | 21 ++++ .../editors/ResParticleLocationEditor.h | 10 ++ 11 files changed, 278 insertions(+), 2 deletions(-) create mode 100644 src/ui/common/editors/ParticleLocation.cpp create mode 100644 src/ui/common/editors/ParticleLocation.h create mode 100644 src/ui/resources/editors/ResAnimTexSrtEditor.cpp create mode 100644 src/ui/resources/editors/ResAnimTexSrtEditor.h create mode 100644 src/ui/resources/editors/ResParticleLocationEditor.cpp create mode 100644 src/ui/resources/editors/ResParticleLocationEditor.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7b4abac..b879baf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -40,6 +40,7 @@ target_sources(${DEVTOOLS_TARGET} ui/common/editors/Pointcloud.cpp ui/common/editors/Resources.cpp ui/common/editors/HsmBase.cpp + ui/common/editors/ParticleLocation.cpp ui/common/viewers/Basic.cpp ui/common/viewers/RflDiff.cpp ui/common/inputs/Basic.cpp @@ -123,6 +124,7 @@ target_sources(${DEVTOOLS_TARGET} ui/common/editors/Pointcloud.h ui/common/editors/Resources.h ui/common/editors/HsmBase.h + ui/common/editors/ParticleLocation.h ui/common/viewers/Basic.h ui/common/viewers/RflDiff.h ui/common/inputs/Basic.h @@ -303,6 +305,8 @@ if(${DEVTOOLS_TARGET_SDK} STREQUAL "rangers") ResMirageLightEditor ResVibrationEditor ResModelEditor + ResAnimTexSrtEditor + ResParticleLocationEditor ) set(DEVTOOLS_FEATURE_CORE_SERVICE_INSPECTORS MemoryInspector diff --git a/src/ui/common/editors/ParticleLocation.cpp b/src/ui/common/editors/ParticleLocation.cpp new file mode 100644 index 0000000..87f7781 --- /dev/null +++ b/src/ui/common/editors/ParticleLocation.cpp @@ -0,0 +1,95 @@ +#include "ParticleLocation.h" +#ifndef DEVTOOLS_TARGET_SDK_wars +#include + +bool Editor(const char* name, hh::fnd::ManagedResource* resource, ucsl::resources::effdb::v100::Particle& data); +bool Editor(const char* name, hh::fnd::ManagedResource* resource, const char*& data); +bool Editor(const char* name, hh::fnd::ManagedResource* resource, ucsl::resources::effdb::v100::Binding& data); + +#include +#include +#include + +using namespace hh::animeff; +using namespace ucsl::resources::effdb::v100; + +bool Editor(const char* name, hh::fnd::ManagedResource* resource, Particle& data) { + bool changed{}; + + if (ImGui::TreeNode(name)) { + changed |= Editor("Attached To Bone", data.attachedToBone); + changed |= CheckboxFlags("Ignore Relative Position", data.flags, Particle::Flag::IGNORE_RELATIVE_POSITION); + changed |= CheckboxFlags("Use Position", data.flags, Particle::Flag::USE_POSITION); + changed |= CheckboxFlags("Use Rotation", data.flags, Particle::Flag::USE_ROTATION); + changed |= CheckboxFlags("Use Scale", data.flags, Particle::Flag::USE_SCALE); + changed |= InputText("Particle Name", data.particleName, resource); + changed |= InputText("Bone Name", data.boneName, resource); + changed |= Editor("Position", data.position); + changed |= Editor("Rotation", data.rotation); + changed |= Editor("Scale", data.scale); + + ImGui::TreePop(); + } + + return changed; +} + +bool Editor(const char* name, hh::fnd::ManagedResource* resource, const char*& data) { + bool changed{}; + + changed |= InputText(name, data, resource); + + return changed; +} + +void InitParticle(hh::fnd::ManagedResource* resource, Particle& item) { + item = {}; + item.boneName = "BoneName"; + item.particleName = "ParticleName"; + item.rotation = { 0, 0, 0, 1 }; + item.scale = { 1, 1, 1 }; +} + +void DeinitParticle(hh::fnd::ManagedResource* resource, Particle& item) { } + +void InitSoundName(hh::fnd::ManagedResource* resource, const char*& item) { + item = {}; + item = "SoundName"; +} + +void DeinitSoundName(hh::fnd::ManagedResource* resource, const char*& item) {} + +bool Editor(const char* name, hh::fnd::ManagedResource* resource, Binding& data) { + bool changed{}; + + if (ImGui::TreeNode(name)) { + changed |= InputText("Clip Name", data.clipName, resource); + + resources::ManagedCArray particles{ resource, data.particles, data.particleCount }; + changed |= Editor("Particles", resource, particles, InitParticle, DeinitParticle); + + resources::ManagedCArray soundNames{ resource, data.soundNames, data.soundNameCount }; + changed |= Editor("Sound Names", resource, soundNames, InitSoundName, DeinitSoundName); + + ImGui::TreePop(); + } + + return changed; +} + +void InitBinding(hh::fnd::ManagedResource* resource, Binding& item) { + item = {}; + item.clipName = "ClipName"; +} + +void DeinitBinding(hh::fnd::ManagedResource* resource, Binding& item) {} + +bool Editor(EffdbData& data, ResParticleLocation* resource) { + bool changed{}; + + resources::ManagedCArray bindings{ resource, data.bindings, data.bindingCount }; + changed |= Editor("Bindings", resource, bindings, InitBinding, DeinitBinding); + + return changed; +} +#endif diff --git a/src/ui/common/editors/ParticleLocation.h b/src/ui/common/editors/ParticleLocation.h new file mode 100644 index 0000000..5b6ce66 --- /dev/null +++ b/src/ui/common/editors/ParticleLocation.h @@ -0,0 +1,5 @@ +#pragma once + +#ifndef DEVTOOLS_TARGET_SDK_wars +bool Editor(ucsl::resources::effdb::v100::EffdbData& data, hh::animeff::ResParticleLocation* resource); +#endif diff --git a/src/ui/common/viewport/InteractiveViewport.cpp b/src/ui/common/viewport/InteractiveViewport.cpp index 986fe98..993eb76 100644 --- a/src/ui/common/viewport/InteractiveViewport.cpp +++ b/src/ui/common/viewport/InteractiveViewport.cpp @@ -53,6 +53,6 @@ void InteractiveViewport::UpdateMatrix(const csl::math::Vector3& position, const auto& viewMatrix = viewportData.viewMatrix; viewMatrix.linear() = rotation.toRotationMatrix(); viewMatrix.translation() = position; - viewportData.inverseViewMatrix = viewMatrix.inverse(); - UpdateViewportData(); + SetViewMatrix(viewMatrix); + UpdateViewMatrix(); } diff --git a/src/ui/common/viewport/Viewport.cpp b/src/ui/common/viewport/Viewport.cpp index 760a1dc..e230c78 100644 --- a/src/ui/common/viewport/Viewport.cpp +++ b/src/ui/common/viewport/Viewport.cpp @@ -3,6 +3,7 @@ using namespace hh::gfx; using namespace hh::needle; +using namespace hh::gfnd; Viewport::~Viewport() { if (renderTexture) { @@ -58,7 +59,25 @@ void Viewport::Setup(const Description& desc) { }; renderTexture = reinterpret_cast(renderEngine->CreateRenderTextureHandle(rtCreateInfo, pAllocator)); + auto* resMgr = hh::fnd::ResourceManager::GetInstance(); + auto* shLightField = resMgr->GetResource("test_lf"); + SupportFX::LightFieldDescription supportFxLfDesc{}; + supportFxLfDesc.binaryData = shLightField->binaryData; + supportFxLfDesc.textures = &shLightField->textures; + supportFx->SetupLightField(supportFxLfDesc, name.c_str()); + + auto* renderingEngine = renderMgr->implementation->renderingEngine; + auto* iblComponent = (IBLComponent*)renderingEngine->GetComponentByHash(csl::ut::HashString("IBLComponent")); + + auto* iblTexture = resMgr->GetResource("defaultibl_test"); + auto* texture = iblTexture->GetTexture(); + iblComponent->SetIBLTexture(&texture, name.c_str()); + viewportData.Reset(); + + viewportData.viewMatrix = csl::math::Matrix34::Identity(); + viewportData.inverseViewMatrix = viewportData.viewMatrix.inverse(); + SetCameraPositionAndTarget({}, {}); float resF[2] = {desc.resolution[0], desc.resolution[1]}; @@ -206,3 +225,22 @@ void Viewport::AddModel(hh::gfx::ResModel* resModel, bool setToAabb) { AddModel(modelInstance, setToAabb); } + +void Viewport::RemoveModel(hh::needle::PBRModelInstance* modelInstance) +{ + size_t modelIdx = models.find(modelInstance); + if (modelIdx == -1) return; + + models.remove(modelIdx); + auto* world{ renderTexture->GetWorldByIdx(0) }; + world->Remove(modelInstance); +} + +void Viewport::ClearModels() { + auto* world{ renderTexture->GetWorldByIdx(0) }; + for (auto* model : models) + world->Remove(model); + + models.clear(); +} + diff --git a/src/ui/common/viewport/Viewport.h b/src/ui/common/viewport/Viewport.h index ef56291..12e30e6 100644 --- a/src/ui/common/viewport/Viewport.h +++ b/src/ui/common/viewport/Viewport.h @@ -41,6 +41,10 @@ class Viewport : public CompatibleObject { void AddModel(hh::needle::PBRModelInstance* modelInstance, bool setToAabb = false); void AddModel(hh::gfx::ResModel* resModel, bool setToAabb = false); + void RemoveModel(hh::needle::PBRModelInstance* modelInstance); + + void ClearModels(); + protected: hh::needle::Texture* GetTexture() const; ImTextureID GetTextureID() const; diff --git a/src/ui/resources/ResourceBrowser.cpp b/src/ui/resources/ResourceBrowser.cpp index b92e755..5129481 100644 --- a/src/ui/resources/ResourceBrowser.cpp +++ b/src/ui/resources/ResourceBrowser.cpp @@ -8,11 +8,13 @@ #include "editors/ResMirageLightEditor.h" #include "editors/ResVibrationEditor.h" #include "editors/ResModelEditor.h" +#include "editors/ResAnimTexSrtEditor.h" #endif //#include "editors/ResObjectWorldEditor.h" #include "editors/ResMaterialEditor.h" #ifndef DEVTOOLS_TARGET_SDK_wars #include "editors/ResPhysicalSkeletonEditor.h" +#include "editors/ResParticleLocationEditor.h" #endif #include #include @@ -233,6 +235,8 @@ void ResourceBrowser::RenderResource(ManagedResource* resource) { ResMaterialEditor::Create(Desktop::instance->GetAllocator(), static_cast(resource)); else if (typeInfo == hh::pba::ResPhysicalSkeleton::GetTypeInfo()) ResPhysicalSkeletonEditor::Create(Desktop::instance->GetAllocator(), static_cast(resource)); + else if (typeInfo == hh::animeff::ResParticleLocation::GetTypeInfo()) + ResParticleLocationEditor::Create(Desktop::instance->GetAllocator(), static_cast(resource)); #endif #ifdef DEVTOOLS_TARGET_SDK_rangers else if (typeInfo == app::ResGismoConfigDesign::GetTypeInfo()) @@ -245,6 +249,8 @@ void ResourceBrowser::RenderResource(ManagedResource* resource) { ResVibrationEditor::Create(Desktop::instance->GetAllocator(), static_cast(resource)); else if (typeInfo == hh::gfx::ResModel::GetTypeInfo()) ResModelEditor::Create(Desktop::instance->GetAllocator(), static_cast(resource)); + /*else if (typeInfo == hh::gfx::ResAnimTexSrt::GetTypeInfo()) + ResAnimTexSrtEditor::Create(Desktop::instance->GetAllocator(), static_cast(resource));*/ #endif } diff --git a/src/ui/resources/editors/ResAnimTexSrtEditor.cpp b/src/ui/resources/editors/ResAnimTexSrtEditor.cpp new file mode 100644 index 0000000..ec14924 --- /dev/null +++ b/src/ui/resources/editors/ResAnimTexSrtEditor.cpp @@ -0,0 +1,76 @@ +#include "ResAnimTexSrtEditor.h" +#include + +using namespace hh::gfx; +using namespace hh::needle; +using namespace hh::fnd; + +void ResAnimTexSrtEditor::SetModel(hh::needle::PBRModelInstance* model) { + previewModel = model; + + if (blender) + previewModel->SetTexSrtBlender(blender->needleBlender); + + if (!viewport) return; + + viewport->ClearModels(); + viewport->AddModel(model, true); +} + +void ResAnimTexSrtEditor::SetModel(hh::gfx::ResModel* model) { + auto* renderMgr = reinterpret_cast(hh::gfnd::RenderManagerBase::GetInstance()); + hh::gfx::RenderManager::SModelCreationInfo createInfo{ pAllocator }; + createInfo.meshResource = model->GetMeshResource(); + + Model* mdl; + renderMgr->CreateModelFromResource2(&mdl, createInfo); + auto* modelInstance = static_cast(renderMgr->CreateModelInstance(mdl, createInfo)); + + SetModel(modelInstance); +} + +ResAnimTexSrtEditor::ResAnimTexSrtEditor(csl::fnd::IAllocator* allocator, hh::gfx::ResAnimTexSrt* resource) : StandaloneWindow{ allocator }, resource{ resource } { + char namebuf[500]; + snprintf(namebuf, sizeof(namebuf), "%s - %s @ 0x%zx (file mapped @ 0x%zx)", resource->GetName(), resource->GetClass().pName, (size_t)&resource, (size_t)resource); + SetTitle(namebuf); + + blender = new (allocator) TexSrtBlenderHH{ allocator }; + TexSrtBlenderDesc blenderDesc{ .animationCount = 1 }; + blender->Initialize(blenderDesc); + blender->needleBlender->controls[0] = hh::needle::AnimTexSrtControl::Create(resource->resource); + + static const char* nameTemplate = "UVAnimViewport"; + static const size_t nameTemplateLen = strlen(nameTemplate); + + const char* resName = resource->name.c_str(); + const size_t resNameLen = strlen(resName); + + const size_t nameLen = resNameLen + nameTemplateLen + 1; + char* nameRaw = new (GetAllocator()) char[nameLen]; + snprintf(nameRaw, nameLen, "%s%s", resName, nameTemplate); + + viewport = new (allocator) Viewport{ allocator }; + viewport->Setup({ .name = nameRaw }); + + GetAllocator()->Free(nameRaw); +} + +ResAnimTexSrtEditor* ResAnimTexSrtEditor::Create(csl::fnd::IAllocator* allocator, hh::gfx::ResAnimTexSrt* resource) { + return new (allocator) ResAnimTexSrtEditor{ allocator, resource }; +} + +// TODO: Requires a different way of handling the UVAnimation, or a manual update function +void ResAnimTexSrtEditor::RenderContents() { + if (ImGui::BeginDragDropTargetCustom(ImGui::GetCurrentWindow()->ContentRegionRect, ImGui::GetCurrentWindow()->ID)) { + if (auto* payload = ImGui::AcceptDragDropPayload("Resource")) { + auto* res = *static_cast(payload->Data); + const ResourceTypeInfo* typeInfo = &res->GetClass(); + + if (typeInfo == ResModel::GetTypeInfo()) + SetModel(reinterpret_cast(res)); + } + ImGui::EndDragDropTarget(); + } + + viewport->Render(); +} diff --git a/src/ui/resources/editors/ResAnimTexSrtEditor.h b/src/ui/resources/editors/ResAnimTexSrtEditor.h new file mode 100644 index 0000000..0f5473f --- /dev/null +++ b/src/ui/resources/editors/ResAnimTexSrtEditor.h @@ -0,0 +1,17 @@ +#pragma once +#include +#include + +class ResAnimTexSrtEditor : public StandaloneWindow { + hh::fnd::Reference resource; + hh::fnd::Reference viewport; + hh::needle::PBRModelInstance* previewModel; + hh::fnd::Reference blender; + + void SetModel(hh::needle::PBRModelInstance* model); + void SetModel(hh::gfx::ResModel* model); +public: + ResAnimTexSrtEditor(csl::fnd::IAllocator* allocator, hh::gfx::ResAnimTexSrt* resource); + static ResAnimTexSrtEditor* Create(csl::fnd::IAllocator* allocator, hh::gfx::ResAnimTexSrt* resource); + virtual void RenderContents(); +}; diff --git a/src/ui/resources/editors/ResParticleLocationEditor.cpp b/src/ui/resources/editors/ResParticleLocationEditor.cpp new file mode 100644 index 0000000..e053c21 --- /dev/null +++ b/src/ui/resources/editors/ResParticleLocationEditor.cpp @@ -0,0 +1,21 @@ +#include "ResParticleLocationEditor.h" +#include + +ResParticleLocationEditor::ResParticleLocationEditor(csl::fnd::IAllocator* allocator, hh::animeff::ResParticleLocation* resource) : StandaloneWindow{ allocator }, resource{ resource } { + char namebuf[500]; + snprintf(namebuf, sizeof(namebuf), "%s - %s @ 0x%zx (file mapped @ 0x%zx)", resource->GetName(), resource->GetClass().pName, (size_t)&resource, (size_t)resource->unpackedBinaryData); + SetTitle(namebuf); +} + +ResParticleLocationEditor* ResParticleLocationEditor::Create(csl::fnd::IAllocator* allocator, hh::animeff::ResParticleLocation* resource) { + return new (allocator) ResParticleLocationEditor{ allocator, resource }; +} + +void ResParticleLocationEditor::RenderContents() { + auto* effdbData = static_cast(resource->unpackedBinaryData); + + if (Editor(*effdbData, resource)) { + resource->bindings.clear(); + resource->Load(effdbData, 0); + } +} diff --git a/src/ui/resources/editors/ResParticleLocationEditor.h b/src/ui/resources/editors/ResParticleLocationEditor.h new file mode 100644 index 0000000..bca1f7c --- /dev/null +++ b/src/ui/resources/editors/ResParticleLocationEditor.h @@ -0,0 +1,10 @@ +#pragma once +#include + +class ResParticleLocationEditor : public StandaloneWindow { + hh::fnd::Reference resource; +public: + ResParticleLocationEditor(csl::fnd::IAllocator* allocator, hh::animeff::ResParticleLocation* resource); + virtual void RenderContents(); + static ResParticleLocationEditor* Create(csl::fnd::IAllocator* allocator, hh::animeff::ResParticleLocation* resource); +}; From 2a1ac1f165ee61ed11e22a0752de799b65536eb6 Mon Sep 17 00:00:00 2001 From: Ashrindy Date: Mon, 13 Oct 2025 16:53:19 +0200 Subject: [PATCH 10/13] remove viewport --- .gitmodules | 3 - CMakeLists.txt | 3 +- src/CMakeLists.txt | 8 - .../common/viewport/InteractiveViewport.cpp | 58 ----- src/ui/common/viewport/InteractiveViewport.h | 14 - src/ui/common/viewport/Scene.cpp | 1 - src/ui/common/viewport/Scene.h | 7 - src/ui/common/viewport/Viewport.cpp | 246 ------------------ src/ui/common/viewport/Viewport.h | 51 ---- src/ui/resources/ResourceBrowser.cpp | 6 - .../resources/editors/ResAnimTexSrtEditor.cpp | 76 ------ .../resources/editors/ResAnimTexSrtEditor.h | 17 -- src/ui/resources/editors/ResModelEditor.cpp | 37 --- src/ui/resources/editors/ResModelEditor.h | 12 - vendor/imviewguizmo/CMakeLists.txt | 9 - vendor/imviewguizmo/ImViewGuizmo | 1 - 16 files changed, 1 insertion(+), 548 deletions(-) delete mode 100644 src/ui/common/viewport/InteractiveViewport.cpp delete mode 100644 src/ui/common/viewport/InteractiveViewport.h delete mode 100644 src/ui/common/viewport/Scene.cpp delete mode 100644 src/ui/common/viewport/Scene.h delete mode 100644 src/ui/common/viewport/Viewport.cpp delete mode 100644 src/ui/common/viewport/Viewport.h delete mode 100644 src/ui/resources/editors/ResAnimTexSrtEditor.cpp delete mode 100644 src/ui/resources/editors/ResAnimTexSrtEditor.h delete mode 100644 src/ui/resources/editors/ResModelEditor.cpp delete mode 100644 src/ui/resources/editors/ResModelEditor.h delete mode 100644 vendor/imviewguizmo/CMakeLists.txt delete mode 160000 vendor/imviewguizmo/ImViewGuizmo diff --git a/.gitmodules b/.gitmodules index 876dfec..e548d03 100644 --- a/.gitmodules +++ b/.gitmodules @@ -34,6 +34,3 @@ [submodule "vendor/uwebsockets/uWebSockets"] path = vendor/uwebsockets/uWebSockets url = https://github.com/uNetworking/uWebSockets.git -[submodule "vendor/imviewguizmo/ImViewGuizmo"] - path = vendor/imviewguizmo/ImViewGuizmo - url = https://github.com/Ka1serM/ImViewGuizmo.git diff --git a/CMakeLists.txt b/CMakeLists.txt index d234555..99d2041 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,8 +21,7 @@ include(FetchContent) FetchContent_Declare(OGDF GIT_REPOSITORY https://github.com/ogdf/ogdf.git GIT_TAG 8a7b22712929f1cd48c4ed701c52b0c0a69c01c8 EXCLUDE_FROM_ALL FIND_PACKAGE_ARGS) FetchContent_Declare(rip GIT_REPOSITORY https://github.com/angryzor/rip.git GIT_TAG v1.0.34 EXCLUDE_FROM_ALL FIND_PACKAGE_ARGS 1.0.34) FetchContent_Declare(dieventlib GIT_REPOSITORY https://github.com/Ashrindy/DiEventLibCPP.git) -FetchContent_Declare(glm GIT_REPOSITORY https://github.com/g-truc/glm.git) -FetchContent_MakeAvailable(ogdf rip dieventlib glm) +FetchContent_MakeAvailable(ogdf rip dieventlib) add_subdirectory(vendor EXCLUDE_FROM_ALL) # Settings for target sdks diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b879baf..6d88827 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -45,9 +45,6 @@ target_sources(${DEVTOOLS_TARGET} ui/common/viewers/RflDiff.cpp ui/common/inputs/Basic.cpp ui/common/overlays/Tag.cpp - ui/common/viewport/Viewport.cpp - ui/common/viewport/Scene.cpp - ui/common/viewport/InteractiveViewport.cpp ui/common/icons.cpp ui/common/StandaloneWindow.cpp ui/common/stb_image.cpp @@ -130,9 +127,6 @@ target_sources(${DEVTOOLS_TARGET} ui/common/inputs/Basic.h ui/common/inputs/Needle.h ui/common/overlays/Tag.h - ui/common/viewport/Viewport.h - ui/common/viewport/Scene.h - ui/common/viewport/InteractiveViewport.h ui/common/icons.h ui/common/NodeEditor.h ui/common/StandaloneWindow.h @@ -304,8 +298,6 @@ if(${DEVTOOLS_TARGET_SDK} STREQUAL "rangers") ResGismoConfigPlanEditor ResMirageLightEditor ResVibrationEditor - ResModelEditor - ResAnimTexSrtEditor ResParticleLocationEditor ) set(DEVTOOLS_FEATURE_CORE_SERVICE_INSPECTORS diff --git a/src/ui/common/viewport/InteractiveViewport.cpp b/src/ui/common/viewport/InteractiveViewport.cpp deleted file mode 100644 index 993eb76..0000000 --- a/src/ui/common/viewport/InteractiveViewport.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "InteractiveViewport.h" -#include -#define IMVIEWGUIZMO_IMPLEMENTATION -#include - -InteractiveViewport::InteractiveViewport(csl::fnd::IAllocator* allocator) : Viewport{ allocator } {} - -bool InteractiveViewport::RotateControl(csl::math::Vector3& position, csl::math::Quaternion& rotation) const { - glm::vec3 camPos = EigenToGLM(position); - glm::quat camRot = EigenToGLM(rotation); - - const ImVec2 guizmoHRes = ImVec2{ 80, 80 } * ImViewGuizmo::GetStyle().scale; - const ImVec2 guizmoRes = guizmoHRes * 2; - - ImVec2 guizmoPos = - ImGui::GetWindowContentRegionMin() + ImGui::GetWindowPos() + // base position - ImVec2{ viewportData.viewportDimensions.resX - guizmoHRes.x, guizmoHRes.y }; // offset position - - ImGui::Dummy(guizmoRes); - - auto id = ImGui::GetID("hover"); - - if (ImGui::ItemHoverable(ImRect(guizmoPos - guizmoHRes, guizmoPos + guizmoHRes), id, ImGuiItemFlags_None)) { - if (ImGui::IsMouseDown(ImGuiMouseButton_Left) && ImGui::IsMouseHoveringRect(guizmoPos - guizmoHRes, guizmoPos + guizmoHRes)) - ImGui::SetActiveID(id, ImGui::GetCurrentWindow()); - if (ImGui::IsMouseReleased(ImGuiMouseButton_Left) && ImGui::IsMouseHoveringRect(guizmoPos - guizmoHRes, guizmoPos + guizmoHRes)) - ImGui::ClearActiveID(); - } - - bool changed = false; - - if (changed |= ImViewGuizmo::Rotate(camPos, camRot, guizmoPos, GetZoomToAABB(), controlSpeed)) { - position = GLMToEigen(camPos); - rotation = GLMToEigen(camRot); - } - - return changed; -} - -void InteractiveViewport::Render() { - Viewport::Render(); - - auto& viewMatrix = viewportData.viewMatrix; - - csl::math::Vector3 camPos{ viewMatrix.translation() }; - csl::math::Quaternion camRot{ viewMatrix.rotation() }; - - if (RotateControl(camPos, camRot)) - UpdateMatrix(camPos, camRot); -} - -void InteractiveViewport::UpdateMatrix(const csl::math::Vector3& position, const csl::math::Quaternion& rotation) { - auto& viewMatrix = viewportData.viewMatrix; - viewMatrix.linear() = rotation.toRotationMatrix(); - viewMatrix.translation() = position; - SetViewMatrix(viewMatrix); - UpdateViewMatrix(); -} diff --git a/src/ui/common/viewport/InteractiveViewport.h b/src/ui/common/viewport/InteractiveViewport.h deleted file mode 100644 index 0a6337a..0000000 --- a/src/ui/common/viewport/InteractiveViewport.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include -#include - -class InteractiveViewport : public Viewport { -public: - float controlSpeed{ 0.015f }; - - InteractiveViewport(csl::fnd::IAllocator* allocator); - - bool RotateControl(csl::math::Vector3& position, csl::math::Quaternion& rotation) const; - virtual void Render() override; - void UpdateMatrix(const csl::math::Vector3& position, const csl::math::Quaternion& rotation); -}; diff --git a/src/ui/common/viewport/Scene.cpp b/src/ui/common/viewport/Scene.cpp deleted file mode 100644 index 333cc85..0000000 --- a/src/ui/common/viewport/Scene.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "Scene.h" diff --git a/src/ui/common/viewport/Scene.h b/src/ui/common/viewport/Scene.h deleted file mode 100644 index 2509437..0000000 --- a/src/ui/common/viewport/Scene.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once -#include - -class Scene : public CompatibleObject { -public: - -}; diff --git a/src/ui/common/viewport/Viewport.cpp b/src/ui/common/viewport/Viewport.cpp deleted file mode 100644 index e230c78..0000000 --- a/src/ui/common/viewport/Viewport.cpp +++ /dev/null @@ -1,246 +0,0 @@ -#include "Viewport.h" -#include - -using namespace hh::gfx; -using namespace hh::needle; -using namespace hh::gfnd; - -Viewport::~Viewport() { - if (renderTexture) { - auto* renderMgr = reinterpret_cast(hh::gfnd::RenderManagerBase::GetInstance()); - auto* renderEngine = renderMgr->GetNeedleResourceDevice(); - - renderEngine->DestroyRenderTextureHandle(renderTexture); - } -} - -Viewport::Viewport(csl::fnd::IAllocator* allocator) : CompatibleObject{ allocator }, models { GetAllocator() }, name{ GetAllocator() } {} - -void Viewport::Render() -{ - if (auto* texture = GetTextureID()) { - ImVec2 pos = ImGui::GetCursorScreenPos(); - - auto& dimensions = viewportData.viewportDimensions; - ImVec2 size{ static_cast(dimensions.resX), static_cast(dimensions.resY) }; - - ImGui::GetWindowDrawList()->AddRectFilled( - pos, - ImVec2(pos.x + size.x, pos.y + size.y), - IM_COL32(0, 0, 0, 255) - ); - - ImGui::Image(texture, size); - } -} - -void Viewport::Setup(const Description& desc) { - auto* renderMgr = reinterpret_cast(hh::gfnd::RenderManagerBase::GetInstance()); - auto* renderEngine = renderMgr->GetNeedleResourceDevice(); - auto* supportFx = renderEngine->GetSupportFX(); - - RenderTextureCreateArgs::TextureSettings textureSettings{ - .format = SurfaceFormat::R8G8B8A8, - .mipLevels = 1 - }; - - name.Set(desc.name); - - RenderTextureCreateArgs rtCreateInfo{ - .width = desc.resolution[0], - .height = desc.resolution[1], - .flags = RenderTextureCreateArgs::UNK2, - .clearedTextureCount = 1, - .textureSettings = &textureSettings, - .allocator = GetAllocator(), - .name = name.c_str(), - .sceneName = name.c_str(), - .autoCreatePipeline = true - }; - renderTexture = reinterpret_cast(renderEngine->CreateRenderTextureHandle(rtCreateInfo, pAllocator)); - - auto* resMgr = hh::fnd::ResourceManager::GetInstance(); - auto* shLightField = resMgr->GetResource("test_lf"); - SupportFX::LightFieldDescription supportFxLfDesc{}; - supportFxLfDesc.binaryData = shLightField->binaryData; - supportFxLfDesc.textures = &shLightField->textures; - supportFx->SetupLightField(supportFxLfDesc, name.c_str()); - - auto* renderingEngine = renderMgr->implementation->renderingEngine; - auto* iblComponent = (IBLComponent*)renderingEngine->GetComponentByHash(csl::ut::HashString("IBLComponent")); - - auto* iblTexture = resMgr->GetResource("defaultibl_test"); - auto* texture = iblTexture->GetTexture(); - iblComponent->SetIBLTexture(&texture, name.c_str()); - - viewportData.Reset(); - - viewportData.viewMatrix = csl::math::Matrix34::Identity(); - viewportData.inverseViewMatrix = viewportData.viewMatrix.inverse(); - - SetCameraPositionAndTarget({}, {}); - - float resF[2] = {desc.resolution[0], desc.resolution[1]}; - viewportData.SetDimensions({ - .resX = resF[0], - .resY = resF[1], - .renderResX = resF[0], - .renderResY = resF[1] - }); - SetCameraFOV(desc.fov); - - UpdateViewportData(); - - if (desc.modelInstance) - AddModel(desc.modelInstance, desc.setToAabb); -} - -void Viewport::UpdateViewportData() { - renderTexture->SetCameraParameter(viewportData.viewMatrix, viewportData.projMatrix); -} - -void Viewport::SetViewMatrix(const csl::math::Matrix34& mat) { - viewportData.viewMatrix = mat; - viewportData.inverseViewMatrix = viewportData.viewMatrix.inverse(); -} - -void Viewport::UpdateViewMatrix() { - auto mat = viewportData.viewMatrix; - csl::math::Vector3 camPos{ mat.translation() }; - SetCameraPositionAndTarget(camPos, viewportData.lookAtPos); - UpdateViewportData(); -} - -float Viewport::GetZoomToAABB(const csl::geom::Aabb& aabb) const { - csl::math::Vector3 bboxExtent{ aabb.Extent() }; - float maxDimension{ bboxExtent.norm() }; - - return maxDimension * 2.5f; -} - -float Viewport::GetZoomToAABB(hh::needle::PBRModelInstance* modelAabb) const { - csl::geom::Aabb bbox; - modelAabb->GetModelSpaceAabb(&bbox); - return GetZoomToAABB(bbox); -} - -float Viewport::GetZoomToAABB() const { - if (models.empty()) return 2.5f; - - float lastDistance{ GetZoomToAABB(models[0]) }; - - if (models.size()) return lastDistance; - - for (auto* model : models) { - if (model == models[0]) continue; - - float distance{ GetZoomToAABB(model) }; - if (distance > lastDistance) - lastDistance = distance; - } - - return lastDistance; -} - -void Viewport::SetCameraToAABB(const csl::geom::Aabb& aabb) { - float distance{ GetZoomToAABB(aabb) }; - - csl::math::Vector3 direction{ 1, 1, 1 }; - direction.normalize(); - - csl::math::Vector3 bboxCenter{ aabb.Center() }; - csl::math::Vector3 camPos{ bboxCenter + direction * distance }; - csl::math::Vector3 camTargetPos{ bboxCenter }; - - SetCameraPositionAndTarget(camPos, camTargetPos); - UpdateViewportData(); -} - -void Viewport::SetCameraToAABB(hh::needle::PBRModelInstance* modelAabb) { - csl::geom::Aabb bbox; - modelAabb->GetModelSpaceAabb(&bbox); - SetCameraToAABB(bbox); -} - -void Viewport::SetCameraPositionAndTarget(const csl::math::Vector3& position, const csl::math::Vector3& target) { - SetViewMatrix(csl::math::Matrix34LookAt(position, csl::math::Vector3::UnitY(), target)); - viewportData.lookAtPos = target; -} - -void Viewport::SetCameraPosition(const csl::math::Vector3& position) { - SetViewMatrix(csl::math::Matrix34LookAt(position, csl::math::Vector3::UnitY(), viewportData.lookAtPos)); -} - -void Viewport::SetCameraTarget(const csl::math::Vector3& target) { - auto& mat{ viewportData.viewMatrix }; - csl::math::Vector3 camPos{ mat.translation() }; - SetViewMatrix(csl::math::Matrix34LookAt(camPos, csl::math::Vector3::UnitY(), target)); - viewportData.lookAtPos = target; -} - -void Viewport::SetCameraFOV(const float fov) { - auto& dimensions{ viewportData.viewportDimensions }; - - float nearZ{ .1f }; - float farZ{ 10000 }; - viewportData.GetClipPlanes(&nearZ, &farZ); - - viewportData.SetPerspectiveProjectionMatrix( - fov, - dimensions.resX / dimensions.resY, - nearZ, - farZ - ); -} - -hh::needle::Texture* Viewport::GetTexture() const { - if (!renderTexture) return nullptr; - - return renderTexture->GetTexture(0); -} - -ImTextureID Viewport::GetTextureID() const { - auto* texture{ GetTexture() }; - return texture == nullptr ? nullptr : GetTextureIDFromMIRAGETexture(texture); -} - -void Viewport::AddModel(hh::needle::PBRModelInstance* modelInstance, bool setToAabb) { - models.push_back(modelInstance); - auto* world{ renderTexture->GetWorldByIdx(0) }; - auto* entryLink{ world->GetReferWorld() }; - world->AddModelInstanceNode(modelInstance, entryLink, true, -1, NEEDLE_RESOURCE_MODEL_INSTANCE); - - if (setToAabb) - SetCameraToAABB(modelInstance); -} - -void Viewport::AddModel(hh::gfx::ResModel* resModel, bool setToAabb) { - auto* renderMgr = reinterpret_cast(hh::gfnd::RenderManagerBase::GetInstance()); - hh::gfx::RenderManager::SModelCreationInfo createInfo{ pAllocator }; - createInfo.meshResource = resModel->GetMeshResource(); - - Model* mdl; - renderMgr->CreateModelFromResource2(&mdl, createInfo); - auto* modelInstance = static_cast(renderMgr->CreateModelInstance(mdl, createInfo)); - - AddModel(modelInstance, setToAabb); -} - -void Viewport::RemoveModel(hh::needle::PBRModelInstance* modelInstance) -{ - size_t modelIdx = models.find(modelInstance); - if (modelIdx == -1) return; - - models.remove(modelIdx); - auto* world{ renderTexture->GetWorldByIdx(0) }; - world->Remove(modelInstance); -} - -void Viewport::ClearModels() { - auto* world{ renderTexture->GetWorldByIdx(0) }; - for (auto* model : models) - world->Remove(model); - - models.clear(); -} - diff --git a/src/ui/common/viewport/Viewport.h b/src/ui/common/viewport/Viewport.h deleted file mode 100644 index 12e30e6..0000000 --- a/src/ui/common/viewport/Viewport.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once -#include - -class Viewport : public CompatibleObject { -public: - struct Description { - unsigned int resolution[2]{ 1024, 1024 }; - hh::needle::PBRModelInstance* modelInstance; - const char* name{ "Viewport" }; - float fov{ 1.0476f }; - bool setToAabb{ false }; - }; - - csl::ut::MoveArray models; - hh::needle::RenderTextureHandle* renderTexture; - hh::gfnd::ViewportData viewportData{}; - csl::ut::VariableString name; - - virtual ~Viewport(); - Viewport(csl::fnd::IAllocator* allocator); - - virtual void Render(); - - void Setup(const Description& desc); - - void UpdateViewportData(); - void SetViewMatrix(const csl::math::Matrix34& mat); - void UpdateViewMatrix(); - - float GetZoomToAABB(const csl::geom::Aabb& aabb) const; - float GetZoomToAABB(hh::needle::PBRModelInstance* modelAabb) const; - float GetZoomToAABB() const; - - void SetCameraToAABB(const csl::geom::Aabb& aabb); - void SetCameraToAABB(hh::needle::PBRModelInstance* modelAabb); - void SetCameraPositionAndTarget(const csl::math::Vector3& position, const csl::math::Vector3& target); - void SetCameraPosition(const csl::math::Vector3& position); - void SetCameraTarget(const csl::math::Vector3& target); - void SetCameraFOV(const float fov); - - void AddModel(hh::needle::PBRModelInstance* modelInstance, bool setToAabb = false); - void AddModel(hh::gfx::ResModel* resModel, bool setToAabb = false); - - void RemoveModel(hh::needle::PBRModelInstance* modelInstance); - - void ClearModels(); - -protected: - hh::needle::Texture* GetTexture() const; - ImTextureID GetTextureID() const; -}; diff --git a/src/ui/resources/ResourceBrowser.cpp b/src/ui/resources/ResourceBrowser.cpp index 5129481..735650a 100644 --- a/src/ui/resources/ResourceBrowser.cpp +++ b/src/ui/resources/ResourceBrowser.cpp @@ -7,8 +7,6 @@ #include "editors/ResGismoConfigPlanEditor.h" #include "editors/ResMirageLightEditor.h" #include "editors/ResVibrationEditor.h" -#include "editors/ResModelEditor.h" -#include "editors/ResAnimTexSrtEditor.h" #endif //#include "editors/ResObjectWorldEditor.h" #include "editors/ResMaterialEditor.h" @@ -247,10 +245,6 @@ void ResourceBrowser::RenderResource(ManagedResource* resource) { ResMirageLightEditor::Create(Desktop::instance->GetAllocator(), static_cast(resource)); else if (typeInfo == hh::hid::ResVibration::GetTypeInfo()) ResVibrationEditor::Create(Desktop::instance->GetAllocator(), static_cast(resource)); - else if (typeInfo == hh::gfx::ResModel::GetTypeInfo()) - ResModelEditor::Create(Desktop::instance->GetAllocator(), static_cast(resource)); - /*else if (typeInfo == hh::gfx::ResAnimTexSrt::GetTypeInfo()) - ResAnimTexSrtEditor::Create(Desktop::instance->GetAllocator(), static_cast(resource));*/ #endif } diff --git a/src/ui/resources/editors/ResAnimTexSrtEditor.cpp b/src/ui/resources/editors/ResAnimTexSrtEditor.cpp deleted file mode 100644 index ec14924..0000000 --- a/src/ui/resources/editors/ResAnimTexSrtEditor.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "ResAnimTexSrtEditor.h" -#include - -using namespace hh::gfx; -using namespace hh::needle; -using namespace hh::fnd; - -void ResAnimTexSrtEditor::SetModel(hh::needle::PBRModelInstance* model) { - previewModel = model; - - if (blender) - previewModel->SetTexSrtBlender(blender->needleBlender); - - if (!viewport) return; - - viewport->ClearModels(); - viewport->AddModel(model, true); -} - -void ResAnimTexSrtEditor::SetModel(hh::gfx::ResModel* model) { - auto* renderMgr = reinterpret_cast(hh::gfnd::RenderManagerBase::GetInstance()); - hh::gfx::RenderManager::SModelCreationInfo createInfo{ pAllocator }; - createInfo.meshResource = model->GetMeshResource(); - - Model* mdl; - renderMgr->CreateModelFromResource2(&mdl, createInfo); - auto* modelInstance = static_cast(renderMgr->CreateModelInstance(mdl, createInfo)); - - SetModel(modelInstance); -} - -ResAnimTexSrtEditor::ResAnimTexSrtEditor(csl::fnd::IAllocator* allocator, hh::gfx::ResAnimTexSrt* resource) : StandaloneWindow{ allocator }, resource{ resource } { - char namebuf[500]; - snprintf(namebuf, sizeof(namebuf), "%s - %s @ 0x%zx (file mapped @ 0x%zx)", resource->GetName(), resource->GetClass().pName, (size_t)&resource, (size_t)resource); - SetTitle(namebuf); - - blender = new (allocator) TexSrtBlenderHH{ allocator }; - TexSrtBlenderDesc blenderDesc{ .animationCount = 1 }; - blender->Initialize(blenderDesc); - blender->needleBlender->controls[0] = hh::needle::AnimTexSrtControl::Create(resource->resource); - - static const char* nameTemplate = "UVAnimViewport"; - static const size_t nameTemplateLen = strlen(nameTemplate); - - const char* resName = resource->name.c_str(); - const size_t resNameLen = strlen(resName); - - const size_t nameLen = resNameLen + nameTemplateLen + 1; - char* nameRaw = new (GetAllocator()) char[nameLen]; - snprintf(nameRaw, nameLen, "%s%s", resName, nameTemplate); - - viewport = new (allocator) Viewport{ allocator }; - viewport->Setup({ .name = nameRaw }); - - GetAllocator()->Free(nameRaw); -} - -ResAnimTexSrtEditor* ResAnimTexSrtEditor::Create(csl::fnd::IAllocator* allocator, hh::gfx::ResAnimTexSrt* resource) { - return new (allocator) ResAnimTexSrtEditor{ allocator, resource }; -} - -// TODO: Requires a different way of handling the UVAnimation, or a manual update function -void ResAnimTexSrtEditor::RenderContents() { - if (ImGui::BeginDragDropTargetCustom(ImGui::GetCurrentWindow()->ContentRegionRect, ImGui::GetCurrentWindow()->ID)) { - if (auto* payload = ImGui::AcceptDragDropPayload("Resource")) { - auto* res = *static_cast(payload->Data); - const ResourceTypeInfo* typeInfo = &res->GetClass(); - - if (typeInfo == ResModel::GetTypeInfo()) - SetModel(reinterpret_cast(res)); - } - ImGui::EndDragDropTarget(); - } - - viewport->Render(); -} diff --git a/src/ui/resources/editors/ResAnimTexSrtEditor.h b/src/ui/resources/editors/ResAnimTexSrtEditor.h deleted file mode 100644 index 0f5473f..0000000 --- a/src/ui/resources/editors/ResAnimTexSrtEditor.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include -#include - -class ResAnimTexSrtEditor : public StandaloneWindow { - hh::fnd::Reference resource; - hh::fnd::Reference viewport; - hh::needle::PBRModelInstance* previewModel; - hh::fnd::Reference blender; - - void SetModel(hh::needle::PBRModelInstance* model); - void SetModel(hh::gfx::ResModel* model); -public: - ResAnimTexSrtEditor(csl::fnd::IAllocator* allocator, hh::gfx::ResAnimTexSrt* resource); - static ResAnimTexSrtEditor* Create(csl::fnd::IAllocator* allocator, hh::gfx::ResAnimTexSrt* resource); - virtual void RenderContents(); -}; diff --git a/src/ui/resources/editors/ResModelEditor.cpp b/src/ui/resources/editors/ResModelEditor.cpp deleted file mode 100644 index 4f54de4..0000000 --- a/src/ui/resources/editors/ResModelEditor.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "ResModelEditor.h" -#include -#include -#include - -using namespace hh::gfx; -using namespace hh::needle; - -ResModelEditor::ResModelEditor(csl::fnd::IAllocator* allocator, ResModel* resource) : StandaloneWindow{ allocator } { - char namebuf[500]; - snprintf(namebuf, sizeof(namebuf), "%s - %s @ 0x%zx (file mapped @ 0x%zx)", resource->GetName(), resource->GetClass().pName, (size_t)&resource, (size_t)resource); - SetTitle(namebuf); - - static const char* nameTemplate = "ModelViewport"; - static const size_t nameTemplateLen = strlen(nameTemplate); - - const char* resName = resource->name.c_str(); - const size_t resNameLen = strlen(resName); - - const size_t nameLen = resNameLen + nameTemplateLen + 1; - char* nameRaw = new (GetAllocator()) char[nameLen]; - snprintf(nameRaw, nameLen, "%s%s", resName, nameTemplate); - - viewport = new (allocator) InteractiveViewport{ allocator }; - viewport->Setup({.name = nameRaw}); - viewport->AddModel(resource, true); - - GetAllocator()->Free(nameRaw); -} - -ResModelEditor* ResModelEditor::Create(csl::fnd::IAllocator* allocator, ResModel* resource) { - return new (allocator) ResModelEditor{ allocator, resource }; -} - -void ResModelEditor::RenderContents() { - viewport->Render(); -} diff --git a/src/ui/resources/editors/ResModelEditor.h b/src/ui/resources/editors/ResModelEditor.h deleted file mode 100644 index e22304d..0000000 --- a/src/ui/resources/editors/ResModelEditor.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include -#include - -class ResModelEditor : public StandaloneWindow { -public: - hh::fnd::Reference viewport; - - ResModelEditor(csl::fnd::IAllocator* allocator, hh::gfx::ResModel* resource); - virtual void RenderContents(); - static ResModelEditor* Create(csl::fnd::IAllocator* allocator, hh::gfx::ResModel* resource); -}; diff --git a/vendor/imviewguizmo/CMakeLists.txt b/vendor/imviewguizmo/CMakeLists.txt deleted file mode 100644 index 3888bbf..0000000 --- a/vendor/imviewguizmo/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.28) -project(imviewguizmo LANGUAGES CXX) - -add_library(imviewguizmo INTERFACE) -target_link_libraries(imviewguizmo INTERFACE glm::glm) -target_sources(imviewguizmo - INTERFACE FILE_SET HEADERS BASE_DIRS ImViewGuizmo FILES - ImViewGuizmo/ImViewGuizmo.h -) diff --git a/vendor/imviewguizmo/ImViewGuizmo b/vendor/imviewguizmo/ImViewGuizmo deleted file mode 160000 index 104a4e1..0000000 --- a/vendor/imviewguizmo/ImViewGuizmo +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 104a4e1cf20e87fff1daa264690e0f9f446920e1 From 66f3c372c1f99ab3e4263ef9585d0b53bfe53e98 Mon Sep 17 00:00:00 2001 From: Ashrindy Date: Mon, 13 Oct 2025 17:00:11 +0200 Subject: [PATCH 11/13] Update CMakeLists.txt --- vendor/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index 4faaae4..fb8ab03 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -4,7 +4,6 @@ set(IMGUI_BUILD_BACKEND_DX11 ON) add_subdirectory(detours) add_subdirectory(imgui) add_subdirectory(imguizmo) -add_subdirectory(imviewguizmo) # add_subdirectory(imgui-file-dialog) add_subdirectory(imgui-node-editor) add_subdirectory(imgui_club) From 13e1898767ff5bc98b97c2b03b273337966f4644 Mon Sep 17 00:00:00 2001 From: Ashrindy Date: Mon, 13 Oct 2025 17:27:56 +0200 Subject: [PATCH 12/13] remove glmutils --- src/CMakeLists.txt | 2 -- src/ui/common/Theme.cpp | 17 +---------------- src/utilities/math/GLMUtils.cpp | 17 ----------------- src/utilities/math/GLMUtils.h | 8 -------- 4 files changed, 1 insertion(+), 43 deletions(-) delete mode 100644 src/utilities/math/GLMUtils.cpp delete mode 100644 src/utilities/math/GLMUtils.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6d88827..3eb9f97 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -73,7 +73,6 @@ target_sources(${DEVTOOLS_TARGET} utilities/math/EulerTransform.cpp utilities/math/Frustum.cpp utilities/math/MathUtils.cpp - utilities/math/GLMUtils.cpp utilities/ObjectDataUtils.cpp utilities/GameObjectUtils.cpp utilities/ResourceTypes.cpp @@ -169,7 +168,6 @@ target_sources(${DEVTOOLS_TARGET} utilities/Helpers.h utilities/math/EulerTransform.h utilities/math/MathUtils.h - utilities/math/GLMUtils.h utilities/math/Frustum.h utilities/math/Ray.h utilities/ObjectDataUtils.h diff --git a/src/ui/common/Theme.cpp b/src/ui/common/Theme.cpp index 27e740c..90edc98 100644 --- a/src/ui/common/Theme.cpp +++ b/src/ui/common/Theme.cpp @@ -1,5 +1,4 @@ #include "Theme.h" -#include void Theme_SonicFrontiers() { ImGuiStyle& style = ImGui::GetStyle(); @@ -106,8 +105,6 @@ void Theme_SonicFrontiers() { style.Colors[ImGuiCol_NavWindowingHighlight] = ImVec4(0.70f, 0.70f, 0.70f, 0.70f); style.Colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.20f); style.Colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f); - - ImViewGuizmo::GetStyle().scale = 0.65f; } void Theme_SonicForces() { @@ -216,8 +213,6 @@ void Theme_SonicForces() { colors[ImGuiCol_NavWindowingHighlight] = ImVec4(0.70f, 0.70f, 0.70f, 0.70f); colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.09f, 0.09f, 0.09f, 0.20f); colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.09f, 0.09f, 0.09f, 0.35f); - - ImViewGuizmo::GetStyle().scale = 0.65f; } void Theme_Gindows() { @@ -324,8 +319,6 @@ void Theme_Gindows() { style.Colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); style.Colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); style.Colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); - - ImViewGuizmo::GetStyle().scale = 0.65f; } void Theme_Sonadow_Generations() { @@ -434,8 +427,6 @@ void Theme_Sonadow_Generations() { colors[ImGuiCol_NavWindowingHighlight] = ImVec4(0.70f, 0.70f, 0.70f, 0.70f); colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.20f); colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f); - - ImViewGuizmo::GetStyle().scale = 0.65f; } void Theme_ImGui() { @@ -489,8 +480,6 @@ void Theme_ImGui() { style.CircleTessellationMaxError = 0.30f; ImGui::StyleColorsDark(&style); - - ImViewGuizmo::GetStyle().scale = 0.65f; } void Theme_ContrastImGui() { @@ -599,8 +588,6 @@ void Theme_ContrastImGui() { colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); - - ImViewGuizmo::GetStyle().scale = 0.65f; } void Theme_ModernContrastImGui() { @@ -680,9 +667,7 @@ void Theme_ModernContrastImGui() { colors[ImGuiCol_NavHighlight] = ImVec4(0.00f, 0.46f, 1.00f, 1.00f); colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); - colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); - - ImViewGuizmo::GetStyle().scale = 0.65f; + colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); } Theme Theme::themes[themeCount] = { diff --git a/src/utilities/math/GLMUtils.cpp b/src/utilities/math/GLMUtils.cpp deleted file mode 100644 index 3dd7527..0000000 --- a/src/utilities/math/GLMUtils.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "GLMUtils.h" - -glm::vec3 EigenToGLM(const Eigen::Vector3f& v) { - return glm::vec3(v.x(), v.y(), v.z()); -} - -Eigen::Vector3f GLMToEigen(const glm::vec3& v) { - return Eigen::Vector3f(v.x, v.y, v.z); -} - -glm::quat EigenToGLM(const Eigen::Quaternionf& q) { - return glm::quat(q.w(), q.x(), q.y(), q.z()); -} - -Eigen::Quaternionf GLMToEigen(const glm::quat& q) { - return Eigen::Quaternionf(q.w, q.x, q.y, q.z); -} diff --git a/src/utilities/math/GLMUtils.h b/src/utilities/math/GLMUtils.h deleted file mode 100644 index 122ee7c..0000000 --- a/src/utilities/math/GLMUtils.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -#include -#include - -glm::vec3 EigenToGLM(const Eigen::Vector3f& v); -Eigen::Vector3f GLMToEigen(const glm::vec3& v); -glm::quat EigenToGLM(const Eigen::Quaternionf& q); -Eigen::Quaternionf GLMToEigen(const glm::quat& q); From 619820d0b10e49e60c6f4cbc41d7bd3d63e0d6a3 Mon Sep 17 00:00:00 2001 From: Ashrindy Date: Mon, 13 Oct 2025 17:53:52 +0200 Subject: [PATCH 13/13] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 99d2041..b9e54f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,7 +84,7 @@ foreach(DEVTOOLS_TARGET_SDK miller rangers wars) add_subdirectory(${SDK_PATH} ${DEVTOOLS_TARGET_SDK}-sdk EXCLUDE_FROM_ALL) add_library(${DEVTOOLS_TARGET} SHARED) - target_link_libraries(${DEVTOOLS_TARGET} PRIVATE ${DEVTOOLS_TARGET_SDK}-sdk filewatch detours imgui imgui-backend-win32 imgui-backend-dx11 imgui-node-editor imgui-memory-editor imguizmo imviewguizmo implot imtimeline imbrowser yyjson reflectcpp OGDF rip-hl uwebsockets DiEventLib) + target_link_libraries(${DEVTOOLS_TARGET} PRIVATE ${DEVTOOLS_TARGET_SDK}-sdk filewatch detours imgui imgui-backend-win32 imgui-backend-dx11 imgui-node-editor imgui-memory-editor imguizmo implot imtimeline imbrowser yyjson reflectcpp OGDF rip-hl uwebsockets DiEventLib) target_compile_features(${DEVTOOLS_TARGET} PRIVATE cxx_std_20) target_compile_options(${DEVTOOLS_TARGET} PRIVATE /permissive- /W4 /wd4100 /wd4458 /wd4324) target_compile_definitions(${DEVTOOLS_TARGET}