添加assimp库,修改mono的运行时的目录

This commit is contained in:
2025-10-26 10:59:44 +08:00
parent 1bdb1d240e
commit 9c45444354
126 changed files with 26379 additions and 110 deletions

View File

@ -3,6 +3,7 @@
//
#include "EditorLayer.h"
#include "Hazel.h"
#include <imgui.h>
#include <ImGuizmo.h>
@ -12,7 +13,8 @@
#include <Hazel/Scene/SceneSerializer.h>
#include <Hazel/Utils/PlatformUtils.h>
#include "glm/gtx/matrix_decompose.hpp"
#include "imgui_internal.h"
namespace Hazel
{
@ -51,6 +53,8 @@ namespace Hazel
m_SceneHierachyPanel.SetContext(m_ActiveScene);
m_GizmoType = ImGuizmo::OPERATION::TRANSLATE;
m_GizmoMode = ImGuizmo::WORLD;
auto commandLineArgs = Application::Get().GetSpecification().commandLineArgs;
if (commandLineArgs.count > 1)
{
@ -302,6 +306,19 @@ namespace Hazel
ImGui::Text("Vertices: %d", stats.GetTotalVertexCount());
ImGui::Text("Indices: %d", stats.GetTotalIndexCount());
static float fpsRefreshTime = 0.0f;
static float displayedFPS = 0;
float currentTime = ImGui::GetTime();
// 每秒更新一次要显示的FPS
if (currentTime - fpsRefreshTime >= 1.0f)
{
fpsRefreshTime = currentTime;
displayedFPS = ImGui::GetIO().Framerate;
}
// 显示FPS
ImGui::Text("FPS: %.3f", displayedFPS);
ImGui::Separator();
ImGui::Text("viewPortSize: (%.2f, %.2f)", m_ViewPortSize.x, m_ViewPortSize.y);
@ -325,6 +342,13 @@ namespace Hazel
ImGui::Separator();
if (ImGui::Button(m_GizmoMode == ImGuizmo::WORLD ? "coordinate system World" : "coordinate system Local"))
{
m_GizmoMode = m_GizmoMode == ImGuizmo::WORLD ? ImGuizmo::LOCAL : ImGuizmo::WORLD;
}
ImGui::Separator();
ImGui::Checkbox("Show Colliders", &m_ShowPhysicsColliders);
ImGui::End();
@ -403,7 +427,7 @@ namespace Hazel
auto& tc = selectedEntity.GetComponent<TransformComponent>();
glm::mat4 transform = tc.GetTransform();
bool snap = SDL_GetModState() & SDL_KMOD_CTRL;
bool snap = Input::GetModState() & SDL_KMOD_CTRL;
float snapValue = 0.5f;
if (m_GizmoType == ImGuizmo::OPERATION::TRANSLATE)
snapValue = 0.25f;
@ -414,7 +438,8 @@ namespace Hazel
float snapValues[3] = {snapValue, snapValue, snapValue};
if (ImGuizmo::Manipulate(glm::value_ptr(cameraView), glm::value_ptr(cameraProjection),
static_cast<ImGuizmo::OPERATION>(m_GizmoType), ImGuizmo::WORLD,
static_cast<ImGuizmo::OPERATION>(m_GizmoType),
static_cast<ImGuizmo::MODE>(m_GizmoMode),
glm::value_ptr(transform), nullptr, snap ? snapValues : nullptr) && !Input::IsKeyPressed(KeyCode::LALT))
{
if (ImGuizmo::IsUsing())
@ -545,10 +570,17 @@ namespace Hazel
return;
}
if (m_SceneState == SceneState::Play)
m_ActiveScene->OnRuntimeStop();
else if (m_SceneState == SceneState::Simulate)
switch (m_SceneState)
{
case SceneState::Play:
m_ActiveScene->OnRuntimeStop();
break;
case SceneState::Simulate:
m_ActiveScene->OnSimulationStop();
break;
default:
break;
}
m_SceneState = SceneState::Edit;
m_ActiveScene = m_EditorScene;
@ -568,7 +600,7 @@ namespace Hazel
m_SceneHierachyPanel.SetContext(m_ActiveScene);
}
void EditorLayer::ChangeOptMode(unsigned int mode)
void EditorLayer::ChangeOptMode(const int mode)
{
if (m_ViewportHovered)
m_GizmoType = mode;
@ -584,57 +616,41 @@ namespace Hazel
if (e.button.clicks && m_ViewportHovered && !ImGuizmo::IsOver() && Input::IsMouseButtonPressed(MouseButton::BUTTON_LEFT) && !Input::IsKeyPressed(KeyCode::LALT))
m_SceneHierachyPanel.SetSelectedEntity(m_HoveredEntity);
#define SHORTCUT_EXIT (SDL_KMOD_CTRL + SDLK_W)
#define SHORTCUT_NEW (SDL_KMOD_CTRL + SDLK_N)
#define SHORTCUT_OPEN (SDL_KMOD_CTRL + SDLK_O)
#define SHORTCUT_SAVE (SDL_KMOD_CTRL + SDLK_S)
#define SHORTCUT_SAVE_AS (SDL_KMOD_CTRL + SDL_KMOD_SHIFT + SDLK_S)
#define SHORTCUT_CTRL_D (SDL_KMOD_CTRL + SDLK_D)
if (e.key.down && e.key.repeat == 0)
{
const auto mod = SDL_GetModState();
const auto ctrl = (mod & SDL_KMOD_CTRL) ? SDL_KMOD_CTRL : 0;
const auto shift = (mod & SDL_KMOD_SHIFT) ? SDL_KMOD_SHIFT : 0;
const auto ctrl = Input::IsKeyPressed(KeyCode::LCTRL);
const auto shift = Input::IsKeyPressed(KeyCode::LSHIFT);
switch (ctrl + shift + e.key.key)
if (ctrl)
{
case SHORTCUT_EXIT:
Application::Get().Close();
break;
case SHORTCUT_NEW:
NewScene();
break;
case SHORTCUT_OPEN:
OpenScene();
break;
case SHORTCUT_SAVE:
SaveScene();
break;
case SHORTCUT_SAVE_AS:
SaveSceneAs();
break;
case SHORTCUT_CTRL_D:
OnDuplicateEntity();
break;
// GIZMO
case SDLK_Q:
ChangeOptMode(-1);
break;
case SDLK_W:
ChangeOptMode(ImGuizmo::OPERATION::TRANSLATE);
break;
case SDLK_E:
ChangeOptMode(ImGuizmo::OPERATION::SCALE);
break;
case SDLK_R:
ChangeOptMode(ImGuizmo::OPERATION::ROTATE);
break;
default:
break;
if (shift)
{
if (Input::IsKeyPressed(KeyCode::S))
SaveSceneAs();
}else
{
if (Input::IsKeyPressed(KeyCode::W))
Application::Get().Close();
else if (Input::IsKeyPressed(KeyCode::S))
SaveScene();
else if (Input::IsKeyPressed(KeyCode::O))
OpenScene();
else if (Input::IsKeyPressed(KeyCode::N))
NewScene();
else if (Input::IsKeyPressed(KeyCode::D))
OnDuplicateEntity();
}
} else
{
if (Input::IsKeyPressed(KeyCode::Q))
ChangeOptMode(-1);
else if (Input::IsKeyPressed(KeyCode::W))
ChangeOptMode(ImGuizmo::OPERATION::TRANSLATE);
else if (Input::IsKeyPressed(KeyCode::E))
ChangeOptMode(ImGuizmo::OPERATION::SCALE);
else if (Input::IsKeyPressed(KeyCode::R))
ChangeOptMode(ImGuizmo::OPERATION::ROTATE);
}
}
}
@ -645,7 +661,7 @@ namespace Hazel
ImGui::PushStyleVar(ImGuiStyleVar_ItemInnerSpacing, ImVec2(0, 0));
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
auto& colors = ImGui::GetStyle().Colors;
const auto& colors = ImGui::GetStyle().Colors;
auto& buttonHovered = colors[ImGuiCol_ButtonHovered];
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(buttonHovered.x, buttonHovered.y, buttonHovered.z, 0.5f));
auto& buttonActive = colors[ImGuiCol_ButtonActive];

View File

@ -41,7 +41,7 @@ namespace Hazel
void OnDuplicateEntity();
void ChangeOptMode(unsigned int mode);
void ChangeOptMode(int mode);
void OnOverLayRender();
@ -73,6 +73,7 @@ namespace Hazel
ContentBroswerPanel m_ContentBroswerPanel;
int m_GizmoType = -1;
int m_GizmoMode = -1;
bool m_ShowPhysicsColliders = false;

View File

@ -41,7 +41,7 @@ namespace Hazel
float cellSize = folderSize + padding;
float panelWidth = ImGui::GetContentRegionAvail().x;
int columnsCount = (int)panelWidth / cellSize;
int columnsCount = static_cast<int>(panelWidth / cellSize);
if (columnsCount <= 1)
columnsCount = 1;
@ -63,6 +63,8 @@ namespace Hazel
auto relativePath = std::filesystem::relative(path, g_AssetPath);
const wchar_t* itemPath = relativePath.c_str();
ImGui::SetDragDropPayload("CONTENT_BROSWER_ITEM", itemPath, (wcslen(itemPath) + 1) * sizeof(wchar_t), ImGuiCond_Once);
ImGui::Text("%s", relativePath.filename().u8string().c_str());
ImGui::EndDragDropSource();
}

View File

@ -25,6 +25,7 @@ namespace Hazel
{
m_Context = context;
m_SelectionContext = {};
m_LastSelectionContext = {};
}
void SceneHierachyPanel::OnImGuiRender()
@ -367,7 +368,7 @@ namespace Hazel
bool setStyleFlag = false;
static char buffer[64] = {};
strcpy(buffer, component.ClassName.c_str());
snprintf(buffer, sizeof(buffer), "%s", component.ClassName.c_str());
if (!scriptClassExists)
{
@ -456,10 +457,17 @@ namespace Hazel
{
ImGui::ColorEdit4("Color", glm::value_ptr(component.Color));
// Texture
ImGui::Button("Texture", ImVec2(100.f, 0.0f));
if (!component.Texture)
ImGui::Button("Texture", ImVec2(100.f, 0.0f));
else
ImGui::ImageButton("Texture", component.Texture->GetRendererID(), ImVec2{100.f, 100.f}, ImVec2{0, 0}, ImVec2{1, 1});
if (ImGui::BeginDragDropTarget())
{
ImDrawList* drawList = ImGui::GetWindowDrawList();
drawList->AddRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(),
IM_COL32(0, 120, 215, 255), 0.0f, 0, 3.0f);
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("CONTENT_BROSWER_ITEM"))
{
const wchar_t* path = (const wchar_t*)payload->Data;