Adding notes in commonly edited scripts to clarify where functions with // notes to know what the script does in better detail.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#include "EditorUI.h"
|
#include "EditorUI.h"
|
||||||
|
|
||||||
// FileBrowser implementation
|
#pragma region File Browser
|
||||||
FileBrowser::FileBrowser() {
|
FileBrowser::FileBrowser() {
|
||||||
currentPath = fs::current_path();
|
currentPath = fs::current_path();
|
||||||
projectRoot = currentPath;
|
projectRoot = currentPath;
|
||||||
@@ -183,7 +183,9 @@ bool FileBrowser::matchesFilter(const fs::directory_entry& entry) const {
|
|||||||
|
|
||||||
return filenameLower.find(filterLower) != std::string::npos;
|
return filenameLower.find(filterLower) != std::string::npos;
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region ImGui Theme
|
||||||
void applyModernTheme() {
|
void applyModernTheme() {
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
ImVec4* colors = style.Colors;
|
ImVec4* colors = style.Colors;
|
||||||
@@ -271,7 +273,10 @@ void applyModernTheme() {
|
|||||||
style.PopupBorderSize = 1.0f;
|
style.PopupBorderSize = 1.0f;
|
||||||
style.TabBorderSize = 1.0f;
|
style.TabBorderSize = 1.0f;
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Dockspace
|
||||||
|
// Call once per frame before rendering editor panels.
|
||||||
void setupDockspace(const std::function<void()>& menuBarContent) {
|
void setupDockspace(const std::function<void()>& menuBarContent) {
|
||||||
static bool dockspaceOpen = true;
|
static bool dockspaceOpen = true;
|
||||||
static ImGuiDockNodeFlags dockspaceFlags = ImGuiDockNodeFlags_None;
|
static ImGuiDockNodeFlags dockspaceFlags = ImGuiDockNodeFlags_None;
|
||||||
@@ -304,3 +309,4 @@ void setupDockspace(const std::function<void()>& menuBarContent) {
|
|||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
|
#pragma region File Browser Enums
|
||||||
|
|
||||||
enum class FileBrowserViewMode {
|
enum class FileBrowserViewMode {
|
||||||
List,
|
List,
|
||||||
Grid
|
Grid
|
||||||
@@ -20,6 +22,9 @@ enum class FileCategory {
|
|||||||
Text,
|
Text,
|
||||||
Unknown
|
Unknown
|
||||||
};
|
};
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region File Browser
|
||||||
|
|
||||||
class FileBrowser {
|
class FileBrowser {
|
||||||
public:
|
public:
|
||||||
@@ -40,6 +45,7 @@ public:
|
|||||||
|
|
||||||
FileBrowser();
|
FileBrowser();
|
||||||
|
|
||||||
|
// Call refresh after mutating currentPath/searchFilter/showHiddenFiles.
|
||||||
void refresh();
|
void refresh();
|
||||||
void navigateUp();
|
void navigateUp();
|
||||||
void navigateTo(const fs::path& path);
|
void navigateTo(const fs::path& path);
|
||||||
@@ -57,9 +63,13 @@ public:
|
|||||||
// Legacy compatibility
|
// Legacy compatibility
|
||||||
bool isOBJFile(const fs::directory_entry& entry) const;
|
bool isOBJFile(const fs::directory_entry& entry) const;
|
||||||
};
|
};
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Editor UI Helpers
|
||||||
|
|
||||||
// Apply the modern dark theme to ImGui
|
// Apply the modern dark theme to ImGui
|
||||||
void applyModernTheme();
|
void applyModernTheme();
|
||||||
|
|
||||||
// Setup ImGui dockspace for the editor
|
// Setup ImGui dockspace for the editor
|
||||||
void setupDockspace(const std::function<void()>& menuBarContent = nullptr);
|
void setupDockspace(const std::function<void()>& menuBarContent = nullptr);
|
||||||
|
#pragma endregion
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#pragma region Environment Window
|
||||||
void Engine::renderEnvironmentWindow() {
|
void Engine::renderEnvironmentWindow() {
|
||||||
if (!showEnvironmentWindow) return;
|
if (!showEnvironmentWindow) return;
|
||||||
ImGui::Begin("Environment", &showEnvironmentWindow);
|
ImGui::Begin("Environment", &showEnvironmentWindow);
|
||||||
@@ -74,7 +75,9 @@ void Engine::renderEnvironmentWindow() {
|
|||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Camera Window
|
||||||
void Engine::renderCameraWindow() {
|
void Engine::renderCameraWindow() {
|
||||||
if (!showCameraWindow) return;
|
if (!showCameraWindow) return;
|
||||||
ImGui::Begin("Camera", &showCameraWindow);
|
ImGui::Begin("Camera", &showCameraWindow);
|
||||||
@@ -96,3 +99,4 @@ void Engine::renderCameraWindow() {
|
|||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#pragma region File Icons
|
||||||
namespace FileIcons {
|
namespace FileIcons {
|
||||||
namespace {
|
namespace {
|
||||||
ImU32 BlendColor(ImU32 a, ImU32 b, float t) {
|
ImU32 BlendColor(ImU32 a, ImU32 b, float t) {
|
||||||
@@ -401,7 +402,9 @@ namespace FileIcons {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region File Actions
|
||||||
namespace {
|
namespace {
|
||||||
enum class CreateKind {
|
enum class CreateKind {
|
||||||
Folder,
|
Folder,
|
||||||
@@ -475,8 +478,10 @@ namespace {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region File Browser Panel
|
||||||
|
// Uses FileBrowser state for navigation, selection, and drag-drop.
|
||||||
void Engine::renderFileBrowserPanel() {
|
void Engine::renderFileBrowserPanel() {
|
||||||
ImGui::Begin("Project", &showFileBrowser);
|
ImGui::Begin("Project", &showFileBrowser);
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
@@ -1242,3 +1247,4 @@ void Engine::renderFileBrowserPanel() {
|
|||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#pragma region ImGui Helpers
|
||||||
namespace ImGui {
|
namespace ImGui {
|
||||||
|
|
||||||
// Animated progress bar that keeps circles moving while work happens in the background.
|
// Animated progress bar that keeps circles moving while work happens in the background.
|
||||||
@@ -103,7 +104,9 @@ bool Spinner(const char* label, float radius, int thickness, const ImU32& color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ImGui
|
} // namespace ImGui
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Package Task State
|
||||||
namespace {
|
namespace {
|
||||||
struct PackageTaskResult {
|
struct PackageTaskResult {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
@@ -117,8 +120,9 @@ struct PackageTaskState {
|
|||||||
std::future<PackageTaskResult> future;
|
std::future<PackageTaskResult> future;
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Launcher
|
||||||
void Engine::renderLauncher() {
|
void Engine::renderLauncher() {
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImVec2 displaySize = io.DisplaySize;
|
ImVec2 displaySize = io.DisplaySize;
|
||||||
@@ -364,7 +368,9 @@ void Engine::renderLauncher() {
|
|||||||
if (projectManager.showOpenProjectDialog)
|
if (projectManager.showOpenProjectDialog)
|
||||||
renderOpenProjectDialog();
|
renderOpenProjectDialog();
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region New Project Dialog
|
||||||
void Engine::renderNewProjectDialog() {
|
void Engine::renderNewProjectDialog() {
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImVec2 center = ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f);
|
ImVec2 center = ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f);
|
||||||
@@ -441,7 +447,9 @@ void Engine::renderNewProjectDialog() {
|
|||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Open Project Dialog
|
||||||
void Engine::renderOpenProjectDialog() {
|
void Engine::renderOpenProjectDialog() {
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImVec2 center = ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f);
|
ImVec2 center = ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f);
|
||||||
@@ -497,7 +505,9 @@ void Engine::renderOpenProjectDialog() {
|
|||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Project Browser Panel
|
||||||
void Engine::renderProjectBrowserPanel() {
|
void Engine::renderProjectBrowserPanel() {
|
||||||
ImVec4 headerCol = ImVec4(0.20f, 0.27f, 0.36f, 1.0f);
|
ImVec4 headerCol = ImVec4(0.20f, 0.27f, 0.36f, 1.0f);
|
||||||
ImVec4 headerColActive = ImVec4(0.24f, 0.34f, 0.46f, 1.0f);
|
ImVec4 headerColActive = ImVec4(0.24f, 0.34f, 0.46f, 1.0f);
|
||||||
@@ -793,3 +803,4 @@ void Engine::renderProjectBrowserPanel() {
|
|||||||
ImGui::PopStyleVar(2);
|
ImGui::PopStyleVar(2);
|
||||||
ImGui::PopStyleColor(3);
|
ImGui::PopStyleColor(3);
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#pragma region Hierarchy Helpers
|
||||||
namespace {
|
namespace {
|
||||||
ImU32 GetHierarchyTypeColor(ObjectType type) {
|
ImU32 GetHierarchyTypeColor(ObjectType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@@ -94,7 +95,9 @@ namespace {
|
|||||||
drawList->AddLine(ImVec2(connectorX, rowMid), ImVec2(itemMin.x + 6.0f, rowMid), lineColor, 1.0f);
|
drawList->AddLine(ImVec2(connectorX, rowMid), ImVec2(itemMin.x + 6.0f, rowMid), lineColor, 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Hierarchy Panel
|
||||||
void Engine::renderHierarchyPanel() {
|
void Engine::renderHierarchyPanel() {
|
||||||
ImGui::Begin("Hierarchy", &showHierarchy);
|
ImGui::Begin("Hierarchy", &showHierarchy);
|
||||||
|
|
||||||
@@ -400,7 +403,9 @@ void Engine::renderObjectNode(SceneObject& obj, const std::string& filter,
|
|||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Inspector Panel
|
||||||
void Engine::renderInspectorPanel() {
|
void Engine::renderInspectorPanel() {
|
||||||
ImGui::Begin("Inspector", &showInspector);
|
ImGui::Begin("Inspector", &showInspector);
|
||||||
|
|
||||||
@@ -2124,6 +2129,9 @@ void Engine::renderInspectorPanel() {
|
|||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Console Panel
|
||||||
void Engine::renderConsolePanel() {
|
void Engine::renderConsolePanel() {
|
||||||
ImGui::Begin("Console", &showConsole);
|
ImGui::Begin("Console", &showConsole);
|
||||||
|
|
||||||
@@ -2160,6 +2168,9 @@ void Engine::renderConsolePanel() {
|
|||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Mesh Builder Panel
|
||||||
void Engine::renderMeshBuilderPanel() {
|
void Engine::renderMeshBuilderPanel() {
|
||||||
ImGui::Begin("Mesh Builder", &showMeshBuilder);
|
ImGui::Begin("Mesh Builder", &showMeshBuilder);
|
||||||
|
|
||||||
@@ -2301,6 +2312,9 @@ void Engine::renderMeshBuilderPanel() {
|
|||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Dialogs
|
||||||
void Engine::renderDialogs() {
|
void Engine::renderDialogs() {
|
||||||
if (showNewSceneDialog) {
|
if (showNewSceneDialog) {
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#pragma region Gizmo Toolbar
|
||||||
namespace GizmoToolbar {
|
namespace GizmoToolbar {
|
||||||
enum class Icon {
|
enum class Icon {
|
||||||
Translate,
|
Translate,
|
||||||
@@ -249,8 +250,10 @@ namespace GizmoToolbar {
|
|||||||
return pressed;
|
return pressed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
|
#pragma region Game Viewport Window
|
||||||
void Engine::renderGameViewportWindow() {
|
void Engine::renderGameViewportWindow() {
|
||||||
gameViewportFocused = false;
|
gameViewportFocused = false;
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(6.0f, 6.0f));
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(6.0f, 6.0f));
|
||||||
@@ -350,6 +353,9 @@ void Engine::renderGameViewportWindow() {
|
|||||||
ImGui::End();
|
ImGui::End();
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Play Controls Bar
|
||||||
void Engine::renderPlayControlsBar() {
|
void Engine::renderPlayControlsBar() {
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
ImVec2 buttonPadding(10.0f, 4.0f);
|
ImVec2 buttonPadding(10.0f, 4.0f);
|
||||||
@@ -428,6 +434,9 @@ void Engine::renderPlayControlsBar() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Main Menu Bar
|
||||||
void Engine::renderMainMenuBar() {
|
void Engine::renderMainMenuBar() {
|
||||||
refreshScriptEditorWindows();
|
refreshScriptEditorWindows();
|
||||||
|
|
||||||
@@ -572,6 +581,10 @@ void Engine::renderMainMenuBar() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Scene Viewport
|
||||||
|
// Final scene output for the editor viewport.
|
||||||
void Engine::renderViewport() {
|
void Engine::renderViewport() {
|
||||||
ImGuiWindowFlags viewportFlags = ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoScrollbar;
|
ImGuiWindowFlags viewportFlags = ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoScrollbar;
|
||||||
|
|
||||||
@@ -1817,3 +1830,4 @@ void Engine::renderViewport() {
|
|||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#pragma region Material File IO Helpers
|
||||||
namespace {
|
namespace {
|
||||||
struct MaterialFileData {
|
struct MaterialFileData {
|
||||||
MaterialProperties props;
|
MaterialProperties props;
|
||||||
@@ -78,7 +79,9 @@ bool writeMaterialFile(const MaterialFileData& data, const std::string& path) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Window + Selection Utilities
|
||||||
void window_size_callback(GLFWwindow* window, int width, int height) {
|
void window_size_callback(GLFWwindow* window, int width, int height) {
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
}
|
}
|
||||||
@@ -141,7 +144,9 @@ Camera Engine::makeCameraFromObject(const SceneObject& obj) const {
|
|||||||
}
|
}
|
||||||
return cam;
|
return cam;
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Transform Helpers
|
||||||
namespace {
|
namespace {
|
||||||
// Equivalent to glm::extractEulerAngleXYZ without depending on the experimental header.
|
// Equivalent to glm::extractEulerAngleXYZ without depending on the experimental header.
|
||||||
glm::vec3 ExtractEulerXYZ(const glm::mat3& m) {
|
glm::vec3 ExtractEulerXYZ(const glm::mat3& m) {
|
||||||
@@ -195,7 +200,9 @@ glm::mat4 Engine::ComposeTransform(const glm::vec3& position, const glm::quat& r
|
|||||||
glm::mat4 Engine::ComposeTransform(const glm::vec3& position, const glm::vec3& rotationDeg, const glm::vec3& scale) {
|
glm::mat4 Engine::ComposeTransform(const glm::vec3& position, const glm::vec3& rotationDeg, const glm::vec3& scale) {
|
||||||
return ComposeTransform(position, QuatFromEulerXYZ(rotationDeg), scale);
|
return ComposeTransform(position, QuatFromEulerXYZ(rotationDeg), scale);
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Undo / Redo
|
||||||
void Engine::recordState(const char* /*reason*/) {
|
void Engine::recordState(const char* /*reason*/) {
|
||||||
SceneSnapshot snap;
|
SceneSnapshot snap;
|
||||||
snap.objects = sceneObjects;
|
snap.objects = sceneObjects;
|
||||||
@@ -246,7 +253,9 @@ void Engine::redo() {
|
|||||||
nextObjectId = snap.nextId;
|
nextObjectId = snap.nextId;
|
||||||
projectManager.currentProject.hasUnsavedChanges = true;
|
projectManager.currentProject.hasUnsavedChanges = true;
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Engine Lifecycle
|
||||||
bool Engine::init() {
|
bool Engine::init() {
|
||||||
std::cerr << "[DEBUG] Creating window..." << std::endl;
|
std::cerr << "[DEBUG] Creating window..." << std::endl;
|
||||||
editorWindow = window.makeWindow();
|
editorWindow = window.makeWindow();
|
||||||
@@ -481,7 +490,9 @@ void Engine::shutdown() {
|
|||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Asset Import
|
||||||
void Engine::importOBJToScene(const std::string& filepath, const std::string& objectName) {
|
void Engine::importOBJToScene(const std::string& filepath, const std::string& objectName) {
|
||||||
recordState("importOBJ");
|
recordState("importOBJ");
|
||||||
std::string errorMsg;
|
std::string errorMsg;
|
||||||
@@ -564,7 +575,9 @@ void Engine::convertModelToRawMesh(const std::string& filepath) {
|
|||||||
addConsoleMessage("Raw mesh export failed: " + error, ConsoleMessageType::Error);
|
addConsoleMessage("Raw mesh export failed: " + error, ConsoleMessageType::Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Mesh Editing
|
||||||
bool Engine::ensureMeshEditTarget(SceneObject* obj) {
|
bool Engine::ensureMeshEditTarget(SceneObject* obj) {
|
||||||
if (!obj) return false;
|
if (!obj) return false;
|
||||||
fs::path ext = fs::path(obj->meshPath).extension();
|
fs::path ext = fs::path(obj->meshPath).extension();
|
||||||
@@ -604,7 +617,9 @@ bool Engine::syncMeshEditToGPU(SceneObject* obj) {
|
|||||||
projectManager.currentProject.hasUnsavedChanges = true;
|
projectManager.currentProject.hasUnsavedChanges = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Material IO
|
||||||
void Engine::loadMaterialFromFile(SceneObject& obj) {
|
void Engine::loadMaterialFromFile(SceneObject& obj) {
|
||||||
if (obj.materialPath.empty()) return;
|
if (obj.materialPath.empty()) return;
|
||||||
try {
|
try {
|
||||||
@@ -688,7 +703,9 @@ void Engine::saveMaterialToFile(const SceneObject& obj) {
|
|||||||
addConsoleMessage("Failed to save material: " + obj.materialPath, ConsoleMessageType::Error);
|
addConsoleMessage("Failed to save material: " + obj.materialPath, ConsoleMessageType::Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Editor Shortcuts
|
||||||
void Engine::handleKeyboardShortcuts() {
|
void Engine::handleKeyboardShortcuts() {
|
||||||
static bool f11Pressed = false;
|
static bool f11Pressed = false;
|
||||||
if (glfwGetKey(editorWindow, GLFW_KEY_F11) == GLFW_PRESS && !f11Pressed) {
|
if (glfwGetKey(editorWindow, GLFW_KEY_F11) == GLFW_PRESS && !f11Pressed) {
|
||||||
@@ -792,7 +809,9 @@ void Engine::handleKeyboardShortcuts() {
|
|||||||
gameViewCursorLocked = false;
|
gameViewCursorLocked = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Runtime Updates
|
||||||
void Engine::updateScripts(float delta) {
|
void Engine::updateScripts(float delta) {
|
||||||
if (sceneObjects.empty()) return;
|
if (sceneObjects.empty()) return;
|
||||||
|
|
||||||
@@ -923,7 +942,9 @@ void Engine::updatePlayerController(float delta) {
|
|||||||
}
|
}
|
||||||
syncLocalTransform(*player);
|
syncLocalTransform(*player);
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Transform Hierarchy
|
||||||
void Engine::updateLocalFromWorld(SceneObject& obj, const glm::vec3& parentPos, const glm::quat& parentRot, const glm::vec3& parentScale) {
|
void Engine::updateLocalFromWorld(SceneObject& obj, const glm::vec3& parentPos, const glm::quat& parentRot, const glm::vec3& parentScale) {
|
||||||
auto safeDiv = [](float v, float d) { return (std::abs(d) > 1e-6f) ? (v / d) : 0.0f; };
|
auto safeDiv = [](float v, float d) { return (std::abs(d) > 1e-6f) ? (v / d) : 0.0f; };
|
||||||
auto unwrapNear = [](float angle, float reference) {
|
auto unwrapNear = [](float angle, float reference) {
|
||||||
@@ -1078,6 +1099,9 @@ void Engine::updateHierarchyWorldTransforms() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Project Lifecycle
|
||||||
void Engine::OpenProjectPath(const std::string& path) {
|
void Engine::OpenProjectPath(const std::string& path) {
|
||||||
try {
|
try {
|
||||||
if (projectManager.loadProject(path)) {
|
if (projectManager.loadProject(path)) {
|
||||||
@@ -1171,7 +1195,9 @@ void Engine::createNewProject(const char* name, const char* location) {
|
|||||||
projectManager.errorMessage = "Failed to create project directory";
|
projectManager.errorMessage = "Failed to create project directory";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Scene Management
|
||||||
void Engine::loadRecentScenes() {
|
void Engine::loadRecentScenes() {
|
||||||
sceneObjects.clear();
|
sceneObjects.clear();
|
||||||
clearSelection();
|
clearSelection();
|
||||||
@@ -1269,7 +1295,9 @@ void Engine::createNewScene(const std::string& sceneName) {
|
|||||||
|
|
||||||
addConsoleMessage("Created new scene: " + sceneName, ConsoleMessageType::Success);
|
addConsoleMessage("Created new scene: " + sceneName, ConsoleMessageType::Success);
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Scene Objects
|
||||||
void Engine::addObject(ObjectType type, const std::string& baseName) {
|
void Engine::addObject(ObjectType type, const std::string& baseName) {
|
||||||
recordState("addObject");
|
recordState("addObject");
|
||||||
int id = nextObjectId++;
|
int id = nextObjectId++;
|
||||||
@@ -1419,7 +1447,9 @@ void Engine::setParent(int childId, int parentId) {
|
|||||||
projectManager.currentProject.hasUnsavedChanges = true;
|
projectManager.currentProject.hasUnsavedChanges = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Console Logging
|
||||||
void Engine::addConsoleMessage(const std::string& message, ConsoleMessageType type) {
|
void Engine::addConsoleMessage(const std::string& message, ConsoleMessageType type) {
|
||||||
std::string prefix;
|
std::string prefix;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@@ -1447,7 +1477,9 @@ void Engine::logToConsole(const std::string& message) {
|
|||||||
void Engine::addConsoleMessageFromScript(const std::string& message, ConsoleMessageType type) {
|
void Engine::addConsoleMessageFromScript(const std::string& message, ConsoleMessageType type) {
|
||||||
addConsoleMessage(message, type);
|
addConsoleMessage(message, type);
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Object Lookup
|
||||||
SceneObject* Engine::findObjectByName(const std::string& name) {
|
SceneObject* Engine::findObjectByName(const std::string& name) {
|
||||||
auto it = std::find_if(sceneObjects.begin(), sceneObjects.end(), [&](const SceneObject& o) {
|
auto it = std::find_if(sceneObjects.begin(), sceneObjects.end(), [&](const SceneObject& o) {
|
||||||
return o.name == name;
|
return o.name == name;
|
||||||
@@ -1463,7 +1495,9 @@ SceneObject* Engine::findObjectById(int id) {
|
|||||||
if (it != sceneObjects.end()) return &(*it);
|
if (it != sceneObjects.end()) return &(*it);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Script Hooks
|
||||||
fs::path Engine::resolveScriptBinary(const fs::path& sourcePath) {
|
fs::path Engine::resolveScriptBinary(const fs::path& sourcePath) {
|
||||||
ScriptBuildConfig config;
|
ScriptBuildConfig config;
|
||||||
std::string error;
|
std::string error;
|
||||||
@@ -1579,7 +1613,9 @@ bool Engine::setAudioClipFromScript(int id, const std::string& path) {
|
|||||||
audio.setObjectLoop(*obj, obj->audioSource.loop);
|
audio.setObjectLoop(*obj, obj->audioSource.loop);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Script Compilation + Editor Tabs
|
||||||
void Engine::compileScriptFile(const fs::path& scriptPath) {
|
void Engine::compileScriptFile(const fs::path& scriptPath) {
|
||||||
if (!projectManager.currentProject.isLoaded) {
|
if (!projectManager.currentProject.isLoaded) {
|
||||||
addConsoleMessage("No project is loaded", ConsoleMessageType::Warning);
|
addConsoleMessage("No project is loaded", ConsoleMessageType::Warning);
|
||||||
@@ -1747,7 +1783,9 @@ void Engine::renderScriptEditorWindows() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region ImGui Setup
|
||||||
void Engine::setupImGui() {
|
void Engine::setupImGui() {
|
||||||
std::cerr << "[DEBUG] setupImGui: getting primary monitor..." << std::endl;
|
std::cerr << "[DEBUG] setupImGui: getting primary monitor..." << std::endl;
|
||||||
float mainScale = 1.0f;
|
float mainScale = 1.0f;
|
||||||
@@ -1793,3 +1831,4 @@ void Engine::setupImGui() {
|
|||||||
}
|
}
|
||||||
std::cerr << "[DEBUG] setupImGui: complete!" << std::endl;
|
std::cerr << "[DEBUG] setupImGui: complete!" << std::endl;
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "MeshBuilder.h"
|
#include "MeshBuilder.h"
|
||||||
|
|
||||||
|
#pragma region State Reset
|
||||||
void MeshBuilder::clear() {
|
void MeshBuilder::clear() {
|
||||||
mesh = RawMeshAsset();
|
mesh = RawMeshAsset();
|
||||||
hasMesh = false;
|
hasMesh = false;
|
||||||
@@ -7,7 +8,9 @@ void MeshBuilder::clear() {
|
|||||||
selectedVertex = -1;
|
selectedVertex = -1;
|
||||||
loadedPath.clear();
|
loadedPath.clear();
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region File IO
|
||||||
bool MeshBuilder::load(const std::string& path, std::string& error) {
|
bool MeshBuilder::load(const std::string& path, std::string& error) {
|
||||||
auto& loader = getModelLoader();
|
auto& loader = getModelLoader();
|
||||||
RawMeshAsset loaded;
|
RawMeshAsset loaded;
|
||||||
@@ -35,7 +38,9 @@ bool MeshBuilder::save(const std::string& path, std::string& error) {
|
|||||||
dirty = false;
|
dirty = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Geometry Editing
|
||||||
void MeshBuilder::recomputeNormals() {
|
void MeshBuilder::recomputeNormals() {
|
||||||
if (mesh.positions.empty()) return;
|
if (mesh.positions.empty()) return;
|
||||||
mesh.normals.assign(mesh.positions.size(), glm::vec3(0.0f));
|
mesh.normals.assign(mesh.positions.size(), glm::vec3(0.0f));
|
||||||
@@ -103,3 +108,4 @@ bool MeshBuilder::addFace(const std::vector<uint32_t>& indices, std::string& err
|
|||||||
dirty = true;
|
dirty = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "ModelLoader.h"
|
#include "ModelLoader.h"
|
||||||
|
|
||||||
|
#pragma region Mesh Builder State
|
||||||
// Lightweight mesh editing state used by the MeshBuilder panel.
|
// Lightweight mesh editing state used by the MeshBuilder panel.
|
||||||
class MeshBuilder {
|
class MeshBuilder {
|
||||||
public:
|
public:
|
||||||
@@ -11,7 +12,9 @@ public:
|
|||||||
std::string loadedPath;
|
std::string loadedPath;
|
||||||
bool dirty = false;
|
bool dirty = false;
|
||||||
int selectedVertex = -1;
|
int selectedVertex = -1;
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Mesh Builder API
|
||||||
bool load(const std::string& path, std::string& error);
|
bool load(const std::string& path, std::string& error);
|
||||||
bool save(const std::string& path, std::string& error);
|
bool save(const std::string& path, std::string& error);
|
||||||
void clear();
|
void clear();
|
||||||
@@ -20,3 +23,4 @@ public:
|
|||||||
// Add a new face defined by vertex indices (3 = triangle, 4 = quad fan).
|
// Add a new face defined by vertex indices (3 = triangle, 4 = quad fan).
|
||||||
bool addFace(const std::vector<uint32_t>& indices, std::string& error);
|
bool addFace(const std::vector<uint32_t>& indices, std::string& error);
|
||||||
};
|
};
|
||||||
|
#pragma endregion
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#pragma region Local Path Helpers
|
||||||
namespace {
|
namespace {
|
||||||
fs::path normalizePath(const fs::path& p) {
|
fs::path normalizePath(const fs::path& p) {
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
@@ -59,7 +60,9 @@ fs::path guessIncludeDir(const fs::path& repoRoot, const std::string& includeRel
|
|||||||
return normalizePath(repoRoot);
|
return normalizePath(repoRoot);
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Lifecycle
|
||||||
PackageManager::PackageManager() {
|
PackageManager::PackageManager() {
|
||||||
buildRegistry();
|
buildRegistry();
|
||||||
}
|
}
|
||||||
@@ -70,7 +73,9 @@ void PackageManager::setProjectRoot(const fs::path& root) {
|
|||||||
manifestPath = projectRoot / "packages.modu";
|
manifestPath = projectRoot / "packages.modu";
|
||||||
loadManifest();
|
loadManifest();
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Install / Remove
|
||||||
bool PackageManager::isInstalled(const std::string& id) const {
|
bool PackageManager::isInstalled(const std::string& id) const {
|
||||||
return std::find(installedIds.begin(), installedIds.end(), id) != installedIds.end();
|
return std::find(installedIds.begin(), installedIds.end(), id) != installedIds.end();
|
||||||
}
|
}
|
||||||
@@ -135,7 +140,9 @@ bool PackageManager::remove(const std::string& id) {
|
|||||||
saveManifest();
|
saveManifest();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Build Config
|
||||||
void PackageManager::applyToBuildConfig(ScriptBuildConfig& config) const {
|
void PackageManager::applyToBuildConfig(ScriptBuildConfig& config) const {
|
||||||
std::unordered_set<std::string> defineSet(config.defines.begin(), config.defines.end());
|
std::unordered_set<std::string> defineSet(config.defines.begin(), config.defines.end());
|
||||||
std::unordered_set<std::string> linuxLibSet(config.linuxLinkLibs.begin(), config.linuxLinkLibs.end());
|
std::unordered_set<std::string> linuxLibSet(config.linuxLinkLibs.begin(), config.linuxLinkLibs.end());
|
||||||
@@ -167,7 +174,9 @@ void PackageManager::applyToBuildConfig(ScriptBuildConfig& config) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Registry
|
||||||
void PackageManager::buildRegistry() {
|
void PackageManager::buildRegistry() {
|
||||||
registry.clear();
|
registry.clear();
|
||||||
fs::path engineRoot = fs::current_path();
|
fs::path engineRoot = fs::current_path();
|
||||||
@@ -230,7 +239,9 @@ void PackageManager::buildRegistry() {
|
|||||||
miniaudio.includeDirs = { engineRoot / "include/ThirdParty" };
|
miniaudio.includeDirs = { engineRoot / "include/ThirdParty" };
|
||||||
add(miniaudio);
|
add(miniaudio);
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Manifest IO
|
||||||
void PackageManager::loadManifest() {
|
void PackageManager::loadManifest() {
|
||||||
installedIds.clear();
|
installedIds.clear();
|
||||||
for (const auto& pkg : registry) {
|
for (const auto& pkg : registry) {
|
||||||
@@ -336,7 +347,9 @@ void PackageManager::saveManifest() const {
|
|||||||
file << join(pkg->windowsLibs, ';') << "\n";
|
file << join(pkg->windowsLibs, ';') << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Registry Lookup
|
||||||
const PackageInfo* PackageManager::findPackage(const std::string& id) const {
|
const PackageInfo* PackageManager::findPackage(const std::string& id) const {
|
||||||
auto it = std::find_if(registry.begin(), registry.end(), [&](const PackageInfo& p) {
|
auto it = std::find_if(registry.begin(), registry.end(), [&](const PackageInfo& p) {
|
||||||
return p.id == id;
|
return p.id == id;
|
||||||
@@ -348,7 +361,9 @@ bool PackageManager::isBuiltIn(const std::string& id) const {
|
|||||||
const PackageInfo* pkg = findPackage(id);
|
const PackageInfo* pkg = findPackage(id);
|
||||||
return pkg && pkg->builtIn;
|
return pkg && pkg->builtIn;
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Utility Helpers
|
||||||
std::string PackageManager::trim(const std::string& value) {
|
std::string PackageManager::trim(const std::string& value) {
|
||||||
size_t start = 0;
|
size_t start = 0;
|
||||||
while (start < value.size() && std::isspace(static_cast<unsigned char>(value[start]))) start++;
|
while (start < value.size() && std::isspace(static_cast<unsigned char>(value[start]))) start++;
|
||||||
@@ -406,7 +421,9 @@ std::string PackageManager::join(const std::vector<std::string>& vals, char deli
|
|||||||
}
|
}
|
||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region External Packages
|
||||||
fs::path PackageManager::packagesFolder() const {
|
fs::path PackageManager::packagesFolder() const {
|
||||||
fs::path newFolder = projectRoot / "Library" / "InstalledPackages";
|
fs::path newFolder = projectRoot / "Library" / "InstalledPackages";
|
||||||
if (fs::exists(newFolder) || fs::exists(projectRoot / "scripts.modu")) {
|
if (fs::exists(newFolder) || fs::exists(projectRoot / "scripts.modu")) {
|
||||||
@@ -516,3 +533,4 @@ bool PackageManager::updateGitPackage(const std::string& id, std::string& outLog
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#pragma endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user