|
1 | 1 | #include "Inspector.h" |
2 | 2 |
|
3 | | -#include <Game-Lib/Util/ServiceLocator.h> |
4 | | -#include <Game-Lib/Util/ImguiUtil.h> |
5 | 3 | #include <Game-Lib/Application/EnttRegistries.h> |
6 | | -#include <Game-Lib/Rendering/GameRenderer.h> |
7 | | -#include <Game-Lib/Rendering/Terrain/TerrainRenderer.h> |
8 | | -#include <Game-Lib/Rendering/Model/ModelLoader.h> |
9 | | -#include <Game-Lib/Rendering/Model/ModelRenderer.h> |
10 | | -#include <Game-Lib/Rendering/Debug/DebugRenderer.h> |
11 | | -#include <Game-Lib/Rendering/PixelQuery.h> |
12 | | -#include <Game-Lib/Rendering/Camera.h> |
13 | 4 | #include <Game-Lib/ECS/Singletons/ActiveCamera.h> |
14 | 5 | #include <Game-Lib/ECS/Singletons/FreeflyingCameraSettings.h> |
15 | 6 | #include <Game-Lib/ECS/Singletons/RenderState.h> |
16 | 7 | #include <Game-Lib/ECS/Singletons/Database/TextureSingleton.h> |
17 | 8 | #include <Game-Lib/ECS/Components/Camera.h> |
| 9 | +#include <Game-Lib/ECS/Components/Decal.h> |
18 | 10 | #include <Game-Lib/ECS/Components/Model.h> |
19 | 11 | #include <Game-Lib/ECS/Components/Name.h> |
20 | 12 | #include <Game-Lib/ECS/Components/Unit.h> |
|
23 | 15 | #include <Game-Lib/Editor/ActionStack.h> |
24 | 16 | #include <Game-Lib/Editor/Hierarchy.h> |
25 | 17 | #include <Game-Lib/Editor/Viewport.h> |
| 18 | +#include <Game-Lib/Rendering/GameRenderer.h> |
| 19 | +#include <Game-Lib/Rendering/Terrain/TerrainRenderer.h> |
| 20 | +#include <Game-Lib/Rendering/Model/ModelLoader.h> |
| 21 | +#include <Game-Lib/Rendering/Model/ModelRenderer.h> |
| 22 | +#include <Game-Lib/Rendering/Debug/DebugRenderer.h> |
| 23 | +#include <Game-Lib/Rendering/PixelQuery.h> |
| 24 | +#include <Game-Lib/Rendering/Camera.h> |
| 25 | +#include <Game-Lib/Util/ServiceLocator.h> |
| 26 | +#include <Game-Lib/Util/ImguiUtil.h> |
26 | 27 |
|
27 | 28 | #include <Renderer/RenderSettings.h> |
28 | 29 |
|
@@ -322,8 +323,12 @@ namespace Editor |
322 | 323 |
|
323 | 324 | InspectEntityTransform(entity); |
324 | 325 |
|
| 326 | + InspectEntityAABB(entity); |
| 327 | + |
325 | 328 | InspectEntityModel(entity); |
326 | 329 |
|
| 330 | + InspectEntityDecal(entity); |
| 331 | + |
327 | 332 | if (ECS::Components::Unit* unit = registry->try_get<ECS::Components::Unit>(entity)) |
328 | 333 | { |
329 | 334 | ImGui::Text("Body ID: %d", unit->bodyID); |
@@ -521,6 +526,119 @@ namespace Editor |
521 | 526 | ImGui::PopStyleColor(); |
522 | 527 | } |
523 | 528 |
|
| 529 | + void Inspector::InspectEntityAABB(entt::entity entity) |
| 530 | + { |
| 531 | + entt::registry* registry = ServiceLocator::GetEnttRegistries()->gameRegistry; |
| 532 | + |
| 533 | + ECS::Components::AABB* aabb = registry->try_get<ECS::Components::AABB>(entity); |
| 534 | + |
| 535 | + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.4f, 0.4f, 0.4f, 1.0f)); |
| 536 | + |
| 537 | + if (aabb) |
| 538 | + { |
| 539 | + if (Util::Imgui::BeginGroupPanel("AABB")) |
| 540 | + { |
| 541 | + bool isDirty = false; |
| 542 | + |
| 543 | + // Center Pos |
| 544 | + vec3 centerPos = aabb->centerPos; |
| 545 | + if (ImGui::DragFloat3("center pos", ¢erPos.x)) |
| 546 | + { |
| 547 | + aabb->centerPos = centerPos; |
| 548 | + isDirty = true; |
| 549 | + } |
| 550 | + |
| 551 | + // Extents |
| 552 | + vec3 extents = aabb->extents; |
| 553 | + if (ImGui::DragFloat3("extents", &extents.x)) |
| 554 | + { |
| 555 | + aabb->extents = extents; |
| 556 | + isDirty = true; |
| 557 | + } |
| 558 | + |
| 559 | + if (isDirty) |
| 560 | + { |
| 561 | + registry->emplace_or_replace<ECS::Components::DirtyAABB>(entity); |
| 562 | + } |
| 563 | + } |
| 564 | + Util::Imgui::EndGroupPanel(); |
| 565 | + } |
| 566 | + ImGui::PopStyleColor(); |
| 567 | + } |
| 568 | + |
| 569 | + void Inspector::InspectEntityDecal(entt::entity entity) |
| 570 | + { |
| 571 | + entt::registry* registry = ServiceLocator::GetEnttRegistries()->gameRegistry; |
| 572 | + |
| 573 | + ECS::Components::Decal* decal = registry->try_get<ECS::Components::Decal>(entity); |
| 574 | + |
| 575 | + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.4f, 0.4f, 0.4f, 1.0f)); |
| 576 | + |
| 577 | + if (decal) |
| 578 | + { |
| 579 | + if (Util::Imgui::BeginGroupPanel("Decal")) |
| 580 | + { |
| 581 | + bool isDirty = false; |
| 582 | + |
| 583 | + std::string texturePath = decal->texturePath; |
| 584 | + if (ImGui::InputText("Texture Path", &texturePath)) |
| 585 | + { |
| 586 | + decal->texturePath = texturePath; |
| 587 | + isDirty = true; |
| 588 | + } |
| 589 | + |
| 590 | + Color color = decal->colorMultiplier; |
| 591 | + if (ImGui::ColorEdit3("Color Multiplier", &color.r)) |
| 592 | + { |
| 593 | + decal->colorMultiplier = color; |
| 594 | + isDirty = true; |
| 595 | + } |
| 596 | + |
| 597 | + f32 thresholdMin = f32(decal->thresholdMinMax.x); |
| 598 | + if (ImGui::SliderFloat("Threshold Min", &thresholdMin, -1.0f, 1.0f)) |
| 599 | + { |
| 600 | + decal->thresholdMinMax.x = f16(thresholdMin); |
| 601 | + isDirty = true; |
| 602 | + } |
| 603 | + |
| 604 | + f32 thresholdMax = f32(decal->thresholdMinMax.y); |
| 605 | + if (ImGui::SliderFloat("Threshold Max", &thresholdMax, -1.0f, 1.0f)) |
| 606 | + { |
| 607 | + decal->thresholdMinMax.y = f16(thresholdMax); |
| 608 | + isDirty = true; |
| 609 | + } |
| 610 | + |
| 611 | + vec2 minUV = vec2(decal->minUV); |
| 612 | + if (ImGui::DragFloat2("Min UV", &minUV.x, 0.01f, 0.0f, 1.0f)) |
| 613 | + { |
| 614 | + decal->minUV = hvec2(minUV); |
| 615 | + isDirty = true; |
| 616 | + } |
| 617 | + |
| 618 | + vec2 maxUV = vec2(decal->maxUV); |
| 619 | + if (ImGui::DragFloat2("Max UV", &maxUV.x, 0.01f, 0.0f, 1.0f)) |
| 620 | + { |
| 621 | + decal->maxUV = hvec2(maxUV); |
| 622 | + isDirty = true; |
| 623 | + } |
| 624 | + |
| 625 | + u32 flags = decal->flags; |
| 626 | + if (ImGui::InputScalar("Flags", ImGuiDataType_U32, &flags, nullptr, nullptr, "%u", ImGuiInputTextFlags_CharsHexadecimal)) |
| 627 | + { |
| 628 | + decal->flags = flags; |
| 629 | + isDirty = true; |
| 630 | + } |
| 631 | + |
| 632 | + if (isDirty) |
| 633 | + { |
| 634 | + registry->emplace_or_replace<ECS::Components::DirtyDecal>(entity); |
| 635 | + } |
| 636 | + } |
| 637 | + Util::Imgui::EndGroupPanel(); |
| 638 | + } |
| 639 | + ImGui::PopStyleColor(); |
| 640 | + } |
| 641 | + |
524 | 642 | bool Inspector::DrawGizmo(entt::registry* registry, entt::entity entity, ECS::Components::Transform& transform) |
525 | 643 | { |
526 | 644 | entt::registry::context& ctx = registry->ctx(); |
|
0 commit comments