From 1fcbd1f4452a48dd097e84d9004305d291f009f3 Mon Sep 17 00:00:00 2001 From: facobackup Date: Thu, 12 Mar 2026 21:12:41 -0300 Subject: [PATCH 01/11] Moving files around --- CMakeLists.txt | 550 +++++++++--------- src/{context => }/ApplicationContext.cpp | 10 +- src/{context => }/ApplicationContext.h | 66 +-- .../AbstractCoreRepository.h | 2 +- .../abstract => common}/AbstractImporter.h | 4 +- .../AbstractResourceService.h | 4 +- src/common/AbstractRuntimeComponent.h | 6 +- src/common/{interface => }/Changeable.h | 0 src/{enum => common}/FieldType.h | 0 src/common/{interface => }/Icons.h | 0 src/common/{interface => }/Initializable.h | 0 src/common/{inspection => }/Inspectable.cpp | 10 +- src/common/{inspection => }/Inspectable.h | 6 +- .../{inspection => }/InspectableMember.h | 2 +- src/common/{inspection => }/InspectedField.h | 2 +- src/common/{inspection => }/InspectedMethod.h | 0 src/{util => common}/Serializable.cpp | 6 +- src/{util => common}/Serializable.h | 0 src/common/{interface => }/Synchornizable.h | 0 src/{context => core}/glfw/GLFWContext.cpp | 2 +- src/{context => core}/glfw/GLFWContext.h | 0 src/{context => core}/gui/GuiContext.cpp | 6 +- src/{context => core}/gui/GuiContext.h | 0 .../vulkan/VulkanContext.cpp | 2 +- src/{context => core}/vulkan/VulkanContext.h | 0 src/{util => core/vulkan}/VulkanUtils.cpp | 8 +- src/{util => core/vulkan}/VulkanUtils.h | 0 src/{context => }/editor/EditorPanel.cpp | 4 +- src/{context => }/editor/EditorPanel.h | 0 .../editor/abstract/AbstractPanel.cpp | 2 +- .../editor/abstract/AbstractPanel.h | 0 src/{context => }/editor/abstract/IPanel.h | 4 +- .../abstract/form/AbstractFormFieldPanel.h | 0 .../editor/abstract/form/AccordionPanel.cpp | 0 .../editor/abstract/form/AccordionPanel.h | 0 .../editor/abstract/form/ChildPanel.cpp | 0 .../editor/abstract/form/ChildPanel.h | 0 .../editor/abstract/form/FormPanel.cpp | 4 +- .../editor/abstract/form/FormPanel.h | 0 .../abstract/form/types/BooleanField.cpp | 2 +- .../editor/abstract/form/types/BooleanField.h | 2 +- .../editor/abstract/form/types/ColorField.cpp | 2 +- .../editor/abstract/form/types/ColorField.h | 2 +- .../editor/abstract/form/types/FloatField.cpp | 2 +- .../editor/abstract/form/types/FloatField.h | 2 +- .../editor/abstract/form/types/IntField.cpp | 2 +- .../editor/abstract/form/types/IntField.h | 2 +- .../abstract/form/types/MethodField.cpp | 0 .../editor/abstract/form/types/MethodField.h | 2 +- .../editor/abstract/form/types/QuatField.cpp | 4 +- .../editor/abstract/form/types/QuatField.h | 2 +- .../abstract/form/types/ResourceField.cpp | 6 +- .../abstract/form/types/ResourceField.h | 2 +- .../form/types/ResourceFilesPanel.cpp | 6 +- .../abstract/form/types/ResourceFilesPanel.h | 0 .../abstract/form/types/StringField.cpp | 2 +- .../editor/abstract/form/types/StringField.h | 2 +- .../editor/abstract/form/types/Vec2Field.cpp | 4 +- .../editor/abstract/form/types/Vec2Field.h | 2 +- .../editor/abstract/form/types/Vec3Field.cpp | 4 +- .../editor/abstract/form/types/Vec3Field.h | 2 +- .../editor/abstract/form/types/Vec4Field.cpp | 4 +- .../editor/abstract/form/types/Vec4Field.h | 2 +- .../dock-spaces/console/ConsolePanel.cpp | 2 +- .../editor/dock-spaces/console/ConsolePanel.h | 2 +- .../dock-spaces/docks/AbstractDockPanel.h | 2 +- .../dock-spaces/docks/DockSpacePanel.cpp | 8 +- .../editor/dock-spaces/docks/DockSpacePanel.h | 0 .../dock-spaces/files/FilePreviewPanel.cpp | 6 +- .../dock-spaces/files/FilePreviewPanel.h | 0 .../editor/dock-spaces/files/FilesContext.cpp | 2 +- .../editor/dock-spaces/files/FilesContext.h | 2 +- .../dock-spaces/files/FilesHeaderPanel.cpp | 10 +- .../dock-spaces/files/FilesHeaderPanel.h | 0 .../dock-spaces/files/FilesListPanel.cpp | 6 +- .../editor/dock-spaces/files/FilesListPanel.h | 0 .../editor/dock-spaces/files/FilesPanel.cpp | 14 +- .../editor/dock-spaces/files/FilesPanel.h | 2 +- .../dock-spaces/header/AsyncTaskPanel.cpp | 2 +- .../dock-spaces/header/AsyncTaskPanel.h | 0 .../dock-spaces/header/EditorHeaderPanel.cpp | 2 +- .../dock-spaces/header/EditorHeaderPanel.h | 0 .../dock-spaces/inspector/InspectorPanel.cpp | 6 +- .../dock-spaces/inspector/InspectorPanel.h | 2 +- .../dock-spaces/metrics/MetricsPanel.cpp | 0 .../editor/dock-spaces/metrics/MetricsPanel.h | 0 .../repositories/RepositoriesPanel.cpp | 2 +- .../repositories/RepositoriesPanel.h | 0 .../viewport/CameraPositionPanel.cpp | 4 +- .../viewport/CameraPositionPanel.h | 0 .../dock-spaces/viewport/EngineFramePanel.cpp | 18 +- .../dock-spaces/viewport/EngineFramePanel.h | 0 .../dock-spaces/viewport/GizmoPanel.cpp | 4 +- .../editor/dock-spaces/viewport/GizmoPanel.h | 0 .../viewport/GizmoSettingsPanel.cpp | 2 +- .../dock-spaces/viewport/GizmoSettingsPanel.h | 2 +- .../viewport/ViewportHeaderPanel.cpp | 2 +- .../viewport/ViewportHeaderPanel.h | 0 .../dock-spaces/viewport/ViewportPanel.cpp | 4 +- .../dock-spaces/viewport/ViewportPanel.h | 0 .../dock-spaces/world/WorldHeaderPanel.cpp | 4 +- .../dock-spaces/world/WorldHeaderPanel.h | 0 .../editor/dock-spaces/world/WorldPanel.cpp | 8 +- .../editor/dock-spaces/world/WorldPanel.h | 4 +- .../notification => editor/dto}/AsyncTask.h | 0 src/{repository/dock => editor/dto}/DockDTO.h | 5 +- .../dock => editor/dto}/DockSpace.cpp | 18 +- .../dock => editor/dto}/DockSpace.h | 0 src/{dto/file => editor/dto}/EntryMetadata.h | 6 +- src/{dto/file => editor/dto}/FSEntry.h | 2 +- .../dto}/GridPushConstant.h | 0 .../file => editor/dto}/ImportSettingsDTO.h | 2 +- src/{ => editor}/dto/Notification.h | 0 .../voxel/impl => editor/dto}/OctreeNode.cpp | 2 +- .../voxel/impl => editor/dto}/OctreeNode.h | 2 +- src/{service/mesh => editor/dto}/SceneData.h | 2 +- .../mesh => editor/dto}/SceneEntityData.h | 6 +- .../dto}/SceneImportSettingsDTO.h | 0 .../dto}/SelectedDotPushConstant.h | 0 src/{ => editor}/dto/ShortcutDTO.h | 0 .../dto}/SparseVoxelOctreeBuilder.cpp | 2 +- .../dto}/SparseVoxelOctreeBuilder.h | 2 +- src/{ => editor}/enum/EngineResourceIDs.h | 0 src/{ => editor}/enum/EntryType.h | 0 src/{ => editor}/enum/NotificationSeverity.h | 2 +- src/{ => editor}/enum/ShadingMode.h | 2 +- src/{ => editor}/enum/engine-definitions.h | 2 +- .../editor/panel/FileImportModalPanel.cpp | 2 +- .../editor/panel/FileImportModalPanel.h | 0 .../editor/panel/NotificationsPanel.cpp | 4 +- .../editor/panel/NotificationsPanel.h | 0 .../impl/tools => editor/passes}/GridPass.cpp | 8 +- .../impl/tools => editor/passes}/GridPass.h | 4 +- .../tools => editor/passes}/IconsPass.cpp | 8 +- .../impl/tools => editor/passes}/IconsPass.h | 2 +- .../passes}/SelectionIDPass.cpp | 10 +- .../tools => editor/passes}/SelectionIDPass.h | 4 +- .../passes}/SelectionOutlinePass.cpp | 12 +- .../passes}/SelectionOutlinePass.h | 4 +- .../repository}/DockRepository.cpp | 2 +- .../repository}/DockRepository.h | 4 +- .../repository}/EditorRepository.cpp | 4 +- .../repository}/EditorRepository.h | 10 +- .../service}/AsyncTaskService.cpp | 6 +- .../service}/AsyncTaskService.h | 2 +- .../dock => editor/service}/DockService.cpp | 12 +- .../dock => editor/service}/DockService.h | 6 +- .../service}/FileImporterService.cpp | 6 +- .../service}/FileImporterService.h | 4 +- .../files => editor/service}/FilesService.cpp | 16 +- .../files => editor/service}/FilesService.h | 2 +- .../log => editor/service}/LogService.cpp | 2 +- .../log => editor/service}/LogService.h | 2 +- .../service}/MaterialImporterService.cpp | 6 +- .../service}/MaterialImporterService.h | 2 +- .../service}/MeshImporterService.cpp | 16 +- .../service}/MeshImporterService.h | 2 +- .../service}/NotificationService.cpp | 2 +- .../service}/NotificationService.h | 2 +- .../service}/PickingService.cpp | 8 +- .../service}/PickingService.h | 4 +- .../service}/SceneImporterService.cpp | 22 +- .../service}/SceneImporterService.h | 2 +- .../service}/SelectionService.cpp | 6 +- .../service}/SelectionService.h | 4 +- .../service}/TextureImporterService.cpp | 16 +- .../service}/TextureImporterService.h | 2 +- .../theme => editor/service}/ThemeService.cpp | 4 +- .../theme => editor/service}/ThemeService.h | 2 +- .../service}/VoxelImporterService.cpp | 16 +- .../service}/VoxelImporterService.h | 6 +- src/{ => editor}/util/FileDialogUtil.h | 4 +- src/{ => editor}/util/FilesUtil.h | 2 +- src/{ => editor}/util/UIUtil.h | 2 +- src/{ => editor}/util/Util.h | 0 .../util/serialization-definitions.h | 2 +- src/{context => }/engine/EngineContext.cpp | 8 +- src/{context => }/engine/EngineContext.h | 4 +- .../impl => engine/dto}/AbstractComponent.h | 4 +- .../dto}/AccumulationPushConstant.h | 0 .../world/impl => engine/dto}/BoundingBox.h | 2 +- src/{service/camera => engine/dto}/Camera.cpp | 4 +- src/{service/camera => engine/dto}/Camera.h | 4 +- .../dto}/DenoiserPushConstant.h | 0 .../dto}/DescriptorBinding.h | 0 .../dto}/DescriptorInstance.h | 4 +- .../buffers => engine/dto}/GlobalDataUBO.h | 0 .../dto}/HWRayTracingPushConstant.h | 0 src/{dto/buffers => engine/dto}/LightData.h | 0 src/{service/mesh => engine/dto}/MeshData.h | 2 +- .../buffers => engine/dto}/MeshMetadata.h | 0 .../impl => engine/dto}/MetadataComponent.cpp | 6 +- .../impl => engine/dto}/MetadataComponent.h | 8 +- .../dto}/PipelineBuilder.cpp | 4 +- .../pipeline => engine/dto}/PipelineBuilder.h | 2 +- .../dto}/PostProcessingPushConstant.h | 0 .../dto}/PrimitiveComponent.cpp | 8 +- .../dto}/PrimitiveComponent.h | 4 +- .../pipeline => engine/dto}/ShaderModule.cpp | 4 +- .../pipeline => engine/dto}/ShaderModule.h | 0 .../dto}/SparseVoxelOctreeData.h | 2 +- .../texture => engine/dto}/TextureData.h | 0 src/{dto/buffers => engine/dto}/TileInfoUBO.h | 0 .../dto}/TransformComponent.cpp | 6 +- .../dto}/TransformComponent.h | 4 +- src/{service/mesh => engine/dto}/VertexData.h | 2 +- .../dto}/VolumeComponent.cpp | 4 +- .../dto}/VolumeComponent.h | 4 +- src/{dto/buffers => engine/dto}/VolumeData.h | 0 .../voxel/impl => engine/dto}/VoxelData.h | 0 src/{ => engine}/enum/ComponentType.cpp | 6 +- src/{ => engine}/enum/ComponentType.h | 2 +- src/{ => engine}/enum/PassType.h | 0 src/{ => engine}/enum/ResourceType.h | 0 .../engine/frame-builder/EngineFrame.cpp | 0 .../engine/frame-builder/EngineFrame.h | 2 +- .../frame-builder/EngineFrameBuilder.cpp | 0 .../engine/frame-builder/EngineFrameBuilder.h | 4 +- .../structures/BufferBuilder.cpp | 4 +- .../frame-builder/structures/BufferBuilder.h | 2 +- .../CommandBufferRecorderBuilder.cpp | 0 .../structures/CommandBufferRecorderBuilder.h | 0 .../structures/FramebufferBuilder.cpp | 4 +- .../structures/FramebufferBuilder.h | 0 .../frame-builder/structures/PassBuilder.cpp | 6 +- .../frame-builder/structures/PassBuilder.h | 4 +- .../structures/ResourceBuilder.h | 2 +- .../structures/TextureBuilder.cpp | 2 +- .../frame-builder/structures/TextureBuilder.h | 0 .../passes}/AbstractComputePass.cpp | 10 +- .../passes}/AbstractComputePass.h | 2 +- .../engine/passes/AbstractPass.cpp | 2 +- .../engine/passes/AbstractPass.h | 2 +- .../passes}/AbstractRenderPass.cpp | 8 +- .../passes}/AbstractRenderPass.h | 2 +- .../engine/passes/CommandBufferRecorder.cpp | 8 +- .../engine/passes/CommandBufferRecorder.h | 6 +- .../passes}/impl/HWRayTracingPass.cpp | 14 +- .../passes}/impl/HWRayTracingPass.h | 2 +- .../passes}/impl/PostProcessingPass.cpp | 6 +- .../passes}/impl/PostProcessingPass.h | 2 +- .../passes}/impl/SpatialFilterPass.cpp | 8 +- .../passes}/impl/SpatialFilterPass.h | 0 .../passes}/impl/TemporalAccumulationPass.cpp | 8 +- .../passes}/impl/TemporalAccumulationPass.h | 0 .../repository}/EngineRepository.cpp | 6 +- .../repository}/EngineRepository.h | 4 +- .../repository}/ResourceRepository.h | 2 +- .../repository}/RuntimeRepository.h | 0 .../repository}/WorldRepository.cpp | 10 +- .../repository}/WorldRepository.h | 18 +- .../resource}/BufferInstance.cpp | 10 +- .../resource}/BufferInstance.h | 2 +- .../resource}/FrameBufferAttachment.cpp | 4 +- .../resource}/FrameBufferAttachment.h | 2 +- .../resource}/FrameBufferInstance.h | 2 +- .../mesh => engine/resource}/MeshInstance.h | 2 +- .../resource}/PipelineInstance.h | 4 +- .../resource}/RuntimeResource.h | 4 +- .../voxel => engine/resource}/SVOInstance.h | 4 +- .../resource}/TextureInstance.h | 6 +- .../service}/BufferService.cpp | 8 +- .../buffer => engine/service}/BufferService.h | 4 +- .../service}/CameraService.cpp | 6 +- .../camera => engine/service}/CameraService.h | 2 +- .../service}/CommandBufferRecorderService.h | 4 +- .../service}/DescriptorSetService.cpp | 18 +- .../service}/DescriptorSetService.h | 4 +- .../service}/FrameBufferService.cpp | 8 +- .../service}/FrameBufferService.h | 4 +- .../service}/LightService.cpp | 8 +- .../lights => engine/service}/LightService.h | 4 +- .../service}/MaterialService.cpp | 8 +- .../service}/MaterialService.h | 0 .../mesh => engine/service}/MeshService.cpp | 20 +- .../mesh => engine/service}/MeshService.h | 6 +- .../service}/PipelineService.cpp | 22 +- .../service}/PipelineService.h | 6 +- .../service}/RayTracingService.cpp | 18 +- .../service}/RayTracingService.h | 6 +- .../service}/StreamingService.cpp | 12 +- .../service}/StreamingService.h | 6 +- .../service}/TextureService.cpp | 12 +- .../service}/TextureService.h | 6 +- .../service}/TransformService.cpp | 6 +- .../service}/TransformService.h | 4 +- .../service}/VolumeService.cpp | 10 +- .../service}/VolumeService.h | 4 +- .../voxel => engine/service}/VoxelService.cpp | 4 +- .../voxel => engine/service}/VoxelService.h | 4 +- src/{ => engine}/util/ImageUtils.h | 0 src/{ => engine}/util/ShaderUtil.cpp | 20 +- src/{ => engine}/util/ShaderUtil.h | 2 +- src/enum/LightType.h | 19 - src/main.cpp | 2 +- src/repository/dock/DockPosition.h | 14 - 296 files changed, 867 insertions(+), 907 deletions(-) rename src/{context => }/ApplicationContext.cpp (96%) rename src/{context => }/ApplicationContext.h (69%) rename src/{repository/abstract => common}/AbstractCoreRepository.h (86%) rename src/{service/abstract => common}/AbstractImporter.h (91%) rename src/{service/abstract => common}/AbstractResourceService.h (94%) rename src/common/{interface => }/Changeable.h (100%) rename src/{enum => common}/FieldType.h (100%) rename src/common/{interface => }/Icons.h (100%) rename src/common/{interface => }/Initializable.h (100%) rename src/common/{inspection => }/Inspectable.cpp (95%) rename src/common/{inspection => }/Inspectable.h (97%) rename src/common/{inspection => }/InspectableMember.h (92%) rename src/common/{inspection => }/InspectedField.h (92%) rename src/common/{inspection => }/InspectedMethod.h (100%) rename src/{util => common}/Serializable.cpp (86%) rename src/{util => common}/Serializable.h (100%) rename src/common/{interface => }/Synchornizable.h (100%) rename src/{context => core}/glfw/GLFWContext.cpp (99%) rename src/{context => core}/glfw/GLFWContext.h (100%) rename src/{context => core}/gui/GuiContext.cpp (97%) rename src/{context => core}/gui/GuiContext.h (100%) rename src/{context => core}/vulkan/VulkanContext.cpp (99%) rename src/{context => core}/vulkan/VulkanContext.h (100%) rename src/{util => core/vulkan}/VulkanUtils.cpp (90%) rename src/{util => core/vulkan}/VulkanUtils.h (100%) rename src/{context => }/editor/EditorPanel.cpp (97%) rename src/{context => }/editor/EditorPanel.h (100%) rename src/{context => }/editor/abstract/AbstractPanel.cpp (95%) rename src/{context => }/editor/abstract/AbstractPanel.h (100%) rename src/{context => }/editor/abstract/IPanel.h (67%) rename src/{context => }/editor/abstract/form/AbstractFormFieldPanel.h (100%) rename src/{context => }/editor/abstract/form/AccordionPanel.cpp (100%) rename src/{context => }/editor/abstract/form/AccordionPanel.h (100%) rename src/{context => }/editor/abstract/form/ChildPanel.cpp (100%) rename src/{context => }/editor/abstract/form/ChildPanel.h (100%) rename src/{context => }/editor/abstract/form/FormPanel.cpp (97%) rename src/{context => }/editor/abstract/form/FormPanel.h (100%) rename src/{context => }/editor/abstract/form/types/BooleanField.cpp (93%) rename src/{context => }/editor/abstract/form/types/BooleanField.h (86%) rename src/{context => }/editor/abstract/form/types/ColorField.cpp (95%) rename src/{context => }/editor/abstract/form/types/ColorField.h (88%) rename src/{context => }/editor/abstract/form/types/FloatField.cpp (94%) rename src/{context => }/editor/abstract/form/types/FloatField.h (86%) rename src/{context => }/editor/abstract/form/types/IntField.cpp (94%) rename src/{context => }/editor/abstract/form/types/IntField.h (86%) rename src/{context => }/editor/abstract/form/types/MethodField.cpp (100%) rename src/{context => }/editor/abstract/form/types/MethodField.h (86%) rename src/{context => }/editor/abstract/form/types/QuatField.cpp (93%) rename src/{context => }/editor/abstract/form/types/QuatField.h (88%) rename src/{context => }/editor/abstract/form/types/ResourceField.cpp (96%) rename src/{context => }/editor/abstract/form/types/ResourceField.h (92%) rename src/{context => }/editor/abstract/form/types/ResourceFilesPanel.cpp (79%) rename src/{context => }/editor/abstract/form/types/ResourceFilesPanel.h (100%) rename src/{context => }/editor/abstract/form/types/StringField.cpp (94%) rename src/{context => }/editor/abstract/form/types/StringField.h (87%) rename src/{context => }/editor/abstract/form/types/Vec2Field.cpp (91%) rename src/{context => }/editor/abstract/form/types/Vec2Field.h (88%) rename src/{context => }/editor/abstract/form/types/Vec3Field.cpp (92%) rename src/{context => }/editor/abstract/form/types/Vec3Field.h (88%) rename src/{context => }/editor/abstract/form/types/Vec4Field.cpp (92%) rename src/{context => }/editor/abstract/form/types/Vec4Field.h (88%) rename src/{context => }/editor/dock-spaces/console/ConsolePanel.cpp (98%) rename src/{context => }/editor/dock-spaces/console/ConsolePanel.h (88%) rename src/{context => }/editor/dock-spaces/docks/AbstractDockPanel.h (93%) rename src/{context => }/editor/dock-spaces/docks/DockSpacePanel.cpp (97%) rename src/{context => }/editor/dock-spaces/docks/DockSpacePanel.h (100%) rename src/{context => }/editor/dock-spaces/files/FilePreviewPanel.cpp (96%) rename src/{context => }/editor/dock-spaces/files/FilePreviewPanel.h (100%) rename src/{context => }/editor/dock-spaces/files/FilesContext.cpp (91%) rename src/{context => }/editor/dock-spaces/files/FilesContext.h (94%) rename src/{context => }/editor/dock-spaces/files/FilesHeaderPanel.cpp (89%) rename src/{context => }/editor/dock-spaces/files/FilesHeaderPanel.h (100%) rename src/{context => }/editor/dock-spaces/files/FilesListPanel.cpp (98%) rename src/{context => }/editor/dock-spaces/files/FilesListPanel.h (100%) rename src/{context => }/editor/dock-spaces/files/FilesPanel.cpp (95%) rename src/{context => }/editor/dock-spaces/files/FilesPanel.h (95%) rename src/{context => }/editor/dock-spaces/header/AsyncTaskPanel.cpp (98%) rename src/{context => }/editor/dock-spaces/header/AsyncTaskPanel.h (100%) rename src/{context => }/editor/dock-spaces/header/EditorHeaderPanel.cpp (98%) rename src/{context => }/editor/dock-spaces/header/EditorHeaderPanel.h (100%) rename src/{context => }/editor/dock-spaces/inspector/InspectorPanel.cpp (94%) rename src/{context => }/editor/dock-spaces/inspector/InspectorPanel.h (91%) rename src/{context => }/editor/dock-spaces/metrics/MetricsPanel.cpp (100%) rename src/{context => }/editor/dock-spaces/metrics/MetricsPanel.h (100%) rename src/{context => }/editor/dock-spaces/repositories/RepositoriesPanel.cpp (91%) rename src/{context => }/editor/dock-spaces/repositories/RepositoriesPanel.h (100%) rename src/{context => }/editor/dock-spaces/viewport/CameraPositionPanel.cpp (94%) rename src/{context => }/editor/dock-spaces/viewport/CameraPositionPanel.h (100%) rename src/{context => }/editor/dock-spaces/viewport/EngineFramePanel.cpp (92%) rename src/{context => }/editor/dock-spaces/viewport/EngineFramePanel.h (100%) rename src/{context => }/editor/dock-spaces/viewport/GizmoPanel.cpp (97%) rename src/{context => }/editor/dock-spaces/viewport/GizmoPanel.h (100%) rename src/{context => }/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp (99%) rename src/{context => }/editor/dock-spaces/viewport/GizmoSettingsPanel.h (96%) rename src/{context => }/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp (98%) rename src/{context => }/editor/dock-spaces/viewport/ViewportHeaderPanel.h (100%) rename src/{context => }/editor/dock-spaces/viewport/ViewportPanel.cpp (98%) rename src/{context => }/editor/dock-spaces/viewport/ViewportPanel.h (100%) rename src/{context => }/editor/dock-spaces/world/WorldHeaderPanel.cpp (95%) rename src/{context => }/editor/dock-spaces/world/WorldHeaderPanel.h (100%) rename src/{context => }/editor/dock-spaces/world/WorldPanel.cpp (97%) rename src/{context => }/editor/dock-spaces/world/WorldPanel.h (94%) rename src/{service/notification => editor/dto}/AsyncTask.h (100%) rename src/{repository/dock => editor/dto}/DockDTO.h (93%) rename src/{repository/dock => editor/dto}/DockSpace.cpp (70%) rename src/{repository/dock => editor/dto}/DockSpace.h (100%) rename src/{dto/file => editor/dto}/EntryMetadata.h (90%) rename src/{dto/file => editor/dto}/FSEntry.h (95%) rename src/{dto/push-constant => editor/dto}/GridPushConstant.h (100%) rename src/{dto/file => editor/dto}/ImportSettingsDTO.h (86%) rename src/{ => editor}/dto/Notification.h (100%) rename src/{service/voxel/impl => editor/dto}/OctreeNode.cpp (94%) rename src/{service/voxel/impl => editor/dto}/OctreeNode.h (97%) rename src/{service/mesh => editor/dto}/SceneData.h (95%) rename src/{service/mesh => editor/dto}/SceneEntityData.h (83%) rename src/{dto/file => editor/dto}/SceneImportSettingsDTO.h (100%) rename src/{dto/push-constant => editor/dto}/SelectedDotPushConstant.h (100%) rename src/{ => editor}/dto/ShortcutDTO.h (100%) rename src/{service/voxel/impl => editor/dto}/SparseVoxelOctreeBuilder.cpp (97%) rename src/{service/voxel/impl => editor/dto}/SparseVoxelOctreeBuilder.h (95%) rename src/{ => editor}/enum/EngineResourceIDs.h (100%) rename src/{ => editor}/enum/EntryType.h (100%) rename src/{ => editor}/enum/NotificationSeverity.h (96%) rename src/{ => editor}/enum/ShadingMode.h (98%) rename src/{ => editor}/enum/engine-definitions.h (97%) rename src/{context => }/editor/panel/FileImportModalPanel.cpp (99%) rename src/{context => }/editor/panel/FileImportModalPanel.h (100%) rename src/{context => }/editor/panel/NotificationsPanel.cpp (95%) rename src/{context => }/editor/panel/NotificationsPanel.h (100%) rename src/{context/engine/render-pass/impl/tools => editor/passes}/GridPass.cpp (85%) rename src/{context/engine/render-pass/impl/tools => editor/passes}/GridPass.h (80%) rename src/{context/engine/render-pass/impl/tools => editor/passes}/IconsPass.cpp (79%) rename src/{context/engine/render-pass/impl/tools => editor/passes}/IconsPass.h (87%) rename src/{context/engine/render-pass/impl/tools => editor/passes}/SelectionIDPass.cpp (86%) rename src/{context/engine/render-pass/impl/tools => editor/passes}/SelectionIDPass.h (80%) rename src/{context/engine/render-pass/impl/tools => editor/passes}/SelectionOutlinePass.cpp (77%) rename src/{context/engine/render-pass/impl/tools => editor/passes}/SelectionOutlinePass.h (80%) rename src/{repository/dock => editor/repository}/DockRepository.cpp (94%) rename src/{repository/dock => editor/repository}/DockRepository.h (84%) rename src/{repository/editor => editor/repository}/EditorRepository.cpp (98%) rename src/{repository/editor => editor/repository}/EditorRepository.h (91%) rename src/{service/notification => editor/service}/AsyncTaskService.cpp (92%) rename src/{service/notification => editor/service}/AsyncTaskService.h (95%) rename src/{service/dock => editor/service}/DockService.cpp (94%) rename src/{service/dock => editor/service}/DockService.h (73%) rename src/{service/files => editor/service}/FileImporterService.cpp (96%) rename src/{service/files => editor/service}/FileImporterService.h (86%) rename src/{service/files => editor/service}/FilesService.cpp (95%) rename src/{service/files => editor/service}/FilesService.h (93%) rename src/{service/log => editor/service}/LogService.cpp (97%) rename src/{service/log => editor/service}/LogService.h (95%) rename src/{service/material => editor/service}/MaterialImporterService.cpp (96%) rename src/{service/material => editor/service}/MaterialImporterService.h (92%) rename src/{service/mesh => editor/service}/MeshImporterService.cpp (90%) rename src/{service/mesh => editor/service}/MeshImporterService.h (93%) rename src/{service/notification => editor/service}/NotificationService.cpp (95%) rename src/{service/notification => editor/service}/NotificationService.h (92%) rename src/{service/picking => editor/service}/PickingService.cpp (94%) rename src/{service/picking => editor/service}/PickingService.h (80%) rename src/{service/mesh => editor/service}/SceneImporterService.cpp (93%) rename src/{service/mesh => editor/service}/SceneImporterService.h (96%) rename src/{service/selection => editor/service}/SelectionService.cpp (92%) rename src/{service/selection => editor/service}/SelectionService.h (83%) rename src/{service/texture => editor/service}/TextureImporterService.cpp (93%) rename src/{service/texture => editor/service}/TextureImporterService.h (95%) rename src/{service/theme => editor/service}/ThemeService.cpp (98%) rename src/{service/theme => editor/service}/ThemeService.h (93%) rename src/{service/voxel => editor/service}/VoxelImporterService.cpp (94%) rename src/{service/voxel => editor/service}/VoxelImporterService.h (89%) rename src/{ => editor}/util/FileDialogUtil.h (93%) rename src/{ => editor}/util/FilesUtil.h (98%) rename src/{ => editor}/util/UIUtil.h (99%) rename src/{ => editor}/util/Util.h (100%) rename src/{ => editor}/util/serialization-definitions.h (97%) rename src/{context => }/engine/EngineContext.cpp (94%) rename src/{context => }/engine/EngineContext.h (95%) rename src/{repository/world/impl => engine/dto}/AbstractComponent.h (89%) rename src/{dto/push-constant => engine/dto}/AccumulationPushConstant.h (100%) rename src/{repository/world/impl => engine/dto}/BoundingBox.h (97%) rename src/{service/camera => engine/dto}/Camera.cpp (98%) rename src/{service/camera => engine/dto}/Camera.h (98%) rename src/{dto/push-constant => engine/dto}/DenoiserPushConstant.h (100%) rename src/{service/descriptor => engine/dto}/DescriptorBinding.h (100%) rename src/{service/descriptor => engine/dto}/DescriptorInstance.h (85%) rename src/{dto/buffers => engine/dto}/GlobalDataUBO.h (100%) rename src/{dto/push-constant => engine/dto}/HWRayTracingPushConstant.h (100%) rename src/{dto/buffers => engine/dto}/LightData.h (100%) rename src/{service/mesh => engine/dto}/MeshData.h (93%) rename src/{dto/buffers => engine/dto}/MeshMetadata.h (100%) rename src/{repository/world/impl => engine/dto}/MetadataComponent.cpp (64%) rename src/{repository/world/impl => engine/dto}/MetadataComponent.h (83%) rename src/{service/pipeline => engine/dto}/PipelineBuilder.cpp (97%) rename src/{service/pipeline => engine/dto}/PipelineBuilder.h (98%) rename src/{dto/push-constant => engine/dto}/PostProcessingPushConstant.h (100%) rename src/{repository/world/components => engine/dto}/PrimitiveComponent.cpp (94%) rename src/{repository/world/components => engine/dto}/PrimitiveComponent.h (91%) rename src/{service/pipeline => engine/dto}/ShaderModule.cpp (73%) rename src/{service/pipeline => engine/dto}/ShaderModule.h (100%) rename src/{service/voxel/impl => engine/dto}/SparseVoxelOctreeData.h (94%) rename src/{service/texture => engine/dto}/TextureData.h (100%) rename src/{dto/buffers => engine/dto}/TileInfoUBO.h (100%) rename src/{repository/world/components => engine/dto}/TransformComponent.cpp (92%) rename src/{repository/world/components => engine/dto}/TransformComponent.h (91%) rename src/{service/mesh => engine/dto}/VertexData.h (96%) rename src/{repository/world/components => engine/dto}/VolumeComponent.cpp (81%) rename src/{repository/world/components => engine/dto}/VolumeComponent.h (93%) rename src/{dto/buffers => engine/dto}/VolumeData.h (100%) rename src/{service/voxel/impl => engine/dto}/VoxelData.h (100%) rename src/{ => engine}/enum/ComponentType.cpp (95%) rename src/{ => engine}/enum/ComponentType.h (96%) rename src/{ => engine}/enum/PassType.h (100%) rename src/{ => engine}/enum/ResourceType.h (100%) rename src/{context => }/engine/frame-builder/EngineFrame.cpp (100%) rename src/{context => }/engine/frame-builder/EngineFrame.h (96%) rename src/{context => }/engine/frame-builder/EngineFrameBuilder.cpp (100%) rename src/{context => }/engine/frame-builder/EngineFrameBuilder.h (95%) rename src/{context => }/engine/frame-builder/structures/BufferBuilder.cpp (82%) rename src/{context => }/engine/frame-builder/structures/BufferBuilder.h (93%) rename src/{context => }/engine/frame-builder/structures/CommandBufferRecorderBuilder.cpp (100%) rename src/{context => }/engine/frame-builder/structures/CommandBufferRecorderBuilder.h (100%) rename src/{context => }/engine/frame-builder/structures/FramebufferBuilder.cpp (86%) rename src/{context => }/engine/frame-builder/structures/FramebufferBuilder.h (100%) rename src/{context => }/engine/frame-builder/structures/PassBuilder.cpp (86%) rename src/{context => }/engine/frame-builder/structures/PassBuilder.h (93%) rename src/{context => }/engine/frame-builder/structures/ResourceBuilder.h (92%) rename src/{context => }/engine/frame-builder/structures/TextureBuilder.cpp (89%) rename src/{context => }/engine/frame-builder/structures/TextureBuilder.h (100%) rename src/{context/engine/compute-pass => engine/passes}/AbstractComputePass.cpp (96%) rename src/{context/engine/compute-pass => engine/passes}/AbstractComputePass.h (96%) rename src/{context => }/engine/passes/AbstractPass.cpp (98%) rename src/{context => }/engine/passes/AbstractPass.h (96%) rename src/{context/engine/render-pass => engine/passes}/AbstractRenderPass.cpp (83%) rename src/{context/engine/render-pass => engine/passes}/AbstractRenderPass.h (93%) rename src/{context => }/engine/passes/CommandBufferRecorder.cpp (95%) rename src/{context => }/engine/passes/CommandBufferRecorder.h (88%) rename src/{context/engine/compute-pass => engine/passes}/impl/HWRayTracingPass.cpp (90%) rename src/{context/engine/compute-pass => engine/passes}/impl/HWRayTracingPass.h (87%) rename src/{context/engine/render-pass => engine/passes}/impl/PostProcessingPass.cpp (90%) rename src/{context/engine/render-pass => engine/passes}/impl/PostProcessingPass.h (86%) rename src/{context/engine/compute-pass => engine/passes}/impl/SpatialFilterPass.cpp (85%) rename src/{context/engine/compute-pass => engine/passes}/impl/SpatialFilterPass.h (100%) rename src/{context/engine/compute-pass => engine/passes}/impl/TemporalAccumulationPass.cpp (86%) rename src/{context/engine/compute-pass => engine/passes}/impl/TemporalAccumulationPass.h (100%) rename src/{repository/engine => engine/repository}/EngineRepository.cpp (97%) rename src/{repository/engine => engine/repository}/EngineRepository.h (94%) rename src/{repository/abstract => engine/repository}/ResourceRepository.h (83%) rename src/{repository/runtime => engine/repository}/RuntimeRepository.h (100%) rename src/{repository/world => engine/repository}/WorldRepository.cpp (96%) rename src/{repository/world => engine/repository}/WorldRepository.h (73%) rename src/{service/buffer => engine/resource}/BufferInstance.cpp (63%) rename src/{service/buffer => engine/resource}/BufferInstance.h (93%) rename src/{service/framebuffer => engine/resource}/FrameBufferAttachment.cpp (81%) rename src/{service/framebuffer => engine/resource}/FrameBufferAttachment.h (90%) rename src/{service/framebuffer => engine/resource}/FrameBufferInstance.h (92%) rename src/{service/mesh => engine/resource}/MeshInstance.h (88%) rename src/{service/pipeline => engine/resource}/PipelineInstance.h (92%) rename src/{repository/abstract => engine/resource}/RuntimeResource.h (93%) rename src/{service/voxel => engine/resource}/SVOInstance.h (80%) rename src/{service/texture => engine/resource}/TextureInstance.h (83%) rename src/{service/buffer => engine/service}/BufferService.cpp (97%) rename src/{service/buffer => engine/service}/BufferService.h (95%) rename src/{service/camera => engine/service}/CameraService.cpp (98%) rename src/{service/camera => engine/service}/CameraService.h (94%) rename src/{service/passes => engine/service}/CommandBufferRecorderService.h (85%) rename src/{service/descriptor => engine/service}/DescriptorSetService.cpp (96%) rename src/{service/descriptor => engine/service}/DescriptorSetService.h (91%) rename src/{service/framebuffer => engine/service}/FrameBufferService.cpp (98%) rename src/{service/framebuffer => engine/service}/FrameBufferService.h (93%) rename src/{service/lights => engine/service}/LightService.cpp (90%) rename src/{service/lights => engine/service}/LightService.h (91%) rename src/{service/material => engine/service}/MaterialService.cpp (88%) rename src/{service/material => engine/service}/MaterialService.h (100%) rename src/{service/mesh => engine/service}/MeshService.cpp (84%) rename src/{service/mesh => engine/service}/MeshService.h (78%) rename src/{service/pipeline => engine/service}/PipelineService.cpp (97%) rename src/{service/pipeline => engine/service}/PipelineService.h (90%) rename src/{service/raytracing => engine/service}/RayTracingService.cpp (97%) rename src/{service/raytracing => engine/service}/RayTracingService.h (92%) rename src/{repository/streaming => engine/service}/StreamingService.cpp (87%) rename src/{repository/streaming => engine/service}/StreamingService.h (78%) rename src/{service/texture => engine/service}/TextureService.cpp (98%) rename src/{service/texture => engine/service}/TextureService.h (94%) rename src/{service/transform => engine/service}/TransformService.cpp (90%) rename src/{service/transform => engine/service}/TransformService.h (83%) rename src/{service/volumes => engine/service}/VolumeService.cpp (81%) rename src/{service/volumes => engine/service}/VolumeService.h (81%) rename src/{service/voxel => engine/service}/VoxelService.cpp (93%) rename src/{service/voxel => engine/service}/VoxelService.h (82%) rename src/{ => engine}/util/ImageUtils.h (100%) rename src/{ => engine}/util/ShaderUtil.cpp (94%) rename src/{ => engine}/util/ShaderUtil.h (94%) delete mode 100644 src/enum/LightType.h delete mode 100644 src/repository/dock/DockPosition.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e81faae2..1543f480 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,283 +7,281 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_PROTOTYPES") add_executable( metal_engine src/main.cpp - src/context/editor/EditorPanel.cpp - src/context/editor/EditorPanel.h - src/context/editor/abstract/IPanel.h - src/context/engine/EngineContext.cpp - src/context/engine/EngineContext.h - src/util/VulkanUtils.cpp - src/util/VulkanUtils.h - src/context/vulkan/VulkanContext.cpp - src/context/vulkan/VulkanContext.h - src/context/glfw/GLFWContext.cpp - src/context/glfw/GLFWContext.h - src/context/gui/GuiContext.cpp - src/context/gui/GuiContext.h - src/context/editor/dock-spaces/viewport/ViewportPanel.cpp - src/context/editor/dock-spaces/viewport/ViewportPanel.h - src/context/editor/dock-spaces/viewport/EngineFramePanel.cpp - src/context/editor/dock-spaces/viewport/EngineFramePanel.h - src/context/editor/dock-spaces/docks/AbstractDockPanel.h - src/context/ApplicationContext.cpp - src/context/ApplicationContext.h - src/context/editor/abstract/AbstractPanel.h - src/context/editor/abstract/AbstractPanel.cpp - src/common/interface/Synchornizable.h - src/service/camera/CameraService.cpp - src/service/camera/CameraService.h - src/service/camera/Camera.h - src/util/Util.h - src/common/inspection/Inspectable.h - src/common/inspection/Inspectable.cpp - src/common/inspection/InspectedField.h - src/context/editor/dock-spaces/inspector/InspectorPanel.cpp - src/context/editor/dock-spaces/inspector/InspectorPanel.h - src/context/editor/abstract/form/FormPanel.cpp - src/context/editor/abstract/form/FormPanel.h - src/context/editor/abstract/form/AccordionPanel.cpp - src/context/editor/abstract/form/AccordionPanel.h - src/enum/FieldType.h - src/common/inspection/InspectableMember.h + src/editor/EditorPanel.cpp + src/editor/EditorPanel.h + src/editor/abstract/IPanel.h + src/engine/EngineContext.cpp + src/engine/EngineContext.h + src/core/vulkan/VulkanUtils.cpp + src/core/vulkan/VulkanUtils.h + src/core/vulkan/VulkanContext.cpp + src/core/vulkan/VulkanContext.h + src/core/glfw/GLFWContext.cpp + src/core/glfw/GLFWContext.h + src/core/gui/GuiContext.cpp + src/core/gui/GuiContext.h + src/editor/dock-spaces/viewport/ViewportPanel.cpp + src/editor/dock-spaces/viewport/ViewportPanel.h + src/editor/dock-spaces/viewport/EngineFramePanel.cpp + src/editor/dock-spaces/viewport/EngineFramePanel.h + src/editor/dock-spaces/docks/AbstractDockPanel.h + src/ApplicationContext.cpp + src/ApplicationContext.h + src/editor/abstract/AbstractPanel.h + src/editor/abstract/AbstractPanel.cpp + src/common/Synchornizable.h + src/engine/service/CameraService.cpp + src/engine/service/CameraService.h + src/engine/dto/Camera.h + src/editor/util/Util.h + src/common/Inspectable.h + src/common/Inspectable.cpp + src/common/InspectedField.h + src/editor/dock-spaces/inspector/InspectorPanel.cpp + src/editor/dock-spaces/inspector/InspectorPanel.h + src/editor/abstract/form/FormPanel.cpp + src/editor/abstract/form/FormPanel.h + src/editor/abstract/form/AccordionPanel.cpp + src/editor/abstract/form/AccordionPanel.h + src/common/FieldType.h + src/common/InspectableMember.h src/common/AbstractRuntimeComponent.h - src/context/editor/abstract/form/types/BooleanField.cpp - src/context/editor/abstract/form/types/BooleanField.h - src/context/editor/abstract/form/types/IntField.cpp - src/context/editor/abstract/form/types/IntField.h - src/context/editor/abstract/form/types/FloatField.cpp - src/context/editor/abstract/form/types/FloatField.h - src/context/editor/abstract/form/types/MethodField.cpp - src/context/editor/abstract/form/types/MethodField.h - src/util/UIUtil.h - src/context/editor/dock-spaces/header/EditorHeaderPanel.cpp - src/context/editor/dock-spaces/header/EditorHeaderPanel.h - src/context/editor/dock-spaces/header/AsyncTaskPanel.cpp - src/context/editor/dock-spaces/header/AsyncTaskPanel.h - src/common/interface/Icons.h - src/service/dock/DockService.cpp - src/service/dock/DockService.h - src/repository/dock/DockRepository.h - src/repository/dock/DockDTO.h - src/repository/dock/DockSpace.h - src/repository/dock/DockPosition.h - src/context/editor/dock-spaces/docks/DockSpacePanel.cpp - src/context/editor/dock-spaces/docks/DockSpacePanel.h - src/repository/dock/DockSpace.cpp - src/service/theme/ThemeService.cpp - src/service/theme/ThemeService.h - src/repository/editor/EditorRepository.h - src/enum/engine-definitions.h - src/context/editor/dock-spaces/files/FilesPanel.cpp - src/context/editor/dock-spaces/files/FilesPanel.h - src/context/editor/dock-spaces/files/FilesListPanel.cpp - src/context/editor/dock-spaces/files/FilesListPanel.h - src/context/editor/dock-spaces/files/FilePreviewPanel.cpp - src/context/editor/dock-spaces/files/FilePreviewPanel.h - src/context/editor/dock-spaces/console/ConsolePanel.cpp - src/context/editor/dock-spaces/console/ConsolePanel.h - src/context/editor/dock-spaces/metrics/MetricsPanel.cpp - src/context/editor/dock-spaces/metrics/MetricsPanel.h - src/service/log/LogService.cpp - src/service/log/LogService.h - src/context/editor/dock-spaces/world/WorldPanel.cpp - src/context/editor/dock-spaces/world/WorldPanel.h - src/repository/abstract/RuntimeResource.h - src/util/ShaderUtil.cpp - src/util/ShaderUtil.h - src/service/pipeline/ShaderModule.cpp - src/service/pipeline/ShaderModule.h - src/context/engine/render-pass/AbstractRenderPass.cpp - src/context/engine/render-pass/AbstractRenderPass.h - src/service/abstract/AbstractResourceService.h - src/service/framebuffer/FrameBufferAttachment.h - src/repository/abstract/AbstractCoreRepository.h - src/service/framebuffer/FrameBufferService.cpp - src/service/framebuffer/FrameBufferService.h - src/service/framebuffer/FrameBufferInstance.h - src/service/pipeline/PipelineService.cpp - src/service/pipeline/PipelineService.h - src/service/pipeline/PipelineInstance.h - src/service/buffer/BufferService.cpp - src/service/buffer/BufferService.h - src/service/descriptor/DescriptorSetService.cpp - src/service/descriptor/DescriptorSetService.h - src/service/descriptor/DescriptorInstance.h - src/dto/buffers/GlobalDataUBO.h - src/repository/runtime/RuntimeRepository.h - src/service/buffer/BufferInstance.cpp - src/service/buffer/BufferInstance.h - src/service/mesh/MeshService.cpp - src/service/mesh/MeshService.h - src/service/mesh/MeshData.h - src/service/mesh/MeshInstance.h - src/util/FilesUtil.h - src/dto/file/FSEntry.h - src/enum/EntryType.h - src/context/editor/dock-spaces/files/FilesContext.h - src/util/FileDialogUtil.h - src/context/editor/dock-spaces/files/FilesHeaderPanel.cpp - src/context/editor/dock-spaces/files/FilesHeaderPanel.h - src/service/material/MaterialImporterService.cpp - src/service/material/MaterialImporterService.h - src/service/mesh/MeshImporterService.cpp - src/service/mesh/MeshImporterService.h - src/service/mesh/SceneImporterService.cpp - src/service/mesh/SceneImporterService.h - src/service/abstract/AbstractImporter.h - src/service/texture/TextureImporterService.cpp - src/service/texture/TextureImporterService.h - src/dto/file/EntryMetadata.h - src/service/texture/TextureData.h - src/service/texture/TextureService.cpp - src/service/texture/TextureService.h - src/service/files/FilesService.cpp - src/service/files/FilesService.h - src/service/files/FileImporterService.cpp - src/service/files/FileImporterService.h - src/context/editor/dock-spaces/files/FilesContext.cpp - src/service/mesh/VertexData.h - src/context/editor/dock-spaces/viewport/CameraPositionPanel.cpp - src/context/editor/dock-spaces/viewport/CameraPositionPanel.h - src/context/engine/render-pass/impl/tools/GridPass.cpp - src/context/engine/render-pass/impl/tools/GridPass.h - src/context/engine/passes/CommandBufferRecorder.cpp - src/context/engine/passes/CommandBufferRecorder.h - src/service/camera/Camera.cpp - src/repository/world/WorldRepository.cpp - src/repository/world/WorldRepository.h - src/repository/world/impl/MetadataComponent.h - src/enum/ComponentType.cpp - src/enum/ComponentType.h - src/repository/world/impl/AbstractComponent.h - src/repository/world/components/PrimitiveComponent.h - src/repository/world/components/TransformComponent.h - src/enum/ShadingMode.h - src/context/editor/dock-spaces/world/WorldHeaderPanel.cpp - src/context/editor/dock-spaces/world/WorldHeaderPanel.h - src/service/selection/SelectionService.cpp - src/service/selection/SelectionService.h - src/repository/world/impl/MetadataComponent.cpp - src/repository/world/components/TransformComponent.cpp - src/repository/world/components/PrimitiveComponent.cpp - src/context/editor/abstract/form/types/ResourceField.cpp - src/context/editor/abstract/form/types/ResourceField.h - src/context/editor/abstract/form/types/ColorField.cpp - src/context/editor/abstract/form/types/ColorField.h - src/context/editor/abstract/form/types/Vec4Field.cpp - src/context/editor/abstract/form/types/Vec4Field.h - src/context/editor/abstract/form/types/Vec3Field.cpp - src/context/editor/abstract/form/types/Vec3Field.h - src/context/editor/abstract/form/types/Vec2Field.cpp - src/context/editor/abstract/form/types/Vec2Field.h - src/context/editor/abstract/form/types/StringField.cpp - src/context/editor/abstract/form/types/StringField.h - src/context/editor/abstract/form/types/ResourceFilesPanel.h - src/context/editor/abstract/form/types/ResourceFilesPanel.cpp - src/repository/streaming/StreamingService.cpp - src/repository/streaming/StreamingService.h - src/enum/ResourceType.h - src/context/editor/dock-spaces/viewport/GizmoPanel.cpp - src/context/editor/dock-spaces/viewport/GizmoPanel.h - src/context/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp - src/context/editor/dock-spaces/viewport/ViewportHeaderPanel.h - src/context/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp - src/context/editor/dock-spaces/viewport/GizmoSettingsPanel.h - src/context/editor/abstract/form/types/QuatField.cpp - src/context/editor/abstract/form/types/QuatField.h - src/service/transform/TransformService.cpp - src/service/transform/TransformService.h - src/repository/world/impl/BoundingBox.h - src/service/voxel/impl/SparseVoxelOctreeBuilder.cpp - src/service/voxel/impl/SparseVoxelOctreeBuilder.h - src/service/voxel/impl/OctreeNode.cpp - src/service/voxel/impl/OctreeNode.h - src/service/voxel/impl/VoxelData.h - src/service/mesh/SceneData.h - src/context/engine/render-pass/impl/PostProcessingPass.cpp - src/context/engine/render-pass/impl/PostProcessingPass.h - src/context/engine/compute-pass/impl/HWRayTracingPass.cpp - src/context/engine/compute-pass/impl/HWRayTracingPass.h - src/service/raytracing/RayTracingService.cpp - src/service/raytracing/RayTracingService.h - src/service/pipeline/PipelineBuilder.h - src/service/framebuffer/FrameBufferAttachment.cpp - src/repository/engine/EngineRepository.cpp - src/repository/engine/EngineRepository.h - src/util/serialization-definitions.h - src/service/notification/NotificationService.cpp - src/service/notification/NotificationService.h - src/service/notification/AsyncTaskService.cpp - src/service/notification/AsyncTaskService.h - src/dto/Notification.h - src/enum/NotificationSeverity.h - src/service/voxel/impl/SparseVoxelOctreeData.h - src/context/engine/render-pass/impl/tools/SelectionOutlinePass.cpp - src/context/engine/render-pass/impl/tools/SelectionOutlinePass.h - src/service/picking/PickingService.cpp - src/service/picking/PickingService.h - src/service/voxel/SVOInstance.h - src/dto/buffers/TileInfoUBO.h - src/dto/buffers/LightData.h - src/context/engine/render-pass/impl/tools/IconsPass.cpp - src/context/engine/render-pass/impl/tools/IconsPass.h - src/context/engine/render-pass/impl/tools/SelectionIDPass.cpp - src/context/engine/render-pass/impl/tools/SelectionIDPass.h - src/repository/editor/EditorRepository.cpp - src/dto/push-constant/GridPushConstant.h - src/context/engine/compute-pass/AbstractComputePass.cpp - src/context/engine/compute-pass/AbstractComputePass.h - src/context/engine/passes/AbstractPass.cpp - src/context/engine/passes/AbstractPass.h - src/util/ImageUtils.h - src/service/material/MaterialService.cpp - src/service/material/MaterialService.h - src/enum/LightType.h - src/service/lights/LightService.cpp - src/service/lights/LightService.h - src/repository/world/components/VolumeComponent.cpp - src/repository/world/components/VolumeComponent.h - src/service/descriptor/DescriptorBinding.h - src/service/notification/AsyncTask.h - src/service/voxel/VoxelImporterService.cpp - src/service/voxel/VoxelImporterService.h - src/dto/buffers/VolumeData.h - src/service/voxel/VoxelService.cpp - src/service/voxel/VoxelService.h - src/util/Serializable.cpp - src/context/editor/abstract/form/ChildPanel.cpp - src/context/editor/abstract/form/ChildPanel.h - src/dto/file/SceneImportSettingsDTO.h - src/context/editor/panel/NotificationsPanel.cpp - src/context/editor/panel/NotificationsPanel.h - src/context/editor/panel/FileImportModalPanel.cpp - src/context/editor/panel/FileImportModalPanel.h - src/context/engine/frame-builder/EngineFrameBuilder.cpp - src/context/engine/frame-builder/EngineFrameBuilder.h - src/context/engine/frame-builder/EngineFrame.cpp - src/context/engine/frame-builder/EngineFrame.h - src/context/engine/frame-builder/structures/FramebufferBuilder.cpp - src/context/engine/frame-builder/structures/FramebufferBuilder.h - src/context/engine/frame-builder/structures/TextureBuilder.cpp - src/context/engine/frame-builder/structures/TextureBuilder.h - src/context/engine/frame-builder/structures/BufferBuilder.cpp - src/context/engine/frame-builder/structures/BufferBuilder.h - src/context/engine/frame-builder/structures/ResourceBuilder.h - src/service/pipeline/PipelineBuilder.cpp - src/service/descriptor/DescriptorSetService.cpp - src/context/engine/frame-builder/structures/PassBuilder.cpp - src/context/engine/frame-builder/structures/CommandBufferRecorderBuilder.cpp - src/common/interface/Changeable.h - src/context/engine/compute-pass/impl/TemporalAccumulationPass.cpp - src/context/engine/compute-pass/impl/TemporalAccumulationPass.h - src/context/engine/compute-pass/impl/SpatialFilterPass.cpp - src/context/engine/compute-pass/impl/SpatialFilterPass.h - src/enum/ComponentType.cpp - src/service/mesh/SceneEntityData.h - src/context/editor/dock-spaces/repositories/RepositoriesPanel.cpp - src/context/editor/dock-spaces/repositories/RepositoriesPanel.h - src/service/volumes/VolumeService.cpp - src/service/volumes/VolumeService.h - src/repository/dock/DockRepository.cpp + src/editor/abstract/form/types/BooleanField.cpp + src/editor/abstract/form/types/BooleanField.h + src/editor/abstract/form/types/IntField.cpp + src/editor/abstract/form/types/IntField.h + src/editor/abstract/form/types/FloatField.cpp + src/editor/abstract/form/types/FloatField.h + src/editor/abstract/form/types/MethodField.cpp + src/editor/abstract/form/types/MethodField.h + src/editor/util/UIUtil.h + src/editor/dock-spaces/header/EditorHeaderPanel.cpp + src/editor/dock-spaces/header/EditorHeaderPanel.h + src/editor/dock-spaces/header/AsyncTaskPanel.cpp + src/editor/dock-spaces/header/AsyncTaskPanel.h + src/common/Icons.h + src/editor/service/DockService.cpp + src/editor/service/DockService.h + src/editor/repository/DockRepository.h + src/editor/dto/DockDTO.h + src/editor/dto/DockSpace.h + src/editor/dock-spaces/docks/DockSpacePanel.cpp + src/editor/dock-spaces/docks/DockSpacePanel.h + src/editor/dto/DockSpace.cpp + src/editor/service/ThemeService.cpp + src/editor/service/ThemeService.h + src/editor/repository/EditorRepository.h + src/editor/enum/engine-definitions.h + src/editor/dock-spaces/files/FilesPanel.cpp + src/editor/dock-spaces/files/FilesPanel.h + src/editor/dock-spaces/files/FilesListPanel.cpp + src/editor/dock-spaces/files/FilesListPanel.h + src/editor/dock-spaces/files/FilePreviewPanel.cpp + src/editor/dock-spaces/files/FilePreviewPanel.h + src/editor/dock-spaces/console/ConsolePanel.cpp + src/editor/dock-spaces/console/ConsolePanel.h + src/editor/dock-spaces/metrics/MetricsPanel.cpp + src/editor/dock-spaces/metrics/MetricsPanel.h + src/editor/service/LogService.cpp + src/editor/service/LogService.h + src/editor/dock-spaces/world/WorldPanel.cpp + src/editor/dock-spaces/world/WorldPanel.h + src/engine/resource/RuntimeResource.h + src/engine/util/ShaderUtil.cpp + src/engine/util/ShaderUtil.h + src/engine/dto/ShaderModule.cpp + src/engine/dto/ShaderModule.h + src/engine/passes/AbstractRenderPass.cpp + src/engine/passes/AbstractRenderPass.h + src/common/AbstractResourceService.h + src/engine/resource/FrameBufferAttachment.h + src/common/AbstractCoreRepository.h + src/engine/service/FrameBufferService.cpp + src/engine/service/FrameBufferService.h + src/engine/resource/FrameBufferInstance.h + src/engine/service/PipelineService.cpp + src/engine/service/PipelineService.h + src/engine/resource/PipelineInstance.h + src/engine/service/BufferService.cpp + src/engine/service/BufferService.h + src/engine/service/DescriptorSetService.cpp + src/engine/service/DescriptorSetService.h + src/engine/dto/DescriptorInstance.h + src/engine/dto/GlobalDataUBO.h + src/engine/repository/RuntimeRepository.h + src/engine/resource/BufferInstance.cpp + src/engine/resource/BufferInstance.h + src/engine/service/MeshService.cpp + src/engine/service/MeshService.h + src/engine/dto/MeshData.h + src/engine/resource/MeshInstance.h + src/editor/util/FilesUtil.h + src/editor/dto/FSEntry.h + src/editor/enum/EntryType.h + src/editor/dock-spaces/files/FilesContext.h + src/editor/util/FileDialogUtil.h + src/editor/dock-spaces/files/FilesHeaderPanel.cpp + src/editor/dock-spaces/files/FilesHeaderPanel.h + src/editor/service/MaterialImporterService.cpp + src/editor/service/MaterialImporterService.h + src/editor/service/MeshImporterService.cpp + src/editor/service/MeshImporterService.h + src/editor/service/SceneImporterService.cpp + src/editor/service/SceneImporterService.h + src/common/AbstractImporter.h + src/editor/service/TextureImporterService.cpp + src/editor/service/TextureImporterService.h + src/editor/dto/EntryMetadata.h + src/engine/dto/TextureData.h + src/engine/service/TextureService.cpp + src/engine/service/TextureService.h + src/editor/service/FilesService.cpp + src/editor/service/FilesService.h + src/editor/service/FileImporterService.cpp + src/editor/service/FileImporterService.h + src/editor/dock-spaces/files/FilesContext.cpp + src/engine/dto/VertexData.h + src/editor/dock-spaces/viewport/CameraPositionPanel.cpp + src/editor/dock-spaces/viewport/CameraPositionPanel.h + src/editor/passes/GridPass.cpp + src/editor/passes/GridPass.h + src/engine/passes/CommandBufferRecorder.cpp + src/engine/passes/CommandBufferRecorder.h + src/engine/dto/Camera.cpp + src/engine/repository/WorldRepository.cpp + src/engine/repository/WorldRepository.h + src/engine/dto/MetadataComponent.h + src/engine/enum/ComponentType.cpp + src/engine/enum/ComponentType.h + src/engine/dto/AbstractComponent.h + src/engine/dto/PrimitiveComponent.h + src/engine/dto/TransformComponent.h + src/editor/enum/ShadingMode.h + src/editor/dock-spaces/world/WorldHeaderPanel.cpp + src/editor/dock-spaces/world/WorldHeaderPanel.h + src/editor/service/SelectionService.cpp + src/editor/service/SelectionService.h + src/engine/dto/MetadataComponent.cpp + src/engine/dto/TransformComponent.cpp + src/engine/dto/PrimitiveComponent.cpp + src/editor/abstract/form/types/ResourceField.cpp + src/editor/abstract/form/types/ResourceField.h + src/editor/abstract/form/types/ColorField.cpp + src/editor/abstract/form/types/ColorField.h + src/editor/abstract/form/types/Vec4Field.cpp + src/editor/abstract/form/types/Vec4Field.h + src/editor/abstract/form/types/Vec3Field.cpp + src/editor/abstract/form/types/Vec3Field.h + src/editor/abstract/form/types/Vec2Field.cpp + src/editor/abstract/form/types/Vec2Field.h + src/editor/abstract/form/types/StringField.cpp + src/editor/abstract/form/types/StringField.h + src/editor/abstract/form/types/ResourceFilesPanel.h + src/editor/abstract/form/types/ResourceFilesPanel.cpp + src/engine/service/StreamingService.cpp + src/engine/service/StreamingService.h + src/engine/enum/ResourceType.h + src/editor/dock-spaces/viewport/GizmoPanel.cpp + src/editor/dock-spaces/viewport/GizmoPanel.h + src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp + src/editor/dock-spaces/viewport/ViewportHeaderPanel.h + src/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp + src/editor/dock-spaces/viewport/GizmoSettingsPanel.h + src/editor/abstract/form/types/QuatField.cpp + src/editor/abstract/form/types/QuatField.h + src/engine/service/TransformService.cpp + src/engine/service/TransformService.h + src/engine/dto/BoundingBox.h + src/editor/dto/SparseVoxelOctreeBuilder.cpp + src/editor/dto/SparseVoxelOctreeBuilder.h + src/editor/dto/OctreeNode.cpp + src/editor/dto/OctreeNode.h + src/engine/dto/VoxelData.h + src/editor/dto/SceneData.h + src/engine/passes/impl/PostProcessingPass.cpp + src/engine/passes/impl/PostProcessingPass.h + src/engine/passes/impl/HWRayTracingPass.cpp + src/engine/passes/impl/HWRayTracingPass.h + src/engine/service/RayTracingService.cpp + src/engine/service/RayTracingService.h + src/engine/dto/PipelineBuilder.h + src/engine/resource/FrameBufferAttachment.cpp + src/engine/repository/EngineRepository.cpp + src/engine/repository/EngineRepository.h + src/editor/util/serialization-definitions.h + src/editor/service/NotificationService.cpp + src/editor/service/NotificationService.h + src/editor/service/AsyncTaskService.cpp + src/editor/service/AsyncTaskService.h + src/editor/dto/Notification.h + src/editor/enum/NotificationSeverity.h + src/engine/dto/SparseVoxelOctreeData.h + src/editor/passes/SelectionOutlinePass.cpp + src/editor/passes/SelectionOutlinePass.h + src/editor/service/PickingService.cpp + src/editor/service/PickingService.h + src/engine/resource/SVOInstance.h + src/engine/dto/TileInfoUBO.h + src/engine/dto/LightData.h + src/editor/passes/IconsPass.cpp + src/editor/passes/IconsPass.h + src/editor/passes/SelectionIDPass.cpp + src/editor/passes/SelectionIDPass.h + src/editor/repository/EditorRepository.cpp + src/editor/dto/GridPushConstant.h + src/engine/passes/AbstractComputePass.cpp + src/engine/passes/AbstractComputePass.h + src/engine/passes/AbstractPass.cpp + src/engine/passes/AbstractPass.h + src/engine/util/ImageUtils.h + src/engine/service/MaterialService.cpp + src/engine/service/MaterialService.h + src/engine/service/LightService.cpp + src/engine/service/LightService.h + src/engine/dto/VolumeComponent.cpp + src/engine/dto/VolumeComponent.h + src/engine/dto/DescriptorBinding.h + src/editor/dto/AsyncTask.h + src/editor/service/VoxelImporterService.cpp + src/editor/service/VoxelImporterService.h + src/engine/dto/VolumeData.h + src/engine/service/VoxelService.cpp + src/engine/service/VoxelService.h + src/common/Serializable.cpp + src/editor/abstract/form/ChildPanel.cpp + src/editor/abstract/form/ChildPanel.h + src/editor/dto/SceneImportSettingsDTO.h + src/editor/panel/NotificationsPanel.cpp + src/editor/panel/NotificationsPanel.h + src/editor/panel/FileImportModalPanel.cpp + src/editor/panel/FileImportModalPanel.h + src/engine/frame-builder/EngineFrameBuilder.cpp + src/engine/frame-builder/EngineFrameBuilder.h + src/engine/frame-builder/EngineFrame.cpp + src/engine/frame-builder/EngineFrame.h + src/engine/frame-builder/structures/FramebufferBuilder.cpp + src/engine/frame-builder/structures/FramebufferBuilder.h + src/engine/frame-builder/structures/TextureBuilder.cpp + src/engine/frame-builder/structures/TextureBuilder.h + src/engine/frame-builder/structures/BufferBuilder.cpp + src/engine/frame-builder/structures/BufferBuilder.h + src/engine/frame-builder/structures/ResourceBuilder.h + src/engine/dto/PipelineBuilder.cpp + src/engine/service/DescriptorSetService.cpp + src/engine/frame-builder/structures/PassBuilder.cpp + src/engine/frame-builder/structures/CommandBufferRecorderBuilder.cpp + src/common/Changeable.h + src/engine/passes/impl/TemporalAccumulationPass.cpp + src/engine/passes/impl/TemporalAccumulationPass.h + src/engine/passes/impl/SpatialFilterPass.cpp + src/engine/passes/impl/SpatialFilterPass.h + src/engine/enum/ComponentType.cpp + src/editor/dto/SceneEntityData.h + src/editor/dock-spaces/repositories/RepositoriesPanel.cpp + src/editor/dock-spaces/repositories/RepositoriesPanel.h + src/engine/service/VolumeService.cpp + src/engine/service/VolumeService.h + src/editor/repository/DockRepository.cpp ) diff --git a/src/context/ApplicationContext.cpp b/src/ApplicationContext.cpp similarity index 96% rename from src/context/ApplicationContext.cpp rename to src/ApplicationContext.cpp index f489b20b..fba64246 100644 --- a/src/context/ApplicationContext.cpp +++ b/src/ApplicationContext.cpp @@ -1,13 +1,13 @@ -#include "ApplicationContext.h" +#include "context/ApplicationContext.h" #include #include -#include "../util/FilesUtil.h" -#include "../util/VulkanUtils.h" -#include "../util/serialization-definitions.h" +#include "editor/util/FilesUtil.h" +#include "vulkan/VulkanUtils.h" +#include "editor/util/serialization-definitions.h" -#include "../util/FileDialogUtil.h" +#include "editor/util/FileDialogUtil.h" #include namespace Metal { diff --git a/src/context/ApplicationContext.h b/src/ApplicationContext.h similarity index 69% rename from src/context/ApplicationContext.h rename to src/ApplicationContext.h index aad857a1..08ace4d5 100644 --- a/src/context/ApplicationContext.h +++ b/src/ApplicationContext.h @@ -7,41 +7,41 @@ #include "glfw/GLFWContext.h" #include "vulkan/VulkanContext.h" -#include "../service/mesh/MeshService.h" -#include "../service/texture/TextureService.h" -#include "../service/framebuffer/FrameBufferService.h" -#include "../service/pipeline/PipelineService.h" -#include "../service/buffer/BufferService.h" -#include "../service/descriptor/DescriptorSetService.h" -#include "../service/theme/ThemeService.h" -#include "../service/dock/DockService.h" -#include "../service/selection/SelectionService.h" -#include "../service/mesh/SceneImporterService.h" -#include "../service/mesh/MeshImporterService.h" -#include "../service/material/MaterialImporterService.h" -#include "../service/texture/TextureImporterService.h" -#include "../service/files/FilesService.h" -#include "../service/files/FileImporterService.h" -#include "../service/camera/CameraService.h" - -#include "../repository/world/WorldRepository.h" -#include "../repository/runtime/RuntimeRepository.h" -#include "../repository/streaming/StreamingService.h" -#include "../repository/engine/EngineRepository.h" -#include "../repository/dock/DockRepository.h" -#include "../repository/editor/EditorRepository.h" -#include "../service/material/MaterialService.h" -#include "../service/passes/CommandBufferRecorderService.h" +#include "engine/service/MeshService.h" +#include "engine/service/TextureService.h" +#include "engine/service/FrameBufferService.h" +#include "engine/service/PipelineService.h" +#include "engine/service/BufferService.h" +#include "engine/service/DescriptorSetService.h" +#include "editor/service/ThemeService.h" +#include "editor/service/DockService.h" +#include "editor/service/SelectionService.h" +#include "editor/service/SceneImporterService.h" +#include "editor/service/MeshImporterService.h" +#include "editor/service/MaterialImporterService.h" +#include "editor/service/TextureImporterService.h" +#include "editor/service/FilesService.h" +#include "editor/service/FileImporterService.h" +#include "engine/service/CameraService.h" + +#include "engine/repository/WorldRepository.h" +#include "engine/repository/RuntimeRepository.h" +#include "engine/service/StreamingService.h" +#include "engine/repository/EngineRepository.h" +#include "editor/repository/DockRepository.h" +#include "editor/repository/EditorRepository.h" +#include "engine/service/MaterialService.h" +#include "engine/service/CommandBufferRecorderService.h" #include "../service/notification/NotificationService.h" -#include "../service/notification/AsyncTaskService.h" -#include "../service/log/LogService.h" -#include "../service/transform/TransformService.h" -#include "../service/picking/PickingService.h" -#include "../service/volumes/VolumeService.h" -#include "../service/voxel/VoxelImporterService.h" +#include "editor/service/AsyncTaskService.h" +#include "editor/service/LogService.h" +#include "engine/service/TransformService.h" +#include "editor/service/PickingService.h" +#include "engine/service/VolumeService.h" +#include "editor/service/VoxelImporterService.h" #include "../service/voxel/VoxelService.h" -#include "../service/lights/LightService.h" -#include "../service/raytracing/RayTracingService.h" +#include "engine/service/LightService.h" +#include "engine/service/RayTracingService.h" #include "editor/EditorPanel.h" #include "gui/GuiContext.h" diff --git a/src/repository/abstract/AbstractCoreRepository.h b/src/common/AbstractCoreRepository.h similarity index 86% rename from src/repository/abstract/AbstractCoreRepository.h rename to src/common/AbstractCoreRepository.h index 30369685..93631a01 100644 --- a/src/repository/abstract/AbstractCoreRepository.h +++ b/src/common/AbstractCoreRepository.h @@ -1,6 +1,6 @@ #ifndef ABSTRACTCOREREPOSITORY_H #define ABSTRACTCOREREPOSITORY_H -#include "../../common/AbstractRuntimeComponent.h" +#include "AbstractRuntimeComponent.h" namespace Metal { class VulkanContext; diff --git a/src/service/abstract/AbstractImporter.h b/src/common/AbstractImporter.h similarity index 91% rename from src/service/abstract/AbstractImporter.h rename to src/common/AbstractImporter.h index 4998a7a4..24e05029 100644 --- a/src/service/abstract/AbstractImporter.h +++ b/src/common/AbstractImporter.h @@ -4,8 +4,8 @@ #include #include -#include "../../dto/file/ImportSettingsDTO.h" -#include "../../common/AbstractRuntimeComponent.h" +#include "../context/editor/dto/ImportSettingsDTO.h" +#include "AbstractRuntimeComponent.h" namespace Metal { class AbstractImporter : public AbstractRuntimeComponent { diff --git a/src/service/abstract/AbstractResourceService.h b/src/common/AbstractResourceService.h similarity index 94% rename from src/service/abstract/AbstractResourceService.h rename to src/common/AbstractResourceService.h index 0d95c189..c94287d4 100644 --- a/src/service/abstract/AbstractResourceService.h +++ b/src/common/AbstractResourceService.h @@ -4,8 +4,8 @@ #include #include -#include "../../common/AbstractRuntimeComponent.h" -#include "../../repository/abstract/RuntimeResource.h" +#include "AbstractRuntimeComponent.h" +#include "../context/engine/resource/RuntimeResource.h" namespace Metal { class VulkanContext; diff --git a/src/common/AbstractRuntimeComponent.h b/src/common/AbstractRuntimeComponent.h index f8e18f3b..f2b753b1 100644 --- a/src/common/AbstractRuntimeComponent.h +++ b/src/common/AbstractRuntimeComponent.h @@ -1,9 +1,9 @@ #ifndef METAL_ENGINE_ABSTRACTRUNTIMECOMPONENT_H #define METAL_ENGINE_ABSTRACTRUNTIMECOMPONENT_H -#include "interface/Changeable.h" -#include "interface/Initializable.h" -#include "interface/Synchornizable.h" +#include "Changeable.h" +#include "Initializable.h" +#include "Synchornizable.h" #define ENGINE_NAME "Metal Engine" diff --git a/src/common/interface/Changeable.h b/src/common/Changeable.h similarity index 100% rename from src/common/interface/Changeable.h rename to src/common/Changeable.h diff --git a/src/enum/FieldType.h b/src/common/FieldType.h similarity index 100% rename from src/enum/FieldType.h rename to src/common/FieldType.h diff --git a/src/common/interface/Icons.h b/src/common/Icons.h similarity index 100% rename from src/common/interface/Icons.h rename to src/common/Icons.h diff --git a/src/common/interface/Initializable.h b/src/common/Initializable.h similarity index 100% rename from src/common/interface/Initializable.h rename to src/common/Initializable.h diff --git a/src/common/inspection/Inspectable.cpp b/src/common/Inspectable.cpp similarity index 95% rename from src/common/inspection/Inspectable.cpp rename to src/common/Inspectable.cpp index 0bc87b75..a0c0b207 100644 --- a/src/common/inspection/Inspectable.cpp +++ b/src/common/Inspectable.cpp @@ -1,14 +1,14 @@ -#include "Inspectable.h" +#include "inspection/Inspectable.h" #include #include #include #include -#include "InspectedField.h" -#include "InspectedMethod.h" -#include "../../util/Util.h" -#include "../../enum/EntryType.h" +#include "inspection/InspectedField.h" +#include "inspection/InspectedMethod.h" +#include "../context/editor/util/Util.h" +#include "../context/editor/enum/EntryType.h" #define DECLARATION(T, V) \ std::shared_ptr> field = std::make_shared>(&v);\ diff --git a/src/common/inspection/Inspectable.h b/src/common/Inspectable.h similarity index 97% rename from src/common/inspection/Inspectable.h rename to src/common/Inspectable.h index 990de344..1c3df071 100644 --- a/src/common/inspection/Inspectable.h +++ b/src/common/Inspectable.h @@ -7,9 +7,9 @@ #include #include "InspectableMember.h" -#include "../../util/Util.h" -#include "../../enum/EntryType.h" -#include "../interface/Changeable.h" +#include "../context/editor/util/Util.h" +#include "../context/editor/enum/EntryType.h" +#include "Changeable.h" namespace Metal { class Inspectable : public Changeable { diff --git a/src/common/inspection/InspectableMember.h b/src/common/InspectableMember.h similarity index 92% rename from src/common/inspection/InspectableMember.h rename to src/common/InspectableMember.h index dacc8336..08a7ed6e 100644 --- a/src/common/inspection/InspectableMember.h +++ b/src/common/InspectableMember.h @@ -1,7 +1,7 @@ #ifndef METAL_ENGINE_INSPECTABLEMEMBER_H #define METAL_ENGINE_INSPECTABLEMEMBER_H -#include "../../enum/FieldType.h" +#include "FieldType.h" namespace Metal { class Inspectable; diff --git a/src/common/inspection/InspectedField.h b/src/common/InspectedField.h similarity index 92% rename from src/common/inspection/InspectedField.h rename to src/common/InspectedField.h index 9c50c1ce..08b2b22e 100644 --- a/src/common/inspection/InspectedField.h +++ b/src/common/InspectedField.h @@ -4,7 +4,7 @@ #include #include "InspectableMember.h" -#include "../../enum/EntryType.h" +#include "../context/editor/enum/EntryType.h" namespace Metal { template diff --git a/src/common/inspection/InspectedMethod.h b/src/common/InspectedMethod.h similarity index 100% rename from src/common/inspection/InspectedMethod.h rename to src/common/InspectedMethod.h diff --git a/src/util/Serializable.cpp b/src/common/Serializable.cpp similarity index 86% rename from src/util/Serializable.cpp rename to src/common/Serializable.cpp index d7913ae7..98d46573 100644 --- a/src/util/Serializable.cpp +++ b/src/common/Serializable.cpp @@ -1,9 +1,9 @@ -#include "Serializable.h" -#include "../context/ApplicationContext.h" +#include "../util/Serializable.h" +#include "../ApplicationContext.h" #include #include #include -#include "../service/log/LogService.h" +#include "../context/editor/service/LogService.h" namespace Metal { void Serializable::saveToJson(const std::string &path) const { diff --git a/src/util/Serializable.h b/src/common/Serializable.h similarity index 100% rename from src/util/Serializable.h rename to src/common/Serializable.h diff --git a/src/common/interface/Synchornizable.h b/src/common/Synchornizable.h similarity index 100% rename from src/common/interface/Synchornizable.h rename to src/common/Synchornizable.h diff --git a/src/context/glfw/GLFWContext.cpp b/src/core/glfw/GLFWContext.cpp similarity index 99% rename from src/context/glfw/GLFWContext.cpp rename to src/core/glfw/GLFWContext.cpp index b819dc08..333ad510 100644 --- a/src/context/glfw/GLFWContext.cpp +++ b/src/core/glfw/GLFWContext.cpp @@ -1,7 +1,7 @@ #include #include "GLFWContext.h" #include "../ApplicationContext.h" -#include "../../util/VulkanUtils.h" +#include "../vulkan/VulkanUtils.h" namespace Metal { GLFWwindow *GLFWContext::getWindow() const { diff --git a/src/context/glfw/GLFWContext.h b/src/core/glfw/GLFWContext.h similarity index 100% rename from src/context/glfw/GLFWContext.h rename to src/core/glfw/GLFWContext.h diff --git a/src/context/gui/GuiContext.cpp b/src/core/gui/GuiContext.cpp similarity index 97% rename from src/context/gui/GuiContext.cpp rename to src/core/gui/GuiContext.cpp index f78080aa..c6ccbb2c 100644 --- a/src/context/gui/GuiContext.cpp +++ b/src/core/gui/GuiContext.cpp @@ -3,9 +3,9 @@ #include #include "imgui_freetype.h" #include "../ApplicationContext.h" -#include "../../util/VulkanUtils.h" -#include "../../service/descriptor/DescriptorInstance.h" -#include "../../service/texture/TextureInstance.h" +#include "../vulkan/VulkanUtils.h" +#include "../engine/dto/DescriptorInstance.h" +#include "../engine/resource/TextureInstance.h" namespace Metal { void GuiContext::endFrame() { diff --git a/src/context/gui/GuiContext.h b/src/core/gui/GuiContext.h similarity index 100% rename from src/context/gui/GuiContext.h rename to src/core/gui/GuiContext.h diff --git a/src/context/vulkan/VulkanContext.cpp b/src/core/vulkan/VulkanContext.cpp similarity index 99% rename from src/context/vulkan/VulkanContext.cpp rename to src/core/vulkan/VulkanContext.cpp index c2ef2593..0e5415b2 100644 --- a/src/context/vulkan/VulkanContext.cpp +++ b/src/core/vulkan/VulkanContext.cpp @@ -1,7 +1,7 @@ #include "VulkanContext.h" #include "VkBootstrap.h" -#include "../../util/VulkanUtils.h" +#include "VulkanUtils.h" #include "../ApplicationContext.h" namespace Metal { diff --git a/src/context/vulkan/VulkanContext.h b/src/core/vulkan/VulkanContext.h similarity index 100% rename from src/context/vulkan/VulkanContext.h rename to src/core/vulkan/VulkanContext.h diff --git a/src/util/VulkanUtils.cpp b/src/core/vulkan/VulkanUtils.cpp similarity index 90% rename from src/util/VulkanUtils.cpp rename to src/core/vulkan/VulkanUtils.cpp index 32bdd127..182dab58 100644 --- a/src/util/VulkanUtils.cpp +++ b/src/core/vulkan/VulkanUtils.cpp @@ -1,8 +1,8 @@ -#include "VulkanUtils.h" +#include "../../util/VulkanUtils.h" -#include "../../dependencies/vk-bootstrap/src/VkBootstrap.h" -#include "../context/ApplicationContext.h" -#include "../service/log/LogService.h" +#include "../../../dependencies/vk-bootstrap/src/VkBootstrap.h" +#include "../ApplicationContext.h" +#include "../editor/service/LogService.h" namespace Metal { void VulkanUtils::CheckVKResult(VkResult err) { diff --git a/src/util/VulkanUtils.h b/src/core/vulkan/VulkanUtils.h similarity index 100% rename from src/util/VulkanUtils.h rename to src/core/vulkan/VulkanUtils.h diff --git a/src/context/editor/EditorPanel.cpp b/src/editor/EditorPanel.cpp similarity index 97% rename from src/context/editor/EditorPanel.cpp rename to src/editor/EditorPanel.cpp index bbad6c87..2e70ba27 100644 --- a/src/context/editor/EditorPanel.cpp +++ b/src/editor/EditorPanel.cpp @@ -1,7 +1,7 @@ #include "EditorPanel.h" -#include "../../util/UIUtil.h" +#include "util/UIUtil.h" #include "../../context/ApplicationContext.h" -#include "../../dto/Notification.h" +#include "dto/Notification.h" #include "dock-spaces/header/EditorHeaderPanel.h" #include "panel/FileImportModalPanel.h" #include "panel/NotificationsPanel.h" diff --git a/src/context/editor/EditorPanel.h b/src/editor/EditorPanel.h similarity index 100% rename from src/context/editor/EditorPanel.h rename to src/editor/EditorPanel.h diff --git a/src/context/editor/abstract/AbstractPanel.cpp b/src/editor/abstract/AbstractPanel.cpp similarity index 95% rename from src/context/editor/abstract/AbstractPanel.cpp rename to src/editor/abstract/AbstractPanel.cpp index 93beda28..c4ab4cd6 100644 --- a/src/context/editor/abstract/AbstractPanel.cpp +++ b/src/editor/abstract/AbstractPanel.cpp @@ -1,5 +1,5 @@ #include "AbstractPanel.h" -#include "../../../util/Util.h" +#include "../util/Util.h" namespace Metal { void AbstractPanel::appendChild(AbstractPanel *panel) { diff --git a/src/context/editor/abstract/AbstractPanel.h b/src/editor/abstract/AbstractPanel.h similarity index 100% rename from src/context/editor/abstract/AbstractPanel.h rename to src/editor/abstract/AbstractPanel.h diff --git a/src/context/editor/abstract/IPanel.h b/src/editor/abstract/IPanel.h similarity index 67% rename from src/context/editor/abstract/IPanel.h rename to src/editor/abstract/IPanel.h index 3d024efa..8eba6fb6 100644 --- a/src/context/editor/abstract/IPanel.h +++ b/src/editor/abstract/IPanel.h @@ -1,8 +1,8 @@ #ifndef METAL_ENGINE_IPANEL_H #define METAL_ENGINE_IPANEL_H -#include "../../../common/interface/Synchornizable.h" -#include "../../../common/interface/Initializable.h" +#include "../../../common/Synchornizable.h" +#include "../../../common/Initializable.h" namespace Metal { class IPanel : public Syncronizable, public Initializable { diff --git a/src/context/editor/abstract/form/AbstractFormFieldPanel.h b/src/editor/abstract/form/AbstractFormFieldPanel.h similarity index 100% rename from src/context/editor/abstract/form/AbstractFormFieldPanel.h rename to src/editor/abstract/form/AbstractFormFieldPanel.h diff --git a/src/context/editor/abstract/form/AccordionPanel.cpp b/src/editor/abstract/form/AccordionPanel.cpp similarity index 100% rename from src/context/editor/abstract/form/AccordionPanel.cpp rename to src/editor/abstract/form/AccordionPanel.cpp diff --git a/src/context/editor/abstract/form/AccordionPanel.h b/src/editor/abstract/form/AccordionPanel.h similarity index 100% rename from src/context/editor/abstract/form/AccordionPanel.h rename to src/editor/abstract/form/AccordionPanel.h diff --git a/src/context/editor/abstract/form/ChildPanel.cpp b/src/editor/abstract/form/ChildPanel.cpp similarity index 100% rename from src/context/editor/abstract/form/ChildPanel.cpp rename to src/editor/abstract/form/ChildPanel.cpp diff --git a/src/context/editor/abstract/form/ChildPanel.h b/src/editor/abstract/form/ChildPanel.h similarity index 100% rename from src/context/editor/abstract/form/ChildPanel.h rename to src/editor/abstract/form/ChildPanel.h diff --git a/src/context/editor/abstract/form/FormPanel.cpp b/src/editor/abstract/form/FormPanel.cpp similarity index 97% rename from src/context/editor/abstract/form/FormPanel.cpp rename to src/editor/abstract/form/FormPanel.cpp index 3a48ef77..13aeb015 100644 --- a/src/context/editor/abstract/form/FormPanel.cpp +++ b/src/editor/abstract/form/FormPanel.cpp @@ -1,8 +1,8 @@ #include "FormPanel.h" #include "AccordionPanel.h" #include "ChildPanel.h" -#include "../../../../enum/FieldType.h" -#include "../../../../common/inspection/Inspectable.h" +#include "../../../../common/FieldType.h" +#include "../../../../common/Inspectable.h" #include "types/IntField.h" #include "types/FloatField.h" #include "types/BooleanField.h" diff --git a/src/context/editor/abstract/form/FormPanel.h b/src/editor/abstract/form/FormPanel.h similarity index 100% rename from src/context/editor/abstract/form/FormPanel.h rename to src/editor/abstract/form/FormPanel.h diff --git a/src/context/editor/abstract/form/types/BooleanField.cpp b/src/editor/abstract/form/types/BooleanField.cpp similarity index 93% rename from src/context/editor/abstract/form/types/BooleanField.cpp rename to src/editor/abstract/form/types/BooleanField.cpp index 38371db1..4f145c79 100644 --- a/src/context/editor/abstract/form/types/BooleanField.cpp +++ b/src/editor/abstract/form/types/BooleanField.cpp @@ -2,7 +2,7 @@ #include #include -#include "../../../../../common/inspection/Inspectable.h" +#include "../../../../../common/Inspectable.h" namespace Metal { BooleanField::BooleanField(InspectedField &field) : field(field) { diff --git a/src/context/editor/abstract/form/types/BooleanField.h b/src/editor/abstract/form/types/BooleanField.h similarity index 86% rename from src/context/editor/abstract/form/types/BooleanField.h rename to src/editor/abstract/form/types/BooleanField.h index 4cab6295..97c485d8 100644 --- a/src/context/editor/abstract/form/types/BooleanField.h +++ b/src/editor/abstract/form/types/BooleanField.h @@ -2,7 +2,7 @@ #define METAL_ENGINE_BOOLEANFIELD_H #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/inspection/InspectedField.h" +#include "../../../../../common/InspectedField.h" namespace Metal { class BooleanField final : public AbstractFormFieldPanel { diff --git a/src/context/editor/abstract/form/types/ColorField.cpp b/src/editor/abstract/form/types/ColorField.cpp similarity index 95% rename from src/context/editor/abstract/form/types/ColorField.cpp rename to src/editor/abstract/form/types/ColorField.cpp index 0b8cd911..985efafc 100644 --- a/src/context/editor/abstract/form/types/ColorField.cpp +++ b/src/editor/abstract/form/types/ColorField.cpp @@ -1,7 +1,7 @@ #include "ColorField.h" #include #include -#include "../../../../../common/inspection/Inspectable.h" +#include "../../../../../common/Inspectable.h" namespace Metal { ColorField::ColorField(InspectedField &field) : field(field) { diff --git a/src/context/editor/abstract/form/types/ColorField.h b/src/editor/abstract/form/types/ColorField.h similarity index 88% rename from src/context/editor/abstract/form/types/ColorField.h rename to src/editor/abstract/form/types/ColorField.h index 87d9aaac..07ea8eef 100644 --- a/src/context/editor/abstract/form/types/ColorField.h +++ b/src/editor/abstract/form/types/ColorField.h @@ -3,7 +3,7 @@ #include #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/inspection/InspectedField.h" +#include "../../../../../common/InspectedField.h" namespace Metal { class ColorField final : public AbstractFormFieldPanel { diff --git a/src/context/editor/abstract/form/types/FloatField.cpp b/src/editor/abstract/form/types/FloatField.cpp similarity index 94% rename from src/context/editor/abstract/form/types/FloatField.cpp rename to src/editor/abstract/form/types/FloatField.cpp index b431fae9..47252dc9 100644 --- a/src/context/editor/abstract/form/types/FloatField.cpp +++ b/src/editor/abstract/form/types/FloatField.cpp @@ -1,7 +1,7 @@ #include "FloatField.h" #include #include -#include "../../../../../common/inspection/Inspectable.h" +#include "../../../../../common/Inspectable.h" namespace Metal { void FloatField::onSync() { diff --git a/src/context/editor/abstract/form/types/FloatField.h b/src/editor/abstract/form/types/FloatField.h similarity index 86% rename from src/context/editor/abstract/form/types/FloatField.h rename to src/editor/abstract/form/types/FloatField.h index 41e7c8cd..509bfafa 100644 --- a/src/context/editor/abstract/form/types/FloatField.h +++ b/src/editor/abstract/form/types/FloatField.h @@ -2,7 +2,7 @@ #define METAL_ENGINE_FLOATFIELD_H #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/inspection/InspectedField.h" +#include "../../../../../common/InspectedField.h" namespace Metal { diff --git a/src/context/editor/abstract/form/types/IntField.cpp b/src/editor/abstract/form/types/IntField.cpp similarity index 94% rename from src/context/editor/abstract/form/types/IntField.cpp rename to src/editor/abstract/form/types/IntField.cpp index e4187b21..7f2fc001 100644 --- a/src/context/editor/abstract/form/types/IntField.cpp +++ b/src/editor/abstract/form/types/IntField.cpp @@ -1,7 +1,7 @@ #include "IntField.h" #include #include -#include "../../../../../common/inspection/Inspectable.h" +#include "../../../../../common/Inspectable.h" namespace Metal { void IntField::onSync() { diff --git a/src/context/editor/abstract/form/types/IntField.h b/src/editor/abstract/form/types/IntField.h similarity index 86% rename from src/context/editor/abstract/form/types/IntField.h rename to src/editor/abstract/form/types/IntField.h index 6c414468..6d8a2c68 100644 --- a/src/context/editor/abstract/form/types/IntField.h +++ b/src/editor/abstract/form/types/IntField.h @@ -2,7 +2,7 @@ #define METAL_ENGINE_INTFIELD_H #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/inspection/InspectedField.h" +#include "../../../../../common/InspectedField.h" namespace Metal { class IntField final : public AbstractFormFieldPanel { diff --git a/src/context/editor/abstract/form/types/MethodField.cpp b/src/editor/abstract/form/types/MethodField.cpp similarity index 100% rename from src/context/editor/abstract/form/types/MethodField.cpp rename to src/editor/abstract/form/types/MethodField.cpp diff --git a/src/context/editor/abstract/form/types/MethodField.h b/src/editor/abstract/form/types/MethodField.h similarity index 86% rename from src/context/editor/abstract/form/types/MethodField.h rename to src/editor/abstract/form/types/MethodField.h index 704a8b8c..145c8c6f 100644 --- a/src/context/editor/abstract/form/types/MethodField.h +++ b/src/editor/abstract/form/types/MethodField.h @@ -3,7 +3,7 @@ #define METAL_ENGINE_METHODFIELD_H #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/inspection/InspectedMethod.h" +#include "../../../../../common/InspectedMethod.h" namespace Metal { diff --git a/src/context/editor/abstract/form/types/QuatField.cpp b/src/editor/abstract/form/types/QuatField.cpp similarity index 93% rename from src/context/editor/abstract/form/types/QuatField.cpp rename to src/editor/abstract/form/types/QuatField.cpp index 24134b71..512648bb 100644 --- a/src/context/editor/abstract/form/types/QuatField.cpp +++ b/src/editor/abstract/form/types/QuatField.cpp @@ -2,8 +2,8 @@ #include #include #include -#include "../../../../../common/inspection/Inspectable.h" -#include "../../../../../util/UIUtil.h" +#include "../../../../../common/Inspectable.h" +#include "../../../util/UIUtil.h" namespace Metal { QuatField::QuatField(InspectedField &field) : field(field) { diff --git a/src/context/editor/abstract/form/types/QuatField.h b/src/editor/abstract/form/types/QuatField.h similarity index 88% rename from src/context/editor/abstract/form/types/QuatField.h rename to src/editor/abstract/form/types/QuatField.h index c2def953..ed6cd528 100644 --- a/src/context/editor/abstract/form/types/QuatField.h +++ b/src/editor/abstract/form/types/QuatField.h @@ -2,7 +2,7 @@ #define QUATFIELD_H #include #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/inspection/InspectedField.h" +#include "../../../../../common/InspectedField.h" namespace Metal { class QuatField final : public AbstractFormFieldPanel { diff --git a/src/context/editor/abstract/form/types/ResourceField.cpp b/src/editor/abstract/form/types/ResourceField.cpp similarity index 96% rename from src/context/editor/abstract/form/types/ResourceField.cpp rename to src/editor/abstract/form/types/ResourceField.cpp index 7bc9e88c..3c4fac3b 100644 --- a/src/context/editor/abstract/form/types/ResourceField.cpp +++ b/src/editor/abstract/form/types/ResourceField.cpp @@ -4,9 +4,9 @@ #include #include "ResourceFilesPanel.h" -#include "../../../../../common/interface/Icons.h" -#include "../../../../../util/UIUtil.h" -#include "../../../../../dto/file/FSEntry.h" +#include "../../../../../common/Icons.h" +#include "../../../util/UIUtil.h" +#include "../../../dto/FSEntry.h" #include "../../../../../context/ApplicationContext.h" #include "../../../../../common/inspection/Inspectable.h" diff --git a/src/context/editor/abstract/form/types/ResourceField.h b/src/editor/abstract/form/types/ResourceField.h similarity index 92% rename from src/context/editor/abstract/form/types/ResourceField.h rename to src/editor/abstract/form/types/ResourceField.h index 270b78db..308976da 100644 --- a/src/context/editor/abstract/form/types/ResourceField.h +++ b/src/editor/abstract/form/types/ResourceField.h @@ -4,7 +4,7 @@ #include #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/inspection/InspectedField.h" +#include "../../../../../common/InspectedField.h" #include "imgui.h" namespace Metal { diff --git a/src/context/editor/abstract/form/types/ResourceFilesPanel.cpp b/src/editor/abstract/form/types/ResourceFilesPanel.cpp similarity index 79% rename from src/context/editor/abstract/form/types/ResourceFilesPanel.cpp rename to src/editor/abstract/form/types/ResourceFilesPanel.cpp index a74cf470..7cf50247 100644 --- a/src/context/editor/abstract/form/types/ResourceFilesPanel.cpp +++ b/src/editor/abstract/form/types/ResourceFilesPanel.cpp @@ -1,8 +1,8 @@ #include "ResourceFilesPanel.h" -#include "../../../../../common/interface/Icons.h" -#include "../../../../../dto/file/FSEntry.h" -#include "../../../../../service/files/FilesService.h" +#include "../../../../../common/Icons.h" +#include "../../../dto/FSEntry.h" +#include "../../../service/FilesService.h" namespace Metal { std::function ResourceFilesPanel::onAction() { diff --git a/src/context/editor/abstract/form/types/ResourceFilesPanel.h b/src/editor/abstract/form/types/ResourceFilesPanel.h similarity index 100% rename from src/context/editor/abstract/form/types/ResourceFilesPanel.h rename to src/editor/abstract/form/types/ResourceFilesPanel.h diff --git a/src/context/editor/abstract/form/types/StringField.cpp b/src/editor/abstract/form/types/StringField.cpp similarity index 94% rename from src/context/editor/abstract/form/types/StringField.cpp rename to src/editor/abstract/form/types/StringField.cpp index 082b6bbb..2b6ec53d 100644 --- a/src/context/editor/abstract/form/types/StringField.cpp +++ b/src/editor/abstract/form/types/StringField.cpp @@ -1,7 +1,7 @@ #include "StringField.h" #include #include -#include "../../../../../common/inspection/Inspectable.h" +#include "../../../../../common/Inspectable.h" namespace Metal { StringField::StringField(InspectedField &field) : field(field) { diff --git a/src/context/editor/abstract/form/types/StringField.h b/src/editor/abstract/form/types/StringField.h similarity index 87% rename from src/context/editor/abstract/form/types/StringField.h rename to src/editor/abstract/form/types/StringField.h index 2b786379..3e543281 100644 --- a/src/context/editor/abstract/form/types/StringField.h +++ b/src/editor/abstract/form/types/StringField.h @@ -2,7 +2,7 @@ #define STRINGFIELD_H #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/inspection/InspectedField.h" +#include "../../../../../common/InspectedField.h" namespace Metal { diff --git a/src/context/editor/abstract/form/types/Vec2Field.cpp b/src/editor/abstract/form/types/Vec2Field.cpp similarity index 91% rename from src/context/editor/abstract/form/types/Vec2Field.cpp rename to src/editor/abstract/form/types/Vec2Field.cpp index d45d650d..d1d32756 100644 --- a/src/context/editor/abstract/form/types/Vec2Field.cpp +++ b/src/editor/abstract/form/types/Vec2Field.cpp @@ -1,8 +1,8 @@ #include "Vec2Field.h" #include #include -#include "../../../../../common/inspection/Inspectable.h" -#include "../../../../../util/UIUtil.h" +#include "../../../../../common/Inspectable.h" +#include "../../../util/UIUtil.h" namespace Metal { Vec2Field::Vec2Field(InspectedField &field) : field(field) { diff --git a/src/context/editor/abstract/form/types/Vec2Field.h b/src/editor/abstract/form/types/Vec2Field.h similarity index 88% rename from src/context/editor/abstract/form/types/Vec2Field.h rename to src/editor/abstract/form/types/Vec2Field.h index 11a57fc5..cbc6212e 100644 --- a/src/context/editor/abstract/form/types/Vec2Field.h +++ b/src/editor/abstract/form/types/Vec2Field.h @@ -4,7 +4,7 @@ #include #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/inspection/InspectedField.h" +#include "../../../../../common/InspectedField.h" namespace Metal { class Vec2Field final : public AbstractFormFieldPanel { diff --git a/src/context/editor/abstract/form/types/Vec3Field.cpp b/src/editor/abstract/form/types/Vec3Field.cpp similarity index 92% rename from src/context/editor/abstract/form/types/Vec3Field.cpp rename to src/editor/abstract/form/types/Vec3Field.cpp index e518b42e..471f2410 100644 --- a/src/context/editor/abstract/form/types/Vec3Field.cpp +++ b/src/editor/abstract/form/types/Vec3Field.cpp @@ -1,8 +1,8 @@ #include "Vec3Field.h" #include #include -#include "../../../../../common/inspection/Inspectable.h" -#include "../../../../../util/UIUtil.h" +#include "../../../../../common/Inspectable.h" +#include "../../../util/UIUtil.h" namespace Metal { Vec3Field::Vec3Field(InspectedField &field) : field(field) { diff --git a/src/context/editor/abstract/form/types/Vec3Field.h b/src/editor/abstract/form/types/Vec3Field.h similarity index 88% rename from src/context/editor/abstract/form/types/Vec3Field.h rename to src/editor/abstract/form/types/Vec3Field.h index 0bb06e56..dbd36eab 100644 --- a/src/context/editor/abstract/form/types/Vec3Field.h +++ b/src/editor/abstract/form/types/Vec3Field.h @@ -4,7 +4,7 @@ #include #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/inspection/InspectedField.h" +#include "../../../../../common/InspectedField.h" namespace Metal { diff --git a/src/context/editor/abstract/form/types/Vec4Field.cpp b/src/editor/abstract/form/types/Vec4Field.cpp similarity index 92% rename from src/context/editor/abstract/form/types/Vec4Field.cpp rename to src/editor/abstract/form/types/Vec4Field.cpp index 07cc3dde..8e5932f7 100644 --- a/src/context/editor/abstract/form/types/Vec4Field.cpp +++ b/src/editor/abstract/form/types/Vec4Field.cpp @@ -1,8 +1,8 @@ #include "Vec4Field.h" #include #include -#include "../../../../../common/inspection/Inspectable.h" -#include "../../../../../util/UIUtil.h" +#include "../../../../../common/Inspectable.h" +#include "../../../util/UIUtil.h" namespace Metal { Vec4Field::Vec4Field(InspectedField &field) : field(field) { diff --git a/src/context/editor/abstract/form/types/Vec4Field.h b/src/editor/abstract/form/types/Vec4Field.h similarity index 88% rename from src/context/editor/abstract/form/types/Vec4Field.h rename to src/editor/abstract/form/types/Vec4Field.h index 751c0efa..569fde21 100644 --- a/src/context/editor/abstract/form/types/Vec4Field.h +++ b/src/editor/abstract/form/types/Vec4Field.h @@ -3,7 +3,7 @@ #include #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/inspection/InspectedField.h" +#include "../../../../../common/InspectedField.h" namespace Metal { class Vec4Field final : public AbstractFormFieldPanel { diff --git a/src/context/editor/dock-spaces/console/ConsolePanel.cpp b/src/editor/dock-spaces/console/ConsolePanel.cpp similarity index 98% rename from src/context/editor/dock-spaces/console/ConsolePanel.cpp rename to src/editor/dock-spaces/console/ConsolePanel.cpp index c358eaea..4b2e40fe 100644 --- a/src/context/editor/dock-spaces/console/ConsolePanel.cpp +++ b/src/editor/dock-spaces/console/ConsolePanel.cpp @@ -2,7 +2,7 @@ #include "imgui.h" #include "../../../ApplicationContext.h" -#include "../../../../common/interface/Icons.h" +#include "../../../../common/Icons.h" namespace Metal { ConsolePanel::ConsolePanel() { diff --git a/src/context/editor/dock-spaces/console/ConsolePanel.h b/src/editor/dock-spaces/console/ConsolePanel.h similarity index 88% rename from src/context/editor/dock-spaces/console/ConsolePanel.h rename to src/editor/dock-spaces/console/ConsolePanel.h index 8417cb14..5a6e3ae7 100644 --- a/src/context/editor/dock-spaces/console/ConsolePanel.h +++ b/src/editor/dock-spaces/console/ConsolePanel.h @@ -1,7 +1,7 @@ #ifndef CONSOLEPANEL_H #define CONSOLEPANEL_H #include "../docks/AbstractDockPanel.h" -#include "../../../../service/log/LogService.h" +#include "../../service/LogService.h" #include "imgui.h" namespace Metal { diff --git a/src/context/editor/dock-spaces/docks/AbstractDockPanel.h b/src/editor/dock-spaces/docks/AbstractDockPanel.h similarity index 93% rename from src/context/editor/dock-spaces/docks/AbstractDockPanel.h rename to src/editor/dock-spaces/docks/AbstractDockPanel.h index 3f144a8d..997ddd68 100644 --- a/src/context/editor/dock-spaces/docks/AbstractDockPanel.h +++ b/src/editor/dock-spaces/docks/AbstractDockPanel.h @@ -5,7 +5,7 @@ #include #include "../../abstract/AbstractPanel.h" -#include "../../../../dto/ShortcutDTO.h" +#include "../../dto/ShortcutDTO.h" struct ImVec2; diff --git a/src/context/editor/dock-spaces/docks/DockSpacePanel.cpp b/src/editor/dock-spaces/docks/DockSpacePanel.cpp similarity index 97% rename from src/context/editor/dock-spaces/docks/DockSpacePanel.cpp rename to src/editor/dock-spaces/docks/DockSpacePanel.cpp index e07fe1ac..6a938445 100644 --- a/src/context/editor/dock-spaces/docks/DockSpacePanel.cpp +++ b/src/editor/dock-spaces/docks/DockSpacePanel.cpp @@ -5,10 +5,10 @@ #include "AbstractDockPanel.h" #include "../../../../context/ApplicationContext.h" -#include "../../../../common/interface/Icons.h" -#include "../../../../repository/dock/DockDTO.h" -#include "../../../../util/UIUtil.h" -#include "../../../../service/log/LogService.h" +#include "../../../../common/Icons.h" +#include "../../dto/DockDTO.h" +#include "../../util/UIUtil.h" +#include "../../service/LogService.h" namespace Metal { const ImVec2 DockSpacePanel::DEFAULT{-1.f, -1.f}; diff --git a/src/context/editor/dock-spaces/docks/DockSpacePanel.h b/src/editor/dock-spaces/docks/DockSpacePanel.h similarity index 100% rename from src/context/editor/dock-spaces/docks/DockSpacePanel.h rename to src/editor/dock-spaces/docks/DockSpacePanel.h diff --git a/src/context/editor/dock-spaces/files/FilePreviewPanel.cpp b/src/editor/dock-spaces/files/FilePreviewPanel.cpp similarity index 96% rename from src/context/editor/dock-spaces/files/FilePreviewPanel.cpp rename to src/editor/dock-spaces/files/FilePreviewPanel.cpp index 7c7c050b..18365979 100644 --- a/src/context/editor/dock-spaces/files/FilePreviewPanel.cpp +++ b/src/editor/dock-spaces/files/FilePreviewPanel.cpp @@ -1,9 +1,9 @@ #include "FilePreviewPanel.h" #include -#include "../../../../util/UIUtil.h" -#include "../../../../dto/file/FSEntry.h" +#include "../../util/UIUtil.h" +#include "../../dto/FSEntry.h" #include "../../../../context/ApplicationContext.h" -#include "../../../../service/texture/TextureInstance.h" +#include "../../../engine/resource/TextureInstance.h" namespace Metal { FilePreviewPanel::FilePreviewPanel(FilesContext &filesContext) : filesContext(filesContext) { diff --git a/src/context/editor/dock-spaces/files/FilePreviewPanel.h b/src/editor/dock-spaces/files/FilePreviewPanel.h similarity index 100% rename from src/context/editor/dock-spaces/files/FilePreviewPanel.h rename to src/editor/dock-spaces/files/FilePreviewPanel.h diff --git a/src/context/editor/dock-spaces/files/FilesContext.cpp b/src/editor/dock-spaces/files/FilesContext.cpp similarity index 91% rename from src/context/editor/dock-spaces/files/FilesContext.cpp rename to src/editor/dock-spaces/files/FilesContext.cpp index bd74434c..a85c2ef5 100644 --- a/src/context/editor/dock-spaces/files/FilesContext.cpp +++ b/src/editor/dock-spaces/files/FilesContext.cpp @@ -1,6 +1,6 @@ #include "FilesContext.h" -#include "../../../../dto/file/FSEntry.h" +#include "../../dto/FSEntry.h" #include namespace Metal { diff --git a/src/context/editor/dock-spaces/files/FilesContext.h b/src/editor/dock-spaces/files/FilesContext.h similarity index 94% rename from src/context/editor/dock-spaces/files/FilesContext.h rename to src/editor/dock-spaces/files/FilesContext.h index d50da76a..f7d32d0e 100644 --- a/src/context/editor/dock-spaces/files/FilesContext.h +++ b/src/editor/dock-spaces/files/FilesContext.h @@ -3,7 +3,7 @@ #include #include -#include "../../../../enum/EntryType.h" +#include "../../enum/EntryType.h" namespace Metal { diff --git a/src/context/editor/dock-spaces/files/FilesHeaderPanel.cpp b/src/editor/dock-spaces/files/FilesHeaderPanel.cpp similarity index 89% rename from src/context/editor/dock-spaces/files/FilesHeaderPanel.cpp rename to src/editor/dock-spaces/files/FilesHeaderPanel.cpp index 3924fb73..8a0f737b 100644 --- a/src/context/editor/dock-spaces/files/FilesHeaderPanel.cpp +++ b/src/editor/dock-spaces/files/FilesHeaderPanel.cpp @@ -1,11 +1,11 @@ #include "FilesHeaderPanel.h" -#include "../../../../enum/EntryType.h" -#include "../../../../dto/file/FSEntry.h" -#include "../../../../common/interface/Icons.h" -#include "../../../../util/FilesUtil.h" +#include "../../enum/EntryType.h" +#include "../../dto/FSEntry.h" +#include "../../../../common/Icons.h" +#include "../../util/FilesUtil.h" #include "../../../../context/ApplicationContext.h" -#include "../../../../util/UIUtil.h" +#include "../../util/UIUtil.h" namespace Metal { void FilesHeaderPanel::onSync() { diff --git a/src/context/editor/dock-spaces/files/FilesHeaderPanel.h b/src/editor/dock-spaces/files/FilesHeaderPanel.h similarity index 100% rename from src/context/editor/dock-spaces/files/FilesHeaderPanel.h rename to src/editor/dock-spaces/files/FilesHeaderPanel.h diff --git a/src/context/editor/dock-spaces/files/FilesListPanel.cpp b/src/editor/dock-spaces/files/FilesListPanel.cpp similarity index 98% rename from src/context/editor/dock-spaces/files/FilesListPanel.cpp rename to src/editor/dock-spaces/files/FilesListPanel.cpp index 54f75cd0..62bb60c0 100644 --- a/src/context/editor/dock-spaces/files/FilesListPanel.cpp +++ b/src/editor/dock-spaces/files/FilesListPanel.cpp @@ -2,10 +2,10 @@ #include "FilesPanel.h" #include "FilesContext.h" -#include "../../../../util/UIUtil.h" +#include "../../util/UIUtil.h" #include "../../../../context/ApplicationContext.h" -#include "../../../../dto/file//FSEntry.h" -#include "../../../../service/files/FilesService.h" +#include "../../dto/FSEntry.h" +#include "../../service/FilesService.h" #include namespace Metal { diff --git a/src/context/editor/dock-spaces/files/FilesListPanel.h b/src/editor/dock-spaces/files/FilesListPanel.h similarity index 100% rename from src/context/editor/dock-spaces/files/FilesListPanel.h rename to src/editor/dock-spaces/files/FilesListPanel.h diff --git a/src/context/editor/dock-spaces/files/FilesPanel.cpp b/src/editor/dock-spaces/files/FilesPanel.cpp similarity index 95% rename from src/context/editor/dock-spaces/files/FilesPanel.cpp rename to src/editor/dock-spaces/files/FilesPanel.cpp index 32f0e537..ab444e51 100644 --- a/src/context/editor/dock-spaces/files/FilesPanel.cpp +++ b/src/editor/dock-spaces/files/FilesPanel.cpp @@ -3,20 +3,20 @@ #include "FilesHeaderPanel.h" #include "FilesListPanel.h" -#include "../../../../common/interface/Icons.h" +#include "../../../../common/Icons.h" #include "../../../../context/ApplicationContext.h" -#include "../../../../service/mesh/SceneData.h" -#include "../../../../util/UIUtil.h" -#include "../../../../dto/file/FSEntry.h" -#include "../../../../dto/file/SceneImportSettingsDTO.h" +#include "../../dto/SceneData.h" +#include "../../util/UIUtil.h" +#include "../../dto/FSEntry.h" +#include "../../dto/SceneImportSettingsDTO.h" #include "FilesContext.h" -#include "../../../../util/FileDialogUtil.h" +#include "../../util/FileDialogUtil.h" #include "FilePreviewPanel.h" #include "../../abstract/form/FormPanel.h" #include #include -#include "../../../../util/FilesUtil.h" +#include "../../util/FilesUtil.h" namespace Metal { std::string FilesPanel::getActionLabel() { diff --git a/src/context/editor/dock-spaces/files/FilesPanel.h b/src/editor/dock-spaces/files/FilesPanel.h similarity index 95% rename from src/context/editor/dock-spaces/files/FilesPanel.h rename to src/editor/dock-spaces/files/FilesPanel.h index 6643805e..ea127a9f 100644 --- a/src/context/editor/dock-spaces/files/FilesPanel.h +++ b/src/editor/dock-spaces/files/FilesPanel.h @@ -6,7 +6,7 @@ #include "FilesContext.h" #include "../docks/AbstractDockPanel.h" -#include "../../../../dto/file/ImportSettingsDTO.h" +#include "../../dto/ImportSettingsDTO.h" namespace Metal { struct FSEntry; diff --git a/src/context/editor/dock-spaces/header/AsyncTaskPanel.cpp b/src/editor/dock-spaces/header/AsyncTaskPanel.cpp similarity index 98% rename from src/context/editor/dock-spaces/header/AsyncTaskPanel.cpp rename to src/editor/dock-spaces/header/AsyncTaskPanel.cpp index 80db3d2c..ba3626bc 100644 --- a/src/context/editor/dock-spaces/header/AsyncTaskPanel.cpp +++ b/src/editor/dock-spaces/header/AsyncTaskPanel.cpp @@ -1,6 +1,6 @@ #include "AsyncTaskPanel.h" #include "../../../../context/ApplicationContext.h" -#include "../../../../util/UIUtil.h" +#include "../../util/UIUtil.h" #include namespace Metal { diff --git a/src/context/editor/dock-spaces/header/AsyncTaskPanel.h b/src/editor/dock-spaces/header/AsyncTaskPanel.h similarity index 100% rename from src/context/editor/dock-spaces/header/AsyncTaskPanel.h rename to src/editor/dock-spaces/header/AsyncTaskPanel.h diff --git a/src/context/editor/dock-spaces/header/EditorHeaderPanel.cpp b/src/editor/dock-spaces/header/EditorHeaderPanel.cpp similarity index 98% rename from src/context/editor/dock-spaces/header/EditorHeaderPanel.cpp rename to src/editor/dock-spaces/header/EditorHeaderPanel.cpp index 01591466..719902c8 100644 --- a/src/context/editor/dock-spaces/header/EditorHeaderPanel.cpp +++ b/src/editor/dock-spaces/header/EditorHeaderPanel.cpp @@ -1,6 +1,6 @@ #include "EditorHeaderPanel.h" #include "AsyncTaskPanel.h" -#include "../../../../util/UIUtil.h" +#include "../../util/UIUtil.h" #include "../../../../context/ApplicationContext.h" namespace Metal { diff --git a/src/context/editor/dock-spaces/header/EditorHeaderPanel.h b/src/editor/dock-spaces/header/EditorHeaderPanel.h similarity index 100% rename from src/context/editor/dock-spaces/header/EditorHeaderPanel.h rename to src/editor/dock-spaces/header/EditorHeaderPanel.h diff --git a/src/context/editor/dock-spaces/inspector/InspectorPanel.cpp b/src/editor/dock-spaces/inspector/InspectorPanel.cpp similarity index 94% rename from src/context/editor/dock-spaces/inspector/InspectorPanel.cpp rename to src/editor/dock-spaces/inspector/InspectorPanel.cpp index 9a09e624..bd827a58 100644 --- a/src/context/editor/dock-spaces/inspector/InspectorPanel.cpp +++ b/src/editor/dock-spaces/inspector/InspectorPanel.cpp @@ -1,10 +1,10 @@ #include "InspectorPanel.h" #include "../../abstract/form/FormPanel.h" -#include "../../../../util/UIUtil.h" -#include "../../../../common/inspection/Inspectable.h" +#include "../../util/UIUtil.h" +#include "../../../../common/Inspectable.h" #include "../../../../context/ApplicationContext.h" -#include "../../../../repository/world/impl/MetadataComponent.h" +#include "../../../engine/dto/MetadataComponent.h" #include #include diff --git a/src/context/editor/dock-spaces/inspector/InspectorPanel.h b/src/editor/dock-spaces/inspector/InspectorPanel.h similarity index 91% rename from src/context/editor/dock-spaces/inspector/InspectorPanel.h rename to src/editor/dock-spaces/inspector/InspectorPanel.h index 5d024e96..69a3c411 100644 --- a/src/context/editor/dock-spaces/inspector/InspectorPanel.h +++ b/src/editor/dock-spaces/inspector/InspectorPanel.h @@ -1,7 +1,7 @@ #ifndef INSPECTOR_H #define INSPECTOR_H -#include "../../../../enum/engine-definitions.h" +#include "../../enum/engine-definitions.h" #include "../docks/AbstractDockPanel.h" namespace Metal { diff --git a/src/context/editor/dock-spaces/metrics/MetricsPanel.cpp b/src/editor/dock-spaces/metrics/MetricsPanel.cpp similarity index 100% rename from src/context/editor/dock-spaces/metrics/MetricsPanel.cpp rename to src/editor/dock-spaces/metrics/MetricsPanel.cpp diff --git a/src/context/editor/dock-spaces/metrics/MetricsPanel.h b/src/editor/dock-spaces/metrics/MetricsPanel.h similarity index 100% rename from src/context/editor/dock-spaces/metrics/MetricsPanel.h rename to src/editor/dock-spaces/metrics/MetricsPanel.h diff --git a/src/context/editor/dock-spaces/repositories/RepositoriesPanel.cpp b/src/editor/dock-spaces/repositories/RepositoriesPanel.cpp similarity index 91% rename from src/context/editor/dock-spaces/repositories/RepositoriesPanel.cpp rename to src/editor/dock-spaces/repositories/RepositoriesPanel.cpp index 19af1c73..20ba7d80 100644 --- a/src/context/editor/dock-spaces/repositories/RepositoriesPanel.cpp +++ b/src/editor/dock-spaces/repositories/RepositoriesPanel.cpp @@ -1,7 +1,7 @@ #include "RepositoriesPanel.h" #include "../../abstract/form/FormPanel.h" #include "../../../../context/ApplicationContext.h" -#include "../../../../common/inspection/Inspectable.h" +#include "../../../../common/Inspectable.h" namespace Metal { void RepositoriesPanel::onInitialize() { diff --git a/src/context/editor/dock-spaces/repositories/RepositoriesPanel.h b/src/editor/dock-spaces/repositories/RepositoriesPanel.h similarity index 100% rename from src/context/editor/dock-spaces/repositories/RepositoriesPanel.h rename to src/editor/dock-spaces/repositories/RepositoriesPanel.h diff --git a/src/context/editor/dock-spaces/viewport/CameraPositionPanel.cpp b/src/editor/dock-spaces/viewport/CameraPositionPanel.cpp similarity index 94% rename from src/context/editor/dock-spaces/viewport/CameraPositionPanel.cpp rename to src/editor/dock-spaces/viewport/CameraPositionPanel.cpp index e84ed0b5..7ae495d5 100644 --- a/src/context/editor/dock-spaces/viewport/CameraPositionPanel.cpp +++ b/src/editor/dock-spaces/viewport/CameraPositionPanel.cpp @@ -1,8 +1,8 @@ #include "CameraPositionPanel.h" #include "../../../../context/ApplicationContext.h" -#include "../../../../util/UIUtil.h" -#include "../../../../service/camera/Camera.h" +#include "../../util/UIUtil.h" +#include "../../../engine/dto/Camera.h" namespace Metal { void CameraPositionPanel::onSync() { diff --git a/src/context/editor/dock-spaces/viewport/CameraPositionPanel.h b/src/editor/dock-spaces/viewport/CameraPositionPanel.h similarity index 100% rename from src/context/editor/dock-spaces/viewport/CameraPositionPanel.h rename to src/editor/dock-spaces/viewport/CameraPositionPanel.h diff --git a/src/context/editor/dock-spaces/viewport/EngineFramePanel.cpp b/src/editor/dock-spaces/viewport/EngineFramePanel.cpp similarity index 92% rename from src/context/editor/dock-spaces/viewport/EngineFramePanel.cpp rename to src/editor/dock-spaces/viewport/EngineFramePanel.cpp index d1bdc025..5bcd3602 100644 --- a/src/context/editor/dock-spaces/viewport/EngineFramePanel.cpp +++ b/src/editor/dock-spaces/viewport/EngineFramePanel.cpp @@ -2,15 +2,15 @@ #include "../../../../context/ApplicationContext.h" #include "../../../../context/engine/frame-builder/EngineFrameBuilder.h" #include "../../../../context/engine/frame-builder/EngineFrame.h" -#include "../../../../service/descriptor/DescriptorInstance.h" -#include "../../../../service/framebuffer/FrameBufferInstance.h" -#include "../../../../service/picking/PickingService.h" -#include "../../../../enum/engine-definitions.h" -#include "../../../../enum/EngineResourceIDs.h" -#include "../../../../dto/buffers/GlobalDataUBO.h" -#include "../../../../dto/buffers/LightData.h" -#include "../../../../dto/buffers/VolumeData.h" -#include "../../../../dto/buffers/MeshMetadata.h" +#include "../../../engine/dto/DescriptorInstance.h" +#include "../../../engine/resource/FrameBufferInstance.h" +#include "../../service/PickingService.h" +#include "../../enum/engine-definitions.h" +#include "../../enum/EngineResourceIDs.h" +#include "../../../engine/dto/GlobalDataUBO.h" +#include "../../../engine/dto/LightData.h" +#include "../../../engine/dto/VolumeData.h" +#include "../../../engine/dto/MeshMetadata.h" #include "ViewportHeaderPanel.h" #include "ImGuizmo.h" #include diff --git a/src/context/editor/dock-spaces/viewport/EngineFramePanel.h b/src/editor/dock-spaces/viewport/EngineFramePanel.h similarity index 100% rename from src/context/editor/dock-spaces/viewport/EngineFramePanel.h rename to src/editor/dock-spaces/viewport/EngineFramePanel.h diff --git a/src/context/editor/dock-spaces/viewport/GizmoPanel.cpp b/src/editor/dock-spaces/viewport/GizmoPanel.cpp similarity index 97% rename from src/context/editor/dock-spaces/viewport/GizmoPanel.cpp rename to src/editor/dock-spaces/viewport/GizmoPanel.cpp index b8585135..00106002 100644 --- a/src/context/editor/dock-spaces/viewport/GizmoPanel.cpp +++ b/src/editor/dock-spaces/viewport/GizmoPanel.cpp @@ -1,8 +1,8 @@ #include "GizmoPanel.h" #include "../../../../context/ApplicationContext.h" -#include "../../../../repository/world/components/TransformComponent.h" -#include "../../../../service/camera/Camera.h" +#include "../../../engine/dto/TransformComponent.h" +#include "../../../engine/dto/Camera.h" #include "ImGuizmo.h" #include #define GLM_ENABLE_EXPERIMENTAL diff --git a/src/context/editor/dock-spaces/viewport/GizmoPanel.h b/src/editor/dock-spaces/viewport/GizmoPanel.h similarity index 100% rename from src/context/editor/dock-spaces/viewport/GizmoPanel.h rename to src/editor/dock-spaces/viewport/GizmoPanel.h diff --git a/src/context/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp b/src/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp similarity index 99% rename from src/context/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp rename to src/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp index 3d2638d9..e8cc266b 100644 --- a/src/context/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp +++ b/src/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp @@ -1,5 +1,5 @@ #include "GizmoSettingsPanel.h" -#include "../../../../util/UIUtil.h" +#include "../../util/UIUtil.h" #include "../../../../context/ApplicationContext.h" #include "ImGuizmo.h" diff --git a/src/context/editor/dock-spaces/viewport/GizmoSettingsPanel.h b/src/editor/dock-spaces/viewport/GizmoSettingsPanel.h similarity index 96% rename from src/context/editor/dock-spaces/viewport/GizmoSettingsPanel.h rename to src/editor/dock-spaces/viewport/GizmoSettingsPanel.h index aec3a185..0c68b751 100644 --- a/src/context/editor/dock-spaces/viewport/GizmoSettingsPanel.h +++ b/src/editor/dock-spaces/viewport/GizmoSettingsPanel.h @@ -3,7 +3,7 @@ #include #include -#include "../../../../enum/engine-definitions.h" +#include "../../enum/engine-definitions.h" #include "../../abstract/AbstractPanel.h" namespace Metal { diff --git a/src/context/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp b/src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp similarity index 98% rename from src/context/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp rename to src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp index 945b926e..9345dea2 100644 --- a/src/context/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp +++ b/src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp @@ -2,7 +2,7 @@ #include "GizmoSettingsPanel.h" #include "../../../../context/ApplicationContext.h" -#include "../../../../util/UIUtil.h" +#include "../../util/UIUtil.h" namespace Metal { void ViewportHeaderPanel::onInitialize() { diff --git a/src/context/editor/dock-spaces/viewport/ViewportHeaderPanel.h b/src/editor/dock-spaces/viewport/ViewportHeaderPanel.h similarity index 100% rename from src/context/editor/dock-spaces/viewport/ViewportHeaderPanel.h rename to src/editor/dock-spaces/viewport/ViewportHeaderPanel.h diff --git a/src/context/editor/dock-spaces/viewport/ViewportPanel.cpp b/src/editor/dock-spaces/viewport/ViewportPanel.cpp similarity index 98% rename from src/context/editor/dock-spaces/viewport/ViewportPanel.cpp rename to src/editor/dock-spaces/viewport/ViewportPanel.cpp index 4d283a47..e4e051a2 100644 --- a/src/context/editor/dock-spaces/viewport/ViewportPanel.cpp +++ b/src/editor/dock-spaces/viewport/ViewportPanel.cpp @@ -6,9 +6,9 @@ #include "ViewportHeaderPanel.h" #include "EngineFramePanel.h" #include "../../../../context/ApplicationContext.h" -#include "../../../../service/camera/Camera.h" +#include "../../../engine/dto/Camera.h" #include "../../../../context/engine/frame-builder/EngineFrameBuilder.h" -#include "../../../../enum/engine-definitions.h" +#include "../../enum/engine-definitions.h" #include namespace Metal { diff --git a/src/context/editor/dock-spaces/viewport/ViewportPanel.h b/src/editor/dock-spaces/viewport/ViewportPanel.h similarity index 100% rename from src/context/editor/dock-spaces/viewport/ViewportPanel.h rename to src/editor/dock-spaces/viewport/ViewportPanel.h diff --git a/src/context/editor/dock-spaces/world/WorldHeaderPanel.cpp b/src/editor/dock-spaces/world/WorldHeaderPanel.cpp similarity index 95% rename from src/context/editor/dock-spaces/world/WorldHeaderPanel.cpp rename to src/editor/dock-spaces/world/WorldHeaderPanel.cpp index 98b04ce1..13306c06 100644 --- a/src/context/editor/dock-spaces/world/WorldHeaderPanel.cpp +++ b/src/editor/dock-spaces/world/WorldHeaderPanel.cpp @@ -1,8 +1,8 @@ #include "WorldHeaderPanel.h" #include "../../../../context/ApplicationContext.h" -#include "../../../../util/UIUtil.h" -#include "../../../../enum/ComponentType.h" +#include "../../util/UIUtil.h" +#include "../../../engine/enum/ComponentType.h" namespace Metal { void WorldHeaderPanel::onSync() { diff --git a/src/context/editor/dock-spaces/world/WorldHeaderPanel.h b/src/editor/dock-spaces/world/WorldHeaderPanel.h similarity index 100% rename from src/context/editor/dock-spaces/world/WorldHeaderPanel.h rename to src/editor/dock-spaces/world/WorldHeaderPanel.h diff --git a/src/context/editor/dock-spaces/world/WorldPanel.cpp b/src/editor/dock-spaces/world/WorldPanel.cpp similarity index 97% rename from src/context/editor/dock-spaces/world/WorldPanel.cpp rename to src/editor/dock-spaces/world/WorldPanel.cpp index ac2265da..33a1c993 100644 --- a/src/context/editor/dock-spaces/world/WorldPanel.cpp +++ b/src/editor/dock-spaces/world/WorldPanel.cpp @@ -1,11 +1,11 @@ #include "WorldPanel.h" #include "WorldHeaderPanel.h" -#include "../../../../common/interface/Icons.h" -#include "../../../../util/UIUtil.h" +#include "../../../../common/Icons.h" +#include "../../util/UIUtil.h" #include "../../../../context/ApplicationContext.h" -#include "../../../../repository/world/impl/MetadataComponent.h" -#include "../../../../enum/ComponentType.h" +#include "../../../engine/dto/MetadataComponent.h" +#include "../../../engine/enum/ComponentType.h" namespace Metal { void WorldPanel::onInitialize() { diff --git a/src/context/editor/dock-spaces/world/WorldPanel.h b/src/editor/dock-spaces/world/WorldPanel.h similarity index 94% rename from src/context/editor/dock-spaces/world/WorldPanel.h rename to src/editor/dock-spaces/world/WorldPanel.h index a6e87e81..920c7f70 100644 --- a/src/context/editor/dock-spaces/world/WorldPanel.h +++ b/src/editor/dock-spaces/world/WorldPanel.h @@ -3,8 +3,8 @@ #include #include -#include "../../../../enum/engine-definitions.h" -#include "../../../../enum/ComponentType.h" +#include "../../enum/engine-definitions.h" +#include "../../../engine/enum/ComponentType.h" #include "../docks/AbstractDockPanel.h" namespace Metal { diff --git a/src/service/notification/AsyncTask.h b/src/editor/dto/AsyncTask.h similarity index 100% rename from src/service/notification/AsyncTask.h rename to src/editor/dto/AsyncTask.h diff --git a/src/repository/dock/DockDTO.h b/src/editor/dto/DockDTO.h similarity index 93% rename from src/repository/dock/DockDTO.h rename to src/editor/dto/DockDTO.h index 60a8109f..b80af738 100644 --- a/src/repository/dock/DockDTO.h +++ b/src/editor/dto/DockDTO.h @@ -4,9 +4,8 @@ #include #include #include -#include "DockSpace.h" -#include "DockPosition.h" -#include "../../util/Util.h" +#include "../../../repository/dock/DockSpace.h" +#include "../util/Util.h" namespace Metal { struct DockDTO { diff --git a/src/repository/dock/DockSpace.cpp b/src/editor/dto/DockSpace.cpp similarity index 70% rename from src/repository/dock/DockSpace.cpp rename to src/editor/dto/DockSpace.cpp index ce757cbc..810fc661 100644 --- a/src/repository/dock/DockSpace.cpp +++ b/src/editor/dto/DockSpace.cpp @@ -1,12 +1,12 @@ -#include "DockSpace.h" -#include "../../common/interface/Icons.h" -#include "../../context/editor/dock-spaces/console/ConsolePanel.h" -#include "../../context/editor/dock-spaces/files/FilesPanel.h" -#include "../../context/editor/dock-spaces/metrics/MetricsPanel.h" -#include "../../context/editor/dock-spaces/repositories/RepositoriesPanel.h" -#include "../../context/editor/dock-spaces/inspector/InspectorPanel.h" -#include "../../context/editor/dock-spaces/viewport/ViewportPanel.h" -#include "../../context/editor/dock-spaces/world/WorldPanel.h" +#include "../../../repository/dock/DockSpace.h" +#include "../../../common/Icons.h" +#include "../dock-spaces/console/ConsolePanel.h" +#include "../dock-spaces/files/FilesPanel.h" +#include "../dock-spaces/metrics/MetricsPanel.h" +#include "../dock-spaces/repositories/RepositoriesPanel.h" +#include "../dock-spaces/inspector/InspectorPanel.h" +#include "../dock-spaces/viewport/ViewportPanel.h" +#include "../dock-spaces/world/WorldPanel.h" #define CB(clazz) []() { return new clazz; } diff --git a/src/repository/dock/DockSpace.h b/src/editor/dto/DockSpace.h similarity index 100% rename from src/repository/dock/DockSpace.h rename to src/editor/dto/DockSpace.h diff --git a/src/dto/file/EntryMetadata.h b/src/editor/dto/EntryMetadata.h similarity index 90% rename from src/dto/file/EntryMetadata.h rename to src/editor/dto/EntryMetadata.h index e16e5628..4ab792f6 100644 --- a/src/dto/file/EntryMetadata.h +++ b/src/editor/dto/EntryMetadata.h @@ -2,9 +2,9 @@ #define FILEMETADATA_H #include -#include "../../util/Util.h" -#include "../../enum/EntryType.h" -#include "../../util/Serializable.h" +#include "../util/Util.h" +#include "../enum/EntryType.h" +#include "../../../common/Serializable.h" namespace Metal { struct EntryMetadata : Serializable { diff --git a/src/dto/file/FSEntry.h b/src/editor/dto/FSEntry.h similarity index 95% rename from src/dto/file/FSEntry.h rename to src/editor/dto/FSEntry.h index 099b3b1a..03cd72c4 100644 --- a/src/dto/file/FSEntry.h +++ b/src/editor/dto/FSEntry.h @@ -2,7 +2,7 @@ #define FILEENTRY_H #include -#include "../../util/Util.h" +#include "../util/Util.h" #include "EntryMetadata.h" namespace Metal { diff --git a/src/dto/push-constant/GridPushConstant.h b/src/editor/dto/GridPushConstant.h similarity index 100% rename from src/dto/push-constant/GridPushConstant.h rename to src/editor/dto/GridPushConstant.h diff --git a/src/dto/file/ImportSettingsDTO.h b/src/editor/dto/ImportSettingsDTO.h similarity index 86% rename from src/dto/file/ImportSettingsDTO.h rename to src/editor/dto/ImportSettingsDTO.h index 403ba57e..e6d48c90 100644 --- a/src/dto/file/ImportSettingsDTO.h +++ b/src/editor/dto/ImportSettingsDTO.h @@ -1,7 +1,7 @@ #ifndef IMPORTSETTINGSDTO_H #define IMPORTSETTINGSDTO_H -#include "../../common/inspection/Inspectable.h" +#include "../../../common/Inspectable.h" namespace Metal { diff --git a/src/dto/Notification.h b/src/editor/dto/Notification.h similarity index 100% rename from src/dto/Notification.h rename to src/editor/dto/Notification.h diff --git a/src/service/voxel/impl/OctreeNode.cpp b/src/editor/dto/OctreeNode.cpp similarity index 94% rename from src/service/voxel/impl/OctreeNode.cpp rename to src/editor/dto/OctreeNode.cpp index e57248ac..dce3c2ed 100644 --- a/src/service/voxel/impl/OctreeNode.cpp +++ b/src/editor/dto/OctreeNode.cpp @@ -1,4 +1,4 @@ -#include "OctreeNode.h" +#include "../../../service/voxel/impl/OctreeNode.h" namespace Metal { void OctreeNode::addChild(OctreeNode *child, int index) { diff --git a/src/service/voxel/impl/OctreeNode.h b/src/editor/dto/OctreeNode.h similarity index 97% rename from src/service/voxel/impl/OctreeNode.h rename to src/editor/dto/OctreeNode.h index 134d7bb5..6844a46f 100644 --- a/src/service/voxel/impl/OctreeNode.h +++ b/src/editor/dto/OctreeNode.h @@ -3,7 +3,7 @@ #include #include -#include "VoxelData.h" +#include "../../engine/dto/VoxelData.h" namespace Metal { struct OctreeNode final { diff --git a/src/service/mesh/SceneData.h b/src/editor/dto/SceneData.h similarity index 95% rename from src/service/mesh/SceneData.h rename to src/editor/dto/SceneData.h index 852bbd8f..6e52f84b 100644 --- a/src/service/mesh/SceneData.h +++ b/src/editor/dto/SceneData.h @@ -3,7 +3,7 @@ #include #include "SceneEntityData.h" -#include "../../util/Serializable.h" +#include "../../../common/Serializable.h" namespace Metal { diff --git a/src/service/mesh/SceneEntityData.h b/src/editor/dto/SceneEntityData.h similarity index 83% rename from src/service/mesh/SceneEntityData.h rename to src/editor/dto/SceneEntityData.h index 0e60b9f8..48dbf3e9 100644 --- a/src/service/mesh/SceneEntityData.h +++ b/src/editor/dto/SceneEntityData.h @@ -1,9 +1,9 @@ #ifndef METAL_ENGINE_SCENEENTITYDATA_H #define METAL_ENGINE_SCENEENTITYDATA_H #include -#include "../../repository/world/components/PrimitiveComponent.h" -#include "../../repository/world/components/TransformComponent.h" -#include "../../repository/world/impl/MetadataComponent.h" +#include "../../engine/dto/PrimitiveComponent.h" +#include "../../engine/dto/TransformComponent.h" +#include "../../engine/dto/MetadataComponent.h" namespace Metal { diff --git a/src/dto/file/SceneImportSettingsDTO.h b/src/editor/dto/SceneImportSettingsDTO.h similarity index 100% rename from src/dto/file/SceneImportSettingsDTO.h rename to src/editor/dto/SceneImportSettingsDTO.h diff --git a/src/dto/push-constant/SelectedDotPushConstant.h b/src/editor/dto/SelectedDotPushConstant.h similarity index 100% rename from src/dto/push-constant/SelectedDotPushConstant.h rename to src/editor/dto/SelectedDotPushConstant.h diff --git a/src/dto/ShortcutDTO.h b/src/editor/dto/ShortcutDTO.h similarity index 100% rename from src/dto/ShortcutDTO.h rename to src/editor/dto/ShortcutDTO.h diff --git a/src/service/voxel/impl/SparseVoxelOctreeBuilder.cpp b/src/editor/dto/SparseVoxelOctreeBuilder.cpp similarity index 97% rename from src/service/voxel/impl/SparseVoxelOctreeBuilder.cpp rename to src/editor/dto/SparseVoxelOctreeBuilder.cpp index 4bfb325f..8a6c70f4 100644 --- a/src/service/voxel/impl/SparseVoxelOctreeBuilder.cpp +++ b/src/editor/dto/SparseVoxelOctreeBuilder.cpp @@ -1,4 +1,4 @@ -#include "SparseVoxelOctreeBuilder.h" +#include "../../../service/voxel/impl/SparseVoxelOctreeBuilder.h" namespace Metal { void SparseVoxelOctreeBuilder::insert(int maxDepth, glm::vec3 point, VoxelData data) { diff --git a/src/service/voxel/impl/SparseVoxelOctreeBuilder.h b/src/editor/dto/SparseVoxelOctreeBuilder.h similarity index 95% rename from src/service/voxel/impl/SparseVoxelOctreeBuilder.h rename to src/editor/dto/SparseVoxelOctreeBuilder.h index 470fdd9f..d329476b 100644 --- a/src/service/voxel/impl/SparseVoxelOctreeBuilder.h +++ b/src/editor/dto/SparseVoxelOctreeBuilder.h @@ -2,7 +2,7 @@ #define SPARSEVOXELOCTREE_H #include "OctreeNode.h" -#include "../../../repository/world/impl/BoundingBox.h" +#include "../../engine/dto/BoundingBox.h" namespace Metal { class SparseVoxelOctreeBuilder; diff --git a/src/enum/EngineResourceIDs.h b/src/editor/enum/EngineResourceIDs.h similarity index 100% rename from src/enum/EngineResourceIDs.h rename to src/editor/enum/EngineResourceIDs.h diff --git a/src/enum/EntryType.h b/src/editor/enum/EntryType.h similarity index 100% rename from src/enum/EntryType.h rename to src/editor/enum/EntryType.h diff --git a/src/enum/NotificationSeverity.h b/src/editor/enum/NotificationSeverity.h similarity index 96% rename from src/enum/NotificationSeverity.h rename to src/editor/enum/NotificationSeverity.h index 53806f6d..9c0b303b 100644 --- a/src/enum/NotificationSeverity.h +++ b/src/editor/enum/NotificationSeverity.h @@ -2,7 +2,7 @@ #define NOTIFICATIONSEVERITY_H #include -#include "../common/interface/Icons.h" +#include "../../../common/Icons.h" namespace Metal::NotificationSeverities { enum NotificationSeverity { diff --git a/src/enum/ShadingMode.h b/src/editor/enum/ShadingMode.h similarity index 98% rename from src/enum/ShadingMode.h rename to src/editor/enum/ShadingMode.h index 4a296079..f3108cf1 100644 --- a/src/enum/ShadingMode.h +++ b/src/editor/enum/ShadingMode.h @@ -4,7 +4,7 @@ #include #include -#include "../common/interface/Icons.h" +#include "../../../common/Icons.h" namespace Metal { enum ShadingMode { diff --git a/src/enum/engine-definitions.h b/src/editor/enum/engine-definitions.h similarity index 97% rename from src/enum/engine-definitions.h rename to src/editor/enum/engine-definitions.h index cb8984f8..b3496556 100644 --- a/src/enum/engine-definitions.h +++ b/src/editor/enum/engine-definitions.h @@ -4,9 +4,9 @@ #include #define MAX_VOLUMES 300 #define MAX_LIGHTS 300 -#define MAX_MATERIALS 100 #define MAX_MESH_INSTANCES 1000 #define EMPTY_ENTITY entt::null + #define FILE_METADATA ".mjson" #define FILE_SCENE "-scene" #define FILE_MESH "-mesh" diff --git a/src/context/editor/panel/FileImportModalPanel.cpp b/src/editor/panel/FileImportModalPanel.cpp similarity index 99% rename from src/context/editor/panel/FileImportModalPanel.cpp rename to src/editor/panel/FileImportModalPanel.cpp index 2e22bab1..0f002400 100644 --- a/src/context/editor/panel/FileImportModalPanel.cpp +++ b/src/editor/panel/FileImportModalPanel.cpp @@ -3,7 +3,7 @@ #include #include #include "../../ApplicationContext.h" -#include "../../../util/FilesUtil.h" +#include "../util/FilesUtil.h" #include "../abstract/form/FormPanel.h" namespace Metal { diff --git a/src/context/editor/panel/FileImportModalPanel.h b/src/editor/panel/FileImportModalPanel.h similarity index 100% rename from src/context/editor/panel/FileImportModalPanel.h rename to src/editor/panel/FileImportModalPanel.h diff --git a/src/context/editor/panel/NotificationsPanel.cpp b/src/editor/panel/NotificationsPanel.cpp similarity index 95% rename from src/context/editor/panel/NotificationsPanel.cpp rename to src/editor/panel/NotificationsPanel.cpp index 51fc259d..873b0491 100644 --- a/src/context/editor/panel/NotificationsPanel.cpp +++ b/src/editor/panel/NotificationsPanel.cpp @@ -1,8 +1,8 @@ #include "NotificationsPanel.h" #include #include "../../ApplicationContext.h" -#include "../../../util/UIUtil.h" -#include "../../../dto/Notification.h" +#include "../util/UIUtil.h" +#include "../dto/Notification.h" namespace Metal { void NotificationsPanel::onSync() { diff --git a/src/context/editor/panel/NotificationsPanel.h b/src/editor/panel/NotificationsPanel.h similarity index 100% rename from src/context/editor/panel/NotificationsPanel.h rename to src/editor/panel/NotificationsPanel.h diff --git a/src/context/engine/render-pass/impl/tools/GridPass.cpp b/src/editor/passes/GridPass.cpp similarity index 85% rename from src/context/engine/render-pass/impl/tools/GridPass.cpp rename to src/editor/passes/GridPass.cpp index 77eabed2..65cd233f 100644 --- a/src/context/engine/render-pass/impl/tools/GridPass.cpp +++ b/src/editor/passes/GridPass.cpp @@ -1,8 +1,8 @@ -#include "GridPass.h" +#include "../../engine/passes/impl/tools/GridPass.h" -#include "../../../../../context/ApplicationContext.h" -#include "../../../../../service/pipeline/PipelineBuilder.h" -#include "../../../../../enum/EngineResourceIDs.h" +#include "../../ApplicationContext.h" +#include "../../engine/dto/PipelineBuilder.h" +#include "../enum/EngineResourceIDs.h" namespace Metal { void GridPass::onInitialize() { diff --git a/src/context/engine/render-pass/impl/tools/GridPass.h b/src/editor/passes/GridPass.h similarity index 80% rename from src/context/engine/render-pass/impl/tools/GridPass.h rename to src/editor/passes/GridPass.h index e45e24f4..86dc660d 100644 --- a/src/context/engine/render-pass/impl/tools/GridPass.h +++ b/src/editor/passes/GridPass.h @@ -1,7 +1,7 @@ #ifndef GRIDRENDERPASS_H #define GRIDRENDERPASS_H -#include "../../AbstractRenderPass.h" -#include "../../../../../dto/push-constant/GridPushConstant.h" +#include "../../engine/passes/AbstractRenderPass.h" +#include "../dto/GridPushConstant.h" namespace Metal { class GridPass final : public AbstractRenderPass { diff --git a/src/context/engine/render-pass/impl/tools/IconsPass.cpp b/src/editor/passes/IconsPass.cpp similarity index 79% rename from src/context/engine/render-pass/impl/tools/IconsPass.cpp rename to src/editor/passes/IconsPass.cpp index 8734921b..62ff2a18 100644 --- a/src/context/engine/render-pass/impl/tools/IconsPass.cpp +++ b/src/editor/passes/IconsPass.cpp @@ -1,8 +1,8 @@ -#include "IconsPass.h" +#include "../../engine/passes/impl/tools/IconsPass.h" -#include "../../../../../context/ApplicationContext.h" -#include "../../../../../service/pipeline/PipelineBuilder.h" -#include "../../../../../enum/EngineResourceIDs.h" +#include "../../ApplicationContext.h" +#include "../../engine/dto/PipelineBuilder.h" +#include "../enum/EngineResourceIDs.h" namespace Metal { void IconsPass::onInitialize() { diff --git a/src/context/engine/render-pass/impl/tools/IconsPass.h b/src/editor/passes/IconsPass.h similarity index 87% rename from src/context/engine/render-pass/impl/tools/IconsPass.h rename to src/editor/passes/IconsPass.h index 604f068e..cb46ae3c 100644 --- a/src/context/engine/render-pass/impl/tools/IconsPass.h +++ b/src/editor/passes/IconsPass.h @@ -1,6 +1,6 @@ #ifndef ICONRENDERPASS_H #define ICONRENDERPASS_H -#include "../../AbstractRenderPass.h" +#include "../../engine/passes/AbstractRenderPass.h" namespace Metal { class IconsPass final : public AbstractRenderPass { diff --git a/src/context/engine/render-pass/impl/tools/SelectionIDPass.cpp b/src/editor/passes/SelectionIDPass.cpp similarity index 86% rename from src/context/engine/render-pass/impl/tools/SelectionIDPass.cpp rename to src/editor/passes/SelectionIDPass.cpp index f34d9bee..939f0626 100644 --- a/src/context/engine/render-pass/impl/tools/SelectionIDPass.cpp +++ b/src/editor/passes/SelectionIDPass.cpp @@ -1,10 +1,10 @@ #include "SelectionIDPass.h" -#include "../../../../../context/ApplicationContext.h" -#include "../../../../../repository/world/components/TransformComponent.h" -#include "../../../../../dto/push-constant/SelectedDotPushConstant.h" -#include "../../../../../service/pipeline/PipelineBuilder.h" -#include "../../../../../enum/EngineResourceIDs.h" +#include "../../ApplicationContext.h" +#include "../../engine/dto/TransformComponent.h" +#include "../dto/SelectedDotPushConstant.h" +#include "../../engine/dto/PipelineBuilder.h" +#include "../enum/EngineResourceIDs.h" namespace Metal { void SelectionIDPass::onInitialize() { diff --git a/src/context/engine/render-pass/impl/tools/SelectionIDPass.h b/src/editor/passes/SelectionIDPass.h similarity index 80% rename from src/context/engine/render-pass/impl/tools/SelectionIDPass.h rename to src/editor/passes/SelectionIDPass.h index 31957bac..156892dd 100644 --- a/src/context/engine/render-pass/impl/tools/SelectionIDPass.h +++ b/src/editor/passes/SelectionIDPass.h @@ -1,8 +1,8 @@ #ifndef SELECTIONIDPASS_H #define SELECTIONIDPASS_H -#include "../../AbstractRenderPass.h" -#include "../../../../../dto/push-constant/SelectedDotPushConstant.h" +#include "../../engine/passes/AbstractRenderPass.h" +#include "../dto/SelectedDotPushConstant.h" namespace Metal { class SelectionIDPass final : public AbstractRenderPass { diff --git a/src/context/engine/render-pass/impl/tools/SelectionOutlinePass.cpp b/src/editor/passes/SelectionOutlinePass.cpp similarity index 77% rename from src/context/engine/render-pass/impl/tools/SelectionOutlinePass.cpp rename to src/editor/passes/SelectionOutlinePass.cpp index 6e1ca4a4..8be2221e 100644 --- a/src/context/engine/render-pass/impl/tools/SelectionOutlinePass.cpp +++ b/src/editor/passes/SelectionOutlinePass.cpp @@ -1,10 +1,10 @@ -#include "SelectionOutlinePass.h" +#include "../../engine/passes/impl/tools/SelectionOutlinePass.h" -#include "../../../../../context/ApplicationContext.h" -#include "../../../../../repository/world/components/TransformComponent.h" -#include "../../../../../dto/push-constant/SelectedDotPushConstant.h" -#include "../../../../../service/pipeline/PipelineBuilder.h" -#include "../../../../../enum/EngineResourceIDs.h" +#include "../../ApplicationContext.h" +#include "../../engine/dto/TransformComponent.h" +#include "../dto/SelectedDotPushConstant.h" +#include "../../engine/dto/PipelineBuilder.h" +#include "../enum/EngineResourceIDs.h" namespace Metal { void SelectionOutlinePass::onInitialize() { diff --git a/src/context/engine/render-pass/impl/tools/SelectionOutlinePass.h b/src/editor/passes/SelectionOutlinePass.h similarity index 80% rename from src/context/engine/render-pass/impl/tools/SelectionOutlinePass.h rename to src/editor/passes/SelectionOutlinePass.h index 2e620341..4d1b8d7b 100644 --- a/src/context/engine/render-pass/impl/tools/SelectionOutlinePass.h +++ b/src/editor/passes/SelectionOutlinePass.h @@ -1,8 +1,8 @@ #ifndef SELECTEDDOTPASS_H #define SELECTEDDOTPASS_H -#include "../../AbstractRenderPass.h" -#include "../../../../../dto/push-constant/SelectedDotPushConstant.h" +#include "../../engine/passes/AbstractRenderPass.h" +#include "../dto/SelectedDotPushConstant.h" namespace Metal { class SelectionOutlinePass final : public AbstractRenderPass { diff --git a/src/repository/dock/DockRepository.cpp b/src/editor/repository/DockRepository.cpp similarity index 94% rename from src/repository/dock/DockRepository.cpp rename to src/editor/repository/DockRepository.cpp index 560f31d7..507c17f8 100644 --- a/src/repository/dock/DockRepository.cpp +++ b/src/editor/repository/DockRepository.cpp @@ -1,4 +1,4 @@ -#include "DockRepository.h" +#include "../../../repository/dock/DockRepository.h" namespace Metal { DockRepository::DockRepository() : AbstractRuntimeComponent() { diff --git a/src/repository/dock/DockRepository.h b/src/editor/repository/DockRepository.h similarity index 84% rename from src/repository/dock/DockRepository.h rename to src/editor/repository/DockRepository.h index dfbd6d79..ab0648b5 100644 --- a/src/repository/dock/DockRepository.h +++ b/src/editor/repository/DockRepository.h @@ -2,8 +2,8 @@ #define METAL_ENGINE_DOCKREPOSITORY_H #include -#include "DockDTO.h" -#include "../../common/AbstractRuntimeComponent.h" +#include "../dto/DockDTO.h" +#include "../../../common/AbstractRuntimeComponent.h" namespace Metal { struct DockRepository final : AbstractRuntimeComponent { diff --git a/src/repository/editor/EditorRepository.cpp b/src/editor/repository/EditorRepository.cpp similarity index 98% rename from src/repository/editor/EditorRepository.cpp rename to src/editor/repository/EditorRepository.cpp index 84c7cea2..108cb4e1 100644 --- a/src/repository/editor/EditorRepository.cpp +++ b/src/editor/repository/EditorRepository.cpp @@ -1,5 +1,5 @@ -#include "EditorRepository.h" -#include "../../common/interface/Icons.h" +#include "../../../repository/editor/EditorRepository.h" +#include "../../../common/Icons.h" namespace Metal { const char *EditorRepository::getTitle() { diff --git a/src/repository/editor/EditorRepository.h b/src/editor/repository/EditorRepository.h similarity index 91% rename from src/repository/editor/EditorRepository.h rename to src/editor/repository/EditorRepository.h index 95ae4ac5..89d513d2 100644 --- a/src/repository/editor/EditorRepository.h +++ b/src/editor/repository/EditorRepository.h @@ -6,11 +6,11 @@ #include #include -#include "../../dto/ShortcutDTO.h" -#include "../../enum/engine-definitions.h" -#include "../../enum/ShadingMode.h" -#include "../../common/inspection/Inspectable.h" -#include "../../util/Serializable.h" +#include "../dto/ShortcutDTO.h" +#include "../enum/engine-definitions.h" +#include "../enum/ShadingMode.h" +#include "../../../common/Inspectable.h" +#include "../../../common/Serializable.h" namespace Metal { struct TransformComponent; diff --git a/src/service/notification/AsyncTaskService.cpp b/src/editor/service/AsyncTaskService.cpp similarity index 92% rename from src/service/notification/AsyncTaskService.cpp rename to src/editor/service/AsyncTaskService.cpp index 334b3c42..24833c25 100644 --- a/src/service/notification/AsyncTaskService.cpp +++ b/src/editor/service/AsyncTaskService.cpp @@ -1,8 +1,8 @@ -#include "AsyncTaskService.h" +#include "../../../service/notification/AsyncTaskService.h" #include #include -#include "../../util/Util.h" -#include "AsyncTask.h" +#include "../util/Util.h" +#include "../dto/AsyncTask.h" namespace Metal { std::string AsyncTaskService::registerTask(const std::string &name, std::function cancel) { diff --git a/src/service/notification/AsyncTaskService.h b/src/editor/service/AsyncTaskService.h similarity index 95% rename from src/service/notification/AsyncTaskService.h rename to src/editor/service/AsyncTaskService.h index f95581b0..41846f93 100644 --- a/src/service/notification/AsyncTaskService.h +++ b/src/editor/service/AsyncTaskService.h @@ -6,7 +6,7 @@ #include #include #include -#include "AsyncTask.h" +#include "../dto/AsyncTask.h" namespace Metal { class AsyncTaskService { diff --git a/src/service/dock/DockService.cpp b/src/editor/service/DockService.cpp similarity index 94% rename from src/service/dock/DockService.cpp rename to src/editor/service/DockService.cpp index ee1ab8e4..27eb553d 100644 --- a/src/service/dock/DockService.cpp +++ b/src/editor/service/DockService.cpp @@ -1,11 +1,11 @@ #include #include -#include "DockService.h" -#include "../../repository/dock/DockDTO.h" -#include "../../context/editor/abstract/AbstractPanel.h" -#include "../../context/editor/dock-spaces/docks/AbstractDockPanel.h" -#include "../../context/editor/dock-spaces/docks/DockSpacePanel.h" -#include "../../context/ApplicationContext.h" +#include "../../../service/dock/DockService.h" +#include "../dto/DockDTO.h" +#include "../abstract/AbstractPanel.h" +#include "../dock-spaces/docks/AbstractDockPanel.h" +#include "../dock-spaces/docks/DockSpacePanel.h" +#include "../../ApplicationContext.h" namespace Metal { void DockService::buildViews(ImGuiID windowId, AbstractPanel *panel) const { diff --git a/src/service/dock/DockService.h b/src/editor/service/DockService.h similarity index 73% rename from src/service/dock/DockService.h rename to src/editor/service/DockService.h index fe3c9cfd..f2e96c28 100644 --- a/src/service/dock/DockService.h +++ b/src/editor/service/DockService.h @@ -2,9 +2,9 @@ #define METAL_ENGINE_DOCKSERVICE_H #include "imgui.h" -#include "../../repository/dock/DockDTO.h" -#include "../../context/editor/dock-spaces/docks/DockSpacePanel.h" -#include "../../common/AbstractRuntimeComponent.h" +#include "../dto/DockDTO.h" +#include "../dock-spaces/docks/DockSpacePanel.h" +#include "../../../common/AbstractRuntimeComponent.h" namespace Metal { class AbstractPanel; diff --git a/src/service/files/FileImporterService.cpp b/src/editor/service/FileImporterService.cpp similarity index 96% rename from src/service/files/FileImporterService.cpp rename to src/editor/service/FileImporterService.cpp index 84244490..666b5f25 100644 --- a/src/service/files/FileImporterService.cpp +++ b/src/editor/service/FileImporterService.cpp @@ -1,7 +1,7 @@ -#include "FileImporterService.h" +#include "../../../service/files/FileImporterService.h" -#include "../../context/ApplicationContext.h" -#include "../log/LogService.h" +#include "../../ApplicationContext.h" +#include "LogService.h" #include #include diff --git a/src/service/files/FileImporterService.h b/src/editor/service/FileImporterService.h similarity index 86% rename from src/service/files/FileImporterService.h rename to src/editor/service/FileImporterService.h index 2df8abd7..231a3fbc 100644 --- a/src/service/files/FileImporterService.h +++ b/src/editor/service/FileImporterService.h @@ -5,8 +5,8 @@ #include #include -#include "../../dto/file/ImportSettingsDTO.h" -#include "../../common/AbstractRuntimeComponent.h" +#include "../dto/ImportSettingsDTO.h" +#include "../../../common/AbstractRuntimeComponent.h" namespace Metal { class FileImporterService final : public AbstractRuntimeComponent { diff --git a/src/service/files/FilesService.cpp b/src/editor/service/FilesService.cpp similarity index 95% rename from src/service/files/FilesService.cpp rename to src/editor/service/FilesService.cpp index 9d6af371..48f6dc06 100644 --- a/src/service/files/FilesService.cpp +++ b/src/editor/service/FilesService.cpp @@ -1,16 +1,16 @@ -#include "FilesService.h" -#include "../../dto/file/FSEntry.h" -#include "../../enum/EntryType.h" -#include "../../enum/engine-definitions.h" -#include "../../util/FilesUtil.h" -#include "../../context/ApplicationContext.h" -#include "../log/LogService.h" +#include "../../../service/files/FilesService.h" +#include "../dto/FSEntry.h" +#include "../enum/EntryType.h" +#include "../enum/engine-definitions.h" +#include "../util/FilesUtil.h" +#include "../../ApplicationContext.h" +#include "LogService.h" #include #include #include #include #include -#include "../../util/serialization-definitions.h" +#include "../util/serialization-definitions.h" namespace fs = std::filesystem; diff --git a/src/service/files/FilesService.h b/src/editor/service/FilesService.h similarity index 93% rename from src/service/files/FilesService.h rename to src/editor/service/FilesService.h index c2906941..299b1b8d 100644 --- a/src/service/files/FilesService.h +++ b/src/editor/service/FilesService.h @@ -4,7 +4,7 @@ #include #include -#include "../../common/AbstractRuntimeComponent.h" +#include "../../../common/AbstractRuntimeComponent.h" namespace Metal { struct FSEntry; diff --git a/src/service/log/LogService.cpp b/src/editor/service/LogService.cpp similarity index 97% rename from src/service/log/LogService.cpp rename to src/editor/service/LogService.cpp index 28cf54e1..4225a03b 100644 --- a/src/service/log/LogService.cpp +++ b/src/editor/service/LogService.cpp @@ -1,4 +1,4 @@ -#include "LogService.h" +#include "../../../service/log/LogService.h" #include #include #include diff --git a/src/service/log/LogService.h b/src/editor/service/LogService.h similarity index 95% rename from src/service/log/LogService.h rename to src/editor/service/LogService.h index 94254087..22e0487a 100644 --- a/src/service/log/LogService.h +++ b/src/editor/service/LogService.h @@ -4,7 +4,7 @@ #include #include #include -#include "../../common/AbstractRuntimeComponent.h" +#include "../../../common/AbstractRuntimeComponent.h" namespace Metal { diff --git a/src/service/material/MaterialImporterService.cpp b/src/editor/service/MaterialImporterService.cpp similarity index 96% rename from src/service/material/MaterialImporterService.cpp rename to src/editor/service/MaterialImporterService.cpp index 35d659ff..1270b7fd 100644 --- a/src/service/material/MaterialImporterService.cpp +++ b/src/editor/service/MaterialImporterService.cpp @@ -1,7 +1,7 @@ #include "MaterialImporterService.h" -#include "../../context/ApplicationContext.h" -#include "../../enum/engine-definitions.h" -#include "../../repository/world/components/PrimitiveComponent.h" +#include "../../ApplicationContext.h" +#include "../enum/engine-definitions.h" +#include "../../engine/dto/PrimitiveComponent.h" #include #include diff --git a/src/service/material/MaterialImporterService.h b/src/editor/service/MaterialImporterService.h similarity index 92% rename from src/service/material/MaterialImporterService.h rename to src/editor/service/MaterialImporterService.h index 52c9aedd..6f731505 100644 --- a/src/service/material/MaterialImporterService.h +++ b/src/editor/service/MaterialImporterService.h @@ -6,7 +6,7 @@ #include #include -#include "../abstract/AbstractResourceService.h" +#include "../../../common/AbstractResourceService.h" namespace Metal { struct PrimitiveComponent; diff --git a/src/service/mesh/MeshImporterService.cpp b/src/editor/service/MeshImporterService.cpp similarity index 90% rename from src/service/mesh/MeshImporterService.cpp rename to src/editor/service/MeshImporterService.cpp index f8c2a980..9943ad53 100644 --- a/src/service/mesh/MeshImporterService.cpp +++ b/src/editor/service/MeshImporterService.cpp @@ -1,13 +1,13 @@ -#include "MeshImporterService.h" -#include "MeshData.h" -#include "VertexData.h" -#include "../../dto/file/EntryMetadata.h" -#include "../../enum/engine-definitions.h" -#include "../../util/FilesUtil.h" -#include "../../context/ApplicationContext.h" +#include "../../../service/mesh/MeshImporterService.h" +#include "../../engine/dto/MeshData.h" +#include "../../context/editor/dto/VertexData.h" +#include "../dto/EntryMetadata.h" +#include "../enum/engine-definitions.h" +#include "../util/FilesUtil.h" +#include "../../ApplicationContext.h" #include #include -#include "../../util/serialization-definitions.h" +#include "../../../util/serialization-definitions.h" namespace Metal { std::string MeshImporterService::persistMesh(const std::string &targetDir, const MeshData &mesh) const { diff --git a/src/service/mesh/MeshImporterService.h b/src/editor/service/MeshImporterService.h similarity index 93% rename from src/service/mesh/MeshImporterService.h rename to src/editor/service/MeshImporterService.h index 7e707e86..250ea5ac 100644 --- a/src/service/mesh/MeshImporterService.h +++ b/src/editor/service/MeshImporterService.h @@ -1,7 +1,7 @@ #ifndef MESHIMPORTERSERVICE_H #define MESHIMPORTERSERVICE_H -#include "../abstract/AbstractResourceService.h" +#include "../../../common/AbstractResourceService.h" #include #include #include diff --git a/src/service/notification/NotificationService.cpp b/src/editor/service/NotificationService.cpp similarity index 95% rename from src/service/notification/NotificationService.cpp rename to src/editor/service/NotificationService.cpp index 92a21c0b..ed0b6a93 100644 --- a/src/service/notification/NotificationService.cpp +++ b/src/editor/service/NotificationService.cpp @@ -1,5 +1,5 @@ #include "NotificationService.h" -#include "../../dto/Notification.h" +#include "../dto/Notification.h" namespace Metal { void NotificationService::pushMessage(const std::string &message, NotificationSeverities::NotificationSeverity severity) { diff --git a/src/service/notification/NotificationService.h b/src/editor/service/NotificationService.h similarity index 92% rename from src/service/notification/NotificationService.h rename to src/editor/service/NotificationService.h index 32737dc5..050b4183 100644 --- a/src/service/notification/NotificationService.h +++ b/src/editor/service/NotificationService.h @@ -2,7 +2,7 @@ #define TOASTERSERVICE_H #include #include -#include "../../enum/NotificationSeverity.h" +#include "../enum/NotificationSeverity.h" #define MAX_notifications 4 #define MESSAGE_DURATION 3000 diff --git a/src/service/picking/PickingService.cpp b/src/editor/service/PickingService.cpp similarity index 94% rename from src/service/picking/PickingService.cpp rename to src/editor/service/PickingService.cpp index 235ac849..e1ee990e 100644 --- a/src/service/picking/PickingService.cpp +++ b/src/editor/service/PickingService.cpp @@ -1,8 +1,8 @@ -#include "PickingService.h" +#include "../../../service/picking/PickingService.h" -#include "../buffer/BufferInstance.h" -#include "../texture/TextureInstance.h" -#include "../../context/ApplicationContext.h" +#include "../../engine/resource/BufferInstance.h" +#include "../../engine/resource/TextureInstance.h" +#include "../../ApplicationContext.h" namespace Metal { std::optional PickingService::pickEntityFromGBuffer(TextureInstance *attachment, const uint32_t pixelX, diff --git a/src/service/picking/PickingService.h b/src/editor/service/PickingService.h similarity index 80% rename from src/service/picking/PickingService.h rename to src/editor/service/PickingService.h index d86177d0..923248e9 100644 --- a/src/service/picking/PickingService.h +++ b/src/editor/service/PickingService.h @@ -1,8 +1,8 @@ #ifndef PICKINGSERVICE_H #define PICKINGSERVICE_H -#include "../abstract/AbstractResourceService.h" -#include "../../enum/engine-definitions.h" +#include "../../../common/AbstractResourceService.h" +#include "../enum/engine-definitions.h" #include namespace Metal { diff --git a/src/service/mesh/SceneImporterService.cpp b/src/editor/service/SceneImporterService.cpp similarity index 93% rename from src/service/mesh/SceneImporterService.cpp rename to src/editor/service/SceneImporterService.cpp index 08144c8a..7196a0cc 100644 --- a/src/service/mesh/SceneImporterService.cpp +++ b/src/editor/service/SceneImporterService.cpp @@ -1,19 +1,19 @@ -#include "SceneImporterService.h" +#include "../../../service/mesh/SceneImporterService.h" -#include "../../dto/file/FSEntry.h" -#include "MeshData.h" -#include "SceneData.h" -#include "../material/MaterialImporterService.h" +#include "../../../dto/file/FSEntry.h" +#include "../../engine/dto/MeshData.h" +#include "../dto/SceneData.h" +#include "MaterialImporterService.h" #include #include #include #include -#include "../../util/FilesUtil.h" -#include "../../dto/file/EntryMetadata.h" -#include "../../enum/engine-definitions.h" -#include "../../context/ApplicationContext.h" -#include "../../util/serialization-definitions.h" -#include "../../dto/file/SceneImportSettingsDTO.h" +#include "../util/FilesUtil.h" +#include "../dto/EntryMetadata.h" +#include "../enum/engine-definitions.h" +#include "../../ApplicationContext.h" +#include "../util/serialization-definitions.h" +#include "../dto/SceneImportSettingsDTO.h" namespace Metal { std::string SceneImporterService::importData(const std::string &targetDir, const std::string &pathToFile, diff --git a/src/service/mesh/SceneImporterService.h b/src/editor/service/SceneImporterService.h similarity index 96% rename from src/service/mesh/SceneImporterService.h rename to src/editor/service/SceneImporterService.h index 39b6d495..29787d7b 100644 --- a/src/service/mesh/SceneImporterService.h +++ b/src/editor/service/SceneImporterService.h @@ -3,7 +3,7 @@ #include -#include "../abstract/AbstractImporter.h" +#include "../../../common/AbstractImporter.h" #include #include diff --git a/src/service/selection/SelectionService.cpp b/src/editor/service/SelectionService.cpp similarity index 92% rename from src/service/selection/SelectionService.cpp rename to src/editor/service/SelectionService.cpp index 23d4c8ff..d2ac6738 100644 --- a/src/service/selection/SelectionService.cpp +++ b/src/editor/service/SelectionService.cpp @@ -1,7 +1,7 @@ -#include "SelectionService.h" +#include "../../../service/selection/SelectionService.h" -#include "../../context/ApplicationContext.h" -#include "../../repository/world/components/TransformComponent.h" +#include "../../ApplicationContext.h" +#include "../../engine/dto/TransformComponent.h" namespace Metal { void SelectionService::addSelected(entt::entity entity) const { diff --git a/src/service/selection/SelectionService.h b/src/editor/service/SelectionService.h similarity index 83% rename from src/service/selection/SelectionService.h rename to src/editor/service/SelectionService.h index 60cb3dd8..1a878d56 100644 --- a/src/service/selection/SelectionService.h +++ b/src/editor/service/SelectionService.h @@ -2,8 +2,8 @@ #define SELECTIONSERVICE_H #include -#include "../../common/AbstractRuntimeComponent.h" -#include "../../enum/engine-definitions.h" +#include "../../../common/AbstractRuntimeComponent.h" +#include "../enum/engine-definitions.h" namespace Metal { struct WorldRepository; diff --git a/src/service/texture/TextureImporterService.cpp b/src/editor/service/TextureImporterService.cpp similarity index 93% rename from src/service/texture/TextureImporterService.cpp rename to src/editor/service/TextureImporterService.cpp index d5f3d5f5..43723b5d 100644 --- a/src/service/texture/TextureImporterService.cpp +++ b/src/editor/service/TextureImporterService.cpp @@ -1,16 +1,16 @@ #include "TextureImporterService.h" -#include "../../../dependencies/stb/stb_image.h" -#include "../../../dependencies/stb/stb_image_write.h" +#include "../../../../dependencies/stb/stb_image.h" +#include "../../../../dependencies/stb/stb_image_write.h" #include #include -#include "../../util/serialization-definitions.h" +#include "../util/serialization-definitions.h" -#include "../../dto/file/EntryMetadata.h" -#include "../../enum/EntryType.h" -#include "../../util/FilesUtil.h" -#include "../../context/ApplicationContext.h" -#include "TextureData.h" +#include "../dto/EntryMetadata.h" +#include "../enum/EntryType.h" +#include "../util/FilesUtil.h" +#include "../../ApplicationContext.h" +#include "../../engine/dto/TextureData.h" namespace fs = std::filesystem; diff --git a/src/service/texture/TextureImporterService.h b/src/editor/service/TextureImporterService.h similarity index 95% rename from src/service/texture/TextureImporterService.h rename to src/editor/service/TextureImporterService.h index 9cfa4085..244617ed 100644 --- a/src/service/texture/TextureImporterService.h +++ b/src/editor/service/TextureImporterService.h @@ -1,6 +1,6 @@ #ifndef TEXTUREIMPORTER_H #define TEXTUREIMPORTER_H -#include "../abstract/AbstractImporter.h" +#include "../../../common/AbstractImporter.h" struct aiTexture; diff --git a/src/service/theme/ThemeService.cpp b/src/editor/service/ThemeService.cpp similarity index 98% rename from src/service/theme/ThemeService.cpp rename to src/editor/service/ThemeService.cpp index c206b8a2..8e439ab7 100644 --- a/src/service/theme/ThemeService.cpp +++ b/src/editor/service/ThemeService.cpp @@ -1,6 +1,6 @@ -#include "ThemeService.h" +#include "../../../service/theme/ThemeService.h" -#include "../../context/ApplicationContext.h" +#include "../../ApplicationContext.h" namespace Metal { glm::vec3 ThemeService::BACKGROUND_COLOR = glm::vec3(0.f); diff --git a/src/service/theme/ThemeService.h b/src/editor/service/ThemeService.h similarity index 93% rename from src/service/theme/ThemeService.h rename to src/editor/service/ThemeService.h index e9d5f603..b8775037 100644 --- a/src/service/theme/ThemeService.h +++ b/src/editor/service/ThemeService.h @@ -2,7 +2,7 @@ #define THEMESERVICE_H #include #include -#include "../../common/AbstractRuntimeComponent.h" +#include "../../../common/AbstractRuntimeComponent.h" namespace Metal { diff --git a/src/service/voxel/VoxelImporterService.cpp b/src/editor/service/VoxelImporterService.cpp similarity index 94% rename from src/service/voxel/VoxelImporterService.cpp rename to src/editor/service/VoxelImporterService.cpp index 6923f58e..86142ef3 100644 --- a/src/service/voxel/VoxelImporterService.cpp +++ b/src/editor/service/VoxelImporterService.cpp @@ -1,20 +1,20 @@ -#include "VoxelImporterService.h" +#include "../../../service/voxel/VoxelImporterService.h" #include -#include "../../util/serialization-definitions.h" +#include "../util/serialization-definitions.h" -#include "../../context/ApplicationContext.h" -#include "../../dto/file/EntryMetadata.h" -#include "../../enum/EntryType.h" -#include "../../enum/engine-definitions.h" -#include "../../service/log/LogService.h" +#include "../../ApplicationContext.h" +#include "../dto/EntryMetadata.h" +#include "../enum/EntryType.h" +#include "../enum/engine-definitions.h" +#include "LogService.h" #include #include #include #include -#include "impl/SparseVoxelOctreeData.h" +#include "../../engine/dto/SparseVoxelOctreeData.h" namespace fs = std::filesystem; diff --git a/src/service/voxel/VoxelImporterService.h b/src/editor/service/VoxelImporterService.h similarity index 89% rename from src/service/voxel/VoxelImporterService.h rename to src/editor/service/VoxelImporterService.h index 57ed9bac..2e1dc578 100644 --- a/src/service/voxel/VoxelImporterService.h +++ b/src/editor/service/VoxelImporterService.h @@ -1,9 +1,9 @@ #ifndef METAL_ENGINE_VOLUMEIMPORTERSERVICE_H #define METAL_ENGINE_VOLUMEIMPORTERSERVICE_H -#include "../abstract/AbstractImporter.h" -#include "impl/SparseVoxelOctreeBuilder.h" -#include "impl/SparseVoxelOctreeData.h" +#include "../../../common/AbstractImporter.h" +#include "../dto/SparseVoxelOctreeBuilder.h" +#include "../../engine/dto/SparseVoxelOctreeData.h" namespace Metal { struct SVOInstance; diff --git a/src/util/FileDialogUtil.h b/src/editor/util/FileDialogUtil.h similarity index 93% rename from src/util/FileDialogUtil.h rename to src/editor/util/FileDialogUtil.h index 436d9966..39b4b9e3 100644 --- a/src/util/FileDialogUtil.h +++ b/src/editor/util/FileDialogUtil.h @@ -3,8 +3,8 @@ #include #include #include -#include "../service/log/LogService.h" -#include "../context/ApplicationContext.h" +#include "../service/LogService.h" +#include "../../ApplicationContext.h" namespace Metal:: FileDialogUtil { static std::vector PickFiles(std::vector filtersToApply) { diff --git a/src/util/FilesUtil.h b/src/editor/util/FilesUtil.h similarity index 98% rename from src/util/FilesUtil.h rename to src/editor/util/FilesUtil.h index 142aee2d..37aa80df 100644 --- a/src/util/FilesUtil.h +++ b/src/editor/util/FilesUtil.h @@ -2,7 +2,7 @@ #define FILESUTIL_H #include #include -#include "../dto/file/FSEntry.h" +#include "../dto/FSEntry.h" namespace fs = std::filesystem; diff --git a/src/util/UIUtil.h b/src/editor/util/UIUtil.h similarity index 99% rename from src/util/UIUtil.h rename to src/editor/util/UIUtil.h index 48312985..666482bc 100644 --- a/src/util/UIUtil.h +++ b/src/editor/util/UIUtil.h @@ -5,7 +5,7 @@ #include #include "../enum/EntryType.h" -#include "../common/interface/Icons.h" +#include "../../../common/Icons.h" namespace Metal::UIUtil { static constexpr ImVec4 DIRECTORY_COLOR{188 / 255.f, 128 / 255.f, 78 / 255.f, 1}; diff --git a/src/util/Util.h b/src/editor/util/Util.h similarity index 100% rename from src/util/Util.h rename to src/editor/util/Util.h diff --git a/src/util/serialization-definitions.h b/src/editor/util/serialization-definitions.h similarity index 97% rename from src/util/serialization-definitions.h rename to src/editor/util/serialization-definitions.h index eab3426b..ceef1d81 100644 --- a/src/util/serialization-definitions.h +++ b/src/editor/util/serialization-definitions.h @@ -3,7 +3,7 @@ #include #include -#include "Serializable.h" +#include "../../../common/Serializable.h" #include #include #include diff --git a/src/context/engine/EngineContext.cpp b/src/engine/EngineContext.cpp similarity index 94% rename from src/context/engine/EngineContext.cpp rename to src/engine/EngineContext.cpp index 4b8d6c85..ec840921 100644 --- a/src/context/engine/EngineContext.cpp +++ b/src/engine/EngineContext.cpp @@ -1,10 +1,10 @@ #include "EngineContext.h" -#include "../../enum/EngineResourceIDs.h" +#include "../editor/enum/EngineResourceIDs.h" #include "../../context/ApplicationContext.h" -#include "../../service/buffer/BufferInstance.h" -#include "../../service/camera/Camera.h" -#include "../../repository/world/components/TransformComponent.h" +#include "resource/BufferInstance.h" +#include "dto/Camera.h" +#include "dto/TransformComponent.h" namespace Metal { void EngineContext::resetPathTracerAccumulationCount() const { diff --git a/src/context/engine/EngineContext.h b/src/engine/EngineContext.h similarity index 95% rename from src/context/engine/EngineContext.h rename to src/engine/EngineContext.h index 79e99f4b..ad04b00c 100644 --- a/src/context/engine/EngineContext.h +++ b/src/engine/EngineContext.h @@ -5,9 +5,9 @@ #include #include -#include "../../dto/buffers/GlobalDataUBO.h" +#include "dto/GlobalDataUBO.h" #include "../../common/AbstractRuntimeComponent.h" -#include "../../dto/buffers/TileInfoUBO.h" +#include "dto/TileInfoUBO.h" using Clock = std::chrono::high_resolution_clock; using TimePoint = std::chrono::time_point; diff --git a/src/repository/world/impl/AbstractComponent.h b/src/engine/dto/AbstractComponent.h similarity index 89% rename from src/repository/world/impl/AbstractComponent.h rename to src/engine/dto/AbstractComponent.h index b9ab3ebb..a9fcfd67 100644 --- a/src/repository/world/impl/AbstractComponent.h +++ b/src/engine/dto/AbstractComponent.h @@ -1,7 +1,7 @@ #ifndef ABSTRACTCOMPONENT_H #define ABSTRACTCOMPONENT_H -#include "../../../common/inspection/Inspectable.h" -#include "../../../enum/ComponentType.h" +#include "../../../common/Inspectable.h" +#include "../enum/ComponentType.h" namespace Metal { struct AbstractComponent : Inspectable { diff --git a/src/dto/push-constant/AccumulationPushConstant.h b/src/engine/dto/AccumulationPushConstant.h similarity index 100% rename from src/dto/push-constant/AccumulationPushConstant.h rename to src/engine/dto/AccumulationPushConstant.h diff --git a/src/repository/world/impl/BoundingBox.h b/src/engine/dto/BoundingBox.h similarity index 97% rename from src/repository/world/impl/BoundingBox.h rename to src/engine/dto/BoundingBox.h index 94ea7dea..0d15dc8b 100644 --- a/src/repository/world/impl/BoundingBox.h +++ b/src/engine/dto/BoundingBox.h @@ -1,7 +1,7 @@ #ifndef BOUNDINGBOX_H #define BOUNDINGBOX_H #include -#include "../../../util/Serializable.h" +#include "../../../common/Serializable.h" namespace Metal { struct BoundingBox final : Serializable { diff --git a/src/service/camera/Camera.cpp b/src/engine/dto/Camera.cpp similarity index 98% rename from src/service/camera/Camera.cpp rename to src/engine/dto/Camera.cpp index 75fe8e20..b7112275 100644 --- a/src/service/camera/Camera.cpp +++ b/src/engine/dto/Camera.cpp @@ -1,6 +1,6 @@ -#include "Camera.h" +#include "../../../service/camera/Camera.h" -#include "../../common/interface/Icons.h" +#include "../../../common/Icons.h" namespace Metal { void Camera::extractFrustumPlanes(glm::mat4x4 m) { diff --git a/src/service/camera/Camera.h b/src/engine/dto/Camera.h similarity index 98% rename from src/service/camera/Camera.h rename to src/engine/dto/Camera.h index 6afad882..b6b0bf7c 100644 --- a/src/service/camera/Camera.h +++ b/src/engine/dto/Camera.h @@ -6,8 +6,8 @@ #include #include -#include "../../common/inspection/Inspectable.h" -#include "../../util/Serializable.h" +#include "../../../common/Inspectable.h" +#include "../../../common/Serializable.h" namespace Metal { diff --git a/src/dto/push-constant/DenoiserPushConstant.h b/src/engine/dto/DenoiserPushConstant.h similarity index 100% rename from src/dto/push-constant/DenoiserPushConstant.h rename to src/engine/dto/DenoiserPushConstant.h diff --git a/src/service/descriptor/DescriptorBinding.h b/src/engine/dto/DescriptorBinding.h similarity index 100% rename from src/service/descriptor/DescriptorBinding.h rename to src/engine/dto/DescriptorBinding.h diff --git a/src/service/descriptor/DescriptorInstance.h b/src/engine/dto/DescriptorInstance.h similarity index 85% rename from src/service/descriptor/DescriptorInstance.h rename to src/engine/dto/DescriptorInstance.h index f2069c62..ce0fc262 100644 --- a/src/service/descriptor/DescriptorInstance.h +++ b/src/engine/dto/DescriptorInstance.h @@ -2,8 +2,8 @@ #define DESCRIPTORINSTANCE_H #include -#include "../../repository/abstract/RuntimeResource.h" -#include "./DescriptorBinding.h" +#include "../resource/RuntimeResource.h" +#include "../../../service/descriptor/DescriptorBinding.h" namespace Metal { struct BufferInstance; diff --git a/src/dto/buffers/GlobalDataUBO.h b/src/engine/dto/GlobalDataUBO.h similarity index 100% rename from src/dto/buffers/GlobalDataUBO.h rename to src/engine/dto/GlobalDataUBO.h diff --git a/src/dto/push-constant/HWRayTracingPushConstant.h b/src/engine/dto/HWRayTracingPushConstant.h similarity index 100% rename from src/dto/push-constant/HWRayTracingPushConstant.h rename to src/engine/dto/HWRayTracingPushConstant.h diff --git a/src/dto/buffers/LightData.h b/src/engine/dto/LightData.h similarity index 100% rename from src/dto/buffers/LightData.h rename to src/engine/dto/LightData.h diff --git a/src/service/mesh/MeshData.h b/src/engine/dto/MeshData.h similarity index 93% rename from src/service/mesh/MeshData.h rename to src/engine/dto/MeshData.h index f5dfb639..43811394 100644 --- a/src/service/mesh/MeshData.h +++ b/src/engine/dto/MeshData.h @@ -3,7 +3,7 @@ #include #include #include "VertexData.h" -#include "../../util/serialization-definitions.h" +#include "../../editor/util/serialization-definitions.h" namespace Metal { struct MeshData final { diff --git a/src/dto/buffers/MeshMetadata.h b/src/engine/dto/MeshMetadata.h similarity index 100% rename from src/dto/buffers/MeshMetadata.h rename to src/engine/dto/MeshMetadata.h diff --git a/src/repository/world/impl/MetadataComponent.cpp b/src/engine/dto/MetadataComponent.cpp similarity index 64% rename from src/repository/world/impl/MetadataComponent.cpp rename to src/engine/dto/MetadataComponent.cpp index bd5dc915..14ea7662 100644 --- a/src/repository/world/impl/MetadataComponent.cpp +++ b/src/engine/dto/MetadataComponent.cpp @@ -1,6 +1,6 @@ -#include "MetadataComponent.h" -#include "../../../common/interface/Icons.h" -#include "../../../util/UIUtil.h" +#include "../../../repository/world/impl/MetadataComponent.h" +#include "../../../common/Icons.h" +#include "../../editor/util/UIUtil.h" namespace Metal { void MetadataComponent::registerFields() { diff --git a/src/repository/world/impl/MetadataComponent.h b/src/engine/dto/MetadataComponent.h similarity index 83% rename from src/repository/world/impl/MetadataComponent.h rename to src/engine/dto/MetadataComponent.h index 4923e86e..0cf4276d 100644 --- a/src/repository/world/impl/MetadataComponent.h +++ b/src/engine/dto/MetadataComponent.h @@ -4,10 +4,10 @@ #include #include "AbstractComponent.h" -#include "../../../enum/engine-definitions.h" -#include "../../../enum/ComponentType.h" -#include "../../../common/inspection/Inspectable.h" -#include "../../../util/Serializable.h" +#include "../../editor/enum/engine-definitions.h" +#include "../enum/ComponentType.h" +#include "../../../common/Inspectable.h" +#include "../../../common/Serializable.h" namespace Metal { struct MetadataComponent final : AbstractComponent, Serializable { diff --git a/src/service/pipeline/PipelineBuilder.cpp b/src/engine/dto/PipelineBuilder.cpp similarity index 97% rename from src/service/pipeline/PipelineBuilder.cpp rename to src/engine/dto/PipelineBuilder.cpp index 27f0f363..98ab72d5 100644 --- a/src/service/pipeline/PipelineBuilder.cpp +++ b/src/engine/dto/PipelineBuilder.cpp @@ -1,5 +1,5 @@ -#include "PipelineBuilder.h" -#include "../texture/TextureInstance.h" +#include "../../../service/pipeline/PipelineBuilder.h" +#include "../resource/TextureInstance.h" namespace Metal { PipelineBuilder PipelineBuilder::Of(std::string frameBufferId, const char *vertexShader, diff --git a/src/service/pipeline/PipelineBuilder.h b/src/engine/dto/PipelineBuilder.h similarity index 98% rename from src/service/pipeline/PipelineBuilder.h rename to src/engine/dto/PipelineBuilder.h index 14c8095c..cdb39b5e 100644 --- a/src/service/pipeline/PipelineBuilder.h +++ b/src/engine/dto/PipelineBuilder.h @@ -3,7 +3,7 @@ #include #include #include -#include "../descriptor/DescriptorBinding.h" +#include "DescriptorBinding.h" namespace Metal { struct DescriptorInstance; diff --git a/src/dto/push-constant/PostProcessingPushConstant.h b/src/engine/dto/PostProcessingPushConstant.h similarity index 100% rename from src/dto/push-constant/PostProcessingPushConstant.h rename to src/engine/dto/PostProcessingPushConstant.h diff --git a/src/repository/world/components/PrimitiveComponent.cpp b/src/engine/dto/PrimitiveComponent.cpp similarity index 94% rename from src/repository/world/components/PrimitiveComponent.cpp rename to src/engine/dto/PrimitiveComponent.cpp index 26bf57c4..35964482 100644 --- a/src/repository/world/components/PrimitiveComponent.cpp +++ b/src/engine/dto/PrimitiveComponent.cpp @@ -1,7 +1,7 @@ -#include "PrimitiveComponent.h" -#include "../../../context/ApplicationContext.h" -#include "../../../enum/EntryType.h" -#include "../../../service/mesh/MeshData.h" +#include "../../../repository/world/components/PrimitiveComponent.h" +#include "../../ApplicationContext.h" +#include "../../editor/enum/EntryType.h" +#include "MeshData.h" namespace Metal { void PrimitiveComponent::registerFields() { diff --git a/src/repository/world/components/PrimitiveComponent.h b/src/engine/dto/PrimitiveComponent.h similarity index 91% rename from src/repository/world/components/PrimitiveComponent.h rename to src/engine/dto/PrimitiveComponent.h index d5229ac4..d49c8afc 100644 --- a/src/repository/world/components/PrimitiveComponent.h +++ b/src/engine/dto/PrimitiveComponent.h @@ -1,8 +1,8 @@ #ifndef PRIMITIVE_COMPONENT_H #define PRIMITIVE_COMPONENT_H -#include "../impl/AbstractComponent.h" -#include "../../../util/Serializable.h" +#include "AbstractComponent.h" +#include "../../../common/Serializable.h" #include namespace Metal { diff --git a/src/service/pipeline/ShaderModule.cpp b/src/engine/dto/ShaderModule.cpp similarity index 73% rename from src/service/pipeline/ShaderModule.cpp rename to src/engine/dto/ShaderModule.cpp index bbcdfe88..a11e2fb8 100644 --- a/src/service/pipeline/ShaderModule.cpp +++ b/src/engine/dto/ShaderModule.cpp @@ -1,6 +1,6 @@ -#include "ShaderModule.h" +#include "../../../service/pipeline/ShaderModule.h" -#include "../../context/vulkan/VulkanContext.h" +#include "../../vulkan/VulkanContext.h" namespace Metal { void ShaderModule::initialize(glslang_program_t *program) { diff --git a/src/service/pipeline/ShaderModule.h b/src/engine/dto/ShaderModule.h similarity index 100% rename from src/service/pipeline/ShaderModule.h rename to src/engine/dto/ShaderModule.h diff --git a/src/service/voxel/impl/SparseVoxelOctreeData.h b/src/engine/dto/SparseVoxelOctreeData.h similarity index 94% rename from src/service/voxel/impl/SparseVoxelOctreeData.h rename to src/engine/dto/SparseVoxelOctreeData.h index dac7a84b..87987780 100644 --- a/src/service/voxel/impl/SparseVoxelOctreeData.h +++ b/src/engine/dto/SparseVoxelOctreeData.h @@ -4,7 +4,7 @@ #include #include -#include "../../../util/Serializable.h" +#include "../../../common/Serializable.h" namespace Metal { struct SparseVoxelOctreeData final : Serializable { diff --git a/src/service/texture/TextureData.h b/src/engine/dto/TextureData.h similarity index 100% rename from src/service/texture/TextureData.h rename to src/engine/dto/TextureData.h diff --git a/src/dto/buffers/TileInfoUBO.h b/src/engine/dto/TileInfoUBO.h similarity index 100% rename from src/dto/buffers/TileInfoUBO.h rename to src/engine/dto/TileInfoUBO.h diff --git a/src/repository/world/components/TransformComponent.cpp b/src/engine/dto/TransformComponent.cpp similarity index 92% rename from src/repository/world/components/TransformComponent.cpp rename to src/engine/dto/TransformComponent.cpp index 73104008..da3e63b1 100644 --- a/src/repository/world/components/TransformComponent.cpp +++ b/src/engine/dto/TransformComponent.cpp @@ -1,6 +1,6 @@ -#include "TransformComponent.h" -#include "VolumeComponent.h" -#include "../../../context/ApplicationContext.h" +#include "../../../repository/world/components/TransformComponent.h" +#include "../../../repository/world/components/VolumeComponent.h" +#include "../../ApplicationContext.h" #define ROTATION "Rotation" diff --git a/src/repository/world/components/TransformComponent.h b/src/engine/dto/TransformComponent.h similarity index 91% rename from src/repository/world/components/TransformComponent.h rename to src/engine/dto/TransformComponent.h index 3315bcfd..1857e1eb 100644 --- a/src/repository/world/components/TransformComponent.h +++ b/src/engine/dto/TransformComponent.h @@ -5,8 +5,8 @@ #include #include -#include "../impl/AbstractComponent.h" -#include "../../../util/Serializable.h" +#include "AbstractComponent.h" +#include "../../../common/Serializable.h" namespace Metal { diff --git a/src/service/mesh/VertexData.h b/src/engine/dto/VertexData.h similarity index 96% rename from src/service/mesh/VertexData.h rename to src/engine/dto/VertexData.h index 5c366199..677c9fc2 100644 --- a/src/service/mesh/VertexData.h +++ b/src/engine/dto/VertexData.h @@ -4,7 +4,7 @@ #include #include -#include "../../util/serialization-definitions.h" +#include "../../editor/util/serialization-definitions.h" namespace Metal { struct VertexData final { diff --git a/src/repository/world/components/VolumeComponent.cpp b/src/engine/dto/VolumeComponent.cpp similarity index 81% rename from src/repository/world/components/VolumeComponent.cpp rename to src/engine/dto/VolumeComponent.cpp index e0f7b99d..0d9455cc 100644 --- a/src/repository/world/components/VolumeComponent.cpp +++ b/src/engine/dto/VolumeComponent.cpp @@ -1,5 +1,5 @@ -#include "VolumeComponent.h" -#include "../../../context/ApplicationContext.h" +#include "../../../repository/world/components/VolumeComponent.h" +#include "../../ApplicationContext.h" namespace Metal { void VolumeComponent::registerFields() { diff --git a/src/repository/world/components/VolumeComponent.h b/src/engine/dto/VolumeComponent.h similarity index 93% rename from src/repository/world/components/VolumeComponent.h rename to src/engine/dto/VolumeComponent.h index 4ea910c8..57a77cf2 100644 --- a/src/repository/world/components/VolumeComponent.h +++ b/src/engine/dto/VolumeComponent.h @@ -1,8 +1,8 @@ #ifndef VOLUMECOMPONENT_H #define VOLUMECOMPONENT_H -#include "../impl/AbstractComponent.h" -#include "../../../util/Serializable.h" +#include "AbstractComponent.h" +#include "../../../common/Serializable.h" #include namespace Metal { diff --git a/src/dto/buffers/VolumeData.h b/src/engine/dto/VolumeData.h similarity index 100% rename from src/dto/buffers/VolumeData.h rename to src/engine/dto/VolumeData.h diff --git a/src/service/voxel/impl/VoxelData.h b/src/engine/dto/VoxelData.h similarity index 100% rename from src/service/voxel/impl/VoxelData.h rename to src/engine/dto/VoxelData.h diff --git a/src/enum/ComponentType.cpp b/src/engine/enum/ComponentType.cpp similarity index 95% rename from src/enum/ComponentType.cpp rename to src/engine/enum/ComponentType.cpp index 7dfbe93e..8ffb8a23 100644 --- a/src/enum/ComponentType.cpp +++ b/src/engine/enum/ComponentType.cpp @@ -1,6 +1,6 @@ -#include "ComponentType.h" -#include "../repository/world/WorldRepository.h" -#include "../context/ApplicationContext.h" +#include "../../../enum/ComponentType.h" +#include "../repository/WorldRepository.h" +#include "../../ApplicationContext.h" #define DEFINE_COMPONENT(TYPE, NAME, JSON_KEY, ICON, DEPS, CLASS, CREATOR) \ { \ diff --git a/src/enum/ComponentType.h b/src/engine/enum/ComponentType.h similarity index 96% rename from src/enum/ComponentType.h rename to src/engine/enum/ComponentType.h index 6a5433d3..90bddb09 100644 --- a/src/enum/ComponentType.h +++ b/src/engine/enum/ComponentType.h @@ -5,7 +5,7 @@ #include #include #include -#include "../common/interface/Icons.h" +#include "../../../common/Icons.h" namespace Metal { class Inspectable; diff --git a/src/enum/PassType.h b/src/engine/enum/PassType.h similarity index 100% rename from src/enum/PassType.h rename to src/engine/enum/PassType.h diff --git a/src/enum/ResourceType.h b/src/engine/enum/ResourceType.h similarity index 100% rename from src/enum/ResourceType.h rename to src/engine/enum/ResourceType.h diff --git a/src/context/engine/frame-builder/EngineFrame.cpp b/src/engine/frame-builder/EngineFrame.cpp similarity index 100% rename from src/context/engine/frame-builder/EngineFrame.cpp rename to src/engine/frame-builder/EngineFrame.cpp diff --git a/src/context/engine/frame-builder/EngineFrame.h b/src/engine/frame-builder/EngineFrame.h similarity index 96% rename from src/context/engine/frame-builder/EngineFrame.h rename to src/engine/frame-builder/EngineFrame.h index b86e3edc..66c8446d 100644 --- a/src/context/engine/frame-builder/EngineFrame.h +++ b/src/engine/frame-builder/EngineFrame.h @@ -4,7 +4,7 @@ #include #include #include -#include "../../../repository/abstract/RuntimeResource.h" +#include "../resource/RuntimeResource.h" #include "../passes/CommandBufferRecorder.h" #include "../passes/AbstractPass.h" diff --git a/src/context/engine/frame-builder/EngineFrameBuilder.cpp b/src/engine/frame-builder/EngineFrameBuilder.cpp similarity index 100% rename from src/context/engine/frame-builder/EngineFrameBuilder.cpp rename to src/engine/frame-builder/EngineFrameBuilder.cpp diff --git a/src/context/engine/frame-builder/EngineFrameBuilder.h b/src/engine/frame-builder/EngineFrameBuilder.h similarity index 95% rename from src/context/engine/frame-builder/EngineFrameBuilder.h rename to src/engine/frame-builder/EngineFrameBuilder.h index fd42fc69..0462a415 100644 --- a/src/context/engine/frame-builder/EngineFrameBuilder.h +++ b/src/engine/frame-builder/EngineFrameBuilder.h @@ -8,8 +8,8 @@ #include #include "structures/ResourceBuilder.h" -#include "../../../enum/PassType.h" -#include "../../../service/buffer/BufferInstance.h" +#include "../enum/PassType.h" +#include "../resource/BufferInstance.h" namespace Metal { class CommandBufferRecorder; diff --git a/src/context/engine/frame-builder/structures/BufferBuilder.cpp b/src/engine/frame-builder/structures/BufferBuilder.cpp similarity index 82% rename from src/context/engine/frame-builder/structures/BufferBuilder.cpp rename to src/engine/frame-builder/structures/BufferBuilder.cpp index fd2ff11a..2dce9a2c 100644 --- a/src/context/engine/frame-builder/structures/BufferBuilder.cpp +++ b/src/engine/frame-builder/structures/BufferBuilder.cpp @@ -1,7 +1,7 @@ #include "BufferBuilder.h" #include "../../../ApplicationContext.h" -#include "../../../../service/buffer/BufferInstance.h" -#include "../../../../service/buffer/BufferService.h" +#include "../../resource/BufferInstance.h" +#include "../../service/BufferService.h" namespace Metal { ResourceType BufferBuilder::getType() { diff --git a/src/context/engine/frame-builder/structures/BufferBuilder.h b/src/engine/frame-builder/structures/BufferBuilder.h similarity index 93% rename from src/context/engine/frame-builder/structures/BufferBuilder.h rename to src/engine/frame-builder/structures/BufferBuilder.h index 2620383c..740c9e69 100644 --- a/src/context/engine/frame-builder/structures/BufferBuilder.h +++ b/src/engine/frame-builder/structures/BufferBuilder.h @@ -4,7 +4,7 @@ #include "ResourceBuilder.h" #include -#include "../../../../service/buffer/BufferInstance.h" +#include "../../resource/BufferInstance.h" namespace Metal { class BufferBuilder final : public ResourceBuilder { diff --git a/src/context/engine/frame-builder/structures/CommandBufferRecorderBuilder.cpp b/src/engine/frame-builder/structures/CommandBufferRecorderBuilder.cpp similarity index 100% rename from src/context/engine/frame-builder/structures/CommandBufferRecorderBuilder.cpp rename to src/engine/frame-builder/structures/CommandBufferRecorderBuilder.cpp diff --git a/src/context/engine/frame-builder/structures/CommandBufferRecorderBuilder.h b/src/engine/frame-builder/structures/CommandBufferRecorderBuilder.h similarity index 100% rename from src/context/engine/frame-builder/structures/CommandBufferRecorderBuilder.h rename to src/engine/frame-builder/structures/CommandBufferRecorderBuilder.h diff --git a/src/context/engine/frame-builder/structures/FramebufferBuilder.cpp b/src/engine/frame-builder/structures/FramebufferBuilder.cpp similarity index 86% rename from src/context/engine/frame-builder/structures/FramebufferBuilder.cpp rename to src/engine/frame-builder/structures/FramebufferBuilder.cpp index 02d973f0..0978ee74 100644 --- a/src/context/engine/frame-builder/structures/FramebufferBuilder.cpp +++ b/src/engine/frame-builder/structures/FramebufferBuilder.cpp @@ -1,7 +1,7 @@ #include "FramebufferBuilder.h" #include "../../../ApplicationContext.h" -#include "../../../../service/framebuffer/FrameBufferService.h" -#include "../../../../service/framebuffer/FrameBufferInstance.h" +#include "../../service/FrameBufferService.h" +#include "../../resource/FrameBufferInstance.h" namespace Metal { ResourceType FramebufferBuilder::getType() { diff --git a/src/context/engine/frame-builder/structures/FramebufferBuilder.h b/src/engine/frame-builder/structures/FramebufferBuilder.h similarity index 100% rename from src/context/engine/frame-builder/structures/FramebufferBuilder.h rename to src/engine/frame-builder/structures/FramebufferBuilder.h diff --git a/src/context/engine/frame-builder/structures/PassBuilder.cpp b/src/engine/frame-builder/structures/PassBuilder.cpp similarity index 86% rename from src/context/engine/frame-builder/structures/PassBuilder.cpp rename to src/engine/frame-builder/structures/PassBuilder.cpp index 56ce5f6a..ee326176 100644 --- a/src/context/engine/frame-builder/structures/PassBuilder.cpp +++ b/src/engine/frame-builder/structures/PassBuilder.cpp @@ -1,8 +1,8 @@ #include "PassBuilder.h" #include "../../render-pass/impl/PostProcessingPass.h" -#include "../../compute-pass/impl/HWRayTracingPass.h" -#include "../../compute-pass/impl/TemporalAccumulationPass.h" -#include "../../compute-pass/impl/SpatialFilterPass.h" +#include "../../passes/impl/HWRayTracingPass.h" +#include "../../passes/impl/TemporalAccumulationPass.h" +#include "../../passes/impl/SpatialFilterPass.h" #include "../../render-pass/impl/tools/SelectionOutlinePass.h" #include "../../render-pass/impl/tools/GridPass.h" #include "../../render-pass/impl/tools/IconsPass.h" diff --git a/src/context/engine/frame-builder/structures/PassBuilder.h b/src/engine/frame-builder/structures/PassBuilder.h similarity index 93% rename from src/context/engine/frame-builder/structures/PassBuilder.h rename to src/engine/frame-builder/structures/PassBuilder.h index abba7912..e92c1cfd 100644 --- a/src/context/engine/frame-builder/structures/PassBuilder.h +++ b/src/engine/frame-builder/structures/PassBuilder.h @@ -2,8 +2,8 @@ #define METAL_ENGINE_PASSBUILDER_H #include "ResourceBuilder.h" -#include "../../../../enum/PassType.h" -#include "../../../../enum/ResourceType.h" +#include "../../enum/PassType.h" +#include "../../enum/ResourceType.h" namespace Metal { class PassBuilder final : public ResourceBuilder { diff --git a/src/context/engine/frame-builder/structures/ResourceBuilder.h b/src/engine/frame-builder/structures/ResourceBuilder.h similarity index 92% rename from src/context/engine/frame-builder/structures/ResourceBuilder.h rename to src/engine/frame-builder/structures/ResourceBuilder.h index ee26de66..c0bd11d5 100644 --- a/src/context/engine/frame-builder/structures/ResourceBuilder.h +++ b/src/engine/frame-builder/structures/ResourceBuilder.h @@ -1,7 +1,7 @@ #ifndef METAL_ENGINE_RESOURCEBUILDER_H #define METAL_ENGINE_RESOURCEBUILDER_H #include -#include "../../../../enum/ResourceType.h" +#include "../../enum/ResourceType.h" namespace Metal { class RuntimeResource; diff --git a/src/context/engine/frame-builder/structures/TextureBuilder.cpp b/src/engine/frame-builder/structures/TextureBuilder.cpp similarity index 89% rename from src/context/engine/frame-builder/structures/TextureBuilder.cpp rename to src/engine/frame-builder/structures/TextureBuilder.cpp index 72d776a6..91e17622 100644 --- a/src/context/engine/frame-builder/structures/TextureBuilder.cpp +++ b/src/engine/frame-builder/structures/TextureBuilder.cpp @@ -1,6 +1,6 @@ #include "TextureBuilder.h" #include "../../../ApplicationContext.h" -#include "../../../../service/texture/TextureInstance.h" +#include "../../resource/TextureInstance.h" namespace Metal { ResourceType TextureBuilder::getType() { diff --git a/src/context/engine/frame-builder/structures/TextureBuilder.h b/src/engine/frame-builder/structures/TextureBuilder.h similarity index 100% rename from src/context/engine/frame-builder/structures/TextureBuilder.h rename to src/engine/frame-builder/structures/TextureBuilder.h diff --git a/src/context/engine/compute-pass/AbstractComputePass.cpp b/src/engine/passes/AbstractComputePass.cpp similarity index 96% rename from src/context/engine/compute-pass/AbstractComputePass.cpp rename to src/engine/passes/AbstractComputePass.cpp index 1bc48f6d..b847add8 100644 --- a/src/context/engine/compute-pass/AbstractComputePass.cpp +++ b/src/engine/passes/AbstractComputePass.cpp @@ -1,8 +1,8 @@ -#include "AbstractComputePass.h" -#include "../../../context/ApplicationContext.h" -#include "../../../service/pipeline/PipelineInstance.h" -#include "../../../service/texture/TextureInstance.h" -#include "../../../util/ImageUtils.h" +#include "../compute-pass/AbstractComputePass.h" +#include "../../ApplicationContext.h" +#include "../resource/PipelineInstance.h" +#include "../resource/TextureInstance.h" +#include "../util/ImageUtils.h" namespace Metal { AbstractComputePass::AbstractComputePass(const std::string &id) : AbstractPass(id, true) { diff --git a/src/context/engine/compute-pass/AbstractComputePass.h b/src/engine/passes/AbstractComputePass.h similarity index 96% rename from src/context/engine/compute-pass/AbstractComputePass.h rename to src/engine/passes/AbstractComputePass.h index 8075789c..321e0989 100644 --- a/src/context/engine/compute-pass/AbstractComputePass.h +++ b/src/engine/passes/AbstractComputePass.h @@ -2,7 +2,7 @@ #define ABSTRACTCOMPUTEPASS_H #include -#include "../passes/AbstractPass.h" +#include "AbstractPass.h" namespace Metal { struct WorldRepository; diff --git a/src/context/engine/passes/AbstractPass.cpp b/src/engine/passes/AbstractPass.cpp similarity index 98% rename from src/context/engine/passes/AbstractPass.cpp rename to src/engine/passes/AbstractPass.cpp index 31c60932..2000f968 100644 --- a/src/context/engine/passes/AbstractPass.cpp +++ b/src/engine/passes/AbstractPass.cpp @@ -1,7 +1,7 @@ #include "AbstractPass.h" #include "../frame-builder/EngineFrame.h" #include "../../../context/ApplicationContext.h" -#include "../../../service/pipeline/PipelineInstance.h" +#include "../resource/PipelineInstance.h" namespace Metal { AbstractPass::AbstractPass(const std::string &id, bool isComputePass) : RuntimeResource(id), diff --git a/src/context/engine/passes/AbstractPass.h b/src/engine/passes/AbstractPass.h similarity index 96% rename from src/context/engine/passes/AbstractPass.h rename to src/engine/passes/AbstractPass.h index 549a49f5..f95e11fd 100644 --- a/src/context/engine/passes/AbstractPass.h +++ b/src/engine/passes/AbstractPass.h @@ -4,7 +4,7 @@ #include #include #include "../../../common/AbstractRuntimeComponent.h" -#include "../../../repository/abstract/RuntimeResource.h" +#include "../resource/RuntimeResource.h" namespace Metal { class EngineFrame; diff --git a/src/context/engine/render-pass/AbstractRenderPass.cpp b/src/engine/passes/AbstractRenderPass.cpp similarity index 83% rename from src/context/engine/render-pass/AbstractRenderPass.cpp rename to src/engine/passes/AbstractRenderPass.cpp index 48d82395..16cd6eb6 100644 --- a/src/context/engine/render-pass/AbstractRenderPass.cpp +++ b/src/engine/passes/AbstractRenderPass.cpp @@ -1,8 +1,8 @@ -#include "AbstractRenderPass.h" +#include "render-pass/AbstractRenderPass.h" #include "../../../context/ApplicationContext.h" -#include "../../../service/pipeline/PipelineInstance.h" -#include "../../../service/mesh/MeshInstance.h" -#include "../../../service/buffer/BufferInstance.h" +#include "../resource/PipelineInstance.h" +#include "../resource/MeshInstance.h" +#include "../resource/BufferInstance.h" namespace Metal { AbstractRenderPass::AbstractRenderPass(const std::string &id) : AbstractPass(id, false) { diff --git a/src/context/engine/render-pass/AbstractRenderPass.h b/src/engine/passes/AbstractRenderPass.h similarity index 93% rename from src/context/engine/render-pass/AbstractRenderPass.h rename to src/engine/passes/AbstractRenderPass.h index 39b4203c..a08bb11b 100644 --- a/src/context/engine/render-pass/AbstractRenderPass.h +++ b/src/engine/passes/AbstractRenderPass.h @@ -1,7 +1,7 @@ #ifndef ABSTRACTRENDERPASS_H #define ABSTRACTRENDERPASS_H -#include "../passes/AbstractPass.h" +#include "AbstractPass.h" #include "vulkan/vulkan.h" namespace Metal { diff --git a/src/context/engine/passes/CommandBufferRecorder.cpp b/src/engine/passes/CommandBufferRecorder.cpp similarity index 95% rename from src/context/engine/passes/CommandBufferRecorder.cpp rename to src/engine/passes/CommandBufferRecorder.cpp index 90bc3f73..f7019f61 100644 --- a/src/context/engine/passes/CommandBufferRecorder.cpp +++ b/src/engine/passes/CommandBufferRecorder.cpp @@ -3,12 +3,12 @@ #include -#include "../../../service/descriptor/DescriptorInstance.h" -#include "../../../service/framebuffer/FrameBufferInstance.h" -#include "../../../service/pipeline/PipelineInstance.h" +#include "../dto/DescriptorInstance.h" +#include "../resource/FrameBufferInstance.h" +#include "../resource/PipelineInstance.h" #include "../../ApplicationContext.h" #include "../render-pass/AbstractRenderPass.h" -#include "../../../util/VulkanUtils.h" +#include "../../vulkan/VulkanUtils.h" namespace Metal { void CommandBufferRecorder::createCommandBuffer() { diff --git a/src/context/engine/passes/CommandBufferRecorder.h b/src/engine/passes/CommandBufferRecorder.h similarity index 88% rename from src/context/engine/passes/CommandBufferRecorder.h rename to src/engine/passes/CommandBufferRecorder.h index ad428c13..7897160d 100644 --- a/src/context/engine/passes/CommandBufferRecorder.h +++ b/src/engine/passes/CommandBufferRecorder.h @@ -1,10 +1,10 @@ #ifndef RENDERPASS_H #define RENDERPASS_H -#include "../../../repository/abstract/RuntimeResource.h" +#include "../resource/RuntimeResource.h" #include #include -#include "../../../service/pipeline/PipelineInstance.h" -#include "../../../util/VulkanUtils.h" +#include "../resource/PipelineInstance.h" +#include "../../vulkan/VulkanUtils.h" namespace Metal { class AbstractPass; diff --git a/src/context/engine/compute-pass/impl/HWRayTracingPass.cpp b/src/engine/passes/impl/HWRayTracingPass.cpp similarity index 90% rename from src/context/engine/compute-pass/impl/HWRayTracingPass.cpp rename to src/engine/passes/impl/HWRayTracingPass.cpp index dcba2bfa..5a9dbeca 100644 --- a/src/context/engine/compute-pass/impl/HWRayTracingPass.cpp +++ b/src/engine/passes/impl/HWRayTracingPass.cpp @@ -1,11 +1,11 @@ -#include "./HWRayTracingPass.h" +#include "../../compute-pass/impl/HWRayTracingPass.h" #include "../../../ApplicationContext.h" -#include "../../../../service/framebuffer/FrameBufferInstance.h" -#include "../../../../service/pipeline/PipelineBuilder.h" -#include "../../../../service/pipeline/PipelineInstance.h" -#include "../../../../service/texture/TextureInstance.h" -#include "../../../../service/raytracing/RayTracingService.h" -#include "../../../../enum/EngineResourceIDs.h" +#include "../../resource/FrameBufferInstance.h" +#include "../../dto/PipelineBuilder.h" +#include "../../resource/PipelineInstance.h" +#include "../../resource/TextureInstance.h" +#include "../../service/RayTracingService.h" +#include "../../../editor/enum/EngineResourceIDs.h" namespace Metal { void HWRayTracingPass::onInitialize() { diff --git a/src/context/engine/compute-pass/impl/HWRayTracingPass.h b/src/engine/passes/impl/HWRayTracingPass.h similarity index 87% rename from src/context/engine/compute-pass/impl/HWRayTracingPass.h rename to src/engine/passes/impl/HWRayTracingPass.h index bdd574e5..860a2424 100644 --- a/src/context/engine/compute-pass/impl/HWRayTracingPass.h +++ b/src/engine/passes/impl/HWRayTracingPass.h @@ -1,7 +1,7 @@ #ifndef HWRAYTRACINGPASS_H #define HWRAYTRACINGPASS_H #include "../AbstractComputePass.h" -#include "../../../../dto/push-constant/HWRayTracingPushConstant.h" +#include "../../dto/HWRayTracingPushConstant.h" namespace Metal { class HWRayTracingPass final : public AbstractComputePass { diff --git a/src/context/engine/render-pass/impl/PostProcessingPass.cpp b/src/engine/passes/impl/PostProcessingPass.cpp similarity index 90% rename from src/context/engine/render-pass/impl/PostProcessingPass.cpp rename to src/engine/passes/impl/PostProcessingPass.cpp index db325602..543fe4aa 100644 --- a/src/context/engine/render-pass/impl/PostProcessingPass.cpp +++ b/src/engine/passes/impl/PostProcessingPass.cpp @@ -1,9 +1,9 @@ -#include "PostProcessingPass.h" +#include "../render-pass/impl/PostProcessingPass.h" #include "../../../../context/ApplicationContext.h" -#include "../../../../service/pipeline/PipelineBuilder.h" -#include "../../../../enum/EngineResourceIDs.h" +#include "../../dto/PipelineBuilder.h" +#include "../../../editor/enum/EngineResourceIDs.h" namespace Metal { diff --git a/src/context/engine/render-pass/impl/PostProcessingPass.h b/src/engine/passes/impl/PostProcessingPass.h similarity index 86% rename from src/context/engine/render-pass/impl/PostProcessingPass.h rename to src/engine/passes/impl/PostProcessingPass.h index b6bb3c4b..98dbcbc9 100644 --- a/src/context/engine/render-pass/impl/PostProcessingPass.h +++ b/src/engine/passes/impl/PostProcessingPass.h @@ -1,7 +1,7 @@ #ifndef POSTPROCESSINGPASS_H #define POSTPROCESSINGPASS_H #include "../AbstractRenderPass.h" -#include "../../../../dto/push-constant/PostProcessingPushConstant.h" +#include "../../dto/PostProcessingPushConstant.h" namespace Metal { class PostProcessingPass final : public AbstractRenderPass { diff --git a/src/context/engine/compute-pass/impl/SpatialFilterPass.cpp b/src/engine/passes/impl/SpatialFilterPass.cpp similarity index 85% rename from src/context/engine/compute-pass/impl/SpatialFilterPass.cpp rename to src/engine/passes/impl/SpatialFilterPass.cpp index f59bc568..3a3aa6ff 100644 --- a/src/context/engine/compute-pass/impl/SpatialFilterPass.cpp +++ b/src/engine/passes/impl/SpatialFilterPass.cpp @@ -1,8 +1,8 @@ -#include "SpatialFilterPass.h" +#include "../../compute-pass/impl/SpatialFilterPass.h" #include "../../../ApplicationContext.h" -#include "../../../../service/pipeline/PipelineBuilder.h" -#include "../../../../service/texture/TextureInstance.h" -#include "../../../../enum/EngineResourceIDs.h" +#include "../../dto/PipelineBuilder.h" +#include "../../resource/TextureInstance.h" +#include "../../../editor/enum/EngineResourceIDs.h" namespace Metal { void SpatialFilterPass::onInitialize() { diff --git a/src/context/engine/compute-pass/impl/SpatialFilterPass.h b/src/engine/passes/impl/SpatialFilterPass.h similarity index 100% rename from src/context/engine/compute-pass/impl/SpatialFilterPass.h rename to src/engine/passes/impl/SpatialFilterPass.h diff --git a/src/context/engine/compute-pass/impl/TemporalAccumulationPass.cpp b/src/engine/passes/impl/TemporalAccumulationPass.cpp similarity index 86% rename from src/context/engine/compute-pass/impl/TemporalAccumulationPass.cpp rename to src/engine/passes/impl/TemporalAccumulationPass.cpp index 3a885a0a..d7108241 100644 --- a/src/context/engine/compute-pass/impl/TemporalAccumulationPass.cpp +++ b/src/engine/passes/impl/TemporalAccumulationPass.cpp @@ -1,8 +1,8 @@ -#include "TemporalAccumulationPass.h" +#include "../../compute-pass/impl/TemporalAccumulationPass.h" #include "../../../ApplicationContext.h" -#include "../../../../service/pipeline/PipelineBuilder.h" -#include "../../../../service/texture/TextureInstance.h" -#include "../../../../enum/EngineResourceIDs.h" +#include "../../dto/PipelineBuilder.h" +#include "../../resource/TextureInstance.h" +#include "../../../editor/enum/EngineResourceIDs.h" namespace Metal { void TemporalAccumulationPass::onInitialize() { diff --git a/src/context/engine/compute-pass/impl/TemporalAccumulationPass.h b/src/engine/passes/impl/TemporalAccumulationPass.h similarity index 100% rename from src/context/engine/compute-pass/impl/TemporalAccumulationPass.h rename to src/engine/passes/impl/TemporalAccumulationPass.h diff --git a/src/repository/engine/EngineRepository.cpp b/src/engine/repository/EngineRepository.cpp similarity index 97% rename from src/repository/engine/EngineRepository.cpp rename to src/engine/repository/EngineRepository.cpp index 1add07b1..f5ac4024 100644 --- a/src/repository/engine/EngineRepository.cpp +++ b/src/engine/repository/EngineRepository.cpp @@ -1,7 +1,7 @@ -#include "EngineRepository.h" +#include "../../../repository/engine/EngineRepository.h" -#include "../../common/interface/Icons.h" -#include "../../context/ApplicationContext.h" +#include "../../../common/Icons.h" +#include "../../ApplicationContext.h" #define LEVEL_OF_DETAIL "Level of detail" #define PATH_TRACER "Path tracer" diff --git a/src/repository/engine/EngineRepository.h b/src/engine/repository/EngineRepository.h similarity index 94% rename from src/repository/engine/EngineRepository.h rename to src/engine/repository/EngineRepository.h index de4db803..0870e1b0 100644 --- a/src/repository/engine/EngineRepository.h +++ b/src/engine/repository/EngineRepository.h @@ -1,8 +1,8 @@ #ifndef ENGINEREPO_H #define ENGINEREPO_H -#include "../../common/inspection/Inspectable.h" +#include "../../../common/Inspectable.h" #include -#include "../../util/Serializable.h" +#include "../../../common/Serializable.h" namespace Metal { struct EngineRepository final : Inspectable, Serializable { diff --git a/src/repository/abstract/ResourceRepository.h b/src/engine/repository/ResourceRepository.h similarity index 83% rename from src/repository/abstract/ResourceRepository.h rename to src/engine/repository/ResourceRepository.h index bebf7cfb..20ec9f5d 100644 --- a/src/repository/abstract/ResourceRepository.h +++ b/src/engine/repository/ResourceRepository.h @@ -2,7 +2,7 @@ #define RESOURCEREPOSITORY_H #include -#include "RuntimeResource.h" +#include "../repository/abstract/RuntimeResource.h" namespace Metal { struct ResourceRepository final { diff --git a/src/repository/runtime/RuntimeRepository.h b/src/engine/repository/RuntimeRepository.h similarity index 100% rename from src/repository/runtime/RuntimeRepository.h rename to src/engine/repository/RuntimeRepository.h diff --git a/src/repository/world/WorldRepository.cpp b/src/engine/repository/WorldRepository.cpp similarity index 96% rename from src/repository/world/WorldRepository.cpp rename to src/engine/repository/WorldRepository.cpp index fd9a1cc9..aa0da49b 100644 --- a/src/repository/world/WorldRepository.cpp +++ b/src/engine/repository/WorldRepository.cpp @@ -1,9 +1,9 @@ -#include "WorldRepository.h" +#include "../../../repository/world/WorldRepository.h" -#include "../../context/ApplicationContext.h" -#include "../../enum/ComponentType.h" -#include "../../service/mesh/SceneData.h" -#include "../../util/serialization-definitions.h" +#include "../../ApplicationContext.h" +#include "../enum/ComponentType.h" +#include "../../editor/dto/SceneData.h" +#include "../../editor/util/serialization-definitions.h" namespace Metal { entt::entity WorldRepository::createEntity() { diff --git a/src/repository/world/WorldRepository.h b/src/engine/repository/WorldRepository.h similarity index 73% rename from src/repository/world/WorldRepository.h rename to src/engine/repository/WorldRepository.h index 2088eff3..86d0f415 100644 --- a/src/repository/world/WorldRepository.h +++ b/src/engine/repository/WorldRepository.h @@ -6,15 +6,15 @@ #include #include -#include "../../common/AbstractRuntimeComponent.h" -#include "../../util/Serializable.h" -#include "../../enum/engine-definitions.h" -#include "../../service/camera/Camera.h" -#include "impl/MetadataComponent.h" -#include "../../enum/ComponentType.h" -#include "components/TransformComponent.h" -#include "components/PrimitiveComponent.h" -#include "components/VolumeComponent.h" +#include "../../../common/AbstractRuntimeComponent.h" +#include "../../../common/Serializable.h" +#include "../../editor/enum/engine-definitions.h" +#include "../dto/Camera.h" +#include "../dto/MetadataComponent.h" +#include "../enum/ComponentType.h" +#include "../dto/TransformComponent.h" +#include "../dto/PrimitiveComponent.h" +#include "../dto/VolumeComponent.h" namespace Metal { class Inspectable; diff --git a/src/service/buffer/BufferInstance.cpp b/src/engine/resource/BufferInstance.cpp similarity index 63% rename from src/service/buffer/BufferInstance.cpp rename to src/engine/resource/BufferInstance.cpp index 53e2b27f..a8698cb0 100644 --- a/src/service/buffer/BufferInstance.cpp +++ b/src/engine/resource/BufferInstance.cpp @@ -1,10 +1,10 @@ -#include "BufferInstance.h" +#include "../../../service/buffer/BufferInstance.h" #include -#include "../../service/log/LogService.h" -#include "../../context/ApplicationContext.h" -#include "../../context/vulkan/VulkanContext.h" -#include "../../util/VulkanUtils.h" +#include "../../editor/service/LogService.h" +#include "../../ApplicationContext.h" +#include "../../vulkan/VulkanContext.h" +#include "../../vulkan/VulkanUtils.h" namespace Metal { BufferType BufferInstance::getBufferType() { diff --git a/src/service/buffer/BufferInstance.h b/src/engine/resource/BufferInstance.h similarity index 93% rename from src/service/buffer/BufferInstance.h rename to src/engine/resource/BufferInstance.h index 1cd66932..175a1cbd 100644 --- a/src/service/buffer/BufferInstance.h +++ b/src/engine/resource/BufferInstance.h @@ -3,7 +3,7 @@ #include -#include "../../repository/abstract/RuntimeResource.h" +#include "RuntimeResource.h" namespace Metal { enum BufferType { diff --git a/src/service/framebuffer/FrameBufferAttachment.cpp b/src/engine/resource/FrameBufferAttachment.cpp similarity index 81% rename from src/service/framebuffer/FrameBufferAttachment.cpp rename to src/engine/resource/FrameBufferAttachment.cpp index e04d3983..cf4a0c4c 100644 --- a/src/service/framebuffer/FrameBufferAttachment.cpp +++ b/src/engine/resource/FrameBufferAttachment.cpp @@ -1,7 +1,7 @@ -#include "FrameBufferAttachment.h" +#include "../../../service/framebuffer/FrameBufferAttachment.h" -#include "../../context/ApplicationContext.h" +#include "../../ApplicationContext.h" namespace Metal { void FrameBufferAttachment::dispose() const { diff --git a/src/service/framebuffer/FrameBufferAttachment.h b/src/engine/resource/FrameBufferAttachment.h similarity index 90% rename from src/service/framebuffer/FrameBufferAttachment.h rename to src/engine/resource/FrameBufferAttachment.h index 1c865e8f..6e559c13 100644 --- a/src/service/framebuffer/FrameBufferAttachment.h +++ b/src/engine/resource/FrameBufferAttachment.h @@ -1,6 +1,6 @@ #ifndef FRAMEBUFFERATTACHMENT_H #define FRAMEBUFFERATTACHMENT_H -#include "../descriptor/DescriptorInstance.h" +#include "../dto/DescriptorInstance.h" namespace Metal { struct FrameBufferAttachment final { diff --git a/src/service/framebuffer/FrameBufferInstance.h b/src/engine/resource/FrameBufferInstance.h similarity index 92% rename from src/service/framebuffer/FrameBufferInstance.h rename to src/engine/resource/FrameBufferInstance.h index 9de1a0e7..3587924e 100644 --- a/src/service/framebuffer/FrameBufferInstance.h +++ b/src/engine/resource/FrameBufferInstance.h @@ -1,7 +1,7 @@ #ifndef FRAMEBUFFER_INSTANCE_H #define FRAMEBUFFER_INSTANCE_H -#include "../../repository/abstract/RuntimeResource.h" +#include "RuntimeResource.h" #include #include #include "FrameBufferAttachment.h" diff --git a/src/service/mesh/MeshInstance.h b/src/engine/resource/MeshInstance.h similarity index 88% rename from src/service/mesh/MeshInstance.h rename to src/engine/resource/MeshInstance.h index d869a3bd..6321e421 100644 --- a/src/service/mesh/MeshInstance.h +++ b/src/engine/resource/MeshInstance.h @@ -1,6 +1,6 @@ #ifndef MESHINSTANCE_H #define MESHINSTANCE_H -#include "../../repository/abstract/RuntimeResource.h" +#include "RuntimeResource.h" namespace Metal { struct BufferInstance; diff --git a/src/service/pipeline/PipelineInstance.h b/src/engine/resource/PipelineInstance.h similarity index 92% rename from src/service/pipeline/PipelineInstance.h rename to src/engine/resource/PipelineInstance.h index b9361236..321f10c9 100644 --- a/src/service/pipeline/PipelineInstance.h +++ b/src/engine/resource/PipelineInstance.h @@ -2,8 +2,8 @@ #define PIPELINEINSTANCE_H #include -#include "../../repository/abstract/RuntimeResource.h" -#include "../descriptor/DescriptorInstance.h" +#include "RuntimeResource.h" +#include "../dto/DescriptorInstance.h" #include namespace Metal { diff --git a/src/repository/abstract/RuntimeResource.h b/src/engine/resource/RuntimeResource.h similarity index 93% rename from src/repository/abstract/RuntimeResource.h rename to src/engine/resource/RuntimeResource.h index 045a102f..a99d4632 100644 --- a/src/repository/abstract/RuntimeResource.h +++ b/src/engine/resource/RuntimeResource.h @@ -1,7 +1,7 @@ #ifndef IGPURESOURCE_H #define IGPURESOURCE_H -#include "../../enum/ResourceType.h" -#include "../../util/Util.h" +#include "../enum/ResourceType.h" +#include "../../editor/util/Util.h" #include using Clock = std::chrono::high_resolution_clock; diff --git a/src/service/voxel/SVOInstance.h b/src/engine/resource/SVOInstance.h similarity index 80% rename from src/service/voxel/SVOInstance.h rename to src/engine/resource/SVOInstance.h index 954d3296..6c13542f 100644 --- a/src/service/voxel/SVOInstance.h +++ b/src/engine/resource/SVOInstance.h @@ -1,7 +1,7 @@ #ifndef SVOINSTANCE_H #define SVOINSTANCE_H -#include "../../repository/abstract/RuntimeResource.h" -#include "../../service/buffer/BufferInstance.h" +#include "RuntimeResource.h" +#include "BufferInstance.h" namespace Metal { struct DescriptorInstance; diff --git a/src/service/texture/TextureInstance.h b/src/engine/resource/TextureInstance.h similarity index 83% rename from src/service/texture/TextureInstance.h rename to src/engine/resource/TextureInstance.h index 31bdd44a..0f78471e 100644 --- a/src/service/texture/TextureInstance.h +++ b/src/engine/resource/TextureInstance.h @@ -2,9 +2,9 @@ #define TEXTUREINSTANCE_H #include -#include "../descriptor/DescriptorInstance.h" -#include "../../repository/abstract/RuntimeResource.h" -#include "../../context/vulkan/VulkanContext.h" +#include "../dto/DescriptorInstance.h" +#include "../../../common/RuntimeResource.h" +#include "../../vulkan/VulkanContext.h" namespace Metal { struct TextureInstance final : RuntimeResource { diff --git a/src/service/buffer/BufferService.cpp b/src/engine/service/BufferService.cpp similarity index 97% rename from src/service/buffer/BufferService.cpp rename to src/engine/service/BufferService.cpp index fa569bfd..0b6beec3 100644 --- a/src/service/buffer/BufferService.cpp +++ b/src/engine/service/BufferService.cpp @@ -1,8 +1,8 @@ -#include "BufferService.h" +#include "../../../service/buffer/BufferService.h" -#include "../../context/ApplicationContext.h" -#include "../../util/VulkanUtils.h" -#include "BufferInstance.h" +#include "../../ApplicationContext.h" +#include "../../vulkan/VulkanUtils.h" +#include "../resource/BufferInstance.h" namespace Metal { BufferInstance *BufferService::createBuffer(const std::string &id, VkDeviceSize bufferSize, diff --git a/src/service/buffer/BufferService.h b/src/engine/service/BufferService.h similarity index 95% rename from src/service/buffer/BufferService.h rename to src/engine/service/BufferService.h index 54c920cf..91de4573 100644 --- a/src/service/buffer/BufferService.h +++ b/src/engine/service/BufferService.h @@ -3,8 +3,8 @@ #include #include -#include "../abstract/AbstractResourceService.h" -#include "BufferInstance.h" +#include "../../../common/AbstractResourceService.h" +#include "../resource/BufferInstance.h" #include "vulkan/vulkan.h" namespace Metal { diff --git a/src/service/camera/CameraService.cpp b/src/engine/service/CameraService.cpp similarity index 98% rename from src/service/camera/CameraService.cpp rename to src/engine/service/CameraService.cpp index 723c06d6..9058a3f1 100644 --- a/src/service/camera/CameraService.cpp +++ b/src/engine/service/CameraService.cpp @@ -1,7 +1,7 @@ -#include "CameraService.h" +#include "../../../service/camera/CameraService.h" -#include "Camera.h" -#include "../../context/ApplicationContext.h" +#include "../dto/Camera.h" +#include "../../ApplicationContext.h" namespace Metal { // Per frame diff --git a/src/service/camera/CameraService.h b/src/engine/service/CameraService.h similarity index 94% rename from src/service/camera/CameraService.h rename to src/engine/service/CameraService.h index 967f3a1c..98efd602 100644 --- a/src/service/camera/CameraService.h +++ b/src/engine/service/CameraService.h @@ -1,7 +1,7 @@ #ifndef CAMERASYSTEM_H #define CAMERASYSTEM_H -#include "../../common/AbstractRuntimeComponent.h" +#include "../../../common/AbstractRuntimeComponent.h" #include #include diff --git a/src/service/passes/CommandBufferRecorderService.h b/src/engine/service/CommandBufferRecorderService.h similarity index 85% rename from src/service/passes/CommandBufferRecorderService.h rename to src/engine/service/CommandBufferRecorderService.h index c05d1d50..d4ce7c7c 100644 --- a/src/service/passes/CommandBufferRecorderService.h +++ b/src/engine/service/CommandBufferRecorderService.h @@ -1,8 +1,8 @@ #ifndef COMMANDBUFFERRECORDERSERVICE_H #define COMMANDBUFFERRECORDERSERVICE_H -#include "../abstract/AbstractResourceService.h" -#include "../../context/engine/passes/CommandBufferRecorder.h" +#include "../../../common/AbstractResourceService.h" +#include "../passes/CommandBufferRecorder.h" namespace Metal { class CommandBufferRecorderService final : public AbstractResourceService { diff --git a/src/service/descriptor/DescriptorSetService.cpp b/src/engine/service/DescriptorSetService.cpp similarity index 96% rename from src/service/descriptor/DescriptorSetService.cpp rename to src/engine/service/DescriptorSetService.cpp index 81f7093a..3ee642d5 100644 --- a/src/service/descriptor/DescriptorSetService.cpp +++ b/src/engine/service/DescriptorSetService.cpp @@ -1,12 +1,12 @@ -#include "DescriptorSetService.h" -#include "../../service/pipeline/PipelineBuilder.h" -#include "../../service/buffer/BufferInstance.h" -#include "../../service/log/LogService.h" -#include "../../context/ApplicationContext.h" -#include "../framebuffer/FrameBufferAttachment.h" -#include "../framebuffer/FrameBufferInstance.h" -#include "../texture/TextureInstance.h" -#include "../../util/VulkanUtils.h" +#include "../../../service/descriptor/DescriptorSetService.h" +#include "../dto/PipelineBuilder.h" +#include "../resource/BufferInstance.h" +#include "../../editor/service/LogService.h" +#include "../../ApplicationContext.h" +#include "../resource/FrameBufferAttachment.h" +#include "../../../service/framebuffer/FrameBufferInstance.h" +#include "../resource/TextureInstance.h" +#include "../../vulkan/VulkanUtils.h" namespace Metal { DescriptorInstance *DescriptorSetService::createDescriptor(const PipelineBuilder &pipelineBuilder, const std::string &id, VkShaderStageFlags stageFlags) { diff --git a/src/service/descriptor/DescriptorSetService.h b/src/engine/service/DescriptorSetService.h similarity index 91% rename from src/service/descriptor/DescriptorSetService.h rename to src/engine/service/DescriptorSetService.h index c11de27e..3777cf71 100644 --- a/src/service/descriptor/DescriptorSetService.h +++ b/src/engine/service/DescriptorSetService.h @@ -1,8 +1,8 @@ #ifndef DESCRIPTORSETSERVICE_H #define DESCRIPTORSETSERVICE_H -#include "../abstract/AbstractResourceService.h" -#include "DescriptorInstance.h" +#include "../../../common/AbstractResourceService.h" +#include "../dto/DescriptorInstance.h" namespace Metal { struct PipelineBuilder; diff --git a/src/service/framebuffer/FrameBufferService.cpp b/src/engine/service/FrameBufferService.cpp similarity index 98% rename from src/service/framebuffer/FrameBufferService.cpp rename to src/engine/service/FrameBufferService.cpp index 3cb4a0ff..5188c427 100644 --- a/src/service/framebuffer/FrameBufferService.cpp +++ b/src/engine/service/FrameBufferService.cpp @@ -1,13 +1,13 @@ -#include "FrameBufferService.h" +#include "../../../service/framebuffer/FrameBufferService.h" #include #include #include #include "FrameBufferInstance.h" -#include "../../util/VulkanUtils.h" -#include "FrameBufferAttachment.h" -#include "../../context/ApplicationContext.h" +#include "../../vulkan/VulkanUtils.h" +#include "../resource/FrameBufferAttachment.h" +#include "../../ApplicationContext.h" namespace Metal { diff --git a/src/service/framebuffer/FrameBufferService.h b/src/engine/service/FrameBufferService.h similarity index 93% rename from src/service/framebuffer/FrameBufferService.h rename to src/engine/service/FrameBufferService.h index 15fab167..985f3ab4 100644 --- a/src/service/framebuffer/FrameBufferService.h +++ b/src/engine/service/FrameBufferService.h @@ -5,8 +5,8 @@ #include #include -#include "../abstract/AbstractResourceService.h" -#include "FrameBufferInstance.h" +#include "../../../common/AbstractResourceService.h" +#include "../resource/FrameBufferInstance.h" namespace Metal { struct FrameBufferAttachment; diff --git a/src/service/lights/LightService.cpp b/src/engine/service/LightService.cpp similarity index 90% rename from src/service/lights/LightService.cpp rename to src/engine/service/LightService.cpp index 2ce80c93..e120c769 100644 --- a/src/service/lights/LightService.cpp +++ b/src/engine/service/LightService.cpp @@ -1,7 +1,7 @@ -#include "LightService.h" -#include "../../context/ApplicationContext.h" -#include "../buffer/BufferInstance.h" -#include "../../enum/EngineResourceIDs.h" +#include "../../../service/lights/LightService.h" +#include "../../ApplicationContext.h" +#include "../resource/BufferInstance.h" +#include "../../editor/enum/EngineResourceIDs.h" namespace Metal { void LightService::registerLights() { diff --git a/src/service/lights/LightService.h b/src/engine/service/LightService.h similarity index 91% rename from src/service/lights/LightService.h rename to src/engine/service/LightService.h index 35a71ace..c7046f2a 100644 --- a/src/service/lights/LightService.h +++ b/src/engine/service/LightService.h @@ -2,8 +2,8 @@ #define LIGHTSSERVICE_H #include -#include "../../common/AbstractRuntimeComponent.h" -#include "../../dto/buffers/LightData.h" +#include "../../../common/AbstractRuntimeComponent.h" +#include "../dto/LightData.h" namespace Metal { class LightService final : public AbstractRuntimeComponent { diff --git a/src/service/material/MaterialService.cpp b/src/engine/service/MaterialService.cpp similarity index 88% rename from src/service/material/MaterialService.cpp rename to src/engine/service/MaterialService.cpp index 80c72174..ce5ef1cf 100644 --- a/src/service/material/MaterialService.cpp +++ b/src/engine/service/MaterialService.cpp @@ -1,9 +1,9 @@ -#include "MaterialService.h" +#include "../../../service/material/MaterialService.h" -#include "../../util/serialization-definitions.h" -#include "../../dto/buffers/MeshMetadata.h" +#include "../../editor/util/serialization-definitions.h" +#include "../dto/MeshMetadata.h" -#include "../../context/ApplicationContext.h" +#include "../../ApplicationContext.h" namespace Metal { diff --git a/src/service/material/MaterialService.h b/src/engine/service/MaterialService.h similarity index 100% rename from src/service/material/MaterialService.h rename to src/engine/service/MaterialService.h diff --git a/src/service/mesh/MeshService.cpp b/src/engine/service/MeshService.cpp similarity index 84% rename from src/service/mesh/MeshService.cpp rename to src/engine/service/MeshService.cpp index cf7fbe17..a642e127 100644 --- a/src/service/mesh/MeshService.cpp +++ b/src/engine/service/MeshService.cpp @@ -1,18 +1,18 @@ -#include "MeshService.h" -#include "MeshInstance.h" -#include "MeshData.h" -#include "SceneData.h" +#include "../../../service/mesh/MeshService.h" +#include "../resource/MeshInstance.h" +#include "../dto/MeshData.h" +#include "../../editor/dto/SceneData.h" -#include "../../context/vulkan/VulkanContext.h" -#include "../../util/FilesUtil.h" -#include "../../util/serialization-definitions.h" +#include "../../vulkan/VulkanContext.h" +#include "../../editor/util/FilesUtil.h" +#include "../../editor/util/serialization-definitions.h" #include #include -#include "../../context/ApplicationContext.h" -#include "../../repository/world/components/PrimitiveComponent.h" -#include "../../repository/world/components/TransformComponent.h" +#include "../../ApplicationContext.h" +#include "../dto/PrimitiveComponent.h" +#include "../dto/TransformComponent.h" namespace Metal { MeshInstance *MeshService::create(const std::string &id) { diff --git a/src/service/mesh/MeshService.h b/src/engine/service/MeshService.h similarity index 78% rename from src/service/mesh/MeshService.h rename to src/engine/service/MeshService.h index 68535a20..396af5d1 100644 --- a/src/service/mesh/MeshService.h +++ b/src/engine/service/MeshService.h @@ -1,8 +1,8 @@ #ifndef MESHSERVICE_H #define MESHSERVICE_H -#include "../../service/abstract/AbstractResourceService.h" -#include "MeshInstance.h" -#include "../../enum/engine-definitions.h" +#include "../../../common/AbstractResourceService.h" +#include "../resource/MeshInstance.h" +#include "../../editor/enum/engine-definitions.h" namespace Metal { struct MeshData; diff --git a/src/service/pipeline/PipelineService.cpp b/src/engine/service/PipelineService.cpp similarity index 97% rename from src/service/pipeline/PipelineService.cpp rename to src/engine/service/PipelineService.cpp index beff6a04..56884e6d 100644 --- a/src/service/pipeline/PipelineService.cpp +++ b/src/engine/service/PipelineService.cpp @@ -1,16 +1,16 @@ -#include "PipelineService.h" +#include "../../../service/pipeline/PipelineService.h" -#include "PipelineBuilder.h" -#include "../../util/ShaderUtil.h" -#include "../../context/ApplicationContext.h" -#include "../../util/VulkanUtils.h" +#include "../dto/PipelineBuilder.h" +#include "../util/ShaderUtil.h" +#include "../../ApplicationContext.h" +#include "../../vulkan/VulkanUtils.h" #include "../framebuffer/FrameBufferInstance.h" -#include "../pipeline/PipelineInstance.h" -#include "../mesh/MeshData.h" -#include "../mesh/VertexData.h" -#include "../descriptor/DescriptorInstance.h" -#include "../framebuffer/FrameBufferAttachment.h" -#include "../buffer/BufferInstance.h" +#include "../resource/PipelineInstance.h" +#include "../dto/MeshData.h" +#include "../../context/editor/dto/VertexData.h" +#include "../dto/DescriptorInstance.h" +#include "../resource/FrameBufferAttachment.h" +#include "../resource/BufferInstance.h" namespace Metal { void PipelineService::createPipelineLayout( diff --git a/src/service/pipeline/PipelineService.h b/src/engine/service/PipelineService.h similarity index 90% rename from src/service/pipeline/PipelineService.h rename to src/engine/service/PipelineService.h index 9ac16eaa..d43d8ce1 100644 --- a/src/service/pipeline/PipelineService.h +++ b/src/engine/service/PipelineService.h @@ -2,9 +2,9 @@ #define PIPELINESERVICE_H #include -#include "../abstract/AbstractResourceService.h" -#include "../descriptor/DescriptorSetService.h" -#include "PipelineInstance.h" +#include "../../../common/AbstractResourceService.h" +#include "DescriptorSetService.h" +#include "../resource/PipelineInstance.h" namespace Metal { struct PipelineBuilder; diff --git a/src/service/raytracing/RayTracingService.cpp b/src/engine/service/RayTracingService.cpp similarity index 97% rename from src/service/raytracing/RayTracingService.cpp rename to src/engine/service/RayTracingService.cpp index fd2b6de0..1210906e 100644 --- a/src/service/raytracing/RayTracingService.cpp +++ b/src/engine/service/RayTracingService.cpp @@ -1,12 +1,12 @@ -#include "RayTracingService.h" -#include "../../context/ApplicationContext.h" -#include "../buffer/BufferInstance.h" -#include "../descriptor/DescriptorInstance.h" -#include "../descriptor/DescriptorBinding.h" -#include "../mesh/MeshInstance.h" -#include "../mesh/VertexData.h" -#include "../../util/VulkanUtils.h" -#include "../../enum/EngineResourceIDs.h" +#include "../../../service/raytracing/RayTracingService.h" +#include "../../ApplicationContext.h" +#include "../resource/BufferInstance.h" +#include "../dto/DescriptorInstance.h" +#include "../../../service/descriptor/DescriptorBinding.h" +#include "../resource/MeshInstance.h" +#include "../dto/VertexData.h" +#include "../../vulkan/VulkanUtils.h" +#include "../../editor/enum/EngineResourceIDs.h" #include namespace Metal { diff --git a/src/service/raytracing/RayTracingService.h b/src/engine/service/RayTracingService.h similarity index 92% rename from src/service/raytracing/RayTracingService.h rename to src/engine/service/RayTracingService.h index bfa42ac6..a646b23c 100644 --- a/src/service/raytracing/RayTracingService.h +++ b/src/engine/service/RayTracingService.h @@ -1,14 +1,14 @@ #ifndef RAYTRACINGSERVICE_H #define RAYTRACINGSERVICE_H -#include "../../dto/buffers/MeshMetadata.h" -#include "../../enum/engine-definitions.h" +#include "../dto/MeshMetadata.h" +#include "../../editor/enum/engine-definitions.h" #include #include #include #include #include -#include "../../common/AbstractRuntimeComponent.h" +#include "../../../common/AbstractRuntimeComponent.h" namespace Metal { struct BufferInstance; diff --git a/src/repository/streaming/StreamingService.cpp b/src/engine/service/StreamingService.cpp similarity index 87% rename from src/repository/streaming/StreamingService.cpp rename to src/engine/service/StreamingService.cpp index a3c3667d..6ddb487a 100644 --- a/src/repository/streaming/StreamingService.cpp +++ b/src/engine/service/StreamingService.cpp @@ -1,11 +1,11 @@ -#include "StreamingService.h" +#include "../../../repository/streaming/StreamingService.h" -#include "../../context/ApplicationContext.h" -#include "../../service/voxel/SVOInstance.h" -#include "../../service/mesh/MeshInstance.h" -#include "../../service/texture/TextureInstance.h" +#include "../../ApplicationContext.h" +#include "../resource/SVOInstance.h" +#include "../resource/MeshInstance.h" +#include "../resource/TextureInstance.h" -#include "../../repository/world/components/PrimitiveComponent.h" +#include "../dto/PrimitiveComponent.h" namespace Metal { static constexpr int MAX_TIMEOUT = 10000; diff --git a/src/repository/streaming/StreamingService.h b/src/engine/service/StreamingService.h similarity index 78% rename from src/repository/streaming/StreamingService.h rename to src/engine/service/StreamingService.h index 2fcba091..f2b6a1d8 100644 --- a/src/repository/streaming/StreamingService.h +++ b/src/engine/service/StreamingService.h @@ -4,9 +4,9 @@ #include #include -#include "../../service/abstract/AbstractResourceService.h" -#include "../abstract/AbstractCoreRepository.h" -#include "../abstract/RuntimeResource.h" +#include "../../../common/AbstractResourceService.h" +#include "../../../common/AbstractCoreRepository.h" +#include "../../../repository/abstract/RuntimeResource.h" using Clock = std::chrono::high_resolution_clock; using TimePoint = std::chrono::time_point; diff --git a/src/service/texture/TextureService.cpp b/src/engine/service/TextureService.cpp similarity index 98% rename from src/service/texture/TextureService.cpp rename to src/engine/service/TextureService.cpp index d5eacf08..4e71cd3f 100644 --- a/src/service/texture/TextureService.cpp +++ b/src/engine/service/TextureService.cpp @@ -1,16 +1,16 @@ -#include "TextureService.h" +#include "../../../service/texture/TextureService.h" #include -#include "../../util/ImageUtils.h" +#include "../util/ImageUtils.h" #include #include -#include "TextureData.h" -#include "../../context/ApplicationContext.h" -#include "../../service/texture/TextureInstance.h" -#include "../../service/buffer/BufferInstance.h" +#include "../dto/TextureData.h" +#include "../../ApplicationContext.h" +#include "../resource/TextureInstance.h" +#include "../resource/BufferInstance.h" namespace Metal { void TextureService::copyBufferToImage(const VkBuffer &vkBuffer, const TextureInstance *image, diff --git a/src/service/texture/TextureService.h b/src/engine/service/TextureService.h similarity index 94% rename from src/service/texture/TextureService.h rename to src/engine/service/TextureService.h index 40d00e1f..4184817f 100644 --- a/src/service/texture/TextureService.h +++ b/src/engine/service/TextureService.h @@ -4,9 +4,9 @@ #include #include -#include "TextureData.h" -#include "../abstract/AbstractResourceService.h" -#include "TextureInstance.h" +#include "../dto/TextureData.h" +#include "../../../common/AbstractResourceService.h" +#include "../resource/TextureInstance.h" namespace Metal { struct TextureInstance; diff --git a/src/service/transform/TransformService.cpp b/src/engine/service/TransformService.cpp similarity index 90% rename from src/service/transform/TransformService.cpp rename to src/engine/service/TransformService.cpp index e977dc2f..8a7a0a4f 100644 --- a/src/service/transform/TransformService.cpp +++ b/src/engine/service/TransformService.cpp @@ -1,10 +1,10 @@ -#include "TransformService.h" +#include "../../../service/transform/TransformService.h" #include #include #include -#include "../../context/ApplicationContext.h" -#include "../../repository/world/components/TransformComponent.h" +#include "../../ApplicationContext.h" +#include "../dto/TransformComponent.h" namespace Metal { void TransformService::onSync() { diff --git a/src/service/transform/TransformService.h b/src/engine/service/TransformService.h similarity index 83% rename from src/service/transform/TransformService.h rename to src/engine/service/TransformService.h index 37ea9b5a..1d5d88d8 100644 --- a/src/service/transform/TransformService.h +++ b/src/engine/service/TransformService.h @@ -4,8 +4,8 @@ #include #include -#include "../../enum/engine-definitions.h" -#include "../../common/AbstractRuntimeComponent.h" +#include "../../editor/enum/engine-definitions.h" +#include "../../../common/AbstractRuntimeComponent.h" namespace Metal { struct TransformComponent; diff --git a/src/service/volumes/VolumeService.cpp b/src/engine/service/VolumeService.cpp similarity index 81% rename from src/service/volumes/VolumeService.cpp rename to src/engine/service/VolumeService.cpp index 5c03305b..2e19ef20 100644 --- a/src/service/volumes/VolumeService.cpp +++ b/src/engine/service/VolumeService.cpp @@ -1,8 +1,8 @@ -#include "VolumeService.h" -#include "../../context/ApplicationContext.h" -#include "../../repository/world/components/VolumeComponent.h" -#include "../buffer/BufferInstance.h" -#include "../../enum/EngineResourceIDs.h" +#include "../../../service/volumes/VolumeService.h" +#include "../../ApplicationContext.h" +#include "../dto/VolumeComponent.h" +#include "../resource/BufferInstance.h" +#include "../../editor/enum/EngineResourceIDs.h" namespace Metal { void VolumeService::registerVolumes() { diff --git a/src/service/volumes/VolumeService.h b/src/engine/service/VolumeService.h similarity index 81% rename from src/service/volumes/VolumeService.h rename to src/engine/service/VolumeService.h index c2377b45..3df0d4e7 100644 --- a/src/service/volumes/VolumeService.h +++ b/src/engine/service/VolumeService.h @@ -2,8 +2,8 @@ #define VOLUME_SERVICE_H #include -#include "../../common/AbstractRuntimeComponent.h" -#include "../../dto/buffers/VolumeData.h" +#include "../../../common/AbstractRuntimeComponent.h" +#include "../dto/VolumeData.h" namespace Metal { diff --git a/src/service/voxel/VoxelService.cpp b/src/engine/service/VoxelService.cpp similarity index 93% rename from src/service/voxel/VoxelService.cpp rename to src/engine/service/VoxelService.cpp index 8991b5b9..ab70ff5e 100644 --- a/src/service/voxel/VoxelService.cpp +++ b/src/engine/service/VoxelService.cpp @@ -2,9 +2,9 @@ // Created by russi on 2/18/2026. // -#include "VoxelService.h" +#include "../../../service/voxel/VoxelService.h" -#include "SVOInstance.h" +#include "../resource/SVOInstance.h" namespace Metal { diff --git a/src/service/voxel/VoxelService.h b/src/engine/service/VoxelService.h similarity index 82% rename from src/service/voxel/VoxelService.h rename to src/engine/service/VoxelService.h index cd5450dc..e5c6939a 100644 --- a/src/service/voxel/VoxelService.h +++ b/src/engine/service/VoxelService.h @@ -1,8 +1,8 @@ #ifndef METAL_ENGINE_VOXELSERVICE_H #define METAL_ENGINE_VOXELSERVICE_H -#include "../abstract/AbstractResourceService.h" -#include "SVOInstance.h" +#include "../../../common/AbstractResourceService.h" +#include "../resource/SVOInstance.h" namespace Metal { struct SVOInstance; diff --git a/src/util/ImageUtils.h b/src/engine/util/ImageUtils.h similarity index 100% rename from src/util/ImageUtils.h rename to src/engine/util/ImageUtils.h diff --git a/src/util/ShaderUtil.cpp b/src/engine/util/ShaderUtil.cpp similarity index 94% rename from src/util/ShaderUtil.cpp rename to src/engine/util/ShaderUtil.cpp index e75c5148..1924663c 100644 --- a/src/util/ShaderUtil.cpp +++ b/src/engine/util/ShaderUtil.cpp @@ -1,16 +1,15 @@ -#include "ShaderUtil.h" +#include "../../../util/ShaderUtil.h" #include #include -#include "../service/pipeline/ShaderModule.h" -#include "../util/VulkanUtils.h" -#include "../util/Util.h" -#include "../context/ApplicationContext.h" -#include "FilesUtil.h" -#include "../service/log/LogService.h" -#include "../enum/LightType.h" -#include "../enum/ShadingMode.h" +#include "../dto/ShaderModule.h" +#include "../../vulkan/VulkanUtils.h" +#include "../../editor/util/Util.h" +#include "../../ApplicationContext.h" +#include "../../editor/util/FilesUtil.h" +#include "../../editor/service/LogService.h" +#include "../../editor/enum/ShadingMode.h" #include "glslang/Include/glslang_c_interface.h" #include "glslang/Public/resource_limits_c.h" #define BASE_PATH "../resources/shaders/" @@ -170,9 +169,6 @@ namespace Metal { for (auto &entry: ShadingModes::getShaderEntries()) { source = "#define " + entry.first + " " + std::to_string(entry.second) + "\n" + source; } - for (auto &entry: LightTypes::getEntries()) { - source = "#define " + entry.first + " " + std::to_string(entry.second) + "\n" + source; - } source = "#define PI_2 6.28318530718\n" + source; source = "#define PI 3.14159265\n" + source; diff --git a/src/util/ShaderUtil.h b/src/engine/util/ShaderUtil.h similarity index 94% rename from src/util/ShaderUtil.h rename to src/engine/util/ShaderUtil.h index ad777b65..13f07699 100644 --- a/src/util/ShaderUtil.h +++ b/src/engine/util/ShaderUtil.h @@ -4,7 +4,7 @@ #include #include -#include "../service/pipeline/ShaderModule.h" +#include "../dto/ShaderModule.h" namespace Metal { class ShaderUtil final { diff --git a/src/enum/LightType.h b/src/enum/LightType.h deleted file mode 100644 index 4333562b..00000000 --- a/src/enum/LightType.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef LIGHTTYPE_H -#define LIGHTTYPE_H -#include -#include - -namespace Metal::LightTypes{ - enum LightType { - SPHERE, - PLANE - }; - - inline std::unordered_map getEntries() { - std::unordered_map entries; - entries["ITEM_TYPE_SPHERE"] = SPHERE; - entries["ITEM_TYPE_PLANE"] = PLANE; - return entries; - } -} -#endif //LIGHTTYPE_H diff --git a/src/main.cpp b/src/main.cpp index 6ba7dc50..2e02e7af 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,7 @@ #define VMA_IMPLEMENTATION #define GLM_FORCE_RADIANS #define GLM_FORCE_DEPTH_ZERO_TO_ONE -#include "context/ApplicationContext.h" +#include "ApplicationContext.h" int main(int, char **) { Metal::ApplicationContext::Init(true); diff --git a/src/repository/dock/DockPosition.h b/src/repository/dock/DockPosition.h deleted file mode 100644 index b0b3ae35..00000000 --- a/src/repository/dock/DockPosition.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef METAL_ENGINE_DOCKPOSITION_H -#define METAL_ENGINE_DOCKPOSITION_H - -namespace Metal { - enum DockPosition { - TOP, - RIGHT_BOTTOM, - RIGHT_TOP, - LEFT_TOP, - LEFT_BOTTOM, - BOTTOM - }; -} -#endif //METAL_ENGINE_DOCKPOSITION_H From 54411f0923f9c6b164e6543c0438ed40ff65ee33 Mon Sep 17 00:00:00 2001 From: facobackup Date: Thu, 12 Mar 2026 21:48:35 -0300 Subject: [PATCH 02/11] Fixing includes --- CMakeLists.txt | 2 +- src/ApplicationContext.cpp | 6 +++--- src/ApplicationContext.h | 10 +++++----- src/common/AbstractImporter.h | 2 +- src/common/AbstractResourceService.h | 2 +- src/common/Inspectable.cpp | 10 +++++----- src/common/Inspectable.h | 4 ++-- src/common/InspectedField.h | 2 +- src/common/Serializable.cpp | 4 ++-- .../util => common}/serialization-definitions.h | 2 +- src/core/glfw/GLFWContext.cpp | 2 +- src/core/gui/GuiContext.cpp | 6 +++--- src/core/vulkan/VulkanContext.cpp | 2 +- src/core/vulkan/VulkanUtils.cpp | 6 +++--- src/editor/EditorPanel.cpp | 3 +-- src/editor/abstract/IPanel.h | 4 ++-- src/editor/abstract/form/FormPanel.cpp | 4 ++-- src/editor/abstract/form/types/BooleanField.cpp | 2 +- src/editor/abstract/form/types/BooleanField.h | 2 +- src/editor/abstract/form/types/ColorField.cpp | 2 +- src/editor/abstract/form/types/ColorField.h | 2 +- src/editor/abstract/form/types/FloatField.cpp | 2 +- src/editor/abstract/form/types/FloatField.h | 2 +- src/editor/abstract/form/types/IntField.cpp | 2 +- src/editor/abstract/form/types/IntField.h | 2 +- src/editor/abstract/form/types/MethodField.h | 2 +- src/editor/abstract/form/types/QuatField.cpp | 2 +- src/editor/abstract/form/types/QuatField.h | 2 +- src/editor/abstract/form/types/ResourceField.cpp | 6 +++--- src/editor/abstract/form/types/ResourceField.h | 2 +- src/editor/abstract/form/types/ResourceFilesPanel.cpp | 2 +- src/editor/abstract/form/types/StringField.cpp | 2 +- src/editor/abstract/form/types/StringField.h | 2 +- src/editor/abstract/form/types/Vec2Field.cpp | 2 +- src/editor/abstract/form/types/Vec2Field.h | 2 +- src/editor/abstract/form/types/Vec3Field.cpp | 2 +- src/editor/abstract/form/types/Vec3Field.h | 2 +- src/editor/abstract/form/types/Vec4Field.cpp | 2 +- src/editor/abstract/form/types/Vec4Field.h | 2 +- src/editor/dock-spaces/console/ConsolePanel.cpp | 2 +- src/editor/dock-spaces/docks/DockSpacePanel.cpp | 4 ++-- src/editor/dock-spaces/files/FilePreviewPanel.cpp | 2 +- src/editor/dock-spaces/files/FilesHeaderPanel.cpp | 5 ++--- src/editor/dock-spaces/files/FilesListPanel.cpp | 2 +- src/editor/dock-spaces/files/FilesPanel.cpp | 4 ++-- src/editor/dock-spaces/header/AsyncTaskPanel.cpp | 2 +- src/editor/dock-spaces/header/EditorHeaderPanel.cpp | 2 +- src/editor/dock-spaces/inspector/InspectorPanel.cpp | 4 ++-- .../dock-spaces/repositories/RepositoriesPanel.cpp | 4 ++-- .../dock-spaces/viewport/CameraPositionPanel.cpp | 2 +- src/editor/dock-spaces/viewport/EngineFramePanel.cpp | 6 +++--- src/editor/dock-spaces/viewport/GizmoPanel.cpp | 2 +- src/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp | 2 +- .../dock-spaces/viewport/ViewportHeaderPanel.cpp | 2 +- src/editor/dock-spaces/viewport/ViewportPanel.cpp | 5 ++--- src/editor/dock-spaces/world/WorldHeaderPanel.cpp | 2 +- src/editor/dock-spaces/world/WorldPanel.cpp | 4 ++-- src/editor/dto/DockDTO.h | 2 +- src/editor/dto/DockSpace.cpp | 4 ++-- src/editor/dto/EntryMetadata.h | 2 +- src/editor/dto/ImportSettingsDTO.h | 2 +- src/editor/dto/OctreeNode.cpp | 2 +- src/editor/dto/SceneData.h | 2 +- src/editor/dto/SparseVoxelOctreeBuilder.cpp | 2 +- src/editor/enum/NotificationSeverity.h | 2 +- src/editor/enum/ShadingMode.h | 2 +- src/editor/passes/GridPass.cpp | 2 +- src/editor/passes/IconsPass.cpp | 2 +- src/editor/passes/SelectionOutlinePass.cpp | 2 +- src/editor/repository/DockRepository.cpp | 2 +- src/editor/repository/DockRepository.h | 2 +- src/editor/repository/EditorRepository.cpp | 4 ++-- src/editor/repository/EditorRepository.h | 4 ++-- src/editor/service/AsyncTaskService.cpp | 2 +- src/editor/service/AsyncTaskService.h | 1 - src/editor/service/DockService.cpp | 2 +- src/editor/service/DockService.h | 2 +- src/editor/service/FileImporterService.cpp | 2 +- src/editor/service/FileImporterService.h | 2 +- src/editor/service/FilesService.cpp | 4 ++-- src/editor/service/FilesService.h | 2 +- src/editor/service/LogService.cpp | 2 +- src/editor/service/LogService.h | 2 +- src/editor/service/MaterialImporterService.h | 2 +- src/editor/service/MeshImporterService.cpp | 7 +++---- src/editor/service/MeshImporterService.h | 2 +- src/editor/service/PickingService.cpp | 2 +- src/editor/service/PickingService.h | 2 +- src/editor/service/SceneImporterService.cpp | 6 +++--- src/editor/service/SceneImporterService.h | 2 +- src/editor/service/SelectionService.cpp | 2 +- src/editor/service/SelectionService.h | 2 +- src/editor/service/TextureImporterService.cpp | 2 +- src/editor/service/TextureImporterService.h | 2 +- src/editor/service/ThemeService.cpp | 2 +- src/editor/service/ThemeService.h | 2 +- src/editor/service/VoxelImporterService.cpp | 4 ++-- src/editor/service/VoxelImporterService.h | 2 +- src/editor/util/UIUtil.h | 2 +- src/engine/EngineContext.cpp | 3 +-- src/engine/EngineContext.h | 2 +- src/engine/dto/AbstractComponent.h | 2 +- src/engine/dto/BoundingBox.h | 2 +- src/engine/dto/Camera.cpp | 4 ++-- src/engine/dto/Camera.h | 4 ++-- src/engine/dto/DescriptorInstance.h | 2 +- src/engine/dto/MeshData.h | 2 +- src/engine/dto/MetadataComponent.cpp | 4 +--- src/engine/dto/MetadataComponent.h | 4 ++-- src/engine/dto/PipelineBuilder.cpp | 2 +- src/engine/dto/PrimitiveComponent.cpp | 2 +- src/engine/dto/PrimitiveComponent.h | 2 +- src/engine/dto/ShaderModule.cpp | 4 ++-- src/engine/dto/SparseVoxelOctreeData.h | 2 +- src/engine/dto/TransformComponent.cpp | 4 ++-- src/engine/dto/TransformComponent.h | 2 +- src/engine/dto/VertexData.h | 2 +- src/engine/dto/VolumeComponent.cpp | 2 +- src/engine/dto/VolumeComponent.h | 2 +- src/engine/enum/ComponentType.cpp | 2 +- src/engine/enum/ComponentType.h | 1 - src/engine/frame-builder/EngineFrameBuilder.cpp | 1 - src/engine/frame-builder/structures/PassBuilder.cpp | 10 +++++----- src/engine/passes/AbstractComputePass.cpp | 2 +- src/engine/passes/AbstractPass.cpp | 2 +- src/engine/passes/AbstractPass.h | 2 +- src/engine/passes/AbstractRenderPass.cpp | 5 ++--- src/engine/passes/CommandBufferRecorder.cpp | 6 ++---- src/engine/passes/CommandBufferRecorder.h | 2 +- src/engine/passes/impl/HWRayTracingPass.cpp | 3 +-- src/engine/passes/impl/PostProcessingPass.cpp | 4 ++-- src/engine/passes/impl/SpatialFilterPass.cpp | 2 +- src/engine/passes/impl/TemporalAccumulationPass.cpp | 2 +- src/engine/repository/EngineRepository.cpp | 5 ++--- src/engine/repository/EngineRepository.h | 4 ++-- src/engine/repository/WorldRepository.cpp | 4 ++-- src/engine/repository/WorldRepository.h | 4 ++-- src/engine/resource/BufferInstance.cpp | 8 +------- src/engine/resource/FrameBufferAttachment.cpp | 2 +- src/engine/resource/TextureInstance.h | 4 +--- src/engine/service/BufferService.cpp | 4 ++-- src/engine/service/BufferService.h | 2 +- src/engine/service/CameraService.cpp | 2 +- src/engine/service/CameraService.h | 2 +- src/engine/service/CommandBufferRecorderService.h | 2 +- src/engine/service/DescriptorSetService.cpp | 6 +++--- src/engine/service/DescriptorSetService.h | 2 +- src/engine/service/FrameBufferService.cpp | 6 +++--- src/engine/service/FrameBufferService.h | 2 +- src/engine/service/LightService.cpp | 2 +- src/engine/service/LightService.h | 2 +- src/engine/service/MaterialService.cpp | 4 ++-- src/engine/service/MeshService.cpp | 7 ++----- src/engine/service/MeshService.h | 2 +- src/engine/service/PipelineService.cpp | 9 ++++----- src/engine/service/PipelineService.h | 2 +- src/engine/service/RayTracingService.cpp | 6 +++--- src/engine/service/RayTracingService.h | 2 +- src/engine/service/StreamingService.cpp | 2 +- src/engine/service/StreamingService.h | 5 ++--- src/engine/service/TextureService.cpp | 2 +- src/engine/service/TextureService.h | 2 +- src/engine/service/TransformService.cpp | 2 +- src/engine/service/TransformService.h | 2 +- src/engine/service/VolumeService.cpp | 2 +- src/engine/service/VolumeService.h | 2 +- src/engine/service/VoxelService.cpp | 6 +----- src/engine/service/VoxelService.h | 2 +- src/engine/util/ShaderUtil.cpp | 4 ++-- 169 files changed, 234 insertions(+), 266 deletions(-) rename src/{editor/util => common}/serialization-definitions.h (97%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1543f480..391ca93b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,7 +208,7 @@ add_executable( src/engine/resource/FrameBufferAttachment.cpp src/engine/repository/EngineRepository.cpp src/engine/repository/EngineRepository.h - src/editor/util/serialization-definitions.h + src/common/serialization-definitions.h src/editor/service/NotificationService.cpp src/editor/service/NotificationService.h src/editor/service/AsyncTaskService.cpp diff --git a/src/ApplicationContext.cpp b/src/ApplicationContext.cpp index fba64246..d47dd628 100644 --- a/src/ApplicationContext.cpp +++ b/src/ApplicationContext.cpp @@ -1,11 +1,11 @@ -#include "context/ApplicationContext.h" +#include "ApplicationContext.h" #include #include #include "editor/util/FilesUtil.h" -#include "vulkan/VulkanUtils.h" -#include "editor/util/serialization-definitions.h" +#include "core/vulkan/VulkanUtils.h" +#include "common/serialization-definitions.h" #include "editor/util/FileDialogUtil.h" #include diff --git a/src/ApplicationContext.h b/src/ApplicationContext.h index 08ace4d5..e1c88cfb 100644 --- a/src/ApplicationContext.h +++ b/src/ApplicationContext.h @@ -4,8 +4,8 @@ #include #include "engine/EngineContext.h" -#include "glfw/GLFWContext.h" -#include "vulkan/VulkanContext.h" +#include "core/glfw/GLFWContext.h" +#include "core/vulkan/VulkanContext.h" #include "engine/service/MeshService.h" #include "engine/service/TextureService.h" @@ -32,18 +32,18 @@ #include "editor/repository/EditorRepository.h" #include "engine/service/MaterialService.h" #include "engine/service/CommandBufferRecorderService.h" -#include "../service/notification/NotificationService.h" +#include "editor/service/NotificationService.h" #include "editor/service/AsyncTaskService.h" #include "editor/service/LogService.h" #include "engine/service/TransformService.h" #include "editor/service/PickingService.h" #include "engine/service/VolumeService.h" #include "editor/service/VoxelImporterService.h" -#include "../service/voxel/VoxelService.h" +#include "engine/service/VoxelService.h" #include "engine/service/LightService.h" #include "engine/service/RayTracingService.h" #include "editor/EditorPanel.h" -#include "gui/GuiContext.h" +#include "core/gui/GuiContext.h" #define CTX Metal::ApplicationContext::Get() diff --git a/src/common/AbstractImporter.h b/src/common/AbstractImporter.h index 24e05029..3507b6b9 100644 --- a/src/common/AbstractImporter.h +++ b/src/common/AbstractImporter.h @@ -4,7 +4,7 @@ #include #include -#include "../context/editor/dto/ImportSettingsDTO.h" +#include "../editor/dto/ImportSettingsDTO.h" #include "AbstractRuntimeComponent.h" namespace Metal { diff --git a/src/common/AbstractResourceService.h b/src/common/AbstractResourceService.h index c94287d4..25ad1072 100644 --- a/src/common/AbstractResourceService.h +++ b/src/common/AbstractResourceService.h @@ -5,7 +5,7 @@ #include #include "AbstractRuntimeComponent.h" -#include "../context/engine/resource/RuntimeResource.h" +#include "../engine/resource/RuntimeResource.h" namespace Metal { class VulkanContext; diff --git a/src/common/Inspectable.cpp b/src/common/Inspectable.cpp index a0c0b207..e2b4a1ee 100644 --- a/src/common/Inspectable.cpp +++ b/src/common/Inspectable.cpp @@ -1,14 +1,14 @@ -#include "inspection/Inspectable.h" +#include "Inspectable.h" #include #include #include #include -#include "inspection/InspectedField.h" -#include "inspection/InspectedMethod.h" -#include "../context/editor/util/Util.h" -#include "../context/editor/enum/EntryType.h" +#include "InspectedField.h" +#include "InspectedMethod.h" +#include "../editor/util/Util.h" +#include "../editor/enum/EntryType.h" #define DECLARATION(T, V) \ std::shared_ptr> field = std::make_shared>(&v);\ diff --git a/src/common/Inspectable.h b/src/common/Inspectable.h index 1c3df071..3c300946 100644 --- a/src/common/Inspectable.h +++ b/src/common/Inspectable.h @@ -7,8 +7,8 @@ #include #include "InspectableMember.h" -#include "../context/editor/util/Util.h" -#include "../context/editor/enum/EntryType.h" +#include "../editor/util/Util.h" +#include "../editor/enum/EntryType.h" #include "Changeable.h" namespace Metal { diff --git a/src/common/InspectedField.h b/src/common/InspectedField.h index 08b2b22e..fdcd9155 100644 --- a/src/common/InspectedField.h +++ b/src/common/InspectedField.h @@ -4,7 +4,7 @@ #include #include "InspectableMember.h" -#include "../context/editor/enum/EntryType.h" +#include "../editor/enum/EntryType.h" namespace Metal { template diff --git a/src/common/Serializable.cpp b/src/common/Serializable.cpp index 98d46573..c9a08f3d 100644 --- a/src/common/Serializable.cpp +++ b/src/common/Serializable.cpp @@ -1,9 +1,9 @@ -#include "../util/Serializable.h" +#include "Serializable.h" #include "../ApplicationContext.h" #include #include #include -#include "../context/editor/service/LogService.h" +#include "../editor/service/LogService.h" namespace Metal { void Serializable::saveToJson(const std::string &path) const { diff --git a/src/editor/util/serialization-definitions.h b/src/common/serialization-definitions.h similarity index 97% rename from src/editor/util/serialization-definitions.h rename to src/common/serialization-definitions.h index ceef1d81..eab3426b 100644 --- a/src/editor/util/serialization-definitions.h +++ b/src/common/serialization-definitions.h @@ -3,7 +3,7 @@ #include #include -#include "../../../common/Serializable.h" +#include "Serializable.h" #include #include #include diff --git a/src/core/glfw/GLFWContext.cpp b/src/core/glfw/GLFWContext.cpp index 333ad510..8014aea8 100644 --- a/src/core/glfw/GLFWContext.cpp +++ b/src/core/glfw/GLFWContext.cpp @@ -1,6 +1,6 @@ #include #include "GLFWContext.h" -#include "../ApplicationContext.h" +#include "../../ApplicationContext.h" #include "../vulkan/VulkanUtils.h" namespace Metal { diff --git a/src/core/gui/GuiContext.cpp b/src/core/gui/GuiContext.cpp index c6ccbb2c..6874f866 100644 --- a/src/core/gui/GuiContext.cpp +++ b/src/core/gui/GuiContext.cpp @@ -2,10 +2,10 @@ #include #include "imgui_freetype.h" -#include "../ApplicationContext.h" +#include "../../ApplicationContext.h" #include "../vulkan/VulkanUtils.h" -#include "../engine/dto/DescriptorInstance.h" -#include "../engine/resource/TextureInstance.h" +#include "../../engine/dto/DescriptorInstance.h" +#include "../../engine/resource/TextureInstance.h" namespace Metal { void GuiContext::endFrame() { diff --git a/src/core/vulkan/VulkanContext.cpp b/src/core/vulkan/VulkanContext.cpp index 0e5415b2..040e475d 100644 --- a/src/core/vulkan/VulkanContext.cpp +++ b/src/core/vulkan/VulkanContext.cpp @@ -2,7 +2,7 @@ #include "VkBootstrap.h" #include "VulkanUtils.h" -#include "../ApplicationContext.h" +#include "../../ApplicationContext.h" namespace Metal { VulkanContext::VulkanContext(bool debugMode) : AbstractRuntimeComponent(), diff --git a/src/core/vulkan/VulkanUtils.cpp b/src/core/vulkan/VulkanUtils.cpp index 182dab58..9a133c92 100644 --- a/src/core/vulkan/VulkanUtils.cpp +++ b/src/core/vulkan/VulkanUtils.cpp @@ -1,8 +1,8 @@ -#include "../../util/VulkanUtils.h" +#include "VulkanUtils.h" #include "../../../dependencies/vk-bootstrap/src/VkBootstrap.h" -#include "../ApplicationContext.h" -#include "../editor/service/LogService.h" +#include "../../ApplicationContext.h" +#include "../../editor/service/LogService.h" namespace Metal { void VulkanUtils::CheckVKResult(VkResult err) { diff --git a/src/editor/EditorPanel.cpp b/src/editor/EditorPanel.cpp index 2e70ba27..0f07986a 100644 --- a/src/editor/EditorPanel.cpp +++ b/src/editor/EditorPanel.cpp @@ -1,7 +1,6 @@ #include "EditorPanel.h" #include "util/UIUtil.h" -#include "../../context/ApplicationContext.h" -#include "dto/Notification.h" +#include "../ApplicationContext.h" #include "dock-spaces/header/EditorHeaderPanel.h" #include "panel/FileImportModalPanel.h" #include "panel/NotificationsPanel.h" diff --git a/src/editor/abstract/IPanel.h b/src/editor/abstract/IPanel.h index 8eba6fb6..126139fe 100644 --- a/src/editor/abstract/IPanel.h +++ b/src/editor/abstract/IPanel.h @@ -1,8 +1,8 @@ #ifndef METAL_ENGINE_IPANEL_H #define METAL_ENGINE_IPANEL_H -#include "../../../common/Synchornizable.h" -#include "../../../common/Initializable.h" +#include "../../common/Synchornizable.h" +#include "../../common/Initializable.h" namespace Metal { class IPanel : public Syncronizable, public Initializable { diff --git a/src/editor/abstract/form/FormPanel.cpp b/src/editor/abstract/form/FormPanel.cpp index 13aeb015..5c683c15 100644 --- a/src/editor/abstract/form/FormPanel.cpp +++ b/src/editor/abstract/form/FormPanel.cpp @@ -1,8 +1,8 @@ #include "FormPanel.h" #include "AccordionPanel.h" #include "ChildPanel.h" -#include "../../../../common/FieldType.h" -#include "../../../../common/Inspectable.h" +#include "../../../common/FieldType.h" +#include "../../../common/Inspectable.h" #include "types/IntField.h" #include "types/FloatField.h" #include "types/BooleanField.h" diff --git a/src/editor/abstract/form/types/BooleanField.cpp b/src/editor/abstract/form/types/BooleanField.cpp index 4f145c79..11963c65 100644 --- a/src/editor/abstract/form/types/BooleanField.cpp +++ b/src/editor/abstract/form/types/BooleanField.cpp @@ -2,7 +2,7 @@ #include #include -#include "../../../../../common/Inspectable.h" +#include "../../../../common/Inspectable.h" namespace Metal { BooleanField::BooleanField(InspectedField &field) : field(field) { diff --git a/src/editor/abstract/form/types/BooleanField.h b/src/editor/abstract/form/types/BooleanField.h index 97c485d8..b7e683f9 100644 --- a/src/editor/abstract/form/types/BooleanField.h +++ b/src/editor/abstract/form/types/BooleanField.h @@ -2,7 +2,7 @@ #define METAL_ENGINE_BOOLEANFIELD_H #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/InspectedField.h" +#include "../../../../common/InspectedField.h" namespace Metal { class BooleanField final : public AbstractFormFieldPanel { diff --git a/src/editor/abstract/form/types/ColorField.cpp b/src/editor/abstract/form/types/ColorField.cpp index 985efafc..b63c5967 100644 --- a/src/editor/abstract/form/types/ColorField.cpp +++ b/src/editor/abstract/form/types/ColorField.cpp @@ -1,7 +1,7 @@ #include "ColorField.h" #include #include -#include "../../../../../common/Inspectable.h" +#include "../../../../common/Inspectable.h" namespace Metal { ColorField::ColorField(InspectedField &field) : field(field) { diff --git a/src/editor/abstract/form/types/ColorField.h b/src/editor/abstract/form/types/ColorField.h index 07ea8eef..5d4af9b2 100644 --- a/src/editor/abstract/form/types/ColorField.h +++ b/src/editor/abstract/form/types/ColorField.h @@ -3,7 +3,7 @@ #include #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/InspectedField.h" +#include "../../../../common/InspectedField.h" namespace Metal { class ColorField final : public AbstractFormFieldPanel { diff --git a/src/editor/abstract/form/types/FloatField.cpp b/src/editor/abstract/form/types/FloatField.cpp index 47252dc9..c888e6d8 100644 --- a/src/editor/abstract/form/types/FloatField.cpp +++ b/src/editor/abstract/form/types/FloatField.cpp @@ -1,7 +1,7 @@ #include "FloatField.h" #include #include -#include "../../../../../common/Inspectable.h" +#include "../../../../common/Inspectable.h" namespace Metal { void FloatField::onSync() { diff --git a/src/editor/abstract/form/types/FloatField.h b/src/editor/abstract/form/types/FloatField.h index 509bfafa..80443303 100644 --- a/src/editor/abstract/form/types/FloatField.h +++ b/src/editor/abstract/form/types/FloatField.h @@ -2,7 +2,7 @@ #define METAL_ENGINE_FLOATFIELD_H #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/InspectedField.h" +#include "../../../../common/InspectedField.h" namespace Metal { diff --git a/src/editor/abstract/form/types/IntField.cpp b/src/editor/abstract/form/types/IntField.cpp index 7f2fc001..a8af0903 100644 --- a/src/editor/abstract/form/types/IntField.cpp +++ b/src/editor/abstract/form/types/IntField.cpp @@ -1,7 +1,7 @@ #include "IntField.h" #include #include -#include "../../../../../common/Inspectable.h" +#include "../../../../common/Inspectable.h" namespace Metal { void IntField::onSync() { diff --git a/src/editor/abstract/form/types/IntField.h b/src/editor/abstract/form/types/IntField.h index 6d8a2c68..ffae0f01 100644 --- a/src/editor/abstract/form/types/IntField.h +++ b/src/editor/abstract/form/types/IntField.h @@ -2,7 +2,7 @@ #define METAL_ENGINE_INTFIELD_H #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/InspectedField.h" +#include "../../../../common/InspectedField.h" namespace Metal { class IntField final : public AbstractFormFieldPanel { diff --git a/src/editor/abstract/form/types/MethodField.h b/src/editor/abstract/form/types/MethodField.h index 145c8c6f..9ef1e055 100644 --- a/src/editor/abstract/form/types/MethodField.h +++ b/src/editor/abstract/form/types/MethodField.h @@ -3,7 +3,7 @@ #define METAL_ENGINE_METHODFIELD_H #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/InspectedMethod.h" +#include "../../../../common/InspectedMethod.h" namespace Metal { diff --git a/src/editor/abstract/form/types/QuatField.cpp b/src/editor/abstract/form/types/QuatField.cpp index 512648bb..880f0f82 100644 --- a/src/editor/abstract/form/types/QuatField.cpp +++ b/src/editor/abstract/form/types/QuatField.cpp @@ -2,7 +2,7 @@ #include #include #include -#include "../../../../../common/Inspectable.h" +#include "../../../../common/Inspectable.h" #include "../../../util/UIUtil.h" namespace Metal { diff --git a/src/editor/abstract/form/types/QuatField.h b/src/editor/abstract/form/types/QuatField.h index ed6cd528..833cf1cd 100644 --- a/src/editor/abstract/form/types/QuatField.h +++ b/src/editor/abstract/form/types/QuatField.h @@ -2,7 +2,7 @@ #define QUATFIELD_H #include #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/InspectedField.h" +#include "../../../../common/InspectedField.h" namespace Metal { class QuatField final : public AbstractFormFieldPanel { diff --git a/src/editor/abstract/form/types/ResourceField.cpp b/src/editor/abstract/form/types/ResourceField.cpp index 3c4fac3b..668ec209 100644 --- a/src/editor/abstract/form/types/ResourceField.cpp +++ b/src/editor/abstract/form/types/ResourceField.cpp @@ -4,11 +4,11 @@ #include #include "ResourceFilesPanel.h" -#include "../../../../../common/Icons.h" +#include "../../../../common/Icons.h" #include "../../../util/UIUtil.h" #include "../../../dto/FSEntry.h" -#include "../../../../../context/ApplicationContext.h" -#include "../../../../../common/inspection/Inspectable.h" +#include "../../../../ApplicationContext.h" +#include "../../../../common/Inspectable.h" namespace Metal { constexpr ImGuiWindowFlags flags = ImGuiWindowFlags_NoDocking | diff --git a/src/editor/abstract/form/types/ResourceField.h b/src/editor/abstract/form/types/ResourceField.h index 308976da..8126a42e 100644 --- a/src/editor/abstract/form/types/ResourceField.h +++ b/src/editor/abstract/form/types/ResourceField.h @@ -4,7 +4,7 @@ #include #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/InspectedField.h" +#include "../../../../common/InspectedField.h" #include "imgui.h" namespace Metal { diff --git a/src/editor/abstract/form/types/ResourceFilesPanel.cpp b/src/editor/abstract/form/types/ResourceFilesPanel.cpp index 7cf50247..cf3e6196 100644 --- a/src/editor/abstract/form/types/ResourceFilesPanel.cpp +++ b/src/editor/abstract/form/types/ResourceFilesPanel.cpp @@ -1,6 +1,6 @@ #include "ResourceFilesPanel.h" -#include "../../../../../common/Icons.h" +#include "../../../../common/Icons.h" #include "../../../dto/FSEntry.h" #include "../../../service/FilesService.h" diff --git a/src/editor/abstract/form/types/StringField.cpp b/src/editor/abstract/form/types/StringField.cpp index 2b6ec53d..9f07b8b2 100644 --- a/src/editor/abstract/form/types/StringField.cpp +++ b/src/editor/abstract/form/types/StringField.cpp @@ -1,7 +1,7 @@ #include "StringField.h" #include #include -#include "../../../../../common/Inspectable.h" +#include "../../../../common/Inspectable.h" namespace Metal { StringField::StringField(InspectedField &field) : field(field) { diff --git a/src/editor/abstract/form/types/StringField.h b/src/editor/abstract/form/types/StringField.h index 3e543281..f712b6c5 100644 --- a/src/editor/abstract/form/types/StringField.h +++ b/src/editor/abstract/form/types/StringField.h @@ -2,7 +2,7 @@ #define STRINGFIELD_H #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/InspectedField.h" +#include "../../../../common/InspectedField.h" namespace Metal { diff --git a/src/editor/abstract/form/types/Vec2Field.cpp b/src/editor/abstract/form/types/Vec2Field.cpp index d1d32756..99a88f7f 100644 --- a/src/editor/abstract/form/types/Vec2Field.cpp +++ b/src/editor/abstract/form/types/Vec2Field.cpp @@ -1,7 +1,7 @@ #include "Vec2Field.h" #include #include -#include "../../../../../common/Inspectable.h" +#include "../../../../common/Inspectable.h" #include "../../../util/UIUtil.h" namespace Metal { diff --git a/src/editor/abstract/form/types/Vec2Field.h b/src/editor/abstract/form/types/Vec2Field.h index cbc6212e..fe8d944c 100644 --- a/src/editor/abstract/form/types/Vec2Field.h +++ b/src/editor/abstract/form/types/Vec2Field.h @@ -4,7 +4,7 @@ #include #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/InspectedField.h" +#include "../../../../common/InspectedField.h" namespace Metal { class Vec2Field final : public AbstractFormFieldPanel { diff --git a/src/editor/abstract/form/types/Vec3Field.cpp b/src/editor/abstract/form/types/Vec3Field.cpp index 471f2410..de0ea9b6 100644 --- a/src/editor/abstract/form/types/Vec3Field.cpp +++ b/src/editor/abstract/form/types/Vec3Field.cpp @@ -1,7 +1,7 @@ #include "Vec3Field.h" #include #include -#include "../../../../../common/Inspectable.h" +#include "../../../../common/Inspectable.h" #include "../../../util/UIUtil.h" namespace Metal { diff --git a/src/editor/abstract/form/types/Vec3Field.h b/src/editor/abstract/form/types/Vec3Field.h index dbd36eab..d005b64d 100644 --- a/src/editor/abstract/form/types/Vec3Field.h +++ b/src/editor/abstract/form/types/Vec3Field.h @@ -4,7 +4,7 @@ #include #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/InspectedField.h" +#include "../../../../common/InspectedField.h" namespace Metal { diff --git a/src/editor/abstract/form/types/Vec4Field.cpp b/src/editor/abstract/form/types/Vec4Field.cpp index 8e5932f7..e39247fc 100644 --- a/src/editor/abstract/form/types/Vec4Field.cpp +++ b/src/editor/abstract/form/types/Vec4Field.cpp @@ -1,7 +1,7 @@ #include "Vec4Field.h" #include #include -#include "../../../../../common/Inspectable.h" +#include "../../../../common/Inspectable.h" #include "../../../util/UIUtil.h" namespace Metal { diff --git a/src/editor/abstract/form/types/Vec4Field.h b/src/editor/abstract/form/types/Vec4Field.h index 569fde21..0ce2cae9 100644 --- a/src/editor/abstract/form/types/Vec4Field.h +++ b/src/editor/abstract/form/types/Vec4Field.h @@ -3,7 +3,7 @@ #include #include "../AbstractFormFieldPanel.h" -#include "../../../../../common/InspectedField.h" +#include "../../../../common/InspectedField.h" namespace Metal { class Vec4Field final : public AbstractFormFieldPanel { diff --git a/src/editor/dock-spaces/console/ConsolePanel.cpp b/src/editor/dock-spaces/console/ConsolePanel.cpp index 4b2e40fe..67e17115 100644 --- a/src/editor/dock-spaces/console/ConsolePanel.cpp +++ b/src/editor/dock-spaces/console/ConsolePanel.cpp @@ -2,7 +2,7 @@ #include "imgui.h" #include "../../../ApplicationContext.h" -#include "../../../../common/Icons.h" +#include "../../../common/Icons.h" namespace Metal { ConsolePanel::ConsolePanel() { diff --git a/src/editor/dock-spaces/docks/DockSpacePanel.cpp b/src/editor/dock-spaces/docks/DockSpacePanel.cpp index 6a938445..16098bbc 100644 --- a/src/editor/dock-spaces/docks/DockSpacePanel.cpp +++ b/src/editor/dock-spaces/docks/DockSpacePanel.cpp @@ -4,8 +4,8 @@ #include #include "AbstractDockPanel.h" -#include "../../../../context/ApplicationContext.h" -#include "../../../../common/Icons.h" +#include "../../../ApplicationContext.h" +#include "../../../common/Icons.h" #include "../../dto/DockDTO.h" #include "../../util/UIUtil.h" #include "../../service/LogService.h" diff --git a/src/editor/dock-spaces/files/FilePreviewPanel.cpp b/src/editor/dock-spaces/files/FilePreviewPanel.cpp index 18365979..87a6ca4a 100644 --- a/src/editor/dock-spaces/files/FilePreviewPanel.cpp +++ b/src/editor/dock-spaces/files/FilePreviewPanel.cpp @@ -2,7 +2,7 @@ #include #include "../../util/UIUtil.h" #include "../../dto/FSEntry.h" -#include "../../../../context/ApplicationContext.h" +#include "../../../ApplicationContext.h" #include "../../../engine/resource/TextureInstance.h" namespace Metal { diff --git a/src/editor/dock-spaces/files/FilesHeaderPanel.cpp b/src/editor/dock-spaces/files/FilesHeaderPanel.cpp index 8a0f737b..7b317138 100644 --- a/src/editor/dock-spaces/files/FilesHeaderPanel.cpp +++ b/src/editor/dock-spaces/files/FilesHeaderPanel.cpp @@ -2,9 +2,8 @@ #include "../../enum/EntryType.h" #include "../../dto/FSEntry.h" -#include "../../../../common/Icons.h" -#include "../../util/FilesUtil.h" -#include "../../../../context/ApplicationContext.h" +#include "../../../common/Icons.h" +#include "../../../ApplicationContext.h" #include "../../util/UIUtil.h" namespace Metal { diff --git a/src/editor/dock-spaces/files/FilesListPanel.cpp b/src/editor/dock-spaces/files/FilesListPanel.cpp index 62bb60c0..05b2fa59 100644 --- a/src/editor/dock-spaces/files/FilesListPanel.cpp +++ b/src/editor/dock-spaces/files/FilesListPanel.cpp @@ -3,7 +3,7 @@ #include "FilesPanel.h" #include "FilesContext.h" #include "../../util/UIUtil.h" -#include "../../../../context/ApplicationContext.h" +#include "../../../ApplicationContext.h" #include "../../dto/FSEntry.h" #include "../../service/FilesService.h" #include diff --git a/src/editor/dock-spaces/files/FilesPanel.cpp b/src/editor/dock-spaces/files/FilesPanel.cpp index ab444e51..c09b0515 100644 --- a/src/editor/dock-spaces/files/FilesPanel.cpp +++ b/src/editor/dock-spaces/files/FilesPanel.cpp @@ -3,8 +3,8 @@ #include "FilesHeaderPanel.h" #include "FilesListPanel.h" -#include "../../../../common/Icons.h" -#include "../../../../context/ApplicationContext.h" +#include "../../../common/Icons.h" +#include "../../../ApplicationContext.h" #include "../../dto/SceneData.h" #include "../../util/UIUtil.h" #include "../../dto/FSEntry.h" diff --git a/src/editor/dock-spaces/header/AsyncTaskPanel.cpp b/src/editor/dock-spaces/header/AsyncTaskPanel.cpp index ba3626bc..2cc626c5 100644 --- a/src/editor/dock-spaces/header/AsyncTaskPanel.cpp +++ b/src/editor/dock-spaces/header/AsyncTaskPanel.cpp @@ -1,5 +1,5 @@ #include "AsyncTaskPanel.h" -#include "../../../../context/ApplicationContext.h" +#include "../../../ApplicationContext.h" #include "../../util/UIUtil.h" #include diff --git a/src/editor/dock-spaces/header/EditorHeaderPanel.cpp b/src/editor/dock-spaces/header/EditorHeaderPanel.cpp index 719902c8..b2b577a5 100644 --- a/src/editor/dock-spaces/header/EditorHeaderPanel.cpp +++ b/src/editor/dock-spaces/header/EditorHeaderPanel.cpp @@ -1,7 +1,7 @@ #include "EditorHeaderPanel.h" #include "AsyncTaskPanel.h" #include "../../util/UIUtil.h" -#include "../../../../context/ApplicationContext.h" +#include "../../../ApplicationContext.h" namespace Metal { void EditorHeaderPanel::onSync() { diff --git a/src/editor/dock-spaces/inspector/InspectorPanel.cpp b/src/editor/dock-spaces/inspector/InspectorPanel.cpp index bd827a58..a3c02608 100644 --- a/src/editor/dock-spaces/inspector/InspectorPanel.cpp +++ b/src/editor/dock-spaces/inspector/InspectorPanel.cpp @@ -2,8 +2,8 @@ #include "../../abstract/form/FormPanel.h" #include "../../util/UIUtil.h" -#include "../../../../common/Inspectable.h" -#include "../../../../context/ApplicationContext.h" +#include "../../../common/Inspectable.h" +#include "../../../ApplicationContext.h" #include "../../../engine/dto/MetadataComponent.h" #include #include diff --git a/src/editor/dock-spaces/repositories/RepositoriesPanel.cpp b/src/editor/dock-spaces/repositories/RepositoriesPanel.cpp index 20ba7d80..70957667 100644 --- a/src/editor/dock-spaces/repositories/RepositoriesPanel.cpp +++ b/src/editor/dock-spaces/repositories/RepositoriesPanel.cpp @@ -1,7 +1,7 @@ #include "RepositoriesPanel.h" #include "../../abstract/form/FormPanel.h" -#include "../../../../context/ApplicationContext.h" -#include "../../../../common/Inspectable.h" +#include "../../../ApplicationContext.h" +#include "../../../common/Inspectable.h" namespace Metal { void RepositoriesPanel::onInitialize() { diff --git a/src/editor/dock-spaces/viewport/CameraPositionPanel.cpp b/src/editor/dock-spaces/viewport/CameraPositionPanel.cpp index 7ae495d5..425d60cd 100644 --- a/src/editor/dock-spaces/viewport/CameraPositionPanel.cpp +++ b/src/editor/dock-spaces/viewport/CameraPositionPanel.cpp @@ -1,6 +1,6 @@ #include "CameraPositionPanel.h" -#include "../../../../context/ApplicationContext.h" +#include "../../../ApplicationContext.h" #include "../../util/UIUtil.h" #include "../../../engine/dto/Camera.h" diff --git a/src/editor/dock-spaces/viewport/EngineFramePanel.cpp b/src/editor/dock-spaces/viewport/EngineFramePanel.cpp index 5bcd3602..5ba17e43 100644 --- a/src/editor/dock-spaces/viewport/EngineFramePanel.cpp +++ b/src/editor/dock-spaces/viewport/EngineFramePanel.cpp @@ -1,7 +1,7 @@ #include "EngineFramePanel.h" -#include "../../../../context/ApplicationContext.h" -#include "../../../../context/engine/frame-builder/EngineFrameBuilder.h" -#include "../../../../context/engine/frame-builder/EngineFrame.h" +#include "../../../ApplicationContext.h" +#include "../../../engine/frame-builder/EngineFrameBuilder.h" +#include "../../../engine/frame-builder/EngineFrame.h" #include "../../../engine/dto/DescriptorInstance.h" #include "../../../engine/resource/FrameBufferInstance.h" #include "../../service/PickingService.h" diff --git a/src/editor/dock-spaces/viewport/GizmoPanel.cpp b/src/editor/dock-spaces/viewport/GizmoPanel.cpp index 00106002..501340c3 100644 --- a/src/editor/dock-spaces/viewport/GizmoPanel.cpp +++ b/src/editor/dock-spaces/viewport/GizmoPanel.cpp @@ -1,6 +1,6 @@ #include "GizmoPanel.h" -#include "../../../../context/ApplicationContext.h" +#include "../../../ApplicationContext.h" #include "../../../engine/dto/TransformComponent.h" #include "../../../engine/dto/Camera.h" #include "ImGuizmo.h" diff --git a/src/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp b/src/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp index e8cc266b..75632216 100644 --- a/src/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp +++ b/src/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp @@ -1,6 +1,6 @@ #include "GizmoSettingsPanel.h" #include "../../util/UIUtil.h" -#include "../../../../context/ApplicationContext.h" +#include "../../../ApplicationContext.h" #include "ImGuizmo.h" namespace Metal { diff --git a/src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp b/src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp index 9345dea2..d4dbbafe 100644 --- a/src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp +++ b/src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp @@ -1,7 +1,7 @@ #include "ViewportHeaderPanel.h" #include "GizmoSettingsPanel.h" -#include "../../../../context/ApplicationContext.h" +#include "../../../ApplicationContext.h" #include "../../util/UIUtil.h" namespace Metal { diff --git a/src/editor/dock-spaces/viewport/ViewportPanel.cpp b/src/editor/dock-spaces/viewport/ViewportPanel.cpp index e4e051a2..d923b9ae 100644 --- a/src/editor/dock-spaces/viewport/ViewportPanel.cpp +++ b/src/editor/dock-spaces/viewport/ViewportPanel.cpp @@ -5,10 +5,9 @@ #include "ImGuizmo.h" #include "ViewportHeaderPanel.h" #include "EngineFramePanel.h" -#include "../../../../context/ApplicationContext.h" +#include "../../../ApplicationContext.h" #include "../../../engine/dto/Camera.h" -#include "../../../../context/engine/frame-builder/EngineFrameBuilder.h" -#include "../../enum/engine-definitions.h" +#include "../../../engine/frame-builder/EngineFrameBuilder.h" #include namespace Metal { diff --git a/src/editor/dock-spaces/world/WorldHeaderPanel.cpp b/src/editor/dock-spaces/world/WorldHeaderPanel.cpp index 13306c06..8aea7de6 100644 --- a/src/editor/dock-spaces/world/WorldHeaderPanel.cpp +++ b/src/editor/dock-spaces/world/WorldHeaderPanel.cpp @@ -1,6 +1,6 @@ #include "WorldHeaderPanel.h" -#include "../../../../context/ApplicationContext.h" +#include "../../../ApplicationContext.h" #include "../../util/UIUtil.h" #include "../../../engine/enum/ComponentType.h" diff --git a/src/editor/dock-spaces/world/WorldPanel.cpp b/src/editor/dock-spaces/world/WorldPanel.cpp index 33a1c993..c7cd1842 100644 --- a/src/editor/dock-spaces/world/WorldPanel.cpp +++ b/src/editor/dock-spaces/world/WorldPanel.cpp @@ -1,9 +1,9 @@ #include "WorldPanel.h" #include "WorldHeaderPanel.h" -#include "../../../../common/Icons.h" +#include "../../../common/Icons.h" #include "../../util/UIUtil.h" -#include "../../../../context/ApplicationContext.h" +#include "../../../ApplicationContext.h" #include "../../../engine/dto/MetadataComponent.h" #include "../../../engine/enum/ComponentType.h" diff --git a/src/editor/dto/DockDTO.h b/src/editor/dto/DockDTO.h index b80af738..1d3b84f3 100644 --- a/src/editor/dto/DockDTO.h +++ b/src/editor/dto/DockDTO.h @@ -4,7 +4,7 @@ #include #include #include -#include "../../../repository/dock/DockSpace.h" +#include "DockSpace.h" #include "../util/Util.h" namespace Metal { diff --git a/src/editor/dto/DockSpace.cpp b/src/editor/dto/DockSpace.cpp index 810fc661..186a612a 100644 --- a/src/editor/dto/DockSpace.cpp +++ b/src/editor/dto/DockSpace.cpp @@ -1,5 +1,5 @@ -#include "../../../repository/dock/DockSpace.h" -#include "../../../common/Icons.h" +#include "DockSpace.h" +#include "../../common/Icons.h" #include "../dock-spaces/console/ConsolePanel.h" #include "../dock-spaces/files/FilesPanel.h" #include "../dock-spaces/metrics/MetricsPanel.h" diff --git a/src/editor/dto/EntryMetadata.h b/src/editor/dto/EntryMetadata.h index 4ab792f6..bfb9a00c 100644 --- a/src/editor/dto/EntryMetadata.h +++ b/src/editor/dto/EntryMetadata.h @@ -4,7 +4,7 @@ #include #include "../util/Util.h" #include "../enum/EntryType.h" -#include "../../../common/Serializable.h" +#include "../../common//Serializable.h" namespace Metal { struct EntryMetadata : Serializable { diff --git a/src/editor/dto/ImportSettingsDTO.h b/src/editor/dto/ImportSettingsDTO.h index e6d48c90..061b3a4f 100644 --- a/src/editor/dto/ImportSettingsDTO.h +++ b/src/editor/dto/ImportSettingsDTO.h @@ -1,7 +1,7 @@ #ifndef IMPORTSETTINGSDTO_H #define IMPORTSETTINGSDTO_H -#include "../../../common/Inspectable.h" +#include "../../common//Inspectable.h" namespace Metal { diff --git a/src/editor/dto/OctreeNode.cpp b/src/editor/dto/OctreeNode.cpp index dce3c2ed..e57248ac 100644 --- a/src/editor/dto/OctreeNode.cpp +++ b/src/editor/dto/OctreeNode.cpp @@ -1,4 +1,4 @@ -#include "../../../service/voxel/impl/OctreeNode.h" +#include "OctreeNode.h" namespace Metal { void OctreeNode::addChild(OctreeNode *child, int index) { diff --git a/src/editor/dto/SceneData.h b/src/editor/dto/SceneData.h index 6e52f84b..ef40380e 100644 --- a/src/editor/dto/SceneData.h +++ b/src/editor/dto/SceneData.h @@ -3,7 +3,7 @@ #include #include "SceneEntityData.h" -#include "../../../common/Serializable.h" +#include "../../common//Serializable.h" namespace Metal { diff --git a/src/editor/dto/SparseVoxelOctreeBuilder.cpp b/src/editor/dto/SparseVoxelOctreeBuilder.cpp index 8a6c70f4..4bfb325f 100644 --- a/src/editor/dto/SparseVoxelOctreeBuilder.cpp +++ b/src/editor/dto/SparseVoxelOctreeBuilder.cpp @@ -1,4 +1,4 @@ -#include "../../../service/voxel/impl/SparseVoxelOctreeBuilder.h" +#include "SparseVoxelOctreeBuilder.h" namespace Metal { void SparseVoxelOctreeBuilder::insert(int maxDepth, glm::vec3 point, VoxelData data) { diff --git a/src/editor/enum/NotificationSeverity.h b/src/editor/enum/NotificationSeverity.h index 9c0b303b..e15d107e 100644 --- a/src/editor/enum/NotificationSeverity.h +++ b/src/editor/enum/NotificationSeverity.h @@ -2,7 +2,7 @@ #define NOTIFICATIONSEVERITY_H #include -#include "../../../common/Icons.h" +#include "../../common/Icons.h" namespace Metal::NotificationSeverities { enum NotificationSeverity { diff --git a/src/editor/enum/ShadingMode.h b/src/editor/enum/ShadingMode.h index f3108cf1..3a949993 100644 --- a/src/editor/enum/ShadingMode.h +++ b/src/editor/enum/ShadingMode.h @@ -4,7 +4,7 @@ #include #include -#include "../../../common/Icons.h" +#include "../../common/Icons.h" namespace Metal { enum ShadingMode { diff --git a/src/editor/passes/GridPass.cpp b/src/editor/passes/GridPass.cpp index 65cd233f..365aaef8 100644 --- a/src/editor/passes/GridPass.cpp +++ b/src/editor/passes/GridPass.cpp @@ -1,4 +1,4 @@ -#include "../../engine/passes/impl/tools/GridPass.h" +#include "GridPass.h" #include "../../ApplicationContext.h" #include "../../engine/dto/PipelineBuilder.h" diff --git a/src/editor/passes/IconsPass.cpp b/src/editor/passes/IconsPass.cpp index 62ff2a18..73e0126b 100644 --- a/src/editor/passes/IconsPass.cpp +++ b/src/editor/passes/IconsPass.cpp @@ -1,4 +1,4 @@ -#include "../../engine/passes/impl/tools/IconsPass.h" +#include "IconsPass.h" #include "../../ApplicationContext.h" #include "../../engine/dto/PipelineBuilder.h" diff --git a/src/editor/passes/SelectionOutlinePass.cpp b/src/editor/passes/SelectionOutlinePass.cpp index 8be2221e..d3e542ca 100644 --- a/src/editor/passes/SelectionOutlinePass.cpp +++ b/src/editor/passes/SelectionOutlinePass.cpp @@ -1,4 +1,4 @@ -#include "../../engine/passes/impl/tools/SelectionOutlinePass.h" +#include "SelectionOutlinePass.h" #include "../../ApplicationContext.h" #include "../../engine/dto/TransformComponent.h" diff --git a/src/editor/repository/DockRepository.cpp b/src/editor/repository/DockRepository.cpp index 507c17f8..560f31d7 100644 --- a/src/editor/repository/DockRepository.cpp +++ b/src/editor/repository/DockRepository.cpp @@ -1,4 +1,4 @@ -#include "../../../repository/dock/DockRepository.h" +#include "DockRepository.h" namespace Metal { DockRepository::DockRepository() : AbstractRuntimeComponent() { diff --git a/src/editor/repository/DockRepository.h b/src/editor/repository/DockRepository.h index ab0648b5..9fe872bd 100644 --- a/src/editor/repository/DockRepository.h +++ b/src/editor/repository/DockRepository.h @@ -3,7 +3,7 @@ #include #include "../dto/DockDTO.h" -#include "../../../common/AbstractRuntimeComponent.h" +#include "../../common/AbstractRuntimeComponent.h" namespace Metal { struct DockRepository final : AbstractRuntimeComponent { diff --git a/src/editor/repository/EditorRepository.cpp b/src/editor/repository/EditorRepository.cpp index 108cb4e1..b4cb5b1b 100644 --- a/src/editor/repository/EditorRepository.cpp +++ b/src/editor/repository/EditorRepository.cpp @@ -1,5 +1,5 @@ -#include "../../../repository/editor/EditorRepository.h" -#include "../../../common/Icons.h" +#include "EditorRepository.h" +#include "../../common/Icons.h" namespace Metal { const char *EditorRepository::getTitle() { diff --git a/src/editor/repository/EditorRepository.h b/src/editor/repository/EditorRepository.h index 89d513d2..ea30d277 100644 --- a/src/editor/repository/EditorRepository.h +++ b/src/editor/repository/EditorRepository.h @@ -9,8 +9,8 @@ #include "../dto/ShortcutDTO.h" #include "../enum/engine-definitions.h" #include "../enum/ShadingMode.h" -#include "../../../common/Inspectable.h" -#include "../../../common/Serializable.h" +#include "../../common/Inspectable.h" +#include "../../common/Serializable.h" namespace Metal { struct TransformComponent; diff --git a/src/editor/service/AsyncTaskService.cpp b/src/editor/service/AsyncTaskService.cpp index 24833c25..d2200a0d 100644 --- a/src/editor/service/AsyncTaskService.cpp +++ b/src/editor/service/AsyncTaskService.cpp @@ -1,4 +1,4 @@ -#include "../../../service/notification/AsyncTaskService.h" +#include "AsyncTaskService.h" #include #include #include "../util/Util.h" diff --git a/src/editor/service/AsyncTaskService.h b/src/editor/service/AsyncTaskService.h index 41846f93..71a16e40 100644 --- a/src/editor/service/AsyncTaskService.h +++ b/src/editor/service/AsyncTaskService.h @@ -4,7 +4,6 @@ #include #include #include -#include #include #include "../dto/AsyncTask.h" diff --git a/src/editor/service/DockService.cpp b/src/editor/service/DockService.cpp index 27eb553d..5bbffb0a 100644 --- a/src/editor/service/DockService.cpp +++ b/src/editor/service/DockService.cpp @@ -1,6 +1,6 @@ #include #include -#include "../../../service/dock/DockService.h" +#include "DockService.h" #include "../dto/DockDTO.h" #include "../abstract/AbstractPanel.h" #include "../dock-spaces/docks/AbstractDockPanel.h" diff --git a/src/editor/service/DockService.h b/src/editor/service/DockService.h index f2e96c28..6d00ee6e 100644 --- a/src/editor/service/DockService.h +++ b/src/editor/service/DockService.h @@ -4,7 +4,7 @@ #include "imgui.h" #include "../dto/DockDTO.h" #include "../dock-spaces/docks/DockSpacePanel.h" -#include "../../../common/AbstractRuntimeComponent.h" +#include "../../common/AbstractRuntimeComponent.h" namespace Metal { class AbstractPanel; diff --git a/src/editor/service/FileImporterService.cpp b/src/editor/service/FileImporterService.cpp index 666b5f25..09e8f104 100644 --- a/src/editor/service/FileImporterService.cpp +++ b/src/editor/service/FileImporterService.cpp @@ -1,4 +1,4 @@ -#include "../../../service/files/FileImporterService.h" +#include "FileImporterService.h" #include "../../ApplicationContext.h" #include "LogService.h" diff --git a/src/editor/service/FileImporterService.h b/src/editor/service/FileImporterService.h index 231a3fbc..ee69dcb4 100644 --- a/src/editor/service/FileImporterService.h +++ b/src/editor/service/FileImporterService.h @@ -6,7 +6,7 @@ #include #include "../dto/ImportSettingsDTO.h" -#include "../../../common/AbstractRuntimeComponent.h" +#include "../../common/AbstractRuntimeComponent.h" namespace Metal { class FileImporterService final : public AbstractRuntimeComponent { diff --git a/src/editor/service/FilesService.cpp b/src/editor/service/FilesService.cpp index 48f6dc06..fd0bf822 100644 --- a/src/editor/service/FilesService.cpp +++ b/src/editor/service/FilesService.cpp @@ -1,4 +1,4 @@ -#include "../../../service/files/FilesService.h" +#include "FilesService.h" #include "../dto/FSEntry.h" #include "../enum/EntryType.h" #include "../enum/engine-definitions.h" @@ -10,7 +10,7 @@ #include #include #include -#include "../util/serialization-definitions.h" +#include "../../common/serialization-definitions.h" namespace fs = std::filesystem; diff --git a/src/editor/service/FilesService.h b/src/editor/service/FilesService.h index 299b1b8d..c2906941 100644 --- a/src/editor/service/FilesService.h +++ b/src/editor/service/FilesService.h @@ -4,7 +4,7 @@ #include #include -#include "../../../common/AbstractRuntimeComponent.h" +#include "../../common/AbstractRuntimeComponent.h" namespace Metal { struct FSEntry; diff --git a/src/editor/service/LogService.cpp b/src/editor/service/LogService.cpp index 4225a03b..28cf54e1 100644 --- a/src/editor/service/LogService.cpp +++ b/src/editor/service/LogService.cpp @@ -1,4 +1,4 @@ -#include "../../../service/log/LogService.h" +#include "LogService.h" #include #include #include diff --git a/src/editor/service/LogService.h b/src/editor/service/LogService.h index 22e0487a..94254087 100644 --- a/src/editor/service/LogService.h +++ b/src/editor/service/LogService.h @@ -4,7 +4,7 @@ #include #include #include -#include "../../../common/AbstractRuntimeComponent.h" +#include "../../common/AbstractRuntimeComponent.h" namespace Metal { diff --git a/src/editor/service/MaterialImporterService.h b/src/editor/service/MaterialImporterService.h index 6f731505..5eb416e5 100644 --- a/src/editor/service/MaterialImporterService.h +++ b/src/editor/service/MaterialImporterService.h @@ -6,7 +6,7 @@ #include #include -#include "../../../common/AbstractResourceService.h" +#include "../../common/AbstractResourceService.h" namespace Metal { struct PrimitiveComponent; diff --git a/src/editor/service/MeshImporterService.cpp b/src/editor/service/MeshImporterService.cpp index 9943ad53..4dabe766 100644 --- a/src/editor/service/MeshImporterService.cpp +++ b/src/editor/service/MeshImporterService.cpp @@ -1,13 +1,12 @@ -#include "../../../service/mesh/MeshImporterService.h" +#include "MeshImporterService.h" #include "../../engine/dto/MeshData.h" -#include "../../context/editor/dto/VertexData.h" +#include "../../engine/dto/VertexData.h" #include "../dto/EntryMetadata.h" #include "../enum/engine-definitions.h" #include "../util/FilesUtil.h" #include "../../ApplicationContext.h" #include -#include -#include "../../../util/serialization-definitions.h" +#include "../../common/serialization-definitions.h" namespace Metal { std::string MeshImporterService::persistMesh(const std::string &targetDir, const MeshData &mesh) const { diff --git a/src/editor/service/MeshImporterService.h b/src/editor/service/MeshImporterService.h index 250ea5ac..5d522770 100644 --- a/src/editor/service/MeshImporterService.h +++ b/src/editor/service/MeshImporterService.h @@ -1,7 +1,7 @@ #ifndef MESHIMPORTERSERVICE_H #define MESHIMPORTERSERVICE_H -#include "../../../common/AbstractResourceService.h" +#include "../../common/AbstractResourceService.h" #include #include #include diff --git a/src/editor/service/PickingService.cpp b/src/editor/service/PickingService.cpp index e1ee990e..45c76e19 100644 --- a/src/editor/service/PickingService.cpp +++ b/src/editor/service/PickingService.cpp @@ -1,4 +1,4 @@ -#include "../../../service/picking/PickingService.h" +#include "PickingService.h" #include "../../engine/resource/BufferInstance.h" #include "../../engine/resource/TextureInstance.h" diff --git a/src/editor/service/PickingService.h b/src/editor/service/PickingService.h index 923248e9..36ff15c0 100644 --- a/src/editor/service/PickingService.h +++ b/src/editor/service/PickingService.h @@ -1,7 +1,7 @@ #ifndef PICKINGSERVICE_H #define PICKINGSERVICE_H -#include "../../../common/AbstractResourceService.h" +#include "../../common/AbstractResourceService.h" #include "../enum/engine-definitions.h" #include diff --git a/src/editor/service/SceneImporterService.cpp b/src/editor/service/SceneImporterService.cpp index 7196a0cc..d63b859c 100644 --- a/src/editor/service/SceneImporterService.cpp +++ b/src/editor/service/SceneImporterService.cpp @@ -1,6 +1,6 @@ -#include "../../../service/mesh/SceneImporterService.h" +#include "SceneImporterService.h" -#include "../../../dto/file/FSEntry.h" +#include "../dto/FSEntry.h" #include "../../engine/dto/MeshData.h" #include "../dto/SceneData.h" #include "MaterialImporterService.h" @@ -12,7 +12,7 @@ #include "../dto/EntryMetadata.h" #include "../enum/engine-definitions.h" #include "../../ApplicationContext.h" -#include "../util/serialization-definitions.h" +#include "../../common/serialization-definitions.h" #include "../dto/SceneImportSettingsDTO.h" namespace Metal { diff --git a/src/editor/service/SceneImporterService.h b/src/editor/service/SceneImporterService.h index 29787d7b..6cec5ce0 100644 --- a/src/editor/service/SceneImporterService.h +++ b/src/editor/service/SceneImporterService.h @@ -3,7 +3,7 @@ #include -#include "../../../common/AbstractImporter.h" +#include "../../common/AbstractImporter.h" #include #include diff --git a/src/editor/service/SelectionService.cpp b/src/editor/service/SelectionService.cpp index d2ac6738..245a54ed 100644 --- a/src/editor/service/SelectionService.cpp +++ b/src/editor/service/SelectionService.cpp @@ -1,4 +1,4 @@ -#include "../../../service/selection/SelectionService.h" +#include "SelectionService.h" #include "../../ApplicationContext.h" #include "../../engine/dto/TransformComponent.h" diff --git a/src/editor/service/SelectionService.h b/src/editor/service/SelectionService.h index 1a878d56..f86db212 100644 --- a/src/editor/service/SelectionService.h +++ b/src/editor/service/SelectionService.h @@ -2,7 +2,7 @@ #define SELECTIONSERVICE_H #include -#include "../../../common/AbstractRuntimeComponent.h" +#include "../../common/AbstractRuntimeComponent.h" #include "../enum/engine-definitions.h" namespace Metal { diff --git a/src/editor/service/TextureImporterService.cpp b/src/editor/service/TextureImporterService.cpp index 43723b5d..61697ff1 100644 --- a/src/editor/service/TextureImporterService.cpp +++ b/src/editor/service/TextureImporterService.cpp @@ -4,7 +4,7 @@ #include "../../../../dependencies/stb/stb_image_write.h" #include #include -#include "../util/serialization-definitions.h" +#include "../../common/serialization-definitions.h" #include "../dto/EntryMetadata.h" #include "../enum/EntryType.h" diff --git a/src/editor/service/TextureImporterService.h b/src/editor/service/TextureImporterService.h index 244617ed..7357eeac 100644 --- a/src/editor/service/TextureImporterService.h +++ b/src/editor/service/TextureImporterService.h @@ -1,6 +1,6 @@ #ifndef TEXTUREIMPORTER_H #define TEXTUREIMPORTER_H -#include "../../../common/AbstractImporter.h" +#include "../../common/AbstractImporter.h" struct aiTexture; diff --git a/src/editor/service/ThemeService.cpp b/src/editor/service/ThemeService.cpp index 8e439ab7..4eee2551 100644 --- a/src/editor/service/ThemeService.cpp +++ b/src/editor/service/ThemeService.cpp @@ -1,4 +1,4 @@ -#include "../../../service/theme/ThemeService.h" +#include "ThemeService.h" #include "../../ApplicationContext.h" diff --git a/src/editor/service/ThemeService.h b/src/editor/service/ThemeService.h index b8775037..e9d5f603 100644 --- a/src/editor/service/ThemeService.h +++ b/src/editor/service/ThemeService.h @@ -2,7 +2,7 @@ #define THEMESERVICE_H #include #include -#include "../../../common/AbstractRuntimeComponent.h" +#include "../../common/AbstractRuntimeComponent.h" namespace Metal { diff --git a/src/editor/service/VoxelImporterService.cpp b/src/editor/service/VoxelImporterService.cpp index 86142ef3..101fa675 100644 --- a/src/editor/service/VoxelImporterService.cpp +++ b/src/editor/service/VoxelImporterService.cpp @@ -1,7 +1,7 @@ -#include "../../../service/voxel/VoxelImporterService.h" +#include "VoxelImporterService.h" #include -#include "../util/serialization-definitions.h" +#include "../../common/serialization-definitions.h" #include "../../ApplicationContext.h" #include "../dto/EntryMetadata.h" diff --git a/src/editor/service/VoxelImporterService.h b/src/editor/service/VoxelImporterService.h index 2e1dc578..4cee1f71 100644 --- a/src/editor/service/VoxelImporterService.h +++ b/src/editor/service/VoxelImporterService.h @@ -1,7 +1,7 @@ #ifndef METAL_ENGINE_VOLUMEIMPORTERSERVICE_H #define METAL_ENGINE_VOLUMEIMPORTERSERVICE_H -#include "../../../common/AbstractImporter.h" +#include "../../common/AbstractImporter.h" #include "../dto/SparseVoxelOctreeBuilder.h" #include "../../engine/dto/SparseVoxelOctreeData.h" diff --git a/src/editor/util/UIUtil.h b/src/editor/util/UIUtil.h index 666482bc..dc10a0a2 100644 --- a/src/editor/util/UIUtil.h +++ b/src/editor/util/UIUtil.h @@ -5,7 +5,7 @@ #include #include "../enum/EntryType.h" -#include "../../../common/Icons.h" +#include "../../common/Icons.h" namespace Metal::UIUtil { static constexpr ImVec4 DIRECTORY_COLOR{188 / 255.f, 128 / 255.f, 78 / 255.f, 1}; diff --git a/src/engine/EngineContext.cpp b/src/engine/EngineContext.cpp index ec840921..744ca3ab 100644 --- a/src/engine/EngineContext.cpp +++ b/src/engine/EngineContext.cpp @@ -1,9 +1,8 @@ #include "EngineContext.h" #include "../editor/enum/EngineResourceIDs.h" -#include "../../context/ApplicationContext.h" +#include "../ApplicationContext.h" #include "resource/BufferInstance.h" -#include "dto/Camera.h" #include "dto/TransformComponent.h" namespace Metal { diff --git a/src/engine/EngineContext.h b/src/engine/EngineContext.h index ad04b00c..6c07088d 100644 --- a/src/engine/EngineContext.h +++ b/src/engine/EngineContext.h @@ -6,7 +6,7 @@ #include #include "dto/GlobalDataUBO.h" -#include "../../common/AbstractRuntimeComponent.h" +#include "../common/AbstractRuntimeComponent.h" #include "dto/TileInfoUBO.h" using Clock = std::chrono::high_resolution_clock; diff --git a/src/engine/dto/AbstractComponent.h b/src/engine/dto/AbstractComponent.h index a9fcfd67..5f8db038 100644 --- a/src/engine/dto/AbstractComponent.h +++ b/src/engine/dto/AbstractComponent.h @@ -1,6 +1,6 @@ #ifndef ABSTRACTCOMPONENT_H #define ABSTRACTCOMPONENT_H -#include "../../../common/Inspectable.h" +#include "../../common/Inspectable.h" #include "../enum/ComponentType.h" namespace Metal { diff --git a/src/engine/dto/BoundingBox.h b/src/engine/dto/BoundingBox.h index 0d15dc8b..ec6de8bb 100644 --- a/src/engine/dto/BoundingBox.h +++ b/src/engine/dto/BoundingBox.h @@ -1,7 +1,7 @@ #ifndef BOUNDINGBOX_H #define BOUNDINGBOX_H #include -#include "../../../common/Serializable.h" +#include "../../common/Serializable.h" namespace Metal { struct BoundingBox final : Serializable { diff --git a/src/engine/dto/Camera.cpp b/src/engine/dto/Camera.cpp index b7112275..91260a28 100644 --- a/src/engine/dto/Camera.cpp +++ b/src/engine/dto/Camera.cpp @@ -1,6 +1,6 @@ -#include "../../../service/camera/Camera.h" +#include "Camera.h" -#include "../../../common/Icons.h" +#include "../../common/Icons.h" namespace Metal { void Camera::extractFrustumPlanes(glm::mat4x4 m) { diff --git a/src/engine/dto/Camera.h b/src/engine/dto/Camera.h index b6b0bf7c..70928a1c 100644 --- a/src/engine/dto/Camera.h +++ b/src/engine/dto/Camera.h @@ -6,8 +6,8 @@ #include #include -#include "../../../common/Inspectable.h" -#include "../../../common/Serializable.h" +#include "../../common/Inspectable.h" +#include "../../common/Serializable.h" namespace Metal { diff --git a/src/engine/dto/DescriptorInstance.h b/src/engine/dto/DescriptorInstance.h index ce0fc262..c924f7e5 100644 --- a/src/engine/dto/DescriptorInstance.h +++ b/src/engine/dto/DescriptorInstance.h @@ -3,7 +3,7 @@ #include #include "../resource/RuntimeResource.h" -#include "../../../service/descriptor/DescriptorBinding.h" +#include "DescriptorBinding.h" namespace Metal { struct BufferInstance; diff --git a/src/engine/dto/MeshData.h b/src/engine/dto/MeshData.h index 43811394..2a24bd4c 100644 --- a/src/engine/dto/MeshData.h +++ b/src/engine/dto/MeshData.h @@ -3,7 +3,7 @@ #include #include #include "VertexData.h" -#include "../../editor/util/serialization-definitions.h" +#include "../../common/serialization-definitions.h" namespace Metal { struct MeshData final { diff --git a/src/engine/dto/MetadataComponent.cpp b/src/engine/dto/MetadataComponent.cpp index 14ea7662..7726da77 100644 --- a/src/engine/dto/MetadataComponent.cpp +++ b/src/engine/dto/MetadataComponent.cpp @@ -1,6 +1,4 @@ -#include "../../../repository/world/impl/MetadataComponent.h" -#include "../../../common/Icons.h" -#include "../../editor/util/UIUtil.h" +#include "MetadataComponent.h" namespace Metal { void MetadataComponent::registerFields() { diff --git a/src/engine/dto/MetadataComponent.h b/src/engine/dto/MetadataComponent.h index 0cf4276d..59928072 100644 --- a/src/engine/dto/MetadataComponent.h +++ b/src/engine/dto/MetadataComponent.h @@ -6,8 +6,8 @@ #include "AbstractComponent.h" #include "../../editor/enum/engine-definitions.h" #include "../enum/ComponentType.h" -#include "../../../common/Inspectable.h" -#include "../../../common/Serializable.h" +#include "../../common/Inspectable.h" +#include "../../common/Serializable.h" namespace Metal { struct MetadataComponent final : AbstractComponent, Serializable { diff --git a/src/engine/dto/PipelineBuilder.cpp b/src/engine/dto/PipelineBuilder.cpp index 98ab72d5..5bd8a621 100644 --- a/src/engine/dto/PipelineBuilder.cpp +++ b/src/engine/dto/PipelineBuilder.cpp @@ -1,4 +1,4 @@ -#include "../../../service/pipeline/PipelineBuilder.h" +#include "PipelineBuilder.h" #include "../resource/TextureInstance.h" namespace Metal { diff --git a/src/engine/dto/PrimitiveComponent.cpp b/src/engine/dto/PrimitiveComponent.cpp index 35964482..7018d702 100644 --- a/src/engine/dto/PrimitiveComponent.cpp +++ b/src/engine/dto/PrimitiveComponent.cpp @@ -1,4 +1,4 @@ -#include "../../../repository/world/components/PrimitiveComponent.h" +#include "PrimitiveComponent.h" #include "../../ApplicationContext.h" #include "../../editor/enum/EntryType.h" #include "MeshData.h" diff --git a/src/engine/dto/PrimitiveComponent.h b/src/engine/dto/PrimitiveComponent.h index d49c8afc..5b112d5c 100644 --- a/src/engine/dto/PrimitiveComponent.h +++ b/src/engine/dto/PrimitiveComponent.h @@ -2,7 +2,7 @@ #define PRIMITIVE_COMPONENT_H #include "AbstractComponent.h" -#include "../../../common/Serializable.h" +#include "../../common/Serializable.h" #include namespace Metal { diff --git a/src/engine/dto/ShaderModule.cpp b/src/engine/dto/ShaderModule.cpp index a11e2fb8..2149f95a 100644 --- a/src/engine/dto/ShaderModule.cpp +++ b/src/engine/dto/ShaderModule.cpp @@ -1,6 +1,6 @@ -#include "../../../service/pipeline/ShaderModule.h" +#include "ShaderModule.h" -#include "../../vulkan/VulkanContext.h" +#include "../../core/vulkan/VulkanContext.h" namespace Metal { void ShaderModule::initialize(glslang_program_t *program) { diff --git a/src/engine/dto/SparseVoxelOctreeData.h b/src/engine/dto/SparseVoxelOctreeData.h index 87987780..0c4f3be5 100644 --- a/src/engine/dto/SparseVoxelOctreeData.h +++ b/src/engine/dto/SparseVoxelOctreeData.h @@ -4,7 +4,7 @@ #include #include -#include "../../../common/Serializable.h" +#include "../../common/Serializable.h" namespace Metal { struct SparseVoxelOctreeData final : Serializable { diff --git a/src/engine/dto/TransformComponent.cpp b/src/engine/dto/TransformComponent.cpp index da3e63b1..a929c214 100644 --- a/src/engine/dto/TransformComponent.cpp +++ b/src/engine/dto/TransformComponent.cpp @@ -1,5 +1,5 @@ -#include "../../../repository/world/components/TransformComponent.h" -#include "../../../repository/world/components/VolumeComponent.h" +#include "TransformComponent.h" +#include "VolumeComponent.h" #include "../../ApplicationContext.h" #define ROTATION "Rotation" diff --git a/src/engine/dto/TransformComponent.h b/src/engine/dto/TransformComponent.h index 1857e1eb..78974590 100644 --- a/src/engine/dto/TransformComponent.h +++ b/src/engine/dto/TransformComponent.h @@ -6,7 +6,7 @@ #include #include "AbstractComponent.h" -#include "../../../common/Serializable.h" +#include "../../common/Serializable.h" namespace Metal { diff --git a/src/engine/dto/VertexData.h b/src/engine/dto/VertexData.h index 677c9fc2..b9468cfb 100644 --- a/src/engine/dto/VertexData.h +++ b/src/engine/dto/VertexData.h @@ -4,7 +4,7 @@ #include #include -#include "../../editor/util/serialization-definitions.h" +#include "../../common/serialization-definitions.h" namespace Metal { struct VertexData final { diff --git a/src/engine/dto/VolumeComponent.cpp b/src/engine/dto/VolumeComponent.cpp index 0d9455cc..56829e59 100644 --- a/src/engine/dto/VolumeComponent.cpp +++ b/src/engine/dto/VolumeComponent.cpp @@ -1,4 +1,4 @@ -#include "../../../repository/world/components/VolumeComponent.h" +#include "VolumeComponent.h" #include "../../ApplicationContext.h" namespace Metal { diff --git a/src/engine/dto/VolumeComponent.h b/src/engine/dto/VolumeComponent.h index 57a77cf2..c886278b 100644 --- a/src/engine/dto/VolumeComponent.h +++ b/src/engine/dto/VolumeComponent.h @@ -2,7 +2,7 @@ #define VOLUMECOMPONENT_H #include "AbstractComponent.h" -#include "../../../common/Serializable.h" +#include "../../common/Serializable.h" #include namespace Metal { diff --git a/src/engine/enum/ComponentType.cpp b/src/engine/enum/ComponentType.cpp index 8ffb8a23..74fa1e67 100644 --- a/src/engine/enum/ComponentType.cpp +++ b/src/engine/enum/ComponentType.cpp @@ -1,4 +1,4 @@ -#include "../../../enum/ComponentType.h" +#include "ComponentType.h" #include "../repository/WorldRepository.h" #include "../../ApplicationContext.h" diff --git a/src/engine/enum/ComponentType.h b/src/engine/enum/ComponentType.h index 90bddb09..5cfc8fad 100644 --- a/src/engine/enum/ComponentType.h +++ b/src/engine/enum/ComponentType.h @@ -5,7 +5,6 @@ #include #include #include -#include "../../../common/Icons.h" namespace Metal { class Inspectable; diff --git a/src/engine/frame-builder/EngineFrameBuilder.cpp b/src/engine/frame-builder/EngineFrameBuilder.cpp index 9b870737..82804505 100644 --- a/src/engine/frame-builder/EngineFrameBuilder.cpp +++ b/src/engine/frame-builder/EngineFrameBuilder.cpp @@ -8,7 +8,6 @@ #include "EngineFrame.h" #include "../../ApplicationContext.h" #include "../passes/CommandBufferRecorder.h" -#include "../render-pass/impl/tools/SelectionOutlinePass.h" namespace Metal { EngineFrameBuilder::EngineFrameBuilder(std::string frameId) : frameId(std::move(frameId)) { diff --git a/src/engine/frame-builder/structures/PassBuilder.cpp b/src/engine/frame-builder/structures/PassBuilder.cpp index ee326176..8d9d8278 100644 --- a/src/engine/frame-builder/structures/PassBuilder.cpp +++ b/src/engine/frame-builder/structures/PassBuilder.cpp @@ -1,12 +1,12 @@ #include "PassBuilder.h" -#include "../../render-pass/impl/PostProcessingPass.h" +#include "../../passes/impl/PostProcessingPass.h" #include "../../passes/impl/HWRayTracingPass.h" #include "../../passes/impl/TemporalAccumulationPass.h" #include "../../passes/impl/SpatialFilterPass.h" -#include "../../render-pass/impl/tools/SelectionOutlinePass.h" -#include "../../render-pass/impl/tools/GridPass.h" -#include "../../render-pass/impl/tools/IconsPass.h" -#include "../../render-pass/impl/tools/SelectionIDPass.h" +#include "../../../editor/passes/SelectionOutlinePass.h" +#include "../../../editor/passes/GridPass.h" +#include "../../../editor/passes/IconsPass.h" +#include "../../../editor/passes/SelectionIDPass.h" namespace Metal { RuntimeResource* PassBuilder::build() { diff --git a/src/engine/passes/AbstractComputePass.cpp b/src/engine/passes/AbstractComputePass.cpp index b847add8..cd34e278 100644 --- a/src/engine/passes/AbstractComputePass.cpp +++ b/src/engine/passes/AbstractComputePass.cpp @@ -1,4 +1,4 @@ -#include "../compute-pass/AbstractComputePass.h" +#include "AbstractComputePass.h" #include "../../ApplicationContext.h" #include "../resource/PipelineInstance.h" #include "../resource/TextureInstance.h" diff --git a/src/engine/passes/AbstractPass.cpp b/src/engine/passes/AbstractPass.cpp index 2000f968..a0dbd400 100644 --- a/src/engine/passes/AbstractPass.cpp +++ b/src/engine/passes/AbstractPass.cpp @@ -1,6 +1,6 @@ #include "AbstractPass.h" #include "../frame-builder/EngineFrame.h" -#include "../../../context/ApplicationContext.h" +#include "../../ApplicationContext.h" #include "../resource/PipelineInstance.h" namespace Metal { diff --git a/src/engine/passes/AbstractPass.h b/src/engine/passes/AbstractPass.h index f95e11fd..d5fffc8f 100644 --- a/src/engine/passes/AbstractPass.h +++ b/src/engine/passes/AbstractPass.h @@ -3,7 +3,7 @@ #include #include #include -#include "../../../common/AbstractRuntimeComponent.h" +#include "../../common/AbstractRuntimeComponent.h" #include "../resource/RuntimeResource.h" namespace Metal { diff --git a/src/engine/passes/AbstractRenderPass.cpp b/src/engine/passes/AbstractRenderPass.cpp index 16cd6eb6..c8b1084f 100644 --- a/src/engine/passes/AbstractRenderPass.cpp +++ b/src/engine/passes/AbstractRenderPass.cpp @@ -1,6 +1,5 @@ -#include "render-pass/AbstractRenderPass.h" -#include "../../../context/ApplicationContext.h" -#include "../resource/PipelineInstance.h" +#include "AbstractRenderPass.h" +#include "../../ApplicationContext.h" #include "../resource/MeshInstance.h" #include "../resource/BufferInstance.h" diff --git a/src/engine/passes/CommandBufferRecorder.cpp b/src/engine/passes/CommandBufferRecorder.cpp index f7019f61..785eb2f6 100644 --- a/src/engine/passes/CommandBufferRecorder.cpp +++ b/src/engine/passes/CommandBufferRecorder.cpp @@ -1,14 +1,12 @@ #include "CommandBufferRecorder.h" #include -#include -#include "../dto/DescriptorInstance.h" #include "../resource/FrameBufferInstance.h" #include "../resource/PipelineInstance.h" #include "../../ApplicationContext.h" -#include "../render-pass/AbstractRenderPass.h" -#include "../../vulkan/VulkanUtils.h" +#include "AbstractRenderPass.h" +#include "../../core/vulkan/VulkanUtils.h" namespace Metal { void CommandBufferRecorder::createCommandBuffer() { diff --git a/src/engine/passes/CommandBufferRecorder.h b/src/engine/passes/CommandBufferRecorder.h index 7897160d..f7b367c9 100644 --- a/src/engine/passes/CommandBufferRecorder.h +++ b/src/engine/passes/CommandBufferRecorder.h @@ -4,7 +4,7 @@ #include #include #include "../resource/PipelineInstance.h" -#include "../../vulkan/VulkanUtils.h" +#include "../../core/vulkan/VulkanUtils.h" namespace Metal { class AbstractPass; diff --git a/src/engine/passes/impl/HWRayTracingPass.cpp b/src/engine/passes/impl/HWRayTracingPass.cpp index 5a9dbeca..cc537f3e 100644 --- a/src/engine/passes/impl/HWRayTracingPass.cpp +++ b/src/engine/passes/impl/HWRayTracingPass.cpp @@ -1,6 +1,5 @@ -#include "../../compute-pass/impl/HWRayTracingPass.h" +#include "HWRayTracingPass.h" #include "../../../ApplicationContext.h" -#include "../../resource/FrameBufferInstance.h" #include "../../dto/PipelineBuilder.h" #include "../../resource/PipelineInstance.h" #include "../../resource/TextureInstance.h" diff --git a/src/engine/passes/impl/PostProcessingPass.cpp b/src/engine/passes/impl/PostProcessingPass.cpp index 543fe4aa..67aab25f 100644 --- a/src/engine/passes/impl/PostProcessingPass.cpp +++ b/src/engine/passes/impl/PostProcessingPass.cpp @@ -1,6 +1,6 @@ -#include "../render-pass/impl/PostProcessingPass.h" +#include "PostProcessingPass.h" -#include "../../../../context/ApplicationContext.h" +#include "../../../ApplicationContext.h" #include "../../dto/PipelineBuilder.h" #include "../../../editor/enum/EngineResourceIDs.h" diff --git a/src/engine/passes/impl/SpatialFilterPass.cpp b/src/engine/passes/impl/SpatialFilterPass.cpp index 3a3aa6ff..291d7b5f 100644 --- a/src/engine/passes/impl/SpatialFilterPass.cpp +++ b/src/engine/passes/impl/SpatialFilterPass.cpp @@ -1,4 +1,4 @@ -#include "../../compute-pass/impl/SpatialFilterPass.h" +#include "SpatialFilterPass.h" #include "../../../ApplicationContext.h" #include "../../dto/PipelineBuilder.h" #include "../../resource/TextureInstance.h" diff --git a/src/engine/passes/impl/TemporalAccumulationPass.cpp b/src/engine/passes/impl/TemporalAccumulationPass.cpp index d7108241..e1d1029d 100644 --- a/src/engine/passes/impl/TemporalAccumulationPass.cpp +++ b/src/engine/passes/impl/TemporalAccumulationPass.cpp @@ -1,4 +1,4 @@ -#include "../../compute-pass/impl/TemporalAccumulationPass.h" +#include "TemporalAccumulationPass.h" #include "../../../ApplicationContext.h" #include "../../dto/PipelineBuilder.h" #include "../../resource/TextureInstance.h" diff --git a/src/engine/repository/EngineRepository.cpp b/src/engine/repository/EngineRepository.cpp index f5ac4024..30489fef 100644 --- a/src/engine/repository/EngineRepository.cpp +++ b/src/engine/repository/EngineRepository.cpp @@ -1,9 +1,8 @@ -#include "../../../repository/engine/EngineRepository.h" +#include "EngineRepository.h" -#include "../../../common/Icons.h" +#include "../../common/Icons.h" #include "../../ApplicationContext.h" -#define LEVEL_OF_DETAIL "Level of detail" #define PATH_TRACER "Path tracer" #define ATMOSPHERE "Atmosphere" #define SUN "Sun" diff --git a/src/engine/repository/EngineRepository.h b/src/engine/repository/EngineRepository.h index 0870e1b0..fe2b81dc 100644 --- a/src/engine/repository/EngineRepository.h +++ b/src/engine/repository/EngineRepository.h @@ -1,8 +1,8 @@ #ifndef ENGINEREPO_H #define ENGINEREPO_H -#include "../../../common/Inspectable.h" +#include "../../common/Inspectable.h" #include -#include "../../../common/Serializable.h" +#include "../../common/Serializable.h" namespace Metal { struct EngineRepository final : Inspectable, Serializable { diff --git a/src/engine/repository/WorldRepository.cpp b/src/engine/repository/WorldRepository.cpp index aa0da49b..812ccace 100644 --- a/src/engine/repository/WorldRepository.cpp +++ b/src/engine/repository/WorldRepository.cpp @@ -1,9 +1,9 @@ -#include "../../../repository/world/WorldRepository.h" +#include "WorldRepository.h" #include "../../ApplicationContext.h" #include "../enum/ComponentType.h" #include "../../editor/dto/SceneData.h" -#include "../../editor/util/serialization-definitions.h" +#include "../../common/serialization-definitions.h" namespace Metal { entt::entity WorldRepository::createEntity() { diff --git a/src/engine/repository/WorldRepository.h b/src/engine/repository/WorldRepository.h index 86d0f415..1a42b233 100644 --- a/src/engine/repository/WorldRepository.h +++ b/src/engine/repository/WorldRepository.h @@ -6,8 +6,8 @@ #include #include -#include "../../../common/AbstractRuntimeComponent.h" -#include "../../../common/Serializable.h" +#include "../../common/AbstractRuntimeComponent.h" +#include "../../common/Serializable.h" #include "../../editor/enum/engine-definitions.h" #include "../dto/Camera.h" #include "../dto/MetadataComponent.h" diff --git a/src/engine/resource/BufferInstance.cpp b/src/engine/resource/BufferInstance.cpp index a8698cb0..e2144325 100644 --- a/src/engine/resource/BufferInstance.cpp +++ b/src/engine/resource/BufferInstance.cpp @@ -1,10 +1,4 @@ -#include "../../../service/buffer/BufferInstance.h" - -#include -#include "../../editor/service/LogService.h" -#include "../../ApplicationContext.h" -#include "../../vulkan/VulkanContext.h" -#include "../../vulkan/VulkanUtils.h" +#include "BufferInstance.h" namespace Metal { BufferType BufferInstance::getBufferType() { diff --git a/src/engine/resource/FrameBufferAttachment.cpp b/src/engine/resource/FrameBufferAttachment.cpp index cf4a0c4c..3e830173 100644 --- a/src/engine/resource/FrameBufferAttachment.cpp +++ b/src/engine/resource/FrameBufferAttachment.cpp @@ -1,4 +1,4 @@ -#include "../../../service/framebuffer/FrameBufferAttachment.h" +#include "FrameBufferAttachment.h" #include "../../ApplicationContext.h" diff --git a/src/engine/resource/TextureInstance.h b/src/engine/resource/TextureInstance.h index 0f78471e..e77fbafd 100644 --- a/src/engine/resource/TextureInstance.h +++ b/src/engine/resource/TextureInstance.h @@ -1,10 +1,8 @@ #ifndef TEXTUREINSTANCE_H #define TEXTUREINSTANCE_H -#include #include "../dto/DescriptorInstance.h" -#include "../../../common/RuntimeResource.h" -#include "../../vulkan/VulkanContext.h" +#include "RuntimeResource.h" namespace Metal { struct TextureInstance final : RuntimeResource { diff --git a/src/engine/service/BufferService.cpp b/src/engine/service/BufferService.cpp index 0b6beec3..27161788 100644 --- a/src/engine/service/BufferService.cpp +++ b/src/engine/service/BufferService.cpp @@ -1,7 +1,7 @@ -#include "../../../service/buffer/BufferService.h" +#include "BufferService.h" #include "../../ApplicationContext.h" -#include "../../vulkan/VulkanUtils.h" +#include "../../core/vulkan/VulkanUtils.h" #include "../resource/BufferInstance.h" namespace Metal { diff --git a/src/engine/service/BufferService.h b/src/engine/service/BufferService.h index 91de4573..a171a084 100644 --- a/src/engine/service/BufferService.h +++ b/src/engine/service/BufferService.h @@ -3,7 +3,7 @@ #include #include -#include "../../../common/AbstractResourceService.h" +#include "../../common/AbstractResourceService.h" #include "../resource/BufferInstance.h" #include "vulkan/vulkan.h" diff --git a/src/engine/service/CameraService.cpp b/src/engine/service/CameraService.cpp index 9058a3f1..3f58a727 100644 --- a/src/engine/service/CameraService.cpp +++ b/src/engine/service/CameraService.cpp @@ -1,4 +1,4 @@ -#include "../../../service/camera/CameraService.h" +#include "CameraService.h" #include "../dto/Camera.h" #include "../../ApplicationContext.h" diff --git a/src/engine/service/CameraService.h b/src/engine/service/CameraService.h index 98efd602..967f3a1c 100644 --- a/src/engine/service/CameraService.h +++ b/src/engine/service/CameraService.h @@ -1,7 +1,7 @@ #ifndef CAMERASYSTEM_H #define CAMERASYSTEM_H -#include "../../../common/AbstractRuntimeComponent.h" +#include "../../common/AbstractRuntimeComponent.h" #include #include diff --git a/src/engine/service/CommandBufferRecorderService.h b/src/engine/service/CommandBufferRecorderService.h index d4ce7c7c..c741b512 100644 --- a/src/engine/service/CommandBufferRecorderService.h +++ b/src/engine/service/CommandBufferRecorderService.h @@ -1,7 +1,7 @@ #ifndef COMMANDBUFFERRECORDERSERVICE_H #define COMMANDBUFFERRECORDERSERVICE_H -#include "../../../common/AbstractResourceService.h" +#include "../../common/AbstractResourceService.h" #include "../passes/CommandBufferRecorder.h" namespace Metal { diff --git a/src/engine/service/DescriptorSetService.cpp b/src/engine/service/DescriptorSetService.cpp index 3ee642d5..901a1f0a 100644 --- a/src/engine/service/DescriptorSetService.cpp +++ b/src/engine/service/DescriptorSetService.cpp @@ -1,12 +1,12 @@ -#include "../../../service/descriptor/DescriptorSetService.h" +#include "DescriptorSetService.h" #include "../dto/PipelineBuilder.h" #include "../resource/BufferInstance.h" #include "../../editor/service/LogService.h" #include "../../ApplicationContext.h" #include "../resource/FrameBufferAttachment.h" -#include "../../../service/framebuffer/FrameBufferInstance.h" +#include "../resource/FrameBufferInstance.h" #include "../resource/TextureInstance.h" -#include "../../vulkan/VulkanUtils.h" +#include "../../core/vulkan/VulkanUtils.h" namespace Metal { DescriptorInstance *DescriptorSetService::createDescriptor(const PipelineBuilder &pipelineBuilder, const std::string &id, VkShaderStageFlags stageFlags) { diff --git a/src/engine/service/DescriptorSetService.h b/src/engine/service/DescriptorSetService.h index 3777cf71..fd5d7833 100644 --- a/src/engine/service/DescriptorSetService.h +++ b/src/engine/service/DescriptorSetService.h @@ -1,7 +1,7 @@ #ifndef DESCRIPTORSETSERVICE_H #define DESCRIPTORSETSERVICE_H -#include "../../../common/AbstractResourceService.h" +#include "../../common/AbstractResourceService.h" #include "../dto/DescriptorInstance.h" namespace Metal { diff --git a/src/engine/service/FrameBufferService.cpp b/src/engine/service/FrameBufferService.cpp index 5188c427..1f90f6c5 100644 --- a/src/engine/service/FrameBufferService.cpp +++ b/src/engine/service/FrameBufferService.cpp @@ -1,11 +1,11 @@ -#include "../../../service/framebuffer/FrameBufferService.h" +#include "FrameBufferService.h" #include #include #include -#include "FrameBufferInstance.h" -#include "../../vulkan/VulkanUtils.h" +#include "../resource/FrameBufferInstance.h" +#include "../../core/vulkan/VulkanUtils.h" #include "../resource/FrameBufferAttachment.h" #include "../../ApplicationContext.h" diff --git a/src/engine/service/FrameBufferService.h b/src/engine/service/FrameBufferService.h index 985f3ab4..5cc4c221 100644 --- a/src/engine/service/FrameBufferService.h +++ b/src/engine/service/FrameBufferService.h @@ -5,7 +5,7 @@ #include #include -#include "../../../common/AbstractResourceService.h" +#include "../../common/AbstractResourceService.h" #include "../resource/FrameBufferInstance.h" namespace Metal { diff --git a/src/engine/service/LightService.cpp b/src/engine/service/LightService.cpp index e120c769..3d759aa0 100644 --- a/src/engine/service/LightService.cpp +++ b/src/engine/service/LightService.cpp @@ -1,4 +1,4 @@ -#include "../../../service/lights/LightService.h" +#include "LightService.h" #include "../../ApplicationContext.h" #include "../resource/BufferInstance.h" #include "../../editor/enum/EngineResourceIDs.h" diff --git a/src/engine/service/LightService.h b/src/engine/service/LightService.h index c7046f2a..655781c9 100644 --- a/src/engine/service/LightService.h +++ b/src/engine/service/LightService.h @@ -2,7 +2,7 @@ #define LIGHTSSERVICE_H #include -#include "../../../common/AbstractRuntimeComponent.h" +#include "../../common/AbstractRuntimeComponent.h" #include "../dto/LightData.h" namespace Metal { diff --git a/src/engine/service/MaterialService.cpp b/src/engine/service/MaterialService.cpp index ce5ef1cf..a42e5b3b 100644 --- a/src/engine/service/MaterialService.cpp +++ b/src/engine/service/MaterialService.cpp @@ -1,6 +1,6 @@ -#include "../../../service/material/MaterialService.h" +#include "MaterialService.h" -#include "../../editor/util/serialization-definitions.h" +#include "../../common/serialization-definitions.h" #include "../dto/MeshMetadata.h" #include "../../ApplicationContext.h" diff --git a/src/engine/service/MeshService.cpp b/src/engine/service/MeshService.cpp index a642e127..d3838b01 100644 --- a/src/engine/service/MeshService.cpp +++ b/src/engine/service/MeshService.cpp @@ -1,18 +1,15 @@ -#include "../../../service/mesh/MeshService.h" +#include "MeshService.h" #include "../resource/MeshInstance.h" #include "../dto/MeshData.h" #include "../../editor/dto/SceneData.h" -#include "../../vulkan/VulkanContext.h" +#include "../../core/vulkan/VulkanContext.h" #include "../../editor/util/FilesUtil.h" -#include "../../editor/util/serialization-definitions.h" #include #include #include "../../ApplicationContext.h" -#include "../dto/PrimitiveComponent.h" -#include "../dto/TransformComponent.h" namespace Metal { MeshInstance *MeshService::create(const std::string &id) { diff --git a/src/engine/service/MeshService.h b/src/engine/service/MeshService.h index 396af5d1..671c7baf 100644 --- a/src/engine/service/MeshService.h +++ b/src/engine/service/MeshService.h @@ -1,6 +1,6 @@ #ifndef MESHSERVICE_H #define MESHSERVICE_H -#include "../../../common/AbstractResourceService.h" +#include "../../common/AbstractResourceService.h" #include "../resource/MeshInstance.h" #include "../../editor/enum/engine-definitions.h" diff --git a/src/engine/service/PipelineService.cpp b/src/engine/service/PipelineService.cpp index 56884e6d..30df93ea 100644 --- a/src/engine/service/PipelineService.cpp +++ b/src/engine/service/PipelineService.cpp @@ -1,13 +1,12 @@ -#include "../../../service/pipeline/PipelineService.h" - +#include "PipelineService.h" #include "../dto/PipelineBuilder.h" #include "../util/ShaderUtil.h" #include "../../ApplicationContext.h" -#include "../../vulkan/VulkanUtils.h" -#include "../framebuffer/FrameBufferInstance.h" +#include "../../core/vulkan/VulkanUtils.h" +#include "../resource/FrameBufferInstance.h" #include "../resource/PipelineInstance.h" #include "../dto/MeshData.h" -#include "../../context/editor/dto/VertexData.h" +#include "../dto/VertexData.h" #include "../dto/DescriptorInstance.h" #include "../resource/FrameBufferAttachment.h" #include "../resource/BufferInstance.h" diff --git a/src/engine/service/PipelineService.h b/src/engine/service/PipelineService.h index d43d8ce1..6d97a544 100644 --- a/src/engine/service/PipelineService.h +++ b/src/engine/service/PipelineService.h @@ -2,7 +2,7 @@ #define PIPELINESERVICE_H #include -#include "../../../common/AbstractResourceService.h" +#include "../../common/AbstractResourceService.h" #include "DescriptorSetService.h" #include "../resource/PipelineInstance.h" diff --git a/src/engine/service/RayTracingService.cpp b/src/engine/service/RayTracingService.cpp index 1210906e..d46be68a 100644 --- a/src/engine/service/RayTracingService.cpp +++ b/src/engine/service/RayTracingService.cpp @@ -1,11 +1,11 @@ -#include "../../../service/raytracing/RayTracingService.h" +#include "RayTracingService.h" #include "../../ApplicationContext.h" #include "../resource/BufferInstance.h" #include "../dto/DescriptorInstance.h" -#include "../../../service/descriptor/DescriptorBinding.h" +#include "../dto/DescriptorBinding.h" #include "../resource/MeshInstance.h" #include "../dto/VertexData.h" -#include "../../vulkan/VulkanUtils.h" +#include "../../core/vulkan/VulkanUtils.h" #include "../../editor/enum/EngineResourceIDs.h" #include diff --git a/src/engine/service/RayTracingService.h b/src/engine/service/RayTracingService.h index a646b23c..e4b35fa7 100644 --- a/src/engine/service/RayTracingService.h +++ b/src/engine/service/RayTracingService.h @@ -8,7 +8,7 @@ #include #include #include -#include "../../../common/AbstractRuntimeComponent.h" +#include "../../common/AbstractRuntimeComponent.h" namespace Metal { struct BufferInstance; diff --git a/src/engine/service/StreamingService.cpp b/src/engine/service/StreamingService.cpp index 6ddb487a..48895cb4 100644 --- a/src/engine/service/StreamingService.cpp +++ b/src/engine/service/StreamingService.cpp @@ -1,4 +1,4 @@ -#include "../../../repository/streaming/StreamingService.h" +#include "StreamingService.h" #include "../../ApplicationContext.h" #include "../resource/SVOInstance.h" diff --git a/src/engine/service/StreamingService.h b/src/engine/service/StreamingService.h index f2b6a1d8..ccd7e5af 100644 --- a/src/engine/service/StreamingService.h +++ b/src/engine/service/StreamingService.h @@ -4,9 +4,8 @@ #include #include -#include "../../../common/AbstractResourceService.h" -#include "../../../common/AbstractCoreRepository.h" -#include "../../../repository/abstract/RuntimeResource.h" +#include "../../common/AbstractResourceService.h" +#include "../../common/AbstractCoreRepository.h" using Clock = std::chrono::high_resolution_clock; using TimePoint = std::chrono::time_point; diff --git a/src/engine/service/TextureService.cpp b/src/engine/service/TextureService.cpp index 4e71cd3f..8f20419f 100644 --- a/src/engine/service/TextureService.cpp +++ b/src/engine/service/TextureService.cpp @@ -1,4 +1,4 @@ -#include "../../../service/texture/TextureService.h" +#include "TextureService.h" #include diff --git a/src/engine/service/TextureService.h b/src/engine/service/TextureService.h index 4184817f..e1eff442 100644 --- a/src/engine/service/TextureService.h +++ b/src/engine/service/TextureService.h @@ -5,7 +5,7 @@ #include #include "../dto/TextureData.h" -#include "../../../common/AbstractResourceService.h" +#include "../../common/AbstractResourceService.h" #include "../resource/TextureInstance.h" namespace Metal { diff --git a/src/engine/service/TransformService.cpp b/src/engine/service/TransformService.cpp index 8a7a0a4f..5dfdc638 100644 --- a/src/engine/service/TransformService.cpp +++ b/src/engine/service/TransformService.cpp @@ -1,4 +1,4 @@ -#include "../../../service/transform/TransformService.h" +#include "TransformService.h" #include #include #include diff --git a/src/engine/service/TransformService.h b/src/engine/service/TransformService.h index 1d5d88d8..ff399b3e 100644 --- a/src/engine/service/TransformService.h +++ b/src/engine/service/TransformService.h @@ -5,7 +5,7 @@ #include #include "../../editor/enum/engine-definitions.h" -#include "../../../common/AbstractRuntimeComponent.h" +#include "../../common/AbstractRuntimeComponent.h" namespace Metal { struct TransformComponent; diff --git a/src/engine/service/VolumeService.cpp b/src/engine/service/VolumeService.cpp index 2e19ef20..2f5cde9f 100644 --- a/src/engine/service/VolumeService.cpp +++ b/src/engine/service/VolumeService.cpp @@ -1,4 +1,4 @@ -#include "../../../service/volumes/VolumeService.h" +#include "VolumeService.h" #include "../../ApplicationContext.h" #include "../dto/VolumeComponent.h" #include "../resource/BufferInstance.h" diff --git a/src/engine/service/VolumeService.h b/src/engine/service/VolumeService.h index 3df0d4e7..2feafe3e 100644 --- a/src/engine/service/VolumeService.h +++ b/src/engine/service/VolumeService.h @@ -2,7 +2,7 @@ #define VOLUME_SERVICE_H #include -#include "../../../common/AbstractRuntimeComponent.h" +#include "../../common/AbstractRuntimeComponent.h" #include "../dto/VolumeData.h" namespace Metal { diff --git a/src/engine/service/VoxelService.cpp b/src/engine/service/VoxelService.cpp index ab70ff5e..d1db5046 100644 --- a/src/engine/service/VoxelService.cpp +++ b/src/engine/service/VoxelService.cpp @@ -1,8 +1,4 @@ -// -// Created by russi on 2/18/2026. -// - -#include "../../../service/voxel/VoxelService.h" +#include "VoxelService.h" #include "../resource/SVOInstance.h" diff --git a/src/engine/service/VoxelService.h b/src/engine/service/VoxelService.h index e5c6939a..aab1bf57 100644 --- a/src/engine/service/VoxelService.h +++ b/src/engine/service/VoxelService.h @@ -1,7 +1,7 @@ #ifndef METAL_ENGINE_VOXELSERVICE_H #define METAL_ENGINE_VOXELSERVICE_H -#include "../../../common/AbstractResourceService.h" +#include "../../common/AbstractResourceService.h" #include "../resource/SVOInstance.h" namespace Metal { diff --git a/src/engine/util/ShaderUtil.cpp b/src/engine/util/ShaderUtil.cpp index 1924663c..b0544a2e 100644 --- a/src/engine/util/ShaderUtil.cpp +++ b/src/engine/util/ShaderUtil.cpp @@ -1,10 +1,10 @@ -#include "../../../util/ShaderUtil.h" +#include "ShaderUtil.h" #include #include #include "../dto/ShaderModule.h" -#include "../../vulkan/VulkanUtils.h" +#include "../../core/vulkan/VulkanUtils.h" #include "../../editor/util/Util.h" #include "../../ApplicationContext.h" #include "../../editor/util/FilesUtil.h" From cf8ae69c8478393f5ddc1560820e3e11963a116a Mon Sep 17 00:00:00 2001 From: facobackup Date: Thu, 12 Mar 2026 22:37:26 -0300 Subject: [PATCH 03/11] Constructor references Rollback panel removing applicationContext pointer Added imgui rendered window frame and footer --- CMakeLists.txt | 2 + src/ApplicationContext.cpp | 1 + src/ApplicationContext.h | 30 +++--- src/core/glfw/GLFWContext.cpp | 1 + src/editor/EditorPanel.cpp | 40 +++++--- src/editor/EditorPanel.h | 5 + src/editor/abstract/AbstractPanel.cpp | 1 + src/editor/abstract/AbstractPanel.h | 3 +- src/editor/abstract/form/AccordionPanel.cpp | 2 +- src/editor/abstract/form/ChildPanel.cpp | 2 +- .../abstract/form/types/ResourceField.cpp | 2 +- .../dock-spaces/console/ConsolePanel.cpp | 8 +- .../dock-spaces/docks/DockSpacePanel.cpp | 8 +- .../dock-spaces/files/FilePreviewPanel.cpp | 4 +- .../dock-spaces/files/FilesListPanel.cpp | 4 +- src/editor/dock-spaces/files/FilesListPanel.h | 4 +- src/editor/dock-spaces/files/FilesPanel.cpp | 32 +++---- .../dock-spaces/footer/EditorFooterPanel.cpp | 59 ++++++++++++ .../dock-spaces/footer/EditorFooterPanel.h | 16 ++++ .../dock-spaces/header/AsyncTaskPanel.cpp | 4 +- .../dock-spaces/header/EditorHeaderPanel.cpp | 94 ++++++++----------- .../dock-spaces/header/EditorHeaderPanel.h | 4 +- .../dock-spaces/inspector/InspectorPanel.cpp | 8 +- .../dock-spaces/metrics/MetricsPanel.cpp | 12 +-- .../repositories/RepositoriesPanel.cpp | 6 +- .../viewport/CameraPositionPanel.cpp | 6 +- .../dock-spaces/viewport/EngineFramePanel.cpp | 14 +-- .../dock-spaces/viewport/GizmoPanel.cpp | 10 +- .../viewport/GizmoSettingsPanel.cpp | 6 +- .../viewport/ViewportHeaderPanel.cpp | 10 +- .../dock-spaces/viewport/ViewportPanel.cpp | 42 ++++----- .../dock-spaces/world/WorldHeaderPanel.cpp | 2 +- src/editor/dock-spaces/world/WorldPanel.cpp | 30 +++--- src/editor/panel/FileImportModalPanel.cpp | 6 +- src/editor/panel/NotificationsPanel.cpp | 10 +- src/editor/service/FileImporterService.cpp | 35 +++---- src/editor/service/FileImporterService.h | 23 +++++ src/editor/service/FilesService.cpp | 22 ++--- src/editor/service/FilesService.h | 8 +- src/editor/service/LogService.cpp | 16 ++-- src/editor/service/LogService.h | 31 +++--- .../service/MaterialImporterService.cpp | 7 +- src/editor/service/MaterialImporterService.h | 9 ++ src/editor/service/MeshImporterService.cpp | 4 +- src/editor/service/MeshImporterService.h | 5 + src/editor/service/PickingService.cpp | 21 +++-- src/editor/service/PickingService.h | 12 +++ src/editor/service/SceneImporterService.cpp | 25 ++--- src/editor/service/SceneImporterService.h | 37 +++++--- src/editor/service/SelectionService.cpp | 15 +-- src/editor/service/SelectionService.h | 7 ++ src/editor/service/TextureImporterService.cpp | 4 +- src/editor/service/TextureImporterService.h | 6 +- src/editor/service/VoxelImporterService.cpp | 3 +- src/editor/service/VoxelImporterService.h | 4 + src/engine/EngineContext.cpp | 46 +++++---- src/engine/EngineContext.h | 39 ++++++++ src/engine/repository/EngineRepository.cpp | 9 +- src/engine/repository/WorldRepository.cpp | 10 +- src/engine/repository/WorldRepository.h | 8 ++ src/engine/service/BufferService.cpp | 44 +++++---- src/engine/service/BufferService.h | 5 + src/engine/service/CameraService.cpp | 17 ++-- src/engine/service/CameraService.h | 11 ++- src/engine/service/DescriptorSetService.cpp | 33 ++++--- src/engine/service/DescriptorSetService.h | 15 ++- src/engine/service/FrameBufferService.cpp | 23 ++--- src/engine/service/FrameBufferService.h | 7 ++ src/engine/service/LightService.cpp | 14 +-- src/engine/service/LightService.h | 10 ++ src/engine/service/MaterialService.cpp | 17 ++-- src/engine/service/MaterialService.h | 5 + src/engine/service/MeshService.cpp | 15 +-- src/engine/service/MeshService.h | 11 +++ src/engine/service/PipelineService.cpp | 45 ++++----- src/engine/service/PipelineService.h | 15 ++- src/engine/service/RayTracingService.cpp | 71 +++++++------- src/engine/service/RayTracingService.h | 20 +++- src/engine/service/StreamingService.cpp | 32 ++++--- src/engine/service/StreamingService.h | 14 +++ src/engine/service/TextureService.cpp | 62 ++++++------ src/engine/service/TextureService.h | 13 +++ src/engine/service/TransformService.cpp | 10 +- src/engine/service/TransformService.h | 10 ++ src/engine/service/VolumeService.cpp | 8 +- src/engine/service/VolumeService.h | 9 ++ 86 files changed, 906 insertions(+), 524 deletions(-) create mode 100644 src/editor/dock-spaces/footer/EditorFooterPanel.cpp create mode 100644 src/editor/dock-spaces/footer/EditorFooterPanel.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 391ca93b..9fa89d53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,8 @@ add_executable( src/editor/dock-spaces/header/EditorHeaderPanel.h src/editor/dock-spaces/header/AsyncTaskPanel.cpp src/editor/dock-spaces/header/AsyncTaskPanel.h + src/editor/dock-spaces/footer/EditorFooterPanel.cpp + src/editor/dock-spaces/footer/EditorFooterPanel.h src/common/Icons.h src/editor/service/DockService.cpp src/editor/service/DockService.h diff --git a/src/ApplicationContext.cpp b/src/ApplicationContext.cpp index d47dd628..9aff2362 100644 --- a/src/ApplicationContext.cpp +++ b/src/ApplicationContext.cpp @@ -80,6 +80,7 @@ namespace Metal { vulkanContext.onInitialize(); guiContext.onInitialize(); filesService.onInitialize(); + editorPanel.applicationContext = this; editorPanel.onInitialize(); engineContext.onInitialize(); diff --git a/src/ApplicationContext.h b/src/ApplicationContext.h index e1c88cfb..3e0f075e 100644 --- a/src/ApplicationContext.h +++ b/src/ApplicationContext.h @@ -34,7 +34,6 @@ #include "engine/service/CommandBufferRecorderService.h" #include "editor/service/NotificationService.h" #include "editor/service/AsyncTaskService.h" -#include "editor/service/LogService.h" #include "engine/service/TransformService.h" #include "editor/service/PickingService.h" #include "engine/service/VolumeService.h" @@ -67,14 +66,13 @@ namespace Metal { // ----------- Services NotificationService notificationService; AsyncTaskService asyncTaskService; - LogService logService{}; - MeshService meshService{}; - MaterialService materialService{}; - TextureService textureService{}; - FrameBufferService framebufferService{}; - DescriptorSetService descriptorSetService{}; - PipelineService pipelineService{descriptorSetService}; - BufferService bufferService{}; + MeshService meshService{bufferService, rayTracingService, rootDirectory}; + MaterialService materialService{textureService}; + TextureService textureService{vulkanContext, bufferService, pipelineService, descriptorSetService, rootDirectory}; + FrameBufferService framebufferService{vulkanContext}; + DescriptorSetService descriptorSetService{vulkanContext, framebufferService, bufferService, textureService}; + PipelineService pipelineService{vulkanContext, framebufferService, bufferService, descriptorSetService}; + BufferService bufferService{vulkanContext}; ThemeService themeService{}; DockService dockService{}; SelectionService selectionService{}; @@ -84,21 +82,21 @@ namespace Metal { TextureImporterService textureImporter{}; FilesService filesService{}; FileImporterService fileImporterService{}; - CameraService cameraService{}; + CameraService cameraService{engineContext, worldRepository, runtimeRepository}; PickingService pickingService{}; - TransformService transformService{}; - LightService lightService{}; - VolumeService volumeService{}; - RayTracingService rayTracingService{}; + TransformService transformService{worldRepository, rayTracingService}; + LightService lightService{engineContext, engineRepository}; + VolumeService volumeService{worldRepository, engineContext}; + RayTracingService rayTracingService{vulkanContext, pipelineService, worldRepository, meshService, materialService, bufferService, engineContext}; CommandBufferRecorderService commandBufferRecorderService{}; - VoxelImporterService voxelImporterService{}; + VoxelImporterService voxelImporterService{rootDirectory}; VoxelService voxelService{}; // ----------- Services // ----------- Repository WorldRepository worldRepository{}; RuntimeRepository runtimeRepository{}; - StreamingService streamingService{}; + StreamingService streamingService{engineContext, worldRepository, meshService, textureService, voxelService}; EngineRepository engineRepository{}; DockRepository dockRepository{}; EditorRepository editorRepository{}; diff --git a/src/core/glfw/GLFWContext.cpp b/src/core/glfw/GLFWContext.cpp index 8014aea8..9ebba466 100644 --- a/src/core/glfw/GLFWContext.cpp +++ b/src/core/glfw/GLFWContext.cpp @@ -85,6 +85,7 @@ namespace Metal { if (validContext) { glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); + glfwWindowHint(GLFW_DECORATED, GLFW_FALSE); window = glfwCreateWindow(1280, 720, ENGINE_NAME, nullptr, nullptr); if (!glfwVulkanSupported()) { diff --git a/src/editor/EditorPanel.cpp b/src/editor/EditorPanel.cpp index 0f07986a..399fa50e 100644 --- a/src/editor/EditorPanel.cpp +++ b/src/editor/EditorPanel.cpp @@ -2,6 +2,7 @@ #include "util/UIUtil.h" #include "../ApplicationContext.h" #include "dock-spaces/header/EditorHeaderPanel.h" +#include "dock-spaces/footer/EditorFooterPanel.h" #include "panel/FileImportModalPanel.h" #include "panel/NotificationsPanel.h" @@ -15,13 +16,16 @@ namespace Metal { ImGuiWindowFlags_NoNavFocus; const char *EditorPanel::NAME = "##main_window"; const char *EditorPanel::NAME_HEADER = "##header_window"; + const char *EditorPanel::NAME_FOOTER = "##footer_window"; ImVec2 EditorPanel::CENTER(0.0f, 0.0f); float EditorPanel::HEADER_HEIGHT = 25; + float EditorPanel::FOOTER_HEIGHT = 30; void EditorPanel::renderDockSpaces() { const ImGuiViewport *viewport = ImGui::GetMainViewport(); renderHeader(viewport); + renderFooter(viewport); // Begin window { @@ -30,7 +34,7 @@ namespace Metal { ImGui::SetNextWindowPos(UIUtil::AUX_VEC2); UIUtil::AUX_VEC2.x = viewport->Size.x; - UIUtil::AUX_VEC2.y = viewport->Size.y - HEADER_HEIGHT; + UIUtil::AUX_VEC2.y = viewport->Size.y - HEADER_HEIGHT - FOOTER_HEIGHT; ImGui::SetNextWindowSize(UIUtil::AUX_VEC2); ImGui::SetNextWindowViewport(viewport->ID); @@ -42,7 +46,7 @@ namespace Metal { ImGui::PopStyleVar(3); - CTX.dockService.buildViews(windowId, this); + applicationContext->dockService.buildViews(windowId, this); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f); ImGui::DockSpace(windowId, CENTER, ImGuiDockNodeFlags_PassthruCentralNode); @@ -54,7 +58,7 @@ namespace Metal { void EditorPanel::renderHeader(const ImGuiViewport *viewport) { UIUtil::AUX_VEC2.x = viewport->Pos.x; - UIUtil::AUX_VEC2.y = 0; + UIUtil::AUX_VEC2.y = viewport->Pos.y; ImGui::SetNextWindowPos(UIUtil::AUX_VEC2); UIUtil::AUX_VEC2.x = viewport->Size.x; @@ -69,6 +73,23 @@ namespace Metal { ImGui::End(); } + void EditorPanel::renderFooter(const ImGuiViewport *viewport) { + UIUtil::AUX_VEC2.x = viewport->Pos.x; + UIUtil::AUX_VEC2.y = viewport->Pos.y + viewport->Size.y - FOOTER_HEIGHT; + ImGui::SetNextWindowPos(UIUtil::AUX_VEC2); + + UIUtil::AUX_VEC2.x = viewport->Size.x; + UIUtil::AUX_VEC2.y = FOOTER_HEIGHT; + ImGui::SetNextWindowSize(UIUtil::AUX_VEC2); + + SetWindowStyle(); + ImGui::Begin(NAME_FOOTER, &UIUtil::OPEN, FLAGS | ImGuiWindowFlags_NoScrollbar); + ImGui::PopStyleVar(3); + + footerPanel->onSync(); + ImGui::End(); + } + void EditorPanel::SetWindowStyle() { ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); @@ -76,19 +97,16 @@ namespace Metal { } void EditorPanel::onSync() { - CTX.themeService.onSync(); + applicationContext->themeService.onSync(); renderDockSpaces(); notificationsPanel->onSync(); fileImportModalPanel->onSync(); } void EditorPanel::onInitialize() { - headerPanel = new EditorHeaderPanel(); - headerPanel->onInitialize(); - notificationsPanel = new NotificationsPanel(); - notificationsPanel->onInitialize(); - - fileImportModalPanel = new FileImportModalPanel(); - fileImportModalPanel->onInitialize(); + appendChild(headerPanel = new EditorHeaderPanel()); + appendChild(footerPanel = new EditorFooterPanel()); + appendChild(notificationsPanel = new NotificationsPanel()); + appendChild(fileImportModalPanel = new FileImportModalPanel()); } } diff --git a/src/editor/EditorPanel.h b/src/editor/EditorPanel.h index 0a1983e7..32a9cf0a 100644 --- a/src/editor/EditorPanel.h +++ b/src/editor/EditorPanel.h @@ -9,10 +9,13 @@ namespace Metal { static int FLAGS; static const char *NAME; static const char *NAME_HEADER; + static const char *NAME_FOOTER; static ImVec2 CENTER; static float HEADER_HEIGHT; + static float FOOTER_HEIGHT; ImGuiID windowId = 0; AbstractPanel *headerPanel = nullptr; + AbstractPanel *footerPanel = nullptr; AbstractPanel *notificationsPanel = nullptr; AbstractPanel *fileImportModalPanel = nullptr; @@ -22,6 +25,8 @@ namespace Metal { void renderHeader(const ImGuiViewport *viewport); + void renderFooter(const ImGuiViewport *viewport); + public: void onInitialize() override; diff --git a/src/editor/abstract/AbstractPanel.cpp b/src/editor/abstract/AbstractPanel.cpp index c4ab4cd6..3db1de52 100644 --- a/src/editor/abstract/AbstractPanel.cpp +++ b/src/editor/abstract/AbstractPanel.cpp @@ -3,6 +3,7 @@ namespace Metal { void AbstractPanel::appendChild(AbstractPanel *panel) { + panel->applicationContext = applicationContext; panel->onInitialize(); children.emplace_back(panel); } diff --git a/src/editor/abstract/AbstractPanel.h b/src/editor/abstract/AbstractPanel.h index 61ac76b6..d2f52f23 100644 --- a/src/editor/abstract/AbstractPanel.h +++ b/src/editor/abstract/AbstractPanel.h @@ -8,8 +8,9 @@ namespace Metal { class ApplicationContext; - class AbstractPanel : public IPanel { + public: + ApplicationContext *applicationContext{}; protected: std::vector children; const std::string id; diff --git a/src/editor/abstract/form/AccordionPanel.cpp b/src/editor/abstract/form/AccordionPanel.cpp index bf310e4b..0efd891e 100644 --- a/src/editor/abstract/form/AccordionPanel.cpp +++ b/src/editor/abstract/form/AccordionPanel.cpp @@ -14,7 +14,7 @@ namespace Metal { return; } - ImGui::PushStyleColor(ImGuiCol_Header, CTX.themeService.neutralPalette); + ImGui::PushStyleColor(ImGuiCol_Header, applicationContext->themeService.neutralPalette); bool open = ImGui::CollapsingHeader(fixedId.c_str(), ImGuiTreeNodeFlags_None); ImGui::PopStyleColor(); diff --git a/src/editor/abstract/form/ChildPanel.cpp b/src/editor/abstract/form/ChildPanel.cpp index 85f7c309..aaf611b5 100644 --- a/src/editor/abstract/form/ChildPanel.cpp +++ b/src/editor/abstract/form/ChildPanel.cpp @@ -9,7 +9,7 @@ namespace Metal { } void ChildPanel::onSync() { - ImGui::PushStyleColor(ImGuiCol_ChildBg, CTX.themeService.palette0); + ImGui::PushStyleColor(ImGuiCol_ChildBg, applicationContext->themeService.palette0); if (!title.empty()) { ImGui::Spacing(); ImGui::Text(title.c_str()); diff --git a/src/editor/abstract/form/types/ResourceField.cpp b/src/editor/abstract/form/types/ResourceField.cpp index 668ec209..3b06c714 100644 --- a/src/editor/abstract/form/types/ResourceField.cpp +++ b/src/editor/abstract/form/types/ResourceField.cpp @@ -79,7 +79,7 @@ namespace Metal { void ResourceField::onSync() { if (field.field->size() > 0 && (entry == nullptr || entry->getId() != *field.field)) { - entry = CTX.filesService.getResource(*field.field); + entry = applicationContext->filesService.getResource(*field.field); } if (!field.disabled) { renderButton(); diff --git a/src/editor/dock-spaces/console/ConsolePanel.cpp b/src/editor/dock-spaces/console/ConsolePanel.cpp index 67e17115..9f2093af 100644 --- a/src/editor/dock-spaces/console/ConsolePanel.cpp +++ b/src/editor/dock-spaces/console/ConsolePanel.cpp @@ -11,17 +11,15 @@ namespace Metal { } shortcuts = { ShortcutDTO("Clear Logs", ImGuiMod_Ctrl | ImGuiKey_L, [this]() { - CTX.logService.clear(); + LogService::clear(); }) }; } void ConsolePanel::onSync() { - LogService& logService = CTX.logService; - // Header if (ImGui::Button("Clear")) { - logService.clear(); + LogService::clear(); } ImGui::SameLine(); bool copyToClipboard = ImGui::Button("Copy"); @@ -48,7 +46,7 @@ namespace Metal { ImGui::LogToClipboard(); } - const auto entries = logService.getEntriesSnapshot(); + const auto entries = LogService::getEntriesSnapshot(); for (const auto& entry : entries) { if (!levelFilter[(int)entry.level]) continue; if (!filter.PassFilter(entry.message.c_str())) continue; diff --git a/src/editor/dock-spaces/docks/DockSpacePanel.cpp b/src/editor/dock-spaces/docks/DockSpacePanel.cpp index 16098bbc..c6f0826a 100644 --- a/src/editor/dock-spaces/docks/DockSpacePanel.cpp +++ b/src/editor/dock-spaces/docks/DockSpacePanel.cpp @@ -52,13 +52,13 @@ namespace Metal { if (view != nullptr) { const bool isHovered = ImGui::IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows); if (isHovered) { - CTX.editorRepository.focusedShortcuts = view->getShortcuts(); - CTX.editorRepository.focusedWindowName = view->dock->name; + applicationContext->editorRepository.focusedShortcuts = view->getShortcuts(); + applicationContext->editorRepository.focusedWindowName = view->dock->name; } view->isWindowFocused = isHovered; if (view->isWindowFocused) { - for (const auto &shortcut: CTX.editorRepository.focusedShortcuts) { + for (const auto &shortcut: applicationContext->editorRepository.focusedShortcuts) { if (ImGui::IsKeyChordPressed(shortcut.keyChord)) { LOG_INFO("Action called: " + shortcut.name); shortcut.callback(); @@ -116,7 +116,7 @@ namespace Metal { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, headerPadding); const bool isFocused = ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows); ImGui::PushStyleColor(ImGuiCol_TabActive, - isFocused ? CTX.editorRepository.accent : CTX.themeService.palette0); + isFocused ? applicationContext->editorRepository.accent : applicationContext->themeService.palette0); if (ImGui::BeginTabBar((id + "dockTabs").c_str(), ImGuiTabBarFlags_AutoSelectNewTabs)) { for (auto *space: dock->dockSpaces) { diff --git a/src/editor/dock-spaces/files/FilePreviewPanel.cpp b/src/editor/dock-spaces/files/FilePreviewPanel.cpp index 87a6ca4a..143aa77a 100644 --- a/src/editor/dock-spaces/files/FilePreviewPanel.cpp +++ b/src/editor/dock-spaces/files/FilePreviewPanel.cpp @@ -21,7 +21,7 @@ namespace Metal { ImGui::Separator(); if (selected->type == EntryType::TEXTURE) { - auto *texture = CTX.textureService.stream(selected->getId()); + auto *texture = applicationContext->textureService.stream(selected->getId()); if (texture != nullptr) { float availWidth = ImGui::GetContentRegionAvail().x; float availHeight = ImGui::GetContentRegionAvail().y * 0.6f; // reserve space for table @@ -41,7 +41,7 @@ namespace Metal { float offsetX = (availWidth - renderWidth) * 0.5f; if (offsetX > 0) ImGui::SetCursorPosX(ImGui::GetCursorPosX() + offsetX); - CTX.guiContext.renderImage(texture, renderWidth, renderHeight); + applicationContext->guiContext.renderImage(texture, renderWidth, renderHeight); ImGui::Separator(); } } diff --git a/src/editor/dock-spaces/files/FilesListPanel.cpp b/src/editor/dock-spaces/files/FilesListPanel.cpp index 05b2fa59..56229939 100644 --- a/src/editor/dock-spaces/files/FilesListPanel.cpp +++ b/src/editor/dock-spaces/files/FilesListPanel.cpp @@ -89,7 +89,7 @@ namespace Metal { if (!ImGui::IsMouseDown(ImGuiMouseButton_Left) && onDrag != nullptr && fileEntry->type == EntryType::DIRECTORY) { - CTX.filesService.Move(onDrag, fileEntry); + applicationContext->filesService.Move(onDrag, fileEntry); onDrag = nullptr; } } @@ -280,7 +280,7 @@ namespace Metal { FilesService::GetEntries(filesContext.currentDirectory); } if (ImGui::MenuItem("Delete")) { - CTX.filesService.deleteFiles(filesContext.selected); + applicationContext->filesService.deleteFiles(filesContext.selected); FilesService::GetEntries(filesContext.currentDirectory); } ImGui::Separator(); diff --git a/src/editor/dock-spaces/files/FilesListPanel.h b/src/editor/dock-spaces/files/FilesListPanel.h index 9eda2ba8..1bf8dd21 100644 --- a/src/editor/dock-spaces/files/FilesListPanel.h +++ b/src/editor/dock-spaces/files/FilesListPanel.h @@ -45,9 +45,9 @@ namespace Metal { void renderTreeItem(FSEntry *entry); public: - explicit FilesListPanel(FilesContext &ctx, std::function onDoubleClick, + explicit FilesListPanel(FilesContext &applicationContext-> std::function onDoubleClick, EntryType::EntryType typeFilter) - : filesContext(ctx), typeFilter(typeFilter), onDoubleClick(std::move(onDoubleClick)) { + : filesContext(applicationContext->, typeFilter(typeFilter), onDoubleClick(std::move(onDoubleClick)) { } void onSync() override; diff --git a/src/editor/dock-spaces/files/FilesPanel.cpp b/src/editor/dock-spaces/files/FilesPanel.cpp index c09b0515..898b0afa 100644 --- a/src/editor/dock-spaces/files/FilesPanel.cpp +++ b/src/editor/dock-spaces/files/FilesPanel.cpp @@ -28,27 +28,27 @@ namespace Metal { auto files = FileDialogUtil::PickFiles({ { "Files", - CTX.fileImporterService.collectCompatibleFiles().c_str(), + applicationContext->fileImporterService.collectCompatibleFiles().c_str(), } }); if (!files.empty()) { - CTX.editorRepository.pendingImports = files; - CTX.editorRepository.importSettingsMap.clear(); - for (const auto& file : CTX.editorRepository.pendingImports) { - if (CTX.sceneImporterService.isCompatible(file)) { - CTX.editorRepository.importSettingsMap.emplace(file, std::make_shared()); + applicationContext->editorRepository.pendingImports = files; + applicationContext->editorRepository.importSettingsMap.clear(); + for (const auto& file : applicationContext->editorRepository.pendingImports) { + if (applicationContext->sceneImporterService.isCompatible(file)) { + applicationContext->editorRepository.importSettingsMap.emplace(file, std::make_shared()); } else { - CTX.editorRepository.importSettingsMap.emplace(file, std::make_shared()); + applicationContext->editorRepository.importSettingsMap.emplace(file, std::make_shared()); } } - CTX.editorRepository.selectedFileForSettings = CTX.editorRepository.pendingImports[0]; - CTX.editorRepository.targetImportDirectory = filesContext.currentDirectory; + applicationContext->editorRepository.selectedFileForSettings = applicationContext->editorRepository.pendingImports[0]; + applicationContext->editorRepository.targetImportDirectory = filesContext.currentDirectory; } }; } void FilesPanel::onInitialize() { - filesContext.setCurrentDirectory(CTX.filesService.getRoot()); + filesContext.setCurrentDirectory(applicationContext->filesService.getRoot()); appendChild(filesHeader = new FilesHeaderPanel(filesContext, getActionLabel(), onAction())); filesListPanel = new FilesListPanel( filesContext, [ @@ -124,13 +124,13 @@ namespace Metal { void FilesPanel::openResource(FSEntry *root) { switch (root->type) { case EntryType::SCENE: { - CTX.notificationService.pushMessage("Loading scene", NotificationSeverities::SUCCESS); - CTX.worldRepository.loadScene(root->getId()); + applicationContext->notificationService.pushMessage("Loading scene", NotificationSeverities::SUCCESS); + applicationContext->worldRepository.loadScene(root->getId()); break; } case EntryType::VOLUME: { - CTX.notificationService.pushMessage("Loading volume", NotificationSeverities::SUCCESS); - CTX.voxelService.create(root->getId()); + applicationContext->notificationService.pushMessage("Loading volume", NotificationSeverities::SUCCESS); + applicationContext->voxelService.create(root->getId()); break; } case EntryType::DIRECTORY: { @@ -140,7 +140,7 @@ namespace Metal { break; } default: - CTX.notificationService.pushMessage("Unsupported resource type", NotificationSeverities::ERROR); + applicationContext->notificationService.pushMessage("Unsupported resource type", NotificationSeverities::ERROR); break; } } @@ -174,7 +174,7 @@ namespace Metal { } void FilesPanel::deleteSelected() const { - CTX.filesService.deleteFiles(filesContext.selected); + applicationContext->filesService.deleteFiles(filesContext.selected); FilesService::GetEntries(filesContext.currentDirectory); } } diff --git a/src/editor/dock-spaces/footer/EditorFooterPanel.cpp b/src/editor/dock-spaces/footer/EditorFooterPanel.cpp new file mode 100644 index 00000000..c754ab52 --- /dev/null +++ b/src/editor/dock-spaces/footer/EditorFooterPanel.cpp @@ -0,0 +1,59 @@ +#include "EditorFooterPanel.h" +#include "../../util/UIUtil.h" +#include "../../../ApplicationContext.h" + +namespace Metal { + void EditorFooterPanel::onSync() { + renderShortcuts(); + framerate(); + } + + void EditorFooterPanel::framerate() { + const int framerate = static_cast(round(ImGui::GetIO().Framerate)); + if (framerate > 0) { + ImGui::SameLine(ImGui::GetWindowWidth() - 100); + ImGui::Text("%i ms | %i fps", 1000 / framerate, framerate); + } + } + + void EditorFooterPanel::renderShortcuts() { + auto &shortcuts = applicationContext->editorRepository.focusedShortcuts; + if (shortcuts.empty()) return; + + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5); // Some padding + ImGui::Text(applicationContext->editorRepository.focusedWindowName.c_str()); + ImGui::SameLine(); + std::string label; + for (size_t i = 0; i < std::min(shortcuts.size(), size_t(3)); ++i) { + if (i > 0) label += " | "; + label += UIUtil::GetKeyChordName(shortcuts[i].keyChord); + } + + if (ImGui::Button(label.c_str())) { + ImGui::OpenPopup("AllShortcutsPopupFooter"); + } + + if (ImGui::BeginPopup("AllShortcutsPopupFooter")) { + if (ImGui::BeginTable("ShortcutsTableFooter", 2, + ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | + ImGuiTableFlags_SizingStretchProp)) { + ImGui::TableSetupColumn("Key"); + ImGui::TableSetupColumn("Action"); + ImGui::TableHeadersRow(); + + for (const auto &shortcut: shortcuts) { + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TextUnformatted(UIUtil::GetKeyChordName(shortcut.keyChord).c_str()); + ImGui::TableNextColumn(); + if (ImGui::Selectable(shortcut.name.c_str(), false, ImGuiSelectableFlags_SpanAllColumns)) { + shortcut.callback(); + ImGui::CloseCurrentPopup(); + } + } + ImGui::EndTable(); + } + ImGui::EndPopup(); + } + } +} diff --git a/src/editor/dock-spaces/footer/EditorFooterPanel.h b/src/editor/dock-spaces/footer/EditorFooterPanel.h new file mode 100644 index 00000000..257b12bd --- /dev/null +++ b/src/editor/dock-spaces/footer/EditorFooterPanel.h @@ -0,0 +1,16 @@ +#ifndef METAL_ENGINE_EDITORFOOTERPANEL_H +#define METAL_ENGINE_EDITORFOOTERPANEL_H + +#include "../../abstract/AbstractPanel.h" + +namespace Metal { + class EditorFooterPanel final : public AbstractPanel { + void renderShortcuts(); + static void framerate(); + + public: + void onSync() override; + }; +} + +#endif diff --git a/src/editor/dock-spaces/header/AsyncTaskPanel.cpp b/src/editor/dock-spaces/header/AsyncTaskPanel.cpp index 2cc626c5..fba2a231 100644 --- a/src/editor/dock-spaces/header/AsyncTaskPanel.cpp +++ b/src/editor/dock-spaces/header/AsyncTaskPanel.cpp @@ -5,7 +5,7 @@ namespace Metal { void AsyncTaskPanel::onSync() { - auto tasks = CTX.asyncTaskService.getActiveTasks(); + auto tasks = applicationContext->asyncTaskService.getActiveTasks(); if (tasks.empty()) { UIUtil::DynamicSpacing(90); return; @@ -56,7 +56,7 @@ namespace Metal { ImGui::SameLine(); if (ImGui::Button((Icons::close + "##" + task->id).c_str(), ImVec2(UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE))) { - CTX.asyncTaskService.endTask(task->id, true); + applicationContext->asyncTaskService.endTask(task->id, true); } ImGui::EndGroup(); } diff --git a/src/editor/dock-spaces/header/EditorHeaderPanel.cpp b/src/editor/dock-spaces/header/EditorHeaderPanel.cpp index b2b577a5..5c5fac77 100644 --- a/src/editor/dock-spaces/header/EditorHeaderPanel.cpp +++ b/src/editor/dock-spaces/header/EditorHeaderPanel.cpp @@ -9,25 +9,55 @@ namespace Metal { ImGui::Dummy(ImVec2(0, UIUtil::ONLY_ICON_BUTTON_SIZE)); ImGui::Dummy(ImVec2(2, 0)); ImGui::Separator(); + + // Window dragging logic + if (ImGui::IsWindowHovered() && ImGui::IsMouseDragging(ImGuiMouseButton_Left)) { + ImVec2 delta = ImGui::GetIO().MouseDelta; + GLFWwindow* window = applicationContext->glfwContext.getWindow(); + int x, y; + glfwGetWindowPos(window, &x, &y); + glfwSetWindowPos(window, x + (int)delta.x, y + (int)delta.y); + } } - void EditorHeaderPanel::onInitialize() { - appendChild(asyncTask = new AsyncTaskPanel()); + void EditorHeaderPanel::renderWindowControls() { + ImGui::SameLine(ImGui::GetWindowWidth() - (UIUtil::ONLY_ICON_BUTTON_SIZE * 3 + 10)); + + GLFWwindow* window = applicationContext->glfwContext.getWindow(); + + if (UIUtil::ButtonSimple(Icons::minimize, UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE)) { + glfwIconifyWindow(window); + } + ImGui::SameLine(); + + bool isMaximized = glfwGetWindowAttrib(window, GLFW_MAXIMIZED); + if (UIUtil::ButtonSimple(isMaximized ? Icons::filter_none : Icons::crop_square, UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE)) { + if (isMaximized) { + glfwRestoreWindow(window); + } else { + glfwMaximizeWindow(window); + } + } + ImGui::SameLine(); + + if (UIUtil::ButtonSimple(Icons::close, UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE)) { + glfwSetWindowShouldClose(window, GLFW_TRUE); + } } void EditorHeaderPanel::renderFileTab() { if (ImGui::BeginMainMenuBar()) { if (UIUtil::ButtonSimple(Icons::save, UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE)) { - CTX.save(); + applicationContext->save(); } ImGui::SameLine(); if (ImGui::BeginMenu("File")) { if (ImGui::MenuItem("Open", "Ctrl+O")) { - CTX.engineContext.dispose(); - CTX.updateRootPath(true); + applicationContext->engineContext.dispose(); + applicationContext->updateRootPath(true); } if (ImGui::MenuItem("Save", "Ctrl+S")) { - CTX.save(); + applicationContext->save(); } ImGui::Separator(); if (ImGui::MenuItem("Exit")) { @@ -39,67 +69,23 @@ namespace Metal { // Create an "Edit" menu if (ImGui::BeginMenu("Edit")) { if (ImGui::MenuItem("Compile shaders")) { - CTX.engineContext.dispose(); + applicationContext->engineContext.dispose(); // TODO - CREATE NEW FRAME } ImGui::EndMenu(); } UIUtil::LargeSpacing(); - renderShortcuts(); - UIUtil::Spacing(); asyncTask->onSync(); - framerate(); + renderWindowControls(); ImGui::EndMainMenuBar(); } } - void EditorHeaderPanel::framerate() { - const int framerate = static_cast(round(ImGui::GetIO().Framerate)); - if (framerate > 0) { - ImGui::Text("%i ms | %i fps", 1000 / framerate, framerate); - } - } - - void EditorHeaderPanel::renderShortcuts() { - auto &shortcuts = CTX.editorRepository.focusedShortcuts; - if (shortcuts.empty()) return; - ImGui::Text(CTX.editorRepository.focusedWindowName.c_str()); - ImGui::SameLine(); - std::string label; - for (size_t i = 0; i < std::min(shortcuts.size(), size_t(3)); ++i) { - if (i > 0) label += " | "; - label += UIUtil::GetKeyChordName(shortcuts[i].keyChord); - } - - if (ImGui::Button(label.c_str())) { - ImGui::OpenPopup("AllShortcutsPopup"); - } - - if (ImGui::BeginPopup("AllShortcutsPopup")) { - if (ImGui::BeginTable("ShortcutsTable", 2, - ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | - ImGuiTableFlags_SizingStretchProp)) { - ImGui::TableSetupColumn("Key"); - ImGui::TableSetupColumn("Action"); - ImGui::TableHeadersRow(); - - for (const auto &shortcut: shortcuts) { - ImGui::TableNextRow(); - ImGui::TableNextColumn(); - ImGui::TextUnformatted(UIUtil::GetKeyChordName(shortcut.keyChord).c_str()); - ImGui::TableNextColumn(); - if (ImGui::Selectable(shortcut.name.c_str(), false, ImGuiSelectableFlags_SpanAllColumns)) { - shortcut.callback(); - ImGui::CloseCurrentPopup(); - } - } - ImGui::EndTable(); - } - ImGui::EndPopup(); - } + void EditorHeaderPanel::onInitialize() { + appendChild(asyncTask = new AsyncTaskPanel()); } } diff --git a/src/editor/dock-spaces/header/EditorHeaderPanel.h b/src/editor/dock-spaces/header/EditorHeaderPanel.h index 897cae94..75f2f184 100644 --- a/src/editor/dock-spaces/header/EditorHeaderPanel.h +++ b/src/editor/dock-spaces/header/EditorHeaderPanel.h @@ -9,9 +9,7 @@ namespace Metal { void renderFileTab(); - void renderShortcuts(); - - static void framerate(); + void renderWindowControls(); public: void onInitialize() override; diff --git a/src/editor/dock-spaces/inspector/InspectorPanel.cpp b/src/editor/dock-spaces/inspector/InspectorPanel.cpp index a3c02608..bee24e34 100644 --- a/src/editor/dock-spaces/inspector/InspectorPanel.cpp +++ b/src/editor/dock-spaces/inspector/InspectorPanel.cpp @@ -26,11 +26,11 @@ namespace Metal { if (ImGui::BeginPopup((id + "AddComponentPopup").c_str())) { for (const auto &compDef: ComponentTypes::getComponents()) { - bool hasComponent = compDef.getInspectable(CTX.worldRepository, selectedId) != nullptr; + bool hasComponent = compDef.getInspectable(applicationContext->worldRepository, selectedId) != nullptr; if (!hasComponent) { if (ImGui::MenuItem( (compDef.icon + " " + compDef.name + id + "adCOmp" + compDef.name).c_str())) { - CTX.worldRepository.createComponent(selectedId, compDef.type); + applicationContext->worldRepository.createComponent(selectedId, compDef.type); selectedId = EMPTY_ENTITY; tick(); } @@ -42,13 +42,13 @@ namespace Metal { } void InspectorPanel::tick() { - if (auto &editorRepository = CTX.editorRepository; + if (auto &editorRepository = applicationContext->editorRepository; editorRepository.mainSelection != selectedId) { additionalInspection.clear(); selectedId = editorRepository.mainSelection; formPanel->resetForm(); if (selectedId != EMPTY_ENTITY) { - auto &repo = CTX.worldRepository; + auto &repo = applicationContext->worldRepository; selectedEntity = repo.getEntity(selectedId); if (selectedEntity != nullptr) { diff --git a/src/editor/dock-spaces/metrics/MetricsPanel.cpp b/src/editor/dock-spaces/metrics/MetricsPanel.cpp index fc27f0e2..f478554a 100644 --- a/src/editor/dock-spaces/metrics/MetricsPanel.cpp +++ b/src/editor/dock-spaces/metrics/MetricsPanel.cpp @@ -22,11 +22,11 @@ namespace Metal { } void MetricsPanel::onSync() { - drawResourceList("Meshes", CTX.meshService, id); - drawResourceList("Voxels", CTX.voxelService, id); - drawResourceList("Framebuffers", CTX.framebufferService, id); - drawResourceList("Textures", CTX.textureService, id); - drawResourceList("Pipelines", CTX.pipelineService, id); - drawResourceList("Buffers", CTX.bufferService, id); + drawResourceList("Meshes", applicationContext->meshService, id); + drawResourceList("Voxels", applicationContext->voxelService, id); + drawResourceList("Framebuffers", applicationContext->framebufferService, id); + drawResourceList("Textures", applicationContext->textureService, id); + drawResourceList("Pipelines", applicationContext->pipelineService, id); + drawResourceList("Buffers", applicationContext->bufferService, id); } } diff --git a/src/editor/dock-spaces/repositories/RepositoriesPanel.cpp b/src/editor/dock-spaces/repositories/RepositoriesPanel.cpp index 70957667..fff6ec87 100644 --- a/src/editor/dock-spaces/repositories/RepositoriesPanel.cpp +++ b/src/editor/dock-spaces/repositories/RepositoriesPanel.cpp @@ -8,9 +8,9 @@ namespace Metal { formPanel = new FormPanel(); appendChild(formPanel); - repositories.push_back(&CTX.editorRepository); - repositories.push_back(&CTX.engineRepository); - repositories.push_back(&CTX.worldRepository.camera); + repositories.push_back(&applicationContext->editorRepository); + repositories.push_back(&applicationContext->engineRepository); + repositories.push_back(&applicationContext->worldRepository.camera); } void RepositoriesPanel::onSync() { diff --git a/src/editor/dock-spaces/viewport/CameraPositionPanel.cpp b/src/editor/dock-spaces/viewport/CameraPositionPanel.cpp index 425d60cd..9af7929e 100644 --- a/src/editor/dock-spaces/viewport/CameraPositionPanel.cpp +++ b/src/editor/dock-spaces/viewport/CameraPositionPanel.cpp @@ -18,7 +18,7 @@ namespace Metal { ImGui::SetNextWindowBgAlpha(.4f); if (ImGui::Begin(id.c_str(), &UIUtil::OPEN, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse)) { - const auto &positionCamera = CTX.worldRepository.camera.position; + const auto &positionCamera = applicationContext->worldRepository.camera.position; ImGui::TextColored(RED, "X: %i", static_cast(positionCamera.x)); ImGui::SameLine(); ImGui::TextColored(GREEN, "Y: %i", static_cast(positionCamera.y)); @@ -27,10 +27,10 @@ namespace Metal { ImGui::SameLine(); ImGui::Text( - "Yaw: %i", static_cast(CTX.worldRepository.camera.yaw * TO_DEG)); + "Yaw: %i", static_cast(applicationContext->worldRepository.camera.yaw * TO_DEG)); ImGui::SameLine(); ImGui::Text("Pitch: %i", - static_cast(CTX.worldRepository.camera.pitch * TO_DEG)); + static_cast(applicationContext->worldRepository.camera.pitch * TO_DEG)); } ImGui::PopStyleVar(); ImGui::End(); diff --git a/src/editor/dock-spaces/viewport/EngineFramePanel.cpp b/src/editor/dock-spaces/viewport/EngineFramePanel.cpp index 5ba17e43..bae6fdde 100644 --- a/src/editor/dock-spaces/viewport/EngineFramePanel.cpp +++ b/src/editor/dock-spaces/viewport/EngineFramePanel.cpp @@ -17,8 +17,8 @@ namespace Metal { void EngineFramePanel::onInitialize() { - const auto gBufferW = CTX.vulkanContext.getWindowWidth() / CTX.engineRepository.shadingResInvScale; - const auto gBufferH = CTX.vulkanContext.getWindowHeight() / CTX.engineRepository.shadingResInvScale; + const auto gBufferW = applicationContext->vulkanContext.getWindowWidth() / applicationContext->engineRepository.shadingResInvScale; + const auto gBufferH = applicationContext->vulkanContext.getWindowHeight() / applicationContext->engineRepository.shadingResInvScale; engineFrame = EngineFrameBuilder() .addBuffer(RID_GLOBAL_DATA, sizeof(GlobalDataUBO), @@ -55,7 +55,7 @@ namespace Metal { .addPass(ICONS, RID_POST_PROCESSING_CB) .build(); - CTX.engineContext.registerFrame(engineFrame.get()); + applicationContext->engineContext.registerFrame(engineFrame.get()); } void EngineFramePanel::onSync() { @@ -64,7 +64,7 @@ namespace Metal { auto *framebuffer = engineFrame->getResourceAs(RID_POST_PROCESSING_FBO); if (framebuffer) { - CTX.descriptorSetService.setImageDescriptor(framebuffer, 0); + applicationContext->descriptorSetService.setImageDescriptor(framebuffer, 0); ImGui::Image(reinterpret_cast(framebuffer->attachments[0]->imageDescriptor->vkDescriptorSet), viewportSize); @@ -105,8 +105,8 @@ namespace Metal { const uint32_t pixelX = std::min(static_cast(u * static_cast(width)), width - 1); const uint32_t pixelY = std::min(static_cast(v * static_cast(height)), height - 1); - const auto picked = CTX.pickingService.pickEntityFromGBuffer(gBufferPositionIndex, pixelX, pixelY); - CTX.selectionService.clearSelection(); - CTX.selectionService.addSelected(picked.value_or(EMPTY_ENTITY)); + const auto picked = applicationContext->pickingService.pickEntityFromGBuffer(gBufferPositionIndex, pixelX, pixelY); + applicationContext->selectionService.clearSelection(); + applicationContext->selectionService.addSelected(picked.value_or(EMPTY_ENTITY)); } } // Metal diff --git a/src/editor/dock-spaces/viewport/GizmoPanel.cpp b/src/editor/dock-spaces/viewport/GizmoPanel.cpp index 501340c3..aed80e22 100644 --- a/src/editor/dock-spaces/viewport/GizmoPanel.cpp +++ b/src/editor/dock-spaces/viewport/GizmoPanel.cpp @@ -13,7 +13,7 @@ namespace Metal { } void GizmoPanel::onInitialize() { - editorRepository = &CTX.editorRepository; + editorRepository = &applicationContext->editorRepository; } void GizmoPanel::onSync() { @@ -22,7 +22,7 @@ namespace Metal { localSelected = nullptr; localChangeId = 0; if (editorRepository->mainSelection != EMPTY_ENTITY) { - CTX.selectionService.updatePrimitiveSelected(); + applicationContext->selectionService.updatePrimitiveSelected(); } return; } @@ -40,7 +40,7 @@ namespace Metal { } recomposeMatrix(); - ImGuizmo::SetOrthographic(CTX.worldRepository.camera.isOrthographic); + ImGuizmo::SetOrthographic(applicationContext->worldRepository.camera.isOrthographic); ImGuizmo::SetDrawlist(); ImVec2 viewportMin = ImGui::GetItemRectMin(); ImVec2 viewportSize = ImGui::GetItemRectSize(); @@ -113,8 +113,8 @@ namespace Metal { } void GizmoPanel::recomposeMatrix() { - viewMatrixCache = glm::value_ptr(CTX.worldRepository.camera.viewMatrix); - cacheProjection = CTX.worldRepository.camera.projectionMatrix; + viewMatrixCache = glm::value_ptr(applicationContext->worldRepository.camera.viewMatrix); + cacheProjection = applicationContext->worldRepository.camera.projectionMatrix; cacheProjection[1][1] *= -1; diff --git a/src/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp b/src/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp index 75632216..1a3e1c07 100644 --- a/src/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp +++ b/src/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp @@ -5,7 +5,7 @@ namespace Metal { void GizmoSettingsPanel::onInitialize() { - editorRepository = &CTX.editorRepository; + editorRepository = &applicationContext->editorRepository; } void GizmoSettingsPanel::onSync() { @@ -15,9 +15,9 @@ namespace Metal { ImGui::SameLine(); gizmoGrid(); UIUtil::Spacing(); - if (selectedEntityId != editorRepository->mainSelection && CTX.worldRepository.registry.all_of( + if (selectedEntityId != editorRepository->mainSelection && applicationContext->worldRepository.registry.all_of( editorRepository->mainSelection)) { - selectedEntity = CTX.worldRepository.getEntity(editorRepository->mainSelection); + selectedEntity = applicationContext->worldRepository.getEntity(editorRepository->mainSelection); selectedEntityId = editorRepository->mainSelection; } if (selectedEntity != nullptr) { diff --git a/src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp b/src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp index d4dbbafe..5c4d99f9 100644 --- a/src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp +++ b/src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp @@ -33,8 +33,8 @@ namespace Metal { if (UIUtil::ButtonSimple(Icons::center_focus_strong + id + "centerCamera", UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE)) { - CTX.worldRepository.camera.position = {0, 0, 0}; - CTX.worldRepository.camera.registerChange(); + applicationContext->worldRepository.camera.position = {0, 0, 0}; + applicationContext->worldRepository.camera.registerChange(); } UIUtil::RenderTooltip("Center camera?"); @@ -44,19 +44,19 @@ namespace Metal { static float speedValues[] = {0.1f, 0.5f, 1.0f, 2.0f, 5.0f, 10.0f}; int currentSpeedIndex = 2; for (int i = 0; i < 6; i++) { - if (CTX.worldRepository.camera.movementSensitivity == speedValues[i]) { + if (applicationContext->worldRepository.camera.movementSensitivity == speedValues[i]) { currentSpeedIndex = i; break; } } if (ImGui::Combo((id + "speedCamera").c_str(), ¤tSpeedIndex, speeds, IM_ARRAYSIZE(speeds))) { - CTX.worldRepository.camera.movementSensitivity = speedValues[currentSpeedIndex]; + applicationContext->worldRepository.camera.movementSensitivity = speedValues[currentSpeedIndex]; } UIUtil::RenderTooltip("Camera speed"); } void ViewportHeaderPanel::shadingMode() { - auto &editorRepository = CTX.editorRepository; + auto &editorRepository = applicationContext->editorRepository; ImGui::SetNextItemWidth(150); shadingModelOption = ShadingModes::IndexOfValue(editorRepository.shadingMode); diff --git a/src/editor/dock-spaces/viewport/ViewportPanel.cpp b/src/editor/dock-spaces/viewport/ViewportPanel.cpp index d923b9ae..8d7e4807 100644 --- a/src/editor/dock-spaces/viewport/ViewportPanel.cpp +++ b/src/editor/dock-spaces/viewport/ViewportPanel.cpp @@ -18,40 +18,40 @@ namespace Metal { appendChild(cameraPanel = new CameraPositionPanel()); shortcuts = { - ShortcutDTO("Change shading mode", ImGuiKey_Q, []() { - CTX.editorRepository.shadingMode = ShadingModes::ValueOfIndex( - ShadingModes::IndexOfValue(CTX.editorRepository.shadingMode) + 1); + ShortcutDTO("Change shading mode", ImGuiKey_Q, [this]() { + applicationContext->editorRepository.shadingMode = ShadingModes::ValueOfIndex( + ShadingModes::IndexOfValue(applicationContext->editorRepository.shadingMode) + 1); }), - ShortcutDTO("Translate", ImGuiKey_1, []() { - CTX.editorRepository.gizmoType = ImGuizmo::OPERATION::TRANSLATE; + ShortcutDTO("Translate", ImGuiKey_1, [this]() { + applicationContext->editorRepository.gizmoType = ImGuizmo::OPERATION::TRANSLATE; }), - ShortcutDTO("Scale", ImGuiKey_2, []() { - CTX.editorRepository.gizmoType = ImGuizmo::OPERATION::SCALE; + ShortcutDTO("Scale", ImGuiKey_2, [this]() { + applicationContext->editorRepository.gizmoType = ImGuizmo::OPERATION::SCALE; }), - ShortcutDTO("Rotate", ImGuiKey_3, []() { - CTX.editorRepository.gizmoType = ImGuizmo::OPERATION::ROTATE; + ShortcutDTO("Rotate", ImGuiKey_3, [this]() { + applicationContext->editorRepository.gizmoType = ImGuizmo::OPERATION::ROTATE; }), ShortcutDTO("Delete", ImGuiKey_Delete, [this]() { std::vector entities; - for (auto &entry: CTX.editorRepository.selected) { + for (auto &entry: applicationContext->editorRepository.selected) { entities.push_back(entry.first); } - CTX.worldRepository.deleteEntities(entities); - CTX.selectionService.clearSelection(); + applicationContext->worldRepository.deleteEntities(entities); + applicationContext->selectionService.clearSelection(); }), ShortcutDTO("Select All", ImGuiMod_Ctrl | ImGuiKey_A, [this]() { std::vector entities; - auto &storage = CTX.worldRepository.registry.storage(); + auto &storage = applicationContext->worldRepository.registry.storage(); for (auto it = storage.begin(); it != storage.end(); ++it) { auto entity = *it; - if (CTX.worldRepository.registry.all_of(entity)) { + if (applicationContext->worldRepository.registry.all_of(entity)) { entities.push_back(entity); } } - CTX.selectionService.addAllSelected(entities); + applicationContext->selectionService.addAllSelected(entities); }), - ShortcutDTO("Save", ImGuiMod_Ctrl | ImGuiKey_S, [] { - CTX.save(); + ShortcutDTO("Save", ImGuiMod_Ctrl | ImGuiKey_S, [this] { + applicationContext->save(); }) }; } @@ -68,13 +68,13 @@ namespace Metal { } void ViewportPanel::updateCamera() { - auto &worldRepository = CTX.worldRepository; - const auto &cameraService = CTX.cameraService; + auto &worldRepository = applicationContext->worldRepository; + const auto &cameraService = applicationContext->cameraService; if (ImGui::IsWindowHovered() && !ImGuizmo::IsUsing() && ImGui::IsMouseDown(ImGuiMouseButton_Right)) { cameraService.handleInput(isFirstMovement); if (const auto &io = ImGui::GetIO(); io.MouseWheel != 0) { - worldRepository.camera.movementSensitivity += io.MouseWheel * 100 * CTX. + worldRepository.camera.movementSensitivity += io.MouseWheel * 100 * applicationContext-> engineContext.deltaTime; worldRepository.camera.movementSensitivity = std::max(.1f, worldRepository.camera.movementSensitivity); @@ -86,7 +86,7 @@ namespace Metal { } void ViewportPanel::updateInputs() const { - auto &repo = CTX.runtimeRepository; + auto &repo = applicationContext->runtimeRepository; const ImVec2 windowSize = ImGui::GetWindowSize(); size->x = windowSize.x; size->y = windowSize.y; diff --git a/src/editor/dock-spaces/world/WorldHeaderPanel.cpp b/src/editor/dock-spaces/world/WorldHeaderPanel.cpp index 8aea7de6..f263fb2c 100644 --- a/src/editor/dock-spaces/world/WorldHeaderPanel.cpp +++ b/src/editor/dock-spaces/world/WorldHeaderPanel.cpp @@ -28,7 +28,7 @@ namespace Metal { ImGui::SameLine(); if (UIUtil::ButtonSimple(Icons::add + "##hierarchyAdd" + id, UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE)) { - CTX.worldRepository.createEntity(); + applicationContext->worldRepository.createEntity(); } UIUtil::RenderTooltip("Create entity"); } diff --git a/src/editor/dock-spaces/world/WorldPanel.cpp b/src/editor/dock-spaces/world/WorldPanel.cpp index c7cd1842..dfa7c336 100644 --- a/src/editor/dock-spaces/world/WorldPanel.cpp +++ b/src/editor/dock-spaces/world/WorldPanel.cpp @@ -10,17 +10,17 @@ namespace Metal { void WorldPanel::onInitialize() { appendChild(headerPanel = new WorldHeaderPanel()); - world = &CTX.worldRepository; - editorRepository = &CTX.editorRepository; + world = &applicationContext->worldRepository; + editorRepository = &applicationContext->editorRepository; shortcuts = { ShortcutDTO("Delete", ImGuiKey_Delete, [this]() { std::vector entities; - for (auto &entry: CTX.editorRepository.selected) { + for (auto &entry: applicationContext->editorRepository.selected) { entities.push_back(entry.first); } - CTX.worldRepository.deleteEntities(entities); - CTX.selectionService.clearSelection(); + applicationContext->worldRepository.deleteEntities(entities); + applicationContext->selectionService.clearSelection(); }), ShortcutDTO("Select All", ImGuiMod_Ctrl | ImGuiKey_A, [this]() { std::vector entities; @@ -29,10 +29,10 @@ namespace Metal { entities.push_back(entity); } } - CTX.selectionService.addAllSelected(entities); + applicationContext->selectionService.addAllSelected(entities); }), - ShortcutDTO("Save", ImGuiMod_Ctrl | ImGuiKey_S, [] { - CTX.save(); + ShortcutDTO("Save", ImGuiMod_Ctrl | ImGuiKey_S, [this] { + applicationContext->save(); }), }; } @@ -41,11 +41,11 @@ namespace Metal { if (ImGui::BeginPopupContextItem((id + "contextMenu").c_str())) { if (ImGui::MenuItem("Delete")) { std::vector entities; - for (auto &entry: CTX.editorRepository.selected) { + for (auto &entry: applicationContext->editorRepository.selected) { entities.push_back(entry.first); } - CTX.worldRepository.deleteEntities(entities); - CTX.selectionService.clearSelection(); + applicationContext->worldRepository.deleteEntities(entities); + applicationContext->selectionService.clearSelection(); } ImGui::EndPopup(); } @@ -73,7 +73,7 @@ namespace Metal { ImGui::EndTable(); } - if (!CTX.editorRepository.selected.empty()) { + if (!applicationContext->editorRepository.selected.empty()) { contextMenu(); } } @@ -172,7 +172,7 @@ namespace Metal { const bool isVisible = !world->hiddenEntities.contains(entityId); if (UIUtil::ButtonSimple((isVisible ? Icons::visibility : Icons::visibility_off) + ("##v") + std::to_string(static_cast(entt::to_integral(entityId))) + id, 20, 15)) { - CTX.worldRepository.changeVisibility(entityId, !isVisible); + applicationContext->worldRepository.changeVisibility(entityId, !isVisible); } ImGui::PopStyleColor(); ImGui::PopStyleVar(2); @@ -182,9 +182,9 @@ namespace Metal { void WorldPanel::handleClick(const entt::entity entityId) const { if (ImGui::IsItemClicked()) { if (const bool isMultiSelect = ImGui::IsKeyDown(ImGuiKey_LeftCtrl); !isMultiSelect) { - CTX.selectionService.clearSelection(); + applicationContext->selectionService.clearSelection(); } - CTX.selectionService.addSelected(entityId); + applicationContext->selectionService.addSelected(entityId); } } diff --git a/src/editor/panel/FileImportModalPanel.cpp b/src/editor/panel/FileImportModalPanel.cpp index 0f002400..46941806 100644 --- a/src/editor/panel/FileImportModalPanel.cpp +++ b/src/editor/panel/FileImportModalPanel.cpp @@ -13,7 +13,7 @@ namespace Metal { } void FileImportModalPanel::onSync() { - auto &editorRepository = CTX.editorRepository; + auto &editorRepository = applicationContext->editorRepository; if (editorRepository.pendingImports.empty()) { isFirst = true; return; @@ -91,10 +91,10 @@ namespace Metal { if (ImGui::Button(("Approve" + id + "approveImport").c_str(), ImVec2(120, 0))) { for (const std::string &file: editorRepository.pendingImports) { - CTX.fileImporterService.importFile(editorRepository.targetImportDirectory->absolutePath, file, + applicationContext->fileImporterService.importFile(editorRepository.targetImportDirectory->absolutePath, file, editorRepository.importSettingsMap.at(file)); } - CTX.notificationService.pushMessage("Importing files...", NotificationSeverities::WARNING); + applicationContext->notificationService.pushMessage("Importing files...", NotificationSeverities::WARNING); FilesService::GetEntries(editorRepository.targetImportDirectory); editorRepository.pendingImports.clear(); editorRepository.importSettingsMap.clear(); diff --git a/src/editor/panel/NotificationsPanel.cpp b/src/editor/panel/NotificationsPanel.cpp index 873b0491..6b5c8dc0 100644 --- a/src/editor/panel/NotificationsPanel.cpp +++ b/src/editor/panel/NotificationsPanel.cpp @@ -7,17 +7,17 @@ namespace Metal { void NotificationsPanel::onSync() { int usedIndices = 0; - for (int i = 0; i < CTX.notificationService.getNotifications().size(); i++) { - auto *notification = CTX.notificationService.getNotifications()[i]; + for (int i = 0; i < applicationContext->notificationService.getNotifications().size(); i++) { + auto *notification = applicationContext->notificationService.getNotifications()[i]; if (notification == nullptr) { continue; } if (notification->displayTime < 0) { - notification->displayTime = CTX.engineContext.currentTimeMs; + notification->displayTime = applicationContext->engineContext.currentTimeMs; } - if (CTX.engineContext.currentTimeMs - notification->displayTime > MESSAGE_DURATION) { + if (applicationContext->engineContext.currentTimeMs - notification->displayTime > MESSAGE_DURATION) { delete notification; - CTX.notificationService.getNotifications()[i] = nullptr; + applicationContext->notificationService.getNotifications()[i] = nullptr; continue; } ImGui::SetNextWindowPos(ImVec2(5, ImGui::GetMainViewport()->Size.y - 40 * (usedIndices + 1))); diff --git a/src/editor/service/FileImporterService.cpp b/src/editor/service/FileImporterService.cpp index 09e8f104..2131cd1f 100644 --- a/src/editor/service/FileImporterService.cpp +++ b/src/editor/service/FileImporterService.cpp @@ -1,6 +1,9 @@ #include "FileImporterService.h" - -#include "../../ApplicationContext.h" +#include "SceneImporterService.h" +#include "TextureImporterService.h" +#include "VoxelImporterService.h" +#include "NotificationService.h" +#include "AsyncTaskService.h" #include "LogService.h" #include @@ -11,30 +14,30 @@ namespace Metal { const std::shared_ptr &settings) { std::string fileName = file.substr(file.find_last_of(std::filesystem::path::preferred_separator) + 1); runAsync("Import file: " + fileName, - [targetDir, file, fileName, settings](const std::stop_token &token) { + [this, targetDir, file, fileName, settings](const std::stop_token &token) { try { LOG_INFO("Starting file processing: " + fileName); - if (CTX.sceneImporterService.isCompatible(file)) { - CTX.sceneImporterService.importData(targetDir, + if (sceneImporterService.isCompatible(file)) { + sceneImporterService.importData(targetDir, file, settings, token); - } else if (CTX.textureImporter.isCompatible(file)) { - CTX.textureImporter.importData(targetDir, file, settings, token); - } else if (CTX.voxelImporterService.isCompatible(file)) { - CTX.voxelImporterService.importData(targetDir, file, settings, token); + } else if (textureImporterService.isCompatible(file)) { + textureImporterService.importData(targetDir, file, settings, token); + } else if (voxelImporterService.isCompatible(file)) { + voxelImporterService.importData(targetDir, file, settings, token); } LOG_INFO("Successfully imported file: " + fileName); - CTX.notificationService.pushMessage("Successfully imported file: " + fileName, + notificationService.pushMessage("Successfully imported file: " + fileName, NotificationSeverities::SUCCESS); } catch (std::exception &e) { - CTX.notificationService.pushMessage(e.what(), NotificationSeverities::ERROR); + notificationService.pushMessage(e.what(), NotificationSeverities::ERROR); } }); } std::string FileImporterService::runAsync(const std::string &taskName, const LoadingTask &task) const { std::stop_source stopSource; - std::string taskId = CTX.asyncTaskService.registerTask(taskName, [stopSource]() mutable { + std::string taskId = asyncTaskService.registerTask(taskName, [stopSource]() mutable { stopSource.request_stop(); }); @@ -46,7 +49,7 @@ namespace Metal { } catch (...) { LOG_ERROR("Loading task failed with unknown error."); } - CTX.asyncTaskService.endTask(taskId, stopToken.stop_requested()); + asyncTaskService.endTask(taskId, stopToken.stop_requested()); }).detach(); return taskId; @@ -54,13 +57,13 @@ namespace Metal { std::string FileImporterService::collectCompatibleFiles() const { std::string outStr = ""; - for (std::string type: CTX.sceneImporterService.getSupportedTypes()) { + for (std::string type: sceneImporterService.getSupportedTypes()) { outStr += type + ","; }; - for (std::string type: CTX.textureImporter.getSupportedTypes()) { + for (std::string type: textureImporterService.getSupportedTypes()) { outStr += type + ","; }; - for (std::string type: CTX.voxelImporterService.getSupportedTypes()) { + for (std::string type: voxelImporterService.getSupportedTypes()) { outStr += type + ","; }; return outStr; diff --git a/src/editor/service/FileImporterService.h b/src/editor/service/FileImporterService.h index ee69dcb4..86b1227b 100644 --- a/src/editor/service/FileImporterService.h +++ b/src/editor/service/FileImporterService.h @@ -9,8 +9,31 @@ #include "../../common/AbstractRuntimeComponent.h" namespace Metal { + class SceneImporterService; + class TextureImporterService; + class VoxelImporterService; + class NotificationService; + class AsyncTaskService; + class FileImporterService final : public AbstractRuntimeComponent { + SceneImporterService &sceneImporterService; + TextureImporterService &textureImporterService; + VoxelImporterService &voxelImporterService; + NotificationService ¬ificationService; + AsyncTaskService &asyncTaskService; + public: + FileImporterService(SceneImporterService &sceneImporterService, + TextureImporterService &textureImporterService, + VoxelImporterService &voxelImporterService, + NotificationService ¬ificationService, + AsyncTaskService &asyncTaskService) + : sceneImporterService(sceneImporterService), + textureImporterService(textureImporterService), + voxelImporterService(voxelImporterService), + notificationService(notificationService), + asyncTaskService(asyncTaskService) { + } using LoadingTask = std::function; diff --git a/src/editor/service/FilesService.cpp b/src/editor/service/FilesService.cpp index fd0bf822..90e59a05 100644 --- a/src/editor/service/FilesService.cpp +++ b/src/editor/service/FilesService.cpp @@ -1,9 +1,9 @@ #include "FilesService.h" +#include "NotificationService.h" #include "../dto/FSEntry.h" #include "../enum/EntryType.h" #include "../enum/engine-definitions.h" #include "../util/FilesUtil.h" -#include "../../ApplicationContext.h" #include "LogService.h" #include #include @@ -14,20 +14,20 @@ namespace fs = std::filesystem; -#define DELETE_F(F)\ +#define DELETE_F(F, rootDir)\ std::filesystem::remove_all(entry.second->absolutePath);\ -std::filesystem::remove_all(CTX.getAssetDirectory() + F(entry.second->getId())); +std::filesystem::remove_all(rootDir + "/assets/" + F(entry.second->getId())); -#define DELETE_S(F)\ +#define DELETE_S(F, rootDir)\ std::filesystem::remove_all(entry.second->absolutePath);\ -std::filesystem::remove_all(CTX.getAssetDirectory() + F(entry.second->getId())); +std::filesystem::remove_all(rootDir + "/assets/" + F(entry.second->getId())); #define DATA \ std::filesystem::file_time_type ftime = last_write_time(entry); namespace Metal { void FilesService::onInitialize() { - root = new FSEntry(nullptr, CTX.getAssetRefDirectory(), ""); + root = new FSEntry(nullptr, rootDirectory + "/assets-ref/", ""); root->type = EntryType::DIRECTORY; root->name = "Files"; GetEntries(root); @@ -70,19 +70,19 @@ namespace Metal { break; } case EntryType::MESH: { - DELETE_F(FORMAT_FILE_MESH) + DELETE_F(FORMAT_FILE_MESH, rootDirectory) break; } case EntryType::TEXTURE: { - DELETE_F(FORMAT_FILE_TEXTURE) + DELETE_F(FORMAT_FILE_TEXTURE, rootDirectory) break; } case EntryType::SCENE: { - DELETE_S(FORMAT_FILE_SCENE) + DELETE_S(FORMAT_FILE_SCENE, rootDirectory) break; } case EntryType::VOLUME: { - DELETE_S(FORMAT_FILE_VOLUME) + DELETE_S(FORMAT_FILE_VOLUME, rootDirectory) break; } default: break;; @@ -116,7 +116,7 @@ namespace Metal { fs::rename(sourcePath, targetPath); } catch (const fs::filesystem_error &e) { LOG_ERROR("Could not move file"); - CTX.notificationService.pushMessage("Could not move entry", NotificationSeverities::ERROR); + notificationService.pushMessage("Could not move entry", NotificationSeverities::ERROR); return; } diff --git a/src/editor/service/FilesService.h b/src/editor/service/FilesService.h index c2906941..62fe176d 100644 --- a/src/editor/service/FilesService.h +++ b/src/editor/service/FilesService.h @@ -9,12 +9,16 @@ namespace Metal { struct FSEntry; + class NotificationService; + class FilesService final : public AbstractRuntimeComponent { FSEntry *root = nullptr; + std::string &rootDirectory; + NotificationService ¬ificationService; public: - explicit FilesService() - : AbstractRuntimeComponent() { + explicit FilesService(std::string &rootDirectory, NotificationService ¬ificationService) + : AbstractRuntimeComponent(), rootDirectory(rootDirectory), notificationService(notificationService) { } FSEntry *getRoot() { diff --git a/src/editor/service/LogService.cpp b/src/editor/service/LogService.cpp index 28cf54e1..c0d5cb41 100644 --- a/src/editor/service/LogService.cpp +++ b/src/editor/service/LogService.cpp @@ -4,12 +4,12 @@ #include #include -namespace Metal { +namespace Metal::LogService { - LogService::LogService() : AbstractRuntimeComponent() { - } + static std::vector entries; + static std::mutex logMutex; - void LogService::log(LogLevel level, const std::string &message) const { + void log(LogLevel level, const std::string &message) { auto now = std::chrono::system_clock::now(); auto in_time_t = std::chrono::system_clock::to_time_t(now); @@ -25,17 +25,17 @@ namespace Metal { std::cout << "[" << timestamp << "] [" << getLevelName(level) << "] " << message << std::endl; } - std::vector LogService::getEntriesSnapshot() const { + std::vector getEntriesSnapshot() { std::lock_guard lock(logMutex); return entries; } - void LogService::clear() { + void clear() { std::lock_guard lock(logMutex); entries.clear(); } - const char* LogService::getLevelName(LogLevel level) { + const char* getLevelName(LogLevel level) { switch (level) { case LogLevel::Trace: return "TRACE"; case LogLevel::Debug: return "DEBUG"; @@ -47,7 +47,7 @@ namespace Metal { } } - uint32_t LogService::getLevelColor(LogLevel level) { + uint32_t getLevelColor(LogLevel level) { switch (level) { case LogLevel::Trace: return 0xFF888888; // Grey case LogLevel::Debug: return 0xFFAAAAAA; // Light Grey diff --git a/src/editor/service/LogService.h b/src/editor/service/LogService.h index 94254087..756e30c4 100644 --- a/src/editor/service/LogService.h +++ b/src/editor/service/LogService.h @@ -23,30 +23,23 @@ namespace Metal { std::string timestamp; }; - class LogService : public AbstractRuntimeComponent { - public: - explicit LogService(); + namespace LogService { + void log(LogLevel level, const std::string &message); - void log(LogLevel level, const std::string &message) const; - - [[nodiscard]] std::vector getEntriesSnapshot() const; + [[nodiscard]] std::vector getEntriesSnapshot(); void clear(); - static const char* getLevelName(LogLevel level); - static uint32_t getLevelColor(LogLevel level); - - private: - mutable std::vector entries; - mutable std::mutex logMutex; - }; + const char* getLevelName(LogLevel level); + uint32_t getLevelColor(LogLevel level); + } } -#define LOG_TRACE(msg) CTX.logService.log(Metal::LogLevel::Trace, msg) -#define LOG_DEBUG(msg) CTX.logService.log(Metal::LogLevel::Debug, msg) -#define LOG_INFO(msg) CTX.logService.log(Metal::LogLevel::Info, msg) -#define LOG_WARN(msg) CTX.logService.log(Metal::LogLevel::Warn, msg) -#define LOG_ERROR(msg) CTX.logService.log(Metal::LogLevel::Error, msg) -#define LOG_FATAL(msg) CTX.logService.log(Metal::LogLevel::Fatal, msg) +#define LOG_TRACE(msg) Metal::LogService::log(Metal::LogLevel::Trace, msg) +#define LOG_DEBUG(msg) Metal::LogService::log(Metal::LogLevel::Debug, msg) +#define LOG_INFO(msg) Metal::LogService::log(Metal::LogLevel::Info, msg) +#define LOG_WARN(msg) Metal::LogService::log(Metal::LogLevel::Warn, msg) +#define LOG_ERROR(msg) Metal::LogService::log(Metal::LogLevel::Error, msg) +#define LOG_FATAL(msg) Metal::LogService::log(Metal::LogLevel::Fatal, msg) #endif diff --git a/src/editor/service/MaterialImporterService.cpp b/src/editor/service/MaterialImporterService.cpp index 1270b7fd..dbe18d97 100644 --- a/src/editor/service/MaterialImporterService.cpp +++ b/src/editor/service/MaterialImporterService.cpp @@ -1,5 +1,6 @@ #include "MaterialImporterService.h" -#include "../../ApplicationContext.h" +#include "TextureImporterService.h" +#include "LogService.h" #include "../enum/engine-definitions.h" #include "../../engine/dto/PrimitiveComponent.h" #include @@ -21,7 +22,7 @@ namespace Metal { try { const unsigned int embeddedIndex = static_cast(std::stoul(p.substr(1))); if (scene && embeddedIndex < scene->mNumTextures) { - return CTX.textureImporter.importEmbeddedTexture( + return textureImporterService.importEmbeddedTexture( targetDir, scene->mTextures[embeddedIndex], nameHint); } } catch (std::exception &e) { @@ -37,7 +38,7 @@ namespace Metal { } resolved = resolved.lexically_normal(); try { - return CTX.textureImporter.importData(targetDir, resolved.string(), nullptr, stopToken); + return textureImporterService.importData(targetDir, resolved.string(), nullptr, stopToken); } catch (std::exception &e) { LOG_ERROR("Failed to import texture " + resolved.string() + ": " + e.what()); return ""; diff --git a/src/editor/service/MaterialImporterService.h b/src/editor/service/MaterialImporterService.h index 5eb416e5..21f5a876 100644 --- a/src/editor/service/MaterialImporterService.h +++ b/src/editor/service/MaterialImporterService.h @@ -11,8 +11,17 @@ namespace Metal { struct PrimitiveComponent; + class TextureImporterService; + class MaterialImporterService final : public AbstractRuntimeComponent { + TextureImporterService &textureImporterService; + std::string &rootDirectory; + public: + MaterialImporterService(TextureImporterService &textureImporterService, std::string &rootDirectory) + : textureImporterService(textureImporterService), rootDirectory(rootDirectory) { + } + void importMaterial(const std::string &targetDir, const aiMaterial *material, const aiScene *scene, const std::string &rootDirectory, PrimitiveComponent &primitive, const std::stop_token &stopToken = {}) const; diff --git a/src/editor/service/MeshImporterService.cpp b/src/editor/service/MeshImporterService.cpp index 4dabe766..6035b5a9 100644 --- a/src/editor/service/MeshImporterService.cpp +++ b/src/editor/service/MeshImporterService.cpp @@ -1,10 +1,10 @@ #include "MeshImporterService.h" +#include "LogService.h" #include "../../engine/dto/MeshData.h" #include "../../engine/dto/VertexData.h" #include "../dto/EntryMetadata.h" #include "../enum/engine-definitions.h" #include "../util/FilesUtil.h" -#include "../../ApplicationContext.h" #include #include "../../common/serialization-definitions.h" @@ -17,7 +17,7 @@ namespace Metal { metadata.name = metadata.name.substr(0, metadata.name.find_last_of('.')); } - std::string lod0Path = CTX.getAssetDirectory() + FORMAT_FILE_MESH(metadata.getId()); + std::string lod0Path = rootDirectory + "/assets/" + FORMAT_FILE_MESH(metadata.getId()); { std::ofstream output(lod0Path, std::ios::binary); cereal::BinaryOutputArchive archive(output); diff --git a/src/editor/service/MeshImporterService.h b/src/editor/service/MeshImporterService.h index 5d522770..82bea5e6 100644 --- a/src/editor/service/MeshImporterService.h +++ b/src/editor/service/MeshImporterService.h @@ -16,7 +16,12 @@ namespace Metal { struct MeshData; class MeshImporterService final : public AbstractRuntimeComponent { + std::string &rootDirectory; + public: + explicit MeshImporterService(std::string &rootDirectory) + : rootDirectory(rootDirectory) { + } void persistAllMeshes(const std::string &targetDir, const aiScene *scene, std::unordered_map &meshMap, diff --git a/src/editor/service/PickingService.cpp b/src/editor/service/PickingService.cpp index 45c76e19..34c7c4ee 100644 --- a/src/editor/service/PickingService.cpp +++ b/src/editor/service/PickingService.cpp @@ -3,17 +3,20 @@ #include "../../engine/resource/BufferInstance.h" #include "../../engine/resource/TextureInstance.h" #include "../../ApplicationContext.h" +#include "../../core/vulkan/VulkanContext.h" +#include "../../engine/service/BufferService.h" +#include "../../engine/repository/WorldRepository.h" namespace Metal { std::optional PickingService::pickEntityFromGBuffer(TextureInstance *attachment, const uint32_t pixelX, const uint32_t pixelY) const { constexpr VkDeviceSize imageSize = 4 * sizeof(float); - auto stagingBuffer = CTX.bufferService.createBuffer("stagingBuffer", imageSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT, + auto stagingBuffer = bufferService.createBuffer("stagingBuffer", imageSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); - VkCommandBuffer commandBuffer = CTX.vulkanContext.beginSingleTimeCommands(); + VkCommandBuffer commandBuffer = vulkanContext.beginSingleTimeCommands(); VkImageMemoryBarrier barrier = {}; barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; @@ -35,8 +38,8 @@ namespace Metal { region.bufferImageHeight = 0; region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; region.imageSubresource.mipLevel = 0; - region.imageSubresource.baseArrayLayer = 0; - region.imageSubresource.layerCount = 1; + region.baseArrayLayer = 0; + region.layerCount = 1; region.imageOffset = {static_cast(pixelX), static_cast(pixelY), 0}; region.imageExtent = {1, 1, 1}; @@ -51,14 +54,14 @@ namespace Metal { vkCmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier); - CTX.vulkanContext.endSingleTimeCommands(commandBuffer); + vulkanContext.endSingleTimeCommands(commandBuffer); void *data = nullptr; - vkMapMemory(CTX.vulkanContext.device.device, stagingBuffer->vkDeviceMemory, 0, imageSize, 0, &data); + vkMapMemory(vulkanContext.device.device, stagingBuffer->vkDeviceMemory, 0, imageSize, 0, &data); const auto *pixel = static_cast(data); const float idValue = pixel[3]; // Render index is in the A channel (index 3) - vkUnmapMemory(CTX.vulkanContext.device.device, stagingBuffer->vkDeviceMemory); - CTX.bufferService.dispose("stagingBuffer"); + vkUnmapMemory(vulkanContext.device.device, stagingBuffer->vkDeviceMemory); + bufferService.dispose("stagingBuffer"); if (idValue <= 0.0f) { return std::nullopt; @@ -66,7 +69,7 @@ namespace Metal { const unsigned int renderIndex = static_cast(idValue + 0.5f) - 1; - auto view = CTX.worldRepository.registry.view(); + auto view = worldRepository.registry.view(); for (auto entity: view) { auto &mesh = view.get(entity); if (mesh.renderIndex == renderIndex) { diff --git a/src/editor/service/PickingService.h b/src/editor/service/PickingService.h index 36ff15c0..88127897 100644 --- a/src/editor/service/PickingService.h +++ b/src/editor/service/PickingService.h @@ -7,8 +7,20 @@ namespace Metal { struct TextureInstance; + class VulkanContext; + class BufferService; + struct WorldRepository; + class PickingService final : public AbstractRuntimeComponent { + VulkanContext &vulkanContext; + BufferService &bufferService; + WorldRepository &worldRepository; + public: + PickingService(VulkanContext &vulkanContext, BufferService &bufferService, WorldRepository &worldRepository) + : vulkanContext(vulkanContext), bufferService(bufferService), worldRepository(worldRepository) {} + PickingService() = delete; + [[nodiscard]] std::optional pickEntityFromGBuffer(TextureInstance *attachment, uint32_t pixelX, uint32_t pixelY) const; }; } // Metal diff --git a/src/editor/service/SceneImporterService.cpp b/src/editor/service/SceneImporterService.cpp index d63b859c..70ef75a7 100644 --- a/src/editor/service/SceneImporterService.cpp +++ b/src/editor/service/SceneImporterService.cpp @@ -1,5 +1,7 @@ #include "SceneImporterService.h" - +#include "MeshImporterService.h" +#include "MaterialImporterService.h" +#include "LogService.h" #include "../dto/FSEntry.h" #include "../../engine/dto/MeshData.h" #include "../dto/SceneData.h" @@ -11,7 +13,6 @@ #include "../util/FilesUtil.h" #include "../dto/EntryMetadata.h" #include "../enum/engine-definitions.h" -#include "../../ApplicationContext.h" #include "../../common/serialization-definitions.h" #include "../dto/SceneImportSettingsDTO.h" @@ -49,7 +50,7 @@ namespace Metal { sceneMetadata.name = sceneData.name = scene->mName.length > 0 ? scene->mName.data : scene->mRootNode->mName.data; - std::string sceneBlobPath = CTX.getAssetDirectory() + FORMAT_FILE_SCENE(sceneMetadata.getId()); + std::string sceneBlobPath = rootDirectory + "/assets/" + FORMAT_FILE_SCENE(sceneMetadata.getId()); std::unordered_map meshMap{}; @@ -57,7 +58,7 @@ namespace Metal { throw std::runtime_error("Import cancelled"); } - CTX.meshImporterService.persistAllMeshes(targetDir, scene, meshMap, stopToken); + meshImporterService.persistAllMeshes(targetDir, scene, meshMap, stopToken); if (stopToken.stop_requested()) { throw std::runtime_error("Import cancelled"); @@ -66,7 +67,7 @@ namespace Metal { fs::path absolutePath = fs::absolute(pathToFile); std::string directoryPath = absolutePath.parent_path().string(); - ProcessNode(sceneData, scene, scene->mRootNode, targetDir, directoryPath, meshMap, stopToken); + processNode(sceneData, scene, scene->mRootNode, targetDir, directoryPath, meshMap, stopToken); ProcessLights(sceneData, scene); if (stopToken.stop_requested()) { @@ -88,10 +89,10 @@ namespace Metal { return sceneMetadata.getId(); } - void SceneImporterService::ProcessNode(SceneData &scene, const aiScene *aiScene, const aiNode *node, + void SceneImporterService::processNode(SceneData &scene, const aiScene *aiScene, const aiNode *node, const std::string &targetDir, const std::string &rootDirectory, const std::unordered_map &meshMap, - const std::stop_token &stopToken) { + const std::stop_token &stopToken) const { if (stopToken.stop_requested()) return; auto ¤tNode = scene.entities.emplace_back(); @@ -105,17 +106,17 @@ namespace Metal { currentNode.transform.rotation = {rotation.w, rotation.x, rotation.y, rotation.z}; currentNode.transform.scale = {scaling.x, scaling.y, scaling.z}; - ProcessMeshes(scene, aiScene, node, targetDir, rootDirectory, meshMap, stopToken); + processMeshes(scene, aiScene, node, targetDir, rootDirectory, meshMap, stopToken); for (unsigned int i = 0; i < node->mNumChildren; ++i) { - ProcessNode(scene, aiScene, node->mChildren[i], targetDir, rootDirectory, meshMap, stopToken); + processNode(scene, aiScene, node->mChildren[i], targetDir, rootDirectory, meshMap, stopToken); } } - void SceneImporterService::ProcessMeshes(SceneData &scene, const aiScene *aiScene, const aiNode *node, + void SceneImporterService::processMeshes(SceneData &scene, const aiScene *aiScene, const aiNode *node, const std::string &targetDir, const std::string &rootDirectory, const std::unordered_map &meshMap, - const std::stop_token &stopToken) { + const std::stop_token &stopToken) const { for (unsigned int i = 0; i < node->mNumMeshes; ++i) { if (stopToken.stop_requested()) return; unsigned int meshIndex = node->mMeshes[i]; @@ -131,7 +132,7 @@ namespace Metal { childMeshNode.entity.name = assimpMesh->mName.length > 0 ? assimpMesh->mName.data : "Mesh"; const aiMaterial *material = aiScene->mMaterials[assimpMesh->mMaterialIndex]; - CTX.materialImporterService.importMaterial(targetDir, material, aiScene, rootDirectory, + materialImporterService.importMaterial(targetDir, material, aiScene, rootDirectory, *childMeshNode.primitive, stopToken); } } diff --git a/src/editor/service/SceneImporterService.h b/src/editor/service/SceneImporterService.h index 6cec5ce0..d70496e7 100644 --- a/src/editor/service/SceneImporterService.h +++ b/src/editor/service/SceneImporterService.h @@ -13,24 +13,39 @@ namespace Metal { struct MeshData; struct SceneData; - class SceneImporterService final : public AbstractImporter { - static void ProcessNode(SceneData &scene, const aiScene *aiScene, const aiNode *node, - const std::string &targetDir, const std::string &rootDirectory, - const std::unordered_map &meshMap, - const std::stop_token &stopToken); - - static void ProcessMeshes(SceneData &scene, const aiScene *aiScene, const aiNode *node, - const std::string &targetDir, const std::string &rootDirectory, - const std::unordered_map &meshMap, - const std::stop_token &stopToken); + class MeshImporterService; + class MaterialImporterService; - static void ProcessLights(SceneData &scene, const aiScene *aiScene); + class SceneImporterService final : public AbstractImporter { + MeshImporterService &meshImporterService; + MaterialImporterService &materialImporterService; + std::string &rootDirectory; public: + SceneImporterService(MeshImporterService &meshImporterService, + MaterialImporterService &materialImporterService, + std::string &rootDirectory) + : meshImporterService(meshImporterService), + materialImporterService(materialImporterService), + rootDirectory(rootDirectory) { + } + std::string importData(const std::string &targetDir, const std::string &pathToFile, const std::shared_ptr &settings, const std::stop_token &stopToken) override; + void processNode(SceneData &scene, const aiScene *aiScene, const aiNode *node, + const std::string &targetDir, const std::string &rootDirectory, + const std::unordered_map &meshMap, + const std::stop_token &stopToken) const; + + void processMeshes(SceneData &scene, const aiScene *aiScene, const aiNode *node, + const std::string &targetDir, const std::string &rootDirectory, + const std::unordered_map &meshMap, + const std::stop_token &stopToken) const; + + static void ProcessLights(SceneData &scene, const aiScene *aiScene); + std::vector getSupportedTypes() override; }; } // Metal diff --git a/src/editor/service/SelectionService.cpp b/src/editor/service/SelectionService.cpp index 245a54ed..0105d673 100644 --- a/src/editor/service/SelectionService.cpp +++ b/src/editor/service/SelectionService.cpp @@ -1,11 +1,10 @@ #include "SelectionService.h" - -#include "../../ApplicationContext.h" +#include "../../editor/repository/EditorRepository.h" +#include "../../engine/repository/WorldRepository.h" #include "../../engine/dto/TransformComponent.h" namespace Metal { void SelectionService::addSelected(entt::entity entity) const { - auto &editorRepository = CTX.editorRepository; if (editorRepository.selected.empty() || entity == EMPTY_ENTITY) { editorRepository.mainSelection = entity; if (editorRepository.mainSelection != EMPTY_ENTITY) { @@ -18,14 +17,12 @@ namespace Metal { } void SelectionService::clearSelection() const { - auto &editorRepository = CTX.editorRepository; editorRepository.selected.clear(); editorRepository.mainSelection = EMPTY_ENTITY; editorRepository.primitiveSelected = nullptr; } void SelectionService::addAllSelected(const std::vector &all) const { - auto &editorRepository = CTX.editorRepository; editorRepository.selected.clear(); const entt::entity first = all.size() > 0 ? all[0] : EMPTY_ENTITY; editorRepository.mainSelection = first; @@ -36,16 +33,14 @@ namespace Metal { } void SelectionService::updatePrimitiveSelected() const { - auto &editorRepository = CTX.editorRepository; - auto &repo = CTX.worldRepository; const auto entityId = editorRepository.mainSelection; - if (entityId == EMPTY_ENTITY || !repo.registry.valid(entityId)) { + if (entityId == EMPTY_ENTITY || !worldRepository.registry.valid(entityId)) { return; } - if (repo.registry.all_of(entityId)) { - editorRepository.primitiveSelected = &repo.registry.get(entityId); + if (worldRepository.registry.all_of(entityId)) { + editorRepository.primitiveSelected = &worldRepository.registry.get(entityId); } } diff --git a/src/editor/service/SelectionService.h b/src/editor/service/SelectionService.h index f86db212..8916fa72 100644 --- a/src/editor/service/SelectionService.h +++ b/src/editor/service/SelectionService.h @@ -10,7 +10,14 @@ namespace Metal { struct EditorRepository; class SelectionService final : public AbstractRuntimeComponent { + EditorRepository &editorRepository; + WorldRepository &worldRepository; + public: + SelectionService(EditorRepository &editorRepository, WorldRepository &worldRepository) + : editorRepository(editorRepository), worldRepository(worldRepository) { + } + void addSelected(entt::entity entity) const; void clearSelection() const; diff --git a/src/editor/service/TextureImporterService.cpp b/src/editor/service/TextureImporterService.cpp index 61697ff1..2b5cb11d 100644 --- a/src/editor/service/TextureImporterService.cpp +++ b/src/editor/service/TextureImporterService.cpp @@ -1,4 +1,5 @@ #include "TextureImporterService.h" +#include "LogService.h" #include "../../../../dependencies/stb/stb_image.h" #include "../../../../dependencies/stb/stb_image_write.h" @@ -9,7 +10,6 @@ #include "../dto/EntryMetadata.h" #include "../enum/EntryType.h" #include "../util/FilesUtil.h" -#include "../../ApplicationContext.h" #include "../../engine/dto/TextureData.h" namespace fs = std::filesystem; @@ -103,7 +103,7 @@ namespace Metal { size_t TextureImporterService::saveImage(const std::string &fileId, const TextureData &textureData) const { - std::string texturePath = CTX.getAssetDirectory() + FORMAT_FILE_TEXTURE(fileId); + std::string texturePath = rootDirectory + "/assets/" + FORMAT_FILE_TEXTURE(fileId); if (!stbi_write_png(texturePath.c_str(), textureData.width, textureData.height, textureData.channels, textureData.data, textureData.width * textureData.channels)) { diff --git a/src/editor/service/TextureImporterService.h b/src/editor/service/TextureImporterService.h index 7357eeac..d00446b9 100644 --- a/src/editor/service/TextureImporterService.h +++ b/src/editor/service/TextureImporterService.h @@ -8,9 +8,11 @@ namespace Metal { struct TextureData; class TextureImporterService final : public AbstractImporter { + std::string &rootDirectory; + public: - explicit TextureImporterService() - : AbstractImporter() { + explicit TextureImporterService(std::string &rootDirectory) + : AbstractImporter(), rootDirectory(rootDirectory) { } std::vector getSupportedTypes() override { diff --git a/src/editor/service/VoxelImporterService.cpp b/src/editor/service/VoxelImporterService.cpp index 101fa675..7d0563db 100644 --- a/src/editor/service/VoxelImporterService.cpp +++ b/src/editor/service/VoxelImporterService.cpp @@ -3,7 +3,6 @@ #include #include "../../common/serialization-definitions.h" -#include "../../ApplicationContext.h" #include "../dto/EntryMetadata.h" #include "../enum/EntryType.h" #include "../enum/engine-definitions.h" @@ -29,7 +28,7 @@ namespace Metal { metadata.name = metadata.name.substr(0, metadata.name.find_last_of('.')); - std::string outPath = CTX.getAssetDirectory() + FORMAT_FILE_VOLUME(metadata.getId()); + std::string outPath = rootDirectory + "/assets/" + FORMAT_FILE_VOLUME(metadata.getId()); metadata.size = convertToSVO(pathToFile, outPath, stopToken); DUMP_TEMPLATE(targetDir + '/' + FORMAT_FILE_METADATA(metadata.getId()), metadata) diff --git a/src/editor/service/VoxelImporterService.h b/src/editor/service/VoxelImporterService.h index 4cee1f71..fed4a639 100644 --- a/src/editor/service/VoxelImporterService.h +++ b/src/editor/service/VoxelImporterService.h @@ -9,7 +9,11 @@ namespace Metal { struct SVOInstance; class VoxelImporterService final : public AbstractImporter { + const std::string &rootDirectory; public: + explicit VoxelImporterService(const std::string &rootDirectory) : rootDirectory(rootDirectory) {} + VoxelImporterService() = delete; + std::vector getSupportedTypes() override; size_t convertToSVO(const std::string &sourcePath, const std::string &outPath, diff --git a/src/engine/EngineContext.cpp b/src/engine/EngineContext.cpp index 744ca3ab..e97a104e 100644 --- a/src/engine/EngineContext.cpp +++ b/src/engine/EngineContext.cpp @@ -1,13 +1,21 @@ #include "EngineContext.h" +#include "service/TransformService.h" +#include "service/StreamingService.h" +#include "service/RayTracingService.h" +#include "service/CameraService.h" +#include "service/LightService.h" +#include "service/VolumeService.h" +#include "repository/WorldRepository.h" +#include "repository/EngineRepository.h" +#include "../editor/repository/EditorRepository.h" #include "../editor/enum/EngineResourceIDs.h" -#include "../ApplicationContext.h" #include "resource/BufferInstance.h" #include "dto/TransformComponent.h" namespace Metal { void EngineContext::resetPathTracerAccumulationCount() const { - CTX.engineRepository.pathTracerAccumulationCount = 0; + engineRepository.pathTracerAccumulationCount = 0; } void EngineContext::onInitialize() { @@ -36,12 +44,12 @@ namespace Metal { void EngineContext::onSync() { updateCurrentTime(); - CTX.transformService.onSync(); - CTX.streamingService.onSync(); - CTX.rayTracingService.onSync(); - CTX.cameraService.onSync(); - CTX.lightService.onSync(); - CTX.volumeService.onSync(); + transformService.onSync(); + streamingService.onSync(); + rayTracingService.onSync(); + cameraService.onSync(); + lightService.onSync(); + volumeService.onSync(); for (auto *frame: registeredFrames) { if (frame->getShouldRender()) { @@ -58,7 +66,7 @@ namespace Metal { } void EngineContext::updateGlobalData() { - auto &camera = CTX.worldRepository.camera; + auto &camera = worldRepository.camera; globalDataUBO.previousProjView = globalDataUBO.projView; globalDataUBO.viewMatrix = camera.viewMatrix; globalDataUBO.projectionMatrix = camera.projectionMatrix; @@ -66,21 +74,21 @@ namespace Metal { globalDataUBO.invProj = camera.invProjectionMatrix; globalDataUBO.invView = camera.invViewMatrix; globalDataUBO.cameraWorldPosition = camera.position; - globalDataUBO.volumeCount = CTX.volumeService.getCount(); - globalDataUBO.lightsCount = CTX.lightService.getCount(); - globalDataUBO.debugFlag = ShadingModes::IndexOfValue(CTX.editorRepository.shadingMode); - CTX.engineRepository.pathTracerAccumulationCount++; - globalDataUBO.pathTracerAccumulationCount = CTX.engineRepository.pathTracerAccumulationCount; + globalDataUBO.volumeCount = volumeService.getCount(); + globalDataUBO.lightsCount = lightService.getCount(); + globalDataUBO.debugFlag = ShadingModes::IndexOfValue(editorRepository.shadingMode); + engineRepository.pathTracerAccumulationCount++; + globalDataUBO.pathTracerAccumulationCount = engineRepository.pathTracerAccumulationCount; globalDataUBO.globalFrameCount++; - globalDataUBO.pathTracerMaxSamples = CTX.engineRepository.pathTracerMaxSamples; - globalDataUBO.denoiserEnabled = CTX.engineRepository.denoiserEnabled && ( + globalDataUBO.pathTracerMaxSamples = engineRepository.pathTracerMaxSamples; + globalDataUBO.denoiserEnabled = engineRepository.denoiserEnabled && ( globalDataUBO.debugFlag == LIT || globalDataUBO.debugFlag == LIGHTING_ONLY) ? 1 : 0; - CTX.lightService.computeSunInfo(); - globalDataUBO.sunPosition = CTX.lightService.getSunPosition(); - globalDataUBO.sunColor = CTX.lightService.getSunColor(); + lightService.computeSunInfo(); + globalDataUBO.sunPosition = lightService.getSunPosition(); + globalDataUBO.sunColor = lightService.getSunColor(); currentFrame->getResourceAs(RID_GLOBAL_DATA)->update(&globalDataUBO); } } diff --git a/src/engine/EngineContext.h b/src/engine/EngineContext.h index 6c07088d..5f73f823 100644 --- a/src/engine/EngineContext.h +++ b/src/engine/EngineContext.h @@ -13,13 +13,52 @@ using Clock = std::chrono::high_resolution_clock; using TimePoint = std::chrono::time_point; namespace Metal { + class TransformService; + class StreamingService; + class RayTracingService; + class CameraService; + class LightService; + class VolumeService; + struct WorldRepository; + struct EditorRepository; + struct EngineRepository; + class EngineContext final : public AbstractRuntimeComponent { + TransformService &transformService; + StreamingService &streamingService; + RayTracingService &rayTracingService; + CameraService &cameraService; + LightService &lightService; + VolumeService &volumeService; + WorldRepository &worldRepository; + EditorRepository &editorRepository; + EngineRepository &engineRepository; + GlobalDataUBO globalDataUBO{}; long long start = -1; bool cameraUpdated = true; bool giSettingsUpdated = true; public: + EngineContext(TransformService &transformService, + StreamingService &streamingService, + RayTracingService &rayTracingService, + CameraService &cameraService, + LightService &lightService, + VolumeService &volumeService, + WorldRepository &worldRepository, + EditorRepository &editorRepository, + EngineRepository &engineRepository) + : transformService(transformService), + streamingService(streamingService), + rayTracingService(rayTracingService), + cameraService(cameraService), + lightService(lightService), + volumeService(volumeService), + worldRepository(worldRepository), + editorRepository(editorRepository), + engineRepository(engineRepository) { + } GlobalDataUBO &getGlobalDataUBO() { return globalDataUBO; } void setCameraUpdated(const bool val) { diff --git a/src/engine/repository/EngineRepository.cpp b/src/engine/repository/EngineRepository.cpp index 30489fef..6d4aa4d2 100644 --- a/src/engine/repository/EngineRepository.cpp +++ b/src/engine/repository/EngineRepository.cpp @@ -41,10 +41,11 @@ namespace Metal { } void EngineRepository::onUpdate(InspectableMember *member) { - if (member != nullptr && (member->group == PATH_TRACER || member->group == ATMOSPHERE || member->group - == SUN || member->group == DEPTH_OF_FIELD)) { - CTX.engineContext.setGISettingsUpdated(true); - } + // TODO - EVENT + // if (member != nullptr && (member->group == PATH_TRACER || member->group == ATMOSPHERE || member->group + // == SUN || member->group == DEPTH_OF_FIELD)) { + // engineContext.setGISettingsUpdated(true); + // } } nlohmann::json EngineRepository::toJson() const { diff --git a/src/engine/repository/WorldRepository.cpp b/src/engine/repository/WorldRepository.cpp index 812ccace..519cb1a5 100644 --- a/src/engine/repository/WorldRepository.cpp +++ b/src/engine/repository/WorldRepository.cpp @@ -1,6 +1,6 @@ #include "WorldRepository.h" +#include "../service/RayTracingService.h" -#include "../../ApplicationContext.h" #include "../enum/ComponentType.h" #include "../../editor/dto/SceneData.h" #include "../../common/serialization-definitions.h" @@ -35,7 +35,7 @@ namespace Metal { registry.destroy(entityId); } - CTX.rayTracingService.markDirty(); + rayTracingService.markDirty(); } void WorldRepository::changeVisibility(entt::entity entity, bool isVisible) { @@ -45,12 +45,12 @@ namespace Metal { } else { hiddenEntities.insert({entity, true}); } - CTX.rayTracingService.markDirty(); + rayTracingService.markDirty(); } void WorldRepository::loadScene(const std::string &sceneId) { SceneData sceneData; - const auto pathToFile = CTX.getAssetDirectory() + FORMAT_FILE_SCENE(sceneId); + const auto pathToFile = rootDirectory + "/assets/" + FORMAT_FILE_SCENE(sceneId); PARSE_TEMPLATE(sceneData, pathToFile) for (auto &entityData: sceneData.entities) { @@ -86,7 +86,7 @@ namespace Metal { } } - CTX.rayTracingService.markDirty(); + rayTracingService.markDirty(); } void WorldRepository::createComponent(const entt::entity entityId, ComponentType type) { diff --git a/src/engine/repository/WorldRepository.h b/src/engine/repository/WorldRepository.h index 1a42b233..0e261522 100644 --- a/src/engine/repository/WorldRepository.h +++ b/src/engine/repository/WorldRepository.h @@ -18,8 +18,16 @@ namespace Metal { class Inspectable; + class RayTracingService; struct WorldRepository final : AbstractRuntimeComponent, Serializable { + RayTracingService &rayTracingService; + std::string &rootDirectory; + + WorldRepository(RayTracingService &rayTracingService, std::string &rootDirectory) + : rayTracingService(rayTracingService), rootDirectory(rootDirectory) { + } + Camera camera{-(glm::pi() / 4), glm::pi() / 4, {10, 10, 10}}; entt::registry registry{}; std::unordered_map culled{}; diff --git a/src/engine/service/BufferService.cpp b/src/engine/service/BufferService.cpp index 27161788..c0931b71 100644 --- a/src/engine/service/BufferService.cpp +++ b/src/engine/service/BufferService.cpp @@ -1,6 +1,6 @@ #include "BufferService.h" -#include "../../ApplicationContext.h" +#include "../../core/vulkan/VulkanContext.h" #include "../../core/vulkan/VulkanUtils.h" #include "../resource/BufferInstance.h" @@ -10,7 +10,7 @@ namespace Metal { VkMemoryPropertyFlags memoryPropertyFlags, BufferType type) { BufferInstance *buffer = createResourceInstance(id, bufferSize, type); createVkBuffer(usageFlags, memoryPropertyFlags, buffer); - vkMapMemory(CTX.vulkanContext.device.device, buffer->vkDeviceMemory, 0, bufferSize, 0, &buffer->mapped); + vkMapMemory(vulkanContext.device.device, buffer->vkDeviceMemory, 0, bufferSize, 0, &buffer->mapped); return buffer; } @@ -23,10 +23,10 @@ namespace Metal { createVkBuffer(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, stagingBuffer); - vkMapMemory(CTX.vulkanContext.device.device, stagingBuffer->vkDeviceMemory, 0, dataSize, 0, + vkMapMemory(vulkanContext.device.device, stagingBuffer->vkDeviceMemory, 0, dataSize, 0, &stagingBuffer->mapped); memcpy(stagingBuffer->mapped, bufferData, dataSize); - vkUnmapMemory(CTX.vulkanContext.device.device, stagingBuffer->vkDeviceMemory); + vkUnmapMemory(vulkanContext.device.device, stagingBuffer->vkDeviceMemory); createVkBuffer(VK_BUFFER_USAGE_TRANSFER_DST_BIT | usageFlags, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, finalBuffer); @@ -38,8 +38,8 @@ namespace Metal { } unsigned int BufferService::findMemoryType(unsigned int typeFilter, VkMemoryPropertyFlags properties) const { - for (unsigned int i = 0; i < CTX.vulkanContext.physicalDeviceMemoryProperties.memoryTypeCount; i++) { - if ((typeFilter & (1 << i)) && (CTX.vulkanContext.physicalDeviceMemoryProperties.memoryTypes[i]. + for (unsigned int i = 0; i < vulkanContext.physicalDeviceMemoryProperties.memoryTypeCount; i++) { + if ((typeFilter & (1 << i)) && (vulkanContext.physicalDeviceMemoryProperties.memoryTypes[i]. propertyFlags & properties) == properties) { return i; @@ -57,31 +57,31 @@ namespace Metal { bufferInfo.usage = usage; bufferInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; - VulkanUtils::CheckVKResult(vkCreateBuffer(CTX.vulkanContext.device.device, &bufferInfo, nullptr, + VulkanUtils::CheckVKResult(vkCreateBuffer(vulkanContext.device.device, &bufferInfo, nullptr, &buffer->vkBuffer)); VkMemoryRequirements memRequirements; - vkGetBufferMemoryRequirements(CTX.vulkanContext.device.device, buffer->vkBuffer, &memRequirements); + vkGetBufferMemoryRequirements(vulkanContext.device.device, buffer->vkBuffer, &memRequirements); VkMemoryAllocateInfo allocInfo{}; allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; allocInfo.allocationSize = memRequirements.size; allocInfo.memoryTypeIndex = findMemoryType(memRequirements.memoryTypeBits, properties); - VulkanUtils::CheckVKResult(vkAllocateMemory(CTX.vulkanContext.device.device, &allocInfo, nullptr, + VulkanUtils::CheckVKResult(vkAllocateMemory(vulkanContext.device.device, &allocInfo, nullptr, &buffer->vkDeviceMemory)); - vkBindBufferMemory(CTX.vulkanContext.device.device, buffer->vkBuffer, buffer->vkDeviceMemory, 0); + vkBindBufferMemory(vulkanContext.device.device, buffer->vkBuffer, buffer->vkDeviceMemory, 0); } void BufferService::copyBuffer(const BufferInstance *srcBuffer, const BufferInstance *dstBuffer) const { - VkCommandBuffer commandBuffer = CTX.vulkanContext.beginSingleTimeCommands(); + VkCommandBuffer commandBuffer = vulkanContext.beginSingleTimeCommands(); VkBufferCopy copyRegion{}; copyRegion.size = dstBuffer->dataSize; vkCmdCopyBuffer(commandBuffer, srcBuffer->vkBuffer, dstBuffer->vkBuffer, 1, ©Region); - CTX.vulkanContext.endSingleTimeCommands(commandBuffer); + vulkanContext.endSingleTimeCommands(commandBuffer); } BufferInstance *BufferService::createBuffer(const std::string &id, VkDeviceSize bufferSize, @@ -99,11 +99,11 @@ namespace Metal { } bufferInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; - VulkanUtils::CheckVKResult(vkCreateBuffer(CTX.vulkanContext.device.device, &bufferInfo, nullptr, + VulkanUtils::CheckVKResult(vkCreateBuffer(vulkanContext.device.device, &bufferInfo, nullptr, &buffer->vkBuffer)); VkMemoryRequirements memRequirements; - vkGetBufferMemoryRequirements(CTX.vulkanContext.device.device, buffer->vkBuffer, &memRequirements); + vkGetBufferMemoryRequirements(vulkanContext.device.device, buffer->vkBuffer, &memRequirements); VkMemoryAllocateInfo allocInfo{}; allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; @@ -117,12 +117,12 @@ namespace Metal { allocInfo.pNext = &allocFlagsInfo; } - VulkanUtils::CheckVKResult(vkAllocateMemory(CTX.vulkanContext.device.device, &allocInfo, nullptr, + VulkanUtils::CheckVKResult(vkAllocateMemory(vulkanContext.device.device, &allocInfo, nullptr, &buffer->vkDeviceMemory)); - vkBindBufferMemory(CTX.vulkanContext.device.device, buffer->vkBuffer, buffer->vkDeviceMemory, 0); + vkBindBufferMemory(vulkanContext.device.device, buffer->vkBuffer, buffer->vkDeviceMemory, 0); if (memoryPropertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) { - vkMapMemory(CTX.vulkanContext.device.device, buffer->vkDeviceMemory, 0, bufferSize, 0, &buffer->mapped); + vkMapMemory(vulkanContext.device.device, buffer->vkDeviceMemory, 0, bufferSize, 0, &buffer->mapped); } return buffer; @@ -137,10 +137,10 @@ namespace Metal { createVkBuffer(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, stagingBuffer); - vkMapMemory(CTX.vulkanContext.device.device, stagingBuffer->vkDeviceMemory, 0, dataSize, 0, + vkMapMemory(vulkanContext.device.device, stagingBuffer->vkDeviceMemory, 0, dataSize, 0, &stagingBuffer->mapped); memcpy(stagingBuffer->mapped, bufferData, dataSize); - vkUnmapMemory(CTX.vulkanContext.device.device, stagingBuffer->vkDeviceMemory); + vkUnmapMemory(vulkanContext.device.device, stagingBuffer->vkDeviceMemory); auto *finalBuffer = createBuffer(id, dataSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT | usageFlags, @@ -153,9 +153,7 @@ namespace Metal { } void BufferService::disposeResource(BufferInstance *resource) { - LOG_INFO("Disposing of buffer instance " + resource->getId()); - - vkDestroyBuffer(CTX.vulkanContext.device.device, resource->vkBuffer, nullptr); - vkFreeMemory(CTX.vulkanContext.device.device, resource->vkDeviceMemory, nullptr); + vkDestroyBuffer(vulkanContext.device.device, resource->vkBuffer, nullptr); + vkFreeMemory(vulkanContext.device.device, resource->vkDeviceMemory, nullptr); } } // Metal diff --git a/src/engine/service/BufferService.h b/src/engine/service/BufferService.h index a171a084..8b6b3632 100644 --- a/src/engine/service/BufferService.h +++ b/src/engine/service/BufferService.h @@ -12,6 +12,8 @@ namespace Metal { class VulkanContext; class BufferService final : public AbstractResourceService { + VulkanContext &vulkanContext; + void copyBuffer(const BufferInstance *srcBuffer, const BufferInstance *dstBuffer) const; @@ -19,6 +21,9 @@ namespace Metal { BufferInstance *buffer) const; public: + explicit BufferService(VulkanContext &vulkanContext) : vulkanContext(vulkanContext) {} + BufferService() = delete; + [[nodiscard]] unsigned int findMemoryType(unsigned int typeFilter, VkMemoryPropertyFlags properties) const; BufferInstance *createBuffer(const std::string &id, VkDeviceSize bufferSize, diff --git a/src/engine/service/CameraService.cpp b/src/engine/service/CameraService.cpp index 3f58a727..9391b3d7 100644 --- a/src/engine/service/CameraService.cpp +++ b/src/engine/service/CameraService.cpp @@ -2,25 +2,26 @@ #include "../dto/Camera.h" #include "../../ApplicationContext.h" +#include "../EngineContext.h" +#include "../repository/WorldRepository.h" +#include "../repository/RuntimeRepository.h" namespace Metal { // Per frame // TODO - EVENT SYSTEM void CameraService::onSync() { - camera = &CTX.worldRepository.camera; + camera = &worldRepository.camera; if (camera != nullptr) { updateAspectRatio(); if (camera->isNotFrozen()) { updateMatrices(); - CTX.engineContext.setCameraUpdated(true); + engineContext.setCameraUpdated(true); camera->freezeVersion(); } } } void CameraService::updateAspectRatio() const { - const auto &runtimeRepository = CTX.runtimeRepository; - const float prevAspect = camera->aspectRatio; camera->aspectRatio = runtimeRepository.viewportW / runtimeRepository.viewportH; if (prevAspect != camera->aspectRatio) { @@ -56,12 +57,11 @@ namespace Metal { camera->invProjectionMatrix = glm::inverse(camera->projectionMatrix); } - CameraService::CameraService() : AbstractRuntimeComponent() { + CameraService::CameraService(EngineContext &engineContext, WorldRepository &worldRepository, RuntimeRepository &runtimeRepository) + : engineContext(engineContext), worldRepository(worldRepository), runtimeRepository(runtimeRepository) { } void CameraService::handleInputInternal() const { - const auto &runtimeRepository = CTX.runtimeRepository; - glm::vec3 forward( -std::sin(camera->yaw) * std::cos(camera->pitch), std::sin(camera->pitch), @@ -76,7 +76,7 @@ namespace Metal { right = glm::normalize(right); const float multiplier = 10 * camera->movementSensitivity * - CTX.engineContext.deltaTime; + engineContext.deltaTime; if (runtimeRepository.leftPressed) { camera->position += right * multiplier; camera->registerChange(); @@ -118,7 +118,6 @@ namespace Metal { } void CameraService::updateDelta(const bool isFirstMovement) const { - const auto &runtimeRepository = CTX.runtimeRepository; const float mouseX = runtimeRepository.mouseX; const float mouseY = runtimeRepository.mouseY; diff --git a/src/engine/service/CameraService.h b/src/engine/service/CameraService.h index 967f3a1c..3109c51d 100644 --- a/src/engine/service/CameraService.h +++ b/src/engine/service/CameraService.h @@ -13,7 +13,16 @@ namespace Metal { class ApplicationContext; struct Camera; + class EngineContext; + struct WorldRepository; + struct RuntimeRepository; + struct Camera; + class CameraService final : public AbstractRuntimeComponent { + EngineContext &engineContext; + WorldRepository &worldRepository; + RuntimeRepository &runtimeRepository; + Camera *camera = nullptr; glm::vec3 xAxis{0.0f}; glm::vec3 yAxis{0.0f}; @@ -38,7 +47,7 @@ namespace Metal { public: void handleInput(bool isFirstMovement) const; - explicit CameraService(); + explicit CameraService(EngineContext &engineContext, WorldRepository &worldRepository, RuntimeRepository &runtimeRepository); void onSync() override; }; diff --git a/src/engine/service/DescriptorSetService.cpp b/src/engine/service/DescriptorSetService.cpp index 901a1f0a..3032fec6 100644 --- a/src/engine/service/DescriptorSetService.cpp +++ b/src/engine/service/DescriptorSetService.cpp @@ -2,7 +2,10 @@ #include "../dto/PipelineBuilder.h" #include "../resource/BufferInstance.h" #include "../../editor/service/LogService.h" -#include "../../ApplicationContext.h" +#include "../../core/vulkan/VulkanContext.h" +#include "FrameBufferService.h" +#include "BufferService.h" +#include "TextureService.h" #include "../resource/FrameBufferAttachment.h" #include "../resource/FrameBufferInstance.h" #include "../resource/TextureInstance.h" @@ -27,13 +30,13 @@ namespace Metal { binding.attachmentIndex = builder.attachmentIndex; if (builder.type == DescriptorBindingType::FBO_ATTACHMENT) { - auto *fbo = CTX.framebufferService.getResource(binding.frameBufferId); + auto *fbo = framebufferService.getResource(binding.frameBufferId); if (fbo == nullptr) { throw std::runtime_error("Framebuffer not found: " + binding.frameBufferId); } binding.view = fbo->attachments[binding.attachmentIndex]->vkImageView; if (binding.sampler == VK_NULL_HANDLE) { - binding.sampler = CTX.vulkanContext.vkImageSampler; + binding.sampler = vulkanContext.vkImageSampler; } } @@ -42,7 +45,7 @@ namespace Metal { binding.descriptorType = VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR; break; case DescriptorBindingType::BUFFER: { - BufferInstance *buffer = CTX.bufferService.getResource(binding.bufferId); + BufferInstance *buffer = bufferService.getResource(binding.bufferId); if (buffer != nullptr) { binding.descriptorType = buffer->getBufferType() == BufferType::UNIFORM_BUFFER @@ -58,7 +61,7 @@ namespace Metal { binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; break; case DescriptorBindingType::STORAGE_IMAGE: { - auto *texture = CTX.textureService.getResource(binding.storageImageId); + auto *texture = textureService.getResource(binding.storageImageId); if (texture == nullptr) { throw std::runtime_error("Storage image texture not found: " + binding.storageImageId); } @@ -77,7 +80,7 @@ namespace Metal { void DescriptorSetService::disposeResource(DescriptorInstance *resource) { LOG_INFO("Disposing of descriptor set resource"); - vkDestroyDescriptorSetLayout(CTX.vulkanContext.device.device, resource->vkDescriptorSetLayout, nullptr); + vkDestroyDescriptorSetLayout(vulkanContext.device.device, resource->vkDescriptorSetLayout, nullptr); } std::vector DescriptorSetService::getAllDescriptors() const { @@ -96,7 +99,7 @@ namespace Metal { attachment->imageDescriptor = createResourceInstance(framebuffer->getId() + std::to_string(attachmentIndex)); attachment->imageDescriptor->bindings.push_back(DescriptorBinding::Of(VK_SHADER_STAGE_FRAGMENT_BIT, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 0, - CTX.vulkanContext.vkImageSampler, + vulkanContext.vkImageSampler, attachment->vkImageView)); updateDescriptor(attachment->imageDescriptor); } @@ -150,27 +153,27 @@ namespace Metal { layoutInfo.flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT_EXT; layoutInfo.pNext = &flagsInfo; - VulkanUtils::CheckVKResult(vkCreateDescriptorSetLayout(CTX.vulkanContext.device.device, &layoutInfo, + VulkanUtils::CheckVKResult(vkCreateDescriptorSetLayout(vulkanContext.device.device, &layoutInfo, nullptr, &descriptor->vkDescriptorSetLayout)); VkDescriptorSetAllocateInfo allocInfo = {}; allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; - allocInfo.descriptorPool = CTX.vulkanContext.descriptorPool; // Created during setup + allocInfo.descriptorPool = vulkanContext.descriptorPool; // Created during setup allocInfo.descriptorSetCount = 1; allocInfo.pSetLayouts = &descriptor->vkDescriptorSetLayout; - VulkanUtils::CheckVKResult(vkAllocateDescriptorSets(CTX.vulkanContext.device.device, &allocInfo, &descriptor->vkDescriptorSet)); + VulkanUtils::CheckVKResult(vkAllocateDescriptorSets(vulkanContext.device.device, &allocInfo, &descriptor->vkDescriptorSet)); // WRITE - Write(descriptor->vkDescriptorSet, descriptor->bindings); + Write(vulkanContext, bufferService, descriptor->vkDescriptorSet, descriptor->bindings); } void DescriptorSetService::write(DescriptorInstance *descriptor) { - Write(descriptor->vkDescriptorSet, descriptor->bindings); + Write(vulkanContext, bufferService, descriptor->vkDescriptorSet, descriptor->bindings); } - void DescriptorSetService::Write(const VkDescriptorSet &vkDescriptorSet, + void DescriptorSetService::Write(VulkanContext &vulkanContext, BufferService &bufferService, const VkDescriptorSet &vkDescriptorSet, const std::vector &bindings) { std::vector writeDescriptorSets; std::vector bufferInfos; @@ -204,7 +207,7 @@ namespace Metal { writeDescriptorSets.push_back(descriptorWrite); } } else if (!binding.bufferId.empty()) { - BufferInstance *buffer = CTX.bufferService.getResource(binding.bufferId); + BufferInstance *buffer = bufferService.getResource(binding.bufferId); if (buffer == nullptr) { LOG_ERROR("DescriptorSetService Buffer not found: " + binding.bufferId); @@ -258,7 +261,7 @@ namespace Metal { if (writeDescriptorSets.empty()) return; - vkUpdateDescriptorSets(CTX.vulkanContext.device.device, + vkUpdateDescriptorSets(vulkanContext.device.device, static_cast(writeDescriptorSets.size()), writeDescriptorSets.data(), 0, diff --git a/src/engine/service/DescriptorSetService.h b/src/engine/service/DescriptorSetService.h index fd5d7833..f5ebde4e 100644 --- a/src/engine/service/DescriptorSetService.h +++ b/src/engine/service/DescriptorSetService.h @@ -8,9 +8,22 @@ namespace Metal { struct PipelineBuilder; struct TextureInstance; struct FrameBufferInstance; + class VulkanContext; + class FrameBufferService; + class BufferService; + class TextureService; class DescriptorSetService final : public AbstractResourceService { + VulkanContext &vulkanContext; + FrameBufferService &framebufferService; + BufferService &bufferService; + TextureService &textureService; + public: + DescriptorSetService(VulkanContext &vulkanContext, FrameBufferService &framebufferService, BufferService &bufferService, TextureService &textureService) + : vulkanContext(vulkanContext), framebufferService(framebufferService), bufferService(bufferService), textureService(textureService) {} + DescriptorSetService() = delete; + DescriptorInstance *createDescriptor(const PipelineBuilder &pipelineBuilder, const std::string &id, VkShaderStageFlags stageFlags); void disposeResource(DescriptorInstance *resource) override; @@ -25,7 +38,7 @@ namespace Metal { void write(DescriptorInstance *descriptor); - static void Write(const VkDescriptorSet &vkDescriptorSet, const std::vector &bindings); + static void Write(VulkanContext &vulkanContext, BufferService &bufferService, const VkDescriptorSet &vkDescriptorSet, const std::vector &bindings); }; } diff --git a/src/engine/service/FrameBufferService.cpp b/src/engine/service/FrameBufferService.cpp index 1f90f6c5..b1bedf37 100644 --- a/src/engine/service/FrameBufferService.cpp +++ b/src/engine/service/FrameBufferService.cpp @@ -5,6 +5,7 @@ #include #include "../resource/FrameBufferInstance.h" +#include "../../core/vulkan/VulkanContext.h" #include "../../core/vulkan/VulkanUtils.h" #include "../resource/FrameBufferAttachment.h" #include "../../ApplicationContext.h" @@ -22,7 +23,7 @@ namespace Metal { } void FrameBufferService::createDepthAttachment(FrameBufferInstance *framebuffer) const { - VkFormat depthFormat = VulkanUtils::GetValidDepthFormat(CTX.vulkanContext.physDevice.physical_device); + VkFormat depthFormat = VulkanUtils::GetValidDepthFormat(vulkanContext.physDevice.physical_device); const auto att = createAttachmentInternal(depthFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, framebuffer); att->depth = true; @@ -72,20 +73,20 @@ namespace Metal { image.sharingMode = VK_SHARING_MODE_EXCLUSIVE; VulkanUtils::CheckVKResult( - vkCreateImage(CTX.vulkanContext.device.device, &image, nullptr, &attachment->vkImage)); + vkCreateImage(vulkanContext.device.device, &image, nullptr, &attachment->vkImage)); VkMemoryAllocateInfo memAlloc{}; VkMemoryRequirements memReqs; - vkGetImageMemoryRequirements(CTX.vulkanContext.device.device, attachment->vkImage, &memReqs); + vkGetImageMemoryRequirements(vulkanContext.device.device, attachment->vkImage, &memReqs); memAlloc.allocationSize = memReqs.size; - memAlloc.memoryTypeIndex = VulkanUtils::GetMemTypeIndex(CTX.vulkanContext.physicalDeviceMemoryProperties, + memAlloc.memoryTypeIndex = VulkanUtils::GetMemTypeIndex(vulkanContext.physicalDeviceMemoryProperties, memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); - VulkanUtils::CheckVKResult(vkAllocateMemory(CTX.vulkanContext.device.device, &memAlloc, nullptr, + VulkanUtils::CheckVKResult(vkAllocateMemory(vulkanContext.device.device, &memAlloc, nullptr, &attachment->vkImageMemory)); VulkanUtils::CheckVKResult( - vkBindImageMemory(CTX.vulkanContext.device.device, attachment->vkImage, attachment->vkImageMemory, 0)); + vkBindImageMemory(vulkanContext.device.device, attachment->vkImage, attachment->vkImageMemory, 0)); VkImageViewCreateInfo imageView{}; imageView.viewType = VK_IMAGE_VIEW_TYPE_2D; @@ -97,7 +98,7 @@ namespace Metal { imageView.subresourceRange.baseArrayLayer = 0; imageView.subresourceRange.layerCount = 1; imageView.image = attachment->vkImage; - VulkanUtils::CheckVKResult(vkCreateImageView(CTX.vulkanContext.device.device, &imageView, nullptr, + VulkanUtils::CheckVKResult(vkCreateImageView(vulkanContext.device.device, &imageView, nullptr, &attachment->vkImageView)); return attachment; } @@ -166,7 +167,7 @@ namespace Metal { renderPassInfo.dependencyCount = dependencies.size(); renderPassInfo.pDependencies = dependencies.data(); - VulkanUtils::CheckVKResult(vkCreateRenderPass(CTX.vulkanContext.device.device, + VulkanUtils::CheckVKResult(vkCreateRenderPass(vulkanContext.device.device, &renderPassInfo, nullptr, &framebuffer->vkRenderPass)); @@ -195,14 +196,14 @@ namespace Metal { framebufferInfo.height = framebuffer->bufferHeight; framebufferInfo.layers = 1; - vkCreateFramebuffer(CTX.vulkanContext.device.device, &framebufferInfo, nullptr, + vkCreateFramebuffer(vulkanContext.device.device, &framebufferInfo, nullptr, &framebuffer->vkFramebuffer); } void FrameBufferService::disposeResource(FrameBufferInstance *resource) { LOG_INFO("Disposing framebuffer instance"); - vkDestroyFramebuffer(CTX.vulkanContext.device.device, resource->vkFramebuffer, nullptr); - vkDestroyRenderPass(CTX.vulkanContext.device.device, resource->vkRenderPass, nullptr); + vkDestroyFramebuffer(vulkanContext.device.device, resource->vkFramebuffer, nullptr); + vkDestroyRenderPass(vulkanContext.device.device, resource->vkRenderPass, nullptr); for (int i = 0; i < resource->attachments.size(); i++) { LOG_INFO("Disposing of attachment instance " + std::to_string(i)); diff --git a/src/engine/service/FrameBufferService.h b/src/engine/service/FrameBufferService.h index 5cc4c221..33694124 100644 --- a/src/engine/service/FrameBufferService.h +++ b/src/engine/service/FrameBufferService.h @@ -12,7 +12,11 @@ namespace Metal { struct FrameBufferAttachment; struct FrameBufferInstance; + class VulkanContext; + class FrameBufferService final : public AbstractResourceService { + VulkanContext &vulkanContext; + std::shared_ptr createAttachmentInternal(VkFormat format, VkImageUsageFlagBits usage, FrameBufferInstance *framebuffer) const; @@ -20,6 +24,9 @@ namespace Metal { void createVKFrameBuffer(FrameBufferInstance *framebuffer) const; public: + explicit FrameBufferService(VulkanContext &vulkanContext) : vulkanContext(vulkanContext) {} + FrameBufferService() = delete; + FrameBufferInstance *createFrameBuffer(const std::string &id, unsigned int w, unsigned int h, glm::vec4 clearColor = glm::vec4(0.0f)); diff --git a/src/engine/service/LightService.cpp b/src/engine/service/LightService.cpp index 3d759aa0..3f4ca266 100644 --- a/src/engine/service/LightService.cpp +++ b/src/engine/service/LightService.cpp @@ -2,6 +2,8 @@ #include "../../ApplicationContext.h" #include "../resource/BufferInstance.h" #include "../../editor/enum/EngineResourceIDs.h" +#include "../EngineContext.h" +#include "../repository/EngineRepository.h" namespace Metal { void LightService::registerLights() { @@ -15,19 +17,19 @@ namespace Metal { registerLights(); if (!items.empty()) { - CTX.engineContext.currentFrame->getResourceAs(RID_LIGHT_BUFFER)->update(items.data()); + engineContext.currentFrame->getResourceAs(RID_LIGHT_BUFFER)->update(items.data()); } } void LightService::computeSunInfo() { sunPosition = glm::vec3(0, - std::cos(CTX.engineRepository.elapsedTime), - std::sin(CTX.engineRepository.elapsedTime)) * CTX.engineRepository + std::cos(engineRepository.elapsedTime), + std::sin(engineRepository.elapsedTime)) * engineRepository .sunDistance; sunColor = LightService::CalculateSunColor( - sunPosition.y / CTX.engineRepository.sunDistance, - CTX.engineRepository.nightColor, CTX.engineRepository.dawnColor, - CTX.engineRepository.middayColor); + sunPosition.y / engineRepository.sunDistance, + engineRepository.nightColor, engineRepository.dawnColor, + engineRepository.middayColor); } glm::vec3 LightService::CalculateSunColor(const float elevation, glm::vec3 &nightColor, glm::vec3 &dawnColor, diff --git a/src/engine/service/LightService.h b/src/engine/service/LightService.h index 655781c9..905b53e0 100644 --- a/src/engine/service/LightService.h +++ b/src/engine/service/LightService.h @@ -6,7 +6,13 @@ #include "../dto/LightData.h" namespace Metal { + class EngineContext; + struct EngineRepository; + class LightService final : public AbstractRuntimeComponent { + EngineContext &engineContext; + EngineRepository &engineRepository; + std::vector items{}; glm::vec3 sunColor{}; glm::vec3 sunPosition{}; @@ -19,6 +25,10 @@ namespace Metal { static glm::vec3 BlendColors(glm::vec3 &c1, glm::vec3 &c2, float t); public: + explicit LightService(EngineContext &engineContext, EngineRepository &engineRepository) + : engineContext(engineContext), engineRepository(engineRepository) {} + LightService() = delete; + void onSync() override; void computeSunInfo(); diff --git a/src/engine/service/MaterialService.cpp b/src/engine/service/MaterialService.cpp index a42e5b3b..4c41d172 100644 --- a/src/engine/service/MaterialService.cpp +++ b/src/engine/service/MaterialService.cpp @@ -2,9 +2,8 @@ #include "../../common/serialization-definitions.h" #include "../dto/MeshMetadata.h" - -#include "../../ApplicationContext.h" - +#include "TextureService.h" +#include "../dto/PrimitiveComponent.h" namespace Metal { void MaterialService::load(MeshMetadata &materialData, PrimitiveComponent &data) { @@ -21,21 +20,21 @@ namespace Metal { materialData.metallicTextureId = 0; if (!data.albedo.empty()) { - auto *tex = CTX.textureService.stream(data.albedo); + auto *tex = textureService.stream(data.albedo); if (tex != nullptr) { - materialData.albedoTextureId = CTX.textureService.getTextureIndex(data.albedo); + materialData.albedoTextureId = textureService.getTextureIndex(data.albedo); } } if (!data.roughness.empty()) { - auto *tex = CTX.textureService.stream(data.roughness); + auto *tex = textureService.stream(data.roughness); if (tex != nullptr) { - materialData.roughnessTextureId = CTX.textureService.getTextureIndex(data.roughness); + materialData.roughnessTextureId = textureService.getTextureIndex(data.roughness); } } if (!data.metallic.empty()) { - auto *tex = CTX.textureService.stream(data.metallic); + auto *tex = textureService.stream(data.metallic); if (tex != nullptr) { - materialData.metallicTextureId = CTX.textureService.getTextureIndex(data.metallic); + materialData.metallicTextureId = textureService.getTextureIndex(data.metallic); } } } diff --git a/src/engine/service/MaterialService.h b/src/engine/service/MaterialService.h index fce5458e..9c1668bc 100644 --- a/src/engine/service/MaterialService.h +++ b/src/engine/service/MaterialService.h @@ -4,9 +4,14 @@ namespace Metal { struct PrimitiveComponent; struct MeshMetadata; + class TextureService; class MaterialService final { + TextureService &textureService; public: + explicit MaterialService(TextureService &textureService) : textureService(textureService) {} + MaterialService() = delete; + void load(MeshMetadata &data, PrimitiveComponent &component); }; } // Metal diff --git a/src/engine/service/MeshService.cpp b/src/engine/service/MeshService.cpp index d3838b01..2b9488ea 100644 --- a/src/engine/service/MeshService.cpp +++ b/src/engine/service/MeshService.cpp @@ -8,8 +8,11 @@ #include #include +#include #include "../../ApplicationContext.h" +#include "BufferService.h" +#include "RayTracingService.h" namespace Metal { MeshInstance *MeshService::create(const std::string &id) { @@ -22,14 +25,14 @@ namespace Metal { instance->indexCount = data->indices.size(); instance->vertexCount = data->data.size(); - instance->dataBuffer = CTX.bufferService.createBuffer( + instance->dataBuffer = bufferService.createBuffer( id + "_data", sizeof(VertexData) * data->data.size(), VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, data->data.data(), true); - instance->indexBuffer = CTX.bufferService.createBuffer( + instance->indexBuffer = bufferService.createBuffer( id + "_indices", sizeof(unsigned int) * data->indices.size(), VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, @@ -53,7 +56,7 @@ namespace Metal { } MeshData *MeshService::loadMeshData(const std::string &id) const { - auto pathToFile = CTX.getAssetDirectory() + FORMAT_FILE_MESH(id); + auto pathToFile = rootDirectory + "/assets/" + FORMAT_FILE_MESH(id); if (std::filesystem::exists(pathToFile)) { auto *data = new MeshData; std::ifstream input(pathToFile, std::ios::binary); @@ -66,8 +69,8 @@ namespace Metal { void MeshService::disposeResource(MeshInstance *resource) { LOG_INFO("Disposing of mesh instance"); - CTX.rayTracingService.markDirty(); - CTX.bufferService.dispose(resource->indexBuffer->getId()); - CTX.bufferService.dispose(resource->dataBuffer->getId()); + rayTracingService.markDirty(); + bufferService.dispose(resource->indexBuffer->getId()); + bufferService.dispose(resource->dataBuffer->getId()); } } // Metal diff --git a/src/engine/service/MeshService.h b/src/engine/service/MeshService.h index 671c7baf..40ba1270 100644 --- a/src/engine/service/MeshService.h +++ b/src/engine/service/MeshService.h @@ -9,8 +9,19 @@ namespace Metal { struct MeshInstance; struct EntityAssetData; + class BufferService; + class RayTracingService; + class MeshService final : public AbstractResourceService { + BufferService &bufferService; + RayTracingService &rayTracingService; + const std::string &rootDirectory; + public: + MeshService(BufferService &bufferService, RayTracingService &rayTracingService, const std::string &rootDirectory) + : bufferService(bufferService), rayTracingService(rayTracingService), rootDirectory(rootDirectory) {} + MeshService() = delete; + MeshInstance *create(const std::string &id); MeshInstance *stream(const std::string &id); diff --git a/src/engine/service/PipelineService.cpp b/src/engine/service/PipelineService.cpp index 30df93ea..d8feef1b 100644 --- a/src/engine/service/PipelineService.cpp +++ b/src/engine/service/PipelineService.cpp @@ -1,8 +1,10 @@ #include "PipelineService.h" #include "../dto/PipelineBuilder.h" #include "../util/ShaderUtil.h" -#include "../../ApplicationContext.h" +#include "../../core/vulkan/VulkanContext.h" #include "../../core/vulkan/VulkanUtils.h" +#include "FrameBufferService.h" +#include "BufferService.h" #include "../resource/FrameBufferInstance.h" #include "../resource/PipelineInstance.h" #include "../dto/MeshData.h" @@ -10,6 +12,7 @@ #include "../dto/DescriptorInstance.h" #include "../resource/FrameBufferAttachment.h" #include "../resource/BufferInstance.h" +#include "../../ApplicationContext.h" namespace Metal { void PipelineService::createPipelineLayout( @@ -34,7 +37,7 @@ namespace Metal { layoutInfo.pPushConstantRanges = &pushConstantRange; } - VulkanUtils::CheckVKResult(vkCreatePipelineLayout(CTX.vulkanContext.device.device, &layoutInfo, nullptr, + VulkanUtils::CheckVKResult(vkCreatePipelineLayout(vulkanContext.device.device, &layoutInfo, nullptr, &pipeline->vkPipelineLayout)); } @@ -84,12 +87,12 @@ namespace Metal { pipelineInfo.layout = pipeline->vkPipelineLayout; pipelineInfo.stage = computeShaderStageInfo; - if (vkCreateComputePipelines(CTX.vulkanContext.device.device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, + if (vkCreateComputePipelines(vulkanContext.device.device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &pipeline->vkPipeline) != VK_SUCCESS) { throw std::runtime_error("failed to create compute pipeline!"); } - vkDestroyShaderModule(CTX.vulkanContext.device.device, computeShaderModule, nullptr); + vkDestroyShaderModule(vulkanContext.device.device, computeShaderModule, nullptr); return pipeline; } @@ -154,7 +157,7 @@ namespace Metal { multisampling.sampleShadingEnable = VK_FALSE; multisampling.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; - auto *frameBuffer = CTX.framebufferService.getResource(pipelineBuilder.frameBufferId); + auto *frameBuffer = framebufferService.getResource(pipelineBuilder.frameBufferId); if (!frameBuffer) { throw std::runtime_error("Framebuffer not found: " + pipelineBuilder.frameBufferId); } @@ -225,13 +228,13 @@ namespace Metal { pipelineInfo.subpass = 0; pipelineInfo.basePipelineHandle = VK_NULL_HANDLE; - VulkanUtils::CheckVKResult(vkCreateGraphicsPipelines(CTX.vulkanContext.device.device, VK_NULL_HANDLE, 1, + VulkanUtils::CheckVKResult(vkCreateGraphicsPipelines(vulkanContext.device.device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &pipeline->vkPipeline)); - vkDestroyShaderModule(CTX.vulkanContext.device.device, fragmentShaderModule, nullptr); - vkDestroyShaderModule(CTX.vulkanContext.device.device, vertexShaderModule, nullptr); + vkDestroyShaderModule(vulkanContext.device.device, fragmentShaderModule, nullptr); + vkDestroyShaderModule(vulkanContext.device.device, vertexShaderModule, nullptr); return pipeline; } @@ -308,12 +311,12 @@ namespace Metal { rtPipelineInfo.layout = pipeline->vkPipelineLayout; VulkanUtils::CheckVKResult( - CTX.vulkanContext.vkCreateRayTracingPipelinesKHR( - CTX.vulkanContext.device.device, VK_NULL_HANDLE, VK_NULL_HANDLE, + vulkanContext.vkCreateRayTracingPipelinesKHR( + vulkanContext.device.device, VK_NULL_HANDLE, VK_NULL_HANDLE, 1, &rtPipelineInfo, nullptr, &pipeline->vkPipeline)); // Build Shader Binding Table - const auto &rtProps = CTX.vulkanContext.rayTracingPipelineProperties; + const auto &rtProps = vulkanContext.rayTracingPipelineProperties; const uint32_t handleSize = rtProps.shaderGroupHandleSize; const uint32_t handleAlignment = rtProps.shaderGroupHandleAlignment; const uint32_t baseAlignment = rtProps.shaderGroupBaseAlignment; @@ -323,14 +326,14 @@ namespace Metal { const uint32_t sbtSize = groupCount * handleSizeAligned; std::vector shaderHandleStorage(sbtSize); VulkanUtils::CheckVKResult( - CTX.vulkanContext.vkGetRayTracingShaderGroupHandlesKHR( - CTX.vulkanContext.device.device, pipeline->vkPipeline, + vulkanContext.vkGetRayTracingShaderGroupHandlesKHR( + vulkanContext.device.device, pipeline->vkPipeline, 0, groupCount, sbtSize, shaderHandleStorage.data())); // Create SBT buffers - each needs baseAlignment auto createSBTBuffer = [&](uint32_t groupIndex, const std::string &sbtType) -> BufferInstance * { const uint32_t sbtBufferSize = (handleSizeAligned + baseAlignment - 1) & ~(baseAlignment - 1); - auto *buf = CTX.bufferService.createBuffer( + auto *buf = bufferService.createBuffer( pipeline->getId() + "_sbt_" + sbtType, sbtBufferSize, VK_BUFFER_USAGE_SHADER_BINDING_TABLE_BIT_KHR | VK_BUFFER_USAGE_TRANSFER_DST_BIT, @@ -345,8 +348,8 @@ namespace Metal { pipeline->hitSBT = createSBTBuffer(2, "hit"); auto getAddr = [&](const BufferInstance *buf) { - return getBufferDeviceAddress(CTX.vulkanContext.device.device, buf->vkBuffer, - CTX.vulkanContext.vkGetBufferDeviceAddressKHR); + return getBufferDeviceAddress(vulkanContext.device.device, buf->vkBuffer, + vulkanContext.vkGetBufferDeviceAddressKHR); }; pipeline->raygenRegion.deviceAddress = getAddr(pipeline->raygenSBT); @@ -363,9 +366,9 @@ namespace Metal { pipeline->callableRegion = {}; // unused - vkDestroyShaderModule(CTX.vulkanContext.device.device, rayGenModule, nullptr); - vkDestroyShaderModule(CTX.vulkanContext.device.device, missModule, nullptr); - vkDestroyShaderModule(CTX.vulkanContext.device.device, closestHitModule, nullptr); + vkDestroyShaderModule(vulkanContext.device.device, rayGenModule, nullptr); + vkDestroyShaderModule(vulkanContext.device.device, missModule, nullptr); + vkDestroyShaderModule(vulkanContext.device.device, closestHitModule, nullptr); return pipeline; } @@ -377,8 +380,8 @@ namespace Metal { descriptorSetService.dispose(resource->getId()); } - vkDestroyPipelineLayout(CTX.vulkanContext.device.device, resource->vkPipelineLayout, nullptr); - vkDestroyPipeline(CTX.vulkanContext.device.device, resource->vkPipeline, nullptr); + vkDestroyPipelineLayout(vulkanContext.device.device, resource->vkPipelineLayout, nullptr); + vkDestroyPipeline(vulkanContext.device.device, resource->vkPipeline, nullptr); } std::vector PipelineService::getAllDescriptors() const { diff --git a/src/engine/service/PipelineService.h b/src/engine/service/PipelineService.h index 6d97a544..e3095178 100644 --- a/src/engine/service/PipelineService.h +++ b/src/engine/service/PipelineService.h @@ -12,9 +12,20 @@ namespace Metal { struct PipelineInstance; struct DescriptorInstance; + class VulkanContext; + class FrameBufferService; + class BufferService; + class PipelineService final : public AbstractResourceService { + VulkanContext &vulkanContext; + FrameBufferService &framebufferService; + BufferService &bufferService; + DescriptorSetService &descriptorSetService; + public: - explicit PipelineService(DescriptorSetService &descriptorSetService) : descriptorSetService(descriptorSetService) {} + explicit PipelineService(VulkanContext &vulkanContext, FrameBufferService &framebufferService, BufferService &bufferService, DescriptorSetService &descriptorSetService) + : vulkanContext(vulkanContext), framebufferService(framebufferService), bufferService(bufferService), descriptorSetService(descriptorSetService) {} + PipelineService() = delete; PipelineInstance *createPipeline(PipelineBuilder &pipelineBuilder); @@ -23,8 +34,6 @@ namespace Metal { std::vector getAllDescriptors() const; private: - DescriptorSetService &descriptorSetService; - PipelineInstance *createComputePipeline(const PipelineBuilder &pipelineBuilder, PipelineInstance *pipeline); PipelineInstance *createRenderingPipeline(PipelineBuilder &pipelineBuilder, PipelineInstance *pipeline); diff --git a/src/engine/service/RayTracingService.cpp b/src/engine/service/RayTracingService.cpp index d46be68a..26c09a41 100644 --- a/src/engine/service/RayTracingService.cpp +++ b/src/engine/service/RayTracingService.cpp @@ -7,6 +7,13 @@ #include "../dto/VertexData.h" #include "../../core/vulkan/VulkanUtils.h" #include "../../editor/enum/EngineResourceIDs.h" +#include "../../core/vulkan/VulkanContext.h" +#include "PipelineService.h" +#include "../repository/WorldRepository.h" +#include "MeshService.h" +#include "MaterialService.h" +#include "BufferService.h" +#include "../EngineContext.h" #include namespace Metal { @@ -18,7 +25,7 @@ namespace Metal { } void RayTracingService::updateDescriptorSets(VkAccelerationStructureKHR asHandle) { - auto descriptors = CTX.pipelineService.getAllDescriptors(); + auto descriptors = pipelineService.getAllDescriptors(); for (auto *descriptor: descriptors) { bool needsUpdate = false; for (auto &binding: descriptor->bindings) { @@ -29,7 +36,7 @@ namespace Metal { } if (needsUpdate) { - DescriptorSetService::Write(descriptor->vkDescriptorSet, descriptor->bindings); + DescriptorSetService::Write(vulkanContext, bufferService, descriptor->vkDescriptorSet, descriptor->bindings); } } } @@ -45,12 +52,12 @@ namespace Metal { } anyMeshes = false; // Check if any mesh is present and streamed - auto view = CTX.worldRepository.registry.view(); + auto view = worldRepository.registry.view(); for (auto entity: view) { - if (CTX.worldRepository.hiddenEntities.contains(entity)) continue; + if (worldRepository.hiddenEntities.contains(entity)) continue; auto &meshComp = view.get(entity); if (meshComp.meshId.empty()) continue; - auto *instance = CTX.meshService.stream(meshComp.meshId); + auto *instance = meshService.stream(meshComp.meshId); if (instance != nullptr && instance->dataBuffer != nullptr && instance->indexBuffer != nullptr) { anyMeshes = true; break; @@ -89,21 +96,21 @@ namespace Metal { void RayTracingService::updateMeshMaterials() { bool changed = false; - auto view = CTX.worldRepository.registry.view(); + auto view = worldRepository.registry.view(); for (auto entity: view) { - if (CTX.worldRepository.hiddenEntities.contains(entity)) continue; + if (worldRepository.hiddenEntities.contains(entity)) continue; auto &meshComp = view.get(entity); if (meshComp.meshId.empty()) continue; if (meshComp.renderIndex < meshMetadata.size()) { - CTX.materialService.load(meshMetadata[meshComp.renderIndex], meshComp); + materialService.load(meshMetadata[meshComp.renderIndex], meshComp); changed = true; } } if (changed) { - for (auto *frame : CTX.engineContext.registeredFrames) { + for (auto *frame : engineContext.registeredFrames) { auto *meshMetadataBuffer = frame->getResourceAs(RID_MESH_METADATA_BUFFER); if (meshMetadataBuffer != nullptr) { meshMetadataBuffer->update(meshMetadata.data()); @@ -113,7 +120,7 @@ namespace Metal { } void RayTracingService::destroyTLAS() { - auto &vulkan = CTX.vulkanContext; + auto &vulkan = vulkanContext; if (vulkan.device.device != VK_NULL_HANDLE) { vkDeviceWaitIdle(vulkan.device.device); } @@ -124,15 +131,15 @@ namespace Metal { } if (tlasBuffer) { - CTX.bufferService.dispose("tlas_buffer"); + bufferService.dispose("tlas_buffer"); tlasBuffer = nullptr; } if (instancesBuffer) { - CTX.bufferService.dispose("tlas_instances"); + bufferService.dispose("tlas_instances"); instancesBuffer = nullptr; } if (tlasScratchBuffer) { - CTX.bufferService.dispose("tlas_scratch"); + bufferService.dispose("tlas_scratch"); tlasScratchBuffer = nullptr; } @@ -140,18 +147,18 @@ namespace Metal { } void RayTracingService::buildBLAS() { - auto &vulkan = CTX.vulkanContext; + auto &vulkan = vulkanContext; std::unordered_map uniqueMeshes; - auto view = CTX.worldRepository.registry.view(); + auto view = worldRepository.registry.view(); for (auto entity: view) { - if (CTX.worldRepository.hiddenEntities.contains(entity)) continue; + if (worldRepository.hiddenEntities.contains(entity)) continue; auto &meshComp = view.get(entity); if (meshComp.meshId.empty()) continue; if (uniqueMeshes.contains(meshComp.meshId)) continue; - auto *instance = CTX.meshService.stream(meshComp.meshId); + auto *instance = meshService.stream(meshComp.meshId); if (instance == nullptr || instance->dataBuffer == nullptr || instance->indexBuffer == nullptr) { continue; } @@ -173,9 +180,9 @@ namespace Metal { nullptr); } if (existing.buffer) - CTX.bufferService.dispose("blas_" + meshId); + bufferService.dispose("blas_" + meshId); if (existing.scratchBuffer) - CTX.bufferService.dispose("blas_scratch_" + meshId); + bufferService.dispose("blas_scratch_" + meshId); blasEntries.erase(meshId); } VkDeviceAddress vertexAddress = getDeviceAddress(vulkan, instance->dataBuffer->vkBuffer); @@ -214,14 +221,14 @@ namespace Metal { &sizeInfo); BLASEntry entry; - entry.buffer = CTX.bufferService.createBuffer( + entry.buffer = bufferService.createBuffer( "blas_" + meshId, sizeInfo.accelerationStructureSize, VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, true); - entry.scratchBuffer = CTX.bufferService.createBuffer( + entry.scratchBuffer = bufferService.createBuffer( "blas_scratch_" + meshId, sizeInfo.buildScratchSize, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, @@ -258,7 +265,7 @@ namespace Metal { } void RayTracingService::buildTLAS() { - auto &vulkan = CTX.vulkanContext; + auto &vulkan = vulkanContext; meshMetadata.clear(); if (blasEntries.empty()) return; @@ -267,7 +274,7 @@ namespace Metal { } std::vector instances; - auto view = CTX.worldRepository.registry.view(); + auto view = worldRepository.registry.view(); unsigned int currentInstanceIndex = 0; for (auto entity: view) { @@ -275,7 +282,7 @@ namespace Metal { LOG_ERROR("Max mesh instances reached for ray tracing: " + std::to_string(MAX_MESH_INSTANCES)); break; } - if (CTX.worldRepository.hiddenEntities.contains(entity)) continue; + if (worldRepository.hiddenEntities.contains(entity)) continue; auto &meshComp = view.get(entity); if (meshComp.meshId.empty()) continue; @@ -290,8 +297,8 @@ namespace Metal { vulkan.device.device, &addressInfo); glm::mat4 model = glm::mat4(1.0f); - if (CTX.worldRepository.registry.all_of(entity)) { - model = CTX.worldRepository.registry.get(entity).model; + if (worldRepository.registry.all_of(entity)) { + model = worldRepository.registry.get(entity).model; } VkTransformMatrixKHR transform{}; @@ -324,7 +331,7 @@ namespace Metal { updateMeshMaterials(); - instancesBuffer = CTX.bufferService.createBuffer( + instancesBuffer = bufferService.createBuffer( "tlas_instances", sizeof(VkAccelerationStructureInstanceKHR) * instances.size(), VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR, @@ -360,7 +367,7 @@ namespace Metal { &instanceCount, &sizeInfo); - tlasBuffer = CTX.bufferService.createBuffer( + tlasBuffer = bufferService.createBuffer( "tlas_buffer", sizeInfo.accelerationStructureSize, VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR, @@ -375,7 +382,7 @@ namespace Metal { VulkanUtils::CheckVKResult( vulkan.vkCreateAccelerationStructureKHR(vulkan.device.device, &createInfo, nullptr, &tlas)); - tlasScratchBuffer = CTX.bufferService.createBuffer( + tlasScratchBuffer = bufferService.createBuffer( "tlas_scratch", sizeInfo.buildScratchSize, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, @@ -396,7 +403,7 @@ namespace Metal { void RayTracingService::destroyAccelerationStructures() { LOG_INFO("Destroying acceleration structures"); - auto &vulkan = CTX.vulkanContext; + auto &vulkan = vulkanContext; if (vulkan.device.device != VK_NULL_HANDLE) { vkDeviceWaitIdle(vulkan.device.device); @@ -412,9 +419,9 @@ namespace Metal { entry.accelerationStructure = VK_NULL_HANDLE; } if (entry.buffer) - CTX.bufferService.dispose("blas_" + meshId); + bufferService.dispose("blas_" + meshId); if (entry.scratchBuffer) - CTX.bufferService.dispose("blas_scratch_" + meshId); + bufferService.dispose("blas_scratch_" + meshId); } blasEntries.clear(); diff --git a/src/engine/service/RayTracingService.h b/src/engine/service/RayTracingService.h index e4b35fa7..7d90afd3 100644 --- a/src/engine/service/RayTracingService.h +++ b/src/engine/service/RayTracingService.h @@ -11,9 +11,24 @@ #include "../../common/AbstractRuntimeComponent.h" namespace Metal { - struct BufferInstance; + class BufferInstance; + class VulkanContext; + class PipelineService; + struct WorldRepository; + class MeshService; + class MaterialService; + class BufferService; + class EngineContext; class RayTracingService final : public AbstractRuntimeComponent { + VulkanContext &vulkanContext; + PipelineService &pipelineService; + WorldRepository &worldRepository; + MeshService &meshService; + MaterialService &materialService; + BufferService &bufferService; + EngineContext &engineContext; + struct BLASEntry { VkAccelerationStructureKHR accelerationStructure = VK_NULL_HANDLE; BufferInstance *buffer = nullptr; @@ -51,6 +66,9 @@ namespace Metal { void updateMeshMaterials(); public: + RayTracingService(VulkanContext &vulkanContext, PipelineService &pipelineService, WorldRepository &worldRepository, MeshService &meshService, MaterialService &materialService, BufferService &bufferService, EngineContext &engineContext) + : vulkanContext(vulkanContext), pipelineService(pipelineService), worldRepository(worldRepository), meshService(meshService), materialService(materialService), bufferService(bufferService), engineContext(engineContext) {} + RayTracingService() = delete; void setNeedsMaterialUpdate(bool val) { needsMaterialUpdate = val; diff --git a/src/engine/service/StreamingService.cpp b/src/engine/service/StreamingService.cpp index 48895cb4..e5a04f37 100644 --- a/src/engine/service/StreamingService.cpp +++ b/src/engine/service/StreamingService.cpp @@ -1,6 +1,12 @@ #include "StreamingService.h" +#include "../EngineContext.h" +#include "../repository/WorldRepository.h" +#include "MeshService.h" +#include "TextureService.h" +#include "VoxelService.h" #include "../../ApplicationContext.h" + #include "../resource/SVOInstance.h" #include "../resource/MeshInstance.h" #include "../resource/TextureInstance.h" @@ -11,13 +17,13 @@ namespace Metal { static constexpr int MAX_TIMEOUT = 10000; template - void disposeResources(AbstractResourceService &service, std::unordered_map &lastUse) { + void disposeResources(AbstractResourceService &service, std::unordered_map &lastUse, EngineContext &engineContext) { auto &resources = service.getResources(); for (auto it = resources.begin(); it != resources.end();) { if (lastUse.contains(it->second->getId()) && !it->second->isNoDisposal() && ( - CTX.engineContext.currentTimeMs - lastUse.at(it->second->getId())) >= MAX_TIMEOUT) { + engineContext.currentTimeMs - lastUse.at(it->second->getId())) >= MAX_TIMEOUT) { LOG_DEBUG( - "Disposing of " + it->first + " Since last use: " + std::to_string(CTX.engineContext.currentTimeMs - + "Disposing of " + it->first + " Since last use: " + std::to_string(engineContext.currentTimeMs - lastUse.at(it->second->getId()))); std::string id = it->first; ++it; @@ -29,28 +35,28 @@ namespace Metal { } void StreamingService::onSync() { - auto view = CTX.worldRepository.registry.view(); + auto view = worldRepository.registry.view(); for (auto entity: view) { auto &meshComp = view.get(entity); if (!meshComp.meshId.empty()) { - lastUse[meshComp.meshId] = CTX.engineContext.currentTimeMs; + lastUse[meshComp.meshId] = engineContext.currentTimeMs; } if (!meshComp.albedo.empty()) { - lastUse[meshComp.albedo] = CTX.engineContext.currentTimeMs; + lastUse[meshComp.albedo] = engineContext.currentTimeMs; } if (!meshComp.roughness.empty()) { - lastUse[meshComp.roughness] = CTX.engineContext.currentTimeMs; + lastUse[meshComp.roughness] = engineContext.currentTimeMs; } if (!meshComp.metallic.empty()) { - lastUse[meshComp.metallic] = CTX.engineContext.currentTimeMs; + lastUse[meshComp.metallic] = engineContext.currentTimeMs; } } - if ((CTX.engineContext.currentTime - sinceLastCleanup).count() >= MAX_TIMEOUT) { - sinceLastCleanup = CTX.engineContext.currentTime; - disposeResources(CTX.meshService, lastUse); - disposeResources(CTX.textureService, lastUse); - disposeResources(CTX.voxelService, lastUse); + if ((engineContext.currentTime - sinceLastCleanup).count() >= MAX_TIMEOUT) { + sinceLastCleanup = engineContext.currentTime; + disposeResources(meshService, lastUse, engineContext); + disposeResources(textureService, lastUse, engineContext); + disposeResources(voxelService, lastUse, engineContext); } } } diff --git a/src/engine/service/StreamingService.h b/src/engine/service/StreamingService.h index ccd7e5af..d93c7568 100644 --- a/src/engine/service/StreamingService.h +++ b/src/engine/service/StreamingService.h @@ -14,12 +14,26 @@ namespace Metal { struct MeshInstance; struct TextureInstance; struct SVOInstance; + class EngineContext; + struct WorldRepository; + class MeshService; + class TextureService; + class VoxelService; class StreamingService final : public AbstractRuntimeComponent { std::unordered_map lastUse{}; TimePoint sinceLastCleanup; + EngineContext &engineContext; + WorldRepository &worldRepository; + MeshService &meshService; + TextureService &textureService; + VoxelService &voxelService; + public: + StreamingService(EngineContext &engineContext, WorldRepository &worldRepository, MeshService &meshService, TextureService &textureService, VoxelService &voxelService) + : engineContext(engineContext), worldRepository(worldRepository), meshService(meshService), textureService(textureService), voxelService(voxelService) {} + void onSync() override; }; } // Metal diff --git a/src/engine/service/TextureService.cpp b/src/engine/service/TextureService.cpp index 8f20419f..1e045dec 100644 --- a/src/engine/service/TextureService.cpp +++ b/src/engine/service/TextureService.cpp @@ -1,21 +1,29 @@ #include "TextureService.h" #include +#include #include "../util/ImageUtils.h" +#include "../../editor/enum/engine-definitions.h" +#include "../../ApplicationContext.h" #include #include #include "../dto/TextureData.h" -#include "../../ApplicationContext.h" +#include "../../core/vulkan/VulkanContext.h" +#include "../../core/vulkan/VulkanUtils.h" #include "../resource/TextureInstance.h" #include "../resource/BufferInstance.h" +#include "BufferService.h" +#include "PipelineService.h" +#include "DescriptorSetService.h" +#include "../dto/DescriptorInstance.h" namespace Metal { void TextureService::copyBufferToImage(const VkBuffer &vkBuffer, const TextureInstance *image, const int layerCount) const { - VkCommandBuffer commandBuffer = CTX.vulkanContext.beginSingleTimeCommands(); + VkCommandBuffer commandBuffer = vulkanContext.beginSingleTimeCommands(); VkBufferImageCopy region{}; region.bufferOffset = 0; @@ -37,31 +45,31 @@ namespace Metal { VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion); - CTX.vulkanContext.endSingleTimeCommands(commandBuffer); + vulkanContext.endSingleTimeCommands(commandBuffer); } void TextureService::createImageWithInfo(const VkImageCreateInfo &imageInfo, VkMemoryPropertyFlagBits vkMemoryProperties, TextureInstance *image) const { - if (vkCreateImage(CTX.vulkanContext.device.device, &imageInfo, nullptr, &image->vkImage) != VK_SUCCESS) { + if (vkCreateImage(vulkanContext.device.device, &imageInfo, nullptr, &image->vkImage) != VK_SUCCESS) { throw std::runtime_error("failed to create image!"); } VkMemoryRequirements memRequirements; - vkGetImageMemoryRequirements(CTX.vulkanContext.device.device, image->vkImage, &memRequirements); + vkGetImageMemoryRequirements(vulkanContext.device.device, image->vkImage, &memRequirements); VkMemoryAllocateInfo allocInfo{}; allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; allocInfo.allocationSize = memRequirements.size; - allocInfo.memoryTypeIndex = CTX.bufferService.findMemoryType( + allocInfo.memoryTypeIndex = bufferService.findMemoryType( memRequirements.memoryTypeBits, vkMemoryProperties); - if (vkAllocateMemory(CTX.vulkanContext.device.device, &allocInfo, nullptr, &image->vkImageMemory) != + if (vkAllocateMemory(vulkanContext.device.device, &allocInfo, nullptr, &image->vkImageMemory) != VK_SUCCESS) { throw std::runtime_error("failed to allocate image memory!"); } - if (vkBindImageMemory(CTX.vulkanContext.device.device, image->vkImage, image->vkImageMemory, 0) != + if (vkBindImageMemory(vulkanContext.device.device, image->vkImage, image->vkImageMemory, 0) != VK_SUCCESS) { throw std::runtime_error("failed to bind image memory!"); } @@ -84,7 +92,7 @@ namespace Metal { samplerInfo.anisotropyEnable = VK_TRUE; samplerInfo.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; - vkCreateSampler(CTX.vulkanContext.device.device, &samplerInfo, nullptr, &image->vkSampler); + vkCreateSampler(vulkanContext.device.device, &samplerInfo, nullptr, &image->vkSampler); } void TextureService::createImageView(VkFormat imageFormat, TextureInstance *image) const { @@ -102,7 +110,7 @@ namespace Metal { imageViewInfo.subresourceRange.levelCount = image->mipLevels; imageViewInfo.image = image->vkImage; - vkCreateImageView(CTX.vulkanContext.device.device, &imageViewInfo, nullptr, &image->vkImageView); + vkCreateImageView(vulkanContext.device.device, &imageViewInfo, nullptr, &image->vkImageView); } void TextureService::createImage(VkFormat imageFormat, TextureInstance *image, const int width, @@ -125,7 +133,7 @@ namespace Metal { } TextureData *TextureService::loadTextureData(const std::string &id) const { - auto pathToFile = CTX.getAssetDirectory() + FORMAT_FILE_TEXTURE(id); + auto pathToFile = rootDirectory + "/assets/" + FORMAT_FILE_TEXTURE(id); if (std::filesystem::exists(pathToFile)) { int width, height, channels; unsigned char *data = stbi_load(pathToFile.c_str(), &width, &height, &channels, 0); @@ -163,7 +171,7 @@ namespace Metal { image->vkFormat = imageFormat; LOG_INFO("Loading texture " + id + " from " + pathToImage); LOG_INFO("Texture data: Width " + std::to_string(image->width) + " Height " + std::to_string(image->height)); - BufferInstance *stagingBuffer = CTX.bufferService.createBuffer( + BufferInstance *stagingBuffer = bufferService.createBuffer( id + "_staging", image->width * image->height * 4, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); @@ -184,7 +192,7 @@ namespace Metal { void TextureService::transitionImageLayout(const TextureInstance *image, VkImageLayout oldLayout, VkImageLayout newLayout) const { - VkCommandBuffer commandBuffer = CTX.vulkanContext.beginSingleTimeCommands(); + VkCommandBuffer commandBuffer = vulkanContext.beginSingleTimeCommands(); VkImageMemoryBarrier barrier{}; barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; barrier.oldLayout = oldLayout; @@ -235,19 +243,19 @@ namespace Metal { 0, nullptr, 1, &barrier); - CTX.vulkanContext.endSingleTimeCommands(commandBuffer); + vulkanContext.endSingleTimeCommands(commandBuffer); } void TextureService::generateMipmaps(const TextureInstance *image) const { VkFormatProperties formatProperties; - vkGetPhysicalDeviceFormatProperties(CTX.vulkanContext.physDevice.physical_device, image->vkFormat, + vkGetPhysicalDeviceFormatProperties(vulkanContext.physDevice.physical_device, image->vkFormat, &formatProperties); if (!(formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT)) { throw std::runtime_error("texture image format does not support linear blitting!"); } - VkCommandBuffer commandBuffer = CTX.vulkanContext.beginSingleTimeCommands(); + VkCommandBuffer commandBuffer = vulkanContext.beginSingleTimeCommands(); VkImageMemoryBarrier barrier{}; barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; @@ -310,11 +318,11 @@ namespace Metal { vkCmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier); - CTX.vulkanContext.endSingleTimeCommands(commandBuffer); + vulkanContext.endSingleTimeCommands(commandBuffer); } TextureInstance *TextureService::create(const std::string &id) { - auto pathToFile = CTX.getAssetDirectory() + FORMAT_FILE_TEXTURE(id); + auto pathToFile = rootDirectory + "/assets/" + FORMAT_FILE_TEXTURE(id); if (std::filesystem::exists(pathToFile)) { auto *instance = loadTexture(id, pathToFile, true, VK_FORMAT_R8G8B8A8_UNORM); if (instance != nullptr) { @@ -363,7 +371,7 @@ namespace Metal { textureIndices[id] = index; // Update all descriptors that contain a texture array - auto descriptors = CTX.pipelineService.getAllDescriptors(); + auto descriptors = pipelineService.getAllDescriptors(); for (auto *descriptor: descriptors) { for (auto &binding: descriptor->bindings) { if (binding.descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER && binding.descriptorCount > 1) { @@ -376,12 +384,12 @@ namespace Metal { write.descriptorCount = 1; VkDescriptorImageInfo imageInfo{}; - imageInfo.sampler = CTX.vulkanContext.vkTextureSampler; + imageInfo.sampler = vulkanContext.vkTextureSampler; imageInfo.imageView = texture->vkImageView; imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; write.pImageInfo = &imageInfo; - vkUpdateDescriptorSets(CTX.vulkanContext.device.device, 1, &write, 0, nullptr); + vkUpdateDescriptorSets(vulkanContext.device.device, 1, &write, 0, nullptr); } } } @@ -392,13 +400,13 @@ namespace Metal { } void TextureService::disposeResource(TextureInstance *resource) { - vkDestroyImage(CTX.vulkanContext.device.device, resource->vkImage, nullptr); - vkFreeMemory(CTX.vulkanContext.device.device, resource->vkImageMemory, nullptr); - vkDestroyImageView(CTX.vulkanContext.device.device, resource->vkImageView, nullptr); - vkDestroySampler(CTX.vulkanContext.device.device, resource->vkSampler, nullptr); + vkDestroyImage(vulkanContext.device.device, resource->vkImage, nullptr); + vkFreeMemory(vulkanContext.device.device, resource->vkImageMemory, nullptr); + vkDestroyImageView(vulkanContext.device.device, resource->vkImageView, nullptr); + vkDestroySampler(vulkanContext.device.device, resource->vkSampler, nullptr); if (resource->imageDescriptor != nullptr) { - CTX.descriptorSetService.disposeResource(resource->imageDescriptor); + descriptorSetService.disposeResource(resource->imageDescriptor); } } @@ -418,7 +426,7 @@ namespace Metal { samplerCreateInfo.maxAnisotropy = 8; samplerCreateInfo.anisotropyEnable = VK_TRUE; samplerCreateInfo.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK; - VulkanUtils::CheckVKResult(vkCreateSampler(CTX.vulkanContext.device.device, &samplerCreateInfo, nullptr, + VulkanUtils::CheckVKResult(vkCreateSampler(vulkanContext.device.device, &samplerCreateInfo, nullptr, &vkImageSampler)); } diff --git a/src/engine/service/TextureService.h b/src/engine/service/TextureService.h index e1eff442..891f847d 100644 --- a/src/engine/service/TextureService.h +++ b/src/engine/service/TextureService.h @@ -10,8 +10,17 @@ namespace Metal { struct TextureInstance; + class BufferService; + class PipelineService; + class DescriptorSetService; class TextureService final : public AbstractResourceService { + VulkanContext &vulkanContext; + BufferService &bufferService; + PipelineService &pipelineService; + DescriptorSetService &descriptorSetService; + const std::string &rootDirectory; + unsigned int nextTextureIndex = 1; std::unordered_map textureIndices{}; @@ -32,6 +41,10 @@ namespace Metal { void generateMipmaps(const TextureInstance *image) const; public: + TextureService(VulkanContext &vulkanContext, BufferService &bufferService, PipelineService &pipelineService, DescriptorSetService &descriptorSetService, const std::string &rootDirectory) + : vulkanContext(vulkanContext), bufferService(bufferService), pipelineService(pipelineService), descriptorSetService(descriptorSetService), rootDirectory(rootDirectory) {} + TextureService() = delete; + [[nodiscard]] TextureData *loadTextureData(const std::string &id) const; TextureInstance *stream(const std::string &id); diff --git a/src/engine/service/TransformService.cpp b/src/engine/service/TransformService.cpp index 5dfdc638..4e201f84 100644 --- a/src/engine/service/TransformService.cpp +++ b/src/engine/service/TransformService.cpp @@ -5,11 +5,13 @@ #include "../../ApplicationContext.h" #include "../dto/TransformComponent.h" +#include "../repository/WorldRepository.h" +#include "RayTracingService.h" namespace Metal { void TransformService::onSync() { - for (auto entity : CTX.worldRepository.registry.view()) { - TransformComponent &st = CTX.worldRepository.registry.get(entity); + for (auto entity : worldRepository.registry.view()) { + TransformComponent &st = worldRepository.registry.get(entity); if (st.isNotFrozen()) { transform(&st, nullptr); st.freezeVersion(); @@ -36,8 +38,8 @@ namespace Metal { st->model = auxMat4 * auxMat42; st->freezeVersion(); - if (CTX.worldRepository.registry.all_of(st->getEntityId())) { - CTX.rayTracingService.markDirty(); + if (worldRepository.registry.all_of(st->getEntityId())) { + rayTracingService.markDirty(); } } } // Metal diff --git a/src/engine/service/TransformService.h b/src/engine/service/TransformService.h index ff399b3e..3149e81c 100644 --- a/src/engine/service/TransformService.h +++ b/src/engine/service/TransformService.h @@ -10,13 +10,23 @@ namespace Metal { struct TransformComponent; + struct TransformComponent; + struct WorldRepository; + class RayTracingService; + class TransformService final : AbstractRuntimeComponent { + WorldRepository &worldRepository; + RayTracingService &rayTracingService; + glm::vec3 distanceAux{}; glm::mat4x4 auxMat4{}; glm::vec3 translation{}; glm::mat4x4 auxMat42{}; public: + explicit TransformService(WorldRepository &worldRepository, RayTracingService &rayTracingService) + : worldRepository(worldRepository), rayTracingService(rayTracingService) {} + TransformService() = delete; void onSync() override; diff --git a/src/engine/service/VolumeService.cpp b/src/engine/service/VolumeService.cpp index 2f5cde9f..d04c4454 100644 --- a/src/engine/service/VolumeService.cpp +++ b/src/engine/service/VolumeService.cpp @@ -3,12 +3,14 @@ #include "../dto/VolumeComponent.h" #include "../resource/BufferInstance.h" #include "../../editor/enum/EngineResourceIDs.h" +#include "../repository/WorldRepository.h" +#include "../EngineContext.h" namespace Metal { void VolumeService::registerVolumes() { - auto view = CTX.worldRepository.registry.view(); + auto view = worldRepository.registry.view(); for (auto [entityId, l, t]: view.each()) { - if (CTX.worldRepository.hiddenEntities.contains(entityId)) { + if (worldRepository.hiddenEntities.contains(entityId)) { continue; } @@ -30,7 +32,7 @@ namespace Metal { registerVolumes(); if (!items.empty()) { - CTX.engineContext.currentFrame->getResourceAs(RID_VOLUMES_BUFFER)->update(items.data()); + engineContext.currentFrame->getResourceAs(RID_VOLUMES_BUFFER)->update(items.data()); } } } // Metal diff --git a/src/engine/service/VolumeService.h b/src/engine/service/VolumeService.h index 2feafe3e..60d32fed 100644 --- a/src/engine/service/VolumeService.h +++ b/src/engine/service/VolumeService.h @@ -7,11 +7,20 @@ namespace Metal { + struct WorldRepository; + class EngineContext; + class VolumeService final : public AbstractRuntimeComponent { + WorldRepository &worldRepository; + EngineContext &engineContext; + std::vector items{}; void registerVolumes(); public: + explicit VolumeService(WorldRepository &worldRepository, EngineContext &engineContext) + : worldRepository(worldRepository), engineContext(engineContext) {} + VolumeService() = delete; void onSync() override; From c919b2a2ac500be22d3f6df8074ddec4d5aa8bc9 Mon Sep 17 00:00:00 2001 From: facobackup Date: Sat, 14 Mar 2026 10:06:11 -0300 Subject: [PATCH 04/11] Refactoring frame builder Continuing refactoring of ApplicationContext --- CMakeLists.txt | 7 +- src/ApplicationContext.cpp | 12 --- src/ApplicationContext.h | 96 ++++++++++--------- src/core/glfw/GLFWContext.cpp | 23 ++--- src/core/glfw/GLFWContext.h | 7 ++ src/core/gui/GuiContext.cpp | 40 +++++--- src/core/gui/GuiContext.h | 11 ++- src/core/vulkan/VulkanContext.cpp | 57 +++++++---- src/core/vulkan/VulkanContext.h | 27 +++++- .../dock-spaces/docks/DockSpacePanel.cpp | 6 +- .../dock-spaces/files/FilesHeaderPanel.cpp | 16 +++- .../dock-spaces/files/FilesHeaderPanel.h | 1 - .../dock-spaces/viewport/EngineFramePanel.cpp | 39 +++++--- src/editor/dto/DockSpace.cpp | 29 +++--- src/editor/dto/DockSpace.h | 4 +- src/editor/enum/EntryType.h | 61 +++++------- src/editor/passes/GridPass.h | 2 - src/editor/passes/IconsPass.cpp | 27 ------ src/editor/passes/IconsPass.h | 18 ---- src/editor/passes/SelectionIDPass.h | 1 - src/editor/passes/SelectionOutlinePass.h | 2 - src/editor/repository/EditorRepository.cpp | 6 +- src/editor/service/DockService.cpp | 1 - src/editor/service/DockService.h | 5 + src/editor/service/ThemeService.cpp | 1 - src/editor/service/ThemeService.h | 5 +- src/engine/dto/PrimitiveComponent.cpp | 23 ++--- src/engine/enum/PassType.h | 18 ---- src/engine/enum/ResourceType.h | 3 +- src/engine/frame-builder/EngineFrame.cpp | 13 +-- src/engine/frame-builder/EngineFrame.h | 14 +-- .../frame-builder/EngineFrameBuilder.cpp | 31 +++--- src/engine/frame-builder/EngineFrameBuilder.h | 9 +- .../structures/BufferBuilder.cpp | 2 +- .../frame-builder/structures/PassBuilder.cpp | 34 ------- .../frame-builder/structures/PassBuilder.h | 35 ------- src/engine/passes/AbstractComputePass.cpp | 2 +- src/engine/passes/AbstractComputePass.h | 2 +- src/engine/passes/AbstractPass.cpp | 9 +- src/engine/passes/AbstractPass.h | 12 +-- src/engine/passes/AbstractRenderPass.cpp | 2 +- src/engine/passes/AbstractRenderPass.h | 2 +- src/engine/passes/CommandBufferRecorder.cpp | 4 +- src/engine/passes/CommandBufferRecorder.h | 4 +- src/engine/passes/impl/HWRayTracingPass.h | 3 - src/engine/passes/impl/PostProcessingPass.h | 2 - src/engine/passes/impl/SpatialFilterPass.h | 3 - .../passes/impl/TemporalAccumulationPass.h | 2 - src/engine/service/PipelineService.cpp | 14 +-- src/engine/service/PipelineService.h | 11 ++- .../ShaderService.cpp} | 30 +++--- src/engine/service/ShaderService.h | 34 +++++++ src/engine/service/StreamingService.h | 3 +- src/engine/util/ShaderUtil.h | 27 ------ 54 files changed, 375 insertions(+), 477 deletions(-) delete mode 100644 src/editor/passes/IconsPass.cpp delete mode 100644 src/editor/passes/IconsPass.h delete mode 100644 src/engine/enum/PassType.h delete mode 100644 src/engine/frame-builder/structures/PassBuilder.cpp delete mode 100644 src/engine/frame-builder/structures/PassBuilder.h rename src/engine/{util/ShaderUtil.cpp => service/ShaderService.cpp} (88%) create mode 100644 src/engine/service/ShaderService.h delete mode 100644 src/engine/util/ShaderUtil.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fa89d53..50fc7887 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,8 +89,8 @@ add_executable( src/editor/dock-spaces/world/WorldPanel.cpp src/editor/dock-spaces/world/WorldPanel.h src/engine/resource/RuntimeResource.h - src/engine/util/ShaderUtil.cpp - src/engine/util/ShaderUtil.h + src/engine/service/ShaderService.cpp + src/engine/service/ShaderService.h src/engine/dto/ShaderModule.cpp src/engine/dto/ShaderModule.h src/engine/passes/AbstractRenderPass.cpp @@ -225,8 +225,6 @@ add_executable( src/engine/resource/SVOInstance.h src/engine/dto/TileInfoUBO.h src/engine/dto/LightData.h - src/editor/passes/IconsPass.cpp - src/editor/passes/IconsPass.h src/editor/passes/SelectionIDPass.cpp src/editor/passes/SelectionIDPass.h src/editor/repository/EditorRepository.cpp @@ -270,7 +268,6 @@ add_executable( src/engine/frame-builder/structures/ResourceBuilder.h src/engine/dto/PipelineBuilder.cpp src/engine/service/DescriptorSetService.cpp - src/engine/frame-builder/structures/PassBuilder.cpp src/engine/frame-builder/structures/CommandBufferRecorderBuilder.cpp src/common/Changeable.h src/engine/passes/impl/TemporalAccumulationPass.cpp diff --git a/src/ApplicationContext.cpp b/src/ApplicationContext.cpp index 9aff2362..8c794998 100644 --- a/src/ApplicationContext.cpp +++ b/src/ApplicationContext.cpp @@ -11,18 +11,6 @@ #include namespace Metal { - std::unique_ptr ApplicationContext::CONTEXT = nullptr; - - ApplicationContext &ApplicationContext::Get() { - if (CONTEXT == nullptr) { - throw std::runtime_error("Context not initialized"); - } - return *CONTEXT; - } - - void ApplicationContext::Init(bool debugMode) { - CONTEXT = std::make_unique(debugMode); - } void ApplicationContext::updateRootPath(bool forceSelection) { std::string cachedPath; diff --git a/src/ApplicationContext.h b/src/ApplicationContext.h index 3e0f075e..78774aa7 100644 --- a/src/ApplicationContext.h +++ b/src/ApplicationContext.h @@ -44,70 +44,80 @@ #include "editor/EditorPanel.h" #include "core/gui/GuiContext.h" -#define CTX Metal::ApplicationContext::Get() - +#define CTX ApplicationContext::CONTEXT namespace Metal { - class ApplicationContext { - static std::unique_ptr CONTEXT; - bool debugMode; + class ApplicationContext : public Initializable{ EditorPanel editorPanel; std::string rootDirectory; public: - explicit ApplicationContext(bool debug_mode) - : debugMode(debug_mode) { - } - - EngineContext engineContext{}; - VulkanContext vulkanContext{ debugMode}; - GuiContext guiContext{}; + static ApplicationContext CONTEXT; + + VulkanContext vulkanContext{ + true, + glfwContext, + engineRepository, + meshService, + textureService, + framebufferService, + pipelineService, + rayTracingService + }; + GuiContext guiContext{vulkanContext, glfwContext, descriptorSetService}; GLFWContext glfwContext{}; + EngineContext engineContext{ + transformService, + streamingService, + rayTracingService, + cameraService, + lightService, + volumeService, + worldRepository, + editorRepository, + engineRepository + }; + + // ----------- Repository + WorldRepository worldRepository{rayTracingService, rootDirectory}; + RuntimeRepository runtimeRepository{}; + EngineRepository engineRepository{}; + DockRepository dockRepository{}; + EditorRepository editorRepository{}; + // ----------- Services NotificationService notificationService; AsyncTaskService asyncTaskService; - MeshService meshService{bufferService, rayTracingService, rootDirectory}; - MaterialService materialService{textureService}; - TextureService textureService{vulkanContext, bufferService, pipelineService, descriptorSetService, rootDirectory}; + BufferService bufferService{vulkanContext}; FrameBufferService framebufferService{vulkanContext}; + ThemeService themeService{editorRepository}; + DockService dockService{dockRepository}; DescriptorSetService descriptorSetService{vulkanContext, framebufferService, bufferService, textureService}; - PipelineService pipelineService{vulkanContext, framebufferService, bufferService, descriptorSetService}; - BufferService bufferService{vulkanContext}; - ThemeService themeService{}; - DockService dockService{}; - SelectionService selectionService{}; - SceneImporterService sceneImporterService{}; - MeshImporterService meshImporterService{}; - MaterialImporterService materialImporterService{}; - TextureImporterService textureImporter{}; - FilesService filesService{}; - FileImporterService fileImporterService{}; + SelectionService selectionService{editorRepository, worldRepository}; + VoxelImporterService voxelImporterService{rootDirectory}; + MeshImporterService meshImporterService{rootDirectory}; + TextureImporterService textureImporter{rootDirectory}; + MaterialImporterService materialImporterService{textureImporter, rootDirectory}; + SceneImporterService sceneImporterService{meshImporterService, materialImporterService, rootDirectory}; + FilesService filesService{rootDirectory, notificationService}; + FileImporterService fileImporterService{ + sceneImporterService, textureImporter, voxelImporterService, notificationService, asyncTaskService + }; CameraService cameraService{engineContext, worldRepository, runtimeRepository}; - PickingService pickingService{}; + PickingService pickingService{vulkanContext, bufferService, worldRepository}; TransformService transformService{worldRepository, rayTracingService}; LightService lightService{engineContext, engineRepository}; VolumeService volumeService{worldRepository, engineContext}; - RayTracingService rayTracingService{vulkanContext, pipelineService, worldRepository, meshService, materialService, bufferService, engineContext}; + RayTracingService rayTracingService{ + vulkanContext, pipelineService, worldRepository, meshService, materialService, bufferService, engineContext + }; CommandBufferRecorderService commandBufferRecorderService{}; - VoxelImporterService voxelImporterService{rootDirectory}; VoxelService voxelService{}; - // ----------- Services - - // ----------- Repository - WorldRepository worldRepository{}; - RuntimeRepository runtimeRepository{}; StreamingService streamingService{engineContext, worldRepository, meshService, textureService, voxelService}; - EngineRepository engineRepository{}; - DockRepository dockRepository{}; - EditorRepository editorRepository{}; + // ----------- Services // ----------- Repository - - static ApplicationContext &Get(); - - static void Init(bool debugMode); - - [[nodiscard]] bool isDebugMode() const { return debugMode; } + [[nodiscard]] bool isDebugMode() const { return true; } void updateRootPath(bool forceSelection); diff --git a/src/core/glfw/GLFWContext.cpp b/src/core/glfw/GLFWContext.cpp index 9ebba466..4c489631 100644 --- a/src/core/glfw/GLFWContext.cpp +++ b/src/core/glfw/GLFWContext.cpp @@ -2,6 +2,7 @@ #include "GLFWContext.h" #include "../../ApplicationContext.h" #include "../vulkan/VulkanUtils.h" +#include "../vulkan/VulkanContext.h" namespace Metal { GLFWwindow *GLFWContext::getWindow() const { @@ -19,19 +20,19 @@ namespace Metal { int fb_width, fb_height; glfwGetFramebufferSize(window, &fb_width, &fb_height); if (fb_width > 0 && fb_height > 0 && - (swapChainRebuild || CTX.vulkanContext.imguiVulkanWindow.Width != + (swapChainRebuild || vulkanContext->imguiVulkanWindow.Width != fb_width || - CTX.vulkanContext.imguiVulkanWindow.Height != fb_height)) { + vulkanContext->imguiVulkanWindow.Height != fb_height)) { ImGui_ImplVulkan_SetMinImageCount(MAX_FRAMES_IN_FLIGHT); - ImGui_ImplVulkanH_CreateOrResizeWindow(CTX.vulkanContext.instance.instance, - CTX.vulkanContext.physDevice.physical_device, - CTX.vulkanContext.device.device, - &CTX.vulkanContext.imguiVulkanWindow, - CTX.vulkanContext.queueFamily, + ImGui_ImplVulkanH_CreateOrResizeWindow(vulkanContext->instance.instance, + vulkanContext->physDevice.physical_device, + vulkanContext->device.device, + &vulkanContext->imguiVulkanWindow, + vulkanContext->queueFamily, nullptr, fb_width, fb_height, MAX_FRAMES_IN_FLIGHT); - CTX.vulkanContext.imguiVulkanWindow.FrameIndex = 0; + vulkanContext->imguiVulkanWindow.FrameIndex = 0; swapChainRebuild = false; } if (glfwGetWindowAttrib(window, GLFW_ICONIFIED) != 0) { @@ -47,7 +48,7 @@ namespace Metal { } ImGui_ImplVulkanH_Window &GLFWContext::getGUIWindow() const { - return CTX.vulkanContext.imguiVulkanWindow; + return vulkanContext->imguiVulkanWindow; } void GLFWContext::setSwapChainRebuild(const bool val) { @@ -58,7 +59,7 @@ namespace Metal { if (swapChainRebuild) { return; } - auto &wd = CTX.vulkanContext.imguiVulkanWindow; + auto &wd = vulkanContext->imguiVulkanWindow; VkSemaphore semaphore = wd.FrameSemaphores[wd.SemaphoreIndex].RenderCompleteSemaphore; VkPresentInfoKHR info = {}; info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; @@ -67,7 +68,7 @@ namespace Metal { info.swapchainCount = 1; info.pSwapchains = &wd.Swapchain; info.pImageIndices = &wd.FrameIndex; - VkResult err = vkQueuePresentKHR(CTX.vulkanContext.graphicsQueue, &info); + VkResult err = vkQueuePresentKHR(vulkanContext->graphicsQueue, &info); if (err == VK_ERROR_OUT_OF_DATE_KHR || err == VK_SUBOPTIMAL_KHR) { swapChainRebuild = true; return; diff --git a/src/core/glfw/GLFWContext.h b/src/core/glfw/GLFWContext.h index a2df6e3e..01ac63cb 100644 --- a/src/core/glfw/GLFWContext.h +++ b/src/core/glfw/GLFWContext.h @@ -14,7 +14,10 @@ struct ImGui_ImplVulkanH_Window; namespace Metal { class ApplicationContext; + class VulkanContext; + class GLFWContext final : public Initializable { + VulkanContext *vulkanContext = nullptr; GLFWwindow *window = nullptr; bool validContext = true; ; @@ -41,6 +44,10 @@ namespace Metal { void dispose() const; [[nodiscard]] ImGui_ImplVulkanH_Window &getGUIWindow() const; + + void setVulkanContext(VulkanContext *vulkanContext) { + this->vulkanContext = vulkanContext; + } }; } diff --git a/src/core/gui/GuiContext.cpp b/src/core/gui/GuiContext.cpp index 6874f866..b92bfff5 100644 --- a/src/core/gui/GuiContext.cpp +++ b/src/core/gui/GuiContext.cpp @@ -8,12 +8,16 @@ #include "../../engine/resource/TextureInstance.h" namespace Metal { + #include "../vulkan/VulkanContext.h" + #include "../glfw/GLFWContext.h" + #include "../../engine/service/DescriptorSetService.h" + void GuiContext::endFrame() { } void GuiContext::renderImage(TextureInstance *texture, const float sizeX, const float sizeY) const { - CTX.descriptorSetService.setImageDescriptor(texture); + descriptorSetService.setImageDescriptor(texture); ImGui::Image(reinterpret_cast(texture->imageDescriptor->vkDescriptorSet), ImVec2{sizeX, sizeY}); } @@ -61,19 +65,19 @@ namespace Metal { io.ConfigWindowsResizeFromEdges = true; // Setup Platform/Renderer backends - ImGui_ImplGlfw_InitForVulkan(CTX.glfwContext.getWindow(), true); + ImGui_ImplGlfw_InitForVulkan(glfwContext.getWindow(), true); ImGui_ImplVulkan_InitInfo init_info = {}; - init_info.Instance = CTX.vulkanContext.instance.instance; - init_info.PhysicalDevice = CTX.vulkanContext.physDevice.physical_device; - init_info.Device = CTX.vulkanContext.device.device; - init_info.QueueFamily = CTX.vulkanContext.queueFamily; - init_info.Queue = CTX.vulkanContext.graphicsQueue; - init_info.PipelineCache = CTX.vulkanContext.pipelineCache; - init_info.DescriptorPool = CTX.vulkanContext.descriptorPool; - init_info.RenderPass = CTX.vulkanContext.imguiVulkanWindow.RenderPass; + init_info.Instance = vulkanContext.instance.instance; + init_info.PhysicalDevice = vulkanContext.physDevice.physical_device; + init_info.Device = vulkanContext.device.device; + init_info.QueueFamily = vulkanContext.queueFamily; + init_info.Queue = vulkanContext.graphicsQueue; + init_info.PipelineCache = vulkanContext.pipelineCache; + init_info.DescriptorPool = vulkanContext.descriptorPool; + init_info.RenderPass = vulkanContext.imguiVulkanWindow.RenderPass; init_info.Subpass = 0; init_info.MinImageCount = MAX_FRAMES_IN_FLIGHT; - init_info.ImageCount = CTX.vulkanContext.imguiVulkanWindow.ImageCount; + init_info.ImageCount = vulkanContext.imguiVulkanWindow.ImageCount; init_info.MSAASamples = VK_SAMPLE_COUNT_1_BIT; init_info.Allocator = nullptr; init_info.CheckVkResultFn = VulkanUtils::CheckVKResult; @@ -137,16 +141,22 @@ namespace Metal { } void GuiContext::dispose() const { - const VkResult err = vkDeviceWaitIdle(CTX.vulkanContext.device.device); + const VkResult err = vkDeviceWaitIdle(vulkanContext.device.device); VulkanUtils::CheckVKResult(err); ImGui_ImplVulkan_Shutdown(); ImGui_ImplGlfw_Shutdown(); ImGui::DestroyContext(); - ImGui_ImplVulkanH_DestroyWindow(CTX.vulkanContext.instance, CTX.vulkanContext.device.device, - &CTX.glfwContext.getGUIWindow(), + ImGui_ImplVulkanH_DestroyWindow(vulkanContext.instance, vulkanContext.device.device, + &glfwContext.getGUIWindow(), nullptr); } - GuiContext::GuiContext() : AbstractRuntimeComponent() { + GuiContext::GuiContext(VulkanContext &vulkanContext, + GLFWContext &glfwContext, + DescriptorSetService &descriptorSetService) + : AbstractRuntimeComponent(), + vulkanContext(vulkanContext), + glfwContext(glfwContext), + descriptorSetService(descriptorSetService) { } } diff --git a/src/core/gui/GuiContext.h b/src/core/gui/GuiContext.h index e360874b..5324f944 100644 --- a/src/core/gui/GuiContext.h +++ b/src/core/gui/GuiContext.h @@ -10,7 +10,14 @@ namespace Metal { struct FrameBufferAttachment; struct TextureInstance; + class VulkanContext; + class DescriptorSetService; + class GuiContext final : public AbstractRuntimeComponent { + VulkanContext &vulkanContext; + GLFWContext &glfwContext; + DescriptorSetService &descriptorSetService; + static void applySpacing(); void applyFonts(); @@ -19,7 +26,9 @@ namespace Metal { ImFont *largeIconsFont = nullptr; public: - explicit GuiContext(); + explicit GuiContext(VulkanContext &vulkanContext, + GLFWContext &glfwContext, + DescriptorSetService &descriptorSetService); [[ nodiscard]] ImFont *getLargeIconsFont() const { return largeIconsFont; diff --git a/src/core/vulkan/VulkanContext.cpp b/src/core/vulkan/VulkanContext.cpp index 040e475d..9480dbda 100644 --- a/src/core/vulkan/VulkanContext.cpp +++ b/src/core/vulkan/VulkanContext.cpp @@ -1,12 +1,27 @@ #include "VulkanContext.h" - #include "VkBootstrap.h" #include "VulkanUtils.h" #include "../../ApplicationContext.h" +#include "../../editor/service/LogService.h" namespace Metal { - VulkanContext::VulkanContext(bool debugMode) : AbstractRuntimeComponent(), - debugMode(debugMode) { + VulkanContext::VulkanContext(bool debugMode, + GLFWContext &glfwContext, + EngineRepository &engineRepository, + MeshService &meshService, + TextureService &textureService, + FrameBufferService &framebufferService, + PipelineService &pipelineService, + RayTracingService &rayTracingService) + : AbstractRuntimeComponent(), + glfwContext(glfwContext), + engineRepository(engineRepository), + meshService(meshService), + textureService(textureService), + framebufferService(framebufferService), + pipelineService(pipelineService), + rayTracingService(rayTracingService), + debugMode(debugMode) { } void VulkanContext::createSwapChain() { @@ -162,7 +177,7 @@ namespace Metal { } void VulkanContext::createPresentMode() { - VkPresentModeKHR presentModes = !CTX.engineRepository.vsync + VkPresentModeKHR presentModes = !engineRepository.vsync ? VK_PRESENT_MODE_IMMEDIATE_KHR : VK_PRESENT_MODE_FIFO_KHR; imguiVulkanWindow.PresentMode = ImGui_ImplVulkanH_SelectPresentMode( @@ -254,12 +269,12 @@ namespace Metal { imguiVulkanWindow.ClearValue.color.float32[2] = 0; imguiVulkanWindow.ClearValue.color.float32[3] = 1; - this->window = CTX.glfwContext.getWindow(); + this->window = glfwContext.getWindow(); vkb::InstanceBuilder instanceBuilder; // ------- CORE INITIALIZATION // ----- INSTANCE AND EXTENSIONS - addExtensions(instanceBuilder, CTX.glfwContext.getInstanceExtensions()); + addExtensions(instanceBuilder, glfwContext.getInstanceExtensions()); auto vkbResult = instanceBuilder .set_app_name(ENGINE_NAME) .set_engine_name(ENGINE_NAME) @@ -281,24 +296,24 @@ namespace Metal { createMemoryAllocator(); createCommandPool(); createDescriptorPool(); - CTX.textureService.createSampler(false, vkImageSampler, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER); - CTX.textureService.createSampler(true, vkTextureSampler, VK_SAMPLER_ADDRESS_MODE_REPEAT); + textureService.createSampler(false, vkImageSampler, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER); + textureService.createSampler(true, vkTextureSampler, VK_SAMPLER_ADDRESS_MODE_REPEAT); // ------- CORE INITIALIZATION } void VulkanContext::dispose() const { - CTX.pipelineService.disposeAll(); - CTX.textureService.disposeAll(); - CTX.meshService.disposeAll(); - CTX.framebufferService.disposeAll(); - CTX.rayTracingService.destroyAccelerationStructures(); + pipelineService.disposeAll(); + textureService.disposeAll(); + meshService.disposeAll(); + framebufferService.disposeAll(); + rayTracingService.destroyAccelerationStructures(); vkDestroySampler(device.device, vkImageSampler, nullptr); vkDestroySampler(device.device, vkTextureSampler, nullptr); - vkDestroyDescriptorPool(CTX.vulkanContext.device.device, descriptorPool, + vkDestroyDescriptorPool(device.device, descriptorPool, nullptr); - vkDestroyCommandPool(CTX.vulkanContext.device.device, commandPool, + vkDestroyCommandPool(device.device, commandPool, nullptr); vkDestroyDevice(device.device, nullptr); @@ -323,7 +338,7 @@ namespace Metal { poolInfo.maxSets = 500; VulkanUtils::CheckVKResult(vkCreateDescriptorPool(device.device, &poolInfo, - nullptr, &CTX.vulkanContext.descriptorPool)); + nullptr, &descriptorPool)); } VkCommandBuffer VulkanContext::beginSingleTimeCommands() const { @@ -360,19 +375,19 @@ namespace Metal { void VulkanContext::submitFrame(VkSemaphore image_acquired_semaphore, VkSemaphore render_complete_semaphore, - ImGui_ImplVulkanH_Frame *fd) const { + ImGui_ImplVulkanH_Frame *fd) { VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; VkSubmitInfo info = {}; - CTX.vulkanContext.pushCommandBuffer(fd->CommandBuffer); + pushCommandBuffer(fd->CommandBuffer); info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; info.waitSemaphoreCount = 1; info.pWaitSemaphores = &image_acquired_semaphore; info.pWaitDstStageMask = &wait_stage; - info.commandBufferCount = CTX.vulkanContext.getCommandBuffers().size(); - info.pCommandBuffers = CTX.vulkanContext.getCommandBuffers().data(); + info.commandBufferCount = getCommandBuffers().size(); + info.pCommandBuffers = getCommandBuffers().data(); info.signalSemaphoreCount = 1; info.pSignalSemaphores = &render_complete_semaphore; VulkanUtils::CheckVKResult(vkEndCommandBuffer(fd->CommandBuffer)); - VulkanUtils::CheckVKResult(vkQueueSubmit(CTX.vulkanContext.graphicsQueue, 1, &info, fd->Fence)); + VulkanUtils::CheckVKResult(vkQueueSubmit(graphicsQueue, 1, &info, fd->Fence)); } } diff --git a/src/core/vulkan/VulkanContext.h b/src/core/vulkan/VulkanContext.h index 2f74c8e4..0da550f5 100644 --- a/src/core/vulkan/VulkanContext.h +++ b/src/core/vulkan/VulkanContext.h @@ -12,7 +12,23 @@ #define VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME "VK_KHR_portability_subset" namespace Metal { + class GLFWContext; + struct EngineRepository; + class MeshService; + class TextureService; + class FrameBufferService; + class PipelineService; + class RayTracingService; + class VulkanContext final : public AbstractRuntimeComponent { + GLFWContext &glfwContext; + EngineRepository &engineRepository; + MeshService &meshService; + TextureService &textureService; + FrameBufferService &framebufferService; + PipelineService &pipelineService; + RayTracingService &rayTracingService; + static VkBool32 DebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData, @@ -51,7 +67,14 @@ namespace Metal { std::vector &getCommandBuffers() { return commandBuffers; } - explicit VulkanContext(bool debugMode); + explicit VulkanContext(bool debugMode, + GLFWContext &glfwContext, + EngineRepository &engineRepository, + MeshService &meshService, + TextureService &textureService, + FrameBufferService &framebufferService, + PipelineService &pipelineService, + RayTracingService &rayTracingService); VkPhysicalDeviceProperties physicalDeviceProperties{}; VkPhysicalDeviceMemoryProperties physicalDeviceMemoryProperties{}; @@ -98,7 +121,7 @@ namespace Metal { void endSingleTimeCommands(VkCommandBuffer commandBuffer) const; void submitFrame(VkSemaphore image_acquired_semaphore, VkSemaphore render_complete_semaphore, - ImGui_ImplVulkanH_Frame *fd) const; + ImGui_ImplVulkanH_Frame *fd); }; } // Metal diff --git a/src/editor/dock-spaces/docks/DockSpacePanel.cpp b/src/editor/dock-spaces/docks/DockSpacePanel.cpp index c6f0826a..8e998f1e 100644 --- a/src/editor/dock-spaces/docks/DockSpacePanel.cpp +++ b/src/editor/dock-spaces/docks/DockSpacePanel.cpp @@ -143,11 +143,7 @@ namespace Metal { if (ImGui::BeginPopup((id + "NewTabDropdown").c_str())) { ImGui::Text("New Tab"); ImGui::Separator(); - for (int i = 0; i <= 4; i++) { - DockSpace *option = DockSpace::GetOption(i); - if (option == nullptr) { - continue; - } + for (auto *option: DockSpace::OPTIONS_LIST) { const bool exists = hasDockSpace(option->index); const std::string label = option->icon + " " + option->name; if (ImGui::MenuItem(label.c_str(), nullptr, false, !exists)) { diff --git a/src/editor/dock-spaces/files/FilesHeaderPanel.cpp b/src/editor/dock-spaces/files/FilesHeaderPanel.cpp index 7b317138..a81e2751 100644 --- a/src/editor/dock-spaces/files/FilesHeaderPanel.cpp +++ b/src/editor/dock-spaces/files/FilesHeaderPanel.cpp @@ -22,7 +22,6 @@ namespace Metal { filesContext.setCurrentDirectory(filesContext.currentDirectory->parent); } UIUtil::RenderTooltip("Go to parent folder"); - } ImGui::SameLine(); @@ -37,9 +36,18 @@ namespace Metal { UIUtil::DynamicSpacing(200); ImGui::SetNextItemWidth(100); - editorMode = IndexOfValue(filesContext.filterType); - if (ImGui::Combo((id + "filter").c_str(), &editorMode, EntryType::Names)) { - filesContext.filterType = EntryType::ValueOfIndex(editorMode); + const auto ¤tDTO = EntryType::GetDTO(filesContext.filterType); + std::string filterLabel = currentDTO.icon + " " + currentDTO.name; + if (ImGui::Button((filterLabel + id + "filter").c_str(), ImVec2(100, 0))) { + ImGui::OpenPopup((id + "FilterPopup").c_str()); + } + if (ImGui::BeginPopup((id + "FilterPopup").c_str())) { + for (const auto &dto: EntryType::ENTRIES) { + if (ImGui::MenuItem((dto.icon + " " + dto.name).c_str())) { + filesContext.filterType = dto.type; + } + } + ImGui::EndPopup(); } ImGui::SameLine(); if (UIUtil::ButtonSimple(actionLabel + id, 100, diff --git a/src/editor/dock-spaces/files/FilesHeaderPanel.h b/src/editor/dock-spaces/files/FilesHeaderPanel.h index c2df144c..ecc11c54 100644 --- a/src/editor/dock-spaces/files/FilesHeaderPanel.h +++ b/src/editor/dock-spaces/files/FilesHeaderPanel.h @@ -10,7 +10,6 @@ namespace Metal { FilesContext &filesContext; std::string actionLabel; std::function action; - int editorMode = 0; public: explicit FilesHeaderPanel(FilesContext &files_context, const std::string &actionLabel, std::function action) diff --git a/src/editor/dock-spaces/viewport/EngineFramePanel.cpp b/src/editor/dock-spaces/viewport/EngineFramePanel.cpp index bae6fdde..b38e5df5 100644 --- a/src/editor/dock-spaces/viewport/EngineFramePanel.cpp +++ b/src/editor/dock-spaces/viewport/EngineFramePanel.cpp @@ -15,24 +15,34 @@ #include "ImGuizmo.h" #include +#include "../../../engine/passes/impl/HWRayTracingPass.h" +#include "../../../engine/passes/impl/PostProcessingPass.h" +#include "../../../engine/passes/impl/SpatialFilterPass.h" +#include "../../../engine/passes/impl/TemporalAccumulationPass.h" +#include "../../passes/GridPass.h" +#include "../../passes/SelectionIDPass.h" +#include "../../passes/SelectionOutlinePass.h" + namespace Metal { void EngineFramePanel::onInitialize() { - const auto gBufferW = applicationContext->vulkanContext.getWindowWidth() / applicationContext->engineRepository.shadingResInvScale; - const auto gBufferH = applicationContext->vulkanContext.getWindowHeight() / applicationContext->engineRepository.shadingResInvScale; + const auto gBufferW = applicationContext->vulkanContext.getWindowWidth() / applicationContext->engineRepository. + shadingResInvScale; + const auto gBufferH = applicationContext->vulkanContext.getWindowHeight() / applicationContext->engineRepository + .shadingResInvScale; engineFrame = EngineFrameBuilder() .addBuffer(RID_GLOBAL_DATA, sizeof(GlobalDataUBO), VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, UNIFORM_BUFFER) .addBuffer(RID_LIGHT_BUFFER, MAX_LIGHTS * sizeof(LightData), VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, STORAGE_BUFFER) - .addBuffer(RID_VOLUMES_BUFFER, MAX_VOLUMES * sizeof(VolumeData), - VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, STORAGE_BUFFER) + .addBuffer(RID_VOLUMES_BUFFER, MAX_VOLUMES * sizeof(VolumeData), + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, STORAGE_BUFFER) .addBuffer(RID_MESH_METADATA_BUFFER, MAX_MESH_INSTANCES * sizeof(MeshMetadata), VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, STORAGE_BUFFER) .addTexture(RID_ACCUMULATED_FRAME, gBufferW, gBufferH) .addTexture(RID_GBUFFER_POSITION_INDEX, gBufferW, gBufferH, VK_FORMAT_R32G32B32A32_SFLOAT) .addTexture(RID_GBUFFER_NORMAL, gBufferW, gBufferH, VK_FORMAT_R16G16B16A16_SFLOAT) - .addTexture(RID_PREVIOUS_POSITION_INDEX, gBufferW, gBufferH, VK_FORMAT_R32G32B32_SFLOAT) // I noticed current position is rgba32f, but let's check. + .addTexture(RID_PREVIOUS_POSITION_INDEX, gBufferW, gBufferH, VK_FORMAT_R32G32B32A32_SFLOAT) .addTexture(RID_PREVIOUS_NORMAL, gBufferW, gBufferH, VK_FORMAT_R16G16B16A16_SFLOAT) .addTexture(RID_DENOISED_FRAME, gBufferW, gBufferH, VK_FORMAT_R16G16B16A16_SFLOAT) .addTexture(RID_TEMPORAL_OUTPUT, gBufferW, gBufferH, VK_FORMAT_R16G16B16A16_SFLOAT) @@ -42,17 +52,15 @@ namespace Metal { .addFramebuffer(RID_POST_PROCESSING_FBO, gBufferW, gBufferH, glm::vec4(0, 0, 0, 0)) .addColor(VK_FORMAT_R16G16B16A16_SFLOAT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) .addComputeCommandBuffer(RID_COMPUTE_CB) - .addPass(RAY_TRACING, RID_COMPUTE_CB) - .addPass(ACCUMULATION, RID_COMPUTE_CB) - .addPass(TEMPORAL_ACCUMULATION, RID_COMPUTE_CB) - .addPass(SPATIAL_FILTER, RID_COMPUTE_CB) + .addPass(std::make_unique(), RID_COMPUTE_CB) + .addPass(std::make_unique(), RID_COMPUTE_CB) + .addPass(std::make_unique(), RID_COMPUTE_CB) .addCommandBuffer(RID_SELECTION_CB, RID_SELECTION_FBO) - .addPass(SELECTION_ID, RID_SELECTION_CB) + .addPass(std::make_unique(), RID_SELECTION_CB) .addCommandBuffer(RID_POST_PROCESSING_CB, RID_POST_PROCESSING_FBO) - .addPass(POST_PROCESSING, RID_POST_PROCESSING_CB) - .addPass(SELECTION_OUTLINE, RID_POST_PROCESSING_CB) - .addPass(GRID, RID_POST_PROCESSING_CB) - .addPass(ICONS, RID_POST_PROCESSING_CB) + .addPass(std::make_unique(), RID_POST_PROCESSING_CB) + .addPass(std::make_unique(), RID_POST_PROCESSING_CB) + .addPass(std::make_unique(), RID_POST_PROCESSING_CB) .build(); applicationContext->engineContext.registerFrame(engineFrame.get()); @@ -105,7 +113,8 @@ namespace Metal { const uint32_t pixelX = std::min(static_cast(u * static_cast(width)), width - 1); const uint32_t pixelY = std::min(static_cast(v * static_cast(height)), height - 1); - const auto picked = applicationContext->pickingService.pickEntityFromGBuffer(gBufferPositionIndex, pixelX, pixelY); + const auto picked = applicationContext->pickingService.pickEntityFromGBuffer( + gBufferPositionIndex, pixelX, pixelY); applicationContext->selectionService.clearSelection(); applicationContext->selectionService.addSelected(picked.value_or(EMPTY_ENTITY)); } diff --git a/src/editor/dto/DockSpace.cpp b/src/editor/dto/DockSpace.cpp index 186a612a..52ce8b7e 100644 --- a/src/editor/dto/DockSpace.cpp +++ b/src/editor/dto/DockSpace.cpp @@ -18,25 +18,22 @@ namespace Metal { DockSpace DockSpace::FILES{3, "Files", Icons::folder_open, 4, 4, CB(FilesPanel)}; DockSpace DockSpace::METRICS{4, "Metrics", Icons::analytics, 4, 4, CB(MetricsPanel)}; DockSpace DockSpace::REPOSITORIES{5, "Repositories", Icons::search, 4, 4, CB(RepositoriesPanel)}; - const char *DockSpace::OPTIONS = "Inspector\0World\0Console\0Files\0Metrics\0Repositories\0"; + const std::vector DockSpace::OPTIONS_LIST = { + &INSPECTOR, + &WORLD, + &CONSOLE, + &FILES, + &METRICS, + &REPOSITORIES + }; DockSpace *DockSpace::GetOption(const int selected) { - switch (selected) { - case 0: - return &INSPECTOR; - case 1: - return &WORLD; - case 2: - return &CONSOLE; - case 3: - return &FILES; - case 4: - return &METRICS; - case 5: - return &REPOSITORIES; - default: - return nullptr; + for (auto *option: OPTIONS_LIST) { + if (option->index == selected) { + return option; + } } + return nullptr; } } diff --git a/src/editor/dto/DockSpace.h b/src/editor/dto/DockSpace.h index 25b2dcd8..98fedeb0 100644 --- a/src/editor/dto/DockSpace.h +++ b/src/editor/dto/DockSpace.h @@ -1,6 +1,7 @@ #ifndef METAL_ENGINE_DOCKSPACE_H #define METAL_ENGINE_DOCKSPACE_H +#include #include #include @@ -15,7 +16,8 @@ namespace Metal { static DockSpace FILES; static DockSpace METRICS; static DockSpace REPOSITORIES; - static const char *OPTIONS; + + static const std::vector OPTIONS_LIST; const int index; const std::string name; diff --git a/src/editor/enum/EntryType.h b/src/editor/enum/EntryType.h index ea1790a7..e291a601 100644 --- a/src/editor/enum/EntryType.h +++ b/src/editor/enum/EntryType.h @@ -1,6 +1,10 @@ #ifndef FILETYPE_H #define FILETYPE_H +#include +#include +#include "../../../common/Icons.h" + namespace Metal::EntryType { enum EntryType { SCENE, @@ -11,47 +15,28 @@ namespace Metal::EntryType { NONE }; - static const char *Names = "Scene\0Mesh\0Texture\0Volume\0Directory\0None\0"; + struct EntryTypeDTO { + EntryType type; + std::string name; + std::string icon; + }; - static EntryType ValueOfIndex(const int option) { - if (option == 0) { - return EntryType::SCENE; - } - if (option == 1) { - return EntryType::MESH; - } - if (option == 2) { - return EntryType::TEXTURE; - } - if (option == 3) { - return EntryType::VOLUME; - } - if (option == 4) { - return EntryType::DIRECTORY; - } - return EntryType::NONE; - } + static const std::vector ENTRIES = { + {SCENE, "Scene", Icons::image}, + {MESH, "Mesh", Icons::view_in_ar}, + {TEXTURE, "Texture", Icons::texture}, + {VOLUME, "Volume", Icons::view_agenda}, + {DIRECTORY, "Directory", Icons::folder}, + {NONE, "None", Icons::close} + }; - static int IndexOfValue(const EntryType mode) { - if (mode == SCENE) { - return 0; - } - if (mode == MESH) { - return 1; - } - if (mode == TEXTURE) { - return 2; - } - if (mode == VOLUME) { - return 3; - } - if (mode == DIRECTORY) { - return 4; - } - if (mode == NONE) { - return 6; + static const EntryTypeDTO& GetDTO(EntryType type) { + for (const auto& dto : ENTRIES) { + if (dto.type == type) { + return dto; + } } - return 6; + return ENTRIES.back(); // Return NONE } } #endif diff --git a/src/editor/passes/GridPass.h b/src/editor/passes/GridPass.h index 86dc660d..ff77ef29 100644 --- a/src/editor/passes/GridPass.h +++ b/src/editor/passes/GridPass.h @@ -8,8 +8,6 @@ namespace Metal { GridPushConstant pushConstant{}; public: - explicit GridPass(const std::string &id) : AbstractRenderPass(id) {} - void onInitialize() override; bool shouldRun() override; diff --git a/src/editor/passes/IconsPass.cpp b/src/editor/passes/IconsPass.cpp deleted file mode 100644 index 73e0126b..00000000 --- a/src/editor/passes/IconsPass.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "IconsPass.h" - -#include "../../ApplicationContext.h" -#include "../../engine/dto/PipelineBuilder.h" -#include "../enum/EngineResourceIDs.h" - -namespace Metal { - void IconsPass::onInitialize() { - PipelineBuilder iconPipelineBuilder = PipelineBuilder::Of( - getScopedResourceId(RID_POST_PROCESSING_FBO), - "QUAD.vert", - "tools/Icon.frag" - ) - .addBufferBinding(getScopedResourceId(RID_GLOBAL_DATA)) - .addBufferBinding(getScopedResourceId(RID_LIGHT_BUFFER)) - .setBlendEnabled(); - pipelineInstance = CTX.pipelineService.createPipeline(iconPipelineBuilder); - } - - bool IconsPass::shouldRun() { - return CTX.isDebugMode() && CTX.editorRepository.showIcons; - } - - void IconsPass::onSync() { - recordDrawSimpleInstanced(3, 1); - } -} // Metal diff --git a/src/editor/passes/IconsPass.h b/src/editor/passes/IconsPass.h deleted file mode 100644 index cb46ae3c..00000000 --- a/src/editor/passes/IconsPass.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef ICONRENDERPASS_H -#define ICONRENDERPASS_H -#include "../../engine/passes/AbstractRenderPass.h" - -namespace Metal { - class IconsPass final : public AbstractRenderPass { - public: - explicit IconsPass(const std::string &id) : AbstractRenderPass(id) {} - - void onInitialize() override; - - bool shouldRun() override; - - void onSync() override; - }; -} // Metal - -#endif //ICONRENDERPASS_H diff --git a/src/editor/passes/SelectionIDPass.h b/src/editor/passes/SelectionIDPass.h index 156892dd..fe0aac3a 100644 --- a/src/editor/passes/SelectionIDPass.h +++ b/src/editor/passes/SelectionIDPass.h @@ -9,7 +9,6 @@ namespace Metal { SelectedDotPushConstant pushConstant{}; public: - explicit SelectionIDPass(const std::string &id) : AbstractRenderPass(id) {} void onInitialize() override; diff --git a/src/editor/passes/SelectionOutlinePass.h b/src/editor/passes/SelectionOutlinePass.h index 4d1b8d7b..60860a7a 100644 --- a/src/editor/passes/SelectionOutlinePass.h +++ b/src/editor/passes/SelectionOutlinePass.h @@ -9,8 +9,6 @@ namespace Metal { SelectedDotPushConstant pushConstant{}; public: - explicit SelectionOutlinePass(const std::string &id) : AbstractRenderPass(id) {} - void onInitialize() override; bool shouldRun() override; diff --git a/src/editor/repository/EditorRepository.cpp b/src/editor/repository/EditorRepository.cpp index b4cb5b1b..aff132b3 100644 --- a/src/editor/repository/EditorRepository.cpp +++ b/src/editor/repository/EditorRepository.cpp @@ -35,14 +35,14 @@ namespace Metal { j["gizmoUseSnapRotate"] = gizmoUseSnapRotate; j["gizmoUseSnapScale"] = gizmoUseSnapScale; j["showOnlyEntitiesHierarchy"] = showOnlyEntitiesHierarchy; - j["mainSelection"] = static_cast(entt::to_integral(mainSelection)); + j["mainSelection"] = entt::to_integral(mainSelection); j["selected"] = nlohmann::json::array(); for (auto const& [key, val] : selected) { - j["selected"].push_back(static_cast(entt::to_integral(key))); + j["selected"].push_back(entt::to_integral(key)); } j["copied"] = nlohmann::json::array(); for (auto const& entity : copied) { - j["copied"].push_back(static_cast(entt::to_integral(entity))); + j["copied"].push_back(entt::to_integral(entity)); } j["shadingMode"] = shadingMode; return j; diff --git a/src/editor/service/DockService.cpp b/src/editor/service/DockService.cpp index 5bbffb0a..c231964f 100644 --- a/src/editor/service/DockService.cpp +++ b/src/editor/service/DockService.cpp @@ -10,7 +10,6 @@ namespace Metal { void DockService::buildViews(ImGuiID windowId, AbstractPanel *panel) const { if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable) { - DockRepository &dockRepository = CTX.dockRepository; if (dockRepository.isInitialized) { return; } diff --git a/src/editor/service/DockService.h b/src/editor/service/DockService.h index 6d00ee6e..2c5fbf40 100644 --- a/src/editor/service/DockService.h +++ b/src/editor/service/DockService.h @@ -10,7 +10,12 @@ namespace Metal { class AbstractPanel; class DockService final : public AbstractRuntimeComponent { + DockRepository &dockRepository; public: + explicit DockService(DockRepository &dockRepository) + : AbstractRuntimeComponent(), dockRepository(dockRepository) { + } + void buildViews(ImGuiID windowId, AbstractPanel *panel) const; static void createDockSpace(DockDTO *dockSpace, ImGuiID *dockMainId); diff --git a/src/editor/service/ThemeService.cpp b/src/editor/service/ThemeService.cpp index 4eee2551..993a6c9c 100644 --- a/src/editor/service/ThemeService.cpp +++ b/src/editor/service/ThemeService.cpp @@ -6,7 +6,6 @@ namespace Metal { glm::vec3 ThemeService::BACKGROUND_COLOR = glm::vec3(0.f); void ThemeService::onSync() { - EditorRepository &editorRepository = CTX.editorRepository; if (previousTheme == editorRepository.isDarkMode && glm::length(editorRepository.accentColor) == prevLength) { return; } diff --git a/src/editor/service/ThemeService.h b/src/editor/service/ThemeService.h index e9d5f603..94310fbe 100644 --- a/src/editor/service/ThemeService.h +++ b/src/editor/service/ThemeService.h @@ -6,7 +6,9 @@ namespace Metal { + struct EditorRepository; class ThemeService final : public AbstractRuntimeComponent { + EditorRepository &editorRepository; public: ImVec4 neutralPalette{}; ImVec4 palette0{}; @@ -21,7 +23,8 @@ namespace Metal { bool previousTheme = false; float prevLength = 0.0f; - explicit ThemeService() : AbstractRuntimeComponent() { + explicit ThemeService(EditorRepository &editorRepository) + : AbstractRuntimeComponent(), editorRepository(editorRepository) { } void setDarkMode(); diff --git a/src/engine/dto/PrimitiveComponent.cpp b/src/engine/dto/PrimitiveComponent.cpp index 7018d702..519167ca 100644 --- a/src/engine/dto/PrimitiveComponent.cpp +++ b/src/engine/dto/PrimitiveComponent.cpp @@ -19,17 +19,18 @@ namespace Metal { } void PrimitiveComponent::onUpdate(InspectableMember *member) { - if (member != nullptr && member->name == "meshId") { - MeshData *data = CTX.meshService.loadMeshData(meshId); - if (data != nullptr) { - if (CTX.worldRepository.registry.all_of(entityId)) { - CTX.worldRepository.registry.get(entityId).gizmoCenter = data->gizmoCenter; - } - delete data; - } - } - CTX.engineContext.setGISettingsUpdated(true); - CTX.rayTracingService.setNeedsMaterialUpdate(true); + // TODO - EVENT SYSTEM + // if (member != nullptr && member->name == "meshId") { + // MeshData *data = CTX.meshService.loadMeshData(meshId); + // if (data != nullptr) { + // if (CTX.worldRepository.registry.all_of(entityId)) { + // CTX.worldRepository.registry.get(entityId).gizmoCenter = data->gizmoCenter; + // } + // delete data; + // } + // } + // CTX.engineContext.setGISettingsUpdated(true); + // CTX.rayTracingService.setNeedsMaterialUpdate(true); } ComponentType PrimitiveComponent::getType() { diff --git a/src/engine/enum/PassType.h b/src/engine/enum/PassType.h deleted file mode 100644 index d0c67489..00000000 --- a/src/engine/enum/PassType.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef PASS_TYPE_H -#define PASS_TYPE_H - -namespace Metal { - enum PassType { - RAY_TRACING, - ACCUMULATION, - TEMPORAL_ACCUMULATION, - SPATIAL_FILTER, - POST_PROCESSING, - SELECTION_OUTLINE, - GRID, - ICONS, - SELECTION_ID - }; -} - -#endif //PASS_TYPE_H diff --git a/src/engine/enum/ResourceType.h b/src/engine/enum/ResourceType.h index a2ebd28c..c29f3423 100644 --- a/src/engine/enum/ResourceType.h +++ b/src/engine/enum/ResourceType.h @@ -8,8 +8,7 @@ namespace Metal { PIPELINE, BUFFER, DESCRIPTOR_SET, - COMMAND_BUFFER_RECORDER, - PASS + COMMAND_BUFFER_RECORDER }; } diff --git a/src/engine/frame-builder/EngineFrame.cpp b/src/engine/frame-builder/EngineFrame.cpp index 6f714a1b..49d71f48 100644 --- a/src/engine/frame-builder/EngineFrame.cpp +++ b/src/engine/frame-builder/EngineFrame.cpp @@ -12,8 +12,7 @@ namespace Metal { } } - - void EngineFrame::addPass(CommandBufferRecorder *recorder, const std::vector &p) { + void EngineFrame::addPass(CommandBufferRecorder *recorder, const std::vector> &p) { if (recorder) { passes.emplace_back(recorder, p); } @@ -25,16 +24,6 @@ namespace Metal { } } - void EngineFrame::dispose() { - for (auto &pair: passes) { - delete pair.first; - for (auto *pass: pair.second) { - delete pass; - } - } - passes.clear(); - } - std::string EngineFrame::getScopedResourceId(const std::string &resourceId) const { return id + "_" + resourceId; } diff --git a/src/engine/frame-builder/EngineFrame.h b/src/engine/frame-builder/EngineFrame.h index 66c8446d..9ea82210 100644 --- a/src/engine/frame-builder/EngineFrame.h +++ b/src/engine/frame-builder/EngineFrame.h @@ -16,7 +16,7 @@ namespace Metal { std::string id; bool shouldRender = false; std::unordered_map resources; - std::vector > > passes; + std::vector > > > passes; public: explicit EngineFrame(std::string id); @@ -38,20 +38,10 @@ namespace Metal { return nullptr; } - void addPass(CommandBufferRecorder *recorder, const std::vector &p); - - [[nodiscard]] const std::vector > > & - getPasses() const { - return passes; - } + void addPass(CommandBufferRecorder *recorder, const std::vector> &p); void onSync(); - void dispose(); - - void destroy() { - } - [[nodiscard]] std::string getScopedResourceId(const std::string &resourceId) const; }; } diff --git a/src/engine/frame-builder/EngineFrameBuilder.cpp b/src/engine/frame-builder/EngineFrameBuilder.cpp index 82804505..4d8796db 100644 --- a/src/engine/frame-builder/EngineFrameBuilder.cpp +++ b/src/engine/frame-builder/EngineFrameBuilder.cpp @@ -82,9 +82,9 @@ namespace Metal { return *this; } - EngineFrameBuilder &EngineFrameBuilder::addPass(PassType type, const std::string &commandBufferId) { - currentBuilder = std::make_shared(Util::uuidV4(), type, frameId + "_" + commandBufferId); - builders.push_back(currentBuilder); + EngineFrameBuilder &EngineFrameBuilder::addPass(std::unique_ptr pass, + const std::string &commandBufferId) { + passes.emplace_back(std::move(pass), frameId + "_" + commandBufferId); return *this; } @@ -103,37 +103,32 @@ namespace Metal { std::unordered_map builtResources; for (const auto &builder: builders) { - auto *resource = builder->build(); - if (resource) { + if (auto *resource = builder->build()) { frame->addResource(resource); builtResources[builder->getId()] = resource; } } - std::unordered_map > recorderToPasses; + std::unordered_map> > recorderToPasses; std::vector recorderOrder; for (const auto &builder: builders) { if (auto *passBuilder = dynamic_cast(builder.get())) { const auto cbId = passBuilder->getCommandBufferId(); - if (std::find(recorderOrder.begin(), recorderOrder.end(), cbId) == recorderOrder.end()) { + if (std::ranges::find(recorderOrder, cbId) == recorderOrder.end()) { recorderOrder.push_back(cbId); } - - if (builtResources.contains(builder->getId())) { - auto *pass = dynamic_cast(builtResources.at(builder->getId())); - if (pass) { - pass->frame = frame.get(); - pass->onInitialize(); - recorderToPasses[cbId].push_back(pass); - } - } } } + for (auto &pass: passes) { + pass.pass->frame = frame.get(); + pass.pass->onInitialize(); + recorderToPasses[pass.commandBufferId].push_back(std::move(pass.pass)); + } + for (const auto &cbId: recorderOrder) { - auto *recorder = CTX.commandBufferRecorderService.getResource(cbId); - if (recorder) { + if (auto *recorder = dynamic_cast(builtResources.at(cbId))) { frame->addPass(recorder, recorderToPasses[cbId]); } } diff --git a/src/engine/frame-builder/EngineFrameBuilder.h b/src/engine/frame-builder/EngineFrameBuilder.h index 0462a415..63c58cf2 100644 --- a/src/engine/frame-builder/EngineFrameBuilder.h +++ b/src/engine/frame-builder/EngineFrameBuilder.h @@ -12,15 +12,22 @@ #include "../resource/BufferInstance.h" namespace Metal { + class AbstractPass; class CommandBufferRecorder; struct FrameBufferInstance; struct DescriptorBinding; class ResourceBuilder; class EngineFrame; + struct PassData { + std::unique_ptr pass; + std::string commandBufferId; + }; + class EngineFrameBuilder final { std::string frameId; std::vector > builders{}; + std::vector passes{}; std::shared_ptr currentBuilder{}; public: @@ -46,7 +53,7 @@ namespace Metal { EngineFrameBuilder &addComputeCommandBuffer(const std::string &id); - EngineFrameBuilder &addPass(PassType type, const std::string &commandBufferId); + EngineFrameBuilder &addPass(std::unique_ptr pass, const std::string &commandBufferId); bool tryMatch(const std::string &id, ResourceType type); diff --git a/src/engine/frame-builder/structures/BufferBuilder.cpp b/src/engine/frame-builder/structures/BufferBuilder.cpp index 2dce9a2c..ce876357 100644 --- a/src/engine/frame-builder/structures/BufferBuilder.cpp +++ b/src/engine/frame-builder/structures/BufferBuilder.cpp @@ -5,7 +5,7 @@ namespace Metal { ResourceType BufferBuilder::getType() { - return ResourceType::BUFFER; + return BUFFER; } RuntimeResource *BufferBuilder::build() { diff --git a/src/engine/frame-builder/structures/PassBuilder.cpp b/src/engine/frame-builder/structures/PassBuilder.cpp deleted file mode 100644 index 8d9d8278..00000000 --- a/src/engine/frame-builder/structures/PassBuilder.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "PassBuilder.h" -#include "../../passes/impl/PostProcessingPass.h" -#include "../../passes/impl/HWRayTracingPass.h" -#include "../../passes/impl/TemporalAccumulationPass.h" -#include "../../passes/impl/SpatialFilterPass.h" -#include "../../../editor/passes/SelectionOutlinePass.h" -#include "../../../editor/passes/GridPass.h" -#include "../../../editor/passes/IconsPass.h" -#include "../../../editor/passes/SelectionIDPass.h" - -namespace Metal { - RuntimeResource* PassBuilder::build() { - switch (passType) { - case POST_PROCESSING: - return new PostProcessingPass(id); - case RAY_TRACING: - return new HWRayTracingPass(id); - case TEMPORAL_ACCUMULATION: - return new TemporalAccumulationPass(id); - case SPATIAL_FILTER: - return new SpatialFilterPass(id); - case SELECTION_OUTLINE: - return new SelectionOutlinePass(id); - case GRID: - return new GridPass(id); - case ICONS: - return new IconsPass(id); - case SELECTION_ID: - return new SelectionIDPass(id); - default: - return nullptr; - } - } -} diff --git a/src/engine/frame-builder/structures/PassBuilder.h b/src/engine/frame-builder/structures/PassBuilder.h deleted file mode 100644 index e92c1cfd..00000000 --- a/src/engine/frame-builder/structures/PassBuilder.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef METAL_ENGINE_PASSBUILDER_H -#define METAL_ENGINE_PASSBUILDER_H - -#include "ResourceBuilder.h" -#include "../../enum/PassType.h" -#include "../../enum/ResourceType.h" - -namespace Metal { - class PassBuilder final : public ResourceBuilder { - PassType passType; - std::string commandBufferId; - std::string framebufferId; - bool clearBuffer; - - public: - explicit PassBuilder(const std::string &id, PassType type, std::string commandBufferId, - std::string framebufferId = "", bool clearBuffer = true) - : ResourceBuilder(id), passType(type), commandBufferId(std::move(commandBufferId)), - framebufferId(std::move(framebufferId)), clearBuffer(clearBuffer) { - } - - ResourceType getType() override { - return PASS; - } - - RuntimeResource *build() override; - - [[nodiscard]] PassType getPassType() const { return passType; } - const std::string &getCommandBufferId() const { return commandBufferId; } - const std::string &getFramebufferId() const { return framebufferId; } - bool shouldClearBuffer() const { return clearBuffer; } - }; -} - -#endif diff --git a/src/engine/passes/AbstractComputePass.cpp b/src/engine/passes/AbstractComputePass.cpp index cd34e278..bed92677 100644 --- a/src/engine/passes/AbstractComputePass.cpp +++ b/src/engine/passes/AbstractComputePass.cpp @@ -5,7 +5,7 @@ #include "../util/ImageUtils.h" namespace Metal { - AbstractComputePass::AbstractComputePass(const std::string &id) : AbstractPass(id, true) { + AbstractComputePass::AbstractComputePass() : AbstractPass(true) { } void AbstractComputePass::recordDispatch(const unsigned int groupX, const unsigned int groupY, diff --git a/src/engine/passes/AbstractComputePass.h b/src/engine/passes/AbstractComputePass.h index 321e0989..20cd53c2 100644 --- a/src/engine/passes/AbstractComputePass.h +++ b/src/engine/passes/AbstractComputePass.h @@ -13,7 +13,7 @@ namespace Metal { class AbstractComputePass : public AbstractPass { public: - explicit AbstractComputePass(const std::string &id); + explicit AbstractComputePass(); void recordDispatch(unsigned int groupX, unsigned int groupY, unsigned int groupZ) const; diff --git a/src/engine/passes/AbstractPass.cpp b/src/engine/passes/AbstractPass.cpp index a0dbd400..367c8fad 100644 --- a/src/engine/passes/AbstractPass.cpp +++ b/src/engine/passes/AbstractPass.cpp @@ -4,14 +4,7 @@ #include "../resource/PipelineInstance.h" namespace Metal { - AbstractPass::AbstractPass(const std::string &id, bool isComputePass) : RuntimeResource(id), - isComputePass(isComputePass) { - } - - AbstractPass::~AbstractPass() { - if (pipelineInstance != nullptr) { - CTX.pipelineService.dispose(pipelineInstance->getId()); - } + AbstractPass::AbstractPass(bool isComputePass) : isComputePass(isComputePass) { } void AbstractPass::recordPushConstant(const void *data) { diff --git a/src/engine/passes/AbstractPass.h b/src/engine/passes/AbstractPass.h index d5fffc8f..8be0960e 100644 --- a/src/engine/passes/AbstractPass.h +++ b/src/engine/passes/AbstractPass.h @@ -13,7 +13,7 @@ namespace Metal { class StreamingService; struct PipelineInstance; - class AbstractPass : public AbstractRuntimeComponent, public RuntimeResource { + class AbstractPass : public AbstractRuntimeComponent { bool isComputePass; public: @@ -21,13 +21,7 @@ namespace Metal { VkCommandBuffer vkCommandBuffer = VK_NULL_HANDLE; PipelineInstance *pipelineInstance = nullptr; - explicit AbstractPass(const std::string &id, bool isComputePass); - - virtual ~AbstractPass() override; - - ResourceType resourceType() override { - return PASS; - } + explicit AbstractPass( bool isComputePass); void recordPushConstant(const void *data); @@ -39,7 +33,7 @@ namespace Metal { this->vkCommandBuffer = vkCommandBuffer; } - PipelineInstance *getPipeline() { + PipelineInstance *getPipeline() const { return pipelineInstance; } diff --git a/src/engine/passes/AbstractRenderPass.cpp b/src/engine/passes/AbstractRenderPass.cpp index c8b1084f..15708631 100644 --- a/src/engine/passes/AbstractRenderPass.cpp +++ b/src/engine/passes/AbstractRenderPass.cpp @@ -4,7 +4,7 @@ #include "../resource/BufferInstance.h" namespace Metal { - AbstractRenderPass::AbstractRenderPass(const std::string &id) : AbstractPass(id, false) { + AbstractRenderPass::AbstractRenderPass() : AbstractPass(false) { } void AbstractRenderPass::recordDrawSimpleInstanced(const unsigned int vertexCount, const unsigned int instanceCount) const { diff --git a/src/engine/passes/AbstractRenderPass.h b/src/engine/passes/AbstractRenderPass.h index a08bb11b..e751c57c 100644 --- a/src/engine/passes/AbstractRenderPass.h +++ b/src/engine/passes/AbstractRenderPass.h @@ -12,7 +12,7 @@ namespace Metal { class AbstractRenderPass : public AbstractPass { public: - explicit AbstractRenderPass(const std::string &id); + explicit AbstractRenderPass(); void recordDrawSimpleInstanced(unsigned int vertexCount, unsigned int instanceCount) const; diff --git a/src/engine/passes/CommandBufferRecorder.cpp b/src/engine/passes/CommandBufferRecorder.cpp index 785eb2f6..03f9b60c 100644 --- a/src/engine/passes/CommandBufferRecorder.cpp +++ b/src/engine/passes/CommandBufferRecorder.cpp @@ -70,7 +70,7 @@ namespace Metal { } void CommandBufferRecorder::recordCommands( - const std::vector &passes) const { + const std::vector> &passes) const { auto vkCommandBuffer = _commandBuffers[CTX.getFrameIndex()]; VkCommandBufferBeginInfo beginInfo{}; beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; @@ -91,7 +91,7 @@ namespace Metal { } void CommandBufferRecorder::RecordCommandsInternal( - const std::vector &passes, + const std::vector> &passes, VkCommandBuffer vkCommandBuffer) { for (auto &pass: passes) { pass->setCommandBuffer(vkCommandBuffer); diff --git a/src/engine/passes/CommandBufferRecorder.h b/src/engine/passes/CommandBufferRecorder.h index f7b367c9..a188280f 100644 --- a/src/engine/passes/CommandBufferRecorder.h +++ b/src/engine/passes/CommandBufferRecorder.h @@ -20,7 +20,7 @@ namespace Metal { bool computePassMode; static void RecordCommandsInternal( - const std::vector &passes, + const std::vector> &passes, VkCommandBuffer vkCommandBuffer); void createRenderPassInfo(const FrameBufferInstance *frameBuffer, bool clearBuffer); @@ -36,7 +36,7 @@ namespace Metal { void createCommandBuffer(); - void recordCommands(const std::vector &passes) const; + void recordCommands(const std::vector> &passes) const; }; } // Metal diff --git a/src/engine/passes/impl/HWRayTracingPass.h b/src/engine/passes/impl/HWRayTracingPass.h index 860a2424..de0d0f70 100644 --- a/src/engine/passes/impl/HWRayTracingPass.h +++ b/src/engine/passes/impl/HWRayTracingPass.h @@ -9,9 +9,6 @@ namespace Metal { HWRayTracingPushConstant pushConstant{}; public: - explicit HWRayTracingPass(const std::string &id) : AbstractComputePass(id) { - } - void onSync() override; void onInitialize() override; diff --git a/src/engine/passes/impl/PostProcessingPass.h b/src/engine/passes/impl/PostProcessingPass.h index 98dbcbc9..08e60b2c 100644 --- a/src/engine/passes/impl/PostProcessingPass.h +++ b/src/engine/passes/impl/PostProcessingPass.h @@ -7,8 +7,6 @@ namespace Metal { class PostProcessingPass final : public AbstractRenderPass { PostProcessingPushConstant pushConstant{}; public: - explicit PostProcessingPass(const std::string &id) : AbstractRenderPass(id) {} - void onInitialize() override; void onSync() override; diff --git a/src/engine/passes/impl/SpatialFilterPass.h b/src/engine/passes/impl/SpatialFilterPass.h index ef66e4b3..838a353f 100644 --- a/src/engine/passes/impl/SpatialFilterPass.h +++ b/src/engine/passes/impl/SpatialFilterPass.h @@ -5,9 +5,6 @@ namespace Metal { class SpatialFilterPass final : public AbstractComputePass { public: - explicit SpatialFilterPass(const std::string &id) : AbstractComputePass(id) { - } - void onSync() override; void onInitialize() override; diff --git a/src/engine/passes/impl/TemporalAccumulationPass.h b/src/engine/passes/impl/TemporalAccumulationPass.h index e9d61531..a95b2c3f 100644 --- a/src/engine/passes/impl/TemporalAccumulationPass.h +++ b/src/engine/passes/impl/TemporalAccumulationPass.h @@ -5,8 +5,6 @@ namespace Metal { class TemporalAccumulationPass final : public AbstractComputePass { public: - explicit TemporalAccumulationPass(const std::string &id) : AbstractComputePass(id) { - } void onSync() override; diff --git a/src/engine/service/PipelineService.cpp b/src/engine/service/PipelineService.cpp index d8feef1b..83e84709 100644 --- a/src/engine/service/PipelineService.cpp +++ b/src/engine/service/PipelineService.cpp @@ -1,6 +1,6 @@ #include "PipelineService.h" #include "../dto/PipelineBuilder.h" -#include "../util/ShaderUtil.h" +#include "ShaderService.h" #include "../../core/vulkan/VulkanContext.h" #include "../../core/vulkan/VulkanUtils.h" #include "FrameBufferService.h" @@ -73,7 +73,7 @@ namespace Metal { PipelineInstance *pipeline) { pipeline->isCompute = true; pipeline->pushConstantsSize = pipelineBuilder.pushConstantsSize; - VkShaderModule computeShaderModule = ShaderUtil::CreateShaderModule(pipelineBuilder.computeShader); + VkShaderModule computeShaderModule = shaderService.createShaderModule(pipelineBuilder.computeShader); VkPipelineShaderStageCreateInfo computeShaderStageInfo{}; computeShaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; computeShaderStageInfo.stage = VK_SHADER_STAGE_COMPUTE_BIT; @@ -101,8 +101,8 @@ namespace Metal { auto meshDescriptions = VertexData::GetAttributeDescriptions(); pipeline->pushConstantsSize = pipelineBuilder.pushConstantsSize; - auto fragmentShaderModule = ShaderUtil::CreateShaderModule(pipelineBuilder.fragmentShader); - auto vertexShaderModule = ShaderUtil::CreateShaderModule(pipelineBuilder.vertexShader); + auto fragmentShaderModule = shaderService.createShaderModule(pipelineBuilder.fragmentShader); + auto vertexShaderModule = shaderService.createShaderModule(pipelineBuilder.vertexShader); createPipelineLayout(pipelineBuilder.pushConstantsSize, pipeline); std::array shaderStages{}; @@ -252,9 +252,9 @@ namespace Metal { pipeline->pushConstantsSize = pipelineBuilder.pushConstantsSize; // Create shader modules - auto rayGenModule = ShaderUtil::CreateShaderModule(pipelineBuilder.rayGenShader); - auto missModule = ShaderUtil::CreateShaderModule(pipelineBuilder.missShader); - auto closestHitModule = ShaderUtil::CreateShaderModule(pipelineBuilder.closestHitShader); + auto rayGenModule = shaderService.createShaderModule(pipelineBuilder.rayGenShader); + auto missModule = shaderService.createShaderModule(pipelineBuilder.missShader); + auto closestHitModule = shaderService.createShaderModule(pipelineBuilder.closestHitShader); // Shader stages: 0=raygen, 1=miss, 2=closesthit std::array shaderStages{}; diff --git a/src/engine/service/PipelineService.h b/src/engine/service/PipelineService.h index e3095178..55d4852f 100644 --- a/src/engine/service/PipelineService.h +++ b/src/engine/service/PipelineService.h @@ -7,6 +7,7 @@ #include "../resource/PipelineInstance.h" namespace Metal { + class ShaderService; struct PipelineBuilder; struct FrameBufferInstance; struct PipelineInstance; @@ -21,10 +22,16 @@ namespace Metal { FrameBufferService &framebufferService; BufferService &bufferService; DescriptorSetService &descriptorSetService; + ShaderService &shaderService; public: - explicit PipelineService(VulkanContext &vulkanContext, FrameBufferService &framebufferService, BufferService &bufferService, DescriptorSetService &descriptorSetService) - : vulkanContext(vulkanContext), framebufferService(framebufferService), bufferService(bufferService), descriptorSetService(descriptorSetService) {} + explicit PipelineService(ShaderService &shaderService, VulkanContext &vulkanContext, + FrameBufferService &framebufferService, BufferService &bufferService, + DescriptorSetService &descriptorSetService) + : shaderService(shaderService), vulkanContext(vulkanContext), framebufferService(framebufferService), + bufferService(bufferService), descriptorSetService(descriptorSetService) { + } + PipelineService() = delete; PipelineInstance *createPipeline(PipelineBuilder &pipelineBuilder); diff --git a/src/engine/util/ShaderUtil.cpp b/src/engine/service/ShaderService.cpp similarity index 88% rename from src/engine/util/ShaderUtil.cpp rename to src/engine/service/ShaderService.cpp index b0544a2e..8e062433 100644 --- a/src/engine/util/ShaderUtil.cpp +++ b/src/engine/service/ShaderService.cpp @@ -1,7 +1,10 @@ -#include "ShaderUtil.h" +#include "ShaderService.h" #include #include +#include +#include +#include #include "../dto/ShaderModule.h" #include "../../core/vulkan/VulkanUtils.h" @@ -15,7 +18,7 @@ #define BASE_PATH "../resources/shaders/" namespace Metal { - void ShaderUtil::CheckShaderCompilation(glslang_shader_t *shader) { + void ShaderService::CheckShaderCompilation(glslang_shader_t *shader) { const char *infoLog = glslang_shader_get_info_log(shader); const char *debugLog = glslang_shader_get_info_debug_log(shader); const char *shaderCode = glslang_shader_get_preprocessed_code(shader); @@ -28,8 +31,8 @@ namespace Metal { } } - bool ShaderUtil::CompileShader(glslang_stage_t stage, const char *pShaderCode, - ShaderModule *shaderModule) { + bool ShaderService::CompileShader(glslang_stage_t stage, const char *pShaderCode, + ShaderModule *shaderModule) const { const glslang_input_t input = { .language = GLSLANG_SOURCE_GLSL, .stage = stage, @@ -78,7 +81,7 @@ namespace Metal { shaderCreateInfo.codeSize = shaderModule->SPIRV.size() * sizeof(unsigned int); shaderCreateInfo.pCode = static_cast(shaderModule->SPIRV.data()); - VulkanUtils::CheckVKResult(vkCreateShaderModule(CTX.vulkanContext.device.device, &shaderCreateInfo, + VulkanUtils::CheckVKResult(vkCreateShaderModule(vulkanContext.device.device, &shaderCreateInfo, nullptr, &shaderModule->vkShaderModule)); glslang_program_delete(program); @@ -87,7 +90,7 @@ namespace Metal { return !shaderModule->SPIRV.empty(); } - glslang_stage_t ShaderUtil::ShaderStageFromFilename(const char *pFilename) { + glslang_stage_t ShaderService::ShaderStageFromFilename(const char *pFilename) { const std::string s(pFilename); if (s.ends_with(".vert")) { @@ -128,7 +131,7 @@ namespace Metal { throw std::runtime_error("Unknown shader stage in file"); } - std::string ShaderUtil::ProcessIncludes(const std::string &input) { + std::string ShaderService::ProcessIncludes(const std::string &input) { std::string result = input; std::regex includePattern(R"(#include\s+"(.+))"); std::smatch match; @@ -154,16 +157,15 @@ namespace Metal { return result; } - std::string ShaderUtil::ProcessShader(const std::string &file) { + std::string ShaderService::ProcessShader(const std::string &file) { std::string source; FilesUtil::ReadFile(file.c_str(), source); return ProcessIncludes(source); } - VkShaderModule ShaderUtil::CreateShaderModule(const std::string &pFilename) { - const std::string basePath = CTX.getShadersDirectory(); + VkShaderModule ShaderService::createShaderModule(const std::string &pFilename) { std::string source = ProcessShader(BASE_PATH + pFilename); - if (CTX.isDebugMode()) { + if (isDebugMode) { source = "#define DEBUG\n" + source; } for (auto &entry: ShadingModes::getShaderEntries()) { @@ -175,8 +177,8 @@ namespace Metal { const size_t sourceHash = std::hash{}(source); const std::string part(BASE_PATH + pFilename); const std::string shaderName = part.substr(part.find_last_of('/') + 1, part.size()); - const std::string binaryFilename = basePath + shaderName + ".spv"; - const std::string hashFilename = basePath + shaderName + ".hash"; + const std::string binaryFilename = shadersDirectory + shaderName + ".spv"; + const std::string hashFilename = shadersDirectory + shaderName + ".hash"; ShaderModule shader{}; @@ -193,7 +195,7 @@ namespace Metal { shaderCreateInfo.codeSize = shader.SPIRV.size() * sizeof(unsigned int); shaderCreateInfo.pCode = static_cast(shader.SPIRV.data()); - if (vkCreateShaderModule(CTX.vulkanContext.device.device, &shaderCreateInfo, + if (vkCreateShaderModule(vulkanContext.device.device, &shaderCreateInfo, nullptr, &shader.vkShaderModule) == VK_SUCCESS) { needsCompilation = false; LOG_INFO("Loaded cached shader: " + shaderName); diff --git a/src/engine/service/ShaderService.h b/src/engine/service/ShaderService.h new file mode 100644 index 00000000..43a2dd06 --- /dev/null +++ b/src/engine/service/ShaderService.h @@ -0,0 +1,34 @@ +#ifndef SHADERSERVICE_H +#define SHADERSERVICE_H +#include +#include "../dto/ShaderModule.h" +#include "../../common/AbstractRuntimeComponent.h" + +namespace Metal { + class VulkanContext; + + class ShaderService final : public AbstractRuntimeComponent { + bool isDebugMode; + std::string shadersDirectory; + VulkanContext &vulkanContext; + + static void CheckShaderCompilation(glslang_shader_t *shader); + + bool CompileShader(glslang_stage_t stage, const char *pShaderCode, + ShaderModule *shaderModule) const; + + static glslang_stage_t ShaderStageFromFilename(const char *pFilename); + + static std::string ProcessIncludes(const std::string &input); + + static std::string ProcessShader(const std::string &file); + + public: + explicit ShaderService(const std::string &shadersDirectory, bool isDebugMode, VulkanContext &vulkanContext) : shadersDirectory( + shadersDirectory), isDebugMode(isDebugMode), vulkanContext(vulkanContext){} + + VkShaderModule createShaderModule(const std::string &pFilename); + }; +} // Metal + +#endif diff --git a/src/engine/service/StreamingService.h b/src/engine/service/StreamingService.h index d93c7568..649e650a 100644 --- a/src/engine/service/StreamingService.h +++ b/src/engine/service/StreamingService.h @@ -4,8 +4,7 @@ #include #include -#include "../../common/AbstractResourceService.h" -#include "../../common/AbstractCoreRepository.h" +#include "../../common/AbstractRuntimeComponent.h" using Clock = std::chrono::high_resolution_clock; using TimePoint = std::chrono::time_point; diff --git a/src/engine/util/ShaderUtil.h b/src/engine/util/ShaderUtil.h deleted file mode 100644 index 13f07699..00000000 --- a/src/engine/util/ShaderUtil.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef SHADERSERVICE_H -#define SHADERSERVICE_H -#include -#include -#include - -#include "../dto/ShaderModule.h" - -namespace Metal { - class ShaderUtil final { - static void CheckShaderCompilation(glslang_shader_t *shader); - - static bool CompileShader(glslang_stage_t stage, const char *pShaderCode, - ShaderModule *shaderModule); - - static glslang_stage_t ShaderStageFromFilename(const char *pFilename); - - static std::string ProcessIncludes(const std::string &input); - - static std::string ProcessShader(const std::string &file); - - public: - static VkShaderModule CreateShaderModule(const std::string &pFilename); - }; -} // Metal - -#endif From eaf331e0ce1ce29869f0aee7cbe609a4321213cd Mon Sep 17 00:00:00 2001 From: facobackup Date: Sat, 14 Mar 2026 12:20:52 -0300 Subject: [PATCH 05/11] Dependency injection --- CMakeLists.txt | 27 +-- src/ApplicationContext.cpp | 129 +++---------- src/ApplicationContext.h | 176 +++++------------- src/common/AbstractCoreRepository.h | 17 -- src/common/AbstractImporter.h | 8 +- src/common/AbstractResourceService.h | 4 +- src/common/AbstractRuntimeComponent.h | 17 -- src/common/Changeable.h | 28 --- src/{editor/util => common}/FileDialogUtil.h | 4 +- src/{editor/util => common}/FilesUtil.h | 2 +- src/common/IContextMember.cpp | 10 + src/common/IContextMember.h | 32 ++++ src/common/IDisposable.h | 10 + src/common/{Initializable.h => IInit.h} | 4 +- src/common/IRepository.h | 13 ++ .../{Serializable.cpp => ISerialize.cpp} | 8 +- src/common/{Serializable.h => ISerialize.h} | 4 +- src/common/IService.h | 11 ++ src/common/{Synchornizable.h => ISync.h} | 4 +- src/common/Inspectable.h | 21 ++- .../LogService.cpp => common/LoggerUtil.cpp} | 2 +- .../LogService.h => common/LoggerUtil.h} | 1 - src/common/serialization-definitions.h | 2 +- src/core/DirectoryService.cpp | 59 ++++++ src/core/DirectoryService.h | 54 ++++++ src/core/FrameService.cpp | 70 +++++++ src/core/FrameService.h | 43 +++++ src/core/glfw/GLFWContext.cpp | 2 +- src/core/glfw/GLFWContext.h | 21 +-- src/core/gui/GuiContext.cpp | 51 +++-- src/core/gui/GuiContext.h | 27 ++- src/core/vulkan/VulkanContext.cpp | 64 +++---- src/core/vulkan/VulkanContext.h | 42 +++-- src/core/vulkan/VulkanUtils.cpp | 2 +- src/editor/abstract/IPanel.h | 6 +- src/editor/dock-spaces/console/ConsolePanel.h | 2 +- .../dock-spaces/docks/DockSpacePanel.cpp | 2 +- src/editor/dock-spaces/files/FilesPanel.cpp | 4 +- src/editor/dto/EntryMetadata.h | 4 +- src/editor/dto/SceneData.h | 4 +- src/editor/dto/SceneEntityData.h | 2 +- src/editor/enum/EntryType.h | 2 +- src/editor/panel/FileImportModalPanel.cpp | 2 +- src/editor/repository/DockRepository.cpp | 25 --- src/editor/repository/DockRepository.h | 21 --- src/editor/repository/EditorRepository.h | 5 +- src/editor/service/AsyncTaskService.cpp | 2 +- src/editor/service/AsyncTaskService.h | 7 +- src/editor/service/DockService.cpp | 22 +++ src/editor/service/DockService.h | 16 +- src/editor/service/FileImporterService.cpp | 28 +-- src/editor/service/FileImporterService.h | 32 ++-- src/editor/service/FilesService.cpp | 5 +- src/editor/service/FilesService.h | 16 +- .../service/MaterialImporterService.cpp | 6 +- src/editor/service/MaterialImporterService.h | 14 +- src/editor/service/MeshImporterService.cpp | 7 +- src/editor/service/MeshImporterService.h | 12 +- src/editor/service/NotificationService.h | 3 +- src/editor/service/PickingService.cpp | 23 ++- src/editor/service/PickingService.h | 20 +- src/editor/service/SceneImporterService.cpp | 7 +- src/editor/service/SceneImporterService.h | 19 +- src/editor/service/SelectionService.cpp | 28 +-- src/editor/service/SelectionService.h | 15 +- src/editor/service/TextureImporterService.cpp | 8 +- src/editor/service/TextureImporterService.h | 9 +- src/editor/service/ThemeService.h | 15 +- src/editor/service/VoxelImporterService.cpp | 5 +- src/editor/service/VoxelImporterService.h | 10 +- src/engine/EngineContext.cpp | 42 ++--- src/engine/EngineContext.h | 61 +++--- src/engine/dto/BoundingBox.h | 4 +- src/engine/dto/Camera.h | 4 +- src/engine/dto/MetadataComponent.h | 4 +- src/engine/dto/PrimitiveComponent.h | 4 +- src/engine/dto/SparseVoxelOctreeData.h | 4 +- src/engine/dto/TileInfoUBO.h | 13 -- src/engine/dto/TransformComponent.h | 4 +- src/engine/dto/VolumeComponent.h | 4 +- .../frame-builder/EngineFrameBuilder.cpp | 12 +- src/engine/frame-builder/EngineFrameBuilder.h | 1 - src/engine/passes/AbstractPass.h | 5 +- src/engine/repository/EngineRepository.h | 6 +- src/engine/repository/RuntimeRepository.h | 3 +- src/engine/repository/WorldRepository.cpp | 9 +- src/engine/repository/WorldRepository.h | 30 ++- src/engine/service/BufferService.h | 7 +- src/engine/service/CameraService.cpp | 24 +-- src/engine/service/CameraService.h | 20 +- src/engine/service/DescriptorSetService.cpp | 53 +++--- src/engine/service/DescriptorSetService.h | 26 ++- src/engine/service/FrameBufferService.h | 7 +- src/engine/service/LightService.cpp | 13 +- src/engine/service/LightService.h | 18 +- src/engine/service/MaterialService.cpp | 13 +- src/engine/service/MaterialService.h | 13 +- src/engine/service/MeshService.cpp | 16 +- src/engine/service/MeshService.h | 20 +- src/engine/service/PipelineService.h | 21 +-- src/engine/service/RayTracingService.cpp | 9 +- src/engine/service/RayTracingService.h | 46 +++-- src/engine/service/ShaderService.cpp | 27 +-- src/engine/service/ShaderService.h | 25 ++- src/engine/service/StreamingService.cpp | 25 +-- src/engine/service/StreamingService.h | 26 ++- src/engine/service/TextureService.cpp | 2 +- src/engine/service/TextureService.h | 24 ++- src/engine/service/TransformService.cpp | 11 +- src/engine/service/TransformService.h | 20 +- src/engine/service/VolumeService.cpp | 16 +- src/engine/service/VolumeService.h | 18 +- src/main.cpp | 102 +++++++++- 113 files changed, 1214 insertions(+), 975 deletions(-) delete mode 100644 src/common/AbstractCoreRepository.h delete mode 100644 src/common/AbstractRuntimeComponent.h delete mode 100644 src/common/Changeable.h rename src/{editor/util => common}/FileDialogUtil.h (94%) rename src/{editor/util => common}/FilesUtil.h (98%) create mode 100644 src/common/IContextMember.cpp create mode 100644 src/common/IContextMember.h create mode 100644 src/common/IDisposable.h rename src/common/{Initializable.h => IInit.h} (69%) create mode 100644 src/common/IRepository.h rename src/common/{Serializable.cpp => ISerialize.cpp} (77%) rename src/common/{Serializable.h => ISerialize.h} (84%) create mode 100644 src/common/IService.h rename src/common/{Synchornizable.h => ISync.h} (69%) rename src/{editor/service/LogService.cpp => common/LoggerUtil.cpp} (98%) rename src/{editor/service/LogService.h => common/LoggerUtil.h} (95%) create mode 100644 src/core/DirectoryService.cpp create mode 100644 src/core/DirectoryService.h create mode 100644 src/core/FrameService.cpp create mode 100644 src/core/FrameService.h delete mode 100644 src/editor/repository/DockRepository.cpp delete mode 100644 src/editor/repository/DockRepository.h delete mode 100644 src/engine/dto/TileInfoUBO.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 50fc7887..3b165cea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ add_executable( src/ApplicationContext.h src/editor/abstract/AbstractPanel.h src/editor/abstract/AbstractPanel.cpp - src/common/Synchornizable.h + src/common/ISync.h src/engine/service/CameraService.cpp src/engine/service/CameraService.h src/engine/dto/Camera.h @@ -45,7 +45,6 @@ add_executable( src/editor/abstract/form/AccordionPanel.h src/common/FieldType.h src/common/InspectableMember.h - src/common/AbstractRuntimeComponent.h src/editor/abstract/form/types/BooleanField.cpp src/editor/abstract/form/types/BooleanField.h src/editor/abstract/form/types/IntField.cpp @@ -64,7 +63,6 @@ add_executable( src/common/Icons.h src/editor/service/DockService.cpp src/editor/service/DockService.h - src/editor/repository/DockRepository.h src/editor/dto/DockDTO.h src/editor/dto/DockSpace.h src/editor/dock-spaces/docks/DockSpacePanel.cpp @@ -84,8 +82,8 @@ add_executable( src/editor/dock-spaces/console/ConsolePanel.h src/editor/dock-spaces/metrics/MetricsPanel.cpp src/editor/dock-spaces/metrics/MetricsPanel.h - src/editor/service/LogService.cpp - src/editor/service/LogService.h + src/common/LoggerUtil.cpp + src/common/LoggerUtil.h src/editor/dock-spaces/world/WorldPanel.cpp src/editor/dock-spaces/world/WorldPanel.h src/engine/resource/RuntimeResource.h @@ -97,7 +95,6 @@ add_executable( src/engine/passes/AbstractRenderPass.h src/common/AbstractResourceService.h src/engine/resource/FrameBufferAttachment.h - src/common/AbstractCoreRepository.h src/engine/service/FrameBufferService.cpp src/engine/service/FrameBufferService.h src/engine/resource/FrameBufferInstance.h @@ -117,11 +114,11 @@ add_executable( src/engine/service/MeshService.h src/engine/dto/MeshData.h src/engine/resource/MeshInstance.h - src/editor/util/FilesUtil.h + src/common/FilesUtil.h src/editor/dto/FSEntry.h src/editor/enum/EntryType.h src/editor/dock-spaces/files/FilesContext.h - src/editor/util/FileDialogUtil.h + src/common/FileDialogUtil.h src/editor/dock-spaces/files/FilesHeaderPanel.cpp src/editor/dock-spaces/files/FilesHeaderPanel.h src/editor/service/MaterialImporterService.cpp @@ -223,7 +220,6 @@ add_executable( src/editor/service/PickingService.cpp src/editor/service/PickingService.h src/engine/resource/SVOInstance.h - src/engine/dto/TileInfoUBO.h src/engine/dto/LightData.h src/editor/passes/SelectionIDPass.cpp src/editor/passes/SelectionIDPass.h @@ -247,7 +243,7 @@ add_executable( src/engine/dto/VolumeData.h src/engine/service/VoxelService.cpp src/engine/service/VoxelService.h - src/common/Serializable.cpp + src/common/ISerialize.cpp src/editor/abstract/form/ChildPanel.cpp src/editor/abstract/form/ChildPanel.h src/editor/dto/SceneImportSettingsDTO.h @@ -269,7 +265,6 @@ add_executable( src/engine/dto/PipelineBuilder.cpp src/engine/service/DescriptorSetService.cpp src/engine/frame-builder/structures/CommandBufferRecorderBuilder.cpp - src/common/Changeable.h src/engine/passes/impl/TemporalAccumulationPass.cpp src/engine/passes/impl/TemporalAccumulationPass.h src/engine/passes/impl/SpatialFilterPass.cpp @@ -280,7 +275,15 @@ add_executable( src/editor/dock-spaces/repositories/RepositoriesPanel.h src/engine/service/VolumeService.cpp src/engine/service/VolumeService.h - src/editor/repository/DockRepository.cpp + src/common/IContextMember.h + src/common/IService.h + src/common/IRepository.h + src/common/IContextMember.cpp + src/core/DirectoryService.cpp + src/core/DirectoryService.h + src/common/IDisposable.h + src/core/FrameService.cpp + src/core/FrameService.h ) diff --git a/src/ApplicationContext.cpp b/src/ApplicationContext.cpp index 8c794998..a0cb05d3 100644 --- a/src/ApplicationContext.cpp +++ b/src/ApplicationContext.cpp @@ -1,125 +1,46 @@ #include "ApplicationContext.h" -#include -#include - -#include "editor/util/FilesUtil.h" -#include "core/vulkan/VulkanUtils.h" #include "common/serialization-definitions.h" +#include "common/LoggerUtil.h" -#include "editor/util/FileDialogUtil.h" -#include +#include "engine/EngineContext.h" +#include "core/glfw/GLFWContext.h" namespace Metal { + ApplicationContext *ApplicationContext::CONTEXT = nullptr; - void ApplicationContext::updateRootPath(bool forceSelection) { - std::string cachedPath; - std::string cachePathFile = std::filesystem::current_path().string() + CACHED_PATH; - FilesUtil::ReadFile(cachePathFile.c_str(), cachedPath); - cachedPath.erase(std::ranges::remove(cachedPath, '\n').begin(), cachedPath.cend()); - if (cachedPath.empty() || forceSelection || !fs::exists(cachedPath)) { - rootDirectory = FileDialogUtil::SelectDirectory(); - rootDirectory.erase(std::ranges::remove(rootDirectory, '\n').begin(), rootDirectory.cend()); - if (rootDirectory.empty()) { - throw std::runtime_error("No directory selected."); - } - save(); - FilesUtil::WriteFile(cachePathFile.c_str(), rootDirectory.c_str()); - } else { - rootDirectory = cachedPath; - } - PARSE_TEMPLATE(editorRepository, rootDirectory + "/" + HASH_OF_CLASS_NAME(EditorRepository) + ".json") - PARSE_TEMPLATE(engineRepository, rootDirectory + "/" + HASH_OF_CLASS_NAME(EngineRepository) + ".json") - PARSE_TEMPLATE(worldRepository, rootDirectory + "/" + HASH_OF_CLASS_NAME(WorldRepository) + ".json") + ApplicationContext::ApplicationContext(bool debugMode) : debugMode(debugMode) { + CONTEXT = this; + } + void ApplicationContext::onInitialize() { + for (auto &instance : instances) { + instance->setDependencies(*this); + } - FilesUtil::CreateDirectory(getShadersDirectory()); - FilesUtil::CreateDirectory(getAssetRefDirectory()); - FilesUtil::CreateDirectory(getAssetDirectory()); + for (auto &instance : instances) { + auto *init = dynamic_cast(instance.get()); + if (init) { + init->onInitialize(); + } + } } - unsigned int ApplicationContext::getFrameIndex() const { - return vulkanContext.imguiVulkanWindow.FrameIndex; + bool ApplicationContext::isDebugMode() const { + return debugMode; } void ApplicationContext::dispose() { - NFD_Quit(); try { - rayTracingService.destroyAccelerationStructures(); - asyncTaskService.endAll(); - engineContext.dispose(); - guiContext.dispose(); - vulkanContext.dispose(); - glfwContext.dispose(); - } catch (std::exception &e) { - std::cerr << e.what() << std::endl; - } - } - - void ApplicationContext::start() { - NFD_Init(); - - updateRootPath(false); - - glfwContext.onInitialize(); - if (!glfwContext.isValidContext()) { - throw std::runtime_error("Could not create window"); - } - vulkanContext.onInitialize(); - guiContext.onInitialize(); - filesService.onInitialize(); - editorPanel.applicationContext = this; - editorPanel.onInitialize(); - engineContext.onInitialize(); - - GLFWwindow *window = glfwContext.getWindow(); - while (!glfwWindowShouldClose(window)) { - if (glfwContext.beginFrame()) { - GuiContext::BeginFrame(); - editorPanel.onSync(); - ImGui::Render(); - auto *drawData = ImGui::GetDrawData(); - const bool main_is_minimized = (drawData->DisplaySize.x <= 0.0f || drawData->DisplaySize.y <= 0.0f); - if (!main_is_minimized) { - vulkanContext.getCommandBuffers().clear(); - auto &wd = vulkanContext.imguiVulkanWindow; - VkSemaphore imageAcquiredSemaphore = wd.FrameSemaphores[wd.SemaphoreIndex].ImageAcquiredSemaphore; - VkResult err = vkAcquireNextImageKHR(vulkanContext.device.device, wd.Swapchain, UINT64_MAX, - imageAcquiredSemaphore, VK_NULL_HANDLE, - &wd.FrameIndex); - if (err == VK_ERROR_OUT_OF_DATE_KHR || err == VK_SUBOPTIMAL_KHR) { - glfwContext.setSwapChainRebuild(true); - return; - } - - VulkanUtils::CheckVKResult(err); - ImGui_ImplVulkanH_Frame *fd = &wd.Frames[getFrameIndex()]; - VulkanUtils::CheckVKResult(vkWaitForFences(vulkanContext.device.device, 1, &fd->Fence, VK_TRUE, - UINT64_MAX)); - VulkanUtils::CheckVKResult(vkResetFences(vulkanContext.device.device, 1, &fd->Fence)); - VulkanUtils::CheckVKResult(vkResetCommandPool(vulkanContext.device.device, fd->CommandPool, - VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT)); - engineContext.onSync(); - GuiContext::RecordImguiCommandBuffer(drawData, err, wd, fd); - vulkanContext.submitFrame(imageAcquiredSemaphore, wd.FrameSemaphores[wd.SemaphoreIndex]. - RenderCompleteSemaphore, fd); + for (auto it = instances.rbegin(); it != instances.rend(); ++it) { + auto *disposable = dynamic_cast(it->get()); + if (disposable) { + disposable->dispose(); } - if (!main_is_minimized) - glfwContext.presentFrame(); + delete it->release(); } - } - dispose(); - } - - void ApplicationContext::save() { - try { - DUMP_TEMPLATE(rootDirectory + "/" + HASH_OF_CLASS_NAME(EditorRepository) + ".json", editorRepository) - DUMP_TEMPLATE(rootDirectory + "/" + HASH_OF_CLASS_NAME(EngineRepository) + ".json", engineRepository) - DUMP_TEMPLATE(rootDirectory + "/" + HASH_OF_CLASS_NAME(WorldRepository) + ".json", worldRepository) - notificationService.pushMessage("Project saved", NotificationSeverities::SUCCESS); - } catch (const std::exception &e) { + } catch (std::exception &e) { LOG_ERROR(e.what()); - notificationService.pushMessage("Could not save project", NotificationSeverities::ERROR); } } } diff --git a/src/ApplicationContext.h b/src/ApplicationContext.h index 78774aa7..0afd22a2 100644 --- a/src/ApplicationContext.h +++ b/src/ApplicationContext.h @@ -1,157 +1,65 @@ #ifndef METAL_ENGINE_APPLICATIONCONTEXT_H #define METAL_ENGINE_APPLICATIONCONTEXT_H -#define CACHED_PATH "/metal-engine-cached.txt" #include +#include +#include +#include +#include +#include +#include -#include "engine/EngineContext.h" -#include "core/glfw/GLFWContext.h" -#include "core/vulkan/VulkanContext.h" - -#include "engine/service/MeshService.h" -#include "engine/service/TextureService.h" -#include "engine/service/FrameBufferService.h" -#include "engine/service/PipelineService.h" -#include "engine/service/BufferService.h" -#include "engine/service/DescriptorSetService.h" -#include "editor/service/ThemeService.h" -#include "editor/service/DockService.h" -#include "editor/service/SelectionService.h" -#include "editor/service/SceneImporterService.h" -#include "editor/service/MeshImporterService.h" -#include "editor/service/MaterialImporterService.h" -#include "editor/service/TextureImporterService.h" -#include "editor/service/FilesService.h" -#include "editor/service/FileImporterService.h" -#include "engine/service/CameraService.h" - -#include "engine/repository/WorldRepository.h" -#include "engine/repository/RuntimeRepository.h" -#include "engine/service/StreamingService.h" -#include "engine/repository/EngineRepository.h" -#include "editor/repository/DockRepository.h" -#include "editor/repository/EditorRepository.h" -#include "engine/service/MaterialService.h" -#include "engine/service/CommandBufferRecorderService.h" -#include "editor/service/NotificationService.h" -#include "editor/service/AsyncTaskService.h" -#include "engine/service/TransformService.h" -#include "editor/service/PickingService.h" -#include "engine/service/VolumeService.h" -#include "editor/service/VoxelImporterService.h" -#include "engine/service/VoxelService.h" -#include "engine/service/LightService.h" -#include "engine/service/RayTracingService.h" -#include "editor/EditorPanel.h" -#include "core/gui/GuiContext.h" +#include "common/IInit.h" +#include "common/IContextMember.h" +#include "common/IDisposable.h" #define CTX ApplicationContext::CONTEXT +#define ENGINE_NAME "Metal Engine" + namespace Metal { - class ApplicationContext : public Initializable{ - EditorPanel editorPanel; - std::string rootDirectory; + namespace fs = std::filesystem; + class ApplicationContext : public IInit, public IDisposable { public: - static ApplicationContext CONTEXT; - - VulkanContext vulkanContext{ - true, - glfwContext, - engineRepository, - meshService, - textureService, - framebufferService, - pipelineService, - rayTracingService - }; - GuiContext guiContext{vulkanContext, glfwContext, descriptorSetService}; - GLFWContext glfwContext{}; - - EngineContext engineContext{ - transformService, - streamingService, - rayTracingService, - cameraService, - lightService, - volumeService, - worldRepository, - editorRepository, - engineRepository - }; - - // ----------- Repository - WorldRepository worldRepository{rayTracingService, rootDirectory}; - RuntimeRepository runtimeRepository{}; - EngineRepository engineRepository{}; - DockRepository dockRepository{}; - EditorRepository editorRepository{}; - - // ----------- Services - NotificationService notificationService; - AsyncTaskService asyncTaskService; - BufferService bufferService{vulkanContext}; - FrameBufferService framebufferService{vulkanContext}; - ThemeService themeService{editorRepository}; - DockService dockService{dockRepository}; - DescriptorSetService descriptorSetService{vulkanContext, framebufferService, bufferService, textureService}; - SelectionService selectionService{editorRepository, worldRepository}; - VoxelImporterService voxelImporterService{rootDirectory}; - MeshImporterService meshImporterService{rootDirectory}; - TextureImporterService textureImporter{rootDirectory}; - MaterialImporterService materialImporterService{textureImporter, rootDirectory}; - SceneImporterService sceneImporterService{meshImporterService, materialImporterService, rootDirectory}; - FilesService filesService{rootDirectory, notificationService}; - FileImporterService fileImporterService{ - sceneImporterService, textureImporter, voxelImporterService, notificationService, asyncTaskService - }; - CameraService cameraService{engineContext, worldRepository, runtimeRepository}; - PickingService pickingService{vulkanContext, bufferService, worldRepository}; - TransformService transformService{worldRepository, rayTracingService}; - LightService lightService{engineContext, engineRepository}; - VolumeService volumeService{worldRepository, engineContext}; - RayTracingService rayTracingService{ - vulkanContext, pipelineService, worldRepository, meshService, materialService, bufferService, engineContext - }; - CommandBufferRecorderService commandBufferRecorderService{}; - VoxelService voxelService{}; - StreamingService streamingService{engineContext, worldRepository, meshService, textureService, voxelService}; - // ----------- Services - // ----------- Repository - - [[nodiscard]] bool isDebugMode() const { return true; } + static ApplicationContext *CONTEXT; - void updateRootPath(bool forceSelection); + private: + std::unordered_map singletons; + std::vector > instances; + bool debugMode; - [[nodiscard]] bool isValidContext() const { - return glfwContext.isValidContext(); - } + public: + explicit ApplicationContext(bool debugMode); - [[nodiscard]] const std::string &getRootDirectory() const { - return rootDirectory; - } + void onInitialize() override; - [[nodiscard]] std::string getAssetRefDirectory() const { - return rootDirectory + "/assets-ref/"; + template + void registerSingleton(std::unique_ptr instance) { + static_assert(std::is_base_of_v, "T must derive from IContextMember"); + T *ptr = instance.get(); + singletons[typeid(T).name()] = static_cast(ptr); + instances.push_back(std::move(instance)); } - [[nodiscard]] std::string getShadersDirectory() const { - return rootDirectory + "/shaders/"; + template + T &getSingleton() { + auto it = singletons.find(typeid(T).name()); + if (it == singletons.end()) { + throw std::runtime_error(std::string("Singleton not registered: ") + typeid(T).name()); + } + return *static_cast(it->second); } - [[nodiscard]] std::string getAssetDirectory() const { - return rootDirectory + "/assets/"; + void *getSingletonByName(const std::string &name) { + auto it = singletons.find(name); + if (it == singletons.end()) { + throw std::runtime_error(std::string("Singleton not registered: ") + name); + } + return it->second; } - [[nodiscard]] std::string getVideoOutputPath() const { - return rootDirectory + "/output.mp4"; - } - - [[nodiscard]] unsigned int getFrameIndex() const; - - void dispose(); - - void start(); + [[nodiscard]] bool isDebugMode() const; - void save(); + void dispose() override; }; } diff --git a/src/common/AbstractCoreRepository.h b/src/common/AbstractCoreRepository.h deleted file mode 100644 index 93631a01..00000000 --- a/src/common/AbstractCoreRepository.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef ABSTRACTCOREREPOSITORY_H -#define ABSTRACTCOREREPOSITORY_H -#include "AbstractRuntimeComponent.h" - -namespace Metal { - class VulkanContext; - class FrameBufferService; - class BufferService; - class PipelineService; - - class AbstractCoreRepository : public AbstractRuntimeComponent { - }; - - -} // Metal - -#endif //ABSTRACTCOREREPOSITORY_H diff --git a/src/common/AbstractImporter.h b/src/common/AbstractImporter.h index 3507b6b9..ca3dbde0 100644 --- a/src/common/AbstractImporter.h +++ b/src/common/AbstractImporter.h @@ -5,19 +5,15 @@ #include #include "../editor/dto/ImportSettingsDTO.h" -#include "AbstractRuntimeComponent.h" +#include "IService.h" namespace Metal { - class AbstractImporter : public AbstractRuntimeComponent { + class AbstractImporter : public IService { public: virtual std::vector getSupportedTypes() { return {}; } - explicit AbstractImporter() - : AbstractRuntimeComponent() { - } - virtual std::string importData(const std::string &targetDir, const std::string &pathToFile, const std::shared_ptr &settings, const std::stop_token &stopToken) { diff --git a/src/common/AbstractResourceService.h b/src/common/AbstractResourceService.h index 25ad1072..a2e05ce3 100644 --- a/src/common/AbstractResourceService.h +++ b/src/common/AbstractResourceService.h @@ -4,14 +4,14 @@ #include #include -#include "AbstractRuntimeComponent.h" +#include "IService.h" #include "../engine/resource/RuntimeResource.h" namespace Metal { class VulkanContext; template - class AbstractResourceService : public AbstractRuntimeComponent { + class AbstractResourceService : public IService { static_assert(std::is_base_of_v, "T must be a subclass of RuntimeResource"); protected: diff --git a/src/common/AbstractRuntimeComponent.h b/src/common/AbstractRuntimeComponent.h deleted file mode 100644 index f2b753b1..00000000 --- a/src/common/AbstractRuntimeComponent.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef METAL_ENGINE_ABSTRACTRUNTIMECOMPONENT_H -#define METAL_ENGINE_ABSTRACTRUNTIMECOMPONENT_H - -#include "Changeable.h" -#include "Initializable.h" -#include "Synchornizable.h" - -#define ENGINE_NAME "Metal Engine" - -namespace Metal { - class AbstractRuntimeComponent : public Changeable, public Syncronizable, public Initializable { - public: - explicit AbstractRuntimeComponent() = default; - }; -} - -#endif diff --git a/src/common/Changeable.h b/src/common/Changeable.h deleted file mode 100644 index 8ce78c2b..00000000 --- a/src/common/Changeable.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef CHANGEABLE_H -#define CHANGEABLE_H - -namespace Metal { - class Changeable { - protected: - unsigned long changes = 0; - unsigned long frozenVersion = 99999; - - public: - [[nodiscard]] unsigned long getChangeId() const { - return changes; - } - - void registerChange() { - changes++; - } - - [[nodiscard]] bool isNotFrozen() const { - return frozenVersion != getChangeId(); - } - - void freezeVersion() { - frozenVersion = getChangeId(); - } - }; -} -#endif diff --git a/src/editor/util/FileDialogUtil.h b/src/common/FileDialogUtil.h similarity index 94% rename from src/editor/util/FileDialogUtil.h rename to src/common/FileDialogUtil.h index 39b4b9e3..205c261a 100644 --- a/src/editor/util/FileDialogUtil.h +++ b/src/common/FileDialogUtil.h @@ -3,8 +3,8 @@ #include #include #include -#include "../service/LogService.h" -#include "../../ApplicationContext.h" +#include "LoggerUtil.h" +#include "../ApplicationContext.h" namespace Metal:: FileDialogUtil { static std::vector PickFiles(std::vector filtersToApply) { diff --git a/src/editor/util/FilesUtil.h b/src/common/FilesUtil.h similarity index 98% rename from src/editor/util/FilesUtil.h rename to src/common/FilesUtil.h index 37aa80df..811fcf54 100644 --- a/src/editor/util/FilesUtil.h +++ b/src/common/FilesUtil.h @@ -2,7 +2,7 @@ #define FILESUTIL_H #include #include -#include "../dto/FSEntry.h" +#include "../editor/dto/FSEntry.h" namespace fs = std::filesystem; diff --git a/src/common/IContextMember.cpp b/src/common/IContextMember.cpp new file mode 100644 index 00000000..f42b28ce --- /dev/null +++ b/src/common/IContextMember.cpp @@ -0,0 +1,10 @@ +#include "IContextMember.h" +#include "../ApplicationContext.h" + +namespace Metal { + void IContextMember::setDependencies(ApplicationContext &ctx) { + for (auto &dep : getDependencies()) { + dep.ptr = ctx.getSingletonByName(dep.name); + } + } +} diff --git a/src/common/IContextMember.h b/src/common/IContextMember.h new file mode 100644 index 00000000..1226a4fc --- /dev/null +++ b/src/common/IContextMember.h @@ -0,0 +1,32 @@ +#ifndef METAL_ENGINE_CONTEXTMEMBER_H +#define METAL_ENGINE_CONTEXTMEMBER_H +#include +#include + +namespace Metal { + class ApplicationContext; + + struct Dependency { + std::string name; + void *ptr; + }; + + class IContextMember { + public: + virtual ~IContextMember() = default; + + /** + * Dependency injection. Called after all the context is created and + * will be the data used to initialize the pointers + */ + virtual std::vector getDependencies() { + return {}; + } + + /** + * Will call getDependencies and set the pointers based on the singletons returned + */ + void setDependencies(ApplicationContext &ctx); + }; +} +#endif //METAL_ENGINE_CONTEXTMEMBER_H diff --git a/src/common/IDisposable.h b/src/common/IDisposable.h new file mode 100644 index 00000000..e68d55ea --- /dev/null +++ b/src/common/IDisposable.h @@ -0,0 +1,10 @@ +#ifndef METAL_ENGINE_IDISPOSABLE_H +#define METAL_ENGINE_IDISPOSABLE_H +namespace Metal { + class IDisposable { + public: + virtual ~IDisposable() = default; + virtual void dispose() = 0; + }; +} +#endif \ No newline at end of file diff --git a/src/common/Initializable.h b/src/common/IInit.h similarity index 69% rename from src/common/Initializable.h rename to src/common/IInit.h index 3a3c44bb..93b6bfbd 100644 --- a/src/common/Initializable.h +++ b/src/common/IInit.h @@ -2,9 +2,9 @@ #define METAL_ENGINE_INITIALIZABLE_H namespace Metal { - class Initializable { + class IInit { public: - virtual ~Initializable() = default; + virtual ~IInit() = default; virtual void onInitialize() {} }; diff --git a/src/common/IRepository.h b/src/common/IRepository.h new file mode 100644 index 00000000..88576aad --- /dev/null +++ b/src/common/IRepository.h @@ -0,0 +1,13 @@ +#ifndef METAL_ENGINE_IREPOSITORY_H +#define METAL_ENGINE_IREPOSITORY_H +#include "IContextMember.h" +#include "Inspectable.h" +#include "ISerialize.h" + +namespace Metal { + class IRepository : public IContextMember, public Inspectable, public ISerialize { + public: + virtual ~IRepository() = default; + }; +} +#endif //METAL_ENGINE_IREPOSITORY_H diff --git a/src/common/Serializable.cpp b/src/common/ISerialize.cpp similarity index 77% rename from src/common/Serializable.cpp rename to src/common/ISerialize.cpp index c9a08f3d..192b3bfb 100644 --- a/src/common/Serializable.cpp +++ b/src/common/ISerialize.cpp @@ -1,19 +1,19 @@ -#include "Serializable.h" +#include "ISerialize.h" #include "../ApplicationContext.h" #include #include #include -#include "../editor/service/LogService.h" +#include "LoggerUtil.h" namespace Metal { - void Serializable::saveToJson(const std::string &path) const { + void ISerialize::saveToJson(const std::string &path) const { std::ofstream os(path); if (os.is_open()) { os << toJson().dump(4); } } - void Serializable::loadFromJson(const std::string &path) { + void ISerialize::loadFromJson(const std::string &path) { if (std::filesystem::exists(path)) { std::ifstream is(path); if (is.is_open()) { diff --git a/src/common/Serializable.h b/src/common/ISerialize.h similarity index 84% rename from src/common/Serializable.h rename to src/common/ISerialize.h index b98f673f..d40b4922 100644 --- a/src/common/Serializable.h +++ b/src/common/ISerialize.h @@ -4,9 +4,9 @@ #include namespace Metal { - class Serializable { + class ISerialize { public: - virtual ~Serializable() = default; + virtual ~ISerialize() = default; virtual nlohmann::json toJson() const = 0; diff --git a/src/common/IService.h b/src/common/IService.h new file mode 100644 index 00000000..c880c173 --- /dev/null +++ b/src/common/IService.h @@ -0,0 +1,11 @@ +#ifndef METAL_ENGINE_ISERVICE_H +#define METAL_ENGINE_ISERVICE_H +#include "IContextMember.h" + +namespace Metal { + class IService : public IContextMember { + public: + virtual ~IService() = default; + }; +} +#endif //METAL_ENGINE_ISERVICE_H diff --git a/src/common/Synchornizable.h b/src/common/ISync.h similarity index 69% rename from src/common/Synchornizable.h rename to src/common/ISync.h index d5640524..9cd8af3f 100644 --- a/src/common/Synchornizable.h +++ b/src/common/ISync.h @@ -2,9 +2,9 @@ #define METAL_ENGINE_SYNCHORNIZABLE_H namespace Metal { - class Syncronizable { + class ISync { public: - virtual ~Syncronizable() = default; + virtual ~ISync() = default; virtual void onSync() {} }; diff --git a/src/common/Inspectable.h b/src/common/Inspectable.h index 3c300946..e5990746 100644 --- a/src/common/Inspectable.h +++ b/src/common/Inspectable.h @@ -9,13 +9,14 @@ #include "InspectableMember.h" #include "../editor/util/Util.h" #include "../editor/enum/EntryType.h" -#include "Changeable.h" namespace Metal { - class Inspectable : public Changeable { + class Inspectable { std::string uniqueIdentifier = Util::uuidV4(); std::vector > fields{}; bool fieldsRegistered = false; + unsigned long changes = 0; + unsigned long frozenVersion = 99999; public: Inspectable &operator=(const Inspectable &other) { @@ -87,6 +88,22 @@ namespace Metal { std::string group, std::string name, bool disabled = false); public: + [[nodiscard]] unsigned long getChangeId() const { + return changes; + } + + void registerChange() { + changes++; + } + + [[nodiscard]] bool isNotFrozen() const { + return frozenVersion != getChangeId(); + } + + void freezeVersion() { + frozenVersion = getChangeId(); + } + std::vector > &getFields(); Inspectable() = default; diff --git a/src/editor/service/LogService.cpp b/src/common/LoggerUtil.cpp similarity index 98% rename from src/editor/service/LogService.cpp rename to src/common/LoggerUtil.cpp index c0d5cb41..9f8871cb 100644 --- a/src/editor/service/LogService.cpp +++ b/src/common/LoggerUtil.cpp @@ -1,4 +1,4 @@ -#include "LogService.h" +#include "LoggerUtil.h" #include #include #include diff --git a/src/editor/service/LogService.h b/src/common/LoggerUtil.h similarity index 95% rename from src/editor/service/LogService.h rename to src/common/LoggerUtil.h index 756e30c4..be198cc3 100644 --- a/src/editor/service/LogService.h +++ b/src/common/LoggerUtil.h @@ -4,7 +4,6 @@ #include #include #include -#include "../../common/AbstractRuntimeComponent.h" namespace Metal { diff --git a/src/common/serialization-definitions.h b/src/common/serialization-definitions.h index eab3426b..1a70f527 100644 --- a/src/common/serialization-definitions.h +++ b/src/common/serialization-definitions.h @@ -3,7 +3,7 @@ #include #include -#include "Serializable.h" +#include "ISerialize.h" #include #include #include diff --git a/src/core/DirectoryService.cpp b/src/core/DirectoryService.cpp new file mode 100644 index 00000000..785e1d45 --- /dev/null +++ b/src/core/DirectoryService.cpp @@ -0,0 +1,59 @@ +#include "DirectoryService.h" +#include "../common/FileDialogUtil.h" +#include "../common/FilesUtil.h" +#include "../common/serialization-definitions.h" + +#include +#define CACHED_PATH "/metal-engine-cached.txt" +#include "../editor/repository/EditorRepository.h" +#include "../editor/service/NotificationService.h" +#include "../engine/repository/EngineRepository.h" +#include "../engine/repository/WorldRepository.h" + +namespace Metal { + void DirectoryService::updateRootPath(bool forceSelection) { + std::string cachedPath; + std::string cachePathFile = std::filesystem::current_path().string() + CACHED_PATH; + FilesUtil::ReadFile(cachePathFile.c_str(), cachedPath); + cachedPath.erase(std::ranges::remove(cachedPath, '\n').begin(), cachedPath.cend()); + if (cachedPath.empty() || forceSelection || !fs::exists(cachedPath)) { + rootDirectory = FileDialogUtil::SelectDirectory(); + rootDirectory.erase(std::ranges::remove(rootDirectory, '\n').begin(), rootDirectory.cend()); + if (rootDirectory.empty()) { + throw std::runtime_error("No directory selected."); + } + save(); + FilesUtil::WriteFile(cachePathFile.c_str(), rootDirectory.c_str()); + } else { + rootDirectory = cachedPath; + } + + // TODO - LOOP REPOSITORY SINGLETONS AND CALL + PARSE_TEMPLATE(*editorRepository, rootDirectory + "/" + HASH_OF_CLASS_NAME(EditorRepository) + ".json") + PARSE_TEMPLATE(*engineRepository, rootDirectory + "/" + HASH_OF_CLASS_NAME(EngineRepository) + ".json") + PARSE_TEMPLATE(*worldRepository, rootDirectory + "/" + HASH_OF_CLASS_NAME(WorldRepository) + ".json") + + + FilesUtil::CreateDirectory(getShadersDirectory()); + FilesUtil::CreateDirectory(getAssetRefDirectory()); + FilesUtil::CreateDirectory(getAssetDirectory()); + } + + + void DirectoryService::save() { + try { + // TODO - LOOP REPOSITORY SINGLETONS AND CALL + + DUMP_TEMPLATE(rootDirectory + "/" + HASH_OF_CLASS_NAME(EditorRepository) + ".json", + *editorRepository) + DUMP_TEMPLATE(rootDirectory + "/" + HASH_OF_CLASS_NAME(EngineRepository) + ".json", + *engineRepository) + DUMP_TEMPLATE(rootDirectory + "/" + HASH_OF_CLASS_NAME(WorldRepository) + ".json", + *worldRepository) + notificationService->pushMessage("Project saved", NotificationSeverities::SUCCESS); + } catch (const std::exception &e) { + LOG_ERROR(e.what()); + notificationService->pushMessage("Could not save project", NotificationSeverities::ERROR); + } + } +} // Metal diff --git a/src/core/DirectoryService.h b/src/core/DirectoryService.h new file mode 100644 index 00000000..a02b1339 --- /dev/null +++ b/src/core/DirectoryService.h @@ -0,0 +1,54 @@ +#ifndef METAL_ENGINE_DIRECTORYSERVICE_H +#define METAL_ENGINE_DIRECTORYSERVICE_H +#include "../common/IService.h" + +namespace Metal { + struct EditorRepository; + struct EngineRepository; + struct WorldRepository; + class NotificationService; + + struct DirectoryService final : IService { + EditorRepository *editorRepository = nullptr; + EngineRepository *engineRepository = nullptr; + WorldRepository *worldRepository = nullptr; + NotificationService *notificationService = nullptr; + + std::string rootDirectory; + + std::vector getDependencies() override { + return { + {"EditorRepository", editorRepository}, + {"EngineRepository", engineRepository}, + {"WorldRepository", worldRepository}, + {"NotificationService", notificationService} + }; + } + + void updateRootPath(bool forceSelection); + + void save(); + + [[nodiscard]] const std::string &getRootDirectory() const { + return rootDirectory; + } + + [[nodiscard]] std::string getAssetRefDirectory() const { + return rootDirectory + "/assets-ref/"; + } + + [[nodiscard]] std::string getShadersDirectory() const { + return rootDirectory + "/shaders/"; + } + + [[nodiscard]] std::string getAssetDirectory() const { + return rootDirectory + "/assets/"; + } + + [[nodiscard]] std::string getVideoOutputPath() const { + return rootDirectory + "/output.mp4"; + } + }; +} // Metal + +#endif //METAL_ENGINE_DIRECTORYSERVICE_H diff --git a/src/core/FrameService.cpp b/src/core/FrameService.cpp new file mode 100644 index 00000000..48b35d6d --- /dev/null +++ b/src/core/FrameService.cpp @@ -0,0 +1,70 @@ +#include "FrameService.h" + +#include +#include + +#include "gui/GuiContext.h" +#include "vulkan/VulkanContext.h" +#include "glfw/GLFWContext.h" +#include "../editor/abstract/AbstractPanel.h" +#include "../engine/EngineContext.h" +#include "vulkan/VulkanUtils.h" + +namespace Metal { + unsigned int FrameService::getFrameIndex() const { + return vulkanContext->imguiVulkanWindow.FrameIndex; + } + + void FrameService::dispose() { + NFD_Quit(); + } + + bool FrameService::isValidContext() const { + return glfwContext->isValidContext(); + } + + void FrameService::setPanel(AbstractPanel *panel) { + this->panel = panel; + } + + void FrameService::onInitialize() { + NFD_Init(); + + GLFWwindow *window = glfwContext->getWindow(); + while (!glfwWindowShouldClose(window)) { + if (glfwContext->beginFrame()) { + GuiContext::BeginFrame(); + panel->onSync(); + ImGui::Render(); + auto *drawData = ImGui::GetDrawData(); + const bool main_is_minimized = (drawData->DisplaySize.x <= 0.0f || drawData->DisplaySize.y <= 0.0f); + if (!main_is_minimized) { + vulkanContext->getCommandBuffers().clear(); + auto &wd = vulkanContext->imguiVulkanWindow; + VkSemaphore imageAcquiredSemaphore = wd.FrameSemaphores[wd.SemaphoreIndex].ImageAcquiredSemaphore; + VkResult err = vkAcquireNextImageKHR(vulkanContext->device.device, wd.Swapchain, UINT64_MAX, + imageAcquiredSemaphore, VK_NULL_HANDLE, + &wd.FrameIndex); + if (err == VK_ERROR_OUT_OF_DATE_KHR || err == VK_SUBOPTIMAL_KHR) { + glfwContext->setSwapChainRebuild(true); + return; + } + + VulkanUtils::CheckVKResult(err); + ImGui_ImplVulkanH_Frame *fd = &wd.Frames[getFrameIndex()]; + VulkanUtils::CheckVKResult(vkWaitForFences(vulkanContext->device.device, 1, &fd->Fence, VK_TRUE, + UINT64_MAX)); + VulkanUtils::CheckVKResult(vkResetFences(vulkanContext->device.device, 1, &fd->Fence)); + VulkanUtils::CheckVKResult(vkResetCommandPool(vulkanContext->device.device, fd->CommandPool, + VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT)); + engineContext->onSync(); + GuiContext::RecordImguiCommandBuffer(drawData, err, wd, fd); + vulkanContext->submitFrame(imageAcquiredSemaphore, wd.FrameSemaphores[wd.SemaphoreIndex]. + RenderCompleteSemaphore, fd); + } + if (!main_is_minimized) + glfwContext->presentFrame(); + } + } + } +} // Metal diff --git a/src/core/FrameService.h b/src/core/FrameService.h new file mode 100644 index 00000000..d00287f1 --- /dev/null +++ b/src/core/FrameService.h @@ -0,0 +1,43 @@ +#ifndef METAL_ENGINE_FRAMESERVICE_H +#define METAL_ENGINE_FRAMESERVICE_H +#include "../common/IDisposable.h" +#include "../common/IInit.h" +#include "../common/IService.h" + +namespace Metal { + class EngineContext; + class VulkanContext; + class GLFWContext; + class GuiContext; + class AbstractPanel; + + class FrameService final : public IService, public IInit, public IDisposable { + GLFWContext *glfwContext = nullptr; + VulkanContext *vulkanContext = nullptr; + EngineContext *engineContext = nullptr; + GuiContext *guiContext = nullptr; + AbstractPanel *panel = nullptr; + + public: + std::vector getDependencies() override { + return { + {"GLFWContext", glfwContext}, + {"VulkanContext", vulkanContext}, + {"GuiContext", guiContext}, + {"EngineContext", engineContext} + }; + } + + void setPanel(AbstractPanel *panel); + + void onInitialize() override; + + [[nodiscard]] bool isValidContext() const; + + [[nodiscard]] unsigned int getFrameIndex() const; + + void dispose() override; + }; +} // Metal + +#endif //METAL_ENGINE_FRAMESERVICE_H diff --git a/src/core/glfw/GLFWContext.cpp b/src/core/glfw/GLFWContext.cpp index 4c489631..ae539bb5 100644 --- a/src/core/glfw/GLFWContext.cpp +++ b/src/core/glfw/GLFWContext.cpp @@ -42,7 +42,7 @@ namespace Metal { return true; } - void GLFWContext::dispose() const { + void GLFWContext::dispose() { glfwDestroyWindow(window); glfwTerminate(); } diff --git a/src/core/glfw/GLFWContext.h b/src/core/glfw/GLFWContext.h index 01ac63cb..0f4b06d4 100644 --- a/src/core/glfw/GLFWContext.h +++ b/src/core/glfw/GLFWContext.h @@ -6,31 +6,34 @@ #include #include -#include "../../common/AbstractRuntimeComponent.h" + +#include "../../common/IContextMember.h" +#include "../../common/IDisposable.h" +#include "../../common/IInit.h" struct ImGui_ImplVulkanH_Window; namespace Metal { class ApplicationContext; - class VulkanContext; - class GLFWContext final : public Initializable { + class GLFWContext final : public IContextMember, public IInit, public IDisposable { VulkanContext *vulkanContext = nullptr; GLFWwindow *window = nullptr; bool validContext = true; - ; bool swapChainRebuild = false; ImVector instance_extensions{}; public: + std::vector getDependencies() override { + return {{"VulkanContext", vulkanContext}}; + } + void setSwapChainRebuild(bool val); void presentFrame(); - explicit GLFWContext() = default; - [[nodiscard]] const ImVector &getInstanceExtensions() const; void onInitialize() override; @@ -41,13 +44,9 @@ namespace Metal { bool beginFrame(); - void dispose() const; + void dispose() override; [[nodiscard]] ImGui_ImplVulkanH_Window &getGUIWindow() const; - - void setVulkanContext(VulkanContext *vulkanContext) { - this->vulkanContext = vulkanContext; - } }; } diff --git a/src/core/gui/GuiContext.cpp b/src/core/gui/GuiContext.cpp index b92bfff5..ab84174b 100644 --- a/src/core/gui/GuiContext.cpp +++ b/src/core/gui/GuiContext.cpp @@ -7,17 +7,16 @@ #include "../../engine/dto/DescriptorInstance.h" #include "../../engine/resource/TextureInstance.h" -namespace Metal { - #include "../vulkan/VulkanContext.h" - #include "../glfw/GLFWContext.h" - #include "../../engine/service/DescriptorSetService.h" +#include "../vulkan/VulkanContext.h" +#include "../glfw/GLFWContext.h" +#include "../../engine/service/DescriptorSetService.h" +namespace Metal { void GuiContext::endFrame() { - } void GuiContext::renderImage(TextureInstance *texture, const float sizeX, const float sizeY) const { - descriptorSetService.setImageDescriptor(texture); + descriptorSetService->setImageDescriptor(texture); ImGui::Image(reinterpret_cast(texture->imageDescriptor->vkDescriptorSet), ImVec2{sizeX, sizeY}); } @@ -33,7 +32,8 @@ namespace Metal { info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; err = vkBeginCommandBuffer(fd->CommandBuffer, &info); - VulkanUtils::CheckVKResult(err); { + VulkanUtils::CheckVKResult(err); + { VkRenderPassBeginInfo info = {}; info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; info.renderPass = wd.RenderPass; @@ -65,19 +65,19 @@ namespace Metal { io.ConfigWindowsResizeFromEdges = true; // Setup Platform/Renderer backends - ImGui_ImplGlfw_InitForVulkan(glfwContext.getWindow(), true); + ImGui_ImplGlfw_InitForVulkan(glfwContext->getWindow(), true); ImGui_ImplVulkan_InitInfo init_info = {}; - init_info.Instance = vulkanContext.instance.instance; - init_info.PhysicalDevice = vulkanContext.physDevice.physical_device; - init_info.Device = vulkanContext.device.device; - init_info.QueueFamily = vulkanContext.queueFamily; - init_info.Queue = vulkanContext.graphicsQueue; - init_info.PipelineCache = vulkanContext.pipelineCache; - init_info.DescriptorPool = vulkanContext.descriptorPool; - init_info.RenderPass = vulkanContext.imguiVulkanWindow.RenderPass; + init_info.Instance = vulkanContext->instance.instance; + init_info.PhysicalDevice = vulkanContext->physDevice.physical_device; + init_info.Device = vulkanContext->device.device; + init_info.QueueFamily = vulkanContext->queueFamily; + init_info.Queue = vulkanContext->graphicsQueue; + init_info.PipelineCache = vulkanContext->pipelineCache; + init_info.DescriptorPool = vulkanContext->descriptorPool; + init_info.RenderPass = vulkanContext->imguiVulkanWindow.RenderPass; init_info.Subpass = 0; init_info.MinImageCount = MAX_FRAMES_IN_FLIGHT; - init_info.ImageCount = vulkanContext.imguiVulkanWindow.ImageCount; + init_info.ImageCount = vulkanContext->imguiVulkanWindow.ImageCount; init_info.MSAASamples = VK_SAMPLE_COUNT_1_BIT; init_info.Allocator = nullptr; init_info.CheckVkResultFn = VulkanUtils::CheckVKResult; @@ -140,23 +140,14 @@ namespace Metal { delete fontConfig; } - void GuiContext::dispose() const { - const VkResult err = vkDeviceWaitIdle(vulkanContext.device.device); + void GuiContext::dispose() { + const VkResult err = vkDeviceWaitIdle(vulkanContext->device.device); VulkanUtils::CheckVKResult(err); ImGui_ImplVulkan_Shutdown(); ImGui_ImplGlfw_Shutdown(); ImGui::DestroyContext(); - ImGui_ImplVulkanH_DestroyWindow(vulkanContext.instance, vulkanContext.device.device, - &glfwContext.getGUIWindow(), + ImGui_ImplVulkanH_DestroyWindow(vulkanContext->instance.instance, vulkanContext->device.device, + &glfwContext->getGUIWindow(), nullptr); } - - GuiContext::GuiContext(VulkanContext &vulkanContext, - GLFWContext &glfwContext, - DescriptorSetService &descriptorSetService) - : AbstractRuntimeComponent(), - vulkanContext(vulkanContext), - glfwContext(glfwContext), - descriptorSetService(descriptorSetService) { - } } diff --git a/src/core/gui/GuiContext.h b/src/core/gui/GuiContext.h index 5324f944..5c117b02 100644 --- a/src/core/gui/GuiContext.h +++ b/src/core/gui/GuiContext.h @@ -4,19 +4,22 @@ #define LARGE_FONT_SIZE 38 #include #include -#include "../../common/AbstractRuntimeComponent.h" +#include "../../common/IService.h" +#include "../../common/IDisposable.h" +#include "../../common/IInit.h" namespace Metal { + class GLFWContext; struct FrameBufferAttachment; struct TextureInstance; class VulkanContext; class DescriptorSetService; - class GuiContext final : public AbstractRuntimeComponent { - VulkanContext &vulkanContext; - GLFWContext &glfwContext; - DescriptorSetService &descriptorSetService; + class GuiContext final : public IService, public IDisposable, public IInit { + VulkanContext *vulkanContext = nullptr; + GLFWContext *glfwContext = nullptr; + DescriptorSetService *descriptorSetService = nullptr; static void applySpacing(); @@ -26,15 +29,21 @@ namespace Metal { ImFont *largeIconsFont = nullptr; public: - explicit GuiContext(VulkanContext &vulkanContext, - GLFWContext &glfwContext, - DescriptorSetService &descriptorSetService); + GuiContext() = default; + + std::vector getDependencies() override { + return { + {"VulkanContext", vulkanContext}, + {"GLFWContext", glfwContext}, + {"DescriptorSetService", descriptorSetService} + }; + } [[ nodiscard]] ImFont *getLargeIconsFont() const { return largeIconsFont; } - void dispose() const; + void dispose() override; void onInitialize() override; diff --git a/src/core/vulkan/VulkanContext.cpp b/src/core/vulkan/VulkanContext.cpp index 9480dbda..4c38039e 100644 --- a/src/core/vulkan/VulkanContext.cpp +++ b/src/core/vulkan/VulkanContext.cpp @@ -2,27 +2,17 @@ #include "VkBootstrap.h" #include "VulkanUtils.h" #include "../../ApplicationContext.h" -#include "../../editor/service/LogService.h" +#include "../../common/LoggerUtil.h" + +#include "../glfw/GLFWContext.h" +#include "../../engine/repository/EngineRepository.h" +#include "../../engine/service/MeshService.h" +#include "../../engine/service/TextureService.h" +#include "../../engine/service/FrameBufferService.h" +#include "../../engine/service/PipelineService.h" +#include "../../engine/service/RayTracingService.h" namespace Metal { - VulkanContext::VulkanContext(bool debugMode, - GLFWContext &glfwContext, - EngineRepository &engineRepository, - MeshService &meshService, - TextureService &textureService, - FrameBufferService &framebufferService, - PipelineService &pipelineService, - RayTracingService &rayTracingService) - : AbstractRuntimeComponent(), - glfwContext(glfwContext), - engineRepository(engineRepository), - meshService(meshService), - textureService(textureService), - framebufferService(framebufferService), - pipelineService(pipelineService), - rayTracingService(rayTracingService), - debugMode(debugMode) { - } void VulkanContext::createSwapChain() { int w{}, h{}; @@ -177,7 +167,7 @@ namespace Metal { } void VulkanContext::createPresentMode() { - VkPresentModeKHR presentModes = !engineRepository.vsync + VkPresentModeKHR presentModes = !engineRepository->vsync ? VK_PRESENT_MODE_IMMEDIATE_KHR : VK_PRESENT_MODE_FIFO_KHR; imguiVulkanWindow.PresentMode = ImGui_ImplVulkanH_SelectPresentMode( @@ -264,17 +254,18 @@ namespace Metal { } void VulkanContext::onInitialize() { + this->debugMode = CTX->isDebugMode(); + this->window = glfwContext->getWindow(); + imguiVulkanWindow.ClearValue.color.float32[0] = 0; imguiVulkanWindow.ClearValue.color.float32[1] = 0; imguiVulkanWindow.ClearValue.color.float32[2] = 0; imguiVulkanWindow.ClearValue.color.float32[3] = 1; - - this->window = glfwContext.getWindow(); vkb::InstanceBuilder instanceBuilder; // ------- CORE INITIALIZATION // ----- INSTANCE AND EXTENSIONS - addExtensions(instanceBuilder, glfwContext.getInstanceExtensions()); + addExtensions(instanceBuilder, glfwContext->getInstanceExtensions()); auto vkbResult = instanceBuilder .set_app_name(ENGINE_NAME) .set_engine_name(ENGINE_NAME) @@ -296,17 +287,17 @@ namespace Metal { createMemoryAllocator(); createCommandPool(); createDescriptorPool(); - textureService.createSampler(false, vkImageSampler, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER); - textureService.createSampler(true, vkTextureSampler, VK_SAMPLER_ADDRESS_MODE_REPEAT); + textureService->createSampler(false, vkImageSampler, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER); + textureService->createSampler(true, vkTextureSampler, VK_SAMPLER_ADDRESS_MODE_REPEAT); // ------- CORE INITIALIZATION } - void VulkanContext::dispose() const { - pipelineService.disposeAll(); - textureService.disposeAll(); - meshService.disposeAll(); - framebufferService.disposeAll(); - rayTracingService.destroyAccelerationStructures(); + void VulkanContext::dispose() { + pipelineService->disposeAll(); + textureService->disposeAll(); + meshService->disposeAll(); + framebufferService->disposeAll(); + rayTracingService->dispose(); vkDestroySampler(device.device, vkImageSampler, nullptr); vkDestroySampler(device.device, vkTextureSampler, nullptr); @@ -322,7 +313,7 @@ namespace Metal { } void VulkanContext::createDescriptorPool() const { - const std::array sizes{ + const std::array sizes{ VkDescriptorPoolSize{VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 100}, // 1 for imgui VkDescriptorPoolSize{VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 100}, VkDescriptorPoolSize{VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 100}, @@ -332,13 +323,14 @@ namespace Metal { VkDescriptorPoolCreateInfo poolInfo{}; poolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; - poolInfo.poolSizeCount = sizes.size(); + poolInfo.poolSizeCount = static_cast(sizes.size()); poolInfo.pPoolSizes = sizes.data(); - poolInfo.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT | VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT; + poolInfo.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT | + VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT; poolInfo.maxSets = 500; VulkanUtils::CheckVKResult(vkCreateDescriptorPool(device.device, &poolInfo, - nullptr, &descriptorPool)); + nullptr, const_cast(&descriptorPool))); } VkCommandBuffer VulkanContext::beginSingleTimeCommands() const { @@ -375,7 +367,7 @@ namespace Metal { void VulkanContext::submitFrame(VkSemaphore image_acquired_semaphore, VkSemaphore render_complete_semaphore, - ImGui_ImplVulkanH_Frame *fd) { + ImGui_ImplVulkanH_Frame *fd) { VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; VkSubmitInfo info = {}; pushCommandBuffer(fd->CommandBuffer); diff --git a/src/core/vulkan/VulkanContext.h b/src/core/vulkan/VulkanContext.h index 0da550f5..deed4b7a 100644 --- a/src/core/vulkan/VulkanContext.h +++ b/src/core/vulkan/VulkanContext.h @@ -2,12 +2,13 @@ #define METAL_ENGINE_VULKANCONTEXT_H #include "vk_mem_alloc.h" -#include #include "imgui_impl_vulkan.h" #include #include "VkBootstrap.h" -#include "../../common/AbstractRuntimeComponent.h" +#include "../../common/IInit.h" +#include "../../common/IService.h" +#include "../../common/IDisposable.h" #define VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME "VK_KHR_portability_subset" @@ -20,14 +21,14 @@ namespace Metal { class PipelineService; class RayTracingService; - class VulkanContext final : public AbstractRuntimeComponent { - GLFWContext &glfwContext; - EngineRepository &engineRepository; - MeshService &meshService; - TextureService &textureService; - FrameBufferService &framebufferService; - PipelineService &pipelineService; - RayTracingService &rayTracingService; + class VulkanContext final : public IService, public IDisposable, public IInit { + GLFWContext *glfwContext = nullptr; + EngineRepository *engineRepository = nullptr; + MeshService *meshService = nullptr; + TextureService *textureService = nullptr; + FrameBufferService *framebufferService = nullptr; + PipelineService *pipelineService = nullptr; + RayTracingService *rayTracingService = nullptr; static VkBool32 DebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, @@ -67,14 +68,17 @@ namespace Metal { std::vector &getCommandBuffers() { return commandBuffers; } - explicit VulkanContext(bool debugMode, - GLFWContext &glfwContext, - EngineRepository &engineRepository, - MeshService &meshService, - TextureService &textureService, - FrameBufferService &framebufferService, - PipelineService &pipelineService, - RayTracingService &rayTracingService); + std::vector getDependencies() override { + return { + {"GLFWContext", glfwContext}, + {"EngineRepository", engineRepository}, + {"MeshService", meshService}, + {"TextureService", textureService}, + {"FrameBufferService", framebufferService}, + {"PipelineService", pipelineService}, + {"RayTracingService", rayTracingService} + }; + } VkPhysicalDeviceProperties physicalDeviceProperties{}; VkPhysicalDeviceMemoryProperties physicalDeviceMemoryProperties{}; @@ -104,7 +108,7 @@ namespace Metal { PFN_vkGetRayTracingShaderGroupHandlesKHR vkGetRayTracingShaderGroupHandlesKHR = nullptr; PFN_vkCmdTraceRaysKHR vkCmdTraceRaysKHR = nullptr; - void dispose() const; + void dispose() override; void onInitialize() override; diff --git a/src/core/vulkan/VulkanUtils.cpp b/src/core/vulkan/VulkanUtils.cpp index 9a133c92..9890c96a 100644 --- a/src/core/vulkan/VulkanUtils.cpp +++ b/src/core/vulkan/VulkanUtils.cpp @@ -2,7 +2,7 @@ #include "../../../dependencies/vk-bootstrap/src/VkBootstrap.h" #include "../../ApplicationContext.h" -#include "../../editor/service/LogService.h" +#include "../../common/LoggerUtil.h" namespace Metal { void VulkanUtils::CheckVKResult(VkResult err) { diff --git a/src/editor/abstract/IPanel.h b/src/editor/abstract/IPanel.h index 126139fe..48dfc868 100644 --- a/src/editor/abstract/IPanel.h +++ b/src/editor/abstract/IPanel.h @@ -1,11 +1,11 @@ #ifndef METAL_ENGINE_IPANEL_H #define METAL_ENGINE_IPANEL_H -#include "../../common/Synchornizable.h" -#include "../../common/Initializable.h" +#include "../../common/ISync.h" +#include "../../common/IInit.h" namespace Metal { - class IPanel : public Syncronizable, public Initializable { + class IPanel : public ISync, public IInit { public: virtual void removeAllChildren() { } diff --git a/src/editor/dock-spaces/console/ConsolePanel.h b/src/editor/dock-spaces/console/ConsolePanel.h index 5a6e3ae7..b6897524 100644 --- a/src/editor/dock-spaces/console/ConsolePanel.h +++ b/src/editor/dock-spaces/console/ConsolePanel.h @@ -1,7 +1,7 @@ #ifndef CONSOLEPANEL_H #define CONSOLEPANEL_H #include "../docks/AbstractDockPanel.h" -#include "../../service/LogService.h" +#include "../../../common/LoggerUtil.h" #include "imgui.h" namespace Metal { diff --git a/src/editor/dock-spaces/docks/DockSpacePanel.cpp b/src/editor/dock-spaces/docks/DockSpacePanel.cpp index 8e998f1e..3c0b6cd2 100644 --- a/src/editor/dock-spaces/docks/DockSpacePanel.cpp +++ b/src/editor/dock-spaces/docks/DockSpacePanel.cpp @@ -8,7 +8,7 @@ #include "../../../common/Icons.h" #include "../../dto/DockDTO.h" #include "../../util/UIUtil.h" -#include "../../service/LogService.h" +#include "../../../common/LoggerUtil.h" namespace Metal { const ImVec2 DockSpacePanel::DEFAULT{-1.f, -1.f}; diff --git a/src/editor/dock-spaces/files/FilesPanel.cpp b/src/editor/dock-spaces/files/FilesPanel.cpp index 898b0afa..7f772d6c 100644 --- a/src/editor/dock-spaces/files/FilesPanel.cpp +++ b/src/editor/dock-spaces/files/FilesPanel.cpp @@ -10,13 +10,13 @@ #include "../../dto/FSEntry.h" #include "../../dto/SceneImportSettingsDTO.h" #include "FilesContext.h" -#include "../../util/FileDialogUtil.h" +#include "../../../common/FileDialogUtil.h" #include "FilePreviewPanel.h" #include "../../abstract/form/FormPanel.h" #include #include -#include "../../util/FilesUtil.h" +#include "../../../common/FilesUtil.h" namespace Metal { std::string FilesPanel::getActionLabel() { diff --git a/src/editor/dto/EntryMetadata.h b/src/editor/dto/EntryMetadata.h index bfb9a00c..72b99a55 100644 --- a/src/editor/dto/EntryMetadata.h +++ b/src/editor/dto/EntryMetadata.h @@ -4,10 +4,10 @@ #include #include "../util/Util.h" #include "../enum/EntryType.h" -#include "../../common//Serializable.h" +#include "../../common//ISerialize.h" namespace Metal { - struct EntryMetadata : Serializable { + struct EntryMetadata : ISerialize { protected: std::string id = Util::uuidV4(); diff --git a/src/editor/dto/SceneData.h b/src/editor/dto/SceneData.h index ef40380e..894b3f80 100644 --- a/src/editor/dto/SceneData.h +++ b/src/editor/dto/SceneData.h @@ -3,11 +3,11 @@ #include #include "SceneEntityData.h" -#include "../../common//Serializable.h" +#include "../../common//ISerialize.h" namespace Metal { - struct SceneData final : Serializable { + struct SceneData final : ISerialize { std::vector entities; std::string name; diff --git a/src/editor/dto/SceneEntityData.h b/src/editor/dto/SceneEntityData.h index 48dbf3e9..0fbda6e6 100644 --- a/src/editor/dto/SceneEntityData.h +++ b/src/editor/dto/SceneEntityData.h @@ -7,7 +7,7 @@ namespace Metal { - struct SceneEntityData final : Serializable { + struct SceneEntityData final : ISerialize { MetadataComponent entity; TransformComponent transform; std::optional primitive; diff --git a/src/editor/enum/EntryType.h b/src/editor/enum/EntryType.h index e291a601..ed82b7ea 100644 --- a/src/editor/enum/EntryType.h +++ b/src/editor/enum/EntryType.h @@ -3,7 +3,7 @@ #include #include -#include "../../../common/Icons.h" +#include "../../common/Icons.h" namespace Metal::EntryType { enum EntryType { diff --git a/src/editor/panel/FileImportModalPanel.cpp b/src/editor/panel/FileImportModalPanel.cpp index 46941806..15b233df 100644 --- a/src/editor/panel/FileImportModalPanel.cpp +++ b/src/editor/panel/FileImportModalPanel.cpp @@ -3,7 +3,7 @@ #include #include #include "../../ApplicationContext.h" -#include "../util/FilesUtil.h" +#include "../../common/FilesUtil.h" #include "../abstract/form/FormPanel.h" namespace Metal { diff --git a/src/editor/repository/DockRepository.cpp b/src/editor/repository/DockRepository.cpp deleted file mode 100644 index 560f31d7..00000000 --- a/src/editor/repository/DockRepository.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "DockRepository.h" - -namespace Metal { - DockRepository::DockRepository() : AbstractRuntimeComponent() { - auto *rightT = new DockDTO{&DockSpace::WORLD}; - auto *leftTop = new DockDTO{&DockSpace::REPOSITORIES}; - auto *leftDown = new DockDTO{&DockSpace::INSPECTOR}; - auto *downLeft = new DockDTO{&DockSpace::CONSOLE}; - auto *downRight = new DockDTO{&DockSpace::FILES}; - - center.sizeRatioForNodeAtDir = 0.5f; - rightT->sizeRatioForNodeAtDir = 0.25f; - leftTop->sizeRatioForNodeAtDir = 0.2f; - leftDown->sizeRatioForNodeAtDir = 0.5f; - downLeft->sizeRatioForNodeAtDir = 0.25f; - downRight->sizeRatioForNodeAtDir = 0.5f; - - right.push_back(rightT); - left.push_back(leftTop); - left.push_back(leftDown); - - bottom.push_back(downLeft); - bottom.push_back(downRight); - } -} // Metal diff --git a/src/editor/repository/DockRepository.h b/src/editor/repository/DockRepository.h deleted file mode 100644 index 9fe872bd..00000000 --- a/src/editor/repository/DockRepository.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef METAL_ENGINE_DOCKREPOSITORY_H -#define METAL_ENGINE_DOCKREPOSITORY_H - -#include -#include "../dto/DockDTO.h" -#include "../../common/AbstractRuntimeComponent.h" - -namespace Metal { - struct DockRepository final : AbstractRuntimeComponent { - DockDTO center{&DockSpace::VIEWPORT}; - std::vector bottom; - std::vector left; - std::vector right; - - bool isInitialized = false; - - explicit DockRepository(); - }; -} // Metal - -#endif diff --git a/src/editor/repository/EditorRepository.h b/src/editor/repository/EditorRepository.h index ea30d277..f3133dac 100644 --- a/src/editor/repository/EditorRepository.h +++ b/src/editor/repository/EditorRepository.h @@ -9,15 +9,14 @@ #include "../dto/ShortcutDTO.h" #include "../enum/engine-definitions.h" #include "../enum/ShadingMode.h" -#include "../../common/Inspectable.h" -#include "../../common/Serializable.h" +#include "../../common/IRepository.h" namespace Metal { struct TransformComponent; struct FSEntry; struct ImportSettingsDTO; - struct EditorRepository final : Inspectable, Serializable { + struct EditorRepository final : IRepository { ImVec4 accent{}; ImU32 accentU32 = 0; diff --git a/src/editor/service/AsyncTaskService.cpp b/src/editor/service/AsyncTaskService.cpp index d2200a0d..eb03ec42 100644 --- a/src/editor/service/AsyncTaskService.cpp +++ b/src/editor/service/AsyncTaskService.cpp @@ -40,7 +40,7 @@ namespace Metal { return !tasks.empty(); } - void AsyncTaskService::endAll() { + void AsyncTaskService::dispose() { for (std::shared_ptr &task: tasksArray) { endTask(task->id, true); } diff --git a/src/editor/service/AsyncTaskService.h b/src/editor/service/AsyncTaskService.h index 71a16e40..5ca1a64d 100644 --- a/src/editor/service/AsyncTaskService.h +++ b/src/editor/service/AsyncTaskService.h @@ -5,10 +5,13 @@ #include #include #include + +#include "../../common/IDisposable.h" +#include "../../common/IService.h" #include "../dto/AsyncTask.h" namespace Metal { - class AsyncTaskService { + class AsyncTaskService final : public IService, IDisposable{ std::unordered_map > tasks; std::vector > tasksArray; mutable std::mutex tasksMutex; @@ -22,7 +25,7 @@ namespace Metal { bool hasActiveTasks(); - void endAll(); + void dispose() override; }; } diff --git a/src/editor/service/DockService.cpp b/src/editor/service/DockService.cpp index c231964f..2a5b821f 100644 --- a/src/editor/service/DockService.cpp +++ b/src/editor/service/DockService.cpp @@ -8,6 +8,28 @@ #include "../../ApplicationContext.h" namespace Metal { + DockService::DockService() { + auto *rightT = new DockDTO{&DockSpace::WORLD}; + auto *leftTop = new DockDTO{&DockSpace::REPOSITORIES}; + auto *leftDown = new DockDTO{&DockSpace::INSPECTOR}; + auto *downLeft = new DockDTO{&DockSpace::CONSOLE}; + auto *downRight = new DockDTO{&DockSpace::FILES}; + + center.sizeRatioForNodeAtDir = 0.5f; + rightT->sizeRatioForNodeAtDir = 0.25f; + leftTop->sizeRatioForNodeAtDir = 0.2f; + leftDown->sizeRatioForNodeAtDir = 0.5f; + downLeft->sizeRatioForNodeAtDir = 0.25f; + downRight->sizeRatioForNodeAtDir = 0.5f; + + right.push_back(rightT); + left.push_back(leftTop); + left.push_back(leftDown); + + bottom.push_back(downLeft); + bottom.push_back(downRight); + } + void DockService::buildViews(ImGuiID windowId, AbstractPanel *panel) const { if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable) { if (dockRepository.isInitialized) { diff --git a/src/editor/service/DockService.h b/src/editor/service/DockService.h index 2c5fbf40..8fca6f13 100644 --- a/src/editor/service/DockService.h +++ b/src/editor/service/DockService.h @@ -4,17 +4,21 @@ #include "imgui.h" #include "../dto/DockDTO.h" #include "../dock-spaces/docks/DockSpacePanel.h" -#include "../../common/AbstractRuntimeComponent.h" +#include "../../common/IService.h" namespace Metal { class AbstractPanel; - class DockService final : public AbstractRuntimeComponent { - DockRepository &dockRepository; + class DockService final : public IService { + DockDTO center{&DockSpace::VIEWPORT}; + std::vector bottom; + std::vector left; + std::vector right; + + + bool isInitialized = false; public: - explicit DockService(DockRepository &dockRepository) - : AbstractRuntimeComponent(), dockRepository(dockRepository) { - } + explicit DockService(); void buildViews(ImGuiID windowId, AbstractPanel *panel) const; diff --git a/src/editor/service/FileImporterService.cpp b/src/editor/service/FileImporterService.cpp index 2131cd1f..55c3d6cd 100644 --- a/src/editor/service/FileImporterService.cpp +++ b/src/editor/service/FileImporterService.cpp @@ -4,7 +4,7 @@ #include "VoxelImporterService.h" #include "NotificationService.h" #include "AsyncTaskService.h" -#include "LogService.h" +#include "../../common/LoggerUtil.h" #include #include @@ -17,27 +17,27 @@ namespace Metal { [this, targetDir, file, fileName, settings](const std::stop_token &token) { try { LOG_INFO("Starting file processing: " + fileName); - if (sceneImporterService.isCompatible(file)) { - sceneImporterService.importData(targetDir, + if (sceneImporterService->isCompatible(file)) { + sceneImporterService->importData(targetDir, file, settings, token); - } else if (textureImporterService.isCompatible(file)) { - textureImporterService.importData(targetDir, file, settings, token); - } else if (voxelImporterService.isCompatible(file)) { - voxelImporterService.importData(targetDir, file, settings, token); + } else if (textureImporterService->isCompatible(file)) { + textureImporterService->importData(targetDir, file, settings, token); + } else if (voxelImporterService->isCompatible(file)) { + voxelImporterService->importData(targetDir, file, settings, token); } LOG_INFO("Successfully imported file: " + fileName); - notificationService.pushMessage("Successfully imported file: " + fileName, + notificationService->pushMessage("Successfully imported file: " + fileName, NotificationSeverities::SUCCESS); } catch (std::exception &e) { - notificationService.pushMessage(e.what(), NotificationSeverities::ERROR); + notificationService->pushMessage(e.what(), NotificationSeverities::ERROR); } }); } std::string FileImporterService::runAsync(const std::string &taskName, const LoadingTask &task) const { std::stop_source stopSource; - std::string taskId = asyncTaskService.registerTask(taskName, [stopSource]() mutable { + std::string taskId = asyncTaskService->registerTask(taskName, [stopSource]() mutable { stopSource.request_stop(); }); @@ -49,7 +49,7 @@ namespace Metal { } catch (...) { LOG_ERROR("Loading task failed with unknown error."); } - asyncTaskService.endTask(taskId, stopToken.stop_requested()); + asyncTaskService->endTask(taskId, stopToken.stop_requested()); }).detach(); return taskId; @@ -57,13 +57,13 @@ namespace Metal { std::string FileImporterService::collectCompatibleFiles() const { std::string outStr = ""; - for (std::string type: sceneImporterService.getSupportedTypes()) { + for (std::string type: sceneImporterService->getSupportedTypes()) { outStr += type + ","; }; - for (std::string type: textureImporterService.getSupportedTypes()) { + for (std::string type: textureImporterService->getSupportedTypes()) { outStr += type + ","; }; - for (std::string type: voxelImporterService.getSupportedTypes()) { + for (std::string type: voxelImporterService->getSupportedTypes()) { outStr += type + ","; }; return outStr; diff --git a/src/editor/service/FileImporterService.h b/src/editor/service/FileImporterService.h index 86b1227b..411c617a 100644 --- a/src/editor/service/FileImporterService.h +++ b/src/editor/service/FileImporterService.h @@ -6,7 +6,7 @@ #include #include "../dto/ImportSettingsDTO.h" -#include "../../common/AbstractRuntimeComponent.h" +#include "../../common/IService.h" namespace Metal { class SceneImporterService; @@ -15,24 +15,22 @@ namespace Metal { class NotificationService; class AsyncTaskService; - class FileImporterService final : public AbstractRuntimeComponent { - SceneImporterService &sceneImporterService; - TextureImporterService &textureImporterService; - VoxelImporterService &voxelImporterService; - NotificationService ¬ificationService; - AsyncTaskService &asyncTaskService; + class FileImporterService final : public IService { + SceneImporterService *sceneImporterService = nullptr; + TextureImporterService *textureImporterService = nullptr; + VoxelImporterService *voxelImporterService = nullptr; + NotificationService *notificationService = nullptr; + AsyncTaskService *asyncTaskService = nullptr; public: - FileImporterService(SceneImporterService &sceneImporterService, - TextureImporterService &textureImporterService, - VoxelImporterService &voxelImporterService, - NotificationService ¬ificationService, - AsyncTaskService &asyncTaskService) - : sceneImporterService(sceneImporterService), - textureImporterService(textureImporterService), - voxelImporterService(voxelImporterService), - notificationService(notificationService), - asyncTaskService(asyncTaskService) { + std::vector getDependencies() override { + return { + {"SceneImporterService", sceneImporterService}, + {"TextureImporterService", textureImporterService}, + {"VoxelImporterService", voxelImporterService}, + {"NotificationService", notificationService}, + {"AsyncTaskService", asyncTaskService} + }; } using LoadingTask = std::function; diff --git a/src/editor/service/FilesService.cpp b/src/editor/service/FilesService.cpp index 90e59a05..78bc1b36 100644 --- a/src/editor/service/FilesService.cpp +++ b/src/editor/service/FilesService.cpp @@ -3,8 +3,8 @@ #include "../dto/FSEntry.h" #include "../enum/EntryType.h" #include "../enum/engine-definitions.h" -#include "../util/FilesUtil.h" -#include "LogService.h" +#include "../../common/FilesUtil.h" +#include "../../common/LoggerUtil.h" #include #include #include @@ -162,4 +162,5 @@ namespace Metal { } } } + } // Metal diff --git a/src/editor/service/FilesService.h b/src/editor/service/FilesService.h index 62fe176d..3ecca1a4 100644 --- a/src/editor/service/FilesService.h +++ b/src/editor/service/FilesService.h @@ -4,24 +4,26 @@ #include #include -#include "../../common/AbstractRuntimeComponent.h" +#include "../../common/IInit.h" +#include "../../common/IService.h" namespace Metal { + struct DirectoryService; struct FSEntry; class NotificationService; - class FilesService final : public AbstractRuntimeComponent { + class FilesService final : public IService, public IInit { FSEntry *root = nullptr; - std::string &rootDirectory; - NotificationService ¬ificationService; + DirectoryService *directoryService = nullptr; + NotificationService *notificationService = nullptr; public: - explicit FilesService(std::string &rootDirectory, NotificationService ¬ificationService) - : AbstractRuntimeComponent(), rootDirectory(rootDirectory), notificationService(notificationService) { + std::vector getDependencies() override { + return {{"DirectoryService", directoryService}, {"NotificationService", notificationService}}; } - FSEntry *getRoot() { + FSEntry *getRoot() const { return root; } diff --git a/src/editor/service/MaterialImporterService.cpp b/src/editor/service/MaterialImporterService.cpp index dbe18d97..6aa6009c 100644 --- a/src/editor/service/MaterialImporterService.cpp +++ b/src/editor/service/MaterialImporterService.cpp @@ -1,6 +1,6 @@ #include "MaterialImporterService.h" #include "TextureImporterService.h" -#include "LogService.h" +#include "../../common/LoggerUtil.h" #include "../enum/engine-definitions.h" #include "../../engine/dto/PrimitiveComponent.h" #include @@ -22,7 +22,7 @@ namespace Metal { try { const unsigned int embeddedIndex = static_cast(std::stoul(p.substr(1))); if (scene && embeddedIndex < scene->mNumTextures) { - return textureImporterService.importEmbeddedTexture( + return textureImporterService->importEmbeddedTexture( targetDir, scene->mTextures[embeddedIndex], nameHint); } } catch (std::exception &e) { @@ -38,7 +38,7 @@ namespace Metal { } resolved = resolved.lexically_normal(); try { - return textureImporterService.importData(targetDir, resolved.string(), nullptr, stopToken); + return textureImporterService->importData(targetDir, resolved.string(), nullptr, stopToken); } catch (std::exception &e) { LOG_ERROR("Failed to import texture " + resolved.string() + ": " + e.what()); return ""; diff --git a/src/editor/service/MaterialImporterService.h b/src/editor/service/MaterialImporterService.h index 21f5a876..cbe42008 100644 --- a/src/editor/service/MaterialImporterService.h +++ b/src/editor/service/MaterialImporterService.h @@ -2,24 +2,24 @@ #define MATERIALIMPORTERSERVICE_H #include -#include #include #include -#include "../../common/AbstractResourceService.h" +#include "../../common/IService.h" namespace Metal { struct PrimitiveComponent; class TextureImporterService; - class MaterialImporterService final : public AbstractRuntimeComponent { - TextureImporterService &textureImporterService; - std::string &rootDirectory; + class MaterialImporterService final : public IService { + TextureImporterService *textureImporterService = nullptr; public: - MaterialImporterService(TextureImporterService &textureImporterService, std::string &rootDirectory) - : textureImporterService(textureImporterService), rootDirectory(rootDirectory) { + std::vector getDependencies() override { + return { + {"TextureImporterService", textureImporterService} + }; } void importMaterial(const std::string &targetDir, const aiMaterial *material, const aiScene *scene, diff --git a/src/editor/service/MeshImporterService.cpp b/src/editor/service/MeshImporterService.cpp index 6035b5a9..4a500d42 100644 --- a/src/editor/service/MeshImporterService.cpp +++ b/src/editor/service/MeshImporterService.cpp @@ -1,10 +1,11 @@ #include "MeshImporterService.h" -#include "LogService.h" +#include "../../core/DirectoryService.h" +#include "../../common/LoggerUtil.h" #include "../../engine/dto/MeshData.h" #include "../../engine/dto/VertexData.h" #include "../dto/EntryMetadata.h" #include "../enum/engine-definitions.h" -#include "../util/FilesUtil.h" +#include "../../common/FilesUtil.h" #include #include "../../common/serialization-definitions.h" @@ -17,7 +18,7 @@ namespace Metal { metadata.name = metadata.name.substr(0, metadata.name.find_last_of('.')); } - std::string lod0Path = rootDirectory + "/assets/" + FORMAT_FILE_MESH(metadata.getId()); + std::string lod0Path = directoryService->getAssetDirectory() + FORMAT_FILE_MESH(metadata.getId()); { std::ofstream output(lod0Path, std::ios::binary); cereal::BinaryOutputArchive archive(output); diff --git a/src/editor/service/MeshImporterService.h b/src/editor/service/MeshImporterService.h index 82bea5e6..360be3a5 100644 --- a/src/editor/service/MeshImporterService.h +++ b/src/editor/service/MeshImporterService.h @@ -1,7 +1,7 @@ #ifndef MESHIMPORTERSERVICE_H #define MESHIMPORTERSERVICE_H -#include "../../common/AbstractResourceService.h" +#include "../../common/IService.h" #include #include #include @@ -15,12 +15,14 @@ namespace Metal { }; struct MeshData; - class MeshImporterService final : public AbstractRuntimeComponent { - std::string &rootDirectory; + class MeshImporterService final : public IService { + DirectoryService *directoryService = nullptr; public: - explicit MeshImporterService(std::string &rootDirectory) - : rootDirectory(rootDirectory) { + std::vector getDependencies() override { + return { + {"DirectoryService", directoryService} + }; } void persistAllMeshes(const std::string &targetDir, const aiScene *scene, diff --git a/src/editor/service/NotificationService.h b/src/editor/service/NotificationService.h index 050b4183..f76ebba9 100644 --- a/src/editor/service/NotificationService.h +++ b/src/editor/service/NotificationService.h @@ -3,6 +3,7 @@ #include #include #include "../enum/NotificationSeverity.h" +#include "../../common/IService.h" #define MAX_notifications 4 #define MESSAGE_DURATION 3000 @@ -10,7 +11,7 @@ namespace Metal { struct Notification; - class NotificationService { + class NotificationService : public IService { std::array notifications{}; public: diff --git a/src/editor/service/PickingService.cpp b/src/editor/service/PickingService.cpp index 34c7c4ee..1d1495df 100644 --- a/src/editor/service/PickingService.cpp +++ b/src/editor/service/PickingService.cpp @@ -6,17 +6,19 @@ #include "../../core/vulkan/VulkanContext.h" #include "../../engine/service/BufferService.h" #include "../../engine/repository/WorldRepository.h" +#include "../../engine/dto/PrimitiveComponent.h" +#include "../../engine/dto/TransformComponent.h" namespace Metal { std::optional PickingService::pickEntityFromGBuffer(TextureInstance *attachment, const uint32_t pixelX, const uint32_t pixelY) const { constexpr VkDeviceSize imageSize = 4 * sizeof(float); - auto stagingBuffer = bufferService.createBuffer("stagingBuffer", imageSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT, + auto stagingBuffer = bufferService->createBuffer("stagingBuffer", imageSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); - VkCommandBuffer commandBuffer = vulkanContext.beginSingleTimeCommands(); + VkCommandBuffer commandBuffer = vulkanContext->beginSingleTimeCommands(); VkImageMemoryBarrier barrier = {}; barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; @@ -38,8 +40,8 @@ namespace Metal { region.bufferImageHeight = 0; region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; region.imageSubresource.mipLevel = 0; - region.baseArrayLayer = 0; - region.layerCount = 1; + region.imageSubresource.baseArrayLayer = 0; + region.imageSubresource.layerCount = 1; region.imageOffset = {static_cast(pixelX), static_cast(pixelY), 0}; region.imageExtent = {1, 1, 1}; @@ -54,14 +56,14 @@ namespace Metal { vkCmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier); - vulkanContext.endSingleTimeCommands(commandBuffer); + vulkanContext->endSingleTimeCommands(commandBuffer); void *data = nullptr; - vkMapMemory(vulkanContext.device.device, stagingBuffer->vkDeviceMemory, 0, imageSize, 0, &data); + vkMapMemory(vulkanContext->device.device, stagingBuffer->vkDeviceMemory, 0, imageSize, 0, &data); const auto *pixel = static_cast(data); const float idValue = pixel[3]; // Render index is in the A channel (index 3) - vkUnmapMemory(vulkanContext.device.device, stagingBuffer->vkDeviceMemory); - bufferService.dispose("stagingBuffer"); + vkUnmapMemory(vulkanContext->device.device, stagingBuffer->vkDeviceMemory); + bufferService->dispose("stagingBuffer"); if (idValue <= 0.0f) { return std::nullopt; @@ -69,9 +71,10 @@ namespace Metal { const unsigned int renderIndex = static_cast(idValue + 0.5f) - 1; - auto view = worldRepository.registry.view(); + auto ®istry = worldRepository->registry; + auto view = registry.view(); for (auto entity: view) { - auto &mesh = view.get(entity); + auto &mesh = registry.get(entity); if (mesh.renderIndex == renderIndex) { return entity; } diff --git a/src/editor/service/PickingService.h b/src/editor/service/PickingService.h index 88127897..a51b8167 100644 --- a/src/editor/service/PickingService.h +++ b/src/editor/service/PickingService.h @@ -1,7 +1,7 @@ #ifndef PICKINGSERVICE_H #define PICKINGSERVICE_H -#include "../../common/AbstractResourceService.h" +#include "../../common/IService.h" #include "../enum/engine-definitions.h" #include @@ -11,15 +11,19 @@ namespace Metal { class BufferService; struct WorldRepository; - class PickingService final : public AbstractRuntimeComponent { - VulkanContext &vulkanContext; - BufferService &bufferService; - WorldRepository &worldRepository; + class PickingService final : public IService { + VulkanContext *vulkanContext = nullptr; + BufferService *bufferService = nullptr; + WorldRepository *worldRepository = nullptr; public: - PickingService(VulkanContext &vulkanContext, BufferService &bufferService, WorldRepository &worldRepository) - : vulkanContext(vulkanContext), bufferService(bufferService), worldRepository(worldRepository) {} - PickingService() = delete; + std::vector getDependencies() override { + return { + {"VulkanContext", vulkanContext}, + {"BufferService", bufferService}, + {"WorldRepository", worldRepository} + }; + } [[nodiscard]] std::optional pickEntityFromGBuffer(TextureInstance *attachment, uint32_t pixelX, uint32_t pixelY) const; }; diff --git a/src/editor/service/SceneImporterService.cpp b/src/editor/service/SceneImporterService.cpp index 70ef75a7..86ac3a29 100644 --- a/src/editor/service/SceneImporterService.cpp +++ b/src/editor/service/SceneImporterService.cpp @@ -1,7 +1,7 @@ #include "SceneImporterService.h" #include "MeshImporterService.h" #include "MaterialImporterService.h" -#include "LogService.h" +#include "../../common/LoggerUtil.h" #include "../dto/FSEntry.h" #include "../../engine/dto/MeshData.h" #include "../dto/SceneData.h" @@ -10,10 +10,11 @@ #include #include #include -#include "../util/FilesUtil.h" +#include "../../common/FilesUtil.h" #include "../dto/EntryMetadata.h" #include "../enum/engine-definitions.h" #include "../../common/serialization-definitions.h" +#include "../../core/DirectoryService.h" #include "../dto/SceneImportSettingsDTO.h" namespace Metal { @@ -50,7 +51,7 @@ namespace Metal { sceneMetadata.name = sceneData.name = scene->mName.length > 0 ? scene->mName.data : scene->mRootNode->mName.data; - std::string sceneBlobPath = rootDirectory + "/assets/" + FORMAT_FILE_SCENE(sceneMetadata.getId()); + std::string sceneBlobPath = directoryService->getAssetDirectory() + FORMAT_FILE_SCENE(sceneMetadata.getId()); std::unordered_map meshMap{}; diff --git a/src/editor/service/SceneImporterService.h b/src/editor/service/SceneImporterService.h index d70496e7..997d76bc 100644 --- a/src/editor/service/SceneImporterService.h +++ b/src/editor/service/SceneImporterService.h @@ -8,6 +8,7 @@ #include namespace Metal { + struct DirectoryService; struct MeshId; struct MaterialData; struct MeshData; @@ -17,17 +18,17 @@ namespace Metal { class MaterialImporterService; class SceneImporterService final : public AbstractImporter { - MeshImporterService &meshImporterService; - MaterialImporterService &materialImporterService; - std::string &rootDirectory; + MeshImporterService *meshImporterService = nullptr; + MaterialImporterService *materialImporterService = nullptr; + DirectoryService *directoryService = nullptr; public: - SceneImporterService(MeshImporterService &meshImporterService, - MaterialImporterService &materialImporterService, - std::string &rootDirectory) - : meshImporterService(meshImporterService), - materialImporterService(materialImporterService), - rootDirectory(rootDirectory) { + std::vector getDependencies() override { + return { + {"MeshImporterService", meshImporterService}, + {"MaterialImporterService", materialImporterService}, + {"DirectoryService", directoryService} + }; } std::string importData(const std::string &targetDir, const std::string &pathToFile, diff --git a/src/editor/service/SelectionService.cpp b/src/editor/service/SelectionService.cpp index 0105d673..de66ed82 100644 --- a/src/editor/service/SelectionService.cpp +++ b/src/editor/service/SelectionService.cpp @@ -5,42 +5,42 @@ namespace Metal { void SelectionService::addSelected(entt::entity entity) const { - if (editorRepository.selected.empty() || entity == EMPTY_ENTITY) { - editorRepository.mainSelection = entity; - if (editorRepository.mainSelection != EMPTY_ENTITY) { + if (editorRepository->selected.empty() || entity == EMPTY_ENTITY) { + editorRepository->mainSelection = entity; + if (editorRepository->mainSelection != EMPTY_ENTITY) { updatePrimitiveSelected(); } } if (entity != EMPTY_ENTITY) { - editorRepository.selected.insert({entity, true}); + editorRepository->selected.insert({entity, true}); } } void SelectionService::clearSelection() const { - editorRepository.selected.clear(); - editorRepository.mainSelection = EMPTY_ENTITY; - editorRepository.primitiveSelected = nullptr; + editorRepository->selected.clear(); + editorRepository->mainSelection = EMPTY_ENTITY; + editorRepository->primitiveSelected = nullptr; } void SelectionService::addAllSelected(const std::vector &all) const { - editorRepository.selected.clear(); + editorRepository->selected.clear(); const entt::entity first = all.size() > 0 ? all[0] : EMPTY_ENTITY; - editorRepository.mainSelection = first; + editorRepository->mainSelection = first; updatePrimitiveSelected(); for (auto a: all) { - editorRepository.selected.insert({a, true}); + editorRepository->selected.insert({a, true}); } } void SelectionService::updatePrimitiveSelected() const { - const auto entityId = editorRepository.mainSelection; + const auto entityId = editorRepository->mainSelection; - if (entityId == EMPTY_ENTITY || !worldRepository.registry.valid(entityId)) { + if (entityId == EMPTY_ENTITY || !worldRepository->registry.valid(entityId)) { return; } - if (worldRepository.registry.all_of(entityId)) { - editorRepository.primitiveSelected = &worldRepository.registry.get(entityId); + if (worldRepository->registry.all_of(entityId)) { + editorRepository->primitiveSelected = &worldRepository->registry.get(entityId); } } diff --git a/src/editor/service/SelectionService.h b/src/editor/service/SelectionService.h index 8916fa72..27562703 100644 --- a/src/editor/service/SelectionService.h +++ b/src/editor/service/SelectionService.h @@ -2,20 +2,23 @@ #define SELECTIONSERVICE_H #include -#include "../../common/AbstractRuntimeComponent.h" +#include "../../common/IService.h" #include "../enum/engine-definitions.h" namespace Metal { struct WorldRepository; struct EditorRepository; - class SelectionService final : public AbstractRuntimeComponent { - EditorRepository &editorRepository; - WorldRepository &worldRepository; + class SelectionService final : public IService { + EditorRepository *editorRepository = nullptr; + WorldRepository *worldRepository = nullptr; public: - SelectionService(EditorRepository &editorRepository, WorldRepository &worldRepository) - : editorRepository(editorRepository), worldRepository(worldRepository) { + std::vector getDependencies() override { + return { + {"EditorRepository", editorRepository}, + {"WorldRepository", worldRepository} + }; } void addSelected(entt::entity entity) const; diff --git a/src/editor/service/TextureImporterService.cpp b/src/editor/service/TextureImporterService.cpp index 2b5cb11d..0c6b7009 100644 --- a/src/editor/service/TextureImporterService.cpp +++ b/src/editor/service/TextureImporterService.cpp @@ -1,5 +1,7 @@ #include "TextureImporterService.h" -#include "LogService.h" +#include "../../core/DirectoryService.h" +#include "../../common/LoggerUtil.h" +#include "../enum/engine-definitions.h" #include "../../../../dependencies/stb/stb_image.h" #include "../../../../dependencies/stb/stb_image_write.h" @@ -9,7 +11,7 @@ #include "../dto/EntryMetadata.h" #include "../enum/EntryType.h" -#include "../util/FilesUtil.h" +#include "../../common/FilesUtil.h" #include "../../engine/dto/TextureData.h" namespace fs = std::filesystem; @@ -103,7 +105,7 @@ namespace Metal { size_t TextureImporterService::saveImage(const std::string &fileId, const TextureData &textureData) const { - std::string texturePath = rootDirectory + "/assets/" + FORMAT_FILE_TEXTURE(fileId); + std::string texturePath = directoryService->getAssetDirectory() + FORMAT_FILE_TEXTURE(fileId); if (!stbi_write_png(texturePath.c_str(), textureData.width, textureData.height, textureData.channels, textureData.data, textureData.width * textureData.channels)) { diff --git a/src/editor/service/TextureImporterService.h b/src/editor/service/TextureImporterService.h index d00446b9..59b56317 100644 --- a/src/editor/service/TextureImporterService.h +++ b/src/editor/service/TextureImporterService.h @@ -5,14 +5,17 @@ struct aiTexture; namespace Metal { + class DirectoryService; struct TextureData; class TextureImporterService final : public AbstractImporter { - std::string &rootDirectory; + DirectoryService *directoryService = nullptr; public: - explicit TextureImporterService(std::string &rootDirectory) - : AbstractImporter(), rootDirectory(rootDirectory) { + std::vector getDependencies() override { + return { + {"DirectoryService", directoryService} + }; } std::vector getSupportedTypes() override { diff --git a/src/editor/service/ThemeService.h b/src/editor/service/ThemeService.h index 94310fbe..4cc321d7 100644 --- a/src/editor/service/ThemeService.h +++ b/src/editor/service/ThemeService.h @@ -2,13 +2,14 @@ #define THEMESERVICE_H #include #include -#include "../../common/AbstractRuntimeComponent.h" +#include "../../common/IService.h" +#include "../../common/ISync.h" namespace Metal { struct EditorRepository; - class ThemeService final : public AbstractRuntimeComponent { - EditorRepository &editorRepository; + class ThemeService final : public IService, public ISync { + EditorRepository *editorRepository = nullptr; public: ImVec4 neutralPalette{}; ImVec4 palette0{}; @@ -23,15 +24,15 @@ namespace Metal { bool previousTheme = false; float prevLength = 0.0f; - explicit ThemeService(EditorRepository &editorRepository) - : AbstractRuntimeComponent(), editorRepository(editorRepository) { - } - void setDarkMode(); void setLightMode(); void onSync() override; + + std::vector getDependencies() override { + return {{"EditorRepository", editorRepository}}; + } }; } // Metal diff --git a/src/editor/service/VoxelImporterService.cpp b/src/editor/service/VoxelImporterService.cpp index 7d0563db..65d7546a 100644 --- a/src/editor/service/VoxelImporterService.cpp +++ b/src/editor/service/VoxelImporterService.cpp @@ -1,4 +1,5 @@ #include "VoxelImporterService.h" +#include "../../core/DirectoryService.h" #include #include "../../common/serialization-definitions.h" @@ -6,7 +7,7 @@ #include "../dto/EntryMetadata.h" #include "../enum/EntryType.h" #include "../enum/engine-definitions.h" -#include "LogService.h" +#include "../../common/LoggerUtil.h" #include #include #include @@ -28,7 +29,7 @@ namespace Metal { metadata.name = metadata.name.substr(0, metadata.name.find_last_of('.')); - std::string outPath = rootDirectory + "/assets/" + FORMAT_FILE_VOLUME(metadata.getId()); + std::string outPath = directoryService->getAssetDirectory() + FORMAT_FILE_VOLUME(metadata.getId()); metadata.size = convertToSVO(pathToFile, outPath, stopToken); DUMP_TEMPLATE(targetDir + '/' + FORMAT_FILE_METADATA(metadata.getId()), metadata) diff --git a/src/editor/service/VoxelImporterService.h b/src/editor/service/VoxelImporterService.h index fed4a639..781283b0 100644 --- a/src/editor/service/VoxelImporterService.h +++ b/src/editor/service/VoxelImporterService.h @@ -6,13 +6,17 @@ #include "../../engine/dto/SparseVoxelOctreeData.h" namespace Metal { + class DirectoryService; struct SVOInstance; class VoxelImporterService final : public AbstractImporter { - const std::string &rootDirectory; + DirectoryService *directoryService = nullptr; public: - explicit VoxelImporterService(const std::string &rootDirectory) : rootDirectory(rootDirectory) {} - VoxelImporterService() = delete; + std::vector getDependencies() override { + return { + {"DirectoryService", directoryService} + }; + } std::vector getSupportedTypes() override; diff --git a/src/engine/EngineContext.cpp b/src/engine/EngineContext.cpp index e97a104e..23dcd9d2 100644 --- a/src/engine/EngineContext.cpp +++ b/src/engine/EngineContext.cpp @@ -15,10 +15,7 @@ namespace Metal { void EngineContext::resetPathTracerAccumulationCount() const { - engineRepository.pathTracerAccumulationCount = 0; - } - - void EngineContext::onInitialize() { + engineRepository->pathTracerAccumulationCount = 0; } void EngineContext::updateCurrentTime() { @@ -36,20 +33,17 @@ namespace Metal { } void EngineContext::dispose() { - if (currentFrame != nullptr) { - currentFrame->dispose(); - } } void EngineContext::onSync() { updateCurrentTime(); - transformService.onSync(); - streamingService.onSync(); - rayTracingService.onSync(); - cameraService.onSync(); - lightService.onSync(); - volumeService.onSync(); + transformService->onSync(); + streamingService->onSync(); + rayTracingService->onSync(); + cameraService->onSync(); + lightService->onSync(); + volumeService->onSync(); for (auto *frame: registeredFrames) { if (frame->getShouldRender()) { @@ -66,7 +60,7 @@ namespace Metal { } void EngineContext::updateGlobalData() { - auto &camera = worldRepository.camera; + auto &camera = worldRepository->camera; globalDataUBO.previousProjView = globalDataUBO.projView; globalDataUBO.viewMatrix = camera.viewMatrix; globalDataUBO.projectionMatrix = camera.projectionMatrix; @@ -74,21 +68,21 @@ namespace Metal { globalDataUBO.invProj = camera.invProjectionMatrix; globalDataUBO.invView = camera.invViewMatrix; globalDataUBO.cameraWorldPosition = camera.position; - globalDataUBO.volumeCount = volumeService.getCount(); - globalDataUBO.lightsCount = lightService.getCount(); - globalDataUBO.debugFlag = ShadingModes::IndexOfValue(editorRepository.shadingMode); - engineRepository.pathTracerAccumulationCount++; - globalDataUBO.pathTracerAccumulationCount = engineRepository.pathTracerAccumulationCount; + globalDataUBO.volumeCount = volumeService->getCount(); + globalDataUBO.lightsCount = lightService->getCount(); + globalDataUBO.debugFlag = ShadingModes::IndexOfValue(editorRepository->shadingMode); + engineRepository->pathTracerAccumulationCount++; + globalDataUBO.pathTracerAccumulationCount = engineRepository->pathTracerAccumulationCount; globalDataUBO.globalFrameCount++; - globalDataUBO.pathTracerMaxSamples = engineRepository.pathTracerMaxSamples; - globalDataUBO.denoiserEnabled = engineRepository.denoiserEnabled && ( + globalDataUBO.pathTracerMaxSamples = engineRepository->pathTracerMaxSamples; + globalDataUBO.denoiserEnabled = engineRepository->denoiserEnabled && ( globalDataUBO.debugFlag == LIT || globalDataUBO.debugFlag == LIGHTING_ONLY) ? 1 : 0; - lightService.computeSunInfo(); - globalDataUBO.sunPosition = lightService.getSunPosition(); - globalDataUBO.sunColor = lightService.getSunColor(); + lightService->computeSunInfo(); + globalDataUBO.sunPosition = lightService->getSunPosition(); + globalDataUBO.sunColor = lightService->getSunColor(); currentFrame->getResourceAs(RID_GLOBAL_DATA)->update(&globalDataUBO); } } diff --git a/src/engine/EngineContext.h b/src/engine/EngineContext.h index 5f73f823..127953c8 100644 --- a/src/engine/EngineContext.h +++ b/src/engine/EngineContext.h @@ -6,8 +6,9 @@ #include #include "dto/GlobalDataUBO.h" -#include "../common/AbstractRuntimeComponent.h" -#include "dto/TileInfoUBO.h" +#include "../common/IService.h" +#include "../common/IDisposable.h" +#include "../common/ISync.h" using Clock = std::chrono::high_resolution_clock; using TimePoint = std::chrono::time_point; @@ -23,16 +24,16 @@ namespace Metal { struct EditorRepository; struct EngineRepository; - class EngineContext final : public AbstractRuntimeComponent { - TransformService &transformService; - StreamingService &streamingService; - RayTracingService &rayTracingService; - CameraService &cameraService; - LightService &lightService; - VolumeService &volumeService; - WorldRepository &worldRepository; - EditorRepository &editorRepository; - EngineRepository &engineRepository; + class EngineContext final : public IService, public ISync, public IDisposable { + TransformService *transformService = nullptr; + StreamingService *streamingService = nullptr; + RayTracingService *rayTracingService = nullptr; + CameraService *cameraService = nullptr; + LightService *lightService = nullptr; + VolumeService *volumeService = nullptr; + WorldRepository *worldRepository = nullptr; + EditorRepository *editorRepository = nullptr; + EngineRepository *engineRepository = nullptr; GlobalDataUBO globalDataUBO{}; long long start = -1; @@ -40,25 +41,20 @@ namespace Metal { bool giSettingsUpdated = true; public: - EngineContext(TransformService &transformService, - StreamingService &streamingService, - RayTracingService &rayTracingService, - CameraService &cameraService, - LightService &lightService, - VolumeService &volumeService, - WorldRepository &worldRepository, - EditorRepository &editorRepository, - EngineRepository &engineRepository) - : transformService(transformService), - streamingService(streamingService), - rayTracingService(rayTracingService), - cameraService(cameraService), - lightService(lightService), - volumeService(volumeService), - worldRepository(worldRepository), - editorRepository(editorRepository), - engineRepository(engineRepository) { + std::vector getDependencies() override { + return { + {"TransformService", transformService}, + {"StreamingService", streamingService}, + {"RayTracingService", rayTracingService}, + {"CameraService", cameraService}, + {"LightService", lightService}, + {"VolumeService", volumeService}, + {"WorldRepository", worldRepository}, + {"EditorRepository", editorRepository}, + {"EngineRepository", engineRepository} + }; } + GlobalDataUBO &getGlobalDataUBO() { return globalDataUBO; } void setCameraUpdated(const bool val) { @@ -79,8 +75,6 @@ namespace Metal { return giSettingsUpdated; } - void onInitialize() override; - void updateCurrentTime(); long long currentTimeMs = 0; @@ -90,6 +84,7 @@ namespace Metal { std::vector registeredFrames; EngineFrame *currentFrame = nullptr; + void updateGlobalData(); void registerFrame(EngineFrame *frame) { @@ -102,7 +97,7 @@ namespace Metal { void onSync() override; - void dispose(); + void dispose() override; }; } #endif diff --git a/src/engine/dto/BoundingBox.h b/src/engine/dto/BoundingBox.h index ec6de8bb..74fdbb0a 100644 --- a/src/engine/dto/BoundingBox.h +++ b/src/engine/dto/BoundingBox.h @@ -1,10 +1,10 @@ #ifndef BOUNDINGBOX_H #define BOUNDINGBOX_H #include -#include "../../common/Serializable.h" +#include "../../common/ISerialize.h" namespace Metal { - struct BoundingBox final : Serializable { + struct BoundingBox final : ISerialize { glm::vec3 min = glm::vec3(std::numeric_limits::max()); glm::vec3 max = glm::vec3(std::numeric_limits::lowest()); glm::vec3 center = glm::vec3(0.0f); diff --git a/src/engine/dto/Camera.h b/src/engine/dto/Camera.h index 70928a1c..ac38f427 100644 --- a/src/engine/dto/Camera.h +++ b/src/engine/dto/Camera.h @@ -7,11 +7,11 @@ #include #include "../../common/Inspectable.h" -#include "../../common/Serializable.h" +#include "../../common/ISerialize.h" namespace Metal { - struct Camera final : Inspectable, Serializable { + struct Camera final : Inspectable, ISerialize { float rotationSensitivity = 1; float movementSensitivity = 1.0f; float zoomSensitivity = 1.0f; diff --git a/src/engine/dto/MetadataComponent.h b/src/engine/dto/MetadataComponent.h index 59928072..14848c28 100644 --- a/src/engine/dto/MetadataComponent.h +++ b/src/engine/dto/MetadataComponent.h @@ -7,10 +7,10 @@ #include "../../editor/enum/engine-definitions.h" #include "../enum/ComponentType.h" #include "../../common/Inspectable.h" -#include "../../common/Serializable.h" +#include "../../common/ISerialize.h" namespace Metal { - struct MetadataComponent final : AbstractComponent, Serializable { + struct MetadataComponent final : AbstractComponent, ISerialize { std::string name = "New entity"; glm::vec3 color{1,1,1}; diff --git a/src/engine/dto/PrimitiveComponent.h b/src/engine/dto/PrimitiveComponent.h index 5b112d5c..3f6e80ef 100644 --- a/src/engine/dto/PrimitiveComponent.h +++ b/src/engine/dto/PrimitiveComponent.h @@ -2,11 +2,11 @@ #define PRIMITIVE_COMPONENT_H #include "AbstractComponent.h" -#include "../../common/Serializable.h" +#include "../../common/ISerialize.h" #include namespace Metal { - struct PrimitiveComponent final : AbstractComponent, Serializable { + struct PrimitiveComponent final : AbstractComponent, ISerialize { std::string meshId; std::string albedo; diff --git a/src/engine/dto/SparseVoxelOctreeData.h b/src/engine/dto/SparseVoxelOctreeData.h index 0c4f3be5..8799a44e 100644 --- a/src/engine/dto/SparseVoxelOctreeData.h +++ b/src/engine/dto/SparseVoxelOctreeData.h @@ -4,10 +4,10 @@ #include #include -#include "../../common/Serializable.h" +#include "../../common/ISerialize.h" namespace Metal { - struct SparseVoxelOctreeData final : Serializable { + struct SparseVoxelOctreeData final : ISerialize { std::vector data{}; unsigned int voxelBufferOffset; diff --git a/src/engine/dto/TileInfoUBO.h b/src/engine/dto/TileInfoUBO.h deleted file mode 100644 index f2dd1a80..00000000 --- a/src/engine/dto/TileInfoUBO.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef TILEINFOUBO_H -#define TILEINFOUBO_H -#include -#include - -namespace Metal { - struct TileInfoUBO final { - std::array tileCenterValid{}; - std::array voxelBufferOffset{}; - }; -} - -#endif //TILEINFOUBO_H diff --git a/src/engine/dto/TransformComponent.h b/src/engine/dto/TransformComponent.h index 78974590..b6b4ab0b 100644 --- a/src/engine/dto/TransformComponent.h +++ b/src/engine/dto/TransformComponent.h @@ -6,11 +6,11 @@ #include #include "AbstractComponent.h" -#include "../../common/Serializable.h" +#include "../../common/ISerialize.h" namespace Metal { - struct TransformComponent final : AbstractComponent, Serializable { + struct TransformComponent final : AbstractComponent, ISerialize { glm::mat4x4 model = glm::identity(); glm::vec3 translation{}; glm::vec3 rotationEuler = {0, 0, 0}; diff --git a/src/engine/dto/VolumeComponent.h b/src/engine/dto/VolumeComponent.h index c886278b..f77d5742 100644 --- a/src/engine/dto/VolumeComponent.h +++ b/src/engine/dto/VolumeComponent.h @@ -2,11 +2,11 @@ #define VOLUMECOMPONENT_H #include "AbstractComponent.h" -#include "../../common/Serializable.h" +#include "../../common/ISerialize.h" #include namespace Metal { - struct VolumeComponent final : AbstractComponent, Serializable { + struct VolumeComponent final : AbstractComponent, ISerialize { glm::vec3 albedo = glm::vec3(1.0f); float density = 1; float g = 0; diff --git a/src/engine/frame-builder/EngineFrameBuilder.cpp b/src/engine/frame-builder/EngineFrameBuilder.cpp index 4d8796db..e9295641 100644 --- a/src/engine/frame-builder/EngineFrameBuilder.cpp +++ b/src/engine/frame-builder/EngineFrameBuilder.cpp @@ -3,7 +3,6 @@ #include "structures/FramebufferBuilder.h" #include "structures/TextureBuilder.h" #include "structures/BufferBuilder.h" -#include "structures/PassBuilder.h" #include "structures/CommandBufferRecorderBuilder.h" #include "EngineFrame.h" #include "../../ApplicationContext.h" @@ -112,16 +111,9 @@ namespace Metal { std::unordered_map> > recorderToPasses; std::vector recorderOrder; - for (const auto &builder: builders) { - if (auto *passBuilder = dynamic_cast(builder.get())) { - const auto cbId = passBuilder->getCommandBufferId(); - if (std::ranges::find(recorderOrder, cbId) == recorderOrder.end()) { - recorderOrder.push_back(cbId); - } - } - } - for (auto &pass: passes) { + recorderOrder.push_back(pass.commandBufferId); + pass.pass->frame = frame.get(); pass.pass->onInitialize(); recorderToPasses[pass.commandBufferId].push_back(std::move(pass.pass)); diff --git a/src/engine/frame-builder/EngineFrameBuilder.h b/src/engine/frame-builder/EngineFrameBuilder.h index 63c58cf2..71ff3a60 100644 --- a/src/engine/frame-builder/EngineFrameBuilder.h +++ b/src/engine/frame-builder/EngineFrameBuilder.h @@ -8,7 +8,6 @@ #include #include "structures/ResourceBuilder.h" -#include "../enum/PassType.h" #include "../resource/BufferInstance.h" namespace Metal { diff --git a/src/engine/passes/AbstractPass.h b/src/engine/passes/AbstractPass.h index 8be0960e..be268269 100644 --- a/src/engine/passes/AbstractPass.h +++ b/src/engine/passes/AbstractPass.h @@ -3,7 +3,8 @@ #include #include #include -#include "../../common/AbstractRuntimeComponent.h" +#include "../../common/ISync.h" +#include "../../common/IInit.h" #include "../resource/RuntimeResource.h" namespace Metal { @@ -13,7 +14,7 @@ namespace Metal { class StreamingService; struct PipelineInstance; - class AbstractPass : public AbstractRuntimeComponent { + class AbstractPass : public ISync, public IInit { bool isComputePass; public: diff --git a/src/engine/repository/EngineRepository.h b/src/engine/repository/EngineRepository.h index fe2b81dc..77f3cab7 100644 --- a/src/engine/repository/EngineRepository.h +++ b/src/engine/repository/EngineRepository.h @@ -1,11 +1,11 @@ #ifndef ENGINEREPO_H #define ENGINEREPO_H -#include "../../common/Inspectable.h" #include -#include "../../common/Serializable.h" + +#include "../../common/IRepository.h" namespace Metal { - struct EngineRepository final : Inspectable, Serializable { + struct EngineRepository final : IRepository { bool vsync = true; bool denoiserEnabled = false; diff --git a/src/engine/repository/RuntimeRepository.h b/src/engine/repository/RuntimeRepository.h index 37215d86..f7c87003 100644 --- a/src/engine/repository/RuntimeRepository.h +++ b/src/engine/repository/RuntimeRepository.h @@ -3,8 +3,7 @@ #include namespace Metal { - struct RuntimeRepository { - + struct RuntimeRepository : IContextMember { bool isFocused; int displayW; int displayH; diff --git a/src/engine/repository/WorldRepository.cpp b/src/engine/repository/WorldRepository.cpp index 519cb1a5..eb2457d6 100644 --- a/src/engine/repository/WorldRepository.cpp +++ b/src/engine/repository/WorldRepository.cpp @@ -4,6 +4,7 @@ #include "../enum/ComponentType.h" #include "../../editor/dto/SceneData.h" #include "../../common/serialization-definitions.h" +#include "../../core/DirectoryService.h" namespace Metal { entt::entity WorldRepository::createEntity() { @@ -35,7 +36,7 @@ namespace Metal { registry.destroy(entityId); } - rayTracingService.markDirty(); + rayTracingService->markDirty(); } void WorldRepository::changeVisibility(entt::entity entity, bool isVisible) { @@ -45,12 +46,12 @@ namespace Metal { } else { hiddenEntities.insert({entity, true}); } - rayTracingService.markDirty(); + rayTracingService->markDirty(); } void WorldRepository::loadScene(const std::string &sceneId) { SceneData sceneData; - const auto pathToFile = rootDirectory + "/assets/" + FORMAT_FILE_SCENE(sceneId); + const auto pathToFile = directoryService->getAssetDirectory() + FORMAT_FILE_SCENE(sceneId); PARSE_TEMPLATE(sceneData, pathToFile) for (auto &entityData: sceneData.entities) { @@ -86,7 +87,7 @@ namespace Metal { } } - rayTracingService.markDirty(); + rayTracingService->markDirty(); } void WorldRepository::createComponent(const entt::entity entityId, ComponentType type) { diff --git a/src/engine/repository/WorldRepository.h b/src/engine/repository/WorldRepository.h index 0e261522..737df3dd 100644 --- a/src/engine/repository/WorldRepository.h +++ b/src/engine/repository/WorldRepository.h @@ -1,38 +1,35 @@ #ifndef WORLDREPOSITORY_H #define WORLDREPOSITORY_H -#include #include #include -#include -#include "../../common/AbstractRuntimeComponent.h" -#include "../../common/Serializable.h" -#include "../../editor/enum/engine-definitions.h" +#include "../../common/IRepository.h" #include "../dto/Camera.h" -#include "../dto/MetadataComponent.h" #include "../enum/ComponentType.h" -#include "../dto/TransformComponent.h" -#include "../dto/PrimitiveComponent.h" -#include "../dto/VolumeComponent.h" namespace Metal { + struct MetadataComponent; class Inspectable; class RayTracingService; + class DirectoryService; - struct WorldRepository final : AbstractRuntimeComponent, Serializable { - RayTracingService &rayTracingService; - std::string &rootDirectory; - - WorldRepository(RayTracingService &rayTracingService, std::string &rootDirectory) - : rayTracingService(rayTracingService), rootDirectory(rootDirectory) { - } + struct WorldRepository final : IRepository { + RayTracingService *rayTracingService; + DirectoryService *directoryService; Camera camera{-(glm::pi() / 4), glm::pi() / 4, {10, 10, 10}}; entt::registry registry{}; std::unordered_map culled{}; std::unordered_map hiddenEntities{}; + std::vector getDependencies() override { + return { + {"RayTracingService", rayTracingService}, + {"DirectoryService", directoryService} + }; + } + void createComponent(entt::entity entity, ComponentType type); entt::entity createEntity(); @@ -48,7 +45,6 @@ namespace Metal { nlohmann::json toJson() const override; void fromJson(const nlohmann::json &j) override; - }; } // Metal diff --git a/src/engine/service/BufferService.h b/src/engine/service/BufferService.h index 8b6b3632..4c77aa73 100644 --- a/src/engine/service/BufferService.h +++ b/src/engine/service/BufferService.h @@ -12,7 +12,7 @@ namespace Metal { class VulkanContext; class BufferService final : public AbstractResourceService { - VulkanContext &vulkanContext; + VulkanContext *vulkanContext = nullptr; void copyBuffer(const BufferInstance *srcBuffer, const BufferInstance *dstBuffer) const; @@ -21,8 +21,9 @@ namespace Metal { BufferInstance *buffer) const; public: - explicit BufferService(VulkanContext &vulkanContext) : vulkanContext(vulkanContext) {} - BufferService() = delete; + BufferService() = default; + + std::vector getDependencies() override; [[nodiscard]] unsigned int findMemoryType(unsigned int typeFilter, VkMemoryPropertyFlags properties) const; diff --git a/src/engine/service/CameraService.cpp b/src/engine/service/CameraService.cpp index 9391b3d7..37dff1aa 100644 --- a/src/engine/service/CameraService.cpp +++ b/src/engine/service/CameraService.cpp @@ -10,12 +10,12 @@ namespace Metal { // Per frame // TODO - EVENT SYSTEM void CameraService::onSync() { - camera = &worldRepository.camera; + camera = &worldRepository->camera; if (camera != nullptr) { updateAspectRatio(); if (camera->isNotFrozen()) { updateMatrices(); - engineContext.setCameraUpdated(true); + engineContext->setCameraUpdated(true); camera->freezeVersion(); } } @@ -23,7 +23,7 @@ namespace Metal { void CameraService::updateAspectRatio() const { const float prevAspect = camera->aspectRatio; - camera->aspectRatio = runtimeRepository.viewportW / runtimeRepository.viewportH; + camera->aspectRatio = runtimeRepository->viewportW / runtimeRepository->viewportH; if (prevAspect != camera->aspectRatio) { camera->registerChange(); } @@ -57,10 +57,6 @@ namespace Metal { camera->invProjectionMatrix = glm::inverse(camera->projectionMatrix); } - CameraService::CameraService(EngineContext &engineContext, WorldRepository &worldRepository, RuntimeRepository &runtimeRepository) - : engineContext(engineContext), worldRepository(worldRepository), runtimeRepository(runtimeRepository) { - } - void CameraService::handleInputInternal() const { glm::vec3 forward( -std::sin(camera->yaw) * std::cos(camera->pitch), @@ -76,16 +72,16 @@ namespace Metal { right = glm::normalize(right); const float multiplier = 10 * camera->movementSensitivity * - engineContext.deltaTime; - if (runtimeRepository.leftPressed) { + engineContext->deltaTime; + if (runtimeRepository->leftPressed) { camera->position += right * multiplier; camera->registerChange(); } - if (runtimeRepository.rightPressed) { + if (runtimeRepository->rightPressed) { camera->position -= right * multiplier; camera->registerChange(); } - if (runtimeRepository.backwardPressed) { + if (runtimeRepository->backwardPressed) { if (camera->isOrthographic) { camera->orthographicProjectionSize += multiplier; } else { @@ -93,7 +89,7 @@ namespace Metal { } camera->registerChange(); } - if (runtimeRepository.forwardPressed) { + if (runtimeRepository->forwardPressed) { if (camera->isOrthographic) { camera->orthographicProjectionSize -= multiplier; } else { @@ -118,8 +114,8 @@ namespace Metal { } void CameraService::updateDelta(const bool isFirstMovement) const { - const float mouseX = runtimeRepository.mouseX; - const float mouseY = runtimeRepository.mouseY; + const float mouseX = runtimeRepository->mouseX; + const float mouseY = runtimeRepository->mouseY; if (isFirstMovement) { camera->lastMouseX = mouseX; diff --git a/src/engine/service/CameraService.h b/src/engine/service/CameraService.h index 3109c51d..7e2fe9cb 100644 --- a/src/engine/service/CameraService.h +++ b/src/engine/service/CameraService.h @@ -1,10 +1,12 @@ #ifndef CAMERASYSTEM_H #define CAMERASYSTEM_H -#include "../../common/AbstractRuntimeComponent.h" +#include "../../common/ISync.h" #include #include +#include "../../common/IService.h" + constexpr float PI_OVER_2 = glm::pi() / 2.0f; constexpr float PI_2 = glm::pi() * 2.0f; constexpr float MIN_MAX_PITCH = glm::radians(89.0f); @@ -18,10 +20,10 @@ namespace Metal { struct RuntimeRepository; struct Camera; - class CameraService final : public AbstractRuntimeComponent { - EngineContext &engineContext; - WorldRepository &worldRepository; - RuntimeRepository &runtimeRepository; + class CameraService final : public IService, public ISync { + EngineContext *engineContext = nullptr; + WorldRepository *worldRepository = nullptr; + RuntimeRepository *runtimeRepository = nullptr; Camera *camera = nullptr; glm::vec3 xAxis{0.0f}; @@ -47,7 +49,13 @@ namespace Metal { public: void handleInput(bool isFirstMovement) const; - explicit CameraService(EngineContext &engineContext, WorldRepository &worldRepository, RuntimeRepository &runtimeRepository); + std::vector getDependencies() override { + return { + {"EngineContext", engineContext}, + {"WorldRepository", worldRepository}, + {"RuntimeRepository", runtimeRepository} + }; + } void onSync() override; }; diff --git a/src/engine/service/DescriptorSetService.cpp b/src/engine/service/DescriptorSetService.cpp index 3032fec6..71a8a55d 100644 --- a/src/engine/service/DescriptorSetService.cpp +++ b/src/engine/service/DescriptorSetService.cpp @@ -1,7 +1,7 @@ #include "DescriptorSetService.h" #include "../dto/PipelineBuilder.h" #include "../resource/BufferInstance.h" -#include "../../editor/service/LogService.h" +#include "../../common/LoggerUtil.h" #include "../../core/vulkan/VulkanContext.h" #include "FrameBufferService.h" #include "BufferService.h" @@ -12,10 +12,11 @@ #include "../../core/vulkan/VulkanUtils.h" namespace Metal { - DescriptorInstance *DescriptorSetService::createDescriptor(const PipelineBuilder &pipelineBuilder, const std::string &id, VkShaderStageFlags stageFlags) { + DescriptorInstance *DescriptorSetService::createDescriptor(const PipelineBuilder &pipelineBuilder, + const std::string &id, VkShaderStageFlags stageFlags) { auto *descriptorInstance = createResourceInstance(id); - for (auto &builder : pipelineBuilder.resourceBindings) { + for (auto &builder: pipelineBuilder.resourceBindings) { DescriptorBinding binding{}; binding.bindingPoint = builder.bindingPoint; binding.descriptorCount = builder.descriptorCount; @@ -36,7 +37,7 @@ namespace Metal { } binding.view = fbo->attachments[binding.attachmentIndex]->vkImageView; if (binding.sampler == VK_NULL_HANDLE) { - binding.sampler = vulkanContext.vkImageSampler; + binding.sampler = vulkanContext->vkImageSampler; } } @@ -45,7 +46,7 @@ namespace Metal { binding.descriptorType = VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR; break; case DescriptorBindingType::BUFFER: { - BufferInstance *buffer = bufferService.getResource(binding.bufferId); + BufferInstance *buffer = bufferService->getResource(binding.bufferId); if (buffer != nullptr) { binding.descriptorType = buffer->getBufferType() == BufferType::UNIFORM_BUFFER @@ -80,26 +81,27 @@ namespace Metal { void DescriptorSetService::disposeResource(DescriptorInstance *resource) { LOG_INFO("Disposing of descriptor set resource"); - vkDestroyDescriptorSetLayout(vulkanContext.device.device, resource->vkDescriptorSetLayout, nullptr); + vkDestroyDescriptorSetLayout(vulkanContext->device.device, resource->vkDescriptorSetLayout, nullptr); } std::vector DescriptorSetService::getAllDescriptors() const { std::vector descriptors; std::lock_guard lock(resourceMutex); - for (auto const& [id, descriptor] : resources) { + for (auto const &[id, descriptor]: resources) { descriptors.emplace_back(descriptor); } return descriptors; } void DescriptorSetService::setImageDescriptor(const FrameBufferInstance *framebuffer, - unsigned int attachmentIndex) { + unsigned int attachmentIndex) { auto attachment = framebuffer->attachments[attachmentIndex]; if (attachment->imageDescriptor == nullptr) { - attachment->imageDescriptor = createResourceInstance(framebuffer->getId() + std::to_string(attachmentIndex)); + attachment->imageDescriptor = + createResourceInstance(framebuffer->getId() + std::to_string(attachmentIndex)); attachment->imageDescriptor->bindings.push_back(DescriptorBinding::Of(VK_SHADER_STAGE_FRAGMENT_BIT, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 0, - vulkanContext.vkImageSampler, + vulkanContext->vkImageSampler, attachment->vkImageView)); updateDescriptor(attachment->imageDescriptor); } @@ -109,14 +111,15 @@ namespace Metal { if (texture->imageDescriptor == nullptr) { texture->imageDescriptor = createResourceInstance(texture->getId() + "_descriptor"); texture->imageDescriptor->bindings.push_back(DescriptorBinding::Of(VK_SHADER_STAGE_FRAGMENT_BIT, - VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, - 0, - texture->vkSampler, - texture->vkImageView + VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, + 0, + texture->vkSampler, + texture->vkImageView )); updateDescriptor(texture->imageDescriptor); } } + void DescriptorSetService::updateDescriptor(DescriptorInstance *descriptor) { if (descriptor->bindings.empty()) { throw std::runtime_error("No descriptor layout sets were created"); @@ -134,7 +137,8 @@ namespace Metal { samplerLayoutBinding.pImmutableSamplers = nullptr; if (binding.descriptorCount > 1) { - bindingFlags.push_back(VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT | VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT); + bindingFlags.push_back( + VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT | VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT); } else { bindingFlags.push_back(0); } @@ -153,31 +157,32 @@ namespace Metal { layoutInfo.flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT_EXT; layoutInfo.pNext = &flagsInfo; - VulkanUtils::CheckVKResult(vkCreateDescriptorSetLayout(vulkanContext.device.device, &layoutInfo, + VulkanUtils::CheckVKResult(vkCreateDescriptorSetLayout(vulkanContext->device.device, &layoutInfo, nullptr, &descriptor->vkDescriptorSetLayout)); VkDescriptorSetAllocateInfo allocInfo = {}; allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; - allocInfo.descriptorPool = vulkanContext.descriptorPool; // Created during setup + allocInfo.descriptorPool = vulkanContext->descriptorPool; // Created during setup allocInfo.descriptorSetCount = 1; allocInfo.pSetLayouts = &descriptor->vkDescriptorSetLayout; - VulkanUtils::CheckVKResult(vkAllocateDescriptorSets(vulkanContext.device.device, &allocInfo, &descriptor->vkDescriptorSet)); + VulkanUtils::CheckVKResult( + vkAllocateDescriptorSets(vulkanContext->device.device, &allocInfo, &descriptor->vkDescriptorSet)); // WRITE - Write(vulkanContext, bufferService, descriptor->vkDescriptorSet, descriptor->bindings); + Write(descriptor->vkDescriptorSet, descriptor->bindings); } void DescriptorSetService::write(DescriptorInstance *descriptor) { - Write(vulkanContext, bufferService, descriptor->vkDescriptorSet, descriptor->bindings); + Write(descriptor->vkDescriptorSet, descriptor->bindings); } - void DescriptorSetService::Write(VulkanContext &vulkanContext, BufferService &bufferService, const VkDescriptorSet &vkDescriptorSet, + void DescriptorSetService::Write(const VkDescriptorSet &vkDescriptorSet, const std::vector &bindings) { std::vector writeDescriptorSets; std::vector bufferInfos; - std::vector> imageInfosPool; + std::vector > imageInfosPool; std::vector asInfos; bufferInfos.reserve(bindings.size()); @@ -207,7 +212,7 @@ namespace Metal { writeDescriptorSets.push_back(descriptorWrite); } } else if (!binding.bufferId.empty()) { - BufferInstance *buffer = bufferService.getResource(binding.bufferId); + BufferInstance *buffer = bufferService->getResource(binding.bufferId); if (buffer == nullptr) { LOG_ERROR("DescriptorSetService Buffer not found: " + binding.bufferId); @@ -261,7 +266,7 @@ namespace Metal { if (writeDescriptorSets.empty()) return; - vkUpdateDescriptorSets(vulkanContext.device.device, + vkUpdateDescriptorSets(vulkanContext->device.device, static_cast(writeDescriptorSets.size()), writeDescriptorSets.data(), 0, diff --git a/src/engine/service/DescriptorSetService.h b/src/engine/service/DescriptorSetService.h index f5ebde4e..52e420fe 100644 --- a/src/engine/service/DescriptorSetService.h +++ b/src/engine/service/DescriptorSetService.h @@ -14,17 +14,23 @@ namespace Metal { class TextureService; class DescriptorSetService final : public AbstractResourceService { - VulkanContext &vulkanContext; - FrameBufferService &framebufferService; - BufferService &bufferService; - TextureService &textureService; + VulkanContext *vulkanContext = nullptr; + FrameBufferService *framebufferService = nullptr; + BufferService *bufferService = nullptr; + TextureService *textureService = nullptr; public: - DescriptorSetService(VulkanContext &vulkanContext, FrameBufferService &framebufferService, BufferService &bufferService, TextureService &textureService) - : vulkanContext(vulkanContext), framebufferService(framebufferService), bufferService(bufferService), textureService(textureService) {} - DescriptorSetService() = delete; - - DescriptorInstance *createDescriptor(const PipelineBuilder &pipelineBuilder, const std::string &id, VkShaderStageFlags stageFlags); + std::vector getDependencies() override { + return { + {"VulkanContext", vulkanContext}, + {"FrameBufferService", framebufferService}, + {"BufferService", bufferService}, + {"TextureService", textureService} + }; + } + + DescriptorInstance *createDescriptor(const PipelineBuilder &pipelineBuilder, const std::string &id, + VkShaderStageFlags stageFlags); void disposeResource(DescriptorInstance *resource) override; @@ -38,7 +44,7 @@ namespace Metal { void write(DescriptorInstance *descriptor); - static void Write(VulkanContext &vulkanContext, BufferService &bufferService, const VkDescriptorSet &vkDescriptorSet, const std::vector &bindings); + void Write(const VkDescriptorSet &vkDescriptorSet, const std::vector &bindings); }; } diff --git a/src/engine/service/FrameBufferService.h b/src/engine/service/FrameBufferService.h index 33694124..76676188 100644 --- a/src/engine/service/FrameBufferService.h +++ b/src/engine/service/FrameBufferService.h @@ -15,7 +15,7 @@ namespace Metal { class VulkanContext; class FrameBufferService final : public AbstractResourceService { - VulkanContext &vulkanContext; + VulkanContext *vulkanContext = nullptr; std::shared_ptr createAttachmentInternal(VkFormat format, VkImageUsageFlagBits usage, @@ -24,8 +24,9 @@ namespace Metal { void createVKFrameBuffer(FrameBufferInstance *framebuffer) const; public: - explicit FrameBufferService(VulkanContext &vulkanContext) : vulkanContext(vulkanContext) {} - FrameBufferService() = delete; + std::vector getDependencies() override { + return {{"VulkanContext", vulkanContext}}; + } FrameBufferInstance *createFrameBuffer(const std::string &id, unsigned int w, unsigned int h, glm::vec4 clearColor = glm::vec4(0.0f)); diff --git a/src/engine/service/LightService.cpp b/src/engine/service/LightService.cpp index 3f4ca266..de69de89 100644 --- a/src/engine/service/LightService.cpp +++ b/src/engine/service/LightService.cpp @@ -17,19 +17,18 @@ namespace Metal { registerLights(); if (!items.empty()) { - engineContext.currentFrame->getResourceAs(RID_LIGHT_BUFFER)->update(items.data()); + engineContext->currentFrame->getResourceAs(RID_LIGHT_BUFFER)->update(items.data()); } } void LightService::computeSunInfo() { sunPosition = glm::vec3(0, - std::cos(engineRepository.elapsedTime), - std::sin(engineRepository.elapsedTime)) * engineRepository - .sunDistance; + std::cos(engineRepository->elapsedTime), + std::sin(engineRepository->elapsedTime)) * engineRepository->sunDistance; sunColor = LightService::CalculateSunColor( - sunPosition.y / engineRepository.sunDistance, - engineRepository.nightColor, engineRepository.dawnColor, - engineRepository.middayColor); + sunPosition.y / engineRepository->sunDistance, + engineRepository->nightColor, engineRepository->dawnColor, + engineRepository->middayColor); } glm::vec3 LightService::CalculateSunColor(const float elevation, glm::vec3 &nightColor, glm::vec3 &dawnColor, diff --git a/src/engine/service/LightService.h b/src/engine/service/LightService.h index 905b53e0..3a5c7575 100644 --- a/src/engine/service/LightService.h +++ b/src/engine/service/LightService.h @@ -2,16 +2,17 @@ #define LIGHTSSERVICE_H #include -#include "../../common/AbstractRuntimeComponent.h" +#include "../../common/IService.h" +#include "../../common/ISync.h" #include "../dto/LightData.h" namespace Metal { class EngineContext; struct EngineRepository; - class LightService final : public AbstractRuntimeComponent { - EngineContext &engineContext; - EngineRepository &engineRepository; + class LightService final : public IService, public ISync{ + EngineContext *engineContext = nullptr; + EngineRepository *engineRepository = nullptr; std::vector items{}; glm::vec3 sunColor{}; @@ -25,9 +26,12 @@ namespace Metal { static glm::vec3 BlendColors(glm::vec3 &c1, glm::vec3 &c2, float t); public: - explicit LightService(EngineContext &engineContext, EngineRepository &engineRepository) - : engineContext(engineContext), engineRepository(engineRepository) {} - LightService() = delete; + std::vector getDependencies() override { + return { + {"EngineContext", engineContext}, + {"EngineRepository", engineRepository} + }; + } void onSync() override; diff --git a/src/engine/service/MaterialService.cpp b/src/engine/service/MaterialService.cpp index 4c41d172..ef66308c 100644 --- a/src/engine/service/MaterialService.cpp +++ b/src/engine/service/MaterialService.cpp @@ -6,6 +6,7 @@ #include "../dto/PrimitiveComponent.h" namespace Metal { + void MaterialService::load(MeshMetadata &materialData, PrimitiveComponent &data) { materialData.albedo = data.albedoColor; materialData.roughness = data.roughnessFactor; @@ -20,21 +21,21 @@ namespace Metal { materialData.metallicTextureId = 0; if (!data.albedo.empty()) { - auto *tex = textureService.stream(data.albedo); + auto *tex = textureService->stream(data.albedo); if (tex != nullptr) { - materialData.albedoTextureId = textureService.getTextureIndex(data.albedo); + materialData.albedoTextureId = textureService->getTextureIndex(data.albedo); } } if (!data.roughness.empty()) { - auto *tex = textureService.stream(data.roughness); + auto *tex = textureService->stream(data.roughness); if (tex != nullptr) { - materialData.roughnessTextureId = textureService.getTextureIndex(data.roughness); + materialData.roughnessTextureId = textureService->getTextureIndex(data.roughness); } } if (!data.metallic.empty()) { - auto *tex = textureService.stream(data.metallic); + auto *tex = textureService->stream(data.metallic); if (tex != nullptr) { - materialData.metallicTextureId = textureService.getTextureIndex(data.metallic); + materialData.metallicTextureId = textureService->getTextureIndex(data.metallic); } } } diff --git a/src/engine/service/MaterialService.h b/src/engine/service/MaterialService.h index 9c1668bc..660c48b8 100644 --- a/src/engine/service/MaterialService.h +++ b/src/engine/service/MaterialService.h @@ -1,16 +1,21 @@ #ifndef MATERIALSERVICE_H #define MATERIALSERVICE_H +#include "../../common/IService.h" namespace Metal { struct PrimitiveComponent; struct MeshMetadata; class TextureService; - class MaterialService final { - TextureService &textureService; + class MaterialService final : public IService { + TextureService *textureService = nullptr; + public: - explicit MaterialService(TextureService &textureService) : textureService(textureService) {} - MaterialService() = delete; + std::vector getDependencies() override { + return { + {"TextureService", textureService} + }; + } void load(MeshMetadata &data, PrimitiveComponent &component); }; diff --git a/src/engine/service/MeshService.cpp b/src/engine/service/MeshService.cpp index 2b9488ea..417887bf 100644 --- a/src/engine/service/MeshService.cpp +++ b/src/engine/service/MeshService.cpp @@ -4,7 +4,8 @@ #include "../../editor/dto/SceneData.h" #include "../../core/vulkan/VulkanContext.h" -#include "../../editor/util/FilesUtil.h" +#include "../../common/FilesUtil.h" +#include "../../core/DirectoryService.h" #include #include @@ -15,6 +16,7 @@ #include "RayTracingService.h" namespace Metal { + MeshInstance *MeshService::create(const std::string &id) { MeshData *data = loadMeshData(id); if (data == nullptr) { @@ -25,14 +27,14 @@ namespace Metal { instance->indexCount = data->indices.size(); instance->vertexCount = data->data.size(); - instance->dataBuffer = bufferService.createBuffer( + instance->dataBuffer = bufferService->createBuffer( id + "_data", sizeof(VertexData) * data->data.size(), VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, data->data.data(), true); - instance->indexBuffer = bufferService.createBuffer( + instance->indexBuffer = bufferService->createBuffer( id + "_indices", sizeof(unsigned int) * data->indices.size(), VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, @@ -56,7 +58,7 @@ namespace Metal { } MeshData *MeshService::loadMeshData(const std::string &id) const { - auto pathToFile = rootDirectory + "/assets/" + FORMAT_FILE_MESH(id); + auto pathToFile = directoryService->getRootDirectory() + "/assets/" + FORMAT_FILE_MESH(id); if (std::filesystem::exists(pathToFile)) { auto *data = new MeshData; std::ifstream input(pathToFile, std::ios::binary); @@ -69,8 +71,8 @@ namespace Metal { void MeshService::disposeResource(MeshInstance *resource) { LOG_INFO("Disposing of mesh instance"); - rayTracingService.markDirty(); - bufferService.dispose(resource->indexBuffer->getId()); - bufferService.dispose(resource->dataBuffer->getId()); + rayTracingService->markDirty(); + bufferService->dispose(resource->indexBuffer->getId()); + bufferService->dispose(resource->dataBuffer->getId()); } } // Metal diff --git a/src/engine/service/MeshService.h b/src/engine/service/MeshService.h index 40ba1270..b7984f35 100644 --- a/src/engine/service/MeshService.h +++ b/src/engine/service/MeshService.h @@ -11,16 +11,23 @@ namespace Metal { class BufferService; class RayTracingService; + class DirectoryService; class MeshService final : public AbstractResourceService { - BufferService &bufferService; - RayTracingService &rayTracingService; - const std::string &rootDirectory; + BufferService *bufferService = nullptr; + RayTracingService *rayTracingService = nullptr; + DirectoryService *directoryService = nullptr; public: - MeshService(BufferService &bufferService, RayTracingService &rayTracingService, const std::string &rootDirectory) - : bufferService(bufferService), rayTracingService(rayTracingService), rootDirectory(rootDirectory) {} - MeshService() = delete; + MeshService() = default; + + std::vector getDependencies() override { + return { + {"BufferService", bufferService}, + {"RayTracingService", rayTracingService}, + {"DirectoryService", directoryService} + }; + } MeshInstance *create(const std::string &id); @@ -29,7 +36,6 @@ namespace Metal { MeshData *loadMeshData(const std::string &id) const; void disposeResource(MeshInstance *resource) override; - }; } // Metal diff --git a/src/engine/service/PipelineService.h b/src/engine/service/PipelineService.h index 55d4852f..a80bbe1f 100644 --- a/src/engine/service/PipelineService.h +++ b/src/engine/service/PipelineService.h @@ -18,21 +18,16 @@ namespace Metal { class BufferService; class PipelineService final : public AbstractResourceService { - VulkanContext &vulkanContext; - FrameBufferService &framebufferService; - BufferService &bufferService; - DescriptorSetService &descriptorSetService; - ShaderService &shaderService; + VulkanContext *vulkanContext = nullptr; + FrameBufferService *framebufferService = nullptr; + BufferService *bufferService = nullptr; + DescriptorSetService *descriptorSetService = nullptr; + ShaderService *shaderService = nullptr; public: - explicit PipelineService(ShaderService &shaderService, VulkanContext &vulkanContext, - FrameBufferService &framebufferService, BufferService &bufferService, - DescriptorSetService &descriptorSetService) - : shaderService(shaderService), vulkanContext(vulkanContext), framebufferService(framebufferService), - bufferService(bufferService), descriptorSetService(descriptorSetService) { - } - - PipelineService() = delete; + PipelineService() = default; + + std::vector getDependencies() override; PipelineInstance *createPipeline(PipelineBuilder &pipelineBuilder); diff --git a/src/engine/service/RayTracingService.cpp b/src/engine/service/RayTracingService.cpp index 26c09a41..902a8641 100644 --- a/src/engine/service/RayTracingService.cpp +++ b/src/engine/service/RayTracingService.cpp @@ -12,6 +12,7 @@ #include "../repository/WorldRepository.h" #include "MeshService.h" #include "MaterialService.h" +#include "DescriptorSetService.h" #include "BufferService.h" #include "../EngineContext.h" #include @@ -25,7 +26,7 @@ namespace Metal { } void RayTracingService::updateDescriptorSets(VkAccelerationStructureKHR asHandle) { - auto descriptors = pipelineService.getAllDescriptors(); + auto descriptors = pipelineService->getAllDescriptors(); for (auto *descriptor: descriptors) { bool needsUpdate = false; for (auto &binding: descriptor->bindings) { @@ -36,7 +37,7 @@ namespace Metal { } if (needsUpdate) { - DescriptorSetService::Write(vulkanContext, bufferService, descriptor->vkDescriptorSet, descriptor->bindings); + descriptorService->Write(vulkanContext, bufferService, descriptor->vkDescriptorSet, descriptor->bindings); } } } @@ -66,7 +67,7 @@ namespace Metal { if (!anyMeshes) { // No meshes – destroy all structures and set descriptor to null - destroyAccelerationStructures(); // destroys BLAS and TLAS (waits for idle) + dispose(); // destroys BLAS and TLAS (waits for idle) updateDescriptorSets(VK_NULL_HANDLE); accelerationStructureBuilt = false; needsRebuild = false; @@ -401,7 +402,7 @@ namespace Metal { vulkan.endSingleTimeCommands(cmd); } - void RayTracingService::destroyAccelerationStructures() { + void RayTracingService::dispose() { LOG_INFO("Destroying acceleration structures"); auto &vulkan = vulkanContext; diff --git a/src/engine/service/RayTracingService.h b/src/engine/service/RayTracingService.h index 7d90afd3..4ecc20b2 100644 --- a/src/engine/service/RayTracingService.h +++ b/src/engine/service/RayTracingService.h @@ -2,13 +2,13 @@ #define RAYTRACINGSERVICE_H #include "../dto/MeshMetadata.h" -#include "../../editor/enum/engine-definitions.h" -#include #include #include #include #include -#include "../../common/AbstractRuntimeComponent.h" +#include "../../common/IService.h" +#include "../../common/ISync.h" +#include "../../common/IDisposable.h" namespace Metal { class BufferInstance; @@ -19,15 +19,17 @@ namespace Metal { class MaterialService; class BufferService; class EngineContext; - - class RayTracingService final : public AbstractRuntimeComponent { - VulkanContext &vulkanContext; - PipelineService &pipelineService; - WorldRepository &worldRepository; - MeshService &meshService; - MaterialService &materialService; - BufferService &bufferService; - EngineContext &engineContext; + class DescriptorService; + + class RayTracingService final : public IService, public ISync, public IDisposable { + VulkanContext *vulkanContext = nullptr; + PipelineService *pipelineService = nullptr; + WorldRepository *worldRepository = nullptr; + MeshService *meshService = nullptr; + MaterialService *materialService = nullptr; + BufferService *bufferService = nullptr; + EngineContext *engineContext = nullptr; + DescriptorService *descriptorService = nullptr; struct BLASEntry { VkAccelerationStructureKHR accelerationStructure = VK_NULL_HANDLE; @@ -36,6 +38,7 @@ namespace Metal { BufferInstance *vertexData = nullptr; BufferInstance *indexData = nullptr; }; + bool anyMeshes = false; // One BLAS per unique mesh ID @@ -66,15 +69,26 @@ namespace Metal { void updateMeshMaterials(); public: - RayTracingService(VulkanContext &vulkanContext, PipelineService &pipelineService, WorldRepository &worldRepository, MeshService &meshService, MaterialService &materialService, BufferService &bufferService, EngineContext &engineContext) - : vulkanContext(vulkanContext), pipelineService(pipelineService), worldRepository(worldRepository), meshService(meshService), materialService(materialService), bufferService(bufferService), engineContext(engineContext) {} - RayTracingService() = delete; + RayTracingService() = default; + + std::vector getDependencies() override { + return { + {"VulkanContext", vulkanContext}, + {"PipelineService", pipelineService}, + {"WorldRepository", worldRepository}, + {"MeshService", meshService}, + {"MaterialService", materialService}, + {"BufferService", bufferService}, + {"EngineContext", engineContext}, + {"DescriptorService", descriptorService} + }; + } void setNeedsMaterialUpdate(bool val) { needsMaterialUpdate = val; } - void destroyAccelerationStructures(); + void dispose() override; void onSync() override; diff --git a/src/engine/service/ShaderService.cpp b/src/engine/service/ShaderService.cpp index 8e062433..acb0ec4e 100644 --- a/src/engine/service/ShaderService.cpp +++ b/src/engine/service/ShaderService.cpp @@ -10,12 +10,15 @@ #include "../../core/vulkan/VulkanUtils.h" #include "../../editor/util/Util.h" #include "../../ApplicationContext.h" -#include "../../editor/util/FilesUtil.h" -#include "../../editor/service/LogService.h" +#include "../../common/FilesUtil.h" +#include "../../common/LoggerUtil.h" #include "../../editor/enum/ShadingMode.h" #include "glslang/Include/glslang_c_interface.h" #include "glslang/Public/resource_limits_c.h" -#define BASE_PATH "../resources/shaders/" +#define BASE_PATH directoryService->getShadersDirectory() + +#include "../../core/DirectoryService.h" +#include "../../core/vulkan/VulkanContext.h" namespace Metal { void ShaderService::CheckShaderCompilation(glslang_shader_t *shader) { @@ -81,7 +84,7 @@ namespace Metal { shaderCreateInfo.codeSize = shaderModule->SPIRV.size() * sizeof(unsigned int); shaderCreateInfo.pCode = static_cast(shaderModule->SPIRV.data()); - VulkanUtils::CheckVKResult(vkCreateShaderModule(vulkanContext.device.device, &shaderCreateInfo, + VulkanUtils::CheckVKResult(vkCreateShaderModule(vulkanContext->device.device, &shaderCreateInfo, nullptr, &shaderModule->vkShaderModule)); glslang_program_delete(program); @@ -131,7 +134,7 @@ namespace Metal { throw std::runtime_error("Unknown shader stage in file"); } - std::string ShaderService::ProcessIncludes(const std::string &input) { + std::string ShaderService::ProcessIncludes(const std::string &input, const std::string &basePath) { std::string result = input; std::regex includePattern(R"(#include\s+"(.+))"); std::smatch match; @@ -144,7 +147,7 @@ namespace Metal { } try { std::string source; - FilesUtil::ReadFile((BASE_PATH + includeFile).c_str(), source); + FilesUtil::ReadFile((basePath + includeFile).c_str(), source); result.replace(match.position(0), match.length(0), source); } catch (const std::exception &e) { LOG_ERROR("Error loading included shader: " + std::string(e.what())); @@ -152,19 +155,20 @@ namespace Metal { } } if (result.find("#include") != std::string::npos) { - result = ProcessIncludes(result); + result = ProcessIncludes(result, basePath); } return result; } - std::string ShaderService::ProcessShader(const std::string &file) { + std::string ShaderService::ProcessShader(const std::string &file, const std::string &basePath) { std::string source; FilesUtil::ReadFile(file.c_str(), source); - return ProcessIncludes(source); + return ProcessIncludes(source, basePath); } VkShaderModule ShaderService::createShaderModule(const std::string &pFilename) { - std::string source = ProcessShader(BASE_PATH + pFilename); + this->isDebugMode = CTX->isDebugMode(); + std::string source = ProcessShader(BASE_PATH + pFilename, BASE_PATH); if (isDebugMode) { source = "#define DEBUG\n" + source; } @@ -177,6 +181,7 @@ namespace Metal { const size_t sourceHash = std::hash{}(source); const std::string part(BASE_PATH + pFilename); const std::string shaderName = part.substr(part.find_last_of('/') + 1, part.size()); + const std::string shadersDirectory = directoryService->getShadersDirectory(); const std::string binaryFilename = shadersDirectory + shaderName + ".spv"; const std::string hashFilename = shadersDirectory + shaderName + ".hash"; @@ -195,7 +200,7 @@ namespace Metal { shaderCreateInfo.codeSize = shader.SPIRV.size() * sizeof(unsigned int); shaderCreateInfo.pCode = static_cast(shader.SPIRV.data()); - if (vkCreateShaderModule(vulkanContext.device.device, &shaderCreateInfo, + if (vkCreateShaderModule(vulkanContext->device.device, &shaderCreateInfo, nullptr, &shader.vkShaderModule) == VK_SUCCESS) { needsCompilation = false; LOG_INFO("Loaded cached shader: " + shaderName); diff --git a/src/engine/service/ShaderService.h b/src/engine/service/ShaderService.h index 43a2dd06..19199570 100644 --- a/src/engine/service/ShaderService.h +++ b/src/engine/service/ShaderService.h @@ -2,15 +2,16 @@ #define SHADERSERVICE_H #include #include "../dto/ShaderModule.h" -#include "../../common/AbstractRuntimeComponent.h" +#include "../../common/IService.h" namespace Metal { class VulkanContext; - class ShaderService final : public AbstractRuntimeComponent { - bool isDebugMode; - std::string shadersDirectory; - VulkanContext &vulkanContext; + class DirectoryService; + class ShaderService final : public IService { + bool isDebugMode = false; + VulkanContext *vulkanContext = nullptr; + DirectoryService *directoryService = nullptr; static void CheckShaderCompilation(glslang_shader_t *shader); @@ -19,13 +20,19 @@ namespace Metal { static glslang_stage_t ShaderStageFromFilename(const char *pFilename); - static std::string ProcessIncludes(const std::string &input); + static std::string ProcessIncludes(const std::string &input, const std::string &basePath); - static std::string ProcessShader(const std::string &file); + static std::string ProcessShader(const std::string &file, const std::string &basePath); public: - explicit ShaderService(const std::string &shadersDirectory, bool isDebugMode, VulkanContext &vulkanContext) : shadersDirectory( - shadersDirectory), isDebugMode(isDebugMode), vulkanContext(vulkanContext){} + ShaderService() = default; + + std::vector getDependencies() override { + return { + {"VulkanContext", vulkanContext}, + {"DirectoryService", directoryService} + }; + } VkShaderModule createShaderModule(const std::string &pFilename); }; diff --git a/src/engine/service/StreamingService.cpp b/src/engine/service/StreamingService.cpp index e5a04f37..1b1cabb8 100644 --- a/src/engine/service/StreamingService.cpp +++ b/src/engine/service/StreamingService.cpp @@ -10,6 +10,7 @@ #include "../resource/SVOInstance.h" #include "../resource/MeshInstance.h" #include "../resource/TextureInstance.h" +#include "../../common/LoggerUtil.h" #include "../dto/PrimitiveComponent.h" @@ -17,17 +18,17 @@ namespace Metal { static constexpr int MAX_TIMEOUT = 10000; template - void disposeResources(AbstractResourceService &service, std::unordered_map &lastUse, EngineContext &engineContext) { - auto &resources = service.getResources(); + void disposeResources(AbstractResourceService *service, std::unordered_map &lastUse, EngineContext *engineContext) { + auto &resources = service->getResources(); for (auto it = resources.begin(); it != resources.end();) { if (lastUse.contains(it->second->getId()) && !it->second->isNoDisposal() && ( - engineContext.currentTimeMs - lastUse.at(it->second->getId())) >= MAX_TIMEOUT) { + engineContext->currentTimeMs - lastUse.at(it->second->getId())) >= MAX_TIMEOUT) { LOG_DEBUG( - "Disposing of " + it->first + " Since last use: " + std::to_string(engineContext.currentTimeMs - + "Disposing of " + it->first + " Since last use: " + std::to_string(engineContext->currentTimeMs - lastUse.at(it->second->getId()))); std::string id = it->first; ++it; - service.dispose(id); + service->dispose(id); } else { ++it; } @@ -35,25 +36,25 @@ namespace Metal { } void StreamingService::onSync() { - auto view = worldRepository.registry.view(); + auto view = worldRepository->registry.view(); for (auto entity: view) { auto &meshComp = view.get(entity); if (!meshComp.meshId.empty()) { - lastUse[meshComp.meshId] = engineContext.currentTimeMs; + lastUse[meshComp.meshId] = engineContext->currentTimeMs; } if (!meshComp.albedo.empty()) { - lastUse[meshComp.albedo] = engineContext.currentTimeMs; + lastUse[meshComp.albedo] = engineContext->currentTimeMs; } if (!meshComp.roughness.empty()) { - lastUse[meshComp.roughness] = engineContext.currentTimeMs; + lastUse[meshComp.roughness] = engineContext->currentTimeMs; } if (!meshComp.metallic.empty()) { - lastUse[meshComp.metallic] = engineContext.currentTimeMs; + lastUse[meshComp.metallic] = engineContext->currentTimeMs; } } - if ((engineContext.currentTime - sinceLastCleanup).count() >= MAX_TIMEOUT) { - sinceLastCleanup = engineContext.currentTime; + if ((engineContext->currentTime - sinceLastCleanup).count() >= MAX_TIMEOUT) { + sinceLastCleanup = engineContext->currentTime; disposeResources(meshService, lastUse, engineContext); disposeResources(textureService, lastUse, engineContext); disposeResources(voxelService, lastUse, engineContext); diff --git a/src/engine/service/StreamingService.h b/src/engine/service/StreamingService.h index 649e650a..44201422 100644 --- a/src/engine/service/StreamingService.h +++ b/src/engine/service/StreamingService.h @@ -4,7 +4,8 @@ #include #include -#include "../../common/AbstractRuntimeComponent.h" +#include "../../common/IService.h" +#include "../../common/ISync.h" using Clock = std::chrono::high_resolution_clock; using TimePoint = std::chrono::time_point; @@ -19,19 +20,26 @@ namespace Metal { class TextureService; class VoxelService; - class StreamingService final : public AbstractRuntimeComponent { + class StreamingService final : public IService, public ISync { std::unordered_map lastUse{}; TimePoint sinceLastCleanup; - EngineContext &engineContext; - WorldRepository &worldRepository; - MeshService &meshService; - TextureService &textureService; - VoxelService &voxelService; + EngineContext *engineContext = nullptr; + WorldRepository *worldRepository = nullptr; + MeshService *meshService = nullptr; + TextureService *textureService = nullptr; + VoxelService *voxelService = nullptr; public: - StreamingService(EngineContext &engineContext, WorldRepository &worldRepository, MeshService &meshService, TextureService &textureService, VoxelService &voxelService) - : engineContext(engineContext), worldRepository(worldRepository), meshService(meshService), textureService(textureService), voxelService(voxelService) {} + std::vector getDependencies() override { + return { + {"EngineContext", engineContext}, + {"WorldRepository", worldRepository}, + {"MeshService", meshService}, + {"TextureService", textureService}, + {"VoxelService", voxelService} + }; + } void onSync() override; }; diff --git a/src/engine/service/TextureService.cpp b/src/engine/service/TextureService.cpp index 1e045dec..8505d17f 100644 --- a/src/engine/service/TextureService.cpp +++ b/src/engine/service/TextureService.cpp @@ -18,9 +18,9 @@ #include "BufferService.h" #include "PipelineService.h" #include "DescriptorSetService.h" -#include "../dto/DescriptorInstance.h" namespace Metal { + void TextureService::copyBufferToImage(const VkBuffer &vkBuffer, const TextureInstance *image, const int layerCount) const { VkCommandBuffer commandBuffer = vulkanContext.beginSingleTimeCommands(); diff --git a/src/engine/service/TextureService.h b/src/engine/service/TextureService.h index 891f847d..047561e7 100644 --- a/src/engine/service/TextureService.h +++ b/src/engine/service/TextureService.h @@ -10,16 +10,18 @@ namespace Metal { struct TextureInstance; + class VulkanContext; class BufferService; class PipelineService; class DescriptorSetService; + class DirectoryService; class TextureService final : public AbstractResourceService { - VulkanContext &vulkanContext; - BufferService &bufferService; - PipelineService &pipelineService; - DescriptorSetService &descriptorSetService; - const std::string &rootDirectory; + VulkanContext *vulkanContext = nullptr; + BufferService *bufferService = nullptr; + PipelineService *pipelineService = nullptr; + DescriptorSetService *descriptorSetService = nullptr; + DirectoryService *directoryService = nullptr; unsigned int nextTextureIndex = 1; std::unordered_map textureIndices{}; @@ -41,9 +43,15 @@ namespace Metal { void generateMipmaps(const TextureInstance *image) const; public: - TextureService(VulkanContext &vulkanContext, BufferService &bufferService, PipelineService &pipelineService, DescriptorSetService &descriptorSetService, const std::string &rootDirectory) - : vulkanContext(vulkanContext), bufferService(bufferService), pipelineService(pipelineService), descriptorSetService(descriptorSetService), rootDirectory(rootDirectory) {} - TextureService() = delete; + std::vector getDependencies() override { + return { + {"VulkanContext", vulkanContext}, + {"BufferService", bufferService}, + {"PipelineService", pipelineService}, + {"DescriptorSetService", descriptorSetService}, + {"DirectoryService", directoryService} + }; + } [[nodiscard]] TextureData *loadTextureData(const std::string &id) const; diff --git a/src/engine/service/TransformService.cpp b/src/engine/service/TransformService.cpp index 4e201f84..bc08a257 100644 --- a/src/engine/service/TransformService.cpp +++ b/src/engine/service/TransformService.cpp @@ -2,16 +2,19 @@ #include #include #include +#include "../../common/LoggerUtil.h" #include "../../ApplicationContext.h" #include "../dto/TransformComponent.h" #include "../repository/WorldRepository.h" +#include "../dto/TransformComponent.h" +#include "../dto/PrimitiveComponent.h" #include "RayTracingService.h" namespace Metal { void TransformService::onSync() { - for (auto entity : worldRepository.registry.view()) { - TransformComponent &st = worldRepository.registry.get(entity); + for (auto entity : worldRepository->registry.view()) { + TransformComponent &st = worldRepository->registry.get(entity); if (st.isNotFrozen()) { transform(&st, nullptr); st.freezeVersion(); @@ -38,8 +41,8 @@ namespace Metal { st->model = auxMat4 * auxMat42; st->freezeVersion(); - if (worldRepository.registry.all_of(st->getEntityId())) { - rayTracingService.markDirty(); + if (worldRepository->registry.all_of(st->getEntityId())) { + rayTracingService->markDirty(); } } } // Metal diff --git a/src/engine/service/TransformService.h b/src/engine/service/TransformService.h index 3149e81c..f221dde7 100644 --- a/src/engine/service/TransformService.h +++ b/src/engine/service/TransformService.h @@ -4,19 +4,18 @@ #include #include -#include "../../editor/enum/engine-definitions.h" -#include "../../common/AbstractRuntimeComponent.h" +#include "../../common/ISync.h" +#include "../../common/IService.h" namespace Metal { struct TransformComponent; - struct TransformComponent; struct WorldRepository; class RayTracingService; - class TransformService final : AbstractRuntimeComponent { - WorldRepository &worldRepository; - RayTracingService &rayTracingService; + class TransformService final : public IService, public ISync { + WorldRepository *worldRepository = nullptr; + RayTracingService *rayTracingService = nullptr; glm::vec3 distanceAux{}; glm::mat4x4 auxMat4{}; @@ -24,9 +23,12 @@ namespace Metal { glm::mat4x4 auxMat42{}; public: - explicit TransformService(WorldRepository &worldRepository, RayTracingService &rayTracingService) - : worldRepository(worldRepository), rayTracingService(rayTracingService) {} - TransformService() = delete; + std::vector getDependencies() override { + return { + {"WorldRepository", worldRepository}, + {"RayTracingService", rayTracingService} + }; + } void onSync() override; diff --git a/src/engine/service/VolumeService.cpp b/src/engine/service/VolumeService.cpp index d04c4454..52d3b3b8 100644 --- a/src/engine/service/VolumeService.cpp +++ b/src/engine/service/VolumeService.cpp @@ -4,13 +4,21 @@ #include "../resource/BufferInstance.h" #include "../../editor/enum/EngineResourceIDs.h" #include "../repository/WorldRepository.h" +#include "../dto/TransformComponent.h" +#include "../dto/VolumeComponent.h" #include "../EngineContext.h" namespace Metal { void VolumeService::registerVolumes() { - auto view = worldRepository.registry.view(); - for (auto [entityId, l, t]: view.each()) { - if (worldRepository.hiddenEntities.contains(entityId)) { + auto ®istry = worldRepository->registry; + auto view = registry.view(); + for (auto entityId: view) { + if (!registry.all_of(entityId)) { + continue; + } + auto &l = registry.get(entityId); + auto &t = registry.get(entityId); + if (worldRepository->hiddenEntities.contains(entityId)) { continue; } @@ -32,7 +40,7 @@ namespace Metal { registerVolumes(); if (!items.empty()) { - engineContext.currentFrame->getResourceAs(RID_VOLUMES_BUFFER)->update(items.data()); + engineContext->currentFrame->getResourceAs(RID_VOLUMES_BUFFER)->update(items.data()); } } } // Metal diff --git a/src/engine/service/VolumeService.h b/src/engine/service/VolumeService.h index 60d32fed..eada2e3d 100644 --- a/src/engine/service/VolumeService.h +++ b/src/engine/service/VolumeService.h @@ -2,7 +2,8 @@ #define VOLUME_SERVICE_H #include -#include "../../common/AbstractRuntimeComponent.h" +#include "../../common/IService.h" +#include "../../common/ISync.h" #include "../dto/VolumeData.h" namespace Metal { @@ -10,17 +11,20 @@ namespace Metal { struct WorldRepository; class EngineContext; - class VolumeService final : public AbstractRuntimeComponent { - WorldRepository &worldRepository; - EngineContext &engineContext; + class VolumeService final : public IService, public ISync { + WorldRepository *worldRepository = nullptr; + EngineContext *engineContext = nullptr; std::vector items{}; void registerVolumes(); public: - explicit VolumeService(WorldRepository &worldRepository, EngineContext &engineContext) - : worldRepository(worldRepository), engineContext(engineContext) {} - VolumeService() = delete; + std::vector getDependencies() override { + return { + {"WorldRepository", worldRepository}, + {"EngineContext", engineContext} + }; + } void onSync() override; diff --git a/src/main.cpp b/src/main.cpp index 2e02e7af..a851954a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,14 +6,110 @@ #define GLM_FORCE_RADIANS #define GLM_FORCE_DEPTH_ZERO_TO_ONE #include "ApplicationContext.h" +#include "core/DirectoryService.h" +#include "core/FrameService.h" +#include "core/glfw/GLFWContext.h" +#include "core/gui/GuiContext.h" +#include "core/vulkan/VulkanContext.h" +#include "editor/EditorPanel.h" +#include "editor/service/AsyncTaskService.h" +#include "editor/service/DockService.h" +#include "editor/service/FileImporterService.h" +#include "editor/service/FilesService.h" +#include "editor/service/MaterialImporterService.h" +#include "editor/service/MeshImporterService.h" +#include "editor/service/NotificationService.h" +#include "editor/service/PickingService.h" +#include "editor/service/SceneImporterService.h" +#include "editor/service/SelectionService.h" +#include "editor/service/TextureImporterService.h" +#include "editor/service/ThemeService.h" +#include "editor/service/VoxelImporterService.h" +#include "editor/repository/EditorRepository.h" + +#include "engine/repository/EngineRepository.h" +#include "engine/repository/RuntimeRepository.h" +#include "engine/repository/WorldRepository.h" + +#include "engine/service/BufferService.h" +#include "engine/service/CameraService.h" +#include "engine/service/CommandBufferRecorderService.h" +#include "engine/service/DescriptorSetService.h" +#include "engine/service/FrameBufferService.h" +#include "engine/service/LightService.h" +#include "engine/service/MaterialService.h" +#include "engine/service/MeshService.h" +#include "engine/service/PipelineService.h" +#include "engine/service/RayTracingService.h" +#include "engine/service/ShaderService.h" +#include "engine/service/StreamingService.h" +#include "engine/service/TextureService.h" +#include "engine/service/TransformService.h" +#include "engine/service/VolumeService.h" +#include "engine/service/VoxelService.h" +#include "engine/EngineContext.h" int main(int, char **) { - Metal::ApplicationContext::Init(true); + Metal::ApplicationContext context{true}; + + // --- ORDER MATTERS + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + // --- ORDER MATTERS + + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + context.registerSingleton(std::make_unique()); + + context.onInitialize(); + auto &frameService = context.getSingleton(); + auto &directoryService = context.getSingleton(); + directoryService.updateRootPath(false); + auto &editor = context.getSingleton(); - if (!CTX.isValidContext()) { + frameService.setPanel(&editor); + if (!frameService.isValidContext()) { printf("GLFW: Vulkan Not Supported\n"); return 1; } - CTX.start(); + frameService.onInitialize(); + context.dispose(); return 0; } From e7210c802d5cc743dd4987f334092658c325a186 Mon Sep 17 00:00:00 2001 From: facobackup Date: Sat, 14 Mar 2026 17:13:09 -0300 Subject: [PATCH 06/11] Dependency injection for panels and other runtime objects --- CMakeLists.txt | 1 - src/ApplicationContext.cpp | 4 - src/ApplicationContext.h | 17 ++- src/common/IContextMember.cpp | 1 + src/common/IContextMember.h | 2 + src/core/gui/GuiContext.cpp | 1 + src/core/gui/GuiContext.h | 1 - src/core/vulkan/VulkanContext.cpp | 2 +- src/editor/EditorPanel.cpp | 6 +- src/editor/EditorPanel.h | 13 ++ src/editor/abstract/AbstractPanel.cpp | 7 +- src/editor/abstract/AbstractPanel.h | 14 +- src/editor/abstract/IPanel.h | 14 -- .../abstract/form/AbstractFormFieldPanel.h | 10 ++ src/editor/abstract/form/AccordionPanel.cpp | 3 +- src/editor/abstract/form/AccordionPanel.h | 3 +- src/editor/abstract/form/ChildPanel.cpp | 3 +- .../abstract/form/types/ResourceField.cpp | 3 +- .../abstract/form/types/ResourceField.h | 6 + .../form/types/ResourceFilesPanel.cpp | 2 +- .../abstract/form/types/StringField.cpp | 2 +- .../dock-spaces/docks/DockSpacePanel.cpp | 10 +- src/editor/dock-spaces/docks/DockSpacePanel.h | 12 ++ .../dock-spaces/files/FilePreviewPanel.cpp | 6 +- .../dock-spaces/files/FilePreviewPanel.h | 13 ++ .../dock-spaces/files/FilesHeaderPanel.cpp | 7 +- .../dock-spaces/files/FilesHeaderPanel.h | 10 +- .../dock-spaces/files/FilesListPanel.cpp | 10 +- src/editor/dock-spaces/files/FilesListPanel.h | 13 +- src/editor/dock-spaces/files/FilesPanel.cpp | 53 +++---- src/editor/dock-spaces/files/FilesPanel.h | 27 ++++ .../dock-spaces/footer/EditorFooterPanel.cpp | 5 +- .../dock-spaces/footer/EditorFooterPanel.h | 10 ++ .../dock-spaces/header/AsyncTaskPanel.cpp | 6 +- .../dock-spaces/header/AsyncTaskPanel.h | 10 ++ .../dock-spaces/header/EditorHeaderPanel.cpp | 17 ++- .../dock-spaces/header/EditorHeaderPanel.h | 16 ++ .../dock-spaces/inspector/InspectorPanel.cpp | 18 +-- .../dock-spaces/inspector/InspectorPanel.h | 12 ++ .../dock-spaces/metrics/MetricsPanel.cpp | 18 ++- src/editor/dock-spaces/metrics/MetricsPanel.h | 25 ++++ .../repositories/RepositoriesPanel.cpp | 10 +- .../repositories/RepositoriesPanel.h | 15 ++ .../viewport/CameraPositionPanel.cpp | 8 +- .../viewport/CameraPositionPanel.h | 10 ++ .../dock-spaces/viewport/EngineFramePanel.cpp | 31 ++-- .../dock-spaces/viewport/EngineFramePanel.h | 24 ++- .../dock-spaces/viewport/GizmoPanel.cpp | 14 +- src/editor/dock-spaces/viewport/GizmoPanel.h | 14 ++ .../viewport/GizmoSettingsPanel.cpp | 10 +- .../dock-spaces/viewport/GizmoSettingsPanel.h | 9 ++ .../viewport/ViewportHeaderPanel.cpp | 16 +- .../viewport/ViewportHeaderPanel.h | 13 ++ .../dock-spaces/viewport/ViewportPanel.cpp | 82 +++++------ .../dock-spaces/viewport/ViewportPanel.h | 28 ++++ .../dock-spaces/world/WorldHeaderPanel.cpp | 4 +- .../dock-spaces/world/WorldHeaderPanel.h | 10 ++ src/editor/dock-spaces/world/WorldPanel.cpp | 31 ++-- src/editor/dock-spaces/world/WorldPanel.h | 14 ++ src/editor/enum/engine-definitions.h | 1 + src/editor/panel/FileImportModalPanel.cpp | 39 ++--- src/editor/panel/FileImportModalPanel.h | 15 ++ src/editor/panel/NotificationsPanel.cpp | 12 +- src/editor/panel/NotificationsPanel.h | 13 ++ src/editor/passes/GridPass.cpp | 15 +- src/editor/passes/GridPass.h | 16 ++ src/editor/passes/SelectionIDPass.cpp | 26 ++-- src/editor/passes/SelectionIDPass.h | 18 +++ src/editor/passes/SelectionOutlinePass.cpp | 15 +- src/editor/passes/SelectionOutlinePass.h | 13 ++ src/editor/service/DockService.cpp | 19 +-- src/editor/service/DockService.h | 7 +- src/editor/service/FilesService.cpp | 27 ++-- src/editor/service/FilesService.h | 4 +- src/editor/service/ThemeService.cpp | 44 +++--- src/engine/EngineContext.cpp | 18 +++ src/engine/EngineContext.h | 9 +- src/engine/enum/ComponentType.cpp | 11 +- src/engine/enum/ComponentType.h | 1 + .../frame-builder/EngineFrameBuilder.cpp | 29 ++-- src/engine/frame-builder/EngineFrameBuilder.h | 21 ++- .../structures/BufferBuilder.cpp | 4 +- .../frame-builder/structures/BufferBuilder.h | 7 + .../CommandBufferRecorderBuilder.cpp | 9 +- .../structures/CommandBufferRecorderBuilder.h | 19 ++- .../structures/FramebufferBuilder.cpp | 19 ++- .../structures/FramebufferBuilder.h | 7 +- .../structures/ResourceBuilder.h | 7 +- .../structures/TextureBuilder.cpp | 8 +- .../frame-builder/structures/TextureBuilder.h | 8 +- src/engine/passes/AbstractPass.h | 4 +- src/engine/passes/CommandBufferRecorder.cpp | 10 +- src/engine/passes/CommandBufferRecorder.h | 10 +- src/engine/passes/impl/HWRayTracingPass.cpp | 41 +++--- src/engine/passes/impl/HWRayTracingPass.h | 22 +++ src/engine/passes/impl/PostProcessingPass.cpp | 14 +- src/engine/passes/impl/PostProcessingPass.h | 17 +++ src/engine/passes/impl/SpatialFilterPass.cpp | 5 +- src/engine/passes/impl/SpatialFilterPass.h | 10 ++ .../passes/impl/TemporalAccumulationPass.cpp | 5 +- .../passes/impl/TemporalAccumulationPass.h | 9 ++ src/engine/repository/WorldRepository.h | 8 +- src/engine/resource/FrameBufferAttachment.cpp | 13 +- src/engine/resource/FrameBufferAttachment.h | 8 +- src/engine/resource/RuntimeResource.h | 19 ++- src/engine/service/BufferService.cpp | 40 ++--- src/engine/service/DescriptorSetService.cpp | 4 +- src/engine/service/FrameBufferService.cpp | 25 ++-- src/engine/service/PipelineService.cpp | 59 ++++---- src/engine/service/RayTracingService.cpp | 139 +++++++++--------- src/engine/service/RayTracingService.h | 8 +- src/engine/service/ShaderService.cpp | 2 +- src/engine/service/TextureService.cpp | 54 +++---- src/main.cpp | 93 ++++++------ 114 files changed, 1212 insertions(+), 624 deletions(-) delete mode 100644 src/editor/abstract/IPanel.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b165cea..9d6aebeb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,6 @@ add_executable( src/main.cpp src/editor/EditorPanel.cpp src/editor/EditorPanel.h - src/editor/abstract/IPanel.h src/engine/EngineContext.cpp src/engine/EngineContext.h src/core/vulkan/VulkanUtils.cpp diff --git a/src/ApplicationContext.cpp b/src/ApplicationContext.cpp index a0cb05d3..b14ca0d3 100644 --- a/src/ApplicationContext.cpp +++ b/src/ApplicationContext.cpp @@ -7,10 +7,7 @@ #include "core/glfw/GLFWContext.h" namespace Metal { - ApplicationContext *ApplicationContext::CONTEXT = nullptr; - ApplicationContext::ApplicationContext(bool debugMode) : debugMode(debugMode) { - CONTEXT = this; } void ApplicationContext::onInitialize() { @@ -37,7 +34,6 @@ namespace Metal { if (disposable) { disposable->dispose(); } - delete it->release(); } } catch (std::exception &e) { LOG_ERROR(e.what()); diff --git a/src/ApplicationContext.h b/src/ApplicationContext.h index 0afd22a2..54ba00fd 100644 --- a/src/ApplicationContext.h +++ b/src/ApplicationContext.h @@ -6,25 +6,21 @@ #include #include #include +#include #include #include "common/IInit.h" #include "common/IContextMember.h" #include "common/IDisposable.h" -#define CTX ApplicationContext::CONTEXT #define ENGINE_NAME "Metal Engine" namespace Metal { namespace fs = std::filesystem; - class ApplicationContext : public IInit, public IDisposable { - public: - static ApplicationContext *CONTEXT; - - private: + class ApplicationContext : public IContextMember, public IInit, public IDisposable { std::unordered_map singletons; - std::vector > instances; + std::vector > instances; bool debugMode; public: @@ -33,7 +29,7 @@ namespace Metal { void onInitialize() override; template - void registerSingleton(std::unique_ptr instance) { + void registerSingleton(std::shared_ptr instance) { static_assert(std::is_base_of_v, "T must derive from IContextMember"); T *ptr = instance.get(); singletons[typeid(T).name()] = static_cast(ptr); @@ -57,6 +53,11 @@ namespace Metal { return it->second; } + void injectDependencies(IContextMember *member) { + std::cout << "Injecting dependencies for: " << typeid(*member).name() << std::endl; + member->setDependencies(*this); + } + [[nodiscard]] bool isDebugMode() const; void dispose() override; diff --git a/src/common/IContextMember.cpp b/src/common/IContextMember.cpp index f42b28ce..8daeee72 100644 --- a/src/common/IContextMember.cpp +++ b/src/common/IContextMember.cpp @@ -3,6 +3,7 @@ namespace Metal { void IContextMember::setDependencies(ApplicationContext &ctx) { + this->ctx = &ctx; for (auto &dep : getDependencies()) { dep.ptr = ctx.getSingletonByName(dep.name); } diff --git a/src/common/IContextMember.h b/src/common/IContextMember.h index 1226a4fc..6a80f326 100644 --- a/src/common/IContextMember.h +++ b/src/common/IContextMember.h @@ -12,6 +12,8 @@ namespace Metal { }; class IContextMember { + public: + ApplicationContext *ctx = nullptr; public: virtual ~IContextMember() = default; diff --git a/src/core/gui/GuiContext.cpp b/src/core/gui/GuiContext.cpp index ab84174b..15fb1226 100644 --- a/src/core/gui/GuiContext.cpp +++ b/src/core/gui/GuiContext.cpp @@ -10,6 +10,7 @@ #include "../vulkan/VulkanContext.h" #include "../glfw/GLFWContext.h" #include "../../engine/service/DescriptorSetService.h" +#include "../../editor/enum/engine-definitions.h" namespace Metal { void GuiContext::endFrame() { diff --git a/src/core/gui/GuiContext.h b/src/core/gui/GuiContext.h index 5c117b02..2ee14541 100644 --- a/src/core/gui/GuiContext.h +++ b/src/core/gui/GuiContext.h @@ -1,7 +1,6 @@ #ifndef METAL_ENGINE_GUICONTEXT_H #define METAL_ENGINE_GUICONTEXT_H -#define LARGE_FONT_SIZE 38 #include #include #include "../../common/IService.h" diff --git a/src/core/vulkan/VulkanContext.cpp b/src/core/vulkan/VulkanContext.cpp index 4c38039e..35f7930d 100644 --- a/src/core/vulkan/VulkanContext.cpp +++ b/src/core/vulkan/VulkanContext.cpp @@ -254,7 +254,7 @@ namespace Metal { } void VulkanContext::onInitialize() { - this->debugMode = CTX->isDebugMode(); + this->debugMode = ctx->isDebugMode(); this->window = glfwContext->getWindow(); imguiVulkanWindow.ClearValue.color.float32[0] = 0; diff --git a/src/editor/EditorPanel.cpp b/src/editor/EditorPanel.cpp index 399fa50e..89efab59 100644 --- a/src/editor/EditorPanel.cpp +++ b/src/editor/EditorPanel.cpp @@ -1,6 +1,8 @@ #include "EditorPanel.h" #include "util/UIUtil.h" #include "../ApplicationContext.h" +#include "service/DockService.h" +#include "service/ThemeService.h" #include "dock-spaces/header/EditorHeaderPanel.h" #include "dock-spaces/footer/EditorFooterPanel.h" #include "panel/FileImportModalPanel.h" @@ -46,7 +48,7 @@ namespace Metal { ImGui::PopStyleVar(3); - applicationContext->dockService.buildViews(windowId, this); + dockService->buildViews(windowId, this); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f); ImGui::DockSpace(windowId, CENTER, ImGuiDockNodeFlags_PassthruCentralNode); @@ -97,7 +99,7 @@ namespace Metal { } void EditorPanel::onSync() { - applicationContext->themeService.onSync(); + themeService->onSync(); renderDockSpaces(); notificationsPanel->onSync(); fileImportModalPanel->onSync(); diff --git a/src/editor/EditorPanel.h b/src/editor/EditorPanel.h index 32a9cf0a..80d47127 100644 --- a/src/editor/EditorPanel.h +++ b/src/editor/EditorPanel.h @@ -5,6 +5,9 @@ #include "abstract/AbstractPanel.h" namespace Metal { + class DockService; + class ThemeService; + class EditorPanel final : public AbstractPanel { static int FLAGS; static const char *NAME; @@ -19,6 +22,9 @@ namespace Metal { AbstractPanel *notificationsPanel = nullptr; AbstractPanel *fileImportModalPanel = nullptr; + DockService *dockService = nullptr; + ThemeService *themeService = nullptr; + static void SetWindowStyle(); void renderDockSpaces(); @@ -28,6 +34,13 @@ namespace Metal { void renderFooter(const ImGuiViewport *viewport); public: + std::vector getDependencies() override { + return { + {"DockService", dockService}, + {"ThemeService", themeService} + }; + } + void onInitialize() override; void onSync() override; diff --git a/src/editor/abstract/AbstractPanel.cpp b/src/editor/abstract/AbstractPanel.cpp index 3db1de52..441d5537 100644 --- a/src/editor/abstract/AbstractPanel.cpp +++ b/src/editor/abstract/AbstractPanel.cpp @@ -1,11 +1,12 @@ #include "AbstractPanel.h" #include "../util/Util.h" +#include "../../ApplicationContext.h" namespace Metal { void AbstractPanel::appendChild(AbstractPanel *panel) { - panel->applicationContext = applicationContext; + ctx->injectDependencies(panel); panel->onInitialize(); - children.emplace_back(panel); + children.push_back(panel); } void AbstractPanel::onSyncChildren() const { @@ -25,7 +26,7 @@ namespace Metal { children.clear(); } - std::vector &AbstractPanel::getChildren() { + std::vector &AbstractPanel::getChildren() { return children; } } diff --git a/src/editor/abstract/AbstractPanel.h b/src/editor/abstract/AbstractPanel.h index d2f52f23..b86431df 100644 --- a/src/editor/abstract/AbstractPanel.h +++ b/src/editor/abstract/AbstractPanel.h @@ -4,15 +4,15 @@ #include #include -#include "IPanel.h" +#include "../../common/IContextMember.h" +#include "../../common/ISync.h" +#include "../../common/IInit.h" namespace Metal { class ApplicationContext; - class AbstractPanel : public IPanel { - public: - ApplicationContext *applicationContext{}; + class AbstractPanel : public IContextMember, public ISync, public IInit { protected: - std::vector children; + std::vector children; const std::string id; virtual void onSyncChildren() const; @@ -20,11 +20,11 @@ namespace Metal { public: explicit AbstractPanel(); - std::vector &getChildren(); + std::vector &getChildren(); void appendChild(AbstractPanel *panel); - void removeAllChildren() override; + void removeAllChildren(); virtual void onRemove() { } diff --git a/src/editor/abstract/IPanel.h b/src/editor/abstract/IPanel.h deleted file mode 100644 index 48dfc868..00000000 --- a/src/editor/abstract/IPanel.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef METAL_ENGINE_IPANEL_H -#define METAL_ENGINE_IPANEL_H - -#include "../../common/ISync.h" -#include "../../common/IInit.h" - -namespace Metal { - class IPanel : public ISync, public IInit { - public: - virtual void removeAllChildren() { - } - }; -} -#endif diff --git a/src/editor/abstract/form/AbstractFormFieldPanel.h b/src/editor/abstract/form/AbstractFormFieldPanel.h index 4ab21a41..bfdb7f1f 100644 --- a/src/editor/abstract/form/AbstractFormFieldPanel.h +++ b/src/editor/abstract/form/AbstractFormFieldPanel.h @@ -6,10 +6,20 @@ #include "../AbstractPanel.h" namespace Metal { + class ThemeService; + class AbstractFormFieldPanel : public AbstractPanel { protected: const std::string* filter = nullptr; + + ThemeService *themeService = nullptr; public: + + std::vector getDependencies() override { + return { + {"ThemeService", themeService} + }; + } [[nodiscard]] virtual bool isVisible() const = 0; void onSyncChildren() const override { diff --git a/src/editor/abstract/form/AccordionPanel.cpp b/src/editor/abstract/form/AccordionPanel.cpp index 0efd891e..bb3789a2 100644 --- a/src/editor/abstract/form/AccordionPanel.cpp +++ b/src/editor/abstract/form/AccordionPanel.cpp @@ -1,6 +1,7 @@ #include "AccordionPanel.h" #include "imgui.h" #include "../../../ApplicationContext.h" +#include "../../service/ThemeService.h" namespace Metal { void AccordionPanel::setTitle(const std::string &t) { @@ -14,7 +15,7 @@ namespace Metal { return; } - ImGui::PushStyleColor(ImGuiCol_Header, applicationContext->themeService.neutralPalette); + ImGui::PushStyleColor(ImGuiCol_Header, themeService->neutralPalette); bool open = ImGui::CollapsingHeader(fixedId.c_str(), ImGuiTreeNodeFlags_None); ImGui::PopStyleColor(); diff --git a/src/editor/abstract/form/AccordionPanel.h b/src/editor/abstract/form/AccordionPanel.h index b161a2a4..65a787e4 100644 --- a/src/editor/abstract/form/AccordionPanel.h +++ b/src/editor/abstract/form/AccordionPanel.h @@ -4,12 +4,13 @@ #include "AbstractFormFieldPanel.h" namespace Metal { + class ThemeService; + class AccordionPanel final : public AbstractFormFieldPanel { std::string fixedId = id; std::string title; public: - void setTitle(const std::string &title); void onSync() override; diff --git a/src/editor/abstract/form/ChildPanel.cpp b/src/editor/abstract/form/ChildPanel.cpp index aaf611b5..498c3971 100644 --- a/src/editor/abstract/form/ChildPanel.cpp +++ b/src/editor/abstract/form/ChildPanel.cpp @@ -1,6 +1,7 @@ #include "ChildPanel.h" #include "imgui.h" #include "../../../ApplicationContext.h" +#include "../../service/ThemeService.h" namespace Metal { void ChildPanel::setTitle(const std::string &t) { @@ -9,7 +10,7 @@ namespace Metal { } void ChildPanel::onSync() { - ImGui::PushStyleColor(ImGuiCol_ChildBg, applicationContext->themeService.palette0); + ImGui::PushStyleColor(ImGuiCol_ChildBg, themeService->palette0); if (!title.empty()) { ImGui::Spacing(); ImGui::Text(title.c_str()); diff --git a/src/editor/abstract/form/types/ResourceField.cpp b/src/editor/abstract/form/types/ResourceField.cpp index 3b06c714..ba761c59 100644 --- a/src/editor/abstract/form/types/ResourceField.cpp +++ b/src/editor/abstract/form/types/ResourceField.cpp @@ -9,6 +9,7 @@ #include "../../../dto/FSEntry.h" #include "../../../../ApplicationContext.h" #include "../../../../common/Inspectable.h" +#include "../../../service/FilesService.h" namespace Metal { constexpr ImGuiWindowFlags flags = ImGuiWindowFlags_NoDocking | @@ -79,7 +80,7 @@ namespace Metal { void ResourceField::onSync() { if (field.field->size() > 0 && (entry == nullptr || entry->getId() != *field.field)) { - entry = applicationContext->filesService.getResource(*field.field); + entry = filesService->getResource(*field.field); } if (!field.disabled) { renderButton(); diff --git a/src/editor/abstract/form/types/ResourceField.h b/src/editor/abstract/form/types/ResourceField.h index 8126a42e..92b8a23b 100644 --- a/src/editor/abstract/form/types/ResourceField.h +++ b/src/editor/abstract/form/types/ResourceField.h @@ -8,14 +8,20 @@ #include "imgui.h" namespace Metal { + class FilesService; struct FSEntry; class ResourceField final : public AbstractFormFieldPanel { InspectedField &field; std::unique_ptr entry = nullptr; mutable bool open = false; + FilesService *filesService = nullptr; public: + std::vector getDependencies() override { + return {{"FilesService", filesService}}; + } + void onInitialize() override; void renderButton(); diff --git a/src/editor/abstract/form/types/ResourceFilesPanel.cpp b/src/editor/abstract/form/types/ResourceFilesPanel.cpp index cf3e6196..b32d295c 100644 --- a/src/editor/abstract/form/types/ResourceFilesPanel.cpp +++ b/src/editor/abstract/form/types/ResourceFilesPanel.cpp @@ -18,7 +18,7 @@ namespace Metal { void ResourceFilesPanel::openResource(FSEntry *root) { if (root->type == EntryType::DIRECTORY) { filesContext.setCurrentDirectory(root); - FilesService::GetEntries(root); + filesService->GetEntries(root); filesContext.selected.clear(); } else { callback(root); diff --git a/src/editor/abstract/form/types/StringField.cpp b/src/editor/abstract/form/types/StringField.cpp index 9f07b8b2..0a24e84a 100644 --- a/src/editor/abstract/form/types/StringField.cpp +++ b/src/editor/abstract/form/types/StringField.cpp @@ -9,7 +9,7 @@ namespace Metal { void StringField::onSync() { if (!field.disabled) { - strcpy(buffer, field.field->c_str()); + strcpy_s(buffer, sizeof(buffer), field.field->c_str()); ImGui::Text(field.name.c_str()); if (ImGui::InputText(field.id.c_str(), buffer, sizeof(buffer))) { *field.field = buffer; diff --git a/src/editor/dock-spaces/docks/DockSpacePanel.cpp b/src/editor/dock-spaces/docks/DockSpacePanel.cpp index 3c0b6cd2..c77db728 100644 --- a/src/editor/dock-spaces/docks/DockSpacePanel.cpp +++ b/src/editor/dock-spaces/docks/DockSpacePanel.cpp @@ -9,6 +9,8 @@ #include "../../dto/DockDTO.h" #include "../../util/UIUtil.h" #include "../../../common/LoggerUtil.h" +#include "../../repository/EditorRepository.h" +#include "../../service/ThemeService.h" namespace Metal { const ImVec2 DockSpacePanel::DEFAULT{-1.f, -1.f}; @@ -52,13 +54,13 @@ namespace Metal { if (view != nullptr) { const bool isHovered = ImGui::IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows); if (isHovered) { - applicationContext->editorRepository.focusedShortcuts = view->getShortcuts(); - applicationContext->editorRepository.focusedWindowName = view->dock->name; + editorRepository->focusedShortcuts = view->getShortcuts(); + editorRepository->focusedWindowName = view->dock->name; } view->isWindowFocused = isHovered; if (view->isWindowFocused) { - for (const auto &shortcut: applicationContext->editorRepository.focusedShortcuts) { + for (const auto &shortcut: editorRepository->focusedShortcuts) { if (ImGui::IsKeyChordPressed(shortcut.keyChord)) { LOG_INFO("Action called: " + shortcut.name); shortcut.callback(); @@ -116,7 +118,7 @@ namespace Metal { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, headerPadding); const bool isFocused = ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows); ImGui::PushStyleColor(ImGuiCol_TabActive, - isFocused ? applicationContext->editorRepository.accent : applicationContext->themeService.palette0); + isFocused ? editorRepository->accent : themeService->palette0); if (ImGui::BeginTabBar((id + "dockTabs").c_str(), ImGuiTabBarFlags_AutoSelectNewTabs)) { for (auto *space: dock->dockSpaces) { diff --git a/src/editor/dock-spaces/docks/DockSpacePanel.h b/src/editor/dock-spaces/docks/DockSpacePanel.h index 56658704..bc89e743 100644 --- a/src/editor/dock-spaces/docks/DockSpacePanel.h +++ b/src/editor/dock-spaces/docks/DockSpacePanel.h @@ -11,6 +11,8 @@ namespace Metal { struct DockDTO; struct DockSpace; class AbstractDockPanel; + struct EditorRepository; + class ThemeService; class DockSpacePanel final : public AbstractPanel { ImVec2 padding{DEFAULT.x, DEFAULT.y}; @@ -26,11 +28,21 @@ namespace Metal { std::unordered_map views{}; ImVec2 headerPadding{0, 3}; + EditorRepository *editorRepository = nullptr; + ThemeService *themeService = nullptr; + DockSpace *getSelectedDockSpace() const; bool hasDockSpace(int index) const; public: + std::vector getDependencies() override { + return { + {"EditorRepository", editorRepository}, + {"ThemeService", themeService} + }; + } + static constexpr int FLAGS = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_MenuBar; static const ImVec2 DEFAULT; static const ImVec2 MAX_SIZE; diff --git a/src/editor/dock-spaces/files/FilePreviewPanel.cpp b/src/editor/dock-spaces/files/FilePreviewPanel.cpp index 143aa77a..f94c1c71 100644 --- a/src/editor/dock-spaces/files/FilePreviewPanel.cpp +++ b/src/editor/dock-spaces/files/FilePreviewPanel.cpp @@ -4,6 +4,8 @@ #include "../../dto/FSEntry.h" #include "../../../ApplicationContext.h" #include "../../../engine/resource/TextureInstance.h" +#include "../../../engine/service/TextureService.h" +#include "../../../core/gui/GuiContext.h" namespace Metal { FilePreviewPanel::FilePreviewPanel(FilesContext &filesContext) : filesContext(filesContext) { @@ -21,7 +23,7 @@ namespace Metal { ImGui::Separator(); if (selected->type == EntryType::TEXTURE) { - auto *texture = applicationContext->textureService.stream(selected->getId()); + auto *texture = textureService->stream(selected->getId()); if (texture != nullptr) { float availWidth = ImGui::GetContentRegionAvail().x; float availHeight = ImGui::GetContentRegionAvail().y * 0.6f; // reserve space for table @@ -41,7 +43,7 @@ namespace Metal { float offsetX = (availWidth - renderWidth) * 0.5f; if (offsetX > 0) ImGui::SetCursorPosX(ImGui::GetCursorPosX() + offsetX); - applicationContext->guiContext.renderImage(texture, renderWidth, renderHeight); + guiContext->renderImage(texture, renderWidth, renderHeight); ImGui::Separator(); } } diff --git a/src/editor/dock-spaces/files/FilePreviewPanel.h b/src/editor/dock-spaces/files/FilePreviewPanel.h index 689ac058..b539a00a 100644 --- a/src/editor/dock-spaces/files/FilePreviewPanel.h +++ b/src/editor/dock-spaces/files/FilePreviewPanel.h @@ -5,10 +5,23 @@ #include "FilesContext.h" namespace Metal { + class TextureService; + class GuiContext; + class FilePreviewPanel final : public AbstractPanel { FilesContext &filesContext; + TextureService *textureService = nullptr; + GuiContext *guiContext = nullptr; + public: + std::vector getDependencies() override { + return { + {"TextureService", textureService}, + {"GuiContext", guiContext} + }; + } + explicit FilePreviewPanel(FilesContext &filesContext); void onSync() override; diff --git a/src/editor/dock-spaces/files/FilesHeaderPanel.cpp b/src/editor/dock-spaces/files/FilesHeaderPanel.cpp index a81e2751..d687da19 100644 --- a/src/editor/dock-spaces/files/FilesHeaderPanel.cpp +++ b/src/editor/dock-spaces/files/FilesHeaderPanel.cpp @@ -4,14 +4,15 @@ #include "../../dto/FSEntry.h" #include "../../../common/Icons.h" #include "../../../ApplicationContext.h" +#include "../../service/FilesService.h" #include "../../util/UIUtil.h" namespace Metal { void FilesHeaderPanel::onSync() { if (UIUtil::ButtonSimple(Icons::create_new_folder + id, UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE)) { - FilesService::CreateDirectory(filesContext.currentDirectory); - FilesService::GetEntries(filesContext.currentDirectory); + filesService->CreateDirectory(filesContext.currentDirectory); + filesService->GetEntries(filesContext.currentDirectory); } UIUtil::RenderTooltip("Create folder"); ImGui::SameLine(); @@ -26,7 +27,7 @@ namespace Metal { ImGui::SameLine(); if (UIUtil::ButtonSimple(Icons::refresh, UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE)) { - FilesService::GetEntries(filesContext.currentDirectory); + filesService->GetEntries(filesContext.currentDirectory); } UIUtil::RenderTooltip("Refresh"); diff --git a/src/editor/dock-spaces/files/FilesHeaderPanel.h b/src/editor/dock-spaces/files/FilesHeaderPanel.h index ecc11c54..479e7235 100644 --- a/src/editor/dock-spaces/files/FilesHeaderPanel.h +++ b/src/editor/dock-spaces/files/FilesHeaderPanel.h @@ -6,13 +6,21 @@ #include "../../abstract/AbstractPanel.h" namespace Metal { + class FilesService; + class FilesHeaderPanel final : public AbstractPanel { FilesContext &filesContext; std::string actionLabel; std::function action; + FilesService *filesService = nullptr; + public: + std::vector getDependencies() override { + return {{"FilesService", filesService}}; + } + explicit FilesHeaderPanel(FilesContext &files_context, const std::string &actionLabel, - std::function action) + std::function action) : filesContext(files_context), actionLabel(actionLabel), action(std::move(action)) { } diff --git a/src/editor/dock-spaces/files/FilesListPanel.cpp b/src/editor/dock-spaces/files/FilesListPanel.cpp index 56229939..068b328f 100644 --- a/src/editor/dock-spaces/files/FilesListPanel.cpp +++ b/src/editor/dock-spaces/files/FilesListPanel.cpp @@ -89,7 +89,7 @@ namespace Metal { if (!ImGui::IsMouseDown(ImGuiMouseButton_Left) && onDrag != nullptr && fileEntry->type == EntryType::DIRECTORY) { - applicationContext->filesService.Move(onDrag, fileEntry); + filesService->Move(onDrag, fileEntry); onDrag = nullptr; } } @@ -211,7 +211,7 @@ namespace Metal { if (isDirectory && open) { if (!loadedDirectoryPaths.contains(entry->absolutePath)) { - FilesService::GetEntries(entry); + filesService->GetEntries(entry); loadedDirectoryPaths.insert(entry->absolutePath); } // After loading, children may change; keep original iteration order to avoid infinite recursion here. @@ -277,11 +277,11 @@ namespace Metal { } if (ImGui::MenuItem("Paste")) { filesContext.toCut.clear(); - FilesService::GetEntries(filesContext.currentDirectory); + filesService->GetEntries(filesContext.currentDirectory); } if (ImGui::MenuItem("Delete")) { - applicationContext->filesService.deleteFiles(filesContext.selected); - FilesService::GetEntries(filesContext.currentDirectory); + filesService->deleteFiles(filesContext.selected); + filesService->GetEntries(filesContext.currentDirectory); } ImGui::Separator(); if (ImGui::MenuItem("Select all")) { diff --git a/src/editor/dock-spaces/files/FilesListPanel.h b/src/editor/dock-spaces/files/FilesListPanel.h index 1bf8dd21..9ebd6e44 100644 --- a/src/editor/dock-spaces/files/FilesListPanel.h +++ b/src/editor/dock-spaces/files/FilesListPanel.h @@ -10,6 +10,7 @@ namespace Metal { struct FSEntry; + class FilesService; class FilesListPanel final : public AbstractPanel { FilesContext &filesContext; @@ -27,6 +28,8 @@ namespace Metal { std::function onDoubleClick; + FilesService *filesService = nullptr; + void ensureCache(); void applySort(); @@ -45,9 +48,15 @@ namespace Metal { void renderTreeItem(FSEntry *entry); public: - explicit FilesListPanel(FilesContext &applicationContext-> std::function onDoubleClick, + std::vector getDependencies() override { + return { + {"FilesService", filesService} + }; + } + + explicit FilesListPanel(FilesContext &filesContext, std::function onDoubleClick, EntryType::EntryType typeFilter) - : filesContext(applicationContext->, typeFilter(typeFilter), onDoubleClick(std::move(onDoubleClick)) { + : filesContext(filesContext), typeFilter(typeFilter), onDoubleClick(std::move(onDoubleClick)) { } void onSync() override; diff --git a/src/editor/dock-spaces/files/FilesPanel.cpp b/src/editor/dock-spaces/files/FilesPanel.cpp index 7f772d6c..91316c83 100644 --- a/src/editor/dock-spaces/files/FilesPanel.cpp +++ b/src/editor/dock-spaces/files/FilesPanel.cpp @@ -1,22 +1,23 @@ #include "FilesPanel.h" - - #include "FilesHeaderPanel.h" #include "FilesListPanel.h" #include "../../../common/Icons.h" -#include "../../../ApplicationContext.h" -#include "../../dto/SceneData.h" #include "../../util/UIUtil.h" #include "../../dto/FSEntry.h" #include "../../dto/SceneImportSettingsDTO.h" #include "FilesContext.h" #include "../../../common/FileDialogUtil.h" - #include "FilePreviewPanel.h" -#include "../../abstract/form/FormPanel.h" #include #include #include "../../../common/FilesUtil.h" +#include "../../service/FileImporterService.h" +#include "../../repository/EditorRepository.h" +#include "../../service/SceneImporterService.h" +#include "../../service/FilesService.h" +#include "../../service/NotificationService.h" +#include "../../../engine/repository/WorldRepository.h" +#include "../../../engine/service/VoxelService.h" namespace Metal { std::string FilesPanel::getActionLabel() { @@ -28,27 +29,27 @@ namespace Metal { auto files = FileDialogUtil::PickFiles({ { "Files", - applicationContext->fileImporterService.collectCompatibleFiles().c_str(), + fileImporterService->collectCompatibleFiles().c_str(), } }); if (!files.empty()) { - applicationContext->editorRepository.pendingImports = files; - applicationContext->editorRepository.importSettingsMap.clear(); - for (const auto& file : applicationContext->editorRepository.pendingImports) { - if (applicationContext->sceneImporterService.isCompatible(file)) { - applicationContext->editorRepository.importSettingsMap.emplace(file, std::make_shared()); + editorRepository->pendingImports = files; + editorRepository->importSettingsMap.clear(); + for (const auto& file : editorRepository->pendingImports) { + if (sceneImporterService->isCompatible(file)) { + editorRepository->importSettingsMap.emplace(file, std::make_shared()); } else { - applicationContext->editorRepository.importSettingsMap.emplace(file, std::make_shared()); + editorRepository->importSettingsMap.emplace(file, std::make_shared()); } } - applicationContext->editorRepository.selectedFileForSettings = applicationContext->editorRepository.pendingImports[0]; - applicationContext->editorRepository.targetImportDirectory = filesContext.currentDirectory; + editorRepository->selectedFileForSettings = editorRepository->pendingImports[0]; + editorRepository->targetImportDirectory = filesContext.currentDirectory; } }; } void FilesPanel::onInitialize() { - filesContext.setCurrentDirectory(applicationContext->filesService.getRoot()); + filesContext.setCurrentDirectory(filesService->getRoot()); appendChild(filesHeader = new FilesHeaderPanel(filesContext, getActionLabel(), onAction())); filesListPanel = new FilesListPanel( filesContext, [ @@ -124,23 +125,23 @@ namespace Metal { void FilesPanel::openResource(FSEntry *root) { switch (root->type) { case EntryType::SCENE: { - applicationContext->notificationService.pushMessage("Loading scene", NotificationSeverities::SUCCESS); - applicationContext->worldRepository.loadScene(root->getId()); + notificationService->pushMessage("Loading scene", NotificationSeverities::SUCCESS); + worldRepository->loadScene(root->getId()); break; } case EntryType::VOLUME: { - applicationContext->notificationService.pushMessage("Loading volume", NotificationSeverities::SUCCESS); - applicationContext->voxelService.create(root->getId()); + notificationService->pushMessage("Loading volume", NotificationSeverities::SUCCESS); + voxelService->create(root->getId()); break; } case EntryType::DIRECTORY: { filesContext.setCurrentDirectory(root); - FilesService::GetEntries(root); + filesService->GetEntries(root); filesContext.selected.clear(); break; } default: - applicationContext->notificationService.pushMessage("Unsupported resource type", NotificationSeverities::ERROR); + notificationService->pushMessage("Unsupported resource type", NotificationSeverities::ERROR); break; } } @@ -150,7 +151,7 @@ namespace Metal { // } filesContext.toCut.clear(); - FilesService::GetEntries(filesContext.currentDirectory); + filesService->GetEntries(filesContext.currentDirectory); } void FilesPanel::openSelected() { @@ -162,7 +163,7 @@ namespace Metal { void FilesPanel::cutSelected() { filesContext.toCut.clear(); filesContext.toCut = filesContext.selected; - FilesService::GetEntries(filesContext.currentDirectory); + filesService->GetEntries(filesContext.currentDirectory); } void FilesPanel::selectAll() { @@ -174,7 +175,7 @@ namespace Metal { } void FilesPanel::deleteSelected() const { - applicationContext->filesService.deleteFiles(filesContext.selected); - FilesService::GetEntries(filesContext.currentDirectory); + filesService->deleteFiles(filesContext.selected); + filesService->GetEntries(filesContext.currentDirectory); } } diff --git a/src/editor/dock-spaces/files/FilesPanel.h b/src/editor/dock-spaces/files/FilesPanel.h index ea127a9f..2c90c3a1 100644 --- a/src/editor/dock-spaces/files/FilesPanel.h +++ b/src/editor/dock-spaces/files/FilesPanel.h @@ -12,6 +12,13 @@ namespace Metal { struct FSEntry; class FilePreviewPanel; class FormPanel; + class FileImporterService; + struct EditorRepository; + class SceneImporterService; + class FilesService; + class NotificationService; + struct WorldRepository; + class VoxelService; class FilesPanel : public AbstractDockPanel { protected: @@ -21,7 +28,27 @@ namespace Metal { AbstractPanel *filesListPanel = nullptr; float previewWidth = 200.0f; + FileImporterService *fileImporterService = nullptr; + EditorRepository *editorRepository = nullptr; + SceneImporterService *sceneImporterService = nullptr; + FilesService *filesService = nullptr; + NotificationService *notificationService = nullptr; + WorldRepository *worldRepository = nullptr; + VoxelService *voxelService = nullptr; + public: + std::vector getDependencies() override { + return { + {"FileImporterService", fileImporterService}, + {"EditorRepository", editorRepository}, + {"SceneImporterService", sceneImporterService}, + {"FilesService", filesService}, + {"NotificationService", notificationService}, + {"WorldRepository", worldRepository}, + {"VoxelService", voxelService} + }; + } + virtual bool renderPreview() { return true; } diff --git a/src/editor/dock-spaces/footer/EditorFooterPanel.cpp b/src/editor/dock-spaces/footer/EditorFooterPanel.cpp index c754ab52..d8336424 100644 --- a/src/editor/dock-spaces/footer/EditorFooterPanel.cpp +++ b/src/editor/dock-spaces/footer/EditorFooterPanel.cpp @@ -1,6 +1,7 @@ #include "EditorFooterPanel.h" #include "../../util/UIUtil.h" #include "../../../ApplicationContext.h" +#include "../../repository/EditorRepository.h" namespace Metal { void EditorFooterPanel::onSync() { @@ -17,11 +18,11 @@ namespace Metal { } void EditorFooterPanel::renderShortcuts() { - auto &shortcuts = applicationContext->editorRepository.focusedShortcuts; + auto &shortcuts = editorRepository->focusedShortcuts; if (shortcuts.empty()) return; ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5); // Some padding - ImGui::Text(applicationContext->editorRepository.focusedWindowName.c_str()); + ImGui::Text(editorRepository->focusedWindowName.c_str()); ImGui::SameLine(); std::string label; for (size_t i = 0; i < std::min(shortcuts.size(), size_t(3)); ++i) { diff --git a/src/editor/dock-spaces/footer/EditorFooterPanel.h b/src/editor/dock-spaces/footer/EditorFooterPanel.h index 257b12bd..372c6119 100644 --- a/src/editor/dock-spaces/footer/EditorFooterPanel.h +++ b/src/editor/dock-spaces/footer/EditorFooterPanel.h @@ -4,11 +4,21 @@ #include "../../abstract/AbstractPanel.h" namespace Metal { + struct EditorRepository; + class EditorFooterPanel final : public AbstractPanel { + EditorRepository *editorRepository = nullptr; + void renderShortcuts(); static void framerate(); public: + std::vector getDependencies() override { + return { + {"EditorRepository", editorRepository} + }; + } + void onSync() override; }; } diff --git a/src/editor/dock-spaces/header/AsyncTaskPanel.cpp b/src/editor/dock-spaces/header/AsyncTaskPanel.cpp index fba2a231..616fc37b 100644 --- a/src/editor/dock-spaces/header/AsyncTaskPanel.cpp +++ b/src/editor/dock-spaces/header/AsyncTaskPanel.cpp @@ -2,10 +2,12 @@ #include "../../../ApplicationContext.h" #include "../../util/UIUtil.h" #include +#include "../../service/AsyncTaskService.h" +#include "../../dto/AsyncTask.h" namespace Metal { void AsyncTaskPanel::onSync() { - auto tasks = applicationContext->asyncTaskService.getActiveTasks(); + auto tasks = asyncTaskService->getActiveTasks(); if (tasks.empty()) { UIUtil::DynamicSpacing(90); return; @@ -56,7 +58,7 @@ namespace Metal { ImGui::SameLine(); if (ImGui::Button((Icons::close + "##" + task->id).c_str(), ImVec2(UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE))) { - applicationContext->asyncTaskService.endTask(task->id, true); + asyncTaskService->endTask(task->id, true); } ImGui::EndGroup(); } diff --git a/src/editor/dock-spaces/header/AsyncTaskPanel.h b/src/editor/dock-spaces/header/AsyncTaskPanel.h index c1e09daf..640dee30 100644 --- a/src/editor/dock-spaces/header/AsyncTaskPanel.h +++ b/src/editor/dock-spaces/header/AsyncTaskPanel.h @@ -4,8 +4,18 @@ #include "../../abstract/AbstractPanel.h" namespace Metal { + class AsyncTaskService; + class AsyncTaskPanel final : public AbstractPanel { + AsyncTaskService *asyncTaskService = nullptr; + public: + std::vector getDependencies() override { + return { + {"AsyncTaskService", asyncTaskService} + }; + } + void onSync() override; }; } diff --git a/src/editor/dock-spaces/header/EditorHeaderPanel.cpp b/src/editor/dock-spaces/header/EditorHeaderPanel.cpp index 5c5fac77..1bca0433 100644 --- a/src/editor/dock-spaces/header/EditorHeaderPanel.cpp +++ b/src/editor/dock-spaces/header/EditorHeaderPanel.cpp @@ -2,6 +2,9 @@ #include "AsyncTaskPanel.h" #include "../../util/UIUtil.h" #include "../../../ApplicationContext.h" +#include "../../../core/DirectoryService.h" +#include "../../../core/glfw/GLFWContext.h" +#include "../../../engine/EngineContext.h" namespace Metal { void EditorHeaderPanel::onSync() { @@ -13,7 +16,7 @@ namespace Metal { // Window dragging logic if (ImGui::IsWindowHovered() && ImGui::IsMouseDragging(ImGuiMouseButton_Left)) { ImVec2 delta = ImGui::GetIO().MouseDelta; - GLFWwindow* window = applicationContext->glfwContext.getWindow(); + GLFWwindow* window = glfwContext->getWindow(); int x, y; glfwGetWindowPos(window, &x, &y); glfwSetWindowPos(window, x + (int)delta.x, y + (int)delta.y); @@ -23,7 +26,7 @@ namespace Metal { void EditorHeaderPanel::renderWindowControls() { ImGui::SameLine(ImGui::GetWindowWidth() - (UIUtil::ONLY_ICON_BUTTON_SIZE * 3 + 10)); - GLFWwindow* window = applicationContext->glfwContext.getWindow(); + GLFWwindow* window = glfwContext->getWindow(); if (UIUtil::ButtonSimple(Icons::minimize, UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE)) { glfwIconifyWindow(window); @@ -48,16 +51,16 @@ namespace Metal { void EditorHeaderPanel::renderFileTab() { if (ImGui::BeginMainMenuBar()) { if (UIUtil::ButtonSimple(Icons::save, UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE)) { - applicationContext->save(); + directoryService->save(); } ImGui::SameLine(); if (ImGui::BeginMenu("File")) { if (ImGui::MenuItem("Open", "Ctrl+O")) { - applicationContext->engineContext.dispose(); - applicationContext->updateRootPath(true); + engineContext->dispose(); + directoryService->updateRootPath(true); } if (ImGui::MenuItem("Save", "Ctrl+S")) { - applicationContext->save(); + directoryService->save(); } ImGui::Separator(); if (ImGui::MenuItem("Exit")) { @@ -69,7 +72,7 @@ namespace Metal { // Create an "Edit" menu if (ImGui::BeginMenu("Edit")) { if (ImGui::MenuItem("Compile shaders")) { - applicationContext->engineContext.dispose(); + engineContext->dispose(); // TODO - CREATE NEW FRAME } ImGui::EndMenu(); diff --git a/src/editor/dock-spaces/header/EditorHeaderPanel.h b/src/editor/dock-spaces/header/EditorHeaderPanel.h index 75f2f184..412ae9a6 100644 --- a/src/editor/dock-spaces/header/EditorHeaderPanel.h +++ b/src/editor/dock-spaces/header/EditorHeaderPanel.h @@ -4,14 +4,30 @@ #include "../../abstract/AbstractPanel.h" namespace Metal { + class GLFWContext; + class EngineContext; + struct DirectoryService; + class EditorHeaderPanel final : public AbstractPanel { AbstractPanel *asyncTask = nullptr; + GLFWContext *glfwContext = nullptr; + EngineContext *engineContext = nullptr; + DirectoryService *directoryService = nullptr; + void renderFileTab(); void renderWindowControls(); public: + std::vector getDependencies() override { + return { + {"GLFWContext", glfwContext}, + {"EngineContext", engineContext}, + {"DirectoryService", directoryService} + }; + } + void onInitialize() override; void onSync() override; diff --git a/src/editor/dock-spaces/inspector/InspectorPanel.cpp b/src/editor/dock-spaces/inspector/InspectorPanel.cpp index bee24e34..adef54bd 100644 --- a/src/editor/dock-spaces/inspector/InspectorPanel.cpp +++ b/src/editor/dock-spaces/inspector/InspectorPanel.cpp @@ -1,5 +1,4 @@ #include "InspectorPanel.h" - #include "../../abstract/form/FormPanel.h" #include "../../util/UIUtil.h" #include "../../../common/Inspectable.h" @@ -7,6 +6,8 @@ #include "../../../engine/dto/MetadataComponent.h" #include #include +#include "../../repository/EditorRepository.h" +#include "../../../engine/repository/WorldRepository.h" namespace Metal { void InspectorPanel::onInitialize() { @@ -26,11 +27,11 @@ namespace Metal { if (ImGui::BeginPopup((id + "AddComponentPopup").c_str())) { for (const auto &compDef: ComponentTypes::getComponents()) { - bool hasComponent = compDef.getInspectable(applicationContext->worldRepository, selectedId) != nullptr; + bool hasComponent = compDef.getInspectable(*worldRepository, selectedId) != nullptr; if (!hasComponent) { if (ImGui::MenuItem( (compDef.icon + " " + compDef.name + id + "adCOmp" + compDef.name).c_str())) { - applicationContext->worldRepository.createComponent(selectedId, compDef.type); + worldRepository->createComponent(selectedId, compDef.type); selectedId = EMPTY_ENTITY; tick(); } @@ -42,20 +43,17 @@ namespace Metal { } void InspectorPanel::tick() { - if (auto &editorRepository = applicationContext->editorRepository; - editorRepository.mainSelection != selectedId) { + if (editorRepository->mainSelection != selectedId) { additionalInspection.clear(); - selectedId = editorRepository.mainSelection; + selectedId = editorRepository->mainSelection; formPanel->resetForm(); if (selectedId != EMPTY_ENTITY) { - auto &repo = applicationContext->worldRepository; - - selectedEntity = repo.getEntity(selectedId); + selectedEntity = worldRepository->getEntity(selectedId); if (selectedEntity != nullptr) { additionalInspection.push_back(selectedEntity); for (const auto &compDef: ComponentTypes::getComponents()) { - if (Inspectable *inspectable = compDef.getInspectable(repo, selectedId)) { + if (Inspectable *inspectable = compDef.getInspectable(*worldRepository, selectedId)) { additionalInspection.push_back(inspectable); } } diff --git a/src/editor/dock-spaces/inspector/InspectorPanel.h b/src/editor/dock-spaces/inspector/InspectorPanel.h index 69a3c411..cf8a1bf6 100644 --- a/src/editor/dock-spaces/inspector/InspectorPanel.h +++ b/src/editor/dock-spaces/inspector/InspectorPanel.h @@ -7,6 +7,8 @@ namespace Metal { class FormPanel; class Inspectable; + struct EditorRepository; + struct WorldRepository; class InspectorPanel final : public AbstractDockPanel { std::vector additionalInspection{}; @@ -15,7 +17,17 @@ namespace Metal { FormPanel *formPanel = nullptr; entt::entity selectedId = EMPTY_ENTITY; + EditorRepository *editorRepository = nullptr; + WorldRepository *worldRepository = nullptr; + public: + std::vector getDependencies() override { + return { + {"EditorRepository", editorRepository}, + {"WorldRepository", worldRepository} + }; + } + void onInitialize() override; void onSync() override; diff --git a/src/editor/dock-spaces/metrics/MetricsPanel.cpp b/src/editor/dock-spaces/metrics/MetricsPanel.cpp index f478554a..7e8bd984 100644 --- a/src/editor/dock-spaces/metrics/MetricsPanel.cpp +++ b/src/editor/dock-spaces/metrics/MetricsPanel.cpp @@ -1,6 +1,12 @@ #include "MetricsPanel.h" #include "../../../ApplicationContext.h" #include "imgui.h" +#include "../../../engine/service/MeshService.h" +#include "../../../engine/service/VoxelService.h" +#include "../../../engine/service/FrameBufferService.h" +#include "../../../engine/service/TextureService.h" +#include "../../../engine/service/PipelineService.h" +#include "../../../engine/service/BufferService.h" namespace Metal { template @@ -22,11 +28,11 @@ namespace Metal { } void MetricsPanel::onSync() { - drawResourceList("Meshes", applicationContext->meshService, id); - drawResourceList("Voxels", applicationContext->voxelService, id); - drawResourceList("Framebuffers", applicationContext->framebufferService, id); - drawResourceList("Textures", applicationContext->textureService, id); - drawResourceList("Pipelines", applicationContext->pipelineService, id); - drawResourceList("Buffers", applicationContext->bufferService, id); + if (meshService) drawResourceList("Meshes", *meshService, id); + if (voxelService) drawResourceList("Voxels", *voxelService, id); + if (framebufferService) drawResourceList("Framebuffers", *framebufferService, id); + if (textureService) drawResourceList("Textures", *textureService, id); + if (pipelineService) drawResourceList("Pipelines", *pipelineService, id); + if (bufferService) drawResourceList("Buffers", *bufferService, id); } } diff --git a/src/editor/dock-spaces/metrics/MetricsPanel.h b/src/editor/dock-spaces/metrics/MetricsPanel.h index 0f133b5a..e81e1e6c 100644 --- a/src/editor/dock-spaces/metrics/MetricsPanel.h +++ b/src/editor/dock-spaces/metrics/MetricsPanel.h @@ -5,8 +5,33 @@ #include "imgui.h" namespace Metal { + class MeshService; + class VoxelService; + class FrameBufferService; + class TextureService; + class PipelineService; + class BufferService; + class MetricsPanel final : public AbstractDockPanel { + MeshService *meshService = nullptr; + VoxelService *voxelService = nullptr; + FrameBufferService *framebufferService = nullptr; + TextureService *textureService = nullptr; + PipelineService *pipelineService = nullptr; + BufferService *bufferService = nullptr; + public: + std::vector getDependencies() override { + return { + {"MeshService", meshService}, + {"VoxelService", voxelService}, + {"FrameBufferService", framebufferService}, + {"TextureService", textureService}, + {"PipelineService", pipelineService}, + {"BufferService", bufferService} + }; + } + void onSync() override; }; } diff --git a/src/editor/dock-spaces/repositories/RepositoriesPanel.cpp b/src/editor/dock-spaces/repositories/RepositoriesPanel.cpp index fff6ec87..4c6bc533 100644 --- a/src/editor/dock-spaces/repositories/RepositoriesPanel.cpp +++ b/src/editor/dock-spaces/repositories/RepositoriesPanel.cpp @@ -2,15 +2,19 @@ #include "../../abstract/form/FormPanel.h" #include "../../../ApplicationContext.h" #include "../../../common/Inspectable.h" +#include "../../repository/EditorRepository.h" +#include "../../../engine/repository/EngineRepository.h" +#include "../../../engine/repository/WorldRepository.h" +#include "../../../engine/dto/Camera.h" namespace Metal { void RepositoriesPanel::onInitialize() { formPanel = new FormPanel(); appendChild(formPanel); - repositories.push_back(&applicationContext->editorRepository); - repositories.push_back(&applicationContext->engineRepository); - repositories.push_back(&applicationContext->worldRepository.camera); + repositories.push_back(editorRepository); + repositories.push_back(engineRepository); + repositories.push_back(&worldRepository->camera); } void RepositoriesPanel::onSync() { diff --git a/src/editor/dock-spaces/repositories/RepositoriesPanel.h b/src/editor/dock-spaces/repositories/RepositoriesPanel.h index b566b984..6121111c 100644 --- a/src/editor/dock-spaces/repositories/RepositoriesPanel.h +++ b/src/editor/dock-spaces/repositories/RepositoriesPanel.h @@ -6,12 +6,27 @@ namespace Metal { class FormPanel; class Inspectable; + struct EditorRepository; + struct EngineRepository; + struct WorldRepository; class RepositoriesPanel final : public AbstractDockPanel { std::vector repositories{}; FormPanel *formPanel = nullptr; + EditorRepository *editorRepository = nullptr; + EngineRepository *engineRepository = nullptr; + WorldRepository *worldRepository = nullptr; + public: + std::vector getDependencies() override { + return { + {"EditorRepository", editorRepository}, + {"EngineRepository", engineRepository}, + {"WorldRepository", worldRepository} + }; + } + void onInitialize() override; void onSync() override; }; diff --git a/src/editor/dock-spaces/viewport/CameraPositionPanel.cpp b/src/editor/dock-spaces/viewport/CameraPositionPanel.cpp index 9af7929e..9ce03f4d 100644 --- a/src/editor/dock-spaces/viewport/CameraPositionPanel.cpp +++ b/src/editor/dock-spaces/viewport/CameraPositionPanel.cpp @@ -1,8 +1,8 @@ #include "CameraPositionPanel.h" - #include "../../../ApplicationContext.h" #include "../../util/UIUtil.h" #include "../../../engine/dto/Camera.h" +#include "../../../engine/repository/WorldRepository.h" namespace Metal { void CameraPositionPanel::onSync() { @@ -18,7 +18,7 @@ namespace Metal { ImGui::SetNextWindowBgAlpha(.4f); if (ImGui::Begin(id.c_str(), &UIUtil::OPEN, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse)) { - const auto &positionCamera = applicationContext->worldRepository.camera.position; + const auto &positionCamera = worldRepository->camera.position; ImGui::TextColored(RED, "X: %i", static_cast(positionCamera.x)); ImGui::SameLine(); ImGui::TextColored(GREEN, "Y: %i", static_cast(positionCamera.y)); @@ -27,10 +27,10 @@ namespace Metal { ImGui::SameLine(); ImGui::Text( - "Yaw: %i", static_cast(applicationContext->worldRepository.camera.yaw * TO_DEG)); + "Yaw: %i", static_cast(worldRepository->camera.yaw * TO_DEG)); ImGui::SameLine(); ImGui::Text("Pitch: %i", - static_cast(applicationContext->worldRepository.camera.pitch * TO_DEG)); + static_cast(worldRepository->camera.pitch * TO_DEG)); } ImGui::PopStyleVar(); ImGui::End(); diff --git a/src/editor/dock-spaces/viewport/CameraPositionPanel.h b/src/editor/dock-spaces/viewport/CameraPositionPanel.h index eabc4a4a..1dd71422 100644 --- a/src/editor/dock-spaces/viewport/CameraPositionPanel.h +++ b/src/editor/dock-spaces/viewport/CameraPositionPanel.h @@ -6,13 +6,23 @@ #include "../../abstract/AbstractPanel.h" namespace Metal { + struct WorldRepository; + class CameraPositionPanel final : public AbstractPanel { ImVec4 RED = ImVec4(1, 0, 0, 1); ImVec4 GREEN = ImVec4(0, 1, 0, 1); ImVec4 BLUE = ImVec4(0, .5f, 1, 1); float TO_DEG = 180.f / glm::pi(); + WorldRepository *worldRepository = nullptr; + public: + std::vector getDependencies() override { + return { + {"WorldRepository", worldRepository} + }; + } + void onSync() override; }; } // Metal diff --git a/src/editor/dock-spaces/viewport/EngineFramePanel.cpp b/src/editor/dock-spaces/viewport/EngineFramePanel.cpp index b38e5df5..12f6587c 100644 --- a/src/editor/dock-spaces/viewport/EngineFramePanel.cpp +++ b/src/editor/dock-spaces/viewport/EngineFramePanel.cpp @@ -14,7 +14,6 @@ #include "ViewportHeaderPanel.h" #include "ImGuizmo.h" #include - #include "../../../engine/passes/impl/HWRayTracingPass.h" #include "../../../engine/passes/impl/PostProcessingPass.h" #include "../../../engine/passes/impl/SpatialFilterPass.h" @@ -22,15 +21,21 @@ #include "../../passes/GridPass.h" #include "../../passes/SelectionIDPass.h" #include "../../passes/SelectionOutlinePass.h" +#include "../../../core/vulkan/VulkanContext.h" +#include "../../../engine/repository/EngineRepository.h" +#include "../../../engine/EngineContext.h" +#include "../../../engine/service/DescriptorSetService.h" +#include "../../service/SelectionService.h" +#include "../../../engine/resource/TextureInstance.h" namespace Metal { void EngineFramePanel::onInitialize() { - const auto gBufferW = applicationContext->vulkanContext.getWindowWidth() / applicationContext->engineRepository. + const auto gBufferW = vulkanContext->getWindowWidth() / engineRepository-> shadingResInvScale; - const auto gBufferH = applicationContext->vulkanContext.getWindowHeight() / applicationContext->engineRepository - .shadingResInvScale; + const auto gBufferH = vulkanContext->getWindowHeight() / engineRepository + ->shadingResInvScale; - engineFrame = EngineFrameBuilder() + engineContext->createFrame(id) .addBuffer(RID_GLOBAL_DATA, sizeof(GlobalDataUBO), VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, UNIFORM_BUFFER) .addBuffer(RID_LIGHT_BUFFER, MAX_LIGHTS * sizeof(LightData), @@ -62,17 +67,15 @@ namespace Metal { .addPass(std::make_unique(), RID_POST_PROCESSING_CB) .addPass(std::make_unique(), RID_POST_PROCESSING_CB) .build(); - - applicationContext->engineContext.registerFrame(engineFrame.get()); } void EngineFramePanel::onSync() { - engineFrame->setShouldRender(true); + engineContext->setCurrentFrame(id); const ImVec2 viewportSize = ImGui::GetContentRegionAvail(); - auto *framebuffer = engineFrame->getResourceAs(RID_POST_PROCESSING_FBO); + auto *framebuffer = engineContext->currentFrame->getResourceAs(RID_POST_PROCESSING_FBO); if (framebuffer) { - applicationContext->descriptorSetService.setImageDescriptor(framebuffer, 0); + descriptorSetService->setImageDescriptor(framebuffer, 0); ImGui::Image(reinterpret_cast(framebuffer->attachments[0]->imageDescriptor->vkDescriptorSet), viewportSize); @@ -103,7 +106,7 @@ namespace Metal { return; } - auto *gBufferPositionIndex = engineFrame->getResourceAs(RID_GBUFFER_POSITION_INDEX); + auto *gBufferPositionIndex = engineContext->currentFrame->getResourceAs(RID_GBUFFER_POSITION_INDEX); if (!gBufferPositionIndex) { return; } @@ -113,9 +116,9 @@ namespace Metal { const uint32_t pixelX = std::min(static_cast(u * static_cast(width)), width - 1); const uint32_t pixelY = std::min(static_cast(v * static_cast(height)), height - 1); - const auto picked = applicationContext->pickingService.pickEntityFromGBuffer( + const auto picked = pickingService->pickEntityFromGBuffer( gBufferPositionIndex, pixelX, pixelY); - applicationContext->selectionService.clearSelection(); - applicationContext->selectionService.addSelected(picked.value_or(EMPTY_ENTITY)); + selectionService->clearSelection(); + selectionService->addSelected(picked.value_or(EMPTY_ENTITY)); } } // Metal diff --git a/src/editor/dock-spaces/viewport/EngineFramePanel.h b/src/editor/dock-spaces/viewport/EngineFramePanel.h index cc7670bb..bee6aba7 100644 --- a/src/editor/dock-spaces/viewport/EngineFramePanel.h +++ b/src/editor/dock-spaces/viewport/EngineFramePanel.h @@ -7,11 +7,33 @@ namespace Metal { class EngineFrame; + class VulkanContext; + struct EngineRepository; + class EngineContext; + class DescriptorSetService; + class PickingService; + class SelectionService; class EngineFramePanel final : public AbstractPanel { - std::unique_ptr engineFrame; + VulkanContext *vulkanContext = nullptr; + EngineRepository *engineRepository = nullptr; + EngineContext *engineContext = nullptr; + DescriptorSetService *descriptorSetService = nullptr; + PickingService *pickingService = nullptr; + SelectionService *selectionService = nullptr; public: + std::vector getDependencies() override { + return { + {"VulkanContext", vulkanContext}, + {"EngineRepository", engineRepository}, + {"EngineContext", engineContext}, + {"DescriptorSetService", descriptorSetService}, + {"PickingService", pickingService}, + {"SelectionService", selectionService} + }; + } + void onInitialize() override; void onSync() override; diff --git a/src/editor/dock-spaces/viewport/GizmoPanel.cpp b/src/editor/dock-spaces/viewport/GizmoPanel.cpp index aed80e22..30f4163d 100644 --- a/src/editor/dock-spaces/viewport/GizmoPanel.cpp +++ b/src/editor/dock-spaces/viewport/GizmoPanel.cpp @@ -1,19 +1,19 @@ #include "GizmoPanel.h" - #include "../../../ApplicationContext.h" #include "../../../engine/dto/TransformComponent.h" #include "../../../engine/dto/Camera.h" #include "ImGuizmo.h" #include -#define GLM_ENABLE_EXPERIMENTAL #include +#include "../../repository/EditorRepository.h" +#include "../../../engine/repository/WorldRepository.h" +#include "../../service/SelectionService.h" namespace Metal { GizmoPanel::GizmoPanel(ImVec2 *position, glm::vec2 *size): size(size), position(position) { } void GizmoPanel::onInitialize() { - editorRepository = &applicationContext->editorRepository; } void GizmoPanel::onSync() { @@ -22,7 +22,7 @@ namespace Metal { localSelected = nullptr; localChangeId = 0; if (editorRepository->mainSelection != EMPTY_ENTITY) { - applicationContext->selectionService.updatePrimitiveSelected(); + selectionService->updatePrimitiveSelected(); } return; } @@ -40,7 +40,7 @@ namespace Metal { } recomposeMatrix(); - ImGuizmo::SetOrthographic(applicationContext->worldRepository.camera.isOrthographic); + ImGuizmo::SetOrthographic(worldRepository->camera.isOrthographic); ImGuizmo::SetDrawlist(); ImVec2 viewportMin = ImGui::GetItemRectMin(); ImVec2 viewportSize = ImGui::GetItemRectSize(); @@ -113,8 +113,8 @@ namespace Metal { } void GizmoPanel::recomposeMatrix() { - viewMatrixCache = glm::value_ptr(applicationContext->worldRepository.camera.viewMatrix); - cacheProjection = applicationContext->worldRepository.camera.projectionMatrix; + viewMatrixCache = glm::value_ptr(worldRepository->camera.viewMatrix); + cacheProjection = worldRepository->camera.projectionMatrix; cacheProjection[1][1] *= -1; diff --git a/src/editor/dock-spaces/viewport/GizmoPanel.h b/src/editor/dock-spaces/viewport/GizmoPanel.h index 36b6ee20..b68c74fc 100644 --- a/src/editor/dock-spaces/viewport/GizmoPanel.h +++ b/src/editor/dock-spaces/viewport/GizmoPanel.h @@ -2,6 +2,7 @@ #define GIZMOPANEL_H #include #include +#define GLM_ENABLE_EXPERIMENTAL #include #include @@ -9,6 +10,8 @@ namespace Metal { struct EditorRepository; + struct WorldRepository; + class SelectionService; } namespace Metal { @@ -31,9 +34,20 @@ namespace Metal { TransformComponent *localSelected = nullptr; int localChangeId{}; bool isGizmoOver = false; + EditorRepository *editorRepository = nullptr; + WorldRepository *worldRepository = nullptr; + SelectionService *selectionService = nullptr; public: + std::vector getDependencies() override { + return { + {"EditorRepository", editorRepository}, + {"WorldRepository", worldRepository}, + {"SelectionService", selectionService} + }; + } + explicit GizmoPanel(ImVec2 *position, glm::vec2 *size); void onInitialize() override; diff --git a/src/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp b/src/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp index 1a3e1c07..9094ce19 100644 --- a/src/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp +++ b/src/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp @@ -2,10 +2,12 @@ #include "../../util/UIUtil.h" #include "../../../ApplicationContext.h" #include "ImGuizmo.h" +#include "../../repository/EditorRepository.h" +#include "../../../engine/repository/WorldRepository.h" +#include "../../../engine/dto/MetadataComponent.h" namespace Metal { void GizmoSettingsPanel::onInitialize() { - editorRepository = &applicationContext->editorRepository; } void GizmoSettingsPanel::onSync() { @@ -15,9 +17,9 @@ namespace Metal { ImGui::SameLine(); gizmoGrid(); UIUtil::Spacing(); - if (selectedEntityId != editorRepository->mainSelection && applicationContext->worldRepository.registry.all_of( + if (selectedEntityId != editorRepository->mainSelection && worldRepository->registry.valid( editorRepository->mainSelection)) { - selectedEntity = applicationContext->worldRepository.getEntity(editorRepository->mainSelection); + selectedEntity = worldRepository->getEntity(editorRepository->mainSelection); selectedEntityId = editorRepository->mainSelection; } if (selectedEntity != nullptr) { @@ -119,7 +121,7 @@ namespace Metal { ImGui::SetNextItemWidth(50); if (ImGui::Combo((id + "scaleSnapAngle").c_str(), &editorRepository->gizmoSnapScaleOption, SNAP_SCALE_OPTIONS, ImGuiComboFlags_NoArrowButton)) { - editorRepository->gizmoSnapScale = SNAP_SCALE_OPTIONS[editorRepository->gizmoSnapScaleOption]; + editorRepository->gizmoSnapScale = SNAP_SCALE_OPTIONS_A[editorRepository->gizmoSnapScaleOption]; } } } // Metal diff --git a/src/editor/dock-spaces/viewport/GizmoSettingsPanel.h b/src/editor/dock-spaces/viewport/GizmoSettingsPanel.h index 0c68b751..998ac529 100644 --- a/src/editor/dock-spaces/viewport/GizmoSettingsPanel.h +++ b/src/editor/dock-spaces/viewport/GizmoSettingsPanel.h @@ -9,6 +9,7 @@ namespace Metal { struct MetadataComponent; struct EditorRepository; + struct WorldRepository; class GizmoSettingsPanel final : public AbstractPanel { static constexpr ImVec2 SPACING = ImVec2(0, 0); @@ -19,10 +20,18 @@ namespace Metal { static constexpr const char *SNAP_SCALE_OPTIONS = "0.5\0 1\0 2\0 5\0 10\0"; static constexpr std::array SNAP_SCALE_OPTIONS_A = {0.5, 1, 2, 5, 10}; EditorRepository *editorRepository = nullptr; + WorldRepository *worldRepository = nullptr; MetadataComponent *selectedEntity = nullptr; entt::entity selectedEntityId = EMPTY_ENTITY; public: + std::vector getDependencies() override { + return { + {"EditorRepository", editorRepository}, + {"WorldRepository", worldRepository} + }; + } + void onInitialize() override; void gizmoGrid() const; diff --git a/src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp b/src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp index 5c4d99f9..c6a7dd27 100644 --- a/src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp +++ b/src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp @@ -1,8 +1,9 @@ #include "ViewportHeaderPanel.h" - #include "GizmoSettingsPanel.h" #include "../../../ApplicationContext.h" #include "../../util/UIUtil.h" +#include "../../repository/EditorRepository.h" +#include "../../../engine/repository/WorldRepository.h" namespace Metal { void ViewportHeaderPanel::onInitialize() { @@ -33,8 +34,8 @@ namespace Metal { if (UIUtil::ButtonSimple(Icons::center_focus_strong + id + "centerCamera", UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE)) { - applicationContext->worldRepository.camera.position = {0, 0, 0}; - applicationContext->worldRepository.camera.registerChange(); + worldRepository->camera.position = {0, 0, 0}; + worldRepository->camera.registerChange(); } UIUtil::RenderTooltip("Center camera?"); @@ -44,21 +45,20 @@ namespace Metal { static float speedValues[] = {0.1f, 0.5f, 1.0f, 2.0f, 5.0f, 10.0f}; int currentSpeedIndex = 2; for (int i = 0; i < 6; i++) { - if (applicationContext->worldRepository.camera.movementSensitivity == speedValues[i]) { + if (worldRepository->camera.movementSensitivity == speedValues[i]) { currentSpeedIndex = i; break; } } if (ImGui::Combo((id + "speedCamera").c_str(), ¤tSpeedIndex, speeds, IM_ARRAYSIZE(speeds))) { - applicationContext->worldRepository.camera.movementSensitivity = speedValues[currentSpeedIndex]; + worldRepository->camera.movementSensitivity = speedValues[currentSpeedIndex]; } UIUtil::RenderTooltip("Camera speed"); } void ViewportHeaderPanel::shadingMode() { - auto &editorRepository = applicationContext->editorRepository; ImGui::SetNextItemWidth(150); - shadingModelOption = ShadingModes::IndexOfValue(editorRepository.shadingMode); + shadingModelOption = ShadingModes::IndexOfValue(editorRepository->shadingMode); auto currentEntry = ShadingModes::entries[shadingModelOption]; if (ImGui::BeginCombo((id + "shadingMode").c_str(), (currentEntry.icon + " " + currentEntry.label).c_str())) { @@ -67,7 +67,7 @@ namespace Metal { auto entry = ShadingModes::entries[i]; if (ImGui::Selectable((entry.icon + " " + entry.label).c_str(), is_selected)) { shadingModelOption = i; - editorRepository.shadingMode = ShadingModes::ValueOfIndex(shadingModelOption); + editorRepository->shadingMode = ShadingModes::ValueOfIndex(shadingModelOption); } if (is_selected) { ImGui::SetItemDefaultFocus(); diff --git a/src/editor/dock-spaces/viewport/ViewportHeaderPanel.h b/src/editor/dock-spaces/viewport/ViewportHeaderPanel.h index ed2e51c1..a5712887 100644 --- a/src/editor/dock-spaces/viewport/ViewportHeaderPanel.h +++ b/src/editor/dock-spaces/viewport/ViewportHeaderPanel.h @@ -5,13 +5,26 @@ #include "../../abstract/AbstractPanel.h" namespace Metal { + struct EditorRepository; + struct WorldRepository; + class ViewportHeaderPanel final : public AbstractPanel { static constexpr int FLAGS = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoCollapse; AbstractPanel *gizmo = nullptr; int shadingModelOption = 0; + EditorRepository *editorRepository = nullptr; + WorldRepository *worldRepository = nullptr; + public: + std::vector getDependencies() override { + return { + {"EditorRepository", editorRepository}, + {"WorldRepository", worldRepository} + }; + } + static constexpr float HEIGHT = 28; void onInitialize() override; diff --git a/src/editor/dock-spaces/viewport/ViewportPanel.cpp b/src/editor/dock-spaces/viewport/ViewportPanel.cpp index 8d7e4807..8114ee67 100644 --- a/src/editor/dock-spaces/viewport/ViewportPanel.cpp +++ b/src/editor/dock-spaces/viewport/ViewportPanel.cpp @@ -1,5 +1,4 @@ #include "ViewportPanel.h" - #include "CameraPositionPanel.h" #include "GizmoPanel.h" #include "ImGuizmo.h" @@ -9,6 +8,14 @@ #include "../../../engine/dto/Camera.h" #include "../../../engine/frame-builder/EngineFrameBuilder.h" #include +#include "../../repository/EditorRepository.h" +#include "../../../engine/repository/WorldRepository.h" +#include "../../service/SelectionService.h" +#include "../../../engine/service/CameraService.h" +#include "../../../engine/repository/RuntimeRepository.h" +#include "../../../engine/EngineContext.h" +#include "../../../core/DirectoryService.h" +#include "../../../engine/dto/MetadataComponent.h" namespace Metal { void ViewportPanel::onInitialize() { @@ -19,39 +26,39 @@ namespace Metal { shortcuts = { ShortcutDTO("Change shading mode", ImGuiKey_Q, [this]() { - applicationContext->editorRepository.shadingMode = ShadingModes::ValueOfIndex( - ShadingModes::IndexOfValue(applicationContext->editorRepository.shadingMode) + 1); + editorRepository->shadingMode = ShadingModes::ValueOfIndex( + ShadingModes::IndexOfValue(editorRepository->shadingMode) + 1); }), ShortcutDTO("Translate", ImGuiKey_1, [this]() { - applicationContext->editorRepository.gizmoType = ImGuizmo::OPERATION::TRANSLATE; + editorRepository->gizmoType = ImGuizmo::OPERATION::TRANSLATE; }), ShortcutDTO("Scale", ImGuiKey_2, [this]() { - applicationContext->editorRepository.gizmoType = ImGuizmo::OPERATION::SCALE; + editorRepository->gizmoType = ImGuizmo::OPERATION::SCALE; }), ShortcutDTO("Rotate", ImGuiKey_3, [this]() { - applicationContext->editorRepository.gizmoType = ImGuizmo::OPERATION::ROTATE; + editorRepository->gizmoType = ImGuizmo::OPERATION::ROTATE; }), ShortcutDTO("Delete", ImGuiKey_Delete, [this]() { std::vector entities; - for (auto &entry: applicationContext->editorRepository.selected) { + for (auto &entry: editorRepository->selected) { entities.push_back(entry.first); } - applicationContext->worldRepository.deleteEntities(entities); - applicationContext->selectionService.clearSelection(); + worldRepository->deleteEntities(entities); + selectionService->clearSelection(); }), ShortcutDTO("Select All", ImGuiMod_Ctrl | ImGuiKey_A, [this]() { std::vector entities; - auto &storage = applicationContext->worldRepository.registry.storage(); + auto &storage = worldRepository->registry.storage(); for (auto it = storage.begin(); it != storage.end(); ++it) { auto entity = *it; - if (applicationContext->worldRepository.registry.all_of(entity)) { + if (worldRepository->registry.all_of(entity)) { entities.push_back(entity); } } - applicationContext->selectionService.addAllSelected(entities); + selectionService->addAllSelected(entities); }), ShortcutDTO("Save", ImGuiMod_Ctrl | ImGuiKey_S, [this] { - applicationContext->save(); + directoryService->save(); }) }; } @@ -68,16 +75,12 @@ namespace Metal { } void ViewportPanel::updateCamera() { - auto &worldRepository = applicationContext->worldRepository; - const auto &cameraService = applicationContext->cameraService; - if (ImGui::IsWindowHovered() && !ImGuizmo::IsUsing() && ImGui::IsMouseDown(ImGuiMouseButton_Right)) { - cameraService.handleInput(isFirstMovement); + cameraService->handleInput(isFirstMovement); if (const auto &io = ImGui::GetIO(); io.MouseWheel != 0) { - worldRepository.camera.movementSensitivity += io.MouseWheel * 100 * applicationContext-> - engineContext.deltaTime; - worldRepository.camera.movementSensitivity = - std::max(.1f, worldRepository.camera.movementSensitivity); + worldRepository->camera.movementSensitivity += io.MouseWheel * 100 * engineContext->deltaTime; + worldRepository->camera.movementSensitivity = + std::max(.1f, worldRepository->camera.movementSensitivity); } isFirstMovement = false; } else { @@ -86,33 +89,28 @@ namespace Metal { } void ViewportPanel::updateInputs() const { - auto &repo = applicationContext->runtimeRepository; - const ImVec2 windowSize = ImGui::GetWindowSize(); - size->x = windowSize.x; - size->y = windowSize.y; - - repo.viewportH = size->y; - repo.viewportW = size->x; + runtimeRepository->viewportH = size->y; + runtimeRepository->viewportW = size->x; const ImVec2 windowPos = ImGui::GetWindowPos(); - repo.viewportX = windowPos.x; - repo.viewportY = windowPos.y; + runtimeRepository->viewportX = windowPos.x; + runtimeRepository->viewportY = windowPos.y; - repo.isFocused = ImGui::IsWindowHovered(); - repo.forwardPressed = ImGui::IsKeyDown(ImGuiKey_W); - repo.backwardPressed = ImGui::IsKeyDown(ImGuiKey_S); - repo.leftPressed = ImGui::IsKeyDown(ImGuiKey_A); - repo.rightPressed = ImGui::IsKeyDown(ImGuiKey_D); - repo.upPressed = ImGui::IsKeyDown(ImGuiKey_Space); - repo.downPressed = ImGui::IsKeyDown(ImGuiKey_LeftCtrl); - repo.mousePressed = ImGui::IsWindowFocused() && ImGui::IsWindowHovered() && ImGui::IsMouseDown( + runtimeRepository->isFocused = ImGui::IsWindowHovered(); + runtimeRepository->forwardPressed = ImGui::IsKeyDown(ImGuiKey_W); + runtimeRepository->backwardPressed = ImGui::IsKeyDown(ImGuiKey_S); + runtimeRepository->leftPressed = ImGui::IsKeyDown(ImGuiKey_A); + runtimeRepository->rightPressed = ImGui::IsKeyDown(ImGuiKey_D); + runtimeRepository->upPressed = ImGui::IsKeyDown(ImGuiKey_Space); + runtimeRepository->downPressed = ImGui::IsKeyDown(ImGuiKey_LeftCtrl); + runtimeRepository->mousePressed = ImGui::IsWindowFocused() && ImGui::IsWindowHovered() && ImGui::IsMouseDown( ImGuiMouseButton_Left); const ImVec2 mousePos = ImGui::GetMousePos(); - repo.mouseX = mousePos.x; - repo.mouseY = mousePos.y; + runtimeRepository->mouseX = mousePos.x; + runtimeRepository->mouseY = mousePos.y; - repo.normalizedMouseX = (repo.mouseX + repo.viewportX) / repo.viewportW; - repo.normalizedMouseY = (repo.viewportH - repo.mouseY + repo.viewportY) / repo.viewportH; + runtimeRepository->normalizedMouseX = (runtimeRepository->mouseX + runtimeRepository->viewportX) / runtimeRepository->viewportW; + runtimeRepository->normalizedMouseY = (runtimeRepository->viewportH - runtimeRepository->mouseY + runtimeRepository->viewportY) / runtimeRepository->viewportH; } } diff --git a/src/editor/dock-spaces/viewport/ViewportPanel.h b/src/editor/dock-spaces/viewport/ViewportPanel.h index 0cc24af5..343cded0 100644 --- a/src/editor/dock-spaces/viewport/ViewportPanel.h +++ b/src/editor/dock-spaces/viewport/ViewportPanel.h @@ -4,6 +4,14 @@ #include "../docks/AbstractDockPanel.h" namespace Metal { + class CameraService; + class SelectionService; + struct EditorRepository; + struct WorldRepository; + struct RuntimeRepository; + class EngineContext; + struct DirectoryService; + class ViewportPanel final : public AbstractDockPanel { bool isFirstMovement = false; AbstractPanel *headerPanel = nullptr; @@ -11,7 +19,27 @@ namespace Metal { AbstractPanel *cameraPanel = nullptr; AbstractPanel *engineFramePanel = nullptr; + CameraService *cameraService = nullptr; + SelectionService *selectionService = nullptr; + EditorRepository *editorRepository = nullptr; + WorldRepository *worldRepository = nullptr; + RuntimeRepository *runtimeRepository = nullptr; + EngineContext *engineContext = nullptr; + DirectoryService *directoryService = nullptr; + public: + std::vector getDependencies() override { + return { + {"CameraService", cameraService}, + {"SelectionService", selectionService}, + {"EditorRepository", editorRepository}, + {"WorldRepository", worldRepository}, + {"RuntimeRepository", runtimeRepository}, + {"EngineContext", engineContext}, + {"DirectoryService", directoryService} + }; + } + void onInitialize() override; void onSync() override; diff --git a/src/editor/dock-spaces/world/WorldHeaderPanel.cpp b/src/editor/dock-spaces/world/WorldHeaderPanel.cpp index f263fb2c..fba2b9f4 100644 --- a/src/editor/dock-spaces/world/WorldHeaderPanel.cpp +++ b/src/editor/dock-spaces/world/WorldHeaderPanel.cpp @@ -1,8 +1,8 @@ #include "WorldHeaderPanel.h" - #include "../../../ApplicationContext.h" #include "../../util/UIUtil.h" #include "../../../engine/enum/ComponentType.h" +#include "../../../engine/repository/WorldRepository.h" namespace Metal { void WorldHeaderPanel::onSync() { @@ -28,7 +28,7 @@ namespace Metal { ImGui::SameLine(); if (UIUtil::ButtonSimple(Icons::add + "##hierarchyAdd" + id, UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE)) { - applicationContext->worldRepository.createEntity(); + worldRepository->createEntity(); } UIUtil::RenderTooltip("Create entity"); } diff --git a/src/editor/dock-spaces/world/WorldHeaderPanel.h b/src/editor/dock-spaces/world/WorldHeaderPanel.h index 1e9f025a..c89b5e4d 100644 --- a/src/editor/dock-spaces/world/WorldHeaderPanel.h +++ b/src/editor/dock-spaces/world/WorldHeaderPanel.h @@ -3,8 +3,18 @@ #include "../../abstract/AbstractPanel.h" namespace Metal { + struct WorldRepository; + class WorldHeaderPanel final : public AbstractPanel { + WorldRepository *worldRepository = nullptr; + public: + std::vector getDependencies() override { + return { + {"WorldRepository", worldRepository} + }; + } + void onSync() override; char search[512]; diff --git a/src/editor/dock-spaces/world/WorldPanel.cpp b/src/editor/dock-spaces/world/WorldPanel.cpp index dfa7c336..ab177ffd 100644 --- a/src/editor/dock-spaces/world/WorldPanel.cpp +++ b/src/editor/dock-spaces/world/WorldPanel.cpp @@ -1,26 +1,27 @@ #include "WorldPanel.h" - #include "WorldHeaderPanel.h" #include "../../../common/Icons.h" #include "../../util/UIUtil.h" #include "../../../ApplicationContext.h" #include "../../../engine/dto/MetadataComponent.h" #include "../../../engine/enum/ComponentType.h" +#include "../../../engine/repository/WorldRepository.h" +#include "../../repository/EditorRepository.h" +#include "../../service/SelectionService.h" +#include "../../../core/DirectoryService.h" namespace Metal { void WorldPanel::onInitialize() { appendChild(headerPanel = new WorldHeaderPanel()); - world = &applicationContext->worldRepository; - editorRepository = &applicationContext->editorRepository; shortcuts = { ShortcutDTO("Delete", ImGuiKey_Delete, [this]() { std::vector entities; - for (auto &entry: applicationContext->editorRepository.selected) { + for (auto &entry: editorRepository->selected) { entities.push_back(entry.first); } - applicationContext->worldRepository.deleteEntities(entities); - applicationContext->selectionService.clearSelection(); + world->deleteEntities(entities); + selectionService->clearSelection(); }), ShortcutDTO("Select All", ImGuiMod_Ctrl | ImGuiKey_A, [this]() { std::vector entities; @@ -29,10 +30,10 @@ namespace Metal { entities.push_back(entity); } } - applicationContext->selectionService.addAllSelected(entities); + selectionService->addAllSelected(entities); }), ShortcutDTO("Save", ImGuiMod_Ctrl | ImGuiKey_S, [this] { - applicationContext->save(); + directoryService->save(); }), }; } @@ -41,11 +42,11 @@ namespace Metal { if (ImGui::BeginPopupContextItem((id + "contextMenu").c_str())) { if (ImGui::MenuItem("Delete")) { std::vector entities; - for (auto &entry: applicationContext->editorRepository.selected) { + for (auto &entry: editorRepository->selected) { entities.push_back(entry.first); } - applicationContext->worldRepository.deleteEntities(entities); - applicationContext->selectionService.clearSelection(); + world->deleteEntities(entities); + selectionService->clearSelection(); } ImGui::EndPopup(); } @@ -73,7 +74,7 @@ namespace Metal { ImGui::EndTable(); } - if (!applicationContext->editorRepository.selected.empty()) { + if (!editorRepository->selected.empty()) { contextMenu(); } } @@ -172,7 +173,7 @@ namespace Metal { const bool isVisible = !world->hiddenEntities.contains(entityId); if (UIUtil::ButtonSimple((isVisible ? Icons::visibility : Icons::visibility_off) + ("##v") + std::to_string(static_cast(entt::to_integral(entityId))) + id, 20, 15)) { - applicationContext->worldRepository.changeVisibility(entityId, !isVisible); + world->changeVisibility(entityId, !isVisible); } ImGui::PopStyleColor(); ImGui::PopStyleVar(2); @@ -182,9 +183,9 @@ namespace Metal { void WorldPanel::handleClick(const entt::entity entityId) const { if (ImGui::IsItemClicked()) { if (const bool isMultiSelect = ImGui::IsKeyDown(ImGuiKey_LeftCtrl); !isMultiSelect) { - applicationContext->selectionService.clearSelection(); + selectionService->clearSelection(); } - applicationContext->selectionService.addSelected(entityId); + selectionService->addSelected(entityId); } } diff --git a/src/editor/dock-spaces/world/WorldPanel.h b/src/editor/dock-spaces/world/WorldPanel.h index 920c7f70..dabf837e 100644 --- a/src/editor/dock-spaces/world/WorldPanel.h +++ b/src/editor/dock-spaces/world/WorldPanel.h @@ -13,6 +13,8 @@ namespace Metal { struct AbstractComponent; struct MetadataComponent; class WorldHeaderPanel; + class SelectionService; + struct DirectoryService; class WorldPanel final : public AbstractDockPanel { static constexpr auto TRANSPARENT = ImVec4(0, 0, 0, 0); @@ -26,7 +28,19 @@ namespace Metal { EditorRepository *editorRepository = nullptr; bool isSomethingHovered = false; + SelectionService *selectionService = nullptr; + DirectoryService *directoryService = nullptr; + public: + std::vector getDependencies() override { + return { + {"WorldRepository", world}, + {"EditorRepository", editorRepository}, + {"SelectionService", selectionService}, + {"DirectoryService", directoryService} + }; + } + void onInitialize() override; void contextMenu() const; diff --git a/src/editor/enum/engine-definitions.h b/src/editor/enum/engine-definitions.h index b3496556..a92a1a39 100644 --- a/src/editor/enum/engine-definitions.h +++ b/src/editor/enum/engine-definitions.h @@ -6,6 +6,7 @@ #define MAX_LIGHTS 300 #define MAX_MESH_INSTANCES 1000 #define EMPTY_ENTITY entt::null +#define LARGE_FONT_SIZE 38 #define FILE_METADATA ".mjson" #define FILE_SCENE "-scene" diff --git a/src/editor/panel/FileImportModalPanel.cpp b/src/editor/panel/FileImportModalPanel.cpp index 15b233df..e52c06ca 100644 --- a/src/editor/panel/FileImportModalPanel.cpp +++ b/src/editor/panel/FileImportModalPanel.cpp @@ -1,10 +1,14 @@ #include "FileImportModalPanel.h" - #include #include #include "../../ApplicationContext.h" #include "../../common/FilesUtil.h" #include "../abstract/form/FormPanel.h" +#include "../repository/EditorRepository.h" +#include "../service/FileImporterService.h" +#include "../service/NotificationService.h" +#include "../service/FilesService.h" +#include "../dto/FSEntry.h" namespace Metal { void FileImportModalPanel::onInitialize() { @@ -13,15 +17,14 @@ namespace Metal { } void FileImportModalPanel::onSync() { - auto &editorRepository = applicationContext->editorRepository; - if (editorRepository.pendingImports.empty()) { + if (editorRepository->pendingImports.empty()) { isFirst = true; return; } if (isFirst) { formPanel->setInspection( - editorRepository.importSettingsMap.at(editorRepository.selectedFileForSettings).get()); + editorRepository->importSettingsMap.at(editorRepository->selectedFileForSettings).get()); isFirst = false; } @@ -50,16 +53,16 @@ namespace Metal { ImGui::TableSetupColumn("Size", ImGuiTableColumnFlags_WidthFixed, 80.0f); ImGui::TableHeadersRow(); - for (const auto &filePath: editorRepository.pendingImports) { + for (const auto &filePath: editorRepository->pendingImports) { std::filesystem::path p(filePath); ImGui::TableNextRow(); ImGui::TableNextColumn(); - bool isSelected = (editorRepository.selectedFileForSettings == filePath); + bool isSelected = (editorRepository->selectedFileForSettings == filePath); if (ImGui::Selectable(p.filename().string().c_str(), isSelected, ImGuiSelectableFlags_SpanAllColumns)) { - editorRepository.selectedFileForSettings = filePath; + editorRepository->selectedFileForSettings = filePath; formPanel->setInspection( - editorRepository.importSettingsMap.at(editorRepository.selectedFileForSettings). + editorRepository->importSettingsMap.at(editorRepository->selectedFileForSettings). get()); } ImGui::TableNextColumn(); @@ -76,7 +79,7 @@ namespace Metal { ImGui::TableNextColumn(); ImGui::Text("Settings: %s", - std::filesystem::path(editorRepository.selectedFileForSettings).filename().string(). + std::filesystem::path(editorRepository->selectedFileForSettings).filename().string(). c_str()); ImGui::BeginChild((id + "SettingsFormChild").c_str(), ImVec2(0, maxHeight - 180.0f), true); formPanel->onSync(); @@ -90,20 +93,20 @@ namespace Metal { ImGui::Spacing(); if (ImGui::Button(("Approve" + id + "approveImport").c_str(), ImVec2(120, 0))) { - for (const std::string &file: editorRepository.pendingImports) { - applicationContext->fileImporterService.importFile(editorRepository.targetImportDirectory->absolutePath, file, - editorRepository.importSettingsMap.at(file)); + for (const std::string &file: editorRepository->pendingImports) { + fileImporterService->importFile(editorRepository->targetImportDirectory->absolutePath, file, + editorRepository->importSettingsMap.at(file)); } - applicationContext->notificationService.pushMessage("Importing files...", NotificationSeverities::WARNING); - FilesService::GetEntries(editorRepository.targetImportDirectory); - editorRepository.pendingImports.clear(); - editorRepository.importSettingsMap.clear(); + notificationService->pushMessage("Importing files...", NotificationSeverities::WARNING); + filesService->GetEntries(editorRepository->targetImportDirectory); + editorRepository->pendingImports.clear(); + editorRepository->importSettingsMap.clear(); formPanel->resetForm(); } ImGui::SameLine(); if (ImGui::Button(("Cancel" + id + "cancel").c_str(), ImVec2(120, 0))) { - editorRepository.pendingImports.clear(); - editorRepository.importSettingsMap.clear(); + editorRepository->pendingImports.clear(); + editorRepository->importSettingsMap.clear(); formPanel->resetForm(); } } diff --git a/src/editor/panel/FileImportModalPanel.h b/src/editor/panel/FileImportModalPanel.h index 03f26316..89c0849b 100644 --- a/src/editor/panel/FileImportModalPanel.h +++ b/src/editor/panel/FileImportModalPanel.h @@ -4,12 +4,27 @@ namespace Metal { class FormPanel; + struct EditorRepository; + class FileImporterService; + class NotificationService; class FileImportModalPanel final : public AbstractPanel { FormPanel *formPanel = nullptr; bool isFirst = false; + EditorRepository *editorRepository = nullptr; + FileImporterService *fileImporterService = nullptr; + NotificationService *notificationService = nullptr; + public: + std::vector getDependencies() override { + return { + {"EditorRepository", editorRepository}, + {"FileImporterService", fileImporterService}, + {"NotificationService", notificationService} + }; + } + void onInitialize() override; void onSync() override; diff --git a/src/editor/panel/NotificationsPanel.cpp b/src/editor/panel/NotificationsPanel.cpp index 6b5c8dc0..8e954514 100644 --- a/src/editor/panel/NotificationsPanel.cpp +++ b/src/editor/panel/NotificationsPanel.cpp @@ -3,21 +3,23 @@ #include "../../ApplicationContext.h" #include "../util/UIUtil.h" #include "../dto/Notification.h" +#include "../service/NotificationService.h" +#include "../../engine/EngineContext.h" namespace Metal { void NotificationsPanel::onSync() { int usedIndices = 0; - for (int i = 0; i < applicationContext->notificationService.getNotifications().size(); i++) { - auto *notification = applicationContext->notificationService.getNotifications()[i]; + for (int i = 0; i < notificationService->getNotifications().size(); i++) { + auto *notification = notificationService->getNotifications()[i]; if (notification == nullptr) { continue; } if (notification->displayTime < 0) { - notification->displayTime = applicationContext->engineContext.currentTimeMs; + notification->displayTime = engineContext->currentTimeMs; } - if (applicationContext->engineContext.currentTimeMs - notification->displayTime > MESSAGE_DURATION) { + if (engineContext->currentTimeMs - notification->displayTime > MESSAGE_DURATION) { delete notification; - applicationContext->notificationService.getNotifications()[i] = nullptr; + notificationService->getNotifications()[i] = nullptr; continue; } ImGui::SetNextWindowPos(ImVec2(5, ImGui::GetMainViewport()->Size.y - 40 * (usedIndices + 1))); diff --git a/src/editor/panel/NotificationsPanel.h b/src/editor/panel/NotificationsPanel.h index 2018f3c0..eae1b8e7 100644 --- a/src/editor/panel/NotificationsPanel.h +++ b/src/editor/panel/NotificationsPanel.h @@ -3,8 +3,21 @@ #include "../abstract/AbstractPanel.h" namespace Metal { + class NotificationService; + class EngineContext; + class NotificationsPanel final : public AbstractPanel { + NotificationService *notificationService = nullptr; + EngineContext *engineContext = nullptr; + public: + std::vector getDependencies() override { + return { + {"NotificationService", notificationService}, + {"EngineContext", engineContext} + }; + } + void onSync() override; }; } // Metal diff --git a/src/editor/passes/GridPass.cpp b/src/editor/passes/GridPass.cpp index 365aaef8..3dfcc2a9 100644 --- a/src/editor/passes/GridPass.cpp +++ b/src/editor/passes/GridPass.cpp @@ -1,7 +1,8 @@ #include "GridPass.h" - #include "../../ApplicationContext.h" #include "../../engine/dto/PipelineBuilder.h" +#include "../../engine/service/PipelineService.h" +#include "../repository/EditorRepository.h" #include "../enum/EngineResourceIDs.h" namespace Metal { @@ -15,18 +16,18 @@ namespace Metal { .setPushConstantsSize(sizeof(GridPushConstant)) .addBufferBinding(getScopedResourceId(RID_GLOBAL_DATA)) .addStorageImageBinding(getScopedResourceId(RID_GBUFFER_POSITION_INDEX)); - pipelineInstance = CTX.pipelineService.createPipeline(gridPipelineBuilder); + pipelineInstance = pipelineService->createPipeline(gridPipelineBuilder); } bool GridPass::shouldRun() { - return CTX.isDebugMode() && CTX.editorRepository.showGrid; + return applicationContext->isDebugMode() && editorRepository->showGrid; } void GridPass::onSync() { - pushConstant.scale = CTX.editorRepository.gridScale; - pushConstant.overlayObjects = CTX.editorRepository.gridOverlayObjects; - pushConstant.threshold = CTX.editorRepository.gridThreshold; - pushConstant.thickness = CTX.editorRepository.gridThickness; + pushConstant.scale = editorRepository->gridScale; + pushConstant.overlayObjects = editorRepository->gridOverlayObjects; + pushConstant.threshold = editorRepository->gridThreshold; + pushConstant.thickness = editorRepository->gridThickness; recordPushConstant(&pushConstant); recordDrawSimpleInstanced(3, 1); } diff --git a/src/editor/passes/GridPass.h b/src/editor/passes/GridPass.h index ff77ef29..93342511 100644 --- a/src/editor/passes/GridPass.h +++ b/src/editor/passes/GridPass.h @@ -4,10 +4,26 @@ #include "../dto/GridPushConstant.h" namespace Metal { + class PipelineService; + class ApplicationContext; + struct EditorRepository; + class GridPass final : public AbstractRenderPass { GridPushConstant pushConstant{}; + PipelineService *pipelineService = nullptr; + ApplicationContext *applicationContext = nullptr; + EditorRepository *editorRepository = nullptr; + public: + std::vector getDependencies() override { + return { + {"PipelineService", pipelineService}, + {"ApplicationContext", applicationContext}, + {"EditorRepository", editorRepository} + }; + } + void onInitialize() override; bool shouldRun() override; diff --git a/src/editor/passes/SelectionIDPass.cpp b/src/editor/passes/SelectionIDPass.cpp index 939f0626..9a917ae0 100644 --- a/src/editor/passes/SelectionIDPass.cpp +++ b/src/editor/passes/SelectionIDPass.cpp @@ -1,9 +1,12 @@ #include "SelectionIDPass.h" - -#include "../../ApplicationContext.h" #include "../../engine/dto/TransformComponent.h" +#include "../../engine/dto/PrimitiveComponent.h" #include "../dto/SelectedDotPushConstant.h" #include "../../engine/dto/PipelineBuilder.h" +#include "../../engine/service/PipelineService.h" +#include "../repository/EditorRepository.h" +#include "../../engine/repository/WorldRepository.h" +#include "../../engine/service/MeshService.h" #include "../enum/EngineResourceIDs.h" namespace Metal { @@ -17,38 +20,37 @@ namespace Metal { .setCullMode(VK_CULL_MODE_NONE) .setPushConstantsSize(sizeof(SelectedDotPushConstant)) .addBufferBinding(getScopedResourceId(RID_GLOBAL_DATA)); - pipelineInstance = CTX.pipelineService.createPipeline(builder); + pipelineInstance = pipelineService->createPipeline(builder); } bool SelectionIDPass::shouldRun() { - return !CTX.editorRepository.selected.empty(); + return !editorRepository->selected.empty(); } void SelectionIDPass::onSync() { - auto &worldRepository = CTX.worldRepository; - for (auto const& [entityId, selected] : CTX.editorRepository.selected) { + for (auto const& [entityId, selected] : editorRepository->selected) { if (!selected) { continue; } - if (!worldRepository.registry.all_of(entityId) || !worldRepository.registry.all_of(entityId)) { + if (!worldRepository->registry.all_of(entityId) || !worldRepository->registry.all_of(entityId)) { continue; } - const auto &mesh = worldRepository.registry.get(entityId); + const auto &mesh = worldRepository->registry.get(entityId); if (mesh.meshId.empty()) { continue; } - if (worldRepository.hiddenEntities.contains(entityId)) { + if (worldRepository->hiddenEntities.contains(entityId)) { continue; } - const auto *meshInstance = CTX.meshService.stream(mesh.meshId); + const auto *meshInstance = meshService->stream(mesh.meshId); if (!meshInstance) { continue; } - pushConstant.model = worldRepository.registry.get(entityId).model; - pushConstant.selectionColor = glm::vec4(CTX.editorRepository.selectionColor, CTX.editorRepository.selectionOutlineThickness); + pushConstant.model = worldRepository->registry.get(entityId).model; + pushConstant.selectionColor = glm::vec4(editorRepository->selectionColor, editorRepository->selectionOutlineThickness); pushConstant.renderIndex = mesh.renderIndex; recordPushConstant(&pushConstant); diff --git a/src/editor/passes/SelectionIDPass.h b/src/editor/passes/SelectionIDPass.h index fe0aac3a..9a972cd2 100644 --- a/src/editor/passes/SelectionIDPass.h +++ b/src/editor/passes/SelectionIDPass.h @@ -5,10 +5,28 @@ #include "../dto/SelectedDotPushConstant.h" namespace Metal { + class PipelineService; + struct EditorRepository; + struct WorldRepository; + class MeshService; + class SelectionIDPass final : public AbstractRenderPass { SelectedDotPushConstant pushConstant{}; + PipelineService *pipelineService = nullptr; + EditorRepository *editorRepository = nullptr; + WorldRepository *worldRepository = nullptr; + MeshService *meshService = nullptr; + public: + std::vector getDependencies() override { + return { + {"PipelineService", pipelineService}, + {"EditorRepository", editorRepository}, + {"WorldRepository", worldRepository}, + {"MeshService", meshService} + }; + } void onInitialize() override; diff --git a/src/editor/passes/SelectionOutlinePass.cpp b/src/editor/passes/SelectionOutlinePass.cpp index d3e542ca..f44c9289 100644 --- a/src/editor/passes/SelectionOutlinePass.cpp +++ b/src/editor/passes/SelectionOutlinePass.cpp @@ -1,9 +1,10 @@ #include "SelectionOutlinePass.h" - #include "../../ApplicationContext.h" #include "../../engine/dto/TransformComponent.h" #include "../dto/SelectedDotPushConstant.h" #include "../../engine/dto/PipelineBuilder.h" +#include "../../engine/service/PipelineService.h" +#include "../repository/EditorRepository.h" #include "../enum/EngineResourceIDs.h" namespace Metal { @@ -17,19 +18,19 @@ namespace Metal { .setPushConstantsSize(sizeof(SelectedDotPushConstant)) .addBufferBinding(getScopedResourceId(RID_GLOBAL_DATA)) .addFboBinding(getScopedResourceId(RID_SELECTION_FBO), 0); - pipelineInstance = CTX.pipelineService.createPipeline(builder); + pipelineInstance = pipelineService->createPipeline(builder); } bool SelectionOutlinePass::shouldRun() { - return !CTX.editorRepository.selected.empty(); + return !editorRepository->selected.empty(); } void SelectionOutlinePass::onSync() { - pushConstant.selectionColor.x = CTX.editorRepository.selectionColor.x; - pushConstant.selectionColor.y = CTX.editorRepository.selectionColor.y; - pushConstant.selectionColor.z = CTX.editorRepository.selectionColor.z; - pushConstant.selectionColor.w = CTX.editorRepository.selectionOutlineThickness; + pushConstant.selectionColor.x = editorRepository->selectionColor.x; + pushConstant.selectionColor.y = editorRepository->selectionColor.y; + pushConstant.selectionColor.z = editorRepository->selectionColor.z; + pushConstant.selectionColor.w = editorRepository->selectionOutlineThickness; recordPushConstant(&pushConstant); recordDrawSimpleInstanced(3, 1); diff --git a/src/editor/passes/SelectionOutlinePass.h b/src/editor/passes/SelectionOutlinePass.h index 60860a7a..3d036e68 100644 --- a/src/editor/passes/SelectionOutlinePass.h +++ b/src/editor/passes/SelectionOutlinePass.h @@ -5,10 +5,23 @@ #include "../dto/SelectedDotPushConstant.h" namespace Metal { + class PipelineService; + struct EditorRepository; + class SelectionOutlinePass final : public AbstractRenderPass { SelectedDotPushConstant pushConstant{}; + PipelineService *pipelineService = nullptr; + EditorRepository *editorRepository = nullptr; + public: + std::vector getDependencies() override { + return { + {"PipelineService", pipelineService}, + {"EditorRepository", editorRepository} + }; + } + void onInitialize() override; bool shouldRun() override; diff --git a/src/editor/service/DockService.cpp b/src/editor/service/DockService.cpp index 2a5b821f..6113369e 100644 --- a/src/editor/service/DockService.cpp +++ b/src/editor/service/DockService.cpp @@ -8,7 +8,7 @@ #include "../../ApplicationContext.h" namespace Metal { - DockService::DockService() { + void DockService::onInitialize() { auto *rightT = new DockDTO{&DockSpace::WORLD}; auto *leftTop = new DockDTO{&DockSpace::REPOSITORIES}; auto *leftDown = new DockDTO{&DockSpace::INSPECTOR}; @@ -30,14 +30,14 @@ namespace Metal { bottom.push_back(downRight); } - void DockService::buildViews(ImGuiID windowId, AbstractPanel *panel) const { + void DockService::buildViews(ImGuiID windowId, AbstractPanel *panel) { if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable) { - if (dockRepository.isInitialized) { + if (isInitialized) { return; } - dockRepository.isInitialized = true; + isInitialized = true; - std::vector toKeep{}; + std::vector toKeep{}; for (auto *child: panel->getChildren()) { auto *p = dynamic_cast(child); if (p == nullptr) { @@ -58,7 +58,6 @@ namespace Metal { ImGui::DockBuilderAddNode(windowId, ImGuiDockNodeFlags_NoTabBar); ImGui::DockBuilderSetNodeSize(windowId, ImGui::GetMainViewport()->Size); - const auto &left = dockRepository.left; for (size_t i = 0; i < left.size(); i++) { DockDTO *dockSpace = left[i]; if (i == 0) { @@ -75,7 +74,6 @@ namespace Metal { addWindow(dockSpace, panel); } - const auto &right = dockRepository.right; for (size_t i = 0; i < right.size(); i++) { DockDTO *dockSpace = right[i]; if (i == 0) { @@ -92,7 +90,6 @@ namespace Metal { addWindow(dockSpace, panel); } - const auto &bottom = dockRepository.bottom; for (size_t i = 0, bottomSize = bottom.size(); i < bottomSize; i++) { DockDTO *dockSpace = bottom[i]; if (i == 0) { @@ -109,10 +106,10 @@ namespace Metal { addWindow(dockSpace, panel); } - dockRepository.center.nodeId = windowId; - addWindow(&dockRepository.center, panel); + center.nodeId = windowId; + addWindow(¢er, panel); - ImGui::DockBuilderDockWindow(dockRepository.center.internalId.c_str(), windowId); + ImGui::DockBuilderDockWindow(center.internalId.c_str(), windowId); ImGui::DockBuilderFinish(windowId); } } diff --git a/src/editor/service/DockService.h b/src/editor/service/DockService.h index 8fca6f13..c8b8de89 100644 --- a/src/editor/service/DockService.h +++ b/src/editor/service/DockService.h @@ -9,7 +9,7 @@ namespace Metal { class AbstractPanel; - class DockService final : public IService { + class DockService final : public IService, public IInit { DockDTO center{&DockSpace::VIEWPORT}; std::vector bottom; std::vector left; @@ -17,10 +17,11 @@ namespace Metal { bool isInitialized = false; + public: - explicit DockService(); + void onInitialize() override; - void buildViews(ImGuiID windowId, AbstractPanel *panel) const; + void buildViews(ImGuiID windowId, AbstractPanel *panel); static void createDockSpace(DockDTO *dockSpace, ImGuiID *dockMainId); diff --git a/src/editor/service/FilesService.cpp b/src/editor/service/FilesService.cpp index 78bc1b36..5b59131f 100644 --- a/src/editor/service/FilesService.cpp +++ b/src/editor/service/FilesService.cpp @@ -11,6 +11,7 @@ #include #include #include "../../common/serialization-definitions.h" +#include "../../core/DirectoryService.h" namespace fs = std::filesystem; @@ -26,14 +27,14 @@ std::filesystem::remove_all(rootDir + "/assets/" + F(entry.second->getId())); std::filesystem::file_time_type ftime = last_write_time(entry); namespace Metal { - void FilesService::onInitialize() { - root = new FSEntry(nullptr, rootDirectory + "/assets-ref/", ""); + void filesService->onInitialize() { + root = new FSEntry(nullptr, directoryService->getAssetRefDirectory(), ""); root->type = EntryType::DIRECTORY; root->name = "Files"; GetEntries(root); } - std::unique_ptr FilesService::getResource(const std::string &id) { + std::unique_ptr filesService->getResource(const std::string &id) { try { for (const auto &entry: fs::recursive_directory_iterator(root->absolutePath)) { if (entry.is_regular_file() && @@ -56,11 +57,11 @@ namespace Metal { return nullptr; } - void FilesService::deleteFiles(const std::unordered_map &selected) { + void filesService->deleteFiles(const std::unordered_map &selected) { for (auto &entry: selected) { switch (entry.second->type) { case EntryType::DIRECTORY: { - FilesService::GetEntries(entry.second); + GetEntries(entry.second); std::unordered_map files; for (auto *f: entry.second->children) { files.insert({f->getId(), f}); @@ -70,19 +71,19 @@ namespace Metal { break; } case EntryType::MESH: { - DELETE_F(FORMAT_FILE_MESH, rootDirectory) + DELETE_F(FORMAT_FILE_MESH, directoryService->getRootDirectory()) break; } case EntryType::TEXTURE: { - DELETE_F(FORMAT_FILE_TEXTURE, rootDirectory) + DELETE_F(FORMAT_FILE_TEXTURE, directoryService->getRootDirectory()) break; } case EntryType::SCENE: { - DELETE_S(FORMAT_FILE_SCENE, rootDirectory) + DELETE_S(FORMAT_FILE_SCENE, directoryService->getRootDirectory()) break; } case EntryType::VOLUME: { - DELETE_S(FORMAT_FILE_VOLUME, rootDirectory) + DELETE_S(FORMAT_FILE_VOLUME, directoryService->getRootDirectory()) break; } default: break;; @@ -90,7 +91,7 @@ namespace Metal { } } - void FilesService::CreateDirectory(FSEntry *currentDirectory) { + void filesService->CreateDirectory(FSEntry *currentDirectory) { int count = 0; for (FSEntry *child: currentDirectory->children) { if (child->type == EntryType::DIRECTORY && child->name == "New Directory (" + std::to_string(count) + ")") { @@ -104,7 +105,7 @@ namespace Metal { std::filesystem::create_directory(pathToDir); } - void FilesService::Move(FSEntry *toMove, FSEntry *targetDir) { + void filesService->Move(FSEntry *toMove, FSEntry *targetDir) { if (!targetDir || targetDir->type != EntryType::DIRECTORY) { return; } @@ -116,7 +117,7 @@ namespace Metal { fs::rename(sourcePath, targetPath); } catch (const fs::filesystem_error &e) { LOG_ERROR("Could not move file"); - notificationService.pushMessage("Could not move entry", NotificationSeverities::ERROR); + notificationService->pushMessage("Could not move entry", NotificationSeverities::ERROR); return; } @@ -132,7 +133,7 @@ namespace Metal { targetDir->children.push_back(toMove); } - void FilesService::GetEntries(FSEntry *root) { + void filesService->GetEntries(FSEntry *root) { if (root->type != EntryType::DIRECTORY) { return; } diff --git a/src/editor/service/FilesService.h b/src/editor/service/FilesService.h index 3ecca1a4..cdefef5a 100644 --- a/src/editor/service/FilesService.h +++ b/src/editor/service/FilesService.h @@ -35,9 +35,9 @@ namespace Metal { void Move(FSEntry *toMove, FSEntry *targetDir); - static void CreateDirectory(FSEntry *currentDirectory); + void CreateDirectory(FSEntry *currentDirectory); - static void GetEntries(FSEntry *root); + void GetEntries(FSEntry *root); }; } // Metal diff --git a/src/editor/service/ThemeService.cpp b/src/editor/service/ThemeService.cpp index 993a6c9c..d508d959 100644 --- a/src/editor/service/ThemeService.cpp +++ b/src/editor/service/ThemeService.cpp @@ -1,21 +1,23 @@ #include "ThemeService.h" -#include "../../ApplicationContext.h" +#include + +#include "../repository/EditorRepository.h" namespace Metal { glm::vec3 ThemeService::BACKGROUND_COLOR = glm::vec3(0.f); void ThemeService::onSync() { - if (previousTheme == editorRepository.isDarkMode && glm::length(editorRepository.accentColor) == prevLength) { + if (previousTheme == editorRepository->isDarkMode && glm::length(editorRepository->accentColor) == prevLength) { return; } - prevLength = glm::length(editorRepository.accentColor); - previousTheme = editorRepository.isDarkMode; + prevLength = glm::length(editorRepository->accentColor); + previousTheme = editorRepository->isDarkMode; ImGuiStyle &style = ImGui::GetStyle(); auto &colors = style.Colors; - if (!editorRepository.isDarkMode) { + if (!editorRepository->isDarkMode) { ImGui::StyleColorsLight(); setLightMode(); } else { @@ -60,24 +62,24 @@ namespace Metal { colors[ImGuiCol_NavWindowingDimBg] = palette2; colors[ImGuiCol_ModalWindowDimBg] = palette2; - editorRepository.accent.y = editorRepository.accentColor.y; - editorRepository.accent.z = editorRepository.accentColor.z; - editorRepository.accent.x = editorRepository.accentColor.x; - editorRepository.accent.w = 1; - editorRepository.accentU32 = ImGui::GetColorU32(editorRepository.accent); + editorRepository->accent.y = editorRepository->accentColor.y; + editorRepository->accent.z = editorRepository->accentColor.z; + editorRepository->accent.x = editorRepository->accentColor.x; + editorRepository->accent.w = 1; + editorRepository->accentU32 = ImGui::GetColorU32(editorRepository->accent); - colors[ImGuiCol_FrameBgHovered] = editorRepository.accent; - colors[ImGuiCol_FrameBgActive] = editorRepository.accent; - colors[ImGuiCol_CheckMark] = editorRepository.accent; - colors[ImGuiCol_SliderGrabActive] = editorRepository.accent; + colors[ImGuiCol_FrameBgHovered] = editorRepository->accent; + colors[ImGuiCol_FrameBgActive] = editorRepository->accent; + colors[ImGuiCol_CheckMark] = editorRepository->accent; + colors[ImGuiCol_SliderGrabActive] = editorRepository->accent; colors[ImGuiCol_Button] = palette3; - colors[ImGuiCol_ButtonHovered] = editorRepository.accent; - colors[ImGuiCol_Header] = editorRepository.accent; - colors[ImGuiCol_HeaderHovered] = editorRepository.accent; - colors[ImGuiCol_HeaderActive] = editorRepository.accent; - colors[ImGuiCol_ResizeGripHovered] = editorRepository.accent; - colors[ImGuiCol_ResizeGripActive] = editorRepository.accent; - colors[ImGuiCol_TextSelectedBg] = editorRepository.accent; + colors[ImGuiCol_ButtonHovered] = editorRepository->accent; + colors[ImGuiCol_Header] = editorRepository->accent; + colors[ImGuiCol_HeaderHovered] = editorRepository->accent; + colors[ImGuiCol_HeaderActive] = editorRepository->accent; + colors[ImGuiCol_ResizeGripHovered] = editorRepository->accent; + colors[ImGuiCol_ResizeGripActive] = editorRepository->accent; + colors[ImGuiCol_TextSelectedBg] = editorRepository->accent; BACKGROUND_COLOR[0] = colors[ImGuiCol_WindowBg].x; BACKGROUND_COLOR[1] = colors[ImGuiCol_WindowBg].y; diff --git a/src/engine/EngineContext.cpp b/src/engine/EngineContext.cpp index 23dcd9d2..ffdb7651 100644 --- a/src/engine/EngineContext.cpp +++ b/src/engine/EngineContext.cpp @@ -1,4 +1,6 @@ #include "EngineContext.h" + +#include "../ApplicationContext.h" #include "service/TransformService.h" #include "service/StreamingService.h" #include "service/RayTracingService.h" @@ -32,6 +34,22 @@ namespace Metal { } } + EngineFrameBuilder EngineContext::createFrame(const std::string &id) { + EngineFrameBuilder frameBuilder(id); + ctx->injectDependencies(&frameBuilder); + return frameBuilder; + } + + void EngineContext::setCurrentFrame(const std::string &id) { + for (auto *frame : registeredFrames) { + if (frame->getId() == id) { + currentFrame = frame; + return; + } + } + throw std::runtime_error("Frame not found"); + } + void EngineContext::dispose() { } diff --git a/src/engine/EngineContext.h b/src/engine/EngineContext.h index 127953c8..2e09a24e 100644 --- a/src/engine/EngineContext.h +++ b/src/engine/EngineContext.h @@ -1,7 +1,6 @@ #ifndef METAL_ENGINE_ENGINECONTEXT_H #define METAL_ENGINE_ENGINECONTEXT_H -#include "frame-builder/EngineFrame.h" #include #include @@ -9,6 +8,8 @@ #include "../common/IService.h" #include "../common/IDisposable.h" #include "../common/ISync.h" +#include "frame-builder/EngineFrame.h" +#include "frame-builder/EngineFrameBuilder.h" using Clock = std::chrono::high_resolution_clock; using TimePoint = std::chrono::time_point; @@ -23,6 +24,8 @@ namespace Metal { struct WorldRepository; struct EditorRepository; struct EngineRepository; + class EngineFrame; + class EngineFrameBuilder; class EngineContext final : public IService, public ISync, public IDisposable { TransformService *transformService = nullptr; @@ -77,6 +80,10 @@ namespace Metal { void updateCurrentTime(); + EngineFrameBuilder createFrame(const std::string &id); + + void setCurrentFrame(const std::string & id); + long long currentTimeMs = 0; TimePoint currentTime; TimePoint previousTime = Clock::now(); diff --git a/src/engine/enum/ComponentType.cpp b/src/engine/enum/ComponentType.cpp index 74fa1e67..14bed4bc 100644 --- a/src/engine/enum/ComponentType.cpp +++ b/src/engine/enum/ComponentType.cpp @@ -1,6 +1,13 @@ #include "ComponentType.h" + +#include "../EngineContext.h" #include "../repository/WorldRepository.h" +#include "../service/RayTracingService.h" #include "../../ApplicationContext.h" +#include "../dto/TransformComponent.h" +#include "../dto/PrimitiveComponent.h" +#include "../dto/VolumeComponent.h" +#include "../dto/MetadataComponent.h" #define DEFINE_COMPONENT(TYPE, NAME, JSON_KEY, ICON, DEPS, CLASS, CREATOR) \ { \ @@ -31,7 +38,7 @@ namespace Metal::ComponentTypes { [](WorldRepository &repo, entt::entity entityId) { auto &mesh = repo.registry.emplace_or_replace(entityId); mesh.setEntityId(entityId); - CTX.rayTracingService.markDirty(); + repo.rayTracingService->markDirty(); } ), DEFINE_COMPONENT( @@ -55,7 +62,7 @@ namespace Metal::ComponentTypes { [](WorldRepository &repo, entt::entity entityId) { auto &atmo = repo.registry.emplace_or_replace(entityId); atmo.setEntityId(entityId); - CTX.engineContext.setGISettingsUpdated(true); + repo.ctx->getSingleton().setGISettingsUpdated(true); } ) }; diff --git a/src/engine/enum/ComponentType.h b/src/engine/enum/ComponentType.h index 5cfc8fad..1b1350ad 100644 --- a/src/engine/enum/ComponentType.h +++ b/src/engine/enum/ComponentType.h @@ -7,6 +7,7 @@ #include namespace Metal { + class ApplicationContext; class Inspectable; struct WorldRepository; diff --git a/src/engine/frame-builder/EngineFrameBuilder.cpp b/src/engine/frame-builder/EngineFrameBuilder.cpp index e9295641..8d3359a8 100644 --- a/src/engine/frame-builder/EngineFrameBuilder.cpp +++ b/src/engine/frame-builder/EngineFrameBuilder.cpp @@ -7,6 +7,7 @@ #include "EngineFrame.h" #include "../../ApplicationContext.h" #include "../passes/CommandBufferRecorder.h" +#include "../EngineContext.h" namespace Metal { EngineFrameBuilder::EngineFrameBuilder(std::string frameId) : frameId(std::move(frameId)) { @@ -15,7 +16,7 @@ namespace Metal { EngineFrameBuilder &EngineFrameBuilder::addFramebuffer(std::string id, const unsigned w, const unsigned h, glm::vec4 clearColor) { currentBuilder = std::make_shared(frameId + "_" + id, w, h, clearColor); - builders.push_back(currentBuilder); + storeBuilder(); return *this; } @@ -38,7 +39,7 @@ namespace Metal { EngineFrameBuilder &EngineFrameBuilder::addTexture(const std::string &id, unsigned w, unsigned h, VkFormat format) { currentBuilder = std::make_shared(frameId + "_" + id, w, h, format); - builders.push_back(currentBuilder); + storeBuilder(); return *this; } @@ -56,7 +57,7 @@ namespace Metal { ? VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT : VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, properties, type); - builders.push_back(currentBuilder); + storeBuilder(); return *this; } @@ -71,13 +72,18 @@ namespace Metal { const bool clearBuffer) { currentBuilder = std::make_shared( frameId + "_" + id, frameId + "_" + framebufferId, clearBuffer); - builders.push_back(currentBuilder); + storeBuilder(); return *this; } + void EngineFrameBuilder::storeBuilder() { + ctx->injectDependencies(currentBuilder.get()); + builders.push_back(currentBuilder); + } + EngineFrameBuilder &EngineFrameBuilder::addComputeCommandBuffer(const std::string &id) { currentBuilder = std::make_shared(frameId + "_" + id); - builders.push_back(currentBuilder); + storeBuilder(); return *this; } @@ -97,8 +103,9 @@ namespace Metal { return false; } - std::unique_ptr EngineFrameBuilder::build() { - auto frame = std::make_unique(frameId); + void EngineFrameBuilder::build() { + auto *frame = new EngineFrame(frameId); + engineContext->registerFrame(frame); std::unordered_map builtResources; for (const auto &builder: builders) { @@ -108,23 +115,23 @@ namespace Metal { } } - std::unordered_map> > recorderToPasses; + std::unordered_map > > recorderToPasses; std::vector recorderOrder; for (auto &pass: passes) { recorderOrder.push_back(pass.commandBufferId); - pass.pass->frame = frame.get(); + pass.pass->frame = frame; + ctx->injectDependencies(pass.pass.get()); pass.pass->onInitialize(); recorderToPasses[pass.commandBufferId].push_back(std::move(pass.pass)); } for (const auto &cbId: recorderOrder) { - if (auto *recorder = dynamic_cast(builtResources.at(cbId))) { + if (auto *recorder = dynamic_cast(builtResources.at(cbId))) { frame->addPass(recorder, recorderToPasses[cbId]); } } - return frame; } } // Metal diff --git a/src/engine/frame-builder/EngineFrameBuilder.h b/src/engine/frame-builder/EngineFrameBuilder.h index 71ff3a60..e4b90114 100644 --- a/src/engine/frame-builder/EngineFrameBuilder.h +++ b/src/engine/frame-builder/EngineFrameBuilder.h @@ -1,16 +1,17 @@ #ifndef METAL_ENGINE_ENGINEFRAMEBUILDER_H #define METAL_ENGINE_ENGINEFRAMEBUILDER_H -#include #include #include #include #include #include +#include "../../common/IContextMember.h" #include "structures/ResourceBuilder.h" #include "../resource/BufferInstance.h" namespace Metal { + class EngineContext; class AbstractPass; class CommandBufferRecorder; struct FrameBufferInstance; @@ -23,14 +24,20 @@ namespace Metal { std::string commandBufferId; }; - class EngineFrameBuilder final { + class EngineFrameBuilder final : public IContextMember { std::string frameId; std::vector > builders{}; std::vector passes{}; std::shared_ptr currentBuilder{}; + EngineContext *engineContext = nullptr; public: + std::vector getDependencies() override { + return {{"EngineContext", engineContext}}; + } + explicit EngineFrameBuilder(std::string frameId = Util::uuidV4()); + EngineFrameBuilder &addFramebuffer(std::string id, unsigned w, unsigned h, glm::vec4 clearColor); EngineFrameBuilder &addFramebuffer(const std::string &id); @@ -39,7 +46,8 @@ namespace Metal { EngineFrameBuilder &addDepth(); - EngineFrameBuilder &addTexture(const std::string &id, unsigned w, unsigned h, VkFormat format = VK_FORMAT_R16G16B16A16_SFLOAT); + EngineFrameBuilder &addTexture(const std::string &id, unsigned w, unsigned h, + VkFormat format = VK_FORMAT_R16G16B16A16_SFLOAT); EngineFrameBuilder &addTexture(const std::string &id); @@ -48,7 +56,10 @@ namespace Metal { EngineFrameBuilder &addBuffer(const std::string &id); - EngineFrameBuilder &addCommandBuffer(const std::string &id, const std::string &framebufferId, bool clearBuffer = true); + EngineFrameBuilder &addCommandBuffer(const std::string &id, const std::string &framebufferId, + bool clearBuffer = true); + + void storeBuilder(); EngineFrameBuilder &addComputeCommandBuffer(const std::string &id); @@ -56,7 +67,7 @@ namespace Metal { bool tryMatch(const std::string &id, ResourceType type); - std::unique_ptr build(); + void build(); }; } // Metal diff --git a/src/engine/frame-builder/structures/BufferBuilder.cpp b/src/engine/frame-builder/structures/BufferBuilder.cpp index ce876357..950d8ee9 100644 --- a/src/engine/frame-builder/structures/BufferBuilder.cpp +++ b/src/engine/frame-builder/structures/BufferBuilder.cpp @@ -9,12 +9,12 @@ namespace Metal { } RuntimeResource *BufferBuilder::build() { - auto *buffer = CTX.bufferService.getResource(id); + auto *buffer = bufferService->getResource(id); if (buffer != nullptr) { return buffer; } - buffer = CTX.bufferService.createBuffer(id, size, usage, properties, type); + buffer = bufferService->createBuffer(id, size, usage, properties, type); buffer->setAsNoDisposal(); return buffer; diff --git a/src/engine/frame-builder/structures/BufferBuilder.h b/src/engine/frame-builder/structures/BufferBuilder.h index 740c9e69..60d18771 100644 --- a/src/engine/frame-builder/structures/BufferBuilder.h +++ b/src/engine/frame-builder/structures/BufferBuilder.h @@ -7,13 +7,20 @@ #include "../../resource/BufferInstance.h" namespace Metal { + class BufferService; + class BufferBuilder final : public ResourceBuilder { VkDeviceSize size; VkBufferUsageFlags usage; VkMemoryPropertyFlags properties; BufferType type; + BufferService *bufferService = nullptr; public: + std::vector getDependencies() override { + return {{"BufferService", bufferService}}; + } + explicit BufferBuilder(const std::string &id, VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, BufferType type) : ResourceBuilder(id), size(size), usage(usage), properties(properties), type(type) { diff --git a/src/engine/frame-builder/structures/CommandBufferRecorderBuilder.cpp b/src/engine/frame-builder/structures/CommandBufferRecorderBuilder.cpp index abb3db0f..ea77203c 100644 --- a/src/engine/frame-builder/structures/CommandBufferRecorderBuilder.cpp +++ b/src/engine/frame-builder/structures/CommandBufferRecorderBuilder.cpp @@ -1,12 +1,13 @@ #include "CommandBufferRecorderBuilder.h" -#include "../../../ApplicationContext.h" +#include "../../service/CommandBufferRecorderService.h" +#include "../../service/FrameBufferService.h" namespace Metal { RuntimeResource *CommandBufferRecorderBuilder::build() { if (computeMode) { - return CTX.commandBufferRecorderService.createCompute(id); + return commandBufferRecorderService->createCompute(id); } - auto *fbo = CTX.framebufferService.getResource(framebufferId); - return CTX.commandBufferRecorderService.create(id, fbo, clearBuffer); + auto *fbo = framebufferService->getResource(framebufferId); + return commandBufferRecorderService->create(id, fbo, clearBuffer); } } diff --git a/src/engine/frame-builder/structures/CommandBufferRecorderBuilder.h b/src/engine/frame-builder/structures/CommandBufferRecorderBuilder.h index 22c7af72..e5a52121 100644 --- a/src/engine/frame-builder/structures/CommandBufferRecorderBuilder.h +++ b/src/engine/frame-builder/structures/CommandBufferRecorderBuilder.h @@ -4,14 +4,27 @@ #include "ResourceBuilder.h" namespace Metal { + class CommandBufferRecorderService; + class FrameBufferService; + class CommandBufferRecorderBuilder final : public ResourceBuilder { std::string framebufferId; bool clearBuffer; bool computeMode; + FrameBufferService *framebufferService = nullptr; + CommandBufferRecorderService *commandBufferRecorderService = nullptr; public: + std::vector getDependencies() override { + return { + {"FrameBufferService", framebufferService}, + {"CommandBufferRecorderService", commandBufferRecorderService} + }; + } + explicit CommandBufferRecorderBuilder(const std::string &id, std::string framebufferId, bool clearBuffer = true) - : ResourceBuilder(id), framebufferId(std::move(framebufferId)), clearBuffer(clearBuffer), computeMode(false) { + : ResourceBuilder(id), framebufferId(std::move(framebufferId)), clearBuffer(clearBuffer), + computeMode(false) { } explicit CommandBufferRecorderBuilder(const std::string &id) @@ -23,9 +36,9 @@ namespace Metal { } RuntimeResource *build() override; - + bool isComputeMode() const { return computeMode; } - const std::string& getFramebufferId() const { return framebufferId; } + const std::string &getFramebufferId() const { return framebufferId; } bool shouldClearBuffer() const { return clearBuffer; } }; } diff --git a/src/engine/frame-builder/structures/FramebufferBuilder.cpp b/src/engine/frame-builder/structures/FramebufferBuilder.cpp index 0978ee74..63adbdf7 100644 --- a/src/engine/frame-builder/structures/FramebufferBuilder.cpp +++ b/src/engine/frame-builder/structures/FramebufferBuilder.cpp @@ -5,28 +5,27 @@ namespace Metal { ResourceType FramebufferBuilder::getType() { - return ResourceType::FRAMEBUFFER; + return FRAMEBUFFER; } - RuntimeResource* FramebufferBuilder::build() { - auto &framebufferService = CTX.framebufferService; - FrameBufferInstance* fbo = framebufferService.getResource(id); + RuntimeResource *FramebufferBuilder::build() { + FrameBufferInstance *fbo = frameBufferService->getResource(id); if (fbo != nullptr) { return fbo; } - fbo = framebufferService.createFrameBuffer(id, w, h, clearColor); + fbo = frameBufferService->createFrameBuffer(id, w, h, clearColor); - for (const auto& attachment : attachments) { - framebufferService.createAttachment(attachment.format, attachment.usage, fbo); + for (const auto &attachment: attachments) { + frameBufferService->createAttachment(attachment.format, attachment.usage, fbo); } if (hasDepth) { - framebufferService.createDepthAttachment(fbo); + frameBufferService->createDepthAttachment(fbo); } - framebufferService.createRenderPass(fbo); + frameBufferService->createRenderPass(fbo); return fbo; } -} // Metal \ No newline at end of file +} // Metal diff --git a/src/engine/frame-builder/structures/FramebufferBuilder.h b/src/engine/frame-builder/structures/FramebufferBuilder.h index f5ebead5..b439cffa 100644 --- a/src/engine/frame-builder/structures/FramebufferBuilder.h +++ b/src/engine/frame-builder/structures/FramebufferBuilder.h @@ -6,6 +6,7 @@ #include "ResourceBuilder.h" namespace Metal { + class FrameBufferService; struct FrameBufferInstance; struct FramebufferAttachmentBuilder { @@ -20,8 +21,12 @@ namespace Metal { glm::vec4 clearColor; std::vector attachments; bool hasDepth = false; - + FrameBufferService *frameBufferService = nullptr; public: + std::vector getDependencies() override { + return {{"FrameBufferService", frameBufferService}}; + } + explicit FramebufferBuilder(const std::string &id, const unsigned w, const unsigned h, glm::vec4 clearColor) : ResourceBuilder(id), clearColor(clearColor), w(w), h(h) { } diff --git a/src/engine/frame-builder/structures/ResourceBuilder.h b/src/engine/frame-builder/structures/ResourceBuilder.h index c0bd11d5..1a5c8ba0 100644 --- a/src/engine/frame-builder/structures/ResourceBuilder.h +++ b/src/engine/frame-builder/structures/ResourceBuilder.h @@ -2,10 +2,12 @@ #define METAL_ENGINE_RESOURCEBUILDER_H #include #include "../../enum/ResourceType.h" +#include "../../../common/IContextMember.h" namespace Metal { class RuntimeResource; - class ResourceBuilder { + + class ResourceBuilder : public IContextMember { protected: std::string id; @@ -16,9 +18,10 @@ namespace Metal { [[nodiscard]] std::string getId() const { return id; } + virtual ~ResourceBuilder() = default; - virtual RuntimeResource* build() = 0; + virtual RuntimeResource *build() = 0; virtual ResourceType getType() = 0; }; diff --git a/src/engine/frame-builder/structures/TextureBuilder.cpp b/src/engine/frame-builder/structures/TextureBuilder.cpp index 91e17622..7b03b40e 100644 --- a/src/engine/frame-builder/structures/TextureBuilder.cpp +++ b/src/engine/frame-builder/structures/TextureBuilder.cpp @@ -1,19 +1,19 @@ #include "TextureBuilder.h" -#include "../../../ApplicationContext.h" #include "../../resource/TextureInstance.h" +#include "../../service/TextureService.h" namespace Metal { ResourceType TextureBuilder::getType() { - return ResourceType::TEXTURE; + return TEXTURE; } RuntimeResource *TextureBuilder::build() { - auto *texture = CTX.textureService.getResource(id); + auto *texture = textureService->getResource(id); if (texture != nullptr) { return texture; } - texture = CTX.textureService.createForCompute(id, w, h, format); + texture = textureService->createForCompute(id, w, h, format); texture->setAsNoDisposal(); return texture; diff --git a/src/engine/frame-builder/structures/TextureBuilder.h b/src/engine/frame-builder/structures/TextureBuilder.h index 1015fdae..3294e0e9 100644 --- a/src/engine/frame-builder/structures/TextureBuilder.h +++ b/src/engine/frame-builder/structures/TextureBuilder.h @@ -5,12 +5,18 @@ #include "ResourceBuilder.h" namespace Metal { + class TextureService; + class TextureBuilder final : public ResourceBuilder { unsigned w; unsigned h; VkFormat format; - + TextureService *textureService = nullptr; public: + std::vector getDependencies() override { + return {{"TextureService", textureService}}; + } + explicit TextureBuilder(const std::string &id, unsigned w, unsigned h, VkFormat format = VK_FORMAT_R16G16B16A16_SFLOAT) : ResourceBuilder(id), w(w), h(h), format(format) { } diff --git a/src/engine/passes/AbstractPass.h b/src/engine/passes/AbstractPass.h index be268269..2cd69f9f 100644 --- a/src/engine/passes/AbstractPass.h +++ b/src/engine/passes/AbstractPass.h @@ -3,6 +3,8 @@ #include #include #include + +#include "../../common/IContextMember.h" #include "../../common/ISync.h" #include "../../common/IInit.h" #include "../resource/RuntimeResource.h" @@ -14,7 +16,7 @@ namespace Metal { class StreamingService; struct PipelineInstance; - class AbstractPass : public ISync, public IInit { + class AbstractPass : public IContextMember, public ISync, public IInit { bool isComputePass; public: diff --git a/src/engine/passes/CommandBufferRecorder.cpp b/src/engine/passes/CommandBufferRecorder.cpp index 03f9b60c..e523f940 100644 --- a/src/engine/passes/CommandBufferRecorder.cpp +++ b/src/engine/passes/CommandBufferRecorder.cpp @@ -7,16 +7,18 @@ #include "../../ApplicationContext.h" #include "AbstractRenderPass.h" #include "../../core/vulkan/VulkanUtils.h" +#include "../../core/vulkan/VulkanContext.h" +#include "../../core/FrameService.h" namespace Metal { void CommandBufferRecorder::createCommandBuffer() { VkCommandBufferAllocateInfo allocInfo{}; allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; - allocInfo.commandPool = CTX.vulkanContext.commandPool; + allocInfo.commandPool = vulkanContext->commandPool; allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; allocInfo.commandBufferCount = MAX_FRAMES_IN_FLIGHT; VulkanUtils::CheckVKResult( - vkAllocateCommandBuffers(CTX.vulkanContext.device.device, &allocInfo, + vkAllocateCommandBuffers(vulkanContext->device.device, &allocInfo, _commandBuffers.data())); } @@ -71,7 +73,7 @@ namespace Metal { void CommandBufferRecorder::recordCommands( const std::vector> &passes) const { - auto vkCommandBuffer = _commandBuffers[CTX.getFrameIndex()]; + auto vkCommandBuffer = _commandBuffers[frameService->getFrameIndex()]; VkCommandBufferBeginInfo beginInfo{}; beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; vkBeginCommandBuffer(vkCommandBuffer, &beginInfo); @@ -87,7 +89,7 @@ namespace Metal { } vkEndCommandBuffer(vkCommandBuffer); - CTX.vulkanContext.pushCommandBuffer(vkCommandBuffer); + vulkanContext->pushCommandBuffer(vkCommandBuffer); } void CommandBufferRecorder::RecordCommandsInternal( diff --git a/src/engine/passes/CommandBufferRecorder.h b/src/engine/passes/CommandBufferRecorder.h index a188280f..e5348c57 100644 --- a/src/engine/passes/CommandBufferRecorder.h +++ b/src/engine/passes/CommandBufferRecorder.h @@ -7,6 +7,7 @@ #include "../../core/vulkan/VulkanUtils.h" namespace Metal { + class FrameService; class AbstractPass; class ApplicationContext; struct FrameBufferInstance; @@ -18,14 +19,19 @@ namespace Metal { VkRenderPassBeginInfo renderPassInfo{}; std::vector clearColors{}; bool computePassMode; + FrameService *frameService = nullptr; static void RecordCommandsInternal( - const std::vector> &passes, + const std::vector > &passes, VkCommandBuffer vkCommandBuffer); void createRenderPassInfo(const FrameBufferInstance *frameBuffer, bool clearBuffer); public: + std::vector getDependencies() override { + return {{"FrameService", frameService}, {"VulkanContext", vulkanContext}}; + } + explicit CommandBufferRecorder(std::string id, FrameBufferInstance *frameBuffer, bool clearBuffer = true); explicit CommandBufferRecorder(std::string id); @@ -36,7 +42,7 @@ namespace Metal { void createCommandBuffer(); - void recordCommands(const std::vector> &passes) const; + void recordCommands(const std::vector > &passes) const; }; } // Metal diff --git a/src/engine/passes/impl/HWRayTracingPass.cpp b/src/engine/passes/impl/HWRayTracingPass.cpp index cc537f3e..af2574ea 100644 --- a/src/engine/passes/impl/HWRayTracingPass.cpp +++ b/src/engine/passes/impl/HWRayTracingPass.cpp @@ -1,9 +1,12 @@ #include "HWRayTracingPass.h" -#include "../../../ApplicationContext.h" #include "../../dto/PipelineBuilder.h" #include "../../resource/PipelineInstance.h" #include "../../resource/TextureInstance.h" #include "../../service/RayTracingService.h" +#include "../../service/PipelineService.h" +#include "../../../core/vulkan/VulkanContext.h" +#include "../../../engine/EngineContext.h" +#include "../../../engine/repository/EngineRepository.h" #include "../../../editor/enum/EngineResourceIDs.h" namespace Metal { @@ -14,16 +17,16 @@ namespace Metal { "rt/HWRayTracing.rchit") .setPushConstantsSize(sizeof(HWRayTracingPushConstant)) .addBufferBinding(getScopedResourceId(RID_GLOBAL_DATA)) - .addAccelerationStructureBinding(CTX.rayTracingService.getTLAS()) + .addAccelerationStructureBinding(rayTracingService->getTLAS()) .addStorageImageBinding(getScopedResourceId(RID_ACCUMULATED_FRAME)) .addStorageImageBinding(getScopedResourceId(RID_GBUFFER_POSITION_INDEX)) .addStorageImageBinding(getScopedResourceId(RID_GBUFFER_NORMAL)) .addBufferBinding(getScopedResourceId(RID_LIGHT_BUFFER)) .addBufferBinding(getScopedResourceId(RID_VOLUMES_BUFFER)) .addBufferBinding(getScopedResourceId(RID_MESH_METADATA_BUFFER)) - .addCombinedImageSamplerBinding(CTX.vulkanContext.vkImageSampler, VK_NULL_HANDLE, + .addCombinedImageSamplerBinding(vulkanContext->vkImageSampler, VK_NULL_HANDLE, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, 1000); - pipelineInstance = CTX.pipelineService.createPipeline(builder); + pipelineInstance = pipelineService->createPipeline(builder); } void HWRayTracingPass::onSync() { @@ -33,9 +36,9 @@ namespace Metal { auto *previousPositionIndex = frame->getResourceAs(RID_PREVIOUS_POSITION_INDEX); auto *previousNormal = frame->getResourceAs(RID_PREVIOUS_NORMAL); - if (isFirstRun || CTX.engineContext.isCameraUpdated() || CTX.engineContext.isGISettingsUpdated()) { + if (isFirstRun || engineContext->isCameraUpdated() || engineContext->isGISettingsUpdated()) { clearTexture(accumulatedFrame->vkImage); - CTX.engineContext.resetPathTracerAccumulationCount(); + engineContext->resetPathTracerAccumulationCount(); isFirstRun = false; } @@ -46,24 +49,24 @@ namespace Metal { startWriting(gBufferNormal->vkImage); // Trace rays - pushConstant.pathTracerMultiplier = CTX.engineRepository.pathTracerMultiplier; - pushConstant.volumeShadowSteps = CTX.engineRepository.volumeShadowSteps; - pushConstant.isAtmosphereEnabled = CTX.engineRepository.atmosphereEnabled; + pushConstant.pathTracerMultiplier = engineRepository->pathTracerMultiplier; + pushConstant.volumeShadowSteps = engineRepository->volumeShadowSteps; + pushConstant.isAtmosphereEnabled = engineRepository->atmosphereEnabled; - pushConstant.multipleImportanceSampling = CTX.engineRepository.multipleImportanceSampling; - pushConstant.pathTracerSamples = CTX.engineRepository.pathTracerSamples; - pushConstant.pathTracerBounces = CTX.engineRepository.pathTracerBounces; - pushConstant.pathTracingEmissiveFactor = CTX.engineRepository.pathTracingEmissiveFactor; - pushConstant.shouldTrace = CTX.rayTracingService.isReady(); + pushConstant.multipleImportanceSampling = engineRepository->multipleImportanceSampling; + pushConstant.pathTracerSamples = engineRepository->pathTracerSamples; + pushConstant.pathTracerBounces = engineRepository->pathTracerBounces; + pushConstant.pathTracingEmissiveFactor = engineRepository->pathTracingEmissiveFactor; + pushConstant.shouldTrace = rayTracingService->isReady(); - pushConstant.dofEnabled = CTX.engineRepository.dofEnabled; - pushConstant.dofFocusDistance = CTX.engineRepository.dofFocusDistance; - pushConstant.dofAperture = CTX.engineRepository.dofAperture; - pushConstant.dofFocalLength = CTX.engineRepository.dofFocalLength; + pushConstant.dofEnabled = engineRepository->dofEnabled; + pushConstant.dofFocusDistance = engineRepository->dofFocusDistance; + pushConstant.dofAperture = engineRepository->dofAperture; + pushConstant.dofFocalLength = engineRepository->dofFocalLength; recordPushConstant(&pushConstant); - CTX.vulkanContext.vkCmdTraceRaysKHR( + vulkanContext->vkCmdTraceRaysKHR( vkCommandBuffer, &pipelineInstance->raygenRegion, &pipelineInstance->missRegion, diff --git a/src/engine/passes/impl/HWRayTracingPass.h b/src/engine/passes/impl/HWRayTracingPass.h index de0d0f70..c8e9601a 100644 --- a/src/engine/passes/impl/HWRayTracingPass.h +++ b/src/engine/passes/impl/HWRayTracingPass.h @@ -4,11 +4,33 @@ #include "../../dto/HWRayTracingPushConstant.h" namespace Metal { + class RayTracingService; + class PipelineService; + class VulkanContext; + class EngineContext; + struct EngineRepository; + class HWRayTracingPass final : public AbstractComputePass { bool isFirstRun = true; HWRayTracingPushConstant pushConstant{}; + RayTracingService *rayTracingService = nullptr; + PipelineService *pipelineService = nullptr; + VulkanContext *vulkanContext = nullptr; + EngineContext *engineContext = nullptr; + EngineRepository *engineRepository = nullptr; + public: + std::vector getDependencies() override { + return { + {"RayTracingService", rayTracingService}, + {"PipelineService", pipelineService}, + {"VulkanContext", vulkanContext}, + {"EngineContext", engineContext}, + {"EngineRepository", engineRepository} + }; + } + void onSync() override; void onInitialize() override; diff --git a/src/engine/passes/impl/PostProcessingPass.cpp b/src/engine/passes/impl/PostProcessingPass.cpp index 67aab25f..f16d3d5d 100644 --- a/src/engine/passes/impl/PostProcessingPass.cpp +++ b/src/engine/passes/impl/PostProcessingPass.cpp @@ -1,9 +1,11 @@ #include "PostProcessingPass.h" - -#include "../../../ApplicationContext.h" - #include "../../dto/PipelineBuilder.h" +#include "../../service/PipelineService.h" +#include "../../../core/vulkan/VulkanContext.h" +#include "../../../engine/repository/WorldRepository.h" #include "../../../editor/enum/EngineResourceIDs.h" +#include "../../frame-builder/EngineFrame.h" +#include "../../resource/TextureInstance.h" namespace Metal { @@ -14,12 +16,12 @@ namespace Metal { "PostProcessing.frag" ) .setPushConstantsSize(sizeof(PostProcessingPushConstant)) - .addCombinedImageSamplerBinding(CTX.vulkanContext.vkImageSampler, frame->getResourceAs(RID_DENOISED_FRAME)->vkImageView); - pipelineInstance = CTX.pipelineService.createPipeline(ppPipelineBuilder); + .addCombinedImageSamplerBinding(vulkanContext->vkImageSampler, frame->getResourceAs(RID_DENOISED_FRAME)->vkImageView); + pipelineInstance = pipelineService->createPipeline(ppPipelineBuilder); } void PostProcessingPass::onSync() { - auto &camera = CTX.worldRepository.camera; + auto &camera = worldRepository->camera; pushConstant.distortionIntensity = camera.distortionIntensity; pushConstant.chromaticAberrationIntensity = camera.chromaticAberrationIntensity; pushConstant.distortionEnabled = camera.distortionEnabled; diff --git a/src/engine/passes/impl/PostProcessingPass.h b/src/engine/passes/impl/PostProcessingPass.h index 08e60b2c..9cf49ab9 100644 --- a/src/engine/passes/impl/PostProcessingPass.h +++ b/src/engine/passes/impl/PostProcessingPass.h @@ -4,9 +4,26 @@ #include "../../dto/PostProcessingPushConstant.h" namespace Metal { + class VulkanContext; + class PipelineService; + struct WorldRepository; + class PostProcessingPass final : public AbstractRenderPass { PostProcessingPushConstant pushConstant{}; + + VulkanContext *vulkanContext = nullptr; + PipelineService *pipelineService = nullptr; + WorldRepository *worldRepository = nullptr; + public: + std::vector getDependencies() override { + return { + {"VulkanContext", vulkanContext}, + {"PipelineService", pipelineService}, + {"WorldRepository", worldRepository} + }; + } + void onInitialize() override; void onSync() override; diff --git a/src/engine/passes/impl/SpatialFilterPass.cpp b/src/engine/passes/impl/SpatialFilterPass.cpp index 291d7b5f..ee34a76f 100644 --- a/src/engine/passes/impl/SpatialFilterPass.cpp +++ b/src/engine/passes/impl/SpatialFilterPass.cpp @@ -1,7 +1,8 @@ #include "SpatialFilterPass.h" -#include "../../../ApplicationContext.h" #include "../../dto/PipelineBuilder.h" #include "../../resource/TextureInstance.h" +#include "../../service/PipelineService.h" +#include "../../frame-builder/EngineFrame.h" #include "../../../editor/enum/EngineResourceIDs.h" namespace Metal { @@ -12,7 +13,7 @@ namespace Metal { .addStorageImageBinding(getScopedResourceId(RID_DENOISED_FRAME)) .addStorageImageBinding(getScopedResourceId(RID_GBUFFER_POSITION_INDEX)) .addStorageImageBinding(getScopedResourceId(RID_GBUFFER_NORMAL)); - pipelineInstance = CTX.pipelineService.createPipeline(spatialBuilder); + pipelineInstance = pipelineService->createPipeline(spatialBuilder); } void SpatialFilterPass::onSync() { diff --git a/src/engine/passes/impl/SpatialFilterPass.h b/src/engine/passes/impl/SpatialFilterPass.h index 838a353f..9edd07ca 100644 --- a/src/engine/passes/impl/SpatialFilterPass.h +++ b/src/engine/passes/impl/SpatialFilterPass.h @@ -3,8 +3,18 @@ #include "../AbstractComputePass.h" namespace Metal { + class PipelineService; + class SpatialFilterPass final : public AbstractComputePass { + PipelineService *pipelineService = nullptr; + public: + std::vector getDependencies() override { + return { + {"PipelineService", pipelineService} + }; + } + void onSync() override; void onInitialize() override; diff --git a/src/engine/passes/impl/TemporalAccumulationPass.cpp b/src/engine/passes/impl/TemporalAccumulationPass.cpp index e1d1029d..68c751aa 100644 --- a/src/engine/passes/impl/TemporalAccumulationPass.cpp +++ b/src/engine/passes/impl/TemporalAccumulationPass.cpp @@ -1,7 +1,8 @@ #include "TemporalAccumulationPass.h" -#include "../../../ApplicationContext.h" #include "../../dto/PipelineBuilder.h" #include "../../resource/TextureInstance.h" +#include "../../service/PipelineService.h" +#include "../../frame-builder/EngineFrame.h" #include "../../../editor/enum/EngineResourceIDs.h" namespace Metal { @@ -15,7 +16,7 @@ namespace Metal { .addStorageImageBinding(getScopedResourceId(RID_PREVIOUS_POSITION_INDEX)) .addStorageImageBinding(getScopedResourceId(RID_GBUFFER_NORMAL)) .addStorageImageBinding(getScopedResourceId(RID_PREVIOUS_NORMAL)); - pipelineInstance = CTX.pipelineService.createPipeline(temporalBuilder); + pipelineInstance = pipelineService->createPipeline(temporalBuilder); } void TemporalAccumulationPass::onSync() { diff --git a/src/engine/passes/impl/TemporalAccumulationPass.h b/src/engine/passes/impl/TemporalAccumulationPass.h index a95b2c3f..ff7c467c 100644 --- a/src/engine/passes/impl/TemporalAccumulationPass.h +++ b/src/engine/passes/impl/TemporalAccumulationPass.h @@ -3,8 +3,17 @@ #include "../AbstractComputePass.h" namespace Metal { + class PipelineService; + class TemporalAccumulationPass final : public AbstractComputePass { + PipelineService *pipelineService = nullptr; + public: + std::vector getDependencies() override { + return { + {"PipelineService", pipelineService} + }; + } void onSync() override; diff --git a/src/engine/repository/WorldRepository.h b/src/engine/repository/WorldRepository.h index 737df3dd..8ed4ee40 100644 --- a/src/engine/repository/WorldRepository.h +++ b/src/engine/repository/WorldRepository.h @@ -15,8 +15,8 @@ namespace Metal { class DirectoryService; struct WorldRepository final : IRepository { - RayTracingService *rayTracingService; - DirectoryService *directoryService; + RayTracingService *rayTracingService = nullptr; + DirectoryService *directoryService = nullptr; Camera camera{-(glm::pi() / 4), glm::pi() / 4, {10, 10, 10}}; entt::registry registry{}; @@ -25,8 +25,8 @@ namespace Metal { std::vector getDependencies() override { return { - {"RayTracingService", rayTracingService}, - {"DirectoryService", directoryService} + {"RayTracingService", rayTracingService}, + {"DirectoryService", directoryService} }; } diff --git a/src/engine/resource/FrameBufferAttachment.cpp b/src/engine/resource/FrameBufferAttachment.cpp index 3e830173..00bbfe33 100644 --- a/src/engine/resource/FrameBufferAttachment.cpp +++ b/src/engine/resource/FrameBufferAttachment.cpp @@ -1,16 +1,15 @@ #include "FrameBufferAttachment.h" - - -#include "../../ApplicationContext.h" +#include "../service/DescriptorSetService.h" +#include "../../core/vulkan/VulkanContext.h" namespace Metal { void FrameBufferAttachment::dispose() const { - vkDestroyImage(CTX.vulkanContext.device.device, vkImage, nullptr); - vkDestroyImageView(CTX.vulkanContext.device.device, vkImageView, nullptr); - vkFreeMemory(CTX.vulkanContext.device.device, vkImageMemory, nullptr); + vkDestroyImage(vulkanContext->device.device, vkImage, nullptr); + vkDestroyImageView(vulkanContext->device.device, vkImageView, nullptr); + vkFreeMemory(vulkanContext->device.device, vkImageMemory, nullptr); if (imageDescriptor != nullptr) { - CTX.descriptorSetService.disposeResource(imageDescriptor); + descriptorSetService->disposeResource(imageDescriptor); } } } diff --git a/src/engine/resource/FrameBufferAttachment.h b/src/engine/resource/FrameBufferAttachment.h index 6e559c13..6a1b102c 100644 --- a/src/engine/resource/FrameBufferAttachment.h +++ b/src/engine/resource/FrameBufferAttachment.h @@ -3,7 +3,9 @@ #include "../dto/DescriptorInstance.h" namespace Metal { - struct FrameBufferAttachment final { + class DescriptorSetService; + + struct FrameBufferAttachment final : IContextMember { VkImage vkImage = VK_NULL_HANDLE; VkDeviceMemory vkImageMemory = VK_NULL_HANDLE; VkImageView vkImageView = VK_NULL_HANDLE; @@ -12,6 +14,10 @@ namespace Metal { bool depth = false; void dispose() const; + + private: + VulkanContext *vulkanContext = nullptr; + DescriptorSetService *descriptorSetService = nullptr; }; } diff --git a/src/engine/resource/RuntimeResource.h b/src/engine/resource/RuntimeResource.h index a99d4632..e3952bcc 100644 --- a/src/engine/resource/RuntimeResource.h +++ b/src/engine/resource/RuntimeResource.h @@ -4,20 +4,29 @@ #include "../../editor/util/Util.h" #include +#include "../../common/IContextMember.h" + using Clock = std::chrono::high_resolution_clock; using TimePoint = std::chrono::time_point; namespace Metal { class VulkanContext; - class RuntimeResource { + class RuntimeResource : public IContextMember { const std::string id; bool noDisposal = false; - std::vector empty{}; + + protected: + VulkanContext *vulkanContext = nullptr; + public: + std::vector getDependencies() override { + return {{"VulkanContext", vulkanContext}}; + } + virtual ~RuntimeResource() = default; - explicit RuntimeResource(const std::string &id = Util::uuidV4()): id(std::move(id)) { + explicit RuntimeResource(const std::string &id = Util::uuidV4()) : id(id) { } [[nodiscard]] std::string getId() const { @@ -35,10 +44,6 @@ namespace Metal { virtual ResourceType resourceType() { throw std::runtime_error("Not implemented"); } - - virtual std::vector &getDependencies() { - return empty; - } }; } #endif diff --git a/src/engine/service/BufferService.cpp b/src/engine/service/BufferService.cpp index c0931b71..d6523bf1 100644 --- a/src/engine/service/BufferService.cpp +++ b/src/engine/service/BufferService.cpp @@ -10,7 +10,7 @@ namespace Metal { VkMemoryPropertyFlags memoryPropertyFlags, BufferType type) { BufferInstance *buffer = createResourceInstance(id, bufferSize, type); createVkBuffer(usageFlags, memoryPropertyFlags, buffer); - vkMapMemory(vulkanContext.device.device, buffer->vkDeviceMemory, 0, bufferSize, 0, &buffer->mapped); + vkMapMemory(vulkanContext->device.device, buffer->vkDeviceMemory, 0, bufferSize, 0, &buffer->mapped); return buffer; } @@ -23,10 +23,10 @@ namespace Metal { createVkBuffer(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, stagingBuffer); - vkMapMemory(vulkanContext.device.device, stagingBuffer->vkDeviceMemory, 0, dataSize, 0, + vkMapMemory(vulkanContext->device.device, stagingBuffer->vkDeviceMemory, 0, dataSize, 0, &stagingBuffer->mapped); memcpy(stagingBuffer->mapped, bufferData, dataSize); - vkUnmapMemory(vulkanContext.device.device, stagingBuffer->vkDeviceMemory); + vkUnmapMemory(vulkanContext->device.device, stagingBuffer->vkDeviceMemory); createVkBuffer(VK_BUFFER_USAGE_TRANSFER_DST_BIT | usageFlags, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, finalBuffer); @@ -38,8 +38,8 @@ namespace Metal { } unsigned int BufferService::findMemoryType(unsigned int typeFilter, VkMemoryPropertyFlags properties) const { - for (unsigned int i = 0; i < vulkanContext.physicalDeviceMemoryProperties.memoryTypeCount; i++) { - if ((typeFilter & (1 << i)) && (vulkanContext.physicalDeviceMemoryProperties.memoryTypes[i]. + for (unsigned int i = 0; i < vulkanContext->physicalDeviceMemoryProperties.memoryTypeCount; i++) { + if ((typeFilter & (1 << i)) && (vulkanContext->physicalDeviceMemoryProperties.memoryTypes[i]. propertyFlags & properties) == properties) { return i; @@ -57,31 +57,31 @@ namespace Metal { bufferInfo.usage = usage; bufferInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; - VulkanUtils::CheckVKResult(vkCreateBuffer(vulkanContext.device.device, &bufferInfo, nullptr, + VulkanUtils::CheckVKResult(vkCreateBuffer(vulkanContext->device.device, &bufferInfo, nullptr, &buffer->vkBuffer)); VkMemoryRequirements memRequirements; - vkGetBufferMemoryRequirements(vulkanContext.device.device, buffer->vkBuffer, &memRequirements); + vkGetBufferMemoryRequirements(vulkanContext->device.device, buffer->vkBuffer, &memRequirements); VkMemoryAllocateInfo allocInfo{}; allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; allocInfo.allocationSize = memRequirements.size; allocInfo.memoryTypeIndex = findMemoryType(memRequirements.memoryTypeBits, properties); - VulkanUtils::CheckVKResult(vkAllocateMemory(vulkanContext.device.device, &allocInfo, nullptr, + VulkanUtils::CheckVKResult(vkAllocateMemory(vulkanContext->device.device, &allocInfo, nullptr, &buffer->vkDeviceMemory)); - vkBindBufferMemory(vulkanContext.device.device, buffer->vkBuffer, buffer->vkDeviceMemory, 0); + vkBindBufferMemory(vulkanContext->device.device, buffer->vkBuffer, buffer->vkDeviceMemory, 0); } void BufferService::copyBuffer(const BufferInstance *srcBuffer, const BufferInstance *dstBuffer) const { - VkCommandBuffer commandBuffer = vulkanContext.beginSingleTimeCommands(); + VkCommandBuffer commandBuffer = vulkanContext->beginSingleTimeCommands(); VkBufferCopy copyRegion{}; copyRegion.size = dstBuffer->dataSize; vkCmdCopyBuffer(commandBuffer, srcBuffer->vkBuffer, dstBuffer->vkBuffer, 1, ©Region); - vulkanContext.endSingleTimeCommands(commandBuffer); + vulkanContext->endSingleTimeCommands(commandBuffer); } BufferInstance *BufferService::createBuffer(const std::string &id, VkDeviceSize bufferSize, @@ -99,11 +99,11 @@ namespace Metal { } bufferInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; - VulkanUtils::CheckVKResult(vkCreateBuffer(vulkanContext.device.device, &bufferInfo, nullptr, + VulkanUtils::CheckVKResult(vkCreateBuffer(vulkanContext->device.device, &bufferInfo, nullptr, &buffer->vkBuffer)); VkMemoryRequirements memRequirements; - vkGetBufferMemoryRequirements(vulkanContext.device.device, buffer->vkBuffer, &memRequirements); + vkGetBufferMemoryRequirements(vulkanContext->device.device, buffer->vkBuffer, &memRequirements); VkMemoryAllocateInfo allocInfo{}; allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; @@ -117,12 +117,12 @@ namespace Metal { allocInfo.pNext = &allocFlagsInfo; } - VulkanUtils::CheckVKResult(vkAllocateMemory(vulkanContext.device.device, &allocInfo, nullptr, + VulkanUtils::CheckVKResult(vkAllocateMemory(vulkanContext->device.device, &allocInfo, nullptr, &buffer->vkDeviceMemory)); - vkBindBufferMemory(vulkanContext.device.device, buffer->vkBuffer, buffer->vkDeviceMemory, 0); + vkBindBufferMemory(vulkanContext->device.device, buffer->vkBuffer, buffer->vkDeviceMemory, 0); if (memoryPropertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) { - vkMapMemory(vulkanContext.device.device, buffer->vkDeviceMemory, 0, bufferSize, 0, &buffer->mapped); + vkMapMemory(vulkanContext->device.device, buffer->vkDeviceMemory, 0, bufferSize, 0, &buffer->mapped); } return buffer; @@ -137,10 +137,10 @@ namespace Metal { createVkBuffer(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, stagingBuffer); - vkMapMemory(vulkanContext.device.device, stagingBuffer->vkDeviceMemory, 0, dataSize, 0, + vkMapMemory(vulkanContext->device.device, stagingBuffer->vkDeviceMemory, 0, dataSize, 0, &stagingBuffer->mapped); memcpy(stagingBuffer->mapped, bufferData, dataSize); - vkUnmapMemory(vulkanContext.device.device, stagingBuffer->vkDeviceMemory); + vkUnmapMemory(vulkanContext->device.device, stagingBuffer->vkDeviceMemory); auto *finalBuffer = createBuffer(id, dataSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT | usageFlags, @@ -153,7 +153,7 @@ namespace Metal { } void BufferService::disposeResource(BufferInstance *resource) { - vkDestroyBuffer(vulkanContext.device.device, resource->vkBuffer, nullptr); - vkFreeMemory(vulkanContext.device.device, resource->vkDeviceMemory, nullptr); + vkDestroyBuffer(vulkanContext->device.device, resource->vkBuffer, nullptr); + vkFreeMemory(vulkanContext->device.device, resource->vkDeviceMemory, nullptr); } } // Metal diff --git a/src/engine/service/DescriptorSetService.cpp b/src/engine/service/DescriptorSetService.cpp index 71a8a55d..e1ea7d22 100644 --- a/src/engine/service/DescriptorSetService.cpp +++ b/src/engine/service/DescriptorSetService.cpp @@ -31,7 +31,7 @@ namespace Metal { binding.attachmentIndex = builder.attachmentIndex; if (builder.type == DescriptorBindingType::FBO_ATTACHMENT) { - auto *fbo = framebufferService.getResource(binding.frameBufferId); + auto *fbo = framebufferService->getResource(binding.frameBufferId); if (fbo == nullptr) { throw std::runtime_error("Framebuffer not found: " + binding.frameBufferId); } @@ -62,7 +62,7 @@ namespace Metal { binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; break; case DescriptorBindingType::STORAGE_IMAGE: { - auto *texture = textureService.getResource(binding.storageImageId); + auto *texture = textureService->getResource(binding.storageImageId); if (texture == nullptr) { throw std::runtime_error("Storage image texture not found: " + binding.storageImageId); } diff --git a/src/engine/service/FrameBufferService.cpp b/src/engine/service/FrameBufferService.cpp index b1bedf37..0292ea33 100644 --- a/src/engine/service/FrameBufferService.cpp +++ b/src/engine/service/FrameBufferService.cpp @@ -1,7 +1,6 @@ #include "FrameBufferService.h" #include -#include #include #include "../resource/FrameBufferInstance.h" @@ -9,6 +8,7 @@ #include "../../core/vulkan/VulkanUtils.h" #include "../resource/FrameBufferAttachment.h" #include "../../ApplicationContext.h" +#include "../../common/LoggerUtil.h" namespace Metal { @@ -23,7 +23,7 @@ namespace Metal { } void FrameBufferService::createDepthAttachment(FrameBufferInstance *framebuffer) const { - VkFormat depthFormat = VulkanUtils::GetValidDepthFormat(vulkanContext.physDevice.physical_device); + VkFormat depthFormat = VulkanUtils::GetValidDepthFormat(vulkanContext->physDevice.physical_device); const auto att = createAttachmentInternal(depthFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, framebuffer); att->depth = true; @@ -42,6 +42,7 @@ namespace Metal { VkImageUsageFlagBits usage, FrameBufferInstance *framebuffer) const { std::shared_ptr attachment = std::make_shared(); + ctx->injectDependencies(attachment.get()); framebuffer->attachments.push_back(attachment); attachment->format = format; @@ -73,20 +74,20 @@ namespace Metal { image.sharingMode = VK_SHARING_MODE_EXCLUSIVE; VulkanUtils::CheckVKResult( - vkCreateImage(vulkanContext.device.device, &image, nullptr, &attachment->vkImage)); + vkCreateImage(vulkanContext->device.device, &image, nullptr, &attachment->vkImage)); VkMemoryAllocateInfo memAlloc{}; VkMemoryRequirements memReqs; - vkGetImageMemoryRequirements(vulkanContext.device.device, attachment->vkImage, &memReqs); + vkGetImageMemoryRequirements(vulkanContext->device.device, attachment->vkImage, &memReqs); memAlloc.allocationSize = memReqs.size; - memAlloc.memoryTypeIndex = VulkanUtils::GetMemTypeIndex(vulkanContext.physicalDeviceMemoryProperties, + memAlloc.memoryTypeIndex = VulkanUtils::GetMemTypeIndex(vulkanContext->physicalDeviceMemoryProperties, memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); - VulkanUtils::CheckVKResult(vkAllocateMemory(vulkanContext.device.device, &memAlloc, nullptr, + VulkanUtils::CheckVKResult(vkAllocateMemory(vulkanContext->device.device, &memAlloc, nullptr, &attachment->vkImageMemory)); VulkanUtils::CheckVKResult( - vkBindImageMemory(vulkanContext.device.device, attachment->vkImage, attachment->vkImageMemory, 0)); + vkBindImageMemory(vulkanContext->device.device, attachment->vkImage, attachment->vkImageMemory, 0)); VkImageViewCreateInfo imageView{}; imageView.viewType = VK_IMAGE_VIEW_TYPE_2D; @@ -98,7 +99,7 @@ namespace Metal { imageView.subresourceRange.baseArrayLayer = 0; imageView.subresourceRange.layerCount = 1; imageView.image = attachment->vkImage; - VulkanUtils::CheckVKResult(vkCreateImageView(vulkanContext.device.device, &imageView, nullptr, + VulkanUtils::CheckVKResult(vkCreateImageView(vulkanContext->device.device, &imageView, nullptr, &attachment->vkImageView)); return attachment; } @@ -167,7 +168,7 @@ namespace Metal { renderPassInfo.dependencyCount = dependencies.size(); renderPassInfo.pDependencies = dependencies.data(); - VulkanUtils::CheckVKResult(vkCreateRenderPass(vulkanContext.device.device, + VulkanUtils::CheckVKResult(vkCreateRenderPass(vulkanContext->device.device, &renderPassInfo, nullptr, &framebuffer->vkRenderPass)); @@ -196,14 +197,14 @@ namespace Metal { framebufferInfo.height = framebuffer->bufferHeight; framebufferInfo.layers = 1; - vkCreateFramebuffer(vulkanContext.device.device, &framebufferInfo, nullptr, + vkCreateFramebuffer(vulkanContext->device.device, &framebufferInfo, nullptr, &framebuffer->vkFramebuffer); } void FrameBufferService::disposeResource(FrameBufferInstance *resource) { LOG_INFO("Disposing framebuffer instance"); - vkDestroyFramebuffer(vulkanContext.device.device, resource->vkFramebuffer, nullptr); - vkDestroyRenderPass(vulkanContext.device.device, resource->vkRenderPass, nullptr); + vkDestroyFramebuffer(vulkanContext->device.device, resource->vkFramebuffer, nullptr); + vkDestroyRenderPass(vulkanContext->device.device, resource->vkRenderPass, nullptr); for (int i = 0; i < resource->attachments.size(); i++) { LOG_INFO("Disposing of attachment instance " + std::to_string(i)); diff --git a/src/engine/service/PipelineService.cpp b/src/engine/service/PipelineService.cpp index 83e84709..0697bf19 100644 --- a/src/engine/service/PipelineService.cpp +++ b/src/engine/service/PipelineService.cpp @@ -13,6 +13,7 @@ #include "../resource/FrameBufferAttachment.h" #include "../resource/BufferInstance.h" #include "../../ApplicationContext.h" +#include "../../common/LoggerUtil.h" namespace Metal { void PipelineService::createPipelineLayout( @@ -37,7 +38,7 @@ namespace Metal { layoutInfo.pPushConstantRanges = &pushConstantRange; } - VulkanUtils::CheckVKResult(vkCreatePipelineLayout(vulkanContext.device.device, &layoutInfo, nullptr, + VulkanUtils::CheckVKResult(vkCreatePipelineLayout(vulkanContext->device.device, &layoutInfo, nullptr, &pipeline->vkPipelineLayout)); } @@ -57,7 +58,7 @@ namespace Metal { stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT; } - pipeline->descriptor = descriptorSetService.createDescriptor(pipelineBuilder, id + "_descriptor", stageFlags); + pipeline->descriptor = descriptorSetService->createDescriptor(pipelineBuilder, id + "_descriptor", stageFlags); } if (pipelineBuilder.isRayTracing) { @@ -73,7 +74,7 @@ namespace Metal { PipelineInstance *pipeline) { pipeline->isCompute = true; pipeline->pushConstantsSize = pipelineBuilder.pushConstantsSize; - VkShaderModule computeShaderModule = shaderService.createShaderModule(pipelineBuilder.computeShader); + VkShaderModule computeShaderModule = shaderService->createShaderModule(pipelineBuilder.computeShader); VkPipelineShaderStageCreateInfo computeShaderStageInfo{}; computeShaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; computeShaderStageInfo.stage = VK_SHADER_STAGE_COMPUTE_BIT; @@ -87,12 +88,12 @@ namespace Metal { pipelineInfo.layout = pipeline->vkPipelineLayout; pipelineInfo.stage = computeShaderStageInfo; - if (vkCreateComputePipelines(vulkanContext.device.device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, + if (vkCreateComputePipelines(vulkanContext->device.device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &pipeline->vkPipeline) != VK_SUCCESS) { throw std::runtime_error("failed to create compute pipeline!"); } - vkDestroyShaderModule(vulkanContext.device.device, computeShaderModule, nullptr); + vkDestroyShaderModule(vulkanContext->device.device, computeShaderModule, nullptr); return pipeline; } @@ -101,8 +102,8 @@ namespace Metal { auto meshDescriptions = VertexData::GetAttributeDescriptions(); pipeline->pushConstantsSize = pipelineBuilder.pushConstantsSize; - auto fragmentShaderModule = shaderService.createShaderModule(pipelineBuilder.fragmentShader); - auto vertexShaderModule = shaderService.createShaderModule(pipelineBuilder.vertexShader); + auto fragmentShaderModule = shaderService->createShaderModule(pipelineBuilder.fragmentShader); + auto vertexShaderModule = shaderService->createShaderModule(pipelineBuilder.vertexShader); createPipelineLayout(pipelineBuilder.pushConstantsSize, pipeline); std::array shaderStages{}; @@ -157,7 +158,7 @@ namespace Metal { multisampling.sampleShadingEnable = VK_FALSE; multisampling.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; - auto *frameBuffer = framebufferService.getResource(pipelineBuilder.frameBufferId); + auto *frameBuffer = framebufferService->getResource(pipelineBuilder.frameBufferId); if (!frameBuffer) { throw std::runtime_error("Framebuffer not found: " + pipelineBuilder.frameBufferId); } @@ -228,13 +229,13 @@ namespace Metal { pipelineInfo.subpass = 0; pipelineInfo.basePipelineHandle = VK_NULL_HANDLE; - VulkanUtils::CheckVKResult(vkCreateGraphicsPipelines(vulkanContext.device.device, VK_NULL_HANDLE, 1, + VulkanUtils::CheckVKResult(vkCreateGraphicsPipelines(vulkanContext->device.device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &pipeline->vkPipeline)); - vkDestroyShaderModule(vulkanContext.device.device, fragmentShaderModule, nullptr); - vkDestroyShaderModule(vulkanContext.device.device, vertexShaderModule, nullptr); + vkDestroyShaderModule(vulkanContext->device.device, fragmentShaderModule, nullptr); + vkDestroyShaderModule(vulkanContext->device.device, vertexShaderModule, nullptr); return pipeline; } @@ -252,9 +253,9 @@ namespace Metal { pipeline->pushConstantsSize = pipelineBuilder.pushConstantsSize; // Create shader modules - auto rayGenModule = shaderService.createShaderModule(pipelineBuilder.rayGenShader); - auto missModule = shaderService.createShaderModule(pipelineBuilder.missShader); - auto closestHitModule = shaderService.createShaderModule(pipelineBuilder.closestHitShader); + auto rayGenModule = shaderService->createShaderModule(pipelineBuilder.rayGenShader); + auto missModule = shaderService->createShaderModule(pipelineBuilder.missShader); + auto closestHitModule = shaderService->createShaderModule(pipelineBuilder.closestHitShader); // Shader stages: 0=raygen, 1=miss, 2=closesthit std::array shaderStages{}; @@ -311,12 +312,12 @@ namespace Metal { rtPipelineInfo.layout = pipeline->vkPipelineLayout; VulkanUtils::CheckVKResult( - vulkanContext.vkCreateRayTracingPipelinesKHR( - vulkanContext.device.device, VK_NULL_HANDLE, VK_NULL_HANDLE, + vulkanContext->vkCreateRayTracingPipelinesKHR( + vulkanContext->device.device, VK_NULL_HANDLE, VK_NULL_HANDLE, 1, &rtPipelineInfo, nullptr, &pipeline->vkPipeline)); // Build Shader Binding Table - const auto &rtProps = vulkanContext.rayTracingPipelineProperties; + const auto &rtProps = vulkanContext->rayTracingPipelineProperties; const uint32_t handleSize = rtProps.shaderGroupHandleSize; const uint32_t handleAlignment = rtProps.shaderGroupHandleAlignment; const uint32_t baseAlignment = rtProps.shaderGroupBaseAlignment; @@ -326,14 +327,14 @@ namespace Metal { const uint32_t sbtSize = groupCount * handleSizeAligned; std::vector shaderHandleStorage(sbtSize); VulkanUtils::CheckVKResult( - vulkanContext.vkGetRayTracingShaderGroupHandlesKHR( - vulkanContext.device.device, pipeline->vkPipeline, + vulkanContext->vkGetRayTracingShaderGroupHandlesKHR( + vulkanContext->device.device, pipeline->vkPipeline, 0, groupCount, sbtSize, shaderHandleStorage.data())); // Create SBT buffers - each needs baseAlignment auto createSBTBuffer = [&](uint32_t groupIndex, const std::string &sbtType) -> BufferInstance * { const uint32_t sbtBufferSize = (handleSizeAligned + baseAlignment - 1) & ~(baseAlignment - 1); - auto *buf = bufferService.createBuffer( + auto *buf = bufferService->createBuffer( pipeline->getId() + "_sbt_" + sbtType, sbtBufferSize, VK_BUFFER_USAGE_SHADER_BINDING_TABLE_BIT_KHR | VK_BUFFER_USAGE_TRANSFER_DST_BIT, @@ -348,8 +349,8 @@ namespace Metal { pipeline->hitSBT = createSBTBuffer(2, "hit"); auto getAddr = [&](const BufferInstance *buf) { - return getBufferDeviceAddress(vulkanContext.device.device, buf->vkBuffer, - vulkanContext.vkGetBufferDeviceAddressKHR); + return getBufferDeviceAddress(vulkanContext->device.device, buf->vkBuffer, + vulkanContext->vkGetBufferDeviceAddressKHR); }; pipeline->raygenRegion.deviceAddress = getAddr(pipeline->raygenSBT); @@ -366,9 +367,9 @@ namespace Metal { pipeline->callableRegion = {}; // unused - vkDestroyShaderModule(vulkanContext.device.device, rayGenModule, nullptr); - vkDestroyShaderModule(vulkanContext.device.device, missModule, nullptr); - vkDestroyShaderModule(vulkanContext.device.device, closestHitModule, nullptr); + vkDestroyShaderModule(vulkanContext->device.device, rayGenModule, nullptr); + vkDestroyShaderModule(vulkanContext->device.device, missModule, nullptr); + vkDestroyShaderModule(vulkanContext->device.device, closestHitModule, nullptr); return pipeline; } @@ -377,14 +378,14 @@ namespace Metal { LOG_INFO("Disposing of pipeline instance"); if (resource->descriptor != nullptr) { - descriptorSetService.dispose(resource->getId()); + descriptorSetService->dispose(resource->getId()); } - vkDestroyPipelineLayout(vulkanContext.device.device, resource->vkPipelineLayout, nullptr); - vkDestroyPipeline(vulkanContext.device.device, resource->vkPipeline, nullptr); + vkDestroyPipelineLayout(vulkanContext->device.device, resource->vkPipelineLayout, nullptr); + vkDestroyPipeline(vulkanContext->device.device, resource->vkPipeline, nullptr); } std::vector PipelineService::getAllDescriptors() const { - return descriptorSetService.getAllDescriptors(); + return descriptorSetService->getAllDescriptors(); } } // Metal diff --git a/src/engine/service/RayTracingService.cpp b/src/engine/service/RayTracingService.cpp index 902a8641..af1fac86 100644 --- a/src/engine/service/RayTracingService.cpp +++ b/src/engine/service/RayTracingService.cpp @@ -8,6 +8,9 @@ #include "../../core/vulkan/VulkanUtils.h" #include "../../editor/enum/EngineResourceIDs.h" #include "../../core/vulkan/VulkanContext.h" +#include "../../common/LoggerUtil.h" +#include "../dto/TransformComponent.h" +#include "../dto/PrimitiveComponent.h" #include "PipelineService.h" #include "../repository/WorldRepository.h" #include "MeshService.h" @@ -18,11 +21,11 @@ #include namespace Metal { - static VkDeviceAddress getDeviceAddress(const VulkanContext &ctx, VkBuffer buffer) { + VkDeviceAddress RayTracingService::getDeviceAddress(VkBuffer buffer) { VkBufferDeviceAddressInfo info{}; info.sType = VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO; info.buffer = buffer; - return ctx.vkGetBufferDeviceAddressKHR(ctx.device.device, &info); + return vulkanContext->vkGetBufferDeviceAddressKHR(vulkanContext->device.device, &info); } void RayTracingService::updateDescriptorSets(VkAccelerationStructureKHR asHandle) { @@ -37,7 +40,7 @@ namespace Metal { } if (needsUpdate) { - descriptorService->Write(vulkanContext, bufferService, descriptor->vkDescriptorSet, descriptor->bindings); + descriptorSetService->Write(descriptor->vkDescriptorSet, descriptor->bindings); } } } @@ -53,12 +56,12 @@ namespace Metal { } anyMeshes = false; // Check if any mesh is present and streamed - auto view = worldRepository.registry.view(); + auto view = worldRepository->registry.view(); for (auto entity: view) { - if (worldRepository.hiddenEntities.contains(entity)) continue; + if (worldRepository->hiddenEntities.contains(entity)) continue; auto &meshComp = view.get(entity); if (meshComp.meshId.empty()) continue; - auto *instance = meshService.stream(meshComp.meshId); + auto *instance = meshService->stream(meshComp.meshId); if (instance != nullptr && instance->dataBuffer != nullptr && instance->indexBuffer != nullptr) { anyMeshes = true; break; @@ -67,7 +70,7 @@ namespace Metal { if (!anyMeshes) { // No meshes – destroy all structures and set descriptor to null - dispose(); // destroys BLAS and TLAS (waits for idle) + dispose(); // destroys BLAS and TLAS (waits for idle) updateDescriptorSets(VK_NULL_HANDLE); accelerationStructureBuilt = false; needsRebuild = false; @@ -75,9 +78,9 @@ namespace Metal { } // At least one mesh exists: rebuild acceleration structures safely - destroyTLAS(); // Destroy old TLAS (waits for idle) before modifying BLAS - buildBLAS(); // Rebuild BLAS (incremental, safe because TLAS is gone) - buildTLAS(); // Build new TLAS + destroyTLAS(); // Destroy old TLAS (waits for idle) before modifying BLAS + buildBLAS(); // Rebuild BLAS (incremental, safe because TLAS is gone) + buildTLAS(); // Build new TLAS if (tlas != VK_NULL_HANDLE) { LOG_INFO("Updating acceleration structures"); @@ -97,21 +100,21 @@ namespace Metal { void RayTracingService::updateMeshMaterials() { bool changed = false; - auto view = worldRepository.registry.view(); + auto view = worldRepository->registry.view(); for (auto entity: view) { - if (worldRepository.hiddenEntities.contains(entity)) continue; + if (worldRepository->hiddenEntities.contains(entity)) continue; auto &meshComp = view.get(entity); if (meshComp.meshId.empty()) continue; if (meshComp.renderIndex < meshMetadata.size()) { - materialService.load(meshMetadata[meshComp.renderIndex], meshComp); + materialService->load(meshMetadata[meshComp.renderIndex], meshComp); changed = true; } } if (changed) { - for (auto *frame : engineContext.registeredFrames) { + for (auto *frame: engineContext->registeredFrames) { auto *meshMetadataBuffer = frame->getResourceAs(RID_MESH_METADATA_BUFFER); if (meshMetadataBuffer != nullptr) { meshMetadataBuffer->update(meshMetadata.data()); @@ -121,26 +124,25 @@ namespace Metal { } void RayTracingService::destroyTLAS() { - auto &vulkan = vulkanContext; - if (vulkan.device.device != VK_NULL_HANDLE) { - vkDeviceWaitIdle(vulkan.device.device); + if (vulkanContext->device.device != VK_NULL_HANDLE) { + vkDeviceWaitIdle(vulkanContext->device.device); } if (tlas != VK_NULL_HANDLE) { - vulkan.vkDestroyAccelerationStructureKHR(vulkan.device.device, tlas, nullptr); + vulkanContext->vkDestroyAccelerationStructureKHR(vulkanContext->device.device, tlas, nullptr); tlas = VK_NULL_HANDLE; } if (tlasBuffer) { - bufferService.dispose("tlas_buffer"); + bufferService->dispose("tlas_buffer"); tlasBuffer = nullptr; } if (instancesBuffer) { - bufferService.dispose("tlas_instances"); + bufferService->dispose("tlas_instances"); instancesBuffer = nullptr; } if (tlasScratchBuffer) { - bufferService.dispose("tlas_scratch"); + bufferService->dispose("tlas_scratch"); tlasScratchBuffer = nullptr; } @@ -152,14 +154,14 @@ namespace Metal { std::unordered_map uniqueMeshes; - auto view = worldRepository.registry.view(); + auto view = worldRepository->registry.view(); for (auto entity: view) { - if (worldRepository.hiddenEntities.contains(entity)) continue; + if (worldRepository->hiddenEntities.contains(entity)) continue; auto &meshComp = view.get(entity); if (meshComp.meshId.empty()) continue; if (uniqueMeshes.contains(meshComp.meshId)) continue; - auto *instance = meshService.stream(meshComp.meshId); + auto *instance = meshService->stream(meshComp.meshId); if (instance == nullptr || instance->dataBuffer == nullptr || instance->indexBuffer == nullptr) { continue; } @@ -176,18 +178,19 @@ namespace Metal { } // If mesh buffers changed, we need to rebuild this BLAS // For now, let's just destroy and re-create below by removing it - if (vulkan.device.device != VK_NULL_HANDLE) { - vulkan.vkDestroyAccelerationStructureKHR(vulkan.device.device, existing.accelerationStructure, - nullptr); + if (vulkanContext->device.device != VK_NULL_HANDLE) { + vulkanContext->vkDestroyAccelerationStructureKHR(vulkanContext->device.device, + existing.accelerationStructure, + nullptr); } if (existing.buffer) - bufferService.dispose("blas_" + meshId); + bufferService->dispose("blas_" + meshId); if (existing.scratchBuffer) - bufferService.dispose("blas_scratch_" + meshId); + bufferService->dispose("blas_scratch_" + meshId); blasEntries.erase(meshId); } - VkDeviceAddress vertexAddress = getDeviceAddress(vulkan, instance->dataBuffer->vkBuffer); - VkDeviceAddress indexAddress = getDeviceAddress(vulkan, instance->indexBuffer->vkBuffer); + VkDeviceAddress vertexAddress = getDeviceAddress(instance->dataBuffer->vkBuffer); + VkDeviceAddress indexAddress = getDeviceAddress(instance->indexBuffer->vkBuffer); VkAccelerationStructureGeometryKHR geometry{}; geometry.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR; @@ -214,22 +217,22 @@ namespace Metal { VkAccelerationStructureBuildSizesInfoKHR sizeInfo{}; sizeInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_SIZES_INFO_KHR; - vulkan.vkGetAccelerationStructureBuildSizesKHR( - vulkan.device.device, + vulkanContext->vkGetAccelerationStructureBuildSizesKHR( + vulkanContext->device.device, VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR, &buildInfo, &primitiveCount, &sizeInfo); BLASEntry entry; - entry.buffer = bufferService.createBuffer( + entry.buffer = bufferService->createBuffer( "blas_" + meshId, sizeInfo.accelerationStructureSize, VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, true); - entry.scratchBuffer = bufferService.createBuffer( + entry.scratchBuffer = bufferService->createBuffer( "blas_scratch_" + meshId, sizeInfo.buildScratchSize, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, @@ -242,11 +245,11 @@ namespace Metal { createInfo.size = sizeInfo.accelerationStructureSize; createInfo.type = VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR; VulkanUtils::CheckVKResult( - vulkan.vkCreateAccelerationStructureKHR(vulkan.device.device, &createInfo, nullptr, - &entry.accelerationStructure)); + vulkanContext->vkCreateAccelerationStructureKHR(vulkanContext->device.device, &createInfo, nullptr, + &entry.accelerationStructure)); buildInfo.dstAccelerationStructure = entry.accelerationStructure; - buildInfo.scratchData.deviceAddress = getDeviceAddress(vulkan, entry.scratchBuffer->vkBuffer); + buildInfo.scratchData.deviceAddress = getDeviceAddress(entry.scratchBuffer->vkBuffer); VkAccelerationStructureBuildRangeInfoKHR rangeInfo{}; rangeInfo.primitiveCount = primitiveCount; @@ -255,9 +258,9 @@ namespace Metal { rangeInfo.transformOffset = 0; const VkAccelerationStructureBuildRangeInfoKHR *pRangeInfo = &rangeInfo; - VkCommandBuffer cmd = vulkan.beginSingleTimeCommands(); - vulkan.vkCmdBuildAccelerationStructuresKHR(cmd, 1, &buildInfo, &pRangeInfo); - vulkan.endSingleTimeCommands(cmd); + VkCommandBuffer cmd = vulkanContext->beginSingleTimeCommands(); + vulkanContext->vkCmdBuildAccelerationStructuresKHR(cmd, 1, &buildInfo, &pRangeInfo); + vulkanContext->endSingleTimeCommands(cmd); entry.vertexData = instance->dataBuffer; entry.indexData = instance->indexBuffer; @@ -266,16 +269,15 @@ namespace Metal { } void RayTracingService::buildTLAS() { - auto &vulkan = vulkanContext; meshMetadata.clear(); if (blasEntries.empty()) return; - if (vulkan.device.device != VK_NULL_HANDLE) { - vkDeviceWaitIdle(vulkan.device.device); + if (vulkanContext->device.device != VK_NULL_HANDLE) { + vkDeviceWaitIdle(vulkanContext->device.device); } std::vector instances; - auto view = worldRepository.registry.view(); + auto view = worldRepository->registry.view(); unsigned int currentInstanceIndex = 0; for (auto entity: view) { @@ -283,7 +285,7 @@ namespace Metal { LOG_ERROR("Max mesh instances reached for ray tracing: " + std::to_string(MAX_MESH_INSTANCES)); break; } - if (worldRepository.hiddenEntities.contains(entity)) continue; + if (worldRepository->hiddenEntities.contains(entity)) continue; auto &meshComp = view.get(entity); if (meshComp.meshId.empty()) continue; @@ -294,12 +296,12 @@ namespace Metal { VkAccelerationStructureDeviceAddressInfoKHR addressInfo{}; addressInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_DEVICE_ADDRESS_INFO_KHR; addressInfo.accelerationStructure = it->second.accelerationStructure; - VkDeviceAddress blasAddress = vulkan.vkGetAccelerationStructureDeviceAddressKHR( - vulkan.device.device, &addressInfo); + VkDeviceAddress blasAddress = vulkanContext->vkGetAccelerationStructureDeviceAddressKHR( + vulkanContext->device.device, &addressInfo); glm::mat4 model = glm::mat4(1.0f); - if (worldRepository.registry.all_of(entity)) { - model = worldRepository.registry.get(entity).model; + if (worldRepository->registry.all_of(entity)) { + model = worldRepository->registry.get(entity).model; } VkTransformMatrixKHR transform{}; @@ -309,8 +311,8 @@ namespace Metal { } } - VkDeviceAddress vertexAddress = getDeviceAddress(vulkan, it->second.vertexData->vkBuffer); - VkDeviceAddress indexAddress = getDeviceAddress(vulkan, it->second.indexData->vkBuffer); + VkDeviceAddress vertexAddress = getDeviceAddress(it->second.vertexData->vkBuffer); + VkDeviceAddress indexAddress = getDeviceAddress(it->second.indexData->vkBuffer); meshComp.renderIndex = currentInstanceIndex; meshMetadata.push_back({meshComp.renderIndex, vertexAddress, indexAddress}); @@ -332,14 +334,14 @@ namespace Metal { updateMeshMaterials(); - instancesBuffer = bufferService.createBuffer( + instancesBuffer = bufferService->createBuffer( "tlas_instances", sizeof(VkAccelerationStructureInstanceKHR) * instances.size(), VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR, instances.data(), true); - VkDeviceAddress instancesAddress = getDeviceAddress(vulkan, instancesBuffer->vkBuffer); + VkDeviceAddress instancesAddress = getDeviceAddress(instancesBuffer->vkBuffer); VkAccelerationStructureGeometryKHR tlasGeometry{}; tlasGeometry.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR; @@ -361,14 +363,14 @@ namespace Metal { VkAccelerationStructureBuildSizesInfoKHR sizeInfo{}; sizeInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_SIZES_INFO_KHR; - vulkan.vkGetAccelerationStructureBuildSizesKHR( - vulkan.device.device, + vulkanContext->vkGetAccelerationStructureBuildSizesKHR( + vulkanContext->device.device, VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR, &buildInfo, &instanceCount, &sizeInfo); - tlasBuffer = bufferService.createBuffer( + tlasBuffer = bufferService->createBuffer( "tlas_buffer", sizeInfo.accelerationStructureSize, VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR, @@ -381,9 +383,9 @@ namespace Metal { createInfo.size = sizeInfo.accelerationStructureSize; createInfo.type = VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR; VulkanUtils::CheckVKResult( - vulkan.vkCreateAccelerationStructureKHR(vulkan.device.device, &createInfo, nullptr, &tlas)); + vulkanContext->vkCreateAccelerationStructureKHR(vulkanContext->device.device, &createInfo, nullptr, &tlas)); - tlasScratchBuffer = bufferService.createBuffer( + tlasScratchBuffer = bufferService->createBuffer( "tlas_scratch", sizeInfo.buildScratchSize, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, @@ -391,23 +393,23 @@ namespace Metal { true); buildInfo.dstAccelerationStructure = tlas; - buildInfo.scratchData.deviceAddress = getDeviceAddress(vulkan, tlasScratchBuffer->vkBuffer); + buildInfo.scratchData.deviceAddress = getDeviceAddress(tlasScratchBuffer->vkBuffer); VkAccelerationStructureBuildRangeInfoKHR rangeInfo{}; rangeInfo.primitiveCount = instanceCount; const VkAccelerationStructureBuildRangeInfoKHR *pRangeInfo = &rangeInfo; - VkCommandBuffer cmd = vulkan.beginSingleTimeCommands(); - vulkan.vkCmdBuildAccelerationStructuresKHR(cmd, 1, &buildInfo, &pRangeInfo); - vulkan.endSingleTimeCommands(cmd); + VkCommandBuffer cmd = vulkanContext->beginSingleTimeCommands(); + vulkanContext->vkCmdBuildAccelerationStructuresKHR(cmd, 1, &buildInfo, &pRangeInfo); + vulkanContext->endSingleTimeCommands(cmd); } void RayTracingService::dispose() { LOG_INFO("Destroying acceleration structures"); auto &vulkan = vulkanContext; - if (vulkan.device.device != VK_NULL_HANDLE) { - vkDeviceWaitIdle(vulkan.device.device); + if (vulkanContext->device.device != VK_NULL_HANDLE) { + vkDeviceWaitIdle(vulkanContext->device.device); } // Destroy TLAS and its buffers @@ -416,13 +418,14 @@ namespace Metal { // Destroy all BLAS entries for (auto &[meshId, entry]: blasEntries) { if (entry.accelerationStructure != VK_NULL_HANDLE) { - vulkan.vkDestroyAccelerationStructureKHR(vulkan.device.device, entry.accelerationStructure, nullptr); + vulkanContext->vkDestroyAccelerationStructureKHR(vulkanContext->device.device, + entry.accelerationStructure, nullptr); entry.accelerationStructure = VK_NULL_HANDLE; } if (entry.buffer) - bufferService.dispose("blas_" + meshId); + bufferService->dispose("blas_" + meshId); if (entry.scratchBuffer) - bufferService.dispose("blas_scratch_" + meshId); + bufferService->dispose("blas_scratch_" + meshId); } blasEntries.clear(); diff --git a/src/engine/service/RayTracingService.h b/src/engine/service/RayTracingService.h index 4ecc20b2..c4325efe 100644 --- a/src/engine/service/RayTracingService.h +++ b/src/engine/service/RayTracingService.h @@ -11,6 +11,7 @@ #include "../../common/IDisposable.h" namespace Metal { + class DescriptorSetService; class BufferInstance; class VulkanContext; class PipelineService; @@ -19,7 +20,6 @@ namespace Metal { class MaterialService; class BufferService; class EngineContext; - class DescriptorService; class RayTracingService final : public IService, public ISync, public IDisposable { VulkanContext *vulkanContext = nullptr; @@ -29,7 +29,7 @@ namespace Metal { MaterialService *materialService = nullptr; BufferService *bufferService = nullptr; EngineContext *engineContext = nullptr; - DescriptorService *descriptorService = nullptr; + DescriptorSetService *descriptorSetService = nullptr; struct BLASEntry { VkAccelerationStructureKHR accelerationStructure = VK_NULL_HANDLE; @@ -58,6 +58,8 @@ namespace Metal { bool needsRebuild = true; bool needsMaterialUpdate = false; + VkDeviceAddress getDeviceAddress(VkBuffer buffer); + void updateDescriptorSets(VkAccelerationStructureKHR asHandle); void buildBLAS(); @@ -80,7 +82,7 @@ namespace Metal { {"MaterialService", materialService}, {"BufferService", bufferService}, {"EngineContext", engineContext}, - {"DescriptorService", descriptorService} + {"DescriptorSetService", descriptorSetService} }; } diff --git a/src/engine/service/ShaderService.cpp b/src/engine/service/ShaderService.cpp index acb0ec4e..30d8b467 100644 --- a/src/engine/service/ShaderService.cpp +++ b/src/engine/service/ShaderService.cpp @@ -167,7 +167,7 @@ namespace Metal { } VkShaderModule ShaderService::createShaderModule(const std::string &pFilename) { - this->isDebugMode = CTX->isDebugMode(); + this->isDebugMode = ctx->isDebugMode(); std::string source = ProcessShader(BASE_PATH + pFilename, BASE_PATH); if (isDebugMode) { source = "#define DEBUG\n" + source; diff --git a/src/engine/service/TextureService.cpp b/src/engine/service/TextureService.cpp index 8505d17f..707322dc 100644 --- a/src/engine/service/TextureService.cpp +++ b/src/engine/service/TextureService.cpp @@ -18,12 +18,14 @@ #include "BufferService.h" #include "PipelineService.h" #include "DescriptorSetService.h" +#include "../../core/DirectoryService.h" +#include "../../common/LoggerUtil.h" namespace Metal { void TextureService::copyBufferToImage(const VkBuffer &vkBuffer, const TextureInstance *image, const int layerCount) const { - VkCommandBuffer commandBuffer = vulkanContext.beginSingleTimeCommands(); + VkCommandBuffer commandBuffer = vulkanContext->beginSingleTimeCommands(); VkBufferImageCopy region{}; region.bufferOffset = 0; @@ -45,31 +47,31 @@ namespace Metal { VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion); - vulkanContext.endSingleTimeCommands(commandBuffer); + vulkanContext->endSingleTimeCommands(commandBuffer); } void TextureService::createImageWithInfo(const VkImageCreateInfo &imageInfo, VkMemoryPropertyFlagBits vkMemoryProperties, TextureInstance *image) const { - if (vkCreateImage(vulkanContext.device.device, &imageInfo, nullptr, &image->vkImage) != VK_SUCCESS) { + if (vkCreateImage(vulkanContext->device.device, &imageInfo, nullptr, &image->vkImage) != VK_SUCCESS) { throw std::runtime_error("failed to create image!"); } VkMemoryRequirements memRequirements; - vkGetImageMemoryRequirements(vulkanContext.device.device, image->vkImage, &memRequirements); + vkGetImageMemoryRequirements(vulkanContext->device.device, image->vkImage, &memRequirements); VkMemoryAllocateInfo allocInfo{}; allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; allocInfo.allocationSize = memRequirements.size; - allocInfo.memoryTypeIndex = bufferService.findMemoryType( + allocInfo.memoryTypeIndex = bufferService->findMemoryType( memRequirements.memoryTypeBits, vkMemoryProperties); - if (vkAllocateMemory(vulkanContext.device.device, &allocInfo, nullptr, &image->vkImageMemory) != + if (vkAllocateMemory(vulkanContext->device.device, &allocInfo, nullptr, &image->vkImageMemory) != VK_SUCCESS) { throw std::runtime_error("failed to allocate image memory!"); } - if (vkBindImageMemory(vulkanContext.device.device, image->vkImage, image->vkImageMemory, 0) != + if (vkBindImageMemory(vulkanContext->device.device, image->vkImage, image->vkImageMemory, 0) != VK_SUCCESS) { throw std::runtime_error("failed to bind image memory!"); } @@ -92,7 +94,7 @@ namespace Metal { samplerInfo.anisotropyEnable = VK_TRUE; samplerInfo.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; - vkCreateSampler(vulkanContext.device.device, &samplerInfo, nullptr, &image->vkSampler); + vkCreateSampler(vulkanContext->device.device, &samplerInfo, nullptr, &image->vkSampler); } void TextureService::createImageView(VkFormat imageFormat, TextureInstance *image) const { @@ -110,7 +112,7 @@ namespace Metal { imageViewInfo.subresourceRange.levelCount = image->mipLevels; imageViewInfo.image = image->vkImage; - vkCreateImageView(vulkanContext.device.device, &imageViewInfo, nullptr, &image->vkImageView); + vkCreateImageView(vulkanContext->device.device, &imageViewInfo, nullptr, &image->vkImageView); } void TextureService::createImage(VkFormat imageFormat, TextureInstance *image, const int width, @@ -133,7 +135,7 @@ namespace Metal { } TextureData *TextureService::loadTextureData(const std::string &id) const { - auto pathToFile = rootDirectory + "/assets/" + FORMAT_FILE_TEXTURE(id); + auto pathToFile = directoryService->getAssetDirectory() + FORMAT_FILE_TEXTURE(id); if (std::filesystem::exists(pathToFile)) { int width, height, channels; unsigned char *data = stbi_load(pathToFile.c_str(), &width, &height, &channels, 0); @@ -171,7 +173,7 @@ namespace Metal { image->vkFormat = imageFormat; LOG_INFO("Loading texture " + id + " from " + pathToImage); LOG_INFO("Texture data: Width " + std::to_string(image->width) + " Height " + std::to_string(image->height)); - BufferInstance *stagingBuffer = bufferService.createBuffer( + BufferInstance *stagingBuffer = bufferService->createBuffer( id + "_staging", image->width * image->height * 4, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); @@ -192,7 +194,7 @@ namespace Metal { void TextureService::transitionImageLayout(const TextureInstance *image, VkImageLayout oldLayout, VkImageLayout newLayout) const { - VkCommandBuffer commandBuffer = vulkanContext.beginSingleTimeCommands(); + VkCommandBuffer commandBuffer = vulkanContext->beginSingleTimeCommands(); VkImageMemoryBarrier barrier{}; barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; barrier.oldLayout = oldLayout; @@ -243,19 +245,19 @@ namespace Metal { 0, nullptr, 1, &barrier); - vulkanContext.endSingleTimeCommands(commandBuffer); + vulkanContext->endSingleTimeCommands(commandBuffer); } void TextureService::generateMipmaps(const TextureInstance *image) const { VkFormatProperties formatProperties; - vkGetPhysicalDeviceFormatProperties(vulkanContext.physDevice.physical_device, image->vkFormat, + vkGetPhysicalDeviceFormatProperties(vulkanContext->physDevice.physical_device, image->vkFormat, &formatProperties); if (!(formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT)) { throw std::runtime_error("texture image format does not support linear blitting!"); } - VkCommandBuffer commandBuffer = vulkanContext.beginSingleTimeCommands(); + VkCommandBuffer commandBuffer = vulkanContext->beginSingleTimeCommands(); VkImageMemoryBarrier barrier{}; barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; @@ -318,11 +320,11 @@ namespace Metal { vkCmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier); - vulkanContext.endSingleTimeCommands(commandBuffer); + vulkanContext->endSingleTimeCommands(commandBuffer); } TextureInstance *TextureService::create(const std::string &id) { - auto pathToFile = rootDirectory + "/assets/" + FORMAT_FILE_TEXTURE(id); + auto pathToFile = directoryService->getAssetDirectory() + FORMAT_FILE_TEXTURE(id); if (std::filesystem::exists(pathToFile)) { auto *instance = loadTexture(id, pathToFile, true, VK_FORMAT_R8G8B8A8_UNORM); if (instance != nullptr) { @@ -371,7 +373,7 @@ namespace Metal { textureIndices[id] = index; // Update all descriptors that contain a texture array - auto descriptors = pipelineService.getAllDescriptors(); + auto descriptors = pipelineService->getAllDescriptors(); for (auto *descriptor: descriptors) { for (auto &binding: descriptor->bindings) { if (binding.descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER && binding.descriptorCount > 1) { @@ -384,12 +386,12 @@ namespace Metal { write.descriptorCount = 1; VkDescriptorImageInfo imageInfo{}; - imageInfo.sampler = vulkanContext.vkTextureSampler; + imageInfo.sampler = vulkanContext->vkTextureSampler; imageInfo.imageView = texture->vkImageView; imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; write.pImageInfo = &imageInfo; - vkUpdateDescriptorSets(vulkanContext.device.device, 1, &write, 0, nullptr); + vkUpdateDescriptorSets(vulkanContext->device.device, 1, &write, 0, nullptr); } } } @@ -400,13 +402,13 @@ namespace Metal { } void TextureService::disposeResource(TextureInstance *resource) { - vkDestroyImage(vulkanContext.device.device, resource->vkImage, nullptr); - vkFreeMemory(vulkanContext.device.device, resource->vkImageMemory, nullptr); - vkDestroyImageView(vulkanContext.device.device, resource->vkImageView, nullptr); - vkDestroySampler(vulkanContext.device.device, resource->vkSampler, nullptr); + vkDestroyImage(vulkanContext->device.device, resource->vkImage, nullptr); + vkFreeMemory(vulkanContext->device.device, resource->vkImageMemory, nullptr); + vkDestroyImageView(vulkanContext->device.device, resource->vkImageView, nullptr); + vkDestroySampler(vulkanContext->device.device, resource->vkSampler, nullptr); if (resource->imageDescriptor != nullptr) { - descriptorSetService.disposeResource(resource->imageDescriptor); + descriptorSetService->disposeResource(resource->imageDescriptor); } } @@ -426,7 +428,7 @@ namespace Metal { samplerCreateInfo.maxAnisotropy = 8; samplerCreateInfo.anisotropyEnable = VK_TRUE; samplerCreateInfo.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK; - VulkanUtils::CheckVKResult(vkCreateSampler(vulkanContext.device.device, &samplerCreateInfo, nullptr, + VulkanUtils::CheckVKResult(vkCreateSampler(vulkanContext->device.device, &samplerCreateInfo, nullptr, &vkImageSampler)); } diff --git a/src/main.cpp b/src/main.cpp index a851954a..bb6fe456 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -50,59 +50,60 @@ #include "engine/EngineContext.h" int main(int, char **) { - Metal::ApplicationContext context{true}; + std::shared_ptr context{}; // --- ORDER MATTERS - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); + context->registerSingleton(context); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); // --- ORDER MATTERS - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); - context.registerSingleton(std::make_unique()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); + context->registerSingleton(std::make_shared()); - context.onInitialize(); - auto &frameService = context.getSingleton(); - auto &directoryService = context.getSingleton(); + context->onInitialize(); + auto &frameService = context->getSingleton(); + auto &directoryService = context->getSingleton(); directoryService.updateRootPath(false); - auto &editor = context.getSingleton(); + Metal::EditorPanel editor{}; + context->injectDependencies(&editor); frameService.setPanel(&editor); if (!frameService.isValidContext()) { @@ -110,6 +111,6 @@ int main(int, char **) { return 1; } frameService.onInitialize(); - context.dispose(); + context->dispose(); return 0; } From a9bd9454eb756a30f3399c3cfd27b164fb3a2255 Mon Sep 17 00:00:00 2001 From: facobackup Date: Sat, 14 Mar 2026 17:27:22 -0300 Subject: [PATCH 07/11] Fixes --- .output.txt | 303 ++++++++++++++++++ src/ApplicationContext.h | 32 +- src/editor/panel/FileImportModalPanel.h | 5 +- src/editor/service/FilesService.cpp | 12 +- src/editor/service/MeshImporterService.h | 2 + src/editor/service/SceneImporterService.cpp | 4 +- src/engine/frame-builder/EngineFrame.cpp | 4 +- src/engine/frame-builder/EngineFrame.h | 2 +- .../frame-builder/EngineFrameBuilder.cpp | 5 +- src/engine/service/BufferService.cpp | 2 + src/engine/service/BufferService.h | 8 +- src/engine/service/MeshService.cpp | 1 + src/engine/service/PipelineService.h | 10 +- src/main.cpp | 2 +- 14 files changed, 369 insertions(+), 23 deletions(-) create mode 100644 .output.txt diff --git a/.output.txt b/.output.txt new file mode 100644 index 00000000..7bda7820 --- /dev/null +++ b/.output.txt @@ -0,0 +1,303 @@ +[23/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\passes\AbstractPass.cpp.obj +C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.cpp(57): warning C4267: 'argument': conversion from 'size_t' to 'uint32_t', possible loss of data +[24/44] Building CXX object CMakeFiles\metal_engine...editor\dock-spaces\header\EditorHeaderPanel.cpp.obj +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(48): warning C4244: 'initializing': conversion from 'int' to 'float', possible loss of data +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(48): warning C4244: 'initializing': conversion from 'int' to 'const float', possible loss of data +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +C:\Users\russi\CLionProjects\metal-engine\src\editor\util\../enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(46): warning C4505: 'Metal::UIUtil::RenderOption': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(52): warning C4505: 'Metal::UIUtil::RenderTooltip': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(66): warning C4505: 'Metal::UIUtil::Spacing': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(72): warning C4505: 'Metal::UIUtil::DynamicSpacing': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(102): warning C4505: 'Metal::UIUtil::DrawVec2Control': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(119): warning C4505: 'Metal::UIUtil::DrawVec3Control': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(159): warning C4505: 'Metal::UIUtil::DrawQuatControl': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(163): warning C4505: 'Metal::UIUtil::GetKeyChordName': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(179): warning C4505: 'Metal::UIUtil::GetEntryIcon': unreferenced function with internal linkage has been removed +[25/44] Building CXX object CMakeFiles\metal_engine.dir\src\ApplicationContext.cpp.obj +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +[26/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\passes\impl\HWRayTracingPass.cpp.obj +C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/MeshMetadata.h(13): warning C4324: 'Metal::MeshMetadata': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\impl\../../service/RayTracingService.h(15): warning C4099: 'Metal::BufferInstance': type name first seen using 'struct' now seen using 'class' +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\DescriptorBinding.h(8): note: see declaration of 'Metal::BufferInstance' +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\common\Inspectable.h(125): warning C4100: 'member': unreferenced parameter +C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed +[27/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\service\LightService.cpp.obj +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/LightData.h(11): warning C4324: 'Metal::LightData': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/LightData.h(12): warning C4324: 'Metal::LightData': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\LightService.h(49): warning C4267: 'return': conversion from 'size_t' to 'unsigned int', possible loss of data +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +C:\Users\russi\CLionProjects\metal-engine\src\common\Inspectable.h(125): warning C4100: 'member': unreferenced parameter +C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed +[28/44] Building CXX object CMakeFiles\metal_engine...c\editor\dock-spaces\viewport\ViewportPanel.cpp.obj +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\../../common/Inspectable.h(125): warning C4100: 'member': unreferenced parameter +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\viewport\../../repository/EditorRepository.h(33): warning C4305: 'initializing': truncation from 'double' to 'float' +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\viewport\../../../engine/repository/WorldRepository.h(15): warning C4099: 'Metal::DirectoryService': type name first seen using 'struct' now seen using 'class' +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\viewport\ViewportPanel.h(13): note: see declaration of 'Metal::DirectoryService' +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(14): warning C4458: declaration of 'entityId' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(31): note: see declaration of 'Metal::AbstractComponent::entityId' +C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed +[29/44] Building CXX object CMakeFiles\metal_engine.dir\src\editor\panel\NotificationsPanel.cpp.obj +C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(48): warning C4244: 'initializing': conversion from 'int' to 'float', possible loss of data +C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(48): warning C4244: 'initializing': conversion from 'int' to 'const float', possible loss of data +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +C:\Users\russi\CLionProjects\metal-engine\src\editor\util\../enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(40): warning C4505: 'Metal::UIUtil::ButtonSimple': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(46): warning C4505: 'Metal::UIUtil::RenderOption': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(52): warning C4505: 'Metal::UIUtil::RenderTooltip': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(60): warning C4505: 'Metal::UIUtil::LargeSpacing': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(66): warning C4505: 'Metal::UIUtil::Spacing': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(72): warning C4505: 'Metal::UIUtil::DynamicSpacing': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(102): warning C4505: 'Metal::UIUtil::DrawVec2Control': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(119): warning C4505: 'Metal::UIUtil::DrawVec3Control': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(159): warning C4505: 'Metal::UIUtil::DrawQuatControl': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(163): warning C4505: 'Metal::UIUtil::GetKeyChordName': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(179): warning C4505: 'Metal::UIUtil::GetEntryIcon': unreferenced function with internal linkage has been removed +[30/44] Building CXX object CMakeFiles\metal_engine...ditor\dock-spaces\viewport\EngineFramePanel.cpp.obj +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\viewport\../../../engine/dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\viewport\../../../engine/dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\viewport\../../../engine/dto/LightData.h(11): warning C4324: 'Metal::LightData': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\viewport\../../../engine/dto/LightData.h(12): warning C4324: 'Metal::LightData': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\viewport\../../../engine/dto/VolumeData.h(11): warning C4324: 'Metal::VolumeData': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\viewport\../../../engine/dto/VolumeData.h(12): warning C4324: 'Metal::VolumeData': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\viewport\../../../engine/dto/MeshMetadata.h(13): warning C4324: 'Metal::MeshMetadata': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\impl\../../dto/PostProcessingPushConstant.h(9): warning C4324: 'Metal::PostProcessingPushConstant': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\impl\../../dto/PostProcessingPushConstant.h(10): warning C4324: 'Metal::PostProcessingPushConstant': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\common\Inspectable.h(125): warning C4100: 'member': unreferenced parameter +C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed +[31/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\service\StreamingService.cpp.obj +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +C:\Users\russi\CLionProjects\metal-engine\src\common\Inspectable.h(125): warning C4100: 'member': unreferenced parameter +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/TextureData.h(16): warning C4244: 'initializing': conversion from 'T' to 'int', possible loss of data + with + [ + T=float + ] +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/TextureData.h(16): warning C4244: 'initializing': conversion from 'T' to 'const int', possible loss of data + with + [ + T=float + ] +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/TextureData.h(17): warning C4244: 'initializing': conversion from 'T' to 'int', possible loss of data + with + [ + T=float + ] +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/TextureData.h(17): warning C4244: 'initializing': conversion from 'T' to 'const int', possible loss of data + with + [ + T=float + ] +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(14): warning C4458: declaration of 'entityId' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(31): note: see declaration of 'Metal::AbstractComponent::entityId' +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/PrimitiveComponent.h(20): warning C4305: 'initializing': truncation from 'double' to 'float' +C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed +[32/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\service\CameraService.cpp.obj +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\../../common/Inspectable.h(125): warning C4100: 'member': unreferenced parameter +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed +[33/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\EngineContext.cpp.obj +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/MeshMetadata.h(13): warning C4324: 'Metal::MeshMetadata': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\service/RayTracingService.h(15): warning C4099: 'Metal::BufferInstance': type name first seen using 'struct' now seen using 'class' +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../resource/BufferInstance.h(14): note: see declaration of 'Metal::BufferInstance' +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/LightData.h(11): warning C4324: 'Metal::LightData': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/LightData.h(12): warning C4324: 'Metal::LightData': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\service/LightService.h(49): warning C4267: 'return': conversion from 'size_t' to 'unsigned int', possible loss of data +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/VolumeData.h(11): warning C4324: 'Metal::VolumeData': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/VolumeData.h(12): warning C4324: 'Metal::VolumeData': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\service/VolumeService.h(32): warning C4267: 'return': conversion from 'size_t' to 'unsigned int', possible loss of data +C:\Users\russi\CLionProjects\metal-engine\src\common\Inspectable.h(125): warning C4100: 'member': unreferenced parameter +C:\Users\russi\CLionProjects\metal-engine\src\engine\../editor/repository/EditorRepository.h(33): warning C4305: 'initializing': truncation from 'double' to 'float' +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(14): warning C4458: declaration of 'entityId' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(31): note: see declaration of 'Metal::AbstractComponent::entityId' +C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed +[34/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\passes\impl\PostProcessingPass.cpp.obj +C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\impl\../../dto/PostProcessingPushConstant.h(9): warning C4324: 'Metal::PostProcessingPushConstant': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\impl\../../dto/PostProcessingPushConstant.h(10): warning C4324: 'Metal::PostProcessingPushConstant': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\common\Inspectable.h(125): warning C4100: 'member': unreferenced parameter +C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed +[35/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\frame-builder\EngineFrame.cpp.obj +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +[36/44] Building CXX object CMakeFiles\metal_engine...src\engine\frame-builder\EngineFrameBuilder.cpp.obj +FAILED: CMakeFiles/metal_engine.dir/src/engine/frame-builder/EngineFrameBuilder.cpp.obj +C:\PROGRA~1\MICROS~2\18\COMMUN~1\VC\Tools\MSVC\1450~1.357\bin\Hostx64\x64\cl.exe /nologo /TP -DBOOST_IOSTREAMS_DYN_LINK -DBOOST_IOSTREAMS_NO_LIB -DBOOST_RANDOM_DYN_LINK -DBOOST_RANDOM_NO_LIB -DFMT_SHARED -DGLFW_DLL -DIMATH_DLL -DIMGUI_ENABLE_FREETYPE -DMESHOPTIMIZER_API=__declspec(dllimport) -DNFD_SHARED -DNOMINMAX -DOPENVDB_ABI_VERSION_NUMBER=12 -DOPENVDB_DLL -DOPENVDB_USE_DELAYED_LOADING -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -DTBB_USE_DEBUG -D_WIN32 -IC:\Users\russi\CLionProjects\metal-engine\dependencies\vk-bootstrap\src -external:IC:\Users\russi\CLionProjects\metal-engine\cmake-build-debug-visual-studio\vcpkg_installed\x64-windows\include -external:IC:\Users\russi\CLionProjects\metal-engine\cmake-build-debug-visual-studio\vcpkg_installed\x64-windows\include\vma -external:IC:\Users\russi\CLionProjects\metal-engine\cmake-build-debug-visual-studio\vcpkg_installed\x64-windows\include\Imath -external:W0 /DWIN32 /D_WINDOWS /EHsc -DVK_PROTOTYPES /Ob0 /Od /RTC1 -std:c++20 -MDd -Zi /W4 /wd4251 /wd4275 /utf-8 /EHsc /showIncludes @CMakeFiles\metal_engine.dir\src\engine\frame-builder\EngineFrameBuilder.cpp.obj.modmap /FoCMakeFiles\metal_engine.dir\src\engine\frame-builder\EngineFrameBuilder.cpp.obj /FdCMakeFiles\metal_engine.dir\ /FS -c C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\EngineFrameBuilder.cpp +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\xmemory(734): error C2672: 'std::construct_at': no matching overloaded function found +C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\xutility(507): note: could be '_Ty *std::construct_at(_Ty *const ,_Types ...) noexcept()' +C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\xmemory(734): note: the associated constraints are not satisfied +C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\xutility(505): note: 'std::unique_ptr>::unique_ptr(const std::unique_ptr> &)': attempting to reference a deleted function +C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\memory(3504): note: see declaration of 'std::unique_ptr>::unique_ptr' +C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\memory(3504): note: 'std::unique_ptr>::unique_ptr(const std::unique_ptr> &)': function was explicitly deleted +C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\xutility(505): note: 'std::unique_ptr>::unique_ptr(const std::unique_ptr> &)': attempting to reference a deleted function +C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\memory(3504): note: see declaration of 'std::unique_ptr>::unique_ptr' +C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\memory(3504): note: 'std::unique_ptr>::unique_ptr(const std::unique_ptr> &)': function was explicitly deleted +C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\xmemory(734): note: the template instantiation context (the oldest one first) is +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\EngineFrameBuilder.cpp(127): note: see reference to class template instantiation 'std::vector>,std::allocator>>>' being compiled +C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\vector(745): note: while compiling class template member function 'std::vector>,std::allocator>>>::vector(const std::vector>,std::allocator>>> &)' +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\EngineFrameBuilder.cpp(132): note: see the first reference to 'std::vector>,std::allocator>>>::vector' in 'Metal::EngineFrameBuilder::build' +C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\vector(749): note: see reference to function template instantiation 'void std::vector>,std::allocator>>>::_Construct_n>*const &,std::unique_ptr>*const &>(const unsigned __int64,std::unique_ptr> *const &,std::unique_ptr> *const &)' being compiled +C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\vector(2120): note: see reference to function template instantiation 'std::unique_ptr> *std::_Uninitialized_copy>*,std::unique_ptr>*,std::allocator>>>(_InIt,_Se,std::unique_ptr> *,_Alloc &)' being compiled + with + [ + _InIt=std::unique_ptr> *, + _Se=std::unique_ptr> *, + _Alloc=std::allocator>> + ] +C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\xmemory(1922): note: see reference to function template instantiation 'void std::_Uninitialized_backout_al>>>::_Emplace_back>&>(std::unique_ptr> &)' being compiled +C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\xmemory(1864): note: see reference to function template instantiation 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,std::unique_ptr>&>(_Alloc &,_Objty *const ,std::unique_ptr> &)' being compiled + with + [ + _Alloc=std::allocator>>, + _Ty=std::unique_ptr>, + _Objty=std::unique_ptr> + ] +[37/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\enum\ComponentType.cpp.obj +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +C:\Users\russi\CLionProjects\metal-engine\src\common\Inspectable.h(125): warning C4100: 'member': unreferenced parameter +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/MeshMetadata.h(13): warning C4324: 'Metal::MeshMetadata': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\enum\../service/RayTracingService.h(15): warning C4099: 'Metal::BufferInstance': type name first seen using 'struct' now seen using 'class' +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../resource/BufferInstance.h(14): note: see declaration of 'Metal::BufferInstance' +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(14): warning C4458: declaration of 'entityId' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(31): note: see declaration of 'Metal::AbstractComponent::entityId' +C:\Users\russi\CLionProjects\metal-engine\src\engine\enum\../dto/PrimitiveComponent.h(20): warning C4305: 'initializing': truncation from 'double' to 'float' +C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed +[38/44] Building CXX object CMakeFiles\metal_engine...engine\passes\impl\TemporalAccumulationPass.cpp.obj +C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +[39/44] Building CXX object CMakeFiles\metal_engine.dir\src\main.cpp.obj +C:\Users\russi\CLionProjects\metal-engine\src\editor\dto\../../common//Inspectable.h(125): warning C4100: 'member': unreferenced parameter +C:\Users\russi\CLionProjects\metal-engine\src\editor\service\../../common/AbstractImporter.h(19): warning C4100: 'stopToken': unreferenced parameter +C:\Users\russi\CLionProjects\metal-engine\src\editor\service\../../common/AbstractImporter.h(18): warning C4100: 'settings': unreferenced parameter +C:\Users\russi\CLionProjects\metal-engine\src\editor\service\../../common/AbstractImporter.h(17): warning C4100: 'pathToFile': unreferenced parameter +C:\Users\russi\CLionProjects\metal-engine\src\editor\service\../../common/AbstractImporter.h(17): warning C4100: 'targetDir': unreferenced parameter +C:\Users\russi\CLionProjects\metal-engine\src\editor/service/TextureImporterService.h(8): warning C4099: 'Metal::DirectoryService': type name first seen using 'struct' now seen using 'class' +C:\Users\russi\CLionProjects\metal-engine\src\core/DirectoryService.h(11): note: see declaration of 'Metal::DirectoryService' +C:\Users\russi\CLionProjects\metal-engine\src\editor/service/VoxelImporterService.h(9): warning C4099: 'Metal::DirectoryService': type name first seen using 'struct' now seen using 'class' +C:\Users\russi\CLionProjects\metal-engine\src\core/DirectoryService.h(11): note: see declaration of 'Metal::DirectoryService' +C:\Users\russi\CLionProjects\metal-engine\src\editor/repository/EditorRepository.h(33): warning C4305: 'initializing': truncation from 'double' to 'float' +C:\Users\russi\CLionProjects\metal-engine\src\engine/repository/WorldRepository.h(15): warning C4099: 'Metal::DirectoryService': type name first seen using 'struct' now seen using 'class' +C:\Users\russi\CLionProjects\metal-engine\src\core/DirectoryService.h(11): note: see declaration of 'Metal::DirectoryService' +C:\Users\russi\CLionProjects\metal-engine\src\engine/service/CommandBufferRecorderService.h(10): warning C4100: 'resource': unreferenced parameter +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/LightData.h(11): warning C4324: 'Metal::LightData': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/LightData.h(12): warning C4324: 'Metal::LightData': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine/service/LightService.h(49): warning C4267: 'return': conversion from 'size_t' to 'unsigned int', possible loss of data +C:\Users\russi\CLionProjects\metal-engine\src\engine/service/MeshService.h(14): warning C4099: 'Metal::DirectoryService': type name first seen using 'struct' now seen using 'class' +C:\Users\russi\CLionProjects\metal-engine\src\core/DirectoryService.h(11): note: see declaration of 'Metal::DirectoryService' +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/MeshMetadata.h(13): warning C4324: 'Metal::MeshMetadata': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine/service/RayTracingService.h(15): warning C4099: 'Metal::BufferInstance': type name first seen using 'struct' now seen using 'class' +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../resource/BufferInstance.h(14): note: see declaration of 'Metal::BufferInstance' +C:\Users\russi\CLionProjects\metal-engine\src\engine/service/ShaderService.h(10): warning C4099: 'Metal::DirectoryService': type name first seen using 'struct' now seen using 'class' +C:\Users\russi\CLionProjects\metal-engine\src\core/DirectoryService.h(11): note: see declaration of 'Metal::DirectoryService' +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/TextureData.h(16): warning C4244: 'initializing': conversion from 'T' to 'int', possible loss of data + with + [ + T=float + ] +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/TextureData.h(16): warning C4244: 'initializing': conversion from 'T' to 'const int', possible loss of data + with + [ + T=float + ] +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/TextureData.h(17): warning C4244: 'initializing': conversion from 'T' to 'int', possible loss of data + with + [ + T=float + ] +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/TextureData.h(17): warning C4244: 'initializing': conversion from 'T' to 'const int', possible loss of data + with + [ + T=float + ] +C:\Users\russi\CLionProjects\metal-engine\src\engine/service/TextureService.h(17): warning C4099: 'Metal::DirectoryService': type name first seen using 'struct' now seen using 'class' +C:\Users\russi\CLionProjects\metal-engine\src\core/DirectoryService.h(11): note: see declaration of 'Metal::DirectoryService' +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/VolumeData.h(11): warning C4324: 'Metal::VolumeData': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/VolumeData.h(12): warning C4324: 'Metal::VolumeData': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine/service/VolumeService.h(32): warning C4267: 'return': conversion from 'size_t' to 'unsigned int', possible loss of data +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\service\../enum/NotificationSeverity.h(14): warning C4505: 'Metal::NotificationSeverities::GetIcon': unreferenced function with internal linkage has been removed +C:\Users\russi\CLionProjects\metal-engine\src\editor\service\../enum/NotificationSeverity.h(26): warning C4505: 'Metal::NotificationSeverities::GetColor': unreferenced function with internal linkage has been removed +[40/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\passes\impl\SpatialFilterPass.cpp.obj +C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +[41/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\service\RayTracingService.cpp.obj +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/MeshMetadata.h(13): warning C4324: 'Metal::MeshMetadata': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../resource/BufferInstance.h(14): warning C4099: 'Metal::BufferInstance': type name first seen using 'class' now seen using 'struct' +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../resource/BufferInstance.h(14): note: see declaration of 'Metal::BufferInstance' +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\../../common/Inspectable.h(125): warning C4100: 'member': unreferenced parameter +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(14): warning C4458: declaration of 'entityId' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(31): note: see declaration of 'Metal::AbstractComponent::entityId' +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/PrimitiveComponent.h(20): warning C4305: 'initializing': truncation from 'double' to 'float' +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\RayTracingService.cpp(153): warning C4189: 'vulkan': local variable is initialized but not referenced +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\RayTracingService.cpp(409): warning C4189: 'vulkan': local variable is initialized but not referenced +C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed +[42/44] Building CXX object CMakeFiles\metal_engine.dir\src\core\FrameService.cpp.obj +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +C:\Users\russi\CLionProjects\metal-engine\src\core\FrameService.cpp(26): warning C4458: declaration of 'panel' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\core\FrameService.h(19): note: see declaration of 'Metal::FrameService::panel' +[43/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\service\VolumeService.cpp.obj +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/VolumeData.h(11): warning C4324: 'Metal::VolumeData': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/VolumeData.h(12): warning C4324: 'Metal::VolumeData': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\service\VolumeService.h(32): warning C4267: 'return': conversion from 'size_t' to 'unsigned int', possible loss of data +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\../../common/Inspectable.h(125): warning C4100: 'member': unreferenced parameter +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(14): warning C4458: declaration of 'entityId' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(31): note: see declaration of 'Metal::AbstractComponent::entityId' +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member +C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' +C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed +ninja: build stopped: subcommand failed. \ No newline at end of file diff --git a/src/ApplicationContext.h b/src/ApplicationContext.h index 54ba00fd..46c9dc6b 100644 --- a/src/ApplicationContext.h +++ b/src/ApplicationContext.h @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include "common/IInit.h" #include "common/IContextMember.h" @@ -23,6 +25,22 @@ namespace Metal { std::vector > instances; bool debugMode; + template + static std::string getTypeName() { + std::string name = typeid(T).name(); + size_t lastSpace = name.find_last_of(' '); + if (lastSpace != std::string::npos) { + name = name.substr(lastSpace + 1); + } + size_t lastColon = name.find_last_of(':'); + if (lastColon != std::string::npos) { + name = name.substr(lastColon + 1); + } + std::transform(name.begin(), name.end(), name.begin(), + [](unsigned char c) { return std::tolower(c); }); + return name; + } + public: explicit ApplicationContext(bool debugMode); @@ -32,23 +50,27 @@ namespace Metal { void registerSingleton(std::shared_ptr instance) { static_assert(std::is_base_of_v, "T must derive from IContextMember"); T *ptr = instance.get(); - singletons[typeid(T).name()] = static_cast(ptr); + singletons[getTypeName()] = static_cast(ptr); instances.push_back(std::move(instance)); } template T &getSingleton() { - auto it = singletons.find(typeid(T).name()); + auto name = getTypeName(); + auto it = singletons.find(name); if (it == singletons.end()) { - throw std::runtime_error(std::string("Singleton not registered: ") + typeid(T).name()); + throw std::runtime_error(std::string("Singleton not registered: ") + name); } return *static_cast(it->second); } void *getSingletonByName(const std::string &name) { - auto it = singletons.find(name); + std::string lowerName = name; + std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), + [](unsigned char c) { return std::tolower(c); }); + auto it = singletons.find(lowerName); if (it == singletons.end()) { - throw std::runtime_error(std::string("Singleton not registered: ") + name); + throw std::runtime_error(std::string("Singleton not registered: ") + lowerName); } return it->second; } diff --git a/src/editor/panel/FileImportModalPanel.h b/src/editor/panel/FileImportModalPanel.h index 89c0849b..f3f5f713 100644 --- a/src/editor/panel/FileImportModalPanel.h +++ b/src/editor/panel/FileImportModalPanel.h @@ -3,6 +3,7 @@ #include "../abstract/AbstractPanel.h" namespace Metal { + class FilesService; class FormPanel; struct EditorRepository; class FileImporterService; @@ -15,13 +16,15 @@ namespace Metal { EditorRepository *editorRepository = nullptr; FileImporterService *fileImporterService = nullptr; NotificationService *notificationService = nullptr; + FilesService *filesService = nullptr; public: std::vector getDependencies() override { return { {"EditorRepository", editorRepository}, {"FileImporterService", fileImporterService}, - {"NotificationService", notificationService} + {"NotificationService", notificationService}, + {"FilesService", filesService} }; } diff --git a/src/editor/service/FilesService.cpp b/src/editor/service/FilesService.cpp index 5b59131f..8813ccaf 100644 --- a/src/editor/service/FilesService.cpp +++ b/src/editor/service/FilesService.cpp @@ -27,14 +27,14 @@ std::filesystem::remove_all(rootDir + "/assets/" + F(entry.second->getId())); std::filesystem::file_time_type ftime = last_write_time(entry); namespace Metal { - void filesService->onInitialize() { + void FilesService::onInitialize() { root = new FSEntry(nullptr, directoryService->getAssetRefDirectory(), ""); root->type = EntryType::DIRECTORY; root->name = "Files"; GetEntries(root); } - std::unique_ptr filesService->getResource(const std::string &id) { + std::unique_ptr FilesService::getResource(const std::string &id) { try { for (const auto &entry: fs::recursive_directory_iterator(root->absolutePath)) { if (entry.is_regular_file() && @@ -57,7 +57,7 @@ namespace Metal { return nullptr; } - void filesService->deleteFiles(const std::unordered_map &selected) { + void FilesService::deleteFiles(const std::unordered_map &selected) { for (auto &entry: selected) { switch (entry.second->type) { case EntryType::DIRECTORY: { @@ -91,7 +91,7 @@ namespace Metal { } } - void filesService->CreateDirectory(FSEntry *currentDirectory) { + void FilesService::CreateDirectory(FSEntry *currentDirectory) { int count = 0; for (FSEntry *child: currentDirectory->children) { if (child->type == EntryType::DIRECTORY && child->name == "New Directory (" + std::to_string(count) + ")") { @@ -105,7 +105,7 @@ namespace Metal { std::filesystem::create_directory(pathToDir); } - void filesService->Move(FSEntry *toMove, FSEntry *targetDir) { + void FilesService::Move(FSEntry *toMove, FSEntry *targetDir) { if (!targetDir || targetDir->type != EntryType::DIRECTORY) { return; } @@ -133,7 +133,7 @@ namespace Metal { targetDir->children.push_back(toMove); } - void filesService->GetEntries(FSEntry *root) { + void FilesService::GetEntries(FSEntry *root) { if (root->type != EntryType::DIRECTORY) { return; } diff --git a/src/editor/service/MeshImporterService.h b/src/editor/service/MeshImporterService.h index 360be3a5..aa9c33fe 100644 --- a/src/editor/service/MeshImporterService.h +++ b/src/editor/service/MeshImporterService.h @@ -9,6 +9,8 @@ #include namespace Metal { + struct DirectoryService; + struct MeshId { std::string id; glm::vec3 gizmoCenter; diff --git a/src/editor/service/SceneImporterService.cpp b/src/editor/service/SceneImporterService.cpp index 86ac3a29..ce925d01 100644 --- a/src/editor/service/SceneImporterService.cpp +++ b/src/editor/service/SceneImporterService.cpp @@ -59,7 +59,7 @@ namespace Metal { throw std::runtime_error("Import cancelled"); } - meshImporterService.persistAllMeshes(targetDir, scene, meshMap, stopToken); + meshImporterService->persistAllMeshes(targetDir, scene, meshMap, stopToken); if (stopToken.stop_requested()) { throw std::runtime_error("Import cancelled"); @@ -133,7 +133,7 @@ namespace Metal { childMeshNode.entity.name = assimpMesh->mName.length > 0 ? assimpMesh->mName.data : "Mesh"; const aiMaterial *material = aiScene->mMaterials[assimpMesh->mMaterialIndex]; - materialImporterService.importMaterial(targetDir, material, aiScene, rootDirectory, + materialImporterService->importMaterial(targetDir, material, aiScene, rootDirectory, *childMeshNode.primitive, stopToken); } } diff --git a/src/engine/frame-builder/EngineFrame.cpp b/src/engine/frame-builder/EngineFrame.cpp index 49d71f48..66e5bb4a 100644 --- a/src/engine/frame-builder/EngineFrame.cpp +++ b/src/engine/frame-builder/EngineFrame.cpp @@ -12,9 +12,9 @@ namespace Metal { } } - void EngineFrame::addPass(CommandBufferRecorder *recorder, const std::vector> &p) { + void EngineFrame::addPass(CommandBufferRecorder *recorder, std::vector> p) { if (recorder) { - passes.emplace_back(recorder, p); + passes.emplace_back(recorder, std::move(p)); } } diff --git a/src/engine/frame-builder/EngineFrame.h b/src/engine/frame-builder/EngineFrame.h index 9ea82210..992c611a 100644 --- a/src/engine/frame-builder/EngineFrame.h +++ b/src/engine/frame-builder/EngineFrame.h @@ -38,7 +38,7 @@ namespace Metal { return nullptr; } - void addPass(CommandBufferRecorder *recorder, const std::vector> &p); + void addPass(CommandBufferRecorder *recorder, std::vector> p); void onSync(); diff --git a/src/engine/frame-builder/EngineFrameBuilder.cpp b/src/engine/frame-builder/EngineFrameBuilder.cpp index 8d3359a8..7693f009 100644 --- a/src/engine/frame-builder/EngineFrameBuilder.cpp +++ b/src/engine/frame-builder/EngineFrameBuilder.cpp @@ -129,7 +129,10 @@ namespace Metal { for (const auto &cbId: recorderOrder) { if (auto *recorder = dynamic_cast(builtResources.at(cbId))) { - frame->addPass(recorder, recorderToPasses[cbId]); + auto it = recorderToPasses.find(cbId); + if (it != recorderToPasses.end() && !it->second.empty()) { + frame->addPass(recorder, std::move(it->second)); + } } } diff --git a/src/engine/service/BufferService.cpp b/src/engine/service/BufferService.cpp index d6523bf1..3078cd54 100644 --- a/src/engine/service/BufferService.cpp +++ b/src/engine/service/BufferService.cpp @@ -5,6 +5,8 @@ #include "../resource/BufferInstance.h" namespace Metal { + + BufferInstance *BufferService::createBuffer(const std::string &id, VkDeviceSize bufferSize, VkBufferUsageFlags usageFlags, VkMemoryPropertyFlags memoryPropertyFlags, BufferType type) { diff --git a/src/engine/service/BufferService.h b/src/engine/service/BufferService.h index 4c77aa73..4fac84e6 100644 --- a/src/engine/service/BufferService.h +++ b/src/engine/service/BufferService.h @@ -21,9 +21,11 @@ namespace Metal { BufferInstance *buffer) const; public: - BufferService() = default; - - std::vector getDependencies() override; + std::vector getDependencies() override { + return { + {"VulkanContext", &vulkanContext} + }; + } [[nodiscard]] unsigned int findMemoryType(unsigned int typeFilter, VkMemoryPropertyFlags properties) const; diff --git a/src/engine/service/MeshService.cpp b/src/engine/service/MeshService.cpp index 417887bf..4394c482 100644 --- a/src/engine/service/MeshService.cpp +++ b/src/engine/service/MeshService.cpp @@ -5,6 +5,7 @@ #include "../../core/vulkan/VulkanContext.h" #include "../../common/FilesUtil.h" +#include "../../common/LoggerUtil.h" #include "../../core/DirectoryService.h" #include diff --git a/src/engine/service/PipelineService.h b/src/engine/service/PipelineService.h index a80bbe1f..2c134925 100644 --- a/src/engine/service/PipelineService.h +++ b/src/engine/service/PipelineService.h @@ -27,7 +27,15 @@ namespace Metal { public: PipelineService() = default; - std::vector getDependencies() override; + std::vector getDependencies() override { + return { + {"VulkanContext", &vulkanContext}, + {"FramebufferService", &framebufferService}, + {"BufferService", &bufferService}, + {"DescriptorSetService", &descriptorSetService}, + {"ShaderService", &shaderService} + }; + } PipelineInstance *createPipeline(PipelineBuilder &pipelineBuilder); diff --git a/src/main.cpp b/src/main.cpp index bb6fe456..8c08e1ab 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -50,7 +50,7 @@ #include "engine/EngineContext.h" int main(int, char **) { - std::shared_ptr context{}; + std::shared_ptr context = std::make_shared(false); // --- ORDER MATTERS context->registerSingleton(context); From e10d7fb732f13f66b8e2a9ebf249a14c1da0f332 Mon Sep 17 00:00:00 2001 From: facobackup Date: Sat, 14 Mar 2026 18:29:57 -0300 Subject: [PATCH 08/11] Fixes --- resources/shaders/rt/HWRayTracing.rgen | 2 + resources/shaders/tools/Icon.frag | 90 ------------------- src/ApplicationContext.cpp | 19 ++-- src/common/AbstractResourceService.h | 9 +- src/common/IContextMember.cpp | 5 +- src/common/IContextMember.h | 2 +- src/core/DirectoryService.cpp | 9 ++ src/core/DirectoryService.h | 16 ++-- src/core/FrameService.cpp | 8 +- src/core/FrameService.h | 14 ++- src/core/glfw/GLFWContext.cpp | 2 +- src/core/glfw/GLFWContext.h | 6 +- src/core/gui/GuiContext.cpp | 2 +- src/core/gui/GuiContext.h | 10 +-- src/core/vulkan/VulkanContext.cpp | 12 +-- src/core/vulkan/VulkanContext.h | 18 ++-- src/editor/EditorPanel.cpp | 8 +- src/editor/EditorPanel.h | 4 +- src/editor/abstract/AbstractPanel.cpp | 7 +- src/editor/abstract/AbstractPanel.h | 2 +- .../abstract/form/AbstractFormFieldPanel.h | 2 +- src/editor/abstract/form/FormPanel.cpp | 6 +- .../abstract/form/types/ResourceField.cpp | 2 +- .../abstract/form/types/ResourceField.h | 2 +- .../dock-spaces/docks/DockSpacePanel.cpp | 2 +- src/editor/dock-spaces/docks/DockSpacePanel.h | 4 +- .../dock-spaces/files/FilePreviewPanel.h | 4 +- .../dock-spaces/files/FilesHeaderPanel.h | 2 +- src/editor/dock-spaces/files/FilesListPanel.h | 2 +- src/editor/dock-spaces/files/FilesPanel.cpp | 6 +- src/editor/dock-spaces/files/FilesPanel.h | 14 +-- .../dock-spaces/footer/EditorFooterPanel.cpp | 5 +- .../dock-spaces/footer/EditorFooterPanel.h | 2 +- .../dock-spaces/header/AsyncTaskPanel.h | 2 +- .../dock-spaces/header/EditorHeaderPanel.cpp | 19 ++-- .../dock-spaces/header/EditorHeaderPanel.h | 6 +- .../dock-spaces/inspector/InspectorPanel.cpp | 2 +- .../dock-spaces/inspector/InspectorPanel.h | 4 +- src/editor/dock-spaces/metrics/MetricsPanel.h | 12 +-- .../repositories/RepositoriesPanel.cpp | 2 +- .../repositories/RepositoriesPanel.h | 7 +- .../viewport/CameraPositionPanel.h | 2 +- .../dock-spaces/viewport/EngineFramePanel.h | 12 +-- src/editor/dock-spaces/viewport/GizmoPanel.h | 6 +- .../dock-spaces/viewport/GizmoSettingsPanel.h | 4 +- .../viewport/ViewportHeaderPanel.cpp | 2 +- .../viewport/ViewportHeaderPanel.h | 4 +- .../dock-spaces/viewport/ViewportPanel.cpp | 8 +- .../dock-spaces/viewport/ViewportPanel.h | 14 +-- .../dock-spaces/world/WorldHeaderPanel.h | 2 +- src/editor/dock-spaces/world/WorldPanel.cpp | 2 +- src/editor/dock-spaces/world/WorldPanel.h | 8 +- src/editor/panel/FileImportModalPanel.cpp | 2 +- src/editor/panel/FileImportModalPanel.h | 8 +- src/editor/panel/NotificationsPanel.h | 4 +- src/editor/passes/GridPass.h | 6 +- src/editor/passes/SelectionIDPass.h | 8 +- src/editor/passes/SelectionOutlinePass.h | 4 +- src/editor/service/DockService.cpp | 4 +- src/editor/service/FileImporterService.h | 10 +-- src/editor/service/FilesService.h | 4 +- src/editor/service/MaterialImporterService.h | 2 +- src/editor/service/MeshImporterService.h | 2 +- src/editor/service/PickingService.h | 6 +- src/editor/service/SceneImporterService.h | 6 +- src/editor/service/SelectionService.h | 4 +- src/editor/service/TextureImporterService.h | 2 +- src/editor/service/ThemeService.h | 2 +- src/editor/service/VoxelImporterService.h | 2 +- src/engine/EngineContext.cpp | 3 +- src/engine/EngineContext.h | 18 ++-- src/engine/frame-builder/EngineFrameBuilder.h | 2 +- .../frame-builder/structures/BufferBuilder.h | 2 +- .../structures/CommandBufferRecorderBuilder.h | 4 +- .../structures/FramebufferBuilder.h | 2 +- .../frame-builder/structures/TextureBuilder.h | 2 +- src/engine/passes/CommandBufferRecorder.cpp | 6 +- src/engine/passes/CommandBufferRecorder.h | 10 ++- src/engine/passes/impl/HWRayTracingPass.h | 10 +-- src/engine/passes/impl/PostProcessingPass.h | 6 +- src/engine/passes/impl/SpatialFilterPass.h | 2 +- .../passes/impl/TemporalAccumulationPass.h | 2 +- src/engine/repository/WorldRepository.h | 4 +- src/engine/resource/FrameBufferAttachment.cpp | 4 - src/engine/resource/FrameBufferAttachment.h | 7 ++ src/engine/resource/RuntimeResource.h | 2 +- src/engine/service/CameraService.h | 6 +- src/engine/service/DescriptorSetService.h | 8 +- src/engine/service/FrameBufferService.cpp | 1 + src/engine/service/FrameBufferService.h | 2 +- src/engine/service/LightService.h | 4 +- src/engine/service/MaterialService.h | 2 +- src/engine/service/MeshService.h | 6 +- src/engine/service/RayTracingService.cpp | 3 - src/engine/service/RayTracingService.h | 16 ++-- src/engine/service/ShaderService.cpp | 23 +++-- src/engine/service/ShaderService.h | 14 +-- src/engine/service/StreamingService.h | 10 +-- src/engine/service/TextureService.h | 10 +-- src/engine/service/TransformService.h | 4 +- src/engine/service/VolumeService.h | 4 +- src/main.cpp | 7 +- 102 files changed, 320 insertions(+), 378 deletions(-) delete mode 100644 resources/shaders/tools/Icon.frag diff --git a/resources/shaders/rt/HWRayTracing.rgen b/resources/shaders/rt/HWRayTracing.rgen index c09ac1bd..69e273fc 100644 --- a/resources/shaders/rt/HWRayTracing.rgen +++ b/resources/shaders/rt/HWRayTracing.rgen @@ -1,4 +1,6 @@ #extension GL_EXT_ray_tracing: require +#define ITEM_TYPE_SPHERE 0 +#define ITEM_TYPE_PLANE 1 #include "../GlobalDataBuffer.glsl" #include "../rt/HWRayTracingPushConstant.glsl" diff --git a/resources/shaders/tools/Icon.frag b/resources/shaders/tools/Icon.frag deleted file mode 100644 index 4a281c2a..00000000 --- a/resources/shaders/tools/Icon.frag +++ /dev/null @@ -1,90 +0,0 @@ -#include "../GlobalDataBuffer.glsl" -#include "../CreateRay.glsl" - -#define LIGHT_SET 1 -#include "../LightBuffer.glsl" - -layout (location = 0) in vec2 texCoords; -layout (location = 0) out vec4 finalColor; - -float sdSphere(vec3 p, float s, in vec3 translation){ - return length(p - translation)-s; -} -float dot2(vec3 v) { - return dot(v, v); -} -float udQuad(vec3 p, vec3 a, vec3 b, vec3 c, vec3 d) -{ - vec3 ba = b - a; vec3 pa = p - a; - vec3 cb = c - b; vec3 pb = p - b; - vec3 dc = d - c; vec3 pc = p - c; - vec3 ad = a - d; vec3 pd = p - d; - vec3 nor = cross(ba, ad); - - return sqrt( - (sign(dot(cross(ba, nor), pa)) + - sign(dot(cross(cb, nor), pb)) + - sign(dot(cross(dc, nor), pc)) + - sign(dot(cross(ad, nor), pd))<3.0) - ? - min(min(min( - dot2(ba*clamp(dot(ba, pa)/dot2(ba), 0.0, 1.0)-pa), - dot2(cb*clamp(dot(cb, pb)/dot2(cb), 0.0, 1.0)-pb)), - dot2(dc*clamp(dot(dc, pc)/dot2(dc), 0.0, 1.0)-pc)), - dot2(ad*clamp(dot(ad, pd)/dot2(ad), 0.0, 1.0)-pd)) - : - dot(nor, pa)*dot(nor, pa)/dot2(nor)); -} - -bool rayMarch(vec3 ro, vec3 rd, in Light l) { - float t = 0.0; - for (int i = 0; i < 256; i++) { - vec3 p = ro + t * rd; - float d; - - switch (l.itemType){ - case ITEM_TYPE_SPHERE:{ - d = sdSphere(p, l.dataB.x, l.position); - break; - } - case ITEM_TYPE_PLANE:{ - vec3 reference = abs(l.dataA.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0); - vec3 right = normalize(cross(l.dataA, reference)); - vec3 up = normalize(cross(right, l.dataA)); - - // Use correct plane dimensions - vec3 halfRight = right * (l.dataB.z * 0.5); - vec3 halfUp = up * (l.dataB.x * 0.5); - - vec3 a = l.position - halfRight - halfUp; - vec3 b = l.position + halfRight - halfUp; - vec3 c = l.position + halfRight + halfUp; - vec3 dl = l.position - halfRight + halfUp; - d = udQuad(p, a, b, c, dl); - break; - } - default :{ - return false; - } - } - if (d < 0.001) return true; - if (t > 100.0) break; - t += d; - } - return false; -} - -void main(){ - if (globalData.lightsCount == 0){ - discard; - } - vec3 dir = createRay(texCoords, globalData.invProj, globalData.invView); - for (uint i = 0; i < globalData.lightsCount; i++){ - Light l = lightBuffer.items[i]; - if (rayMarch(globalData.cameraWorldPosition.xyz, dir, l)){ - finalColor = vec4(l.color.rgb * l.color.a, 1); - return; - } - } - discard; -} \ No newline at end of file diff --git a/src/ApplicationContext.cpp b/src/ApplicationContext.cpp index b14ca0d3..84de4494 100644 --- a/src/ApplicationContext.cpp +++ b/src/ApplicationContext.cpp @@ -11,14 +11,18 @@ namespace Metal { } void ApplicationContext::onInitialize() { - for (auto &instance : instances) { - instance->setDependencies(*this); + for (auto &instance: instances) { + if (instance.get() != this) { + instance->setDependencies(*this); + } } - for (auto &instance : instances) { - auto *init = dynamic_cast(instance.get()); - if (init) { - init->onInitialize(); + for (auto &instance: instances) { + if (instance.get() != this) { + auto *init = dynamic_cast(instance.get()); + if (init) { + init->onInitialize(); + } } } } @@ -30,6 +34,9 @@ namespace Metal { void ApplicationContext::dispose() { try { for (auto it = instances.rbegin(); it != instances.rend(); ++it) { + if (it->get() == this) { + continue; + } auto *disposable = dynamic_cast(it->get()); if (disposable) { disposable->dispose(); diff --git a/src/common/AbstractResourceService.h b/src/common/AbstractResourceService.h index a2e05ce3..870b12f5 100644 --- a/src/common/AbstractResourceService.h +++ b/src/common/AbstractResourceService.h @@ -5,13 +5,14 @@ #include #include "IService.h" +#include "../ApplicationContext.h" #include "../engine/resource/RuntimeResource.h" namespace Metal { class VulkanContext; template - class AbstractResourceService : public IService { + class AbstractResourceService : public IService, public IDisposable { static_assert(std::is_base_of_v, "T must be a subclass of RuntimeResource"); protected: @@ -23,6 +24,10 @@ namespace Metal { std::lock_guard lock(resourceMutex); auto *resource = new T(id, std::forward(args)...); resources[id] = resource; + ctx->injectDependencies(resource); + if (auto *initializable = dynamic_cast(resource)) { + initializable->onInitialize(); + } return resource; } @@ -52,7 +57,7 @@ namespace Metal { } } - void disposeAll() { + void dispose() override { std::lock_guard lock(resourceMutex); for (auto it = resources.begin(); it != resources.end();) { auto *r = it->second; diff --git a/src/common/IContextMember.cpp b/src/common/IContextMember.cpp index 8daeee72..28dae77e 100644 --- a/src/common/IContextMember.cpp +++ b/src/common/IContextMember.cpp @@ -5,7 +5,10 @@ namespace Metal { void IContextMember::setDependencies(ApplicationContext &ctx) { this->ctx = &ctx; for (auto &dep : getDependencies()) { - dep.ptr = ctx.getSingletonByName(dep.name); + void* singleton = ctx.getSingletonByName(dep.name); + if (dep.ptr != nullptr) { + *static_cast(dep.ptr) = singleton; + } } } } diff --git a/src/common/IContextMember.h b/src/common/IContextMember.h index 6a80f326..26b9c2eb 100644 --- a/src/common/IContextMember.h +++ b/src/common/IContextMember.h @@ -14,7 +14,7 @@ namespace Metal { class IContextMember { public: ApplicationContext *ctx = nullptr; - public: + virtual ~IContextMember() = default; /** diff --git a/src/core/DirectoryService.cpp b/src/core/DirectoryService.cpp index 785e1d45..4a3bfd18 100644 --- a/src/core/DirectoryService.cpp +++ b/src/core/DirectoryService.cpp @@ -11,6 +11,15 @@ #include "../engine/repository/WorldRepository.h" namespace Metal { + void DirectoryService::onInitialize() { + NFD_Init(); + updateRootPath(false); + } + + void DirectoryService::dispose() { + NFD_Quit(); + } + void DirectoryService::updateRootPath(bool forceSelection) { std::string cachedPath; std::string cachePathFile = std::filesystem::current_path().string() + CACHED_PATH; diff --git a/src/core/DirectoryService.h b/src/core/DirectoryService.h index a02b1339..1b7c46a0 100644 --- a/src/core/DirectoryService.h +++ b/src/core/DirectoryService.h @@ -1,5 +1,7 @@ #ifndef METAL_ENGINE_DIRECTORYSERVICE_H #define METAL_ENGINE_DIRECTORYSERVICE_H +#include "../common/IDisposable.h" +#include "../common/IInit.h" #include "../common/IService.h" namespace Metal { @@ -8,7 +10,7 @@ namespace Metal { struct WorldRepository; class NotificationService; - struct DirectoryService final : IService { + struct DirectoryService final : IService, IInit, IDisposable{ EditorRepository *editorRepository = nullptr; EngineRepository *engineRepository = nullptr; WorldRepository *worldRepository = nullptr; @@ -18,13 +20,17 @@ namespace Metal { std::vector getDependencies() override { return { - {"EditorRepository", editorRepository}, - {"EngineRepository", engineRepository}, - {"WorldRepository", worldRepository}, - {"NotificationService", notificationService} + {"EditorRepository", &editorRepository}, + {"EngineRepository", &engineRepository}, + {"WorldRepository", &worldRepository}, + {"NotificationService", ¬ificationService} }; } + void onInitialize() override; + + void dispose() override; + void updateRootPath(bool forceSelection); void save(); diff --git a/src/core/FrameService.cpp b/src/core/FrameService.cpp index 48b35d6d..d7a96f9e 100644 --- a/src/core/FrameService.cpp +++ b/src/core/FrameService.cpp @@ -15,10 +15,6 @@ namespace Metal { return vulkanContext->imguiVulkanWindow.FrameIndex; } - void FrameService::dispose() { - NFD_Quit(); - } - bool FrameService::isValidContext() const { return glfwContext->isValidContext(); } @@ -27,9 +23,7 @@ namespace Metal { this->panel = panel; } - void FrameService::onInitialize() { - NFD_Init(); - + void FrameService::start() const { GLFWwindow *window = glfwContext->getWindow(); while (!glfwWindowShouldClose(window)) { if (glfwContext->beginFrame()) { diff --git a/src/core/FrameService.h b/src/core/FrameService.h index d00287f1..2ed29d06 100644 --- a/src/core/FrameService.h +++ b/src/core/FrameService.h @@ -11,7 +11,7 @@ namespace Metal { class GuiContext; class AbstractPanel; - class FrameService final : public IService, public IInit, public IDisposable { + class FrameService final : public IService { GLFWContext *glfwContext = nullptr; VulkanContext *vulkanContext = nullptr; EngineContext *engineContext = nullptr; @@ -21,22 +21,20 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"GLFWContext", glfwContext}, - {"VulkanContext", vulkanContext}, - {"GuiContext", guiContext}, - {"EngineContext", engineContext} + {"GLFWContext", &glfwContext}, + {"VulkanContext", &vulkanContext}, + {"GuiContext", &guiContext}, + {"EngineContext", &engineContext} }; } void setPanel(AbstractPanel *panel); - void onInitialize() override; + void start() const; [[nodiscard]] bool isValidContext() const; [[nodiscard]] unsigned int getFrameIndex() const; - - void dispose() override; }; } // Metal diff --git a/src/core/glfw/GLFWContext.cpp b/src/core/glfw/GLFWContext.cpp index ae539bb5..7a3a6e26 100644 --- a/src/core/glfw/GLFWContext.cpp +++ b/src/core/glfw/GLFWContext.cpp @@ -42,7 +42,7 @@ namespace Metal { return true; } - void GLFWContext::dispose() { + void GLFWContext::disposeManually() { glfwDestroyWindow(window); glfwTerminate(); } diff --git a/src/core/glfw/GLFWContext.h b/src/core/glfw/GLFWContext.h index 0f4b06d4..33ad1dc3 100644 --- a/src/core/glfw/GLFWContext.h +++ b/src/core/glfw/GLFWContext.h @@ -18,7 +18,7 @@ namespace Metal { class ApplicationContext; class VulkanContext; - class GLFWContext final : public IContextMember, public IInit, public IDisposable { + class GLFWContext final : public IContextMember, public IInit { VulkanContext *vulkanContext = nullptr; GLFWwindow *window = nullptr; bool validContext = true; @@ -27,7 +27,7 @@ namespace Metal { public: std::vector getDependencies() override { - return {{"VulkanContext", vulkanContext}}; + return {{"VulkanContext", &vulkanContext}}; } void setSwapChainRebuild(bool val); @@ -44,7 +44,7 @@ namespace Metal { bool beginFrame(); - void dispose() override; + void disposeManually(); [[nodiscard]] ImGui_ImplVulkanH_Window &getGUIWindow() const; }; diff --git a/src/core/gui/GuiContext.cpp b/src/core/gui/GuiContext.cpp index 15fb1226..97c06c7c 100644 --- a/src/core/gui/GuiContext.cpp +++ b/src/core/gui/GuiContext.cpp @@ -141,7 +141,7 @@ namespace Metal { delete fontConfig; } - void GuiContext::dispose() { + void GuiContext::disposeManually() { const VkResult err = vkDeviceWaitIdle(vulkanContext->device.device); VulkanUtils::CheckVKResult(err); ImGui_ImplVulkan_Shutdown(); diff --git a/src/core/gui/GuiContext.h b/src/core/gui/GuiContext.h index 2ee14541..7a27eb6a 100644 --- a/src/core/gui/GuiContext.h +++ b/src/core/gui/GuiContext.h @@ -15,7 +15,7 @@ namespace Metal { class VulkanContext; class DescriptorSetService; - class GuiContext final : public IService, public IDisposable, public IInit { + class GuiContext final : public IService, public IInit { VulkanContext *vulkanContext = nullptr; GLFWContext *glfwContext = nullptr; DescriptorSetService *descriptorSetService = nullptr; @@ -32,9 +32,9 @@ namespace Metal { std::vector getDependencies() override { return { - {"VulkanContext", vulkanContext}, - {"GLFWContext", glfwContext}, - {"DescriptorSetService", descriptorSetService} + {"VulkanContext", &vulkanContext}, + {"GLFWContext", &glfwContext}, + {"DescriptorSetService", &descriptorSetService} }; } @@ -42,7 +42,7 @@ namespace Metal { return largeIconsFont; } - void dispose() override; + void disposeManually(); void onInitialize() override; diff --git a/src/core/vulkan/VulkanContext.cpp b/src/core/vulkan/VulkanContext.cpp index 35f7930d..1fb88ca9 100644 --- a/src/core/vulkan/VulkanContext.cpp +++ b/src/core/vulkan/VulkanContext.cpp @@ -9,8 +9,6 @@ #include "../../engine/service/MeshService.h" #include "../../engine/service/TextureService.h" #include "../../engine/service/FrameBufferService.h" -#include "../../engine/service/PipelineService.h" -#include "../../engine/service/RayTracingService.h" namespace Metal { @@ -292,12 +290,7 @@ namespace Metal { // ------- CORE INITIALIZATION } - void VulkanContext::dispose() { - pipelineService->disposeAll(); - textureService->disposeAll(); - meshService->disposeAll(); - framebufferService->disposeAll(); - rayTracingService->dispose(); + void VulkanContext::disposeManually() { vkDestroySampler(device.device, vkImageSampler, nullptr); vkDestroySampler(device.device, vkTextureSampler, nullptr); @@ -308,12 +301,11 @@ namespace Metal { nullptr); vkDestroyDevice(device.device, nullptr); - vkDestroySurfaceKHR(instance.instance, surface, nullptr); vkb::destroy_instance(instance); } void VulkanContext::createDescriptorPool() const { - const std::array sizes{ + const std::array sizes{ VkDescriptorPoolSize{VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 100}, // 1 for imgui VkDescriptorPoolSize{VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 100}, VkDescriptorPoolSize{VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 100}, diff --git a/src/core/vulkan/VulkanContext.h b/src/core/vulkan/VulkanContext.h index deed4b7a..cee39ddd 100644 --- a/src/core/vulkan/VulkanContext.h +++ b/src/core/vulkan/VulkanContext.h @@ -21,7 +21,7 @@ namespace Metal { class PipelineService; class RayTracingService; - class VulkanContext final : public IService, public IDisposable, public IInit { + class VulkanContext final : public IService, public IInit { GLFWContext *glfwContext = nullptr; EngineRepository *engineRepository = nullptr; MeshService *meshService = nullptr; @@ -70,13 +70,13 @@ namespace Metal { std::vector getDependencies() override { return { - {"GLFWContext", glfwContext}, - {"EngineRepository", engineRepository}, - {"MeshService", meshService}, - {"TextureService", textureService}, - {"FrameBufferService", framebufferService}, - {"PipelineService", pipelineService}, - {"RayTracingService", rayTracingService} + {"GLFWContext", &glfwContext}, + {"EngineRepository", &engineRepository}, + {"MeshService", &meshService}, + {"TextureService", &textureService}, + {"FrameBufferService", &framebufferService}, + {"PipelineService", &pipelineService}, + {"RayTracingService", &rayTracingService} }; } @@ -108,7 +108,7 @@ namespace Metal { PFN_vkGetRayTracingShaderGroupHandlesKHR vkGetRayTracingShaderGroupHandlesKHR = nullptr; PFN_vkCmdTraceRaysKHR vkCmdTraceRaysKHR = nullptr; - void dispose() override; + void disposeManually(); void onInitialize() override; diff --git a/src/editor/EditorPanel.cpp b/src/editor/EditorPanel.cpp index 89efab59..ba38367e 100644 --- a/src/editor/EditorPanel.cpp +++ b/src/editor/EditorPanel.cpp @@ -106,9 +106,9 @@ namespace Metal { } void EditorPanel::onInitialize() { - appendChild(headerPanel = new EditorHeaderPanel()); - appendChild(footerPanel = new EditorFooterPanel()); - appendChild(notificationsPanel = new NotificationsPanel()); - appendChild(fileImportModalPanel = new FileImportModalPanel()); + initializePanel(headerPanel = new EditorHeaderPanel(), false); + initializePanel(footerPanel = new EditorFooterPanel(), false); + initializePanel(notificationsPanel = new NotificationsPanel(), false); + initializePanel(fileImportModalPanel = new FileImportModalPanel(), false); } } diff --git a/src/editor/EditorPanel.h b/src/editor/EditorPanel.h index 80d47127..d007ff7a 100644 --- a/src/editor/EditorPanel.h +++ b/src/editor/EditorPanel.h @@ -36,8 +36,8 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"DockService", dockService}, - {"ThemeService", themeService} + {"DockService", &dockService}, + {"ThemeService", &themeService} }; } diff --git a/src/editor/abstract/AbstractPanel.cpp b/src/editor/abstract/AbstractPanel.cpp index 441d5537..d3e1f1a6 100644 --- a/src/editor/abstract/AbstractPanel.cpp +++ b/src/editor/abstract/AbstractPanel.cpp @@ -3,10 +3,13 @@ #include "../../ApplicationContext.h" namespace Metal { - void AbstractPanel::appendChild(AbstractPanel *panel) { + void AbstractPanel::initializePanel(AbstractPanel *panel, bool addToChildList) { + panel->ctx = ctx; ctx->injectDependencies(panel); panel->onInitialize(); - children.push_back(panel); + if (addToChildList) { + children.push_back(panel); + } } void AbstractPanel::onSyncChildren() const { diff --git a/src/editor/abstract/AbstractPanel.h b/src/editor/abstract/AbstractPanel.h index b86431df..651f9d6b 100644 --- a/src/editor/abstract/AbstractPanel.h +++ b/src/editor/abstract/AbstractPanel.h @@ -22,7 +22,7 @@ namespace Metal { std::vector &getChildren(); - void appendChild(AbstractPanel *panel); + void initializePanel(AbstractPanel *panel, bool addToChildList = true); void removeAllChildren(); diff --git a/src/editor/abstract/form/AbstractFormFieldPanel.h b/src/editor/abstract/form/AbstractFormFieldPanel.h index bfdb7f1f..f3381221 100644 --- a/src/editor/abstract/form/AbstractFormFieldPanel.h +++ b/src/editor/abstract/form/AbstractFormFieldPanel.h @@ -17,7 +17,7 @@ namespace Metal { std::vector getDependencies() override { return { - {"ThemeService", themeService} + {"ThemeService", &themeService} }; } [[nodiscard]] virtual bool isVisible() const = 0; diff --git a/src/editor/abstract/form/FormPanel.cpp b/src/editor/abstract/form/FormPanel.cpp index 5c683c15..3600d088 100644 --- a/src/editor/abstract/form/FormPanel.cpp +++ b/src/editor/abstract/form/FormPanel.cpp @@ -20,14 +20,14 @@ namespace Metal { std::unordered_map groups{}; const auto rootPanel = new ChildPanel(); rootPanel->setFilter(&searchFilter); - appendChild(rootPanel); + initializePanel(rootPanel); rootPanel->setTitle(std::string(inspection->getIcon()) + " " + inspection->getTitle()); for (const auto &field: inspection->getFields()) { if (!groups.contains(field->group)) { const auto panel = new AccordionPanel(); panel->setFilter(&searchFilter); groups[field->group] = panel; - rootPanel->appendChild(panel); + rootPanel->initializePanel(panel); } AccordionPanel *group = groups[field->group]; group->setTitle(field->group); @@ -71,7 +71,7 @@ namespace Metal { } if (fieldPanel) { fieldPanel->setFilter(&searchFilter); - group->appendChild(fieldPanel); + group->initializePanel(fieldPanel); } } } diff --git a/src/editor/abstract/form/types/ResourceField.cpp b/src/editor/abstract/form/types/ResourceField.cpp index ba761c59..884eceb9 100644 --- a/src/editor/abstract/form/types/ResourceField.cpp +++ b/src/editor/abstract/form/types/ResourceField.cpp @@ -19,7 +19,7 @@ namespace Metal { } void ResourceField::onInitialize() { - appendChild(new ResourceFilesPanel([this](FSEntry *file) { + initializePanel(new ResourceFilesPanel([this](FSEntry *file) { if (file == nullptr) { open = false; return; diff --git a/src/editor/abstract/form/types/ResourceField.h b/src/editor/abstract/form/types/ResourceField.h index 92b8a23b..5c970922 100644 --- a/src/editor/abstract/form/types/ResourceField.h +++ b/src/editor/abstract/form/types/ResourceField.h @@ -19,7 +19,7 @@ namespace Metal { public: std::vector getDependencies() override { - return {{"FilesService", filesService}}; + return {{"FilesService", &filesService}}; } void onInitialize() override; diff --git a/src/editor/dock-spaces/docks/DockSpacePanel.cpp b/src/editor/dock-spaces/docks/DockSpacePanel.cpp index c77db728..60f9c479 100644 --- a/src/editor/dock-spaces/docks/DockSpacePanel.cpp +++ b/src/editor/dock-spaces/docks/DockSpacePanel.cpp @@ -36,7 +36,7 @@ namespace Metal { newView->size = &size; newView->dock = selectedSpace; newView->position = &position; - appendChild(newView); + initializePanel(newView); views.emplace(selectedSpace->index, newView); view = newView; } else { diff --git a/src/editor/dock-spaces/docks/DockSpacePanel.h b/src/editor/dock-spaces/docks/DockSpacePanel.h index bc89e743..911e94bc 100644 --- a/src/editor/dock-spaces/docks/DockSpacePanel.h +++ b/src/editor/dock-spaces/docks/DockSpacePanel.h @@ -38,8 +38,8 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"EditorRepository", editorRepository}, - {"ThemeService", themeService} + {"EditorRepository", &editorRepository}, + {"ThemeService", &themeService} }; } diff --git a/src/editor/dock-spaces/files/FilePreviewPanel.h b/src/editor/dock-spaces/files/FilePreviewPanel.h index b539a00a..7486746d 100644 --- a/src/editor/dock-spaces/files/FilePreviewPanel.h +++ b/src/editor/dock-spaces/files/FilePreviewPanel.h @@ -17,8 +17,8 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"TextureService", textureService}, - {"GuiContext", guiContext} + {"TextureService", &textureService}, + {"GuiContext", &guiContext} }; } diff --git a/src/editor/dock-spaces/files/FilesHeaderPanel.h b/src/editor/dock-spaces/files/FilesHeaderPanel.h index 479e7235..2dd46591 100644 --- a/src/editor/dock-spaces/files/FilesHeaderPanel.h +++ b/src/editor/dock-spaces/files/FilesHeaderPanel.h @@ -16,7 +16,7 @@ namespace Metal { public: std::vector getDependencies() override { - return {{"FilesService", filesService}}; + return {{"FilesService", &filesService}}; } explicit FilesHeaderPanel(FilesContext &files_context, const std::string &actionLabel, diff --git a/src/editor/dock-spaces/files/FilesListPanel.h b/src/editor/dock-spaces/files/FilesListPanel.h index 9ebd6e44..b87f2121 100644 --- a/src/editor/dock-spaces/files/FilesListPanel.h +++ b/src/editor/dock-spaces/files/FilesListPanel.h @@ -50,7 +50,7 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"FilesService", filesService} + {"FilesService", &filesService} }; } diff --git a/src/editor/dock-spaces/files/FilesPanel.cpp b/src/editor/dock-spaces/files/FilesPanel.cpp index 91316c83..2823793a 100644 --- a/src/editor/dock-spaces/files/FilesPanel.cpp +++ b/src/editor/dock-spaces/files/FilesPanel.cpp @@ -50,16 +50,16 @@ namespace Metal { void FilesPanel::onInitialize() { filesContext.setCurrentDirectory(filesService->getRoot()); - appendChild(filesHeader = new FilesHeaderPanel(filesContext, getActionLabel(), onAction())); + initializePanel(filesHeader = new FilesHeaderPanel(filesContext, getActionLabel(), onAction())); filesListPanel = new FilesListPanel( filesContext, [ this](FSEntry *entry) { openResource(entry); }, getTypeFilter()); - appendChild(filesListPanel); + initializePanel(filesListPanel); previewPanel = new FilePreviewPanel(filesContext); - appendChild(previewPanel); + initializePanel(previewPanel); shortcuts = { ShortcutDTO("Cut", ImGuiMod_Ctrl | ImGuiKey_X, [this]() { diff --git a/src/editor/dock-spaces/files/FilesPanel.h b/src/editor/dock-spaces/files/FilesPanel.h index 2c90c3a1..cec10119 100644 --- a/src/editor/dock-spaces/files/FilesPanel.h +++ b/src/editor/dock-spaces/files/FilesPanel.h @@ -39,13 +39,13 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"FileImporterService", fileImporterService}, - {"EditorRepository", editorRepository}, - {"SceneImporterService", sceneImporterService}, - {"FilesService", filesService}, - {"NotificationService", notificationService}, - {"WorldRepository", worldRepository}, - {"VoxelService", voxelService} + {"FileImporterService", &fileImporterService}, + {"EditorRepository", &editorRepository}, + {"SceneImporterService", &sceneImporterService}, + {"FilesService", &filesService}, + {"NotificationService", ¬ificationService}, + {"WorldRepository", &worldRepository}, + {"VoxelService", &voxelService} }; } diff --git a/src/editor/dock-spaces/footer/EditorFooterPanel.cpp b/src/editor/dock-spaces/footer/EditorFooterPanel.cpp index d8336424..280a194c 100644 --- a/src/editor/dock-spaces/footer/EditorFooterPanel.cpp +++ b/src/editor/dock-spaces/footer/EditorFooterPanel.cpp @@ -20,14 +20,15 @@ namespace Metal { void EditorFooterPanel::renderShortcuts() { auto &shortcuts = editorRepository->focusedShortcuts; if (shortcuts.empty()) return; - + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5); // Some padding + ImGui::Text(editorRepository->focusedWindowName.c_str()); ImGui::SameLine(); std::string label; for (size_t i = 0; i < std::min(shortcuts.size(), size_t(3)); ++i) { if (i > 0) label += " | "; - label += UIUtil::GetKeyChordName(shortcuts[i].keyChord); + label += UIUtil::GetKeyChordName(shortcuts[i].keyChord) + " " + shortcuts[i].name; } if (ImGui::Button(label.c_str())) { diff --git a/src/editor/dock-spaces/footer/EditorFooterPanel.h b/src/editor/dock-spaces/footer/EditorFooterPanel.h index 372c6119..4dee9bb0 100644 --- a/src/editor/dock-spaces/footer/EditorFooterPanel.h +++ b/src/editor/dock-spaces/footer/EditorFooterPanel.h @@ -15,7 +15,7 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"EditorRepository", editorRepository} + {"EditorRepository", &editorRepository} }; } diff --git a/src/editor/dock-spaces/header/AsyncTaskPanel.h b/src/editor/dock-spaces/header/AsyncTaskPanel.h index 640dee30..d834c713 100644 --- a/src/editor/dock-spaces/header/AsyncTaskPanel.h +++ b/src/editor/dock-spaces/header/AsyncTaskPanel.h @@ -12,7 +12,7 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"AsyncTaskService", asyncTaskService} + {"AsyncTaskService", &asyncTaskService} }; } diff --git a/src/editor/dock-spaces/header/EditorHeaderPanel.cpp b/src/editor/dock-spaces/header/EditorHeaderPanel.cpp index 1bca0433..6f7be23b 100644 --- a/src/editor/dock-spaces/header/EditorHeaderPanel.cpp +++ b/src/editor/dock-spaces/header/EditorHeaderPanel.cpp @@ -16,25 +16,27 @@ namespace Metal { // Window dragging logic if (ImGui::IsWindowHovered() && ImGui::IsMouseDragging(ImGuiMouseButton_Left)) { ImVec2 delta = ImGui::GetIO().MouseDelta; - GLFWwindow* window = glfwContext->getWindow(); + GLFWwindow *window = glfwContext->getWindow(); int x, y; glfwGetWindowPos(window, &x, &y); - glfwSetWindowPos(window, x + (int)delta.x, y + (int)delta.y); + glfwSetWindowPos(window, x + (int) delta.x, y + (int) delta.y); } } void EditorHeaderPanel::renderWindowControls() { ImGui::SameLine(ImGui::GetWindowWidth() - (UIUtil::ONLY_ICON_BUTTON_SIZE * 3 + 10)); - - GLFWwindow* window = glfwContext->getWindow(); - if (UIUtil::ButtonSimple(Icons::minimize, UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE)) { + GLFWwindow *window = glfwContext->getWindow(); + + if (UIUtil::ButtonSimple((Icons::minimize + id + "min"), UIUtil::ONLY_ICON_BUTTON_SIZE, + UIUtil::ONLY_ICON_BUTTON_SIZE)) { glfwIconifyWindow(window); } ImGui::SameLine(); bool isMaximized = glfwGetWindowAttrib(window, GLFW_MAXIMIZED); - if (UIUtil::ButtonSimple(isMaximized ? Icons::filter_none : Icons::crop_square, UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE)) { + if (UIUtil::ButtonSimple((isMaximized ? Icons::filter_none : Icons::crop_square) + id + "max", + UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE)) { if (isMaximized) { glfwRestoreWindow(window); } else { @@ -43,7 +45,8 @@ namespace Metal { } ImGui::SameLine(); - if (UIUtil::ButtonSimple(Icons::close, UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE)) { + if (UIUtil::ButtonSimple(Icons::close + id + "close", UIUtil::ONLY_ICON_BUTTON_SIZE, + UIUtil::ONLY_ICON_BUTTON_SIZE)) { glfwSetWindowShouldClose(window, GLFW_TRUE); } } @@ -89,6 +92,6 @@ namespace Metal { } void EditorHeaderPanel::onInitialize() { - appendChild(asyncTask = new AsyncTaskPanel()); + initializePanel(asyncTask = new AsyncTaskPanel()); } } diff --git a/src/editor/dock-spaces/header/EditorHeaderPanel.h b/src/editor/dock-spaces/header/EditorHeaderPanel.h index 412ae9a6..230591f9 100644 --- a/src/editor/dock-spaces/header/EditorHeaderPanel.h +++ b/src/editor/dock-spaces/header/EditorHeaderPanel.h @@ -22,9 +22,9 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"GLFWContext", glfwContext}, - {"EngineContext", engineContext}, - {"DirectoryService", directoryService} + {"GLFWContext", &glfwContext}, + {"EngineContext", &engineContext}, + {"DirectoryService", &directoryService} }; } diff --git a/src/editor/dock-spaces/inspector/InspectorPanel.cpp b/src/editor/dock-spaces/inspector/InspectorPanel.cpp index adef54bd..c6ed3c38 100644 --- a/src/editor/dock-spaces/inspector/InspectorPanel.cpp +++ b/src/editor/dock-spaces/inspector/InspectorPanel.cpp @@ -12,7 +12,7 @@ namespace Metal { void InspectorPanel::onInitialize() { formPanel = new FormPanel(); - appendChild(formPanel); + initializePanel(formPanel); } void InspectorPanel::onSync() { diff --git a/src/editor/dock-spaces/inspector/InspectorPanel.h b/src/editor/dock-spaces/inspector/InspectorPanel.h index cf8a1bf6..cfb45e4b 100644 --- a/src/editor/dock-spaces/inspector/InspectorPanel.h +++ b/src/editor/dock-spaces/inspector/InspectorPanel.h @@ -23,8 +23,8 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"EditorRepository", editorRepository}, - {"WorldRepository", worldRepository} + {"EditorRepository", &editorRepository}, + {"WorldRepository", &worldRepository} }; } diff --git a/src/editor/dock-spaces/metrics/MetricsPanel.h b/src/editor/dock-spaces/metrics/MetricsPanel.h index e81e1e6c..5a945ebb 100644 --- a/src/editor/dock-spaces/metrics/MetricsPanel.h +++ b/src/editor/dock-spaces/metrics/MetricsPanel.h @@ -23,12 +23,12 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"MeshService", meshService}, - {"VoxelService", voxelService}, - {"FrameBufferService", framebufferService}, - {"TextureService", textureService}, - {"PipelineService", pipelineService}, - {"BufferService", bufferService} + {"MeshService", &meshService}, + {"VoxelService", &voxelService}, + {"FrameBufferService", &framebufferService}, + {"TextureService", &textureService}, + {"PipelineService", &pipelineService}, + {"BufferService", &bufferService} }; } diff --git a/src/editor/dock-spaces/repositories/RepositoriesPanel.cpp b/src/editor/dock-spaces/repositories/RepositoriesPanel.cpp index 4c6bc533..74279177 100644 --- a/src/editor/dock-spaces/repositories/RepositoriesPanel.cpp +++ b/src/editor/dock-spaces/repositories/RepositoriesPanel.cpp @@ -10,7 +10,7 @@ namespace Metal { void RepositoriesPanel::onInitialize() { formPanel = new FormPanel(); - appendChild(formPanel); + initializePanel(formPanel); repositories.push_back(editorRepository); repositories.push_back(engineRepository); diff --git a/src/editor/dock-spaces/repositories/RepositoriesPanel.h b/src/editor/dock-spaces/repositories/RepositoriesPanel.h index 6121111c..7d446362 100644 --- a/src/editor/dock-spaces/repositories/RepositoriesPanel.h +++ b/src/editor/dock-spaces/repositories/RepositoriesPanel.h @@ -21,13 +21,14 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"EditorRepository", editorRepository}, - {"EngineRepository", engineRepository}, - {"WorldRepository", worldRepository} + {"EditorRepository", &editorRepository}, + {"EngineRepository", &engineRepository}, + {"WorldRepository", &worldRepository} }; } void onInitialize() override; + void onSync() override; }; } diff --git a/src/editor/dock-spaces/viewport/CameraPositionPanel.h b/src/editor/dock-spaces/viewport/CameraPositionPanel.h index 1dd71422..4a2b4367 100644 --- a/src/editor/dock-spaces/viewport/CameraPositionPanel.h +++ b/src/editor/dock-spaces/viewport/CameraPositionPanel.h @@ -19,7 +19,7 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"WorldRepository", worldRepository} + {"WorldRepository", &worldRepository} }; } diff --git a/src/editor/dock-spaces/viewport/EngineFramePanel.h b/src/editor/dock-spaces/viewport/EngineFramePanel.h index bee6aba7..0b7f9cba 100644 --- a/src/editor/dock-spaces/viewport/EngineFramePanel.h +++ b/src/editor/dock-spaces/viewport/EngineFramePanel.h @@ -25,12 +25,12 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"VulkanContext", vulkanContext}, - {"EngineRepository", engineRepository}, - {"EngineContext", engineContext}, - {"DescriptorSetService", descriptorSetService}, - {"PickingService", pickingService}, - {"SelectionService", selectionService} + {"VulkanContext", &vulkanContext}, + {"EngineRepository", &engineRepository}, + {"EngineContext", &engineContext}, + {"DescriptorSetService", &descriptorSetService}, + {"PickingService", &pickingService}, + {"SelectionService", &selectionService} }; } diff --git a/src/editor/dock-spaces/viewport/GizmoPanel.h b/src/editor/dock-spaces/viewport/GizmoPanel.h index b68c74fc..12da02fc 100644 --- a/src/editor/dock-spaces/viewport/GizmoPanel.h +++ b/src/editor/dock-spaces/viewport/GizmoPanel.h @@ -42,9 +42,9 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"EditorRepository", editorRepository}, - {"WorldRepository", worldRepository}, - {"SelectionService", selectionService} + {"EditorRepository", &editorRepository}, + {"WorldRepository", &worldRepository}, + {"SelectionService", &selectionService} }; } diff --git a/src/editor/dock-spaces/viewport/GizmoSettingsPanel.h b/src/editor/dock-spaces/viewport/GizmoSettingsPanel.h index 998ac529..7f5b13d0 100644 --- a/src/editor/dock-spaces/viewport/GizmoSettingsPanel.h +++ b/src/editor/dock-spaces/viewport/GizmoSettingsPanel.h @@ -27,8 +27,8 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"EditorRepository", editorRepository}, - {"WorldRepository", worldRepository} + {"EditorRepository", &editorRepository}, + {"WorldRepository", &worldRepository} }; } diff --git a/src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp b/src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp index c6a7dd27..3d4cd54f 100644 --- a/src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp +++ b/src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp @@ -7,7 +7,7 @@ namespace Metal { void ViewportHeaderPanel::onInitialize() { - appendChild(gizmo = new GizmoSettingsPanel()); + initializePanel(gizmo = new GizmoSettingsPanel()); } void ViewportHeaderPanel::onSync() { diff --git a/src/editor/dock-spaces/viewport/ViewportHeaderPanel.h b/src/editor/dock-spaces/viewport/ViewportHeaderPanel.h index a5712887..eb5cf60b 100644 --- a/src/editor/dock-spaces/viewport/ViewportHeaderPanel.h +++ b/src/editor/dock-spaces/viewport/ViewportHeaderPanel.h @@ -20,8 +20,8 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"EditorRepository", editorRepository}, - {"WorldRepository", worldRepository} + {"EditorRepository", &editorRepository}, + {"WorldRepository", &worldRepository} }; } diff --git a/src/editor/dock-spaces/viewport/ViewportPanel.cpp b/src/editor/dock-spaces/viewport/ViewportPanel.cpp index 8114ee67..05f00fa8 100644 --- a/src/editor/dock-spaces/viewport/ViewportPanel.cpp +++ b/src/editor/dock-spaces/viewport/ViewportPanel.cpp @@ -19,10 +19,10 @@ namespace Metal { void ViewportPanel::onInitialize() { - appendChild(headerPanel = new ViewportHeaderPanel()); - appendChild(engineFramePanel = new EngineFramePanel()); - appendChild(gizmoPanel = new GizmoPanel(position, size)); - appendChild(cameraPanel = new CameraPositionPanel()); + initializePanel(headerPanel = new ViewportHeaderPanel()); + initializePanel(engineFramePanel = new EngineFramePanel()); + initializePanel(gizmoPanel = new GizmoPanel(position, size)); + initializePanel(cameraPanel = new CameraPositionPanel()); shortcuts = { ShortcutDTO("Change shading mode", ImGuiKey_Q, [this]() { diff --git a/src/editor/dock-spaces/viewport/ViewportPanel.h b/src/editor/dock-spaces/viewport/ViewportPanel.h index 343cded0..5703d6fa 100644 --- a/src/editor/dock-spaces/viewport/ViewportPanel.h +++ b/src/editor/dock-spaces/viewport/ViewportPanel.h @@ -30,13 +30,13 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"CameraService", cameraService}, - {"SelectionService", selectionService}, - {"EditorRepository", editorRepository}, - {"WorldRepository", worldRepository}, - {"RuntimeRepository", runtimeRepository}, - {"EngineContext", engineContext}, - {"DirectoryService", directoryService} + {"CameraService", &cameraService}, + {"SelectionService", &selectionService}, + {"EditorRepository", &editorRepository}, + {"WorldRepository", &worldRepository}, + {"RuntimeRepository", &runtimeRepository}, + {"EngineContext", &engineContext}, + {"DirectoryService", &directoryService} }; } diff --git a/src/editor/dock-spaces/world/WorldHeaderPanel.h b/src/editor/dock-spaces/world/WorldHeaderPanel.h index c89b5e4d..5a7134a6 100644 --- a/src/editor/dock-spaces/world/WorldHeaderPanel.h +++ b/src/editor/dock-spaces/world/WorldHeaderPanel.h @@ -11,7 +11,7 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"WorldRepository", worldRepository} + {"WorldRepository", &worldRepository} }; } diff --git a/src/editor/dock-spaces/world/WorldPanel.cpp b/src/editor/dock-spaces/world/WorldPanel.cpp index ab177ffd..1b555094 100644 --- a/src/editor/dock-spaces/world/WorldPanel.cpp +++ b/src/editor/dock-spaces/world/WorldPanel.cpp @@ -12,7 +12,7 @@ namespace Metal { void WorldPanel::onInitialize() { - appendChild(headerPanel = new WorldHeaderPanel()); + initializePanel(headerPanel = new WorldHeaderPanel()); shortcuts = { ShortcutDTO("Delete", ImGuiKey_Delete, [this]() { diff --git a/src/editor/dock-spaces/world/WorldPanel.h b/src/editor/dock-spaces/world/WorldPanel.h index dabf837e..37a33934 100644 --- a/src/editor/dock-spaces/world/WorldPanel.h +++ b/src/editor/dock-spaces/world/WorldPanel.h @@ -34,10 +34,10 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"WorldRepository", world}, - {"EditorRepository", editorRepository}, - {"SelectionService", selectionService}, - {"DirectoryService", directoryService} + {"WorldRepository", &world}, + {"EditorRepository", &editorRepository}, + {"SelectionService", &selectionService}, + {"DirectoryService", &directoryService} }; } diff --git a/src/editor/panel/FileImportModalPanel.cpp b/src/editor/panel/FileImportModalPanel.cpp index e52c06ca..832b4828 100644 --- a/src/editor/panel/FileImportModalPanel.cpp +++ b/src/editor/panel/FileImportModalPanel.cpp @@ -13,7 +13,7 @@ namespace Metal { void FileImportModalPanel::onInitialize() { formPanel = new FormPanel(); - appendChild(formPanel); + initializePanel(formPanel); } void FileImportModalPanel::onSync() { diff --git a/src/editor/panel/FileImportModalPanel.h b/src/editor/panel/FileImportModalPanel.h index f3f5f713..fa9a75e5 100644 --- a/src/editor/panel/FileImportModalPanel.h +++ b/src/editor/panel/FileImportModalPanel.h @@ -21,10 +21,10 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"EditorRepository", editorRepository}, - {"FileImporterService", fileImporterService}, - {"NotificationService", notificationService}, - {"FilesService", filesService} + {"EditorRepository", &editorRepository}, + {"FileImporterService", &fileImporterService}, + {"NotificationService", ¬ificationService}, + {"FilesService", &filesService} }; } diff --git a/src/editor/panel/NotificationsPanel.h b/src/editor/panel/NotificationsPanel.h index eae1b8e7..afdf6091 100644 --- a/src/editor/panel/NotificationsPanel.h +++ b/src/editor/panel/NotificationsPanel.h @@ -13,8 +13,8 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"NotificationService", notificationService}, - {"EngineContext", engineContext} + {"NotificationService", ¬ificationService}, + {"EngineContext", &engineContext} }; } diff --git a/src/editor/passes/GridPass.h b/src/editor/passes/GridPass.h index 93342511..f9f2a635 100644 --- a/src/editor/passes/GridPass.h +++ b/src/editor/passes/GridPass.h @@ -18,9 +18,9 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"PipelineService", pipelineService}, - {"ApplicationContext", applicationContext}, - {"EditorRepository", editorRepository} + {"PipelineService", &pipelineService}, + {"ApplicationContext", &applicationContext}, + {"EditorRepository", &editorRepository} }; } diff --git a/src/editor/passes/SelectionIDPass.h b/src/editor/passes/SelectionIDPass.h index 9a972cd2..0bf55bf6 100644 --- a/src/editor/passes/SelectionIDPass.h +++ b/src/editor/passes/SelectionIDPass.h @@ -21,10 +21,10 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"PipelineService", pipelineService}, - {"EditorRepository", editorRepository}, - {"WorldRepository", worldRepository}, - {"MeshService", meshService} + {"PipelineService", &pipelineService}, + {"EditorRepository", &editorRepository}, + {"WorldRepository", &worldRepository}, + {"MeshService", &meshService} }; } diff --git a/src/editor/passes/SelectionOutlinePass.h b/src/editor/passes/SelectionOutlinePass.h index 3d036e68..8a9ccac5 100644 --- a/src/editor/passes/SelectionOutlinePass.h +++ b/src/editor/passes/SelectionOutlinePass.h @@ -17,8 +17,8 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"PipelineService", pipelineService}, - {"EditorRepository", editorRepository} + {"PipelineService", &pipelineService}, + {"EditorRepository", &editorRepository} }; } diff --git a/src/editor/service/DockService.cpp b/src/editor/service/DockService.cpp index 6113369e..cf2f9182 100644 --- a/src/editor/service/DockService.cpp +++ b/src/editor/service/DockService.cpp @@ -135,10 +135,10 @@ namespace Metal { ImGui::DockBuilderDockWindow(d->internalId.c_str(), d->nodeId); for (auto *l: panel->getChildren()) { if (dynamic_cast(l)) { - panel->appendChild(new DockSpacePanel(dynamic_cast(l), d)); + panel->initializePanel(new DockSpacePanel(dynamic_cast(l), d)); return; } } - panel->appendChild(new DockSpacePanel(nullptr, d)); + panel->initializePanel(new DockSpacePanel(nullptr, d)); } } diff --git a/src/editor/service/FileImporterService.h b/src/editor/service/FileImporterService.h index 411c617a..4df01d4a 100644 --- a/src/editor/service/FileImporterService.h +++ b/src/editor/service/FileImporterService.h @@ -25,11 +25,11 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"SceneImporterService", sceneImporterService}, - {"TextureImporterService", textureImporterService}, - {"VoxelImporterService", voxelImporterService}, - {"NotificationService", notificationService}, - {"AsyncTaskService", asyncTaskService} + {"SceneImporterService", &sceneImporterService}, + {"TextureImporterService", &textureImporterService}, + {"VoxelImporterService", &voxelImporterService}, + {"NotificationService", ¬ificationService}, + {"AsyncTaskService", &asyncTaskService} }; } diff --git a/src/editor/service/FilesService.h b/src/editor/service/FilesService.h index cdefef5a..c0228b93 100644 --- a/src/editor/service/FilesService.h +++ b/src/editor/service/FilesService.h @@ -20,7 +20,9 @@ namespace Metal { public: std::vector getDependencies() override { - return {{"DirectoryService", directoryService}, {"NotificationService", notificationService}}; + return { + {"DirectoryService", &directoryService}, + {"NotificationService", ¬ificationService}}; } FSEntry *getRoot() const { diff --git a/src/editor/service/MaterialImporterService.h b/src/editor/service/MaterialImporterService.h index cbe42008..ae2596cc 100644 --- a/src/editor/service/MaterialImporterService.h +++ b/src/editor/service/MaterialImporterService.h @@ -18,7 +18,7 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"TextureImporterService", textureImporterService} + {"TextureImporterService", &textureImporterService} }; } diff --git a/src/editor/service/MeshImporterService.h b/src/editor/service/MeshImporterService.h index aa9c33fe..364c8764 100644 --- a/src/editor/service/MeshImporterService.h +++ b/src/editor/service/MeshImporterService.h @@ -23,7 +23,7 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"DirectoryService", directoryService} + {"DirectoryService", &directoryService} }; } diff --git a/src/editor/service/PickingService.h b/src/editor/service/PickingService.h index a51b8167..d7e2e842 100644 --- a/src/editor/service/PickingService.h +++ b/src/editor/service/PickingService.h @@ -19,9 +19,9 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"VulkanContext", vulkanContext}, - {"BufferService", bufferService}, - {"WorldRepository", worldRepository} + {"VulkanContext", &vulkanContext}, + {"BufferService", &bufferService}, + {"WorldRepository", &worldRepository} }; } diff --git a/src/editor/service/SceneImporterService.h b/src/editor/service/SceneImporterService.h index 997d76bc..daea86d0 100644 --- a/src/editor/service/SceneImporterService.h +++ b/src/editor/service/SceneImporterService.h @@ -25,9 +25,9 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"MeshImporterService", meshImporterService}, - {"MaterialImporterService", materialImporterService}, - {"DirectoryService", directoryService} + {"MeshImporterService", &meshImporterService}, + {"MaterialImporterService", &materialImporterService}, + {"DirectoryService", &directoryService} }; } diff --git a/src/editor/service/SelectionService.h b/src/editor/service/SelectionService.h index 27562703..f3d7a7d0 100644 --- a/src/editor/service/SelectionService.h +++ b/src/editor/service/SelectionService.h @@ -16,8 +16,8 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"EditorRepository", editorRepository}, - {"WorldRepository", worldRepository} + {"EditorRepository", &editorRepository}, + {"WorldRepository", &worldRepository} }; } diff --git a/src/editor/service/TextureImporterService.h b/src/editor/service/TextureImporterService.h index 59b56317..6daa7cc9 100644 --- a/src/editor/service/TextureImporterService.h +++ b/src/editor/service/TextureImporterService.h @@ -14,7 +14,7 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"DirectoryService", directoryService} + {"DirectoryService", &directoryService} }; } diff --git a/src/editor/service/ThemeService.h b/src/editor/service/ThemeService.h index 4cc321d7..4ccf93a6 100644 --- a/src/editor/service/ThemeService.h +++ b/src/editor/service/ThemeService.h @@ -31,7 +31,7 @@ namespace Metal { void onSync() override; std::vector getDependencies() override { - return {{"EditorRepository", editorRepository}}; + return {{"EditorRepository", &editorRepository}}; } }; } // Metal diff --git a/src/editor/service/VoxelImporterService.h b/src/editor/service/VoxelImporterService.h index 781283b0..4221e448 100644 --- a/src/editor/service/VoxelImporterService.h +++ b/src/editor/service/VoxelImporterService.h @@ -14,7 +14,7 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"DirectoryService", directoryService} + {"DirectoryService", &directoryService} }; } diff --git a/src/engine/EngineContext.cpp b/src/engine/EngineContext.cpp index ffdb7651..057569a9 100644 --- a/src/engine/EngineContext.cpp +++ b/src/engine/EngineContext.cpp @@ -41,9 +41,10 @@ namespace Metal { } void EngineContext::setCurrentFrame(const std::string &id) { - for (auto *frame : registeredFrames) { + for (auto *frame: registeredFrames) { if (frame->getId() == id) { currentFrame = frame; + currentFrame->setShouldRender(true); return; } } diff --git a/src/engine/EngineContext.h b/src/engine/EngineContext.h index 2e09a24e..a630a405 100644 --- a/src/engine/EngineContext.h +++ b/src/engine/EngineContext.h @@ -46,15 +46,15 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"TransformService", transformService}, - {"StreamingService", streamingService}, - {"RayTracingService", rayTracingService}, - {"CameraService", cameraService}, - {"LightService", lightService}, - {"VolumeService", volumeService}, - {"WorldRepository", worldRepository}, - {"EditorRepository", editorRepository}, - {"EngineRepository", engineRepository} + {"TransformService", &transformService}, + {"StreamingService", &streamingService}, + {"RayTracingService", &rayTracingService}, + {"CameraService", &cameraService}, + {"LightService", &lightService}, + {"VolumeService", &volumeService}, + {"WorldRepository", &worldRepository}, + {"EditorRepository", &editorRepository}, + {"EngineRepository", &engineRepository} }; } diff --git a/src/engine/frame-builder/EngineFrameBuilder.h b/src/engine/frame-builder/EngineFrameBuilder.h index e4b90114..fa72b744 100644 --- a/src/engine/frame-builder/EngineFrameBuilder.h +++ b/src/engine/frame-builder/EngineFrameBuilder.h @@ -33,7 +33,7 @@ namespace Metal { public: std::vector getDependencies() override { - return {{"EngineContext", engineContext}}; + return {{"EngineContext", &engineContext}}; } explicit EngineFrameBuilder(std::string frameId = Util::uuidV4()); diff --git a/src/engine/frame-builder/structures/BufferBuilder.h b/src/engine/frame-builder/structures/BufferBuilder.h index 60d18771..acb66359 100644 --- a/src/engine/frame-builder/structures/BufferBuilder.h +++ b/src/engine/frame-builder/structures/BufferBuilder.h @@ -18,7 +18,7 @@ namespace Metal { public: std::vector getDependencies() override { - return {{"BufferService", bufferService}}; + return {{"BufferService", &bufferService}}; } explicit BufferBuilder(const std::string &id, VkDeviceSize size, VkBufferUsageFlags usage, diff --git a/src/engine/frame-builder/structures/CommandBufferRecorderBuilder.h b/src/engine/frame-builder/structures/CommandBufferRecorderBuilder.h index e5a52121..19a3b56c 100644 --- a/src/engine/frame-builder/structures/CommandBufferRecorderBuilder.h +++ b/src/engine/frame-builder/structures/CommandBufferRecorderBuilder.h @@ -17,8 +17,8 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"FrameBufferService", framebufferService}, - {"CommandBufferRecorderService", commandBufferRecorderService} + {"FrameBufferService", &framebufferService}, + {"CommandBufferRecorderService", &commandBufferRecorderService} }; } diff --git a/src/engine/frame-builder/structures/FramebufferBuilder.h b/src/engine/frame-builder/structures/FramebufferBuilder.h index b439cffa..d1b4807d 100644 --- a/src/engine/frame-builder/structures/FramebufferBuilder.h +++ b/src/engine/frame-builder/structures/FramebufferBuilder.h @@ -24,7 +24,7 @@ namespace Metal { FrameBufferService *frameBufferService = nullptr; public: std::vector getDependencies() override { - return {{"FrameBufferService", frameBufferService}}; + return {{"FrameBufferService", &frameBufferService}}; } explicit FramebufferBuilder(const std::string &id, const unsigned w, const unsigned h, glm::vec4 clearColor) diff --git a/src/engine/frame-builder/structures/TextureBuilder.h b/src/engine/frame-builder/structures/TextureBuilder.h index 3294e0e9..09618bf9 100644 --- a/src/engine/frame-builder/structures/TextureBuilder.h +++ b/src/engine/frame-builder/structures/TextureBuilder.h @@ -14,7 +14,7 @@ namespace Metal { TextureService *textureService = nullptr; public: std::vector getDependencies() override { - return {{"TextureService", textureService}}; + return {{"TextureService", &textureService}}; } explicit TextureBuilder(const std::string &id, unsigned w, unsigned h, VkFormat format = VK_FORMAT_R16G16B16A16_SFLOAT) diff --git a/src/engine/passes/CommandBufferRecorder.cpp b/src/engine/passes/CommandBufferRecorder.cpp index e523f940..326f9765 100644 --- a/src/engine/passes/CommandBufferRecorder.cpp +++ b/src/engine/passes/CommandBufferRecorder.cpp @@ -11,7 +11,7 @@ #include "../../core/FrameService.h" namespace Metal { - void CommandBufferRecorder::createCommandBuffer() { + void CommandBufferRecorder::onInitialize() { VkCommandBufferAllocateInfo allocInfo{}; allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; allocInfo.commandPool = vulkanContext->commandPool; @@ -36,12 +36,10 @@ namespace Metal { scissor.extent.width = frameBuffer->bufferWidth; scissor.extent.height = frameBuffer->bufferHeight; - createCommandBuffer(); computePassMode = false; } - CommandBufferRecorder::CommandBufferRecorder(std::string id) : RuntimeResource(std::move(id)) { - createCommandBuffer(); + CommandBufferRecorder::CommandBufferRecorder(const std::string &id) : RuntimeResource(id) { computePassMode = true; } diff --git a/src/engine/passes/CommandBufferRecorder.h b/src/engine/passes/CommandBufferRecorder.h index e5348c57..95a3733d 100644 --- a/src/engine/passes/CommandBufferRecorder.h +++ b/src/engine/passes/CommandBufferRecorder.h @@ -3,6 +3,8 @@ #include "../resource/RuntimeResource.h" #include #include + +#include "../../common/IInit.h" #include "../resource/PipelineInstance.h" #include "../../core/vulkan/VulkanUtils.h" @@ -12,7 +14,7 @@ namespace Metal { class ApplicationContext; struct FrameBufferInstance; - class CommandBufferRecorder final : public RuntimeResource { + class CommandBufferRecorder final : public RuntimeResource, public IInit { std::array _commandBuffers{}; VkViewport viewport{}; VkRect2D scissor{}; @@ -29,12 +31,14 @@ namespace Metal { public: std::vector getDependencies() override { - return {{"FrameService", frameService}, {"VulkanContext", vulkanContext}}; + return {{"FrameService", &frameService}, {"VulkanContext", &vulkanContext}}; } + void onInitialize() override; + explicit CommandBufferRecorder(std::string id, FrameBufferInstance *frameBuffer, bool clearBuffer = true); - explicit CommandBufferRecorder(std::string id); + explicit CommandBufferRecorder(const std::string &id); ResourceType resourceType() override { return COMMAND_BUFFER_RECORDER; diff --git a/src/engine/passes/impl/HWRayTracingPass.h b/src/engine/passes/impl/HWRayTracingPass.h index c8e9601a..9774c65d 100644 --- a/src/engine/passes/impl/HWRayTracingPass.h +++ b/src/engine/passes/impl/HWRayTracingPass.h @@ -23,11 +23,11 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"RayTracingService", rayTracingService}, - {"PipelineService", pipelineService}, - {"VulkanContext", vulkanContext}, - {"EngineContext", engineContext}, - {"EngineRepository", engineRepository} + {"RayTracingService", &rayTracingService}, + {"PipelineService", &pipelineService}, + {"VulkanContext", &vulkanContext}, + {"EngineContext", &engineContext}, + {"EngineRepository", &engineRepository} }; } diff --git a/src/engine/passes/impl/PostProcessingPass.h b/src/engine/passes/impl/PostProcessingPass.h index 9cf49ab9..15b31a27 100644 --- a/src/engine/passes/impl/PostProcessingPass.h +++ b/src/engine/passes/impl/PostProcessingPass.h @@ -18,9 +18,9 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"VulkanContext", vulkanContext}, - {"PipelineService", pipelineService}, - {"WorldRepository", worldRepository} + {"VulkanContext", &vulkanContext}, + {"PipelineService", &pipelineService}, + {"WorldRepository", &worldRepository} }; } diff --git a/src/engine/passes/impl/SpatialFilterPass.h b/src/engine/passes/impl/SpatialFilterPass.h index 9edd07ca..515cca51 100644 --- a/src/engine/passes/impl/SpatialFilterPass.h +++ b/src/engine/passes/impl/SpatialFilterPass.h @@ -11,7 +11,7 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"PipelineService", pipelineService} + {"PipelineService", &pipelineService} }; } diff --git a/src/engine/passes/impl/TemporalAccumulationPass.h b/src/engine/passes/impl/TemporalAccumulationPass.h index ff7c467c..f2ed2798 100644 --- a/src/engine/passes/impl/TemporalAccumulationPass.h +++ b/src/engine/passes/impl/TemporalAccumulationPass.h @@ -11,7 +11,7 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"PipelineService", pipelineService} + {"PipelineService", &pipelineService} }; } diff --git a/src/engine/repository/WorldRepository.h b/src/engine/repository/WorldRepository.h index 8ed4ee40..8f62fa62 100644 --- a/src/engine/repository/WorldRepository.h +++ b/src/engine/repository/WorldRepository.h @@ -25,8 +25,8 @@ namespace Metal { std::vector getDependencies() override { return { - {"RayTracingService", rayTracingService}, - {"DirectoryService", directoryService} + {"RayTracingService", &rayTracingService}, + {"DirectoryService", &directoryService} }; } diff --git a/src/engine/resource/FrameBufferAttachment.cpp b/src/engine/resource/FrameBufferAttachment.cpp index 00bbfe33..c580b7b8 100644 --- a/src/engine/resource/FrameBufferAttachment.cpp +++ b/src/engine/resource/FrameBufferAttachment.cpp @@ -7,9 +7,5 @@ namespace Metal { vkDestroyImage(vulkanContext->device.device, vkImage, nullptr); vkDestroyImageView(vulkanContext->device.device, vkImageView, nullptr); vkFreeMemory(vulkanContext->device.device, vkImageMemory, nullptr); - - if (imageDescriptor != nullptr) { - descriptorSetService->disposeResource(imageDescriptor); - } } } diff --git a/src/engine/resource/FrameBufferAttachment.h b/src/engine/resource/FrameBufferAttachment.h index 6a1b102c..9f33e11e 100644 --- a/src/engine/resource/FrameBufferAttachment.h +++ b/src/engine/resource/FrameBufferAttachment.h @@ -15,6 +15,13 @@ namespace Metal { void dispose() const; + std::vector getDependencies() override { + return { + {"VulkanContext", &vulkanContext}, + {"DescriptorSetService", &descriptorSetService} + }; + } + private: VulkanContext *vulkanContext = nullptr; DescriptorSetService *descriptorSetService = nullptr; diff --git a/src/engine/resource/RuntimeResource.h b/src/engine/resource/RuntimeResource.h index e3952bcc..16c485f2 100644 --- a/src/engine/resource/RuntimeResource.h +++ b/src/engine/resource/RuntimeResource.h @@ -21,7 +21,7 @@ namespace Metal { public: std::vector getDependencies() override { - return {{"VulkanContext", vulkanContext}}; + return {{"VulkanContext", &vulkanContext}}; } virtual ~RuntimeResource() = default; diff --git a/src/engine/service/CameraService.h b/src/engine/service/CameraService.h index 7e2fe9cb..c4552745 100644 --- a/src/engine/service/CameraService.h +++ b/src/engine/service/CameraService.h @@ -51,9 +51,9 @@ namespace Metal { std::vector getDependencies() override { return { - {"EngineContext", engineContext}, - {"WorldRepository", worldRepository}, - {"RuntimeRepository", runtimeRepository} + {"EngineContext", &engineContext}, + {"WorldRepository", &worldRepository}, + {"RuntimeRepository", &runtimeRepository} }; } diff --git a/src/engine/service/DescriptorSetService.h b/src/engine/service/DescriptorSetService.h index 52e420fe..d0ff4df0 100644 --- a/src/engine/service/DescriptorSetService.h +++ b/src/engine/service/DescriptorSetService.h @@ -22,10 +22,10 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"VulkanContext", vulkanContext}, - {"FrameBufferService", framebufferService}, - {"BufferService", bufferService}, - {"TextureService", textureService} + {"VulkanContext", &vulkanContext}, + {"FrameBufferService", &framebufferService}, + {"BufferService", &bufferService}, + {"TextureService", &textureService} }; } diff --git a/src/engine/service/FrameBufferService.cpp b/src/engine/service/FrameBufferService.cpp index 0292ea33..a47cb814 100644 --- a/src/engine/service/FrameBufferService.cpp +++ b/src/engine/service/FrameBufferService.cpp @@ -111,6 +111,7 @@ namespace Metal { for (unsigned int i = 0; i < framebuffer->attachments.size(); i++) { VkAttachmentDescription &attachmentDescription = attachmentDescriptions.emplace_back(); const std::shared_ptr fbAttachment = framebuffer->attachments[i]; + ctx->injectDependencies(fbAttachment.get()); attachmentDescription.samples = VK_SAMPLE_COUNT_1_BIT; attachmentDescription.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; attachmentDescription.storeOp = VK_ATTACHMENT_STORE_OP_STORE; diff --git a/src/engine/service/FrameBufferService.h b/src/engine/service/FrameBufferService.h index 76676188..5c077a77 100644 --- a/src/engine/service/FrameBufferService.h +++ b/src/engine/service/FrameBufferService.h @@ -25,7 +25,7 @@ namespace Metal { public: std::vector getDependencies() override { - return {{"VulkanContext", vulkanContext}}; + return {{"VulkanContext", &vulkanContext}}; } FrameBufferInstance *createFrameBuffer(const std::string &id, unsigned int w, unsigned int h, diff --git a/src/engine/service/LightService.h b/src/engine/service/LightService.h index 3a5c7575..9764b680 100644 --- a/src/engine/service/LightService.h +++ b/src/engine/service/LightService.h @@ -28,8 +28,8 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"EngineContext", engineContext}, - {"EngineRepository", engineRepository} + {"EngineContext", &engineContext}, + {"EngineRepository", &engineRepository} }; } diff --git a/src/engine/service/MaterialService.h b/src/engine/service/MaterialService.h index 660c48b8..1656406f 100644 --- a/src/engine/service/MaterialService.h +++ b/src/engine/service/MaterialService.h @@ -13,7 +13,7 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"TextureService", textureService} + {"TextureService", &textureService} }; } diff --git a/src/engine/service/MeshService.h b/src/engine/service/MeshService.h index b7984f35..0fa3241b 100644 --- a/src/engine/service/MeshService.h +++ b/src/engine/service/MeshService.h @@ -23,9 +23,9 @@ namespace Metal { std::vector getDependencies() override { return { - {"BufferService", bufferService}, - {"RayTracingService", rayTracingService}, - {"DirectoryService", directoryService} + {"BufferService", &bufferService}, + {"RayTracingService", &rayTracingService}, + {"DirectoryService", &directoryService} }; } diff --git a/src/engine/service/RayTracingService.cpp b/src/engine/service/RayTracingService.cpp index af1fac86..a0c103f6 100644 --- a/src/engine/service/RayTracingService.cpp +++ b/src/engine/service/RayTracingService.cpp @@ -405,9 +405,6 @@ namespace Metal { } void RayTracingService::dispose() { - LOG_INFO("Destroying acceleration structures"); - auto &vulkan = vulkanContext; - if (vulkanContext->device.device != VK_NULL_HANDLE) { vkDeviceWaitIdle(vulkanContext->device.device); } diff --git a/src/engine/service/RayTracingService.h b/src/engine/service/RayTracingService.h index c4325efe..cec2bca4 100644 --- a/src/engine/service/RayTracingService.h +++ b/src/engine/service/RayTracingService.h @@ -75,14 +75,14 @@ namespace Metal { std::vector getDependencies() override { return { - {"VulkanContext", vulkanContext}, - {"PipelineService", pipelineService}, - {"WorldRepository", worldRepository}, - {"MeshService", meshService}, - {"MaterialService", materialService}, - {"BufferService", bufferService}, - {"EngineContext", engineContext}, - {"DescriptorSetService", descriptorSetService} + {"VulkanContext", &vulkanContext}, + {"PipelineService", &pipelineService}, + {"WorldRepository", &worldRepository}, + {"MeshService", &meshService}, + {"MaterialService", &materialService}, + {"BufferService", &bufferService}, + {"EngineContext", &engineContext}, + {"DescriptorSetService", &descriptorSetService} }; } diff --git a/src/engine/service/ShaderService.cpp b/src/engine/service/ShaderService.cpp index 30d8b467..8fc26d80 100644 --- a/src/engine/service/ShaderService.cpp +++ b/src/engine/service/ShaderService.cpp @@ -15,10 +15,9 @@ #include "../../editor/enum/ShadingMode.h" #include "glslang/Include/glslang_c_interface.h" #include "glslang/Public/resource_limits_c.h" -#define BASE_PATH directoryService->getShadersDirectory() - #include "../../core/DirectoryService.h" #include "../../core/vulkan/VulkanContext.h" +#define BASE_PATH "../resources/shaders/" namespace Metal { void ShaderService::CheckShaderCompilation(glslang_shader_t *shader) { @@ -134,7 +133,7 @@ namespace Metal { throw std::runtime_error("Unknown shader stage in file"); } - std::string ShaderService::ProcessIncludes(const std::string &input, const std::string &basePath) { + std::string ShaderService::ProcessIncludes(const std::string &input) { std::string result = input; std::regex includePattern(R"(#include\s+"(.+))"); std::smatch match; @@ -147,7 +146,7 @@ namespace Metal { } try { std::string source; - FilesUtil::ReadFile((basePath + includeFile).c_str(), source); + FilesUtil::ReadFile((BASE_PATH + includeFile).c_str(), source); result.replace(match.position(0), match.length(0), source); } catch (const std::exception &e) { LOG_ERROR("Error loading included shader: " + std::string(e.what())); @@ -155,21 +154,20 @@ namespace Metal { } } if (result.find("#include") != std::string::npos) { - result = ProcessIncludes(result, basePath); + result = ProcessIncludes(result); } return result; } - std::string ShaderService::ProcessShader(const std::string &file, const std::string &basePath) { + std::string ShaderService::ProcessShader(const std::string &file) { std::string source; FilesUtil::ReadFile(file.c_str(), source); - return ProcessIncludes(source, basePath); + return ProcessIncludes(source); } VkShaderModule ShaderService::createShaderModule(const std::string &pFilename) { - this->isDebugMode = ctx->isDebugMode(); - std::string source = ProcessShader(BASE_PATH + pFilename, BASE_PATH); - if (isDebugMode) { + std::string source = ProcessShader(BASE_PATH + pFilename); + if (ctx->isDebugMode()) { source = "#define DEBUG\n" + source; } for (auto &entry: ShadingModes::getShaderEntries()) { @@ -181,9 +179,8 @@ namespace Metal { const size_t sourceHash = std::hash{}(source); const std::string part(BASE_PATH + pFilename); const std::string shaderName = part.substr(part.find_last_of('/') + 1, part.size()); - const std::string shadersDirectory = directoryService->getShadersDirectory(); - const std::string binaryFilename = shadersDirectory + shaderName + ".spv"; - const std::string hashFilename = shadersDirectory + shaderName + ".hash"; + const std::string binaryFilename = directoryService->getShadersDirectory() + shaderName + ".spv"; + const std::string hashFilename = directoryService->getShadersDirectory() + shaderName + ".hash"; ShaderModule shader{}; diff --git a/src/engine/service/ShaderService.h b/src/engine/service/ShaderService.h index 19199570..98f5b929 100644 --- a/src/engine/service/ShaderService.h +++ b/src/engine/service/ShaderService.h @@ -8,29 +8,29 @@ namespace Metal { class VulkanContext; class DirectoryService; + class ShaderService final : public IService { - bool isDebugMode = false; VulkanContext *vulkanContext = nullptr; DirectoryService *directoryService = nullptr; static void CheckShaderCompilation(glslang_shader_t *shader); - bool CompileShader(glslang_stage_t stage, const char *pShaderCode, - ShaderModule *shaderModule) const; + bool CompileShader(glslang_stage_t stage, const char *pShaderCode, + ShaderModule *shaderModule) const; static glslang_stage_t ShaderStageFromFilename(const char *pFilename); - static std::string ProcessIncludes(const std::string &input, const std::string &basePath); + std::string ProcessIncludes(const std::string &input); - static std::string ProcessShader(const std::string &file, const std::string &basePath); + std::string ProcessShader(const std::string &file); public: ShaderService() = default; std::vector getDependencies() override { return { - {"VulkanContext", vulkanContext}, - {"DirectoryService", directoryService} + {"VulkanContext", &vulkanContext}, + {"DirectoryService", &directoryService} }; } diff --git a/src/engine/service/StreamingService.h b/src/engine/service/StreamingService.h index 44201422..2eecf222 100644 --- a/src/engine/service/StreamingService.h +++ b/src/engine/service/StreamingService.h @@ -33,11 +33,11 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"EngineContext", engineContext}, - {"WorldRepository", worldRepository}, - {"MeshService", meshService}, - {"TextureService", textureService}, - {"VoxelService", voxelService} + {"EngineContext", &engineContext}, + {"WorldRepository", &worldRepository}, + {"MeshService", &meshService}, + {"TextureService", &textureService}, + {"VoxelService", &voxelService} }; } diff --git a/src/engine/service/TextureService.h b/src/engine/service/TextureService.h index 047561e7..abc1bd26 100644 --- a/src/engine/service/TextureService.h +++ b/src/engine/service/TextureService.h @@ -45,11 +45,11 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"VulkanContext", vulkanContext}, - {"BufferService", bufferService}, - {"PipelineService", pipelineService}, - {"DescriptorSetService", descriptorSetService}, - {"DirectoryService", directoryService} + {"VulkanContext", &vulkanContext}, + {"BufferService", &bufferService}, + {"PipelineService", &pipelineService}, + {"DescriptorSetService", &descriptorSetService}, + {"DirectoryService", &directoryService} }; } diff --git a/src/engine/service/TransformService.h b/src/engine/service/TransformService.h index f221dde7..bab96925 100644 --- a/src/engine/service/TransformService.h +++ b/src/engine/service/TransformService.h @@ -25,8 +25,8 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"WorldRepository", worldRepository}, - {"RayTracingService", rayTracingService} + {"WorldRepository", &worldRepository}, + {"RayTracingService", &rayTracingService} }; } diff --git a/src/engine/service/VolumeService.h b/src/engine/service/VolumeService.h index eada2e3d..70ff3a1e 100644 --- a/src/engine/service/VolumeService.h +++ b/src/engine/service/VolumeService.h @@ -21,8 +21,8 @@ namespace Metal { public: std::vector getDependencies() override { return { - {"WorldRepository", worldRepository}, - {"EngineContext", engineContext} + {"WorldRepository", &worldRepository}, + {"EngineContext", &engineContext} }; } diff --git a/src/main.cpp b/src/main.cpp index 8c08e1ab..3fd38ca0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -104,13 +104,18 @@ int main(int, char **) { directoryService.updateRootPath(false); Metal::EditorPanel editor{}; context->injectDependencies(&editor); + editor.onInitialize(); frameService.setPanel(&editor); if (!frameService.isValidContext()) { printf("GLFW: Vulkan Not Supported\n"); return 1; } - frameService.onInitialize(); + frameService.start(); context->dispose(); + context->getSingleton().disposeManually(); + context->getSingleton().disposeManually(); + context->getSingleton().disposeManually(); + return 0; } From 7d8f838202b34513cb28f5caaf42f26c08944e5a Mon Sep 17 00:00:00 2001 From: facobackup Date: Sat, 14 Mar 2026 20:21:07 -0300 Subject: [PATCH 09/11] Tests Adjusting layout --- .output.txt | 303 ----------------- CMakeLists.txt | 306 ++---------------- ...SelectedDot.frag => SelectionOutline.frag} | 0 src/ApplicationContext.cpp | 7 + src/ApplicationContext.h | 3 + src/CMakeLists.txt | 296 +++++++++++++++++ src/core/vulkan/VulkanContext.cpp | 3 +- src/core/vulkan/VulkanContext.h | 1 - src/editor/EditorPanel.cpp | 86 +++-- src/editor/EditorPanel.h | 4 - .../dock-spaces/footer/EditorFooterPanel.cpp | 12 +- .../dock-spaces/footer/EditorFooterPanel.h | 5 + .../dock-spaces/header/AsyncTaskPanel.cpp | 44 ++- .../dock-spaces/header/EditorHeaderPanel.cpp | 63 ++-- .../dock-spaces/header/EditorHeaderPanel.h | 17 +- src/editor/passes/GridPass.cpp | 3 +- src/editor/passes/GridPass.h | 3 - src/editor/passes/SelectionOutlinePass.cpp | 2 +- src/main.cpp | 7 - tests/ApplicationContextTest.cpp | 39 +++ tests/CMakeLists.txt | 21 ++ tests/WorldRepositoryTest.cpp | 64 ++++ vcpkg.json | 8 +- 23 files changed, 587 insertions(+), 710 deletions(-) delete mode 100644 .output.txt rename resources/shaders/tools/{SelectedDot.frag => SelectionOutline.frag} (100%) create mode 100644 src/CMakeLists.txt create mode 100644 tests/ApplicationContextTest.cpp create mode 100644 tests/CMakeLists.txt create mode 100644 tests/WorldRepositoryTest.cpp diff --git a/.output.txt b/.output.txt deleted file mode 100644 index 7bda7820..00000000 --- a/.output.txt +++ /dev/null @@ -1,303 +0,0 @@ -[23/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\passes\AbstractPass.cpp.obj -C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.cpp(57): warning C4267: 'argument': conversion from 'size_t' to 'uint32_t', possible loss of data -[24/44] Building CXX object CMakeFiles\metal_engine...editor\dock-spaces\header\EditorHeaderPanel.cpp.obj -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(48): warning C4244: 'initializing': conversion from 'int' to 'float', possible loss of data -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(48): warning C4244: 'initializing': conversion from 'int' to 'const float', possible loss of data -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -C:\Users\russi\CLionProjects\metal-engine\src\editor\util\../enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(46): warning C4505: 'Metal::UIUtil::RenderOption': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(52): warning C4505: 'Metal::UIUtil::RenderTooltip': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(66): warning C4505: 'Metal::UIUtil::Spacing': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(72): warning C4505: 'Metal::UIUtil::DynamicSpacing': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(102): warning C4505: 'Metal::UIUtil::DrawVec2Control': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(119): warning C4505: 'Metal::UIUtil::DrawVec3Control': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(159): warning C4505: 'Metal::UIUtil::DrawQuatControl': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(163): warning C4505: 'Metal::UIUtil::GetKeyChordName': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\header\../../util/UIUtil.h(179): warning C4505: 'Metal::UIUtil::GetEntryIcon': unreferenced function with internal linkage has been removed -[25/44] Building CXX object CMakeFiles\metal_engine.dir\src\ApplicationContext.cpp.obj -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -[26/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\passes\impl\HWRayTracingPass.cpp.obj -C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/MeshMetadata.h(13): warning C4324: 'Metal::MeshMetadata': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\impl\../../service/RayTracingService.h(15): warning C4099: 'Metal::BufferInstance': type name first seen using 'struct' now seen using 'class' -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\DescriptorBinding.h(8): note: see declaration of 'Metal::BufferInstance' -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\common\Inspectable.h(125): warning C4100: 'member': unreferenced parameter -C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed -[27/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\service\LightService.cpp.obj -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/LightData.h(11): warning C4324: 'Metal::LightData': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/LightData.h(12): warning C4324: 'Metal::LightData': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\LightService.h(49): warning C4267: 'return': conversion from 'size_t' to 'unsigned int', possible loss of data -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -C:\Users\russi\CLionProjects\metal-engine\src\common\Inspectable.h(125): warning C4100: 'member': unreferenced parameter -C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed -[28/44] Building CXX object CMakeFiles\metal_engine...c\editor\dock-spaces\viewport\ViewportPanel.cpp.obj -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\../../common/Inspectable.h(125): warning C4100: 'member': unreferenced parameter -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\viewport\../../repository/EditorRepository.h(33): warning C4305: 'initializing': truncation from 'double' to 'float' -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\viewport\../../../engine/repository/WorldRepository.h(15): warning C4099: 'Metal::DirectoryService': type name first seen using 'struct' now seen using 'class' -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\viewport\ViewportPanel.h(13): note: see declaration of 'Metal::DirectoryService' -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(14): warning C4458: declaration of 'entityId' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(31): note: see declaration of 'Metal::AbstractComponent::entityId' -C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed -[29/44] Building CXX object CMakeFiles\metal_engine.dir\src\editor\panel\NotificationsPanel.cpp.obj -C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(48): warning C4244: 'initializing': conversion from 'int' to 'float', possible loss of data -C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(48): warning C4244: 'initializing': conversion from 'int' to 'const float', possible loss of data -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -C:\Users\russi\CLionProjects\metal-engine\src\editor\util\../enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(40): warning C4505: 'Metal::UIUtil::ButtonSimple': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(46): warning C4505: 'Metal::UIUtil::RenderOption': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(52): warning C4505: 'Metal::UIUtil::RenderTooltip': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(60): warning C4505: 'Metal::UIUtil::LargeSpacing': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(66): warning C4505: 'Metal::UIUtil::Spacing': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(72): warning C4505: 'Metal::UIUtil::DynamicSpacing': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(102): warning C4505: 'Metal::UIUtil::DrawVec2Control': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(119): warning C4505: 'Metal::UIUtil::DrawVec3Control': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(159): warning C4505: 'Metal::UIUtil::DrawQuatControl': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(163): warning C4505: 'Metal::UIUtil::GetKeyChordName': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\panel\../util/UIUtil.h(179): warning C4505: 'Metal::UIUtil::GetEntryIcon': unreferenced function with internal linkage has been removed -[30/44] Building CXX object CMakeFiles\metal_engine...ditor\dock-spaces\viewport\EngineFramePanel.cpp.obj -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\viewport\../../../engine/dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\viewport\../../../engine/dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\viewport\../../../engine/dto/LightData.h(11): warning C4324: 'Metal::LightData': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\viewport\../../../engine/dto/LightData.h(12): warning C4324: 'Metal::LightData': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\viewport\../../../engine/dto/VolumeData.h(11): warning C4324: 'Metal::VolumeData': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\viewport\../../../engine/dto/VolumeData.h(12): warning C4324: 'Metal::VolumeData': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\editor\dock-spaces\viewport\../../../engine/dto/MeshMetadata.h(13): warning C4324: 'Metal::MeshMetadata': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\impl\../../dto/PostProcessingPushConstant.h(9): warning C4324: 'Metal::PostProcessingPushConstant': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\impl\../../dto/PostProcessingPushConstant.h(10): warning C4324: 'Metal::PostProcessingPushConstant': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\common\Inspectable.h(125): warning C4100: 'member': unreferenced parameter -C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed -[31/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\service\StreamingService.cpp.obj -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -C:\Users\russi\CLionProjects\metal-engine\src\common\Inspectable.h(125): warning C4100: 'member': unreferenced parameter -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/TextureData.h(16): warning C4244: 'initializing': conversion from 'T' to 'int', possible loss of data - with - [ - T=float - ] -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/TextureData.h(16): warning C4244: 'initializing': conversion from 'T' to 'const int', possible loss of data - with - [ - T=float - ] -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/TextureData.h(17): warning C4244: 'initializing': conversion from 'T' to 'int', possible loss of data - with - [ - T=float - ] -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/TextureData.h(17): warning C4244: 'initializing': conversion from 'T' to 'const int', possible loss of data - with - [ - T=float - ] -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(14): warning C4458: declaration of 'entityId' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(31): note: see declaration of 'Metal::AbstractComponent::entityId' -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/PrimitiveComponent.h(20): warning C4305: 'initializing': truncation from 'double' to 'float' -C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed -[32/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\service\CameraService.cpp.obj -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\../../common/Inspectable.h(125): warning C4100: 'member': unreferenced parameter -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed -[33/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\EngineContext.cpp.obj -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/MeshMetadata.h(13): warning C4324: 'Metal::MeshMetadata': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\service/RayTracingService.h(15): warning C4099: 'Metal::BufferInstance': type name first seen using 'struct' now seen using 'class' -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../resource/BufferInstance.h(14): note: see declaration of 'Metal::BufferInstance' -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/LightData.h(11): warning C4324: 'Metal::LightData': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/LightData.h(12): warning C4324: 'Metal::LightData': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\service/LightService.h(49): warning C4267: 'return': conversion from 'size_t' to 'unsigned int', possible loss of data -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/VolumeData.h(11): warning C4324: 'Metal::VolumeData': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/VolumeData.h(12): warning C4324: 'Metal::VolumeData': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\service/VolumeService.h(32): warning C4267: 'return': conversion from 'size_t' to 'unsigned int', possible loss of data -C:\Users\russi\CLionProjects\metal-engine\src\common\Inspectable.h(125): warning C4100: 'member': unreferenced parameter -C:\Users\russi\CLionProjects\metal-engine\src\engine\../editor/repository/EditorRepository.h(33): warning C4305: 'initializing': truncation from 'double' to 'float' -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(14): warning C4458: declaration of 'entityId' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(31): note: see declaration of 'Metal::AbstractComponent::entityId' -C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed -[34/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\passes\impl\PostProcessingPass.cpp.obj -C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\impl\../../dto/PostProcessingPushConstant.h(9): warning C4324: 'Metal::PostProcessingPushConstant': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\impl\../../dto/PostProcessingPushConstant.h(10): warning C4324: 'Metal::PostProcessingPushConstant': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\common\Inspectable.h(125): warning C4100: 'member': unreferenced parameter -C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed -[35/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\frame-builder\EngineFrame.cpp.obj -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -[36/44] Building CXX object CMakeFiles\metal_engine...src\engine\frame-builder\EngineFrameBuilder.cpp.obj -FAILED: CMakeFiles/metal_engine.dir/src/engine/frame-builder/EngineFrameBuilder.cpp.obj -C:\PROGRA~1\MICROS~2\18\COMMUN~1\VC\Tools\MSVC\1450~1.357\bin\Hostx64\x64\cl.exe /nologo /TP -DBOOST_IOSTREAMS_DYN_LINK -DBOOST_IOSTREAMS_NO_LIB -DBOOST_RANDOM_DYN_LINK -DBOOST_RANDOM_NO_LIB -DFMT_SHARED -DGLFW_DLL -DIMATH_DLL -DIMGUI_ENABLE_FREETYPE -DMESHOPTIMIZER_API=__declspec(dllimport) -DNFD_SHARED -DNOMINMAX -DOPENVDB_ABI_VERSION_NUMBER=12 -DOPENVDB_DLL -DOPENVDB_USE_DELAYED_LOADING -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -DTBB_USE_DEBUG -D_WIN32 -IC:\Users\russi\CLionProjects\metal-engine\dependencies\vk-bootstrap\src -external:IC:\Users\russi\CLionProjects\metal-engine\cmake-build-debug-visual-studio\vcpkg_installed\x64-windows\include -external:IC:\Users\russi\CLionProjects\metal-engine\cmake-build-debug-visual-studio\vcpkg_installed\x64-windows\include\vma -external:IC:\Users\russi\CLionProjects\metal-engine\cmake-build-debug-visual-studio\vcpkg_installed\x64-windows\include\Imath -external:W0 /DWIN32 /D_WINDOWS /EHsc -DVK_PROTOTYPES /Ob0 /Od /RTC1 -std:c++20 -MDd -Zi /W4 /wd4251 /wd4275 /utf-8 /EHsc /showIncludes @CMakeFiles\metal_engine.dir\src\engine\frame-builder\EngineFrameBuilder.cpp.obj.modmap /FoCMakeFiles\metal_engine.dir\src\engine\frame-builder\EngineFrameBuilder.cpp.obj /FdCMakeFiles\metal_engine.dir\ /FS -c C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\EngineFrameBuilder.cpp -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\xmemory(734): error C2672: 'std::construct_at': no matching overloaded function found -C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\xutility(507): note: could be '_Ty *std::construct_at(_Ty *const ,_Types ...) noexcept()' -C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\xmemory(734): note: the associated constraints are not satisfied -C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\xutility(505): note: 'std::unique_ptr>::unique_ptr(const std::unique_ptr> &)': attempting to reference a deleted function -C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\memory(3504): note: see declaration of 'std::unique_ptr>::unique_ptr' -C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\memory(3504): note: 'std::unique_ptr>::unique_ptr(const std::unique_ptr> &)': function was explicitly deleted -C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\xutility(505): note: 'std::unique_ptr>::unique_ptr(const std::unique_ptr> &)': attempting to reference a deleted function -C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\memory(3504): note: see declaration of 'std::unique_ptr>::unique_ptr' -C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\memory(3504): note: 'std::unique_ptr>::unique_ptr(const std::unique_ptr> &)': function was explicitly deleted -C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\xmemory(734): note: the template instantiation context (the oldest one first) is -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\EngineFrameBuilder.cpp(127): note: see reference to class template instantiation 'std::vector>,std::allocator>>>' being compiled -C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\vector(745): note: while compiling class template member function 'std::vector>,std::allocator>>>::vector(const std::vector>,std::allocator>>> &)' -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\EngineFrameBuilder.cpp(132): note: see the first reference to 'std::vector>,std::allocator>>>::vector' in 'Metal::EngineFrameBuilder::build' -C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\vector(749): note: see reference to function template instantiation 'void std::vector>,std::allocator>>>::_Construct_n>*const &,std::unique_ptr>*const &>(const unsigned __int64,std::unique_ptr> *const &,std::unique_ptr> *const &)' being compiled -C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\vector(2120): note: see reference to function template instantiation 'std::unique_ptr> *std::_Uninitialized_copy>*,std::unique_ptr>*,std::allocator>>>(_InIt,_Se,std::unique_ptr> *,_Alloc &)' being compiled - with - [ - _InIt=std::unique_ptr> *, - _Se=std::unique_ptr> *, - _Alloc=std::allocator>> - ] -C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\xmemory(1922): note: see reference to function template instantiation 'void std::_Uninitialized_backout_al>>>::_Emplace_back>&>(std::unique_ptr> &)' being compiled -C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\include\xmemory(1864): note: see reference to function template instantiation 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,std::unique_ptr>&>(_Alloc &,_Objty *const ,std::unique_ptr> &)' being compiled - with - [ - _Alloc=std::allocator>>, - _Ty=std::unique_ptr>, - _Objty=std::unique_ptr> - ] -[37/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\enum\ComponentType.cpp.obj -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -C:\Users\russi\CLionProjects\metal-engine\src\common\Inspectable.h(125): warning C4100: 'member': unreferenced parameter -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/MeshMetadata.h(13): warning C4324: 'Metal::MeshMetadata': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\enum\../service/RayTracingService.h(15): warning C4099: 'Metal::BufferInstance': type name first seen using 'struct' now seen using 'class' -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../resource/BufferInstance.h(14): note: see declaration of 'Metal::BufferInstance' -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(14): warning C4458: declaration of 'entityId' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(31): note: see declaration of 'Metal::AbstractComponent::entityId' -C:\Users\russi\CLionProjects\metal-engine\src\engine\enum\../dto/PrimitiveComponent.h(20): warning C4305: 'initializing': truncation from 'double' to 'float' -C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed -[38/44] Building CXX object CMakeFiles\metal_engine...engine\passes\impl\TemporalAccumulationPass.cpp.obj -C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -[39/44] Building CXX object CMakeFiles\metal_engine.dir\src\main.cpp.obj -C:\Users\russi\CLionProjects\metal-engine\src\editor\dto\../../common//Inspectable.h(125): warning C4100: 'member': unreferenced parameter -C:\Users\russi\CLionProjects\metal-engine\src\editor\service\../../common/AbstractImporter.h(19): warning C4100: 'stopToken': unreferenced parameter -C:\Users\russi\CLionProjects\metal-engine\src\editor\service\../../common/AbstractImporter.h(18): warning C4100: 'settings': unreferenced parameter -C:\Users\russi\CLionProjects\metal-engine\src\editor\service\../../common/AbstractImporter.h(17): warning C4100: 'pathToFile': unreferenced parameter -C:\Users\russi\CLionProjects\metal-engine\src\editor\service\../../common/AbstractImporter.h(17): warning C4100: 'targetDir': unreferenced parameter -C:\Users\russi\CLionProjects\metal-engine\src\editor/service/TextureImporterService.h(8): warning C4099: 'Metal::DirectoryService': type name first seen using 'struct' now seen using 'class' -C:\Users\russi\CLionProjects\metal-engine\src\core/DirectoryService.h(11): note: see declaration of 'Metal::DirectoryService' -C:\Users\russi\CLionProjects\metal-engine\src\editor/service/VoxelImporterService.h(9): warning C4099: 'Metal::DirectoryService': type name first seen using 'struct' now seen using 'class' -C:\Users\russi\CLionProjects\metal-engine\src\core/DirectoryService.h(11): note: see declaration of 'Metal::DirectoryService' -C:\Users\russi\CLionProjects\metal-engine\src\editor/repository/EditorRepository.h(33): warning C4305: 'initializing': truncation from 'double' to 'float' -C:\Users\russi\CLionProjects\metal-engine\src\engine/repository/WorldRepository.h(15): warning C4099: 'Metal::DirectoryService': type name first seen using 'struct' now seen using 'class' -C:\Users\russi\CLionProjects\metal-engine\src\core/DirectoryService.h(11): note: see declaration of 'Metal::DirectoryService' -C:\Users\russi\CLionProjects\metal-engine\src\engine/service/CommandBufferRecorderService.h(10): warning C4100: 'resource': unreferenced parameter -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/LightData.h(11): warning C4324: 'Metal::LightData': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/LightData.h(12): warning C4324: 'Metal::LightData': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine/service/LightService.h(49): warning C4267: 'return': conversion from 'size_t' to 'unsigned int', possible loss of data -C:\Users\russi\CLionProjects\metal-engine\src\engine/service/MeshService.h(14): warning C4099: 'Metal::DirectoryService': type name first seen using 'struct' now seen using 'class' -C:\Users\russi\CLionProjects\metal-engine\src\core/DirectoryService.h(11): note: see declaration of 'Metal::DirectoryService' -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/MeshMetadata.h(13): warning C4324: 'Metal::MeshMetadata': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine/service/RayTracingService.h(15): warning C4099: 'Metal::BufferInstance': type name first seen using 'struct' now seen using 'class' -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../resource/BufferInstance.h(14): note: see declaration of 'Metal::BufferInstance' -C:\Users\russi\CLionProjects\metal-engine\src\engine/service/ShaderService.h(10): warning C4099: 'Metal::DirectoryService': type name first seen using 'struct' now seen using 'class' -C:\Users\russi\CLionProjects\metal-engine\src\core/DirectoryService.h(11): note: see declaration of 'Metal::DirectoryService' -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/TextureData.h(16): warning C4244: 'initializing': conversion from 'T' to 'int', possible loss of data - with - [ - T=float - ] -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/TextureData.h(16): warning C4244: 'initializing': conversion from 'T' to 'const int', possible loss of data - with - [ - T=float - ] -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/TextureData.h(17): warning C4244: 'initializing': conversion from 'T' to 'int', possible loss of data - with - [ - T=float - ] -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/TextureData.h(17): warning C4244: 'initializing': conversion from 'T' to 'const int', possible loss of data - with - [ - T=float - ] -C:\Users\russi\CLionProjects\metal-engine\src\engine/service/TextureService.h(17): warning C4099: 'Metal::DirectoryService': type name first seen using 'struct' now seen using 'class' -C:\Users\russi\CLionProjects\metal-engine\src\core/DirectoryService.h(11): note: see declaration of 'Metal::DirectoryService' -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/VolumeData.h(11): warning C4324: 'Metal::VolumeData': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/VolumeData.h(12): warning C4324: 'Metal::VolumeData': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine/service/VolumeService.h(32): warning C4267: 'return': conversion from 'size_t' to 'unsigned int', possible loss of data -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\service\../enum/NotificationSeverity.h(14): warning C4505: 'Metal::NotificationSeverities::GetIcon': unreferenced function with internal linkage has been removed -C:\Users\russi\CLionProjects\metal-engine\src\editor\service\../enum/NotificationSeverity.h(26): warning C4505: 'Metal::NotificationSeverities::GetColor': unreferenced function with internal linkage has been removed -[40/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\passes\impl\SpatialFilterPass.cpp.obj -C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\passes\AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -[41/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\service\RayTracingService.cpp.obj -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/MeshMetadata.h(13): warning C4324: 'Metal::MeshMetadata': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../resource/BufferInstance.h(14): warning C4099: 'Metal::BufferInstance': type name first seen using 'class' now seen using 'struct' -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../resource/BufferInstance.h(14): note: see declaration of 'Metal::BufferInstance' -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\../../common/Inspectable.h(125): warning C4100: 'member': unreferenced parameter -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(14): warning C4458: declaration of 'entityId' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(31): note: see declaration of 'Metal::AbstractComponent::entityId' -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/PrimitiveComponent.h(20): warning C4305: 'initializing': truncation from 'double' to 'float' -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\RayTracingService.cpp(153): warning C4189: 'vulkan': local variable is initialized but not referenced -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\RayTracingService.cpp(409): warning C4189: 'vulkan': local variable is initialized but not referenced -C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed -[42/44] Building CXX object CMakeFiles\metal_engine.dir\src\core\FrameService.cpp.obj -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -C:\Users\russi\CLionProjects\metal-engine\src\core\FrameService.cpp(26): warning C4458: declaration of 'panel' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\core\FrameService.h(19): note: see declaration of 'Metal::FrameService::panel' -[43/44] Building CXX object CMakeFiles\metal_engine.dir\src\engine\service\VolumeService.cpp.obj -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/VolumeData.h(11): warning C4324: 'Metal::VolumeData': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\../dto/VolumeData.h(12): warning C4324: 'Metal::VolumeData': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\service\VolumeService.h(32): warning C4267: 'return': conversion from 'size_t' to 'unsigned int', possible loss of data -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\../../common/Inspectable.h(125): warning C4100: 'member': unreferenced parameter -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(14): warning C4458: declaration of 'entityId' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto\AbstractComponent.h(31): note: see declaration of 'Metal::AbstractComponent::entityId' -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(14): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\dto/GlobalDataUBO.h(15): warning C4324: 'Metal::GlobalDataUBO': structure was padded due to alignment specifier -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(35): warning C4458: declaration of 'vkCommandBuffer' hides class member -C:\Users\russi\CLionProjects\metal-engine\src\engine\frame-builder\../passes/AbstractPass.h(24): note: see declaration of 'Metal::AbstractPass::vkCommandBuffer' -C:\Users\russi\CLionProjects\metal-engine\src\common\../editor/enum/EntryType.h(33): warning C4505: 'Metal::EntryType::GetDTO': unreferenced function with internal linkage has been removed -ninja: build stopped: subcommand failed. \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d6aebeb..82d1aa80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,293 +4,14 @@ project(metal_engine CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_PROTOTYPES") -add_executable( - metal_engine - src/main.cpp - src/editor/EditorPanel.cpp - src/editor/EditorPanel.h - src/engine/EngineContext.cpp - src/engine/EngineContext.h - src/core/vulkan/VulkanUtils.cpp - src/core/vulkan/VulkanUtils.h - src/core/vulkan/VulkanContext.cpp - src/core/vulkan/VulkanContext.h - src/core/glfw/GLFWContext.cpp - src/core/glfw/GLFWContext.h - src/core/gui/GuiContext.cpp - src/core/gui/GuiContext.h - src/editor/dock-spaces/viewport/ViewportPanel.cpp - src/editor/dock-spaces/viewport/ViewportPanel.h - src/editor/dock-spaces/viewport/EngineFramePanel.cpp - src/editor/dock-spaces/viewport/EngineFramePanel.h - src/editor/dock-spaces/docks/AbstractDockPanel.h - src/ApplicationContext.cpp - src/ApplicationContext.h - src/editor/abstract/AbstractPanel.h - src/editor/abstract/AbstractPanel.cpp - src/common/ISync.h - src/engine/service/CameraService.cpp - src/engine/service/CameraService.h - src/engine/dto/Camera.h - src/editor/util/Util.h - src/common/Inspectable.h - src/common/Inspectable.cpp - src/common/InspectedField.h - src/editor/dock-spaces/inspector/InspectorPanel.cpp - src/editor/dock-spaces/inspector/InspectorPanel.h - src/editor/abstract/form/FormPanel.cpp - src/editor/abstract/form/FormPanel.h - src/editor/abstract/form/AccordionPanel.cpp - src/editor/abstract/form/AccordionPanel.h - src/common/FieldType.h - src/common/InspectableMember.h - src/editor/abstract/form/types/BooleanField.cpp - src/editor/abstract/form/types/BooleanField.h - src/editor/abstract/form/types/IntField.cpp - src/editor/abstract/form/types/IntField.h - src/editor/abstract/form/types/FloatField.cpp - src/editor/abstract/form/types/FloatField.h - src/editor/abstract/form/types/MethodField.cpp - src/editor/abstract/form/types/MethodField.h - src/editor/util/UIUtil.h - src/editor/dock-spaces/header/EditorHeaderPanel.cpp - src/editor/dock-spaces/header/EditorHeaderPanel.h - src/editor/dock-spaces/header/AsyncTaskPanel.cpp - src/editor/dock-spaces/header/AsyncTaskPanel.h - src/editor/dock-spaces/footer/EditorFooterPanel.cpp - src/editor/dock-spaces/footer/EditorFooterPanel.h - src/common/Icons.h - src/editor/service/DockService.cpp - src/editor/service/DockService.h - src/editor/dto/DockDTO.h - src/editor/dto/DockSpace.h - src/editor/dock-spaces/docks/DockSpacePanel.cpp - src/editor/dock-spaces/docks/DockSpacePanel.h - src/editor/dto/DockSpace.cpp - src/editor/service/ThemeService.cpp - src/editor/service/ThemeService.h - src/editor/repository/EditorRepository.h - src/editor/enum/engine-definitions.h - src/editor/dock-spaces/files/FilesPanel.cpp - src/editor/dock-spaces/files/FilesPanel.h - src/editor/dock-spaces/files/FilesListPanel.cpp - src/editor/dock-spaces/files/FilesListPanel.h - src/editor/dock-spaces/files/FilePreviewPanel.cpp - src/editor/dock-spaces/files/FilePreviewPanel.h - src/editor/dock-spaces/console/ConsolePanel.cpp - src/editor/dock-spaces/console/ConsolePanel.h - src/editor/dock-spaces/metrics/MetricsPanel.cpp - src/editor/dock-spaces/metrics/MetricsPanel.h - src/common/LoggerUtil.cpp - src/common/LoggerUtil.h - src/editor/dock-spaces/world/WorldPanel.cpp - src/editor/dock-spaces/world/WorldPanel.h - src/engine/resource/RuntimeResource.h - src/engine/service/ShaderService.cpp - src/engine/service/ShaderService.h - src/engine/dto/ShaderModule.cpp - src/engine/dto/ShaderModule.h - src/engine/passes/AbstractRenderPass.cpp - src/engine/passes/AbstractRenderPass.h - src/common/AbstractResourceService.h - src/engine/resource/FrameBufferAttachment.h - src/engine/service/FrameBufferService.cpp - src/engine/service/FrameBufferService.h - src/engine/resource/FrameBufferInstance.h - src/engine/service/PipelineService.cpp - src/engine/service/PipelineService.h - src/engine/resource/PipelineInstance.h - src/engine/service/BufferService.cpp - src/engine/service/BufferService.h - src/engine/service/DescriptorSetService.cpp - src/engine/service/DescriptorSetService.h - src/engine/dto/DescriptorInstance.h - src/engine/dto/GlobalDataUBO.h - src/engine/repository/RuntimeRepository.h - src/engine/resource/BufferInstance.cpp - src/engine/resource/BufferInstance.h - src/engine/service/MeshService.cpp - src/engine/service/MeshService.h - src/engine/dto/MeshData.h - src/engine/resource/MeshInstance.h - src/common/FilesUtil.h - src/editor/dto/FSEntry.h - src/editor/enum/EntryType.h - src/editor/dock-spaces/files/FilesContext.h - src/common/FileDialogUtil.h - src/editor/dock-spaces/files/FilesHeaderPanel.cpp - src/editor/dock-spaces/files/FilesHeaderPanel.h - src/editor/service/MaterialImporterService.cpp - src/editor/service/MaterialImporterService.h - src/editor/service/MeshImporterService.cpp - src/editor/service/MeshImporterService.h - src/editor/service/SceneImporterService.cpp - src/editor/service/SceneImporterService.h - src/common/AbstractImporter.h - src/editor/service/TextureImporterService.cpp - src/editor/service/TextureImporterService.h - src/editor/dto/EntryMetadata.h - src/engine/dto/TextureData.h - src/engine/service/TextureService.cpp - src/engine/service/TextureService.h - src/editor/service/FilesService.cpp - src/editor/service/FilesService.h - src/editor/service/FileImporterService.cpp - src/editor/service/FileImporterService.h - src/editor/dock-spaces/files/FilesContext.cpp - src/engine/dto/VertexData.h - src/editor/dock-spaces/viewport/CameraPositionPanel.cpp - src/editor/dock-spaces/viewport/CameraPositionPanel.h - src/editor/passes/GridPass.cpp - src/editor/passes/GridPass.h - src/engine/passes/CommandBufferRecorder.cpp - src/engine/passes/CommandBufferRecorder.h - src/engine/dto/Camera.cpp - src/engine/repository/WorldRepository.cpp - src/engine/repository/WorldRepository.h - src/engine/dto/MetadataComponent.h - src/engine/enum/ComponentType.cpp - src/engine/enum/ComponentType.h - src/engine/dto/AbstractComponent.h - src/engine/dto/PrimitiveComponent.h - src/engine/dto/TransformComponent.h - src/editor/enum/ShadingMode.h - src/editor/dock-spaces/world/WorldHeaderPanel.cpp - src/editor/dock-spaces/world/WorldHeaderPanel.h - src/editor/service/SelectionService.cpp - src/editor/service/SelectionService.h - src/engine/dto/MetadataComponent.cpp - src/engine/dto/TransformComponent.cpp - src/engine/dto/PrimitiveComponent.cpp - src/editor/abstract/form/types/ResourceField.cpp - src/editor/abstract/form/types/ResourceField.h - src/editor/abstract/form/types/ColorField.cpp - src/editor/abstract/form/types/ColorField.h - src/editor/abstract/form/types/Vec4Field.cpp - src/editor/abstract/form/types/Vec4Field.h - src/editor/abstract/form/types/Vec3Field.cpp - src/editor/abstract/form/types/Vec3Field.h - src/editor/abstract/form/types/Vec2Field.cpp - src/editor/abstract/form/types/Vec2Field.h - src/editor/abstract/form/types/StringField.cpp - src/editor/abstract/form/types/StringField.h - src/editor/abstract/form/types/ResourceFilesPanel.h - src/editor/abstract/form/types/ResourceFilesPanel.cpp - src/engine/service/StreamingService.cpp - src/engine/service/StreamingService.h - src/engine/enum/ResourceType.h - src/editor/dock-spaces/viewport/GizmoPanel.cpp - src/editor/dock-spaces/viewport/GizmoPanel.h - src/editor/dock-spaces/viewport/ViewportHeaderPanel.cpp - src/editor/dock-spaces/viewport/ViewportHeaderPanel.h - src/editor/dock-spaces/viewport/GizmoSettingsPanel.cpp - src/editor/dock-spaces/viewport/GizmoSettingsPanel.h - src/editor/abstract/form/types/QuatField.cpp - src/editor/abstract/form/types/QuatField.h - src/engine/service/TransformService.cpp - src/engine/service/TransformService.h - src/engine/dto/BoundingBox.h - src/editor/dto/SparseVoxelOctreeBuilder.cpp - src/editor/dto/SparseVoxelOctreeBuilder.h - src/editor/dto/OctreeNode.cpp - src/editor/dto/OctreeNode.h - src/engine/dto/VoxelData.h - src/editor/dto/SceneData.h - src/engine/passes/impl/PostProcessingPass.cpp - src/engine/passes/impl/PostProcessingPass.h - src/engine/passes/impl/HWRayTracingPass.cpp - src/engine/passes/impl/HWRayTracingPass.h - src/engine/service/RayTracingService.cpp - src/engine/service/RayTracingService.h - src/engine/dto/PipelineBuilder.h - src/engine/resource/FrameBufferAttachment.cpp - src/engine/repository/EngineRepository.cpp - src/engine/repository/EngineRepository.h - src/common/serialization-definitions.h - src/editor/service/NotificationService.cpp - src/editor/service/NotificationService.h - src/editor/service/AsyncTaskService.cpp - src/editor/service/AsyncTaskService.h - src/editor/dto/Notification.h - src/editor/enum/NotificationSeverity.h - src/engine/dto/SparseVoxelOctreeData.h - src/editor/passes/SelectionOutlinePass.cpp - src/editor/passes/SelectionOutlinePass.h - src/editor/service/PickingService.cpp - src/editor/service/PickingService.h - src/engine/resource/SVOInstance.h - src/engine/dto/LightData.h - src/editor/passes/SelectionIDPass.cpp - src/editor/passes/SelectionIDPass.h - src/editor/repository/EditorRepository.cpp - src/editor/dto/GridPushConstant.h - src/engine/passes/AbstractComputePass.cpp - src/engine/passes/AbstractComputePass.h - src/engine/passes/AbstractPass.cpp - src/engine/passes/AbstractPass.h - src/engine/util/ImageUtils.h - src/engine/service/MaterialService.cpp - src/engine/service/MaterialService.h - src/engine/service/LightService.cpp - src/engine/service/LightService.h - src/engine/dto/VolumeComponent.cpp - src/engine/dto/VolumeComponent.h - src/engine/dto/DescriptorBinding.h - src/editor/dto/AsyncTask.h - src/editor/service/VoxelImporterService.cpp - src/editor/service/VoxelImporterService.h - src/engine/dto/VolumeData.h - src/engine/service/VoxelService.cpp - src/engine/service/VoxelService.h - src/common/ISerialize.cpp - src/editor/abstract/form/ChildPanel.cpp - src/editor/abstract/form/ChildPanel.h - src/editor/dto/SceneImportSettingsDTO.h - src/editor/panel/NotificationsPanel.cpp - src/editor/panel/NotificationsPanel.h - src/editor/panel/FileImportModalPanel.cpp - src/editor/panel/FileImportModalPanel.h - src/engine/frame-builder/EngineFrameBuilder.cpp - src/engine/frame-builder/EngineFrameBuilder.h - src/engine/frame-builder/EngineFrame.cpp - src/engine/frame-builder/EngineFrame.h - src/engine/frame-builder/structures/FramebufferBuilder.cpp - src/engine/frame-builder/structures/FramebufferBuilder.h - src/engine/frame-builder/structures/TextureBuilder.cpp - src/engine/frame-builder/structures/TextureBuilder.h - src/engine/frame-builder/structures/BufferBuilder.cpp - src/engine/frame-builder/structures/BufferBuilder.h - src/engine/frame-builder/structures/ResourceBuilder.h - src/engine/dto/PipelineBuilder.cpp - src/engine/service/DescriptorSetService.cpp - src/engine/frame-builder/structures/CommandBufferRecorderBuilder.cpp - src/engine/passes/impl/TemporalAccumulationPass.cpp - src/engine/passes/impl/TemporalAccumulationPass.h - src/engine/passes/impl/SpatialFilterPass.cpp - src/engine/passes/impl/SpatialFilterPass.h - src/engine/enum/ComponentType.cpp - src/editor/dto/SceneEntityData.h - src/editor/dock-spaces/repositories/RepositoriesPanel.cpp - src/editor/dock-spaces/repositories/RepositoriesPanel.h - src/engine/service/VolumeService.cpp - src/engine/service/VolumeService.h - src/common/IContextMember.h - src/common/IService.h - src/common/IRepository.h - src/common/IContextMember.cpp - src/core/DirectoryService.cpp - src/core/DirectoryService.h - src/common/IDisposable.h - src/core/FrameService.cpp - src/core/FrameService.h -) - +if (MSVC) + add_compile_options(/utf-8) +endif() # ------ LIBS find_package(glfw3 REQUIRED) find_package(glm REQUIRED) find_package(imgui REQUIRED) -find_package(spdlog CONFIG REQUIRED) find_package(nlohmann_json CONFIG REQUIRED) find_package(Vulkan) find_package(VulkanMemoryAllocator CONFIG REQUIRED) @@ -301,6 +22,7 @@ find_package(assimp CONFIG REQUIRED) find_package(meshoptimizer CONFIG REQUIRED) find_package(cereal CONFIG REQUIRED) find_package(OpenVDB CONFIG REQUIRED) +find_package(EnTT CONFIG REQUIRED) set(COMMON_LIBRARIES glfw @@ -315,24 +37,34 @@ set(COMMON_LIBRARIES glm::glm imgui::imgui imguizmo::imguizmo - spdlog::spdlog nlohmann_json::nlohmann_json + EnTT::EnTT glslang::glslang glslang::glslang-default-resource-limits glslang::SPVRemapper OpenVDB::openvdb ) -target_link_libraries(metal_engine PRIVATE ${COMMON_LIBRARIES}) + add_subdirectory(dependencies/vk-bootstrap) # ------ LIBS + +add_subdirectory(src) +enable_testing() +add_subdirectory(tests) + # ------ STATIC RESOURCES -file(COPY "${CMAKE_SOURCE_DIR}/resources" DESTINATION "${CMAKE_BINARY_DIR}/") +file(GLOB_RECURSE RESOURCE_FILES "resources/*") +add_custom_target(copy_resources ALL + COMMAND ${CMAKE_COMMAND} -E copy_directory + "${CMAKE_SOURCE_DIR}/resources" + "${CMAKE_BINARY_DIR}/resources" + DEPENDS ${RESOURCE_FILES} + COMMENT "Copying resources to build directory" +) # ------ STATIC RESOURCES # ------ VCPKG - -#set(CMAKE_TOOLCHAIN_FILE "Users/cafe/.vcpkg-clion/vcpkg/scripts/buildsystems/vcpkg.cmake") set(VCPKG_JSON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json") # Include vcpkg toolchain diff --git a/resources/shaders/tools/SelectedDot.frag b/resources/shaders/tools/SelectionOutline.frag similarity index 100% rename from resources/shaders/tools/SelectedDot.frag rename to resources/shaders/tools/SelectionOutline.frag diff --git a/src/ApplicationContext.cpp b/src/ApplicationContext.cpp index 84de4494..df32e882 100644 --- a/src/ApplicationContext.cpp +++ b/src/ApplicationContext.cpp @@ -1,5 +1,12 @@ #include "ApplicationContext.h" +#define STB_IMAGE_IMPLEMENTATION +#include "stb_image.h" +#define STB_IMAGE_WRITE_IMPLEMENTATION +#include "stb_image_write.h" +#define VMA_IMPLEMENTATION +#include + #include "common/serialization-definitions.h" #include "common/LoggerUtil.h" diff --git a/src/ApplicationContext.h b/src/ApplicationContext.h index 46c9dc6b..c4de96c2 100644 --- a/src/ApplicationContext.h +++ b/src/ApplicationContext.h @@ -1,5 +1,8 @@ #ifndef METAL_ENGINE_APPLICATIONCONTEXT_H #define METAL_ENGINE_APPLICATIONCONTEXT_H +#define GLM_FORCE_RADIANS +#define GLM_FORCE_DEPTH_ZERO_TO_ONE + #include #include #include diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000..e2b3bc36 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,296 @@ +set(ENGINE_SOURCES + main.cpp + editor/EditorPanel.cpp + editor/EditorPanel.h + engine/EngineContext.cpp + engine/EngineContext.h + core/vulkan/VulkanUtils.cpp + core/vulkan/VulkanUtils.h + core/vulkan/VulkanContext.cpp + core/vulkan/VulkanContext.h + core/glfw/GLFWContext.cpp + core/glfw/GLFWContext.h + core/gui/GuiContext.cpp + core/gui/GuiContext.h + editor/dock-spaces/viewport/ViewportPanel.cpp + editor/dock-spaces/viewport/ViewportPanel.h + editor/dock-spaces/viewport/EngineFramePanel.cpp + editor/dock-spaces/viewport/EngineFramePanel.h + editor/dock-spaces/docks/AbstractDockPanel.h + ApplicationContext.cpp + ApplicationContext.h + editor/abstract/AbstractPanel.h + editor/abstract/AbstractPanel.cpp + common/ISync.h + engine/service/CameraService.cpp + engine/service/CameraService.h + engine/dto/Camera.h + editor/util/Util.h + common/Inspectable.h + common/Inspectable.cpp + common/InspectedField.h + editor/dock-spaces/inspector/InspectorPanel.cpp + editor/dock-spaces/inspector/InspectorPanel.h + editor/abstract/form/FormPanel.cpp + editor/abstract/form/FormPanel.h + editor/abstract/form/AccordionPanel.cpp + editor/abstract/form/AccordionPanel.h + common/FieldType.h + common/InspectableMember.h + editor/abstract/form/types/BooleanField.cpp + editor/abstract/form/types/BooleanField.h + editor/abstract/form/types/IntField.cpp + editor/abstract/form/types/IntField.h + editor/abstract/form/types/FloatField.cpp + editor/abstract/form/types/FloatField.h + editor/abstract/form/types/MethodField.cpp + editor/abstract/form/types/MethodField.h + editor/util/UIUtil.h + editor/dock-spaces/header/EditorHeaderPanel.cpp + editor/dock-spaces/header/EditorHeaderPanel.h + editor/dock-spaces/header/AsyncTaskPanel.cpp + editor/dock-spaces/header/AsyncTaskPanel.h + editor/dock-spaces/footer/EditorFooterPanel.cpp + editor/dock-spaces/footer/EditorFooterPanel.h + common/Icons.h + editor/service/DockService.cpp + editor/service/DockService.h + editor/dto/DockDTO.h + editor/dto/DockSpace.h + editor/dock-spaces/docks/DockSpacePanel.cpp + editor/dock-spaces/docks/DockSpacePanel.h + editor/dto/DockSpace.cpp + editor/service/ThemeService.cpp + editor/service/ThemeService.h + editor/repository/EditorRepository.h + editor/enum/engine-definitions.h + editor/dock-spaces/files/FilesPanel.cpp + editor/dock-spaces/files/FilesPanel.h + editor/dock-spaces/files/FilesListPanel.cpp + editor/dock-spaces/files/FilesListPanel.h + editor/dock-spaces/files/FilePreviewPanel.cpp + editor/dock-spaces/files/FilePreviewPanel.h + editor/dock-spaces/console/ConsolePanel.cpp + editor/dock-spaces/console/ConsolePanel.h + editor/dock-spaces/metrics/MetricsPanel.cpp + editor/dock-spaces/metrics/MetricsPanel.h + common/LoggerUtil.cpp + common/LoggerUtil.h + editor/dock-spaces/world/WorldPanel.cpp + editor/dock-spaces/world/WorldPanel.h + engine/resource/RuntimeResource.h + engine/service/ShaderService.cpp + engine/service/ShaderService.h + engine/dto/ShaderModule.cpp + engine/dto/ShaderModule.h + engine/passes/AbstractRenderPass.cpp + engine/passes/AbstractRenderPass.h + common/AbstractResourceService.h + engine/resource/FrameBufferAttachment.h + engine/service/FrameBufferService.cpp + engine/service/FrameBufferService.h + engine/resource/FrameBufferInstance.h + engine/service/PipelineService.cpp + engine/service/PipelineService.h + engine/resource/PipelineInstance.h + engine/service/BufferService.cpp + engine/service/BufferService.h + engine/service/DescriptorSetService.cpp + engine/service/DescriptorSetService.h + engine/dto/DescriptorInstance.h + engine/dto/GlobalDataUBO.h + engine/repository/RuntimeRepository.h + engine/resource/BufferInstance.cpp + engine/resource/BufferInstance.h + engine/service/MeshService.cpp + engine/service/MeshService.h + engine/dto/MeshData.h + engine/resource/MeshInstance.h + common/FilesUtil.h + editor/dto/FSEntry.h + editor/enum/EntryType.h + editor/dock-spaces/files/FilesContext.h + common/FileDialogUtil.h + editor/dock-spaces/files/FilesHeaderPanel.cpp + editor/dock-spaces/files/FilesHeaderPanel.h + editor/service/MaterialImporterService.cpp + editor/service/MaterialImporterService.h + editor/service/MeshImporterService.cpp + editor/service/MeshImporterService.h + editor/service/SceneImporterService.cpp + editor/service/SceneImporterService.h + common/AbstractImporter.h + editor/service/TextureImporterService.cpp + editor/service/TextureImporterService.h + editor/dto/EntryMetadata.h + engine/dto/TextureData.h + engine/service/TextureService.cpp + engine/service/TextureService.h + editor/service/FilesService.cpp + editor/service/FilesService.h + editor/service/FileImporterService.cpp + editor/service/FileImporterService.h + editor/dock-spaces/files/FilesContext.cpp + engine/dto/VertexData.h + editor/dock-spaces/viewport/CameraPositionPanel.cpp + editor/dock-spaces/viewport/CameraPositionPanel.h + editor/passes/GridPass.cpp + editor/passes/GridPass.h + engine/passes/CommandBufferRecorder.cpp + engine/passes/CommandBufferRecorder.h + engine/dto/Camera.cpp + engine/repository/WorldRepository.cpp + engine/repository/WorldRepository.h + engine/dto/MetadataComponent.h + engine/enum/ComponentType.cpp + engine/enum/ComponentType.h + engine/dto/AbstractComponent.h + engine/dto/PrimitiveComponent.h + engine/dto/TransformComponent.h + editor/enum/ShadingMode.h + editor/dock-spaces/world/WorldHeaderPanel.cpp + editor/dock-spaces/world/WorldHeaderPanel.h + editor/service/SelectionService.cpp + editor/service/SelectionService.h + engine/dto/MetadataComponent.cpp + engine/dto/TransformComponent.cpp + engine/dto/PrimitiveComponent.cpp + editor/abstract/form/types/ResourceField.cpp + editor/abstract/form/types/ResourceField.h + editor/abstract/form/types/ColorField.cpp + editor/abstract/form/types/ColorField.h + editor/abstract/form/types/Vec4Field.cpp + editor/abstract/form/types/Vec4Field.h + editor/abstract/form/types/Vec3Field.cpp + editor/abstract/form/types/Vec3Field.h + editor/abstract/form/types/Vec2Field.cpp + editor/abstract/form/types/Vec2Field.h + editor/abstract/form/types/StringField.cpp + editor/abstract/form/types/StringField.h + editor/abstract/form/types/ResourceFilesPanel.h + editor/abstract/form/types/ResourceFilesPanel.cpp + engine/service/StreamingService.cpp + engine/service/StreamingService.h + engine/enum/ResourceType.h + editor/dock-spaces/viewport/GizmoPanel.cpp + editor/dock-spaces/viewport/GizmoPanel.h + editor/dock-spaces/viewport/ViewportHeaderPanel.cpp + editor/dock-spaces/viewport/ViewportHeaderPanel.h + editor/dock-spaces/viewport/GizmoSettingsPanel.cpp + editor/dock-spaces/viewport/GizmoSettingsPanel.h + editor/abstract/form/types/QuatField.cpp + editor/abstract/form/types/QuatField.h + engine/service/TransformService.cpp + engine/service/TransformService.h + engine/dto/BoundingBox.h + editor/dto/SparseVoxelOctreeBuilder.cpp + editor/dto/SparseVoxelOctreeBuilder.h + editor/dto/OctreeNode.cpp + editor/dto/OctreeNode.h + engine/dto/VoxelData.h + editor/dto/SceneData.h + engine/passes/impl/PostProcessingPass.cpp + engine/passes/impl/PostProcessingPass.h + engine/passes/impl/HWRayTracingPass.cpp + engine/passes/impl/HWRayTracingPass.h + engine/service/RayTracingService.cpp + engine/service/RayTracingService.h + engine/dto/PipelineBuilder.h + engine/resource/FrameBufferAttachment.cpp + engine/repository/EngineRepository.cpp + engine/repository/EngineRepository.h + common/serialization-definitions.h + editor/service/NotificationService.cpp + editor/service/NotificationService.h + editor/service/AsyncTaskService.cpp + editor/service/AsyncTaskService.h + editor/dto/Notification.h + editor/enum/NotificationSeverity.h + engine/dto/SparseVoxelOctreeData.h + editor/passes/SelectionOutlinePass.cpp + editor/passes/SelectionOutlinePass.h + editor/service/PickingService.cpp + editor/service/PickingService.h + engine/resource/SVOInstance.h + engine/dto/LightData.h + editor/passes/SelectionIDPass.cpp + editor/passes/SelectionIDPass.h + editor/repository/EditorRepository.cpp + editor/dto/GridPushConstant.h + engine/passes/AbstractComputePass.cpp + engine/passes/AbstractComputePass.h + engine/passes/AbstractPass.cpp + engine/passes/AbstractPass.h + engine/util/ImageUtils.h + engine/service/MaterialService.cpp + engine/service/MaterialService.h + engine/service/LightService.cpp + engine/service/LightService.h + engine/dto/VolumeComponent.cpp + engine/dto/VolumeComponent.h + engine/dto/DescriptorBinding.h + editor/dto/AsyncTask.h + editor/service/VoxelImporterService.cpp + editor/service/VoxelImporterService.h + engine/dto/VolumeData.h + engine/service/VoxelService.cpp + engine/service/VoxelService.h + common/ISerialize.cpp + editor/abstract/form/ChildPanel.cpp + editor/abstract/form/ChildPanel.h + editor/dto/SceneImportSettingsDTO.h + editor/panel/NotificationsPanel.cpp + editor/panel/NotificationsPanel.h + editor/panel/FileImportModalPanel.cpp + editor/panel/FileImportModalPanel.h + engine/frame-builder/EngineFrameBuilder.cpp + engine/frame-builder/EngineFrameBuilder.h + engine/frame-builder/EngineFrame.cpp + engine/frame-builder/EngineFrame.h + engine/frame-builder/structures/FramebufferBuilder.cpp + engine/frame-builder/structures/FramebufferBuilder.h + engine/frame-builder/structures/TextureBuilder.cpp + engine/frame-builder/structures/TextureBuilder.h + engine/frame-builder/structures/BufferBuilder.cpp + engine/frame-builder/structures/BufferBuilder.h + engine/frame-builder/structures/ResourceBuilder.h + engine/dto/PipelineBuilder.cpp + engine/service/DescriptorSetService.cpp + engine/frame-builder/structures/CommandBufferRecorderBuilder.cpp + engine/passes/impl/TemporalAccumulationPass.cpp + engine/passes/impl/TemporalAccumulationPass.h + engine/passes/impl/SpatialFilterPass.cpp + engine/passes/impl/SpatialFilterPass.h + engine/enum/ComponentType.cpp + editor/dto/SceneEntityData.h + editor/dock-spaces/repositories/RepositoriesPanel.cpp + editor/dock-spaces/repositories/RepositoriesPanel.h + engine/service/VolumeService.cpp + engine/service/VolumeService.h + common/IContextMember.h + common/IService.h + common/IRepository.h + common/IContextMember.cpp + core/DirectoryService.cpp + core/DirectoryService.h + common/IDisposable.h + core/FrameService.cpp + core/FrameService.h +) + +# Extract non-main sources for testing +set(ENGINE_LIB_SOURCES ${ENGINE_SOURCES}) +list(REMOVE_ITEM ENGINE_LIB_SOURCES main.cpp) + +add_library(metal_engine_lib STATIC ${ENGINE_LIB_SOURCES}) +target_include_directories(metal_engine_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(metal_engine_lib PUBLIC ${COMMON_LIBRARIES}) + +add_executable(metal_engine main.cpp) +target_link_libraries(metal_engine PRIVATE metal_engine_lib) +add_dependencies(metal_engine copy_resources) + +add_custom_command(TARGET metal_engine POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + "${CMAKE_BINARY_DIR}/resources" + "$/resources") diff --git a/src/core/vulkan/VulkanContext.cpp b/src/core/vulkan/VulkanContext.cpp index 1fb88ca9..68520c7d 100644 --- a/src/core/vulkan/VulkanContext.cpp +++ b/src/core/vulkan/VulkanContext.cpp @@ -211,7 +211,7 @@ namespace Metal { const ImVector &instanceExtensions) const { if (auto sysInfoResult = vkb::SystemInfo::get_system_info(); sysInfoResult) { const auto &sysInfo = sysInfoResult.value(); - if (sysInfo.validation_layers_available && debugMode) { + if (sysInfo.validation_layers_available && ctx->isDebugMode()) { if (sysInfo.is_layer_available("VK_LAYER_LUNARG_api_dump")) { // instanceBuilder.enable_layer("VK_LAYER_LUNARG_api_dump"); } @@ -252,7 +252,6 @@ namespace Metal { } void VulkanContext::onInitialize() { - this->debugMode = ctx->isDebugMode(); this->window = glfwContext->getWindow(); imguiVulkanWindow.ClearValue.color.float32[0] = 0; diff --git a/src/core/vulkan/VulkanContext.h b/src/core/vulkan/VulkanContext.h index cee39ddd..2fe36230 100644 --- a/src/core/vulkan/VulkanContext.h +++ b/src/core/vulkan/VulkanContext.h @@ -58,7 +58,6 @@ namespace Metal { unsigned int w{}, h{}; GLFWwindow *window = nullptr; - bool debugMode = false; std::vector commandBuffers{}; public: diff --git a/src/editor/EditorPanel.cpp b/src/editor/EditorPanel.cpp index ba38367e..8626f437 100644 --- a/src/editor/EditorPanel.cpp +++ b/src/editor/EditorPanel.cpp @@ -26,70 +26,68 @@ namespace Metal { void EditorPanel::renderDockSpaces() { const ImGuiViewport *viewport = ImGui::GetMainViewport(); - renderHeader(viewport); - renderFooter(viewport); - // Begin window + // Header { UIUtil::AUX_VEC2.x = viewport->Pos.x; - UIUtil::AUX_VEC2.y = viewport->Pos.y + HEADER_HEIGHT; + UIUtil::AUX_VEC2.y = viewport->Pos.y; ImGui::SetNextWindowPos(UIUtil::AUX_VEC2); UIUtil::AUX_VEC2.x = viewport->Size.x; - UIUtil::AUX_VEC2.y = viewport->Size.y - HEADER_HEIGHT - FOOTER_HEIGHT; + UIUtil::AUX_VEC2.y = HEADER_HEIGHT; ImGui::SetNextWindowSize(UIUtil::AUX_VEC2); - ImGui::SetNextWindowViewport(viewport->ID); SetWindowStyle(); - } + ImGui::Begin(NAME_HEADER, &UIUtil::OPEN, FLAGS | ImGuiWindowFlags_NoScrollbar); + ImGui::PopStyleVar(3); - ImGui::Begin(NAME, &UIUtil::OPEN, FLAGS); - windowId = ImGui::GetID(NAME); - - ImGui::PopStyleVar(3); - - dockService->buildViews(windowId, this); + headerPanel->onSync(); + ImGui::End(); + } - ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f); - ImGui::DockSpace(windowId, CENTER, ImGuiDockNodeFlags_PassthruCentralNode); - ImGui::PopStyleVar(1); + // Main Window (DockSpace) + { + UIUtil::AUX_VEC2.x = viewport->Pos.x; + UIUtil::AUX_VEC2.y = viewport->Pos.y + HEADER_HEIGHT; + ImGui::SetNextWindowPos(UIUtil::AUX_VEC2); - onSyncChildren(); - ImGui::End(); - } + UIUtil::AUX_VEC2.x = viewport->Size.x; + UIUtil::AUX_VEC2.y = viewport->Size.y - HEADER_HEIGHT - FOOTER_HEIGHT; + ImGui::SetNextWindowSize(UIUtil::AUX_VEC2); + ImGui::SetNextWindowViewport(viewport->ID); - void EditorPanel::renderHeader(const ImGuiViewport *viewport) { - UIUtil::AUX_VEC2.x = viewport->Pos.x; - UIUtil::AUX_VEC2.y = viewport->Pos.y; - ImGui::SetNextWindowPos(UIUtil::AUX_VEC2); + SetWindowStyle(); + ImGui::Begin(NAME, &UIUtil::OPEN, FLAGS); + windowId = ImGui::GetID(NAME); + ImGui::PopStyleVar(3); - UIUtil::AUX_VEC2.x = viewport->Size.x; - UIUtil::AUX_VEC2.y = HEADER_HEIGHT; - ImGui::SetNextWindowSize(UIUtil::AUX_VEC2); + dockService->buildViews(windowId, this); - SetWindowStyle(); - ImGui::Begin(NAME_HEADER, &UIUtil::OPEN, FLAGS | ImGuiWindowFlags_NoScrollbar); - ImGui::PopStyleVar(3); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f); + ImGui::DockSpace(windowId, CENTER, ImGuiDockNodeFlags_PassthruCentralNode); + ImGui::PopStyleVar(1); - headerPanel->onSync(); - ImGui::End(); - } + onSyncChildren(); + ImGui::End(); + } - void EditorPanel::renderFooter(const ImGuiViewport *viewport) { - UIUtil::AUX_VEC2.x = viewport->Pos.x; - UIUtil::AUX_VEC2.y = viewport->Pos.y + viewport->Size.y - FOOTER_HEIGHT; - ImGui::SetNextWindowPos(UIUtil::AUX_VEC2); + // Footer + { + UIUtil::AUX_VEC2.x = viewport->Pos.x; + UIUtil::AUX_VEC2.y = viewport->Pos.y + viewport->Size.y - FOOTER_HEIGHT; + ImGui::SetNextWindowPos(UIUtil::AUX_VEC2); - UIUtil::AUX_VEC2.x = viewport->Size.x; - UIUtil::AUX_VEC2.y = FOOTER_HEIGHT; - ImGui::SetNextWindowSize(UIUtil::AUX_VEC2); + UIUtil::AUX_VEC2.x = viewport->Size.x; + UIUtil::AUX_VEC2.y = FOOTER_HEIGHT; + ImGui::SetNextWindowSize(UIUtil::AUX_VEC2); - SetWindowStyle(); - ImGui::Begin(NAME_FOOTER, &UIUtil::OPEN, FLAGS | ImGuiWindowFlags_NoScrollbar); - ImGui::PopStyleVar(3); + SetWindowStyle(); + ImGui::Begin(NAME_FOOTER, &UIUtil::OPEN, FLAGS | ImGuiWindowFlags_NoScrollbar); + ImGui::PopStyleVar(3); - footerPanel->onSync(); - ImGui::End(); + footerPanel->onSync(); + ImGui::End(); + } } void EditorPanel::SetWindowStyle() { diff --git a/src/editor/EditorPanel.h b/src/editor/EditorPanel.h index d007ff7a..f3a97a12 100644 --- a/src/editor/EditorPanel.h +++ b/src/editor/EditorPanel.h @@ -29,10 +29,6 @@ namespace Metal { void renderDockSpaces(); - void renderHeader(const ImGuiViewport *viewport); - - void renderFooter(const ImGuiViewport *viewport); - public: std::vector getDependencies() override { return { diff --git a/src/editor/dock-spaces/footer/EditorFooterPanel.cpp b/src/editor/dock-spaces/footer/EditorFooterPanel.cpp index 280a194c..0a427db7 100644 --- a/src/editor/dock-spaces/footer/EditorFooterPanel.cpp +++ b/src/editor/dock-spaces/footer/EditorFooterPanel.cpp @@ -1,14 +1,22 @@ #include "EditorFooterPanel.h" +#include "../header/AsyncTaskPanel.h" #include "../../util/UIUtil.h" #include "../../../ApplicationContext.h" #include "../../repository/EditorRepository.h" namespace Metal { void EditorFooterPanel::onSync() { + ImGui::Separator(); + asyncTaskPanel->onSync(); + ImGui::SameLine(); renderShortcuts(); framerate(); } + void EditorFooterPanel::onInitialize() { + initializePanel(asyncTaskPanel = new AsyncTaskPanel(), false); + } + void EditorFooterPanel::framerate() { const int framerate = static_cast(round(ImGui::GetIO().Framerate)); if (framerate > 0) { @@ -21,10 +29,8 @@ namespace Metal { auto &shortcuts = editorRepository->focusedShortcuts; if (shortcuts.empty()) return; - ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5); // Some padding + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 2); // Some padding - ImGui::Text(editorRepository->focusedWindowName.c_str()); - ImGui::SameLine(); std::string label; for (size_t i = 0; i < std::min(shortcuts.size(), size_t(3)); ++i) { if (i > 0) label += " | "; diff --git a/src/editor/dock-spaces/footer/EditorFooterPanel.h b/src/editor/dock-spaces/footer/EditorFooterPanel.h index 4dee9bb0..9f4ec717 100644 --- a/src/editor/dock-spaces/footer/EditorFooterPanel.h +++ b/src/editor/dock-spaces/footer/EditorFooterPanel.h @@ -6,8 +6,11 @@ namespace Metal { struct EditorRepository; + class AsyncTaskPanel; + class EditorFooterPanel final : public AbstractPanel { EditorRepository *editorRepository = nullptr; + AsyncTaskPanel *asyncTaskPanel = nullptr; void renderShortcuts(); static void framerate(); @@ -19,6 +22,8 @@ namespace Metal { }; } + void onInitialize() override; + void onSync() override; }; } diff --git a/src/editor/dock-spaces/header/AsyncTaskPanel.cpp b/src/editor/dock-spaces/header/AsyncTaskPanel.cpp index 616fc37b..108824e7 100644 --- a/src/editor/dock-spaces/header/AsyncTaskPanel.cpp +++ b/src/editor/dock-spaces/header/AsyncTaskPanel.cpp @@ -8,37 +8,28 @@ namespace Metal { void AsyncTaskPanel::onSync() { auto tasks = asyncTaskService->getActiveTasks(); - if (tasks.empty()) { - UIUtil::DynamicSpacing(90); - return; - } - UIUtil::DynamicSpacing(250); - ImGui::SameLine(); - - float time = (float)ImGui::GetTime(); - float t = 0.5f + 0.5f * std::sin(time * 3.0f); // 0.0 to 1.0 - - ImVec4 color = ImVec4( - 0.0f + t * 0.4f, - 0.2f + t * 0.5f, - 0.6f + t * 0.4f, - 1.0f - ); + bool hasTasks = !tasks.empty(); + ImGui::BeginGroup(); ImVec2 pos = ImGui::GetCursorScreenPos(); - float width = 150.0f; - float height = 10.0f; + float size = (float)UIUtil::ONLY_ICON_BUTTON_SIZE; - pos.y += (UIUtil::ONLY_ICON_BUTTON_SIZE - height) / 2.0f; + if (ImGui::InvisibleButton("##AsyncTaskIcon", ImVec2(size, size))) { + ImGui::OpenPopup("AsyncTasksPopup"); + } - ImGui::GetWindowDrawList()->AddRectFilled(pos, ImVec2(pos.x + width, pos.y + height), ImGui::ColorConvertFloat4ToU32(color), 5.0f); + ImU32 iconColor = ImGui::GetColorU32(ImGuiCol_Text); + ImGui::GetWindowDrawList()->AddText(ImGui::GetFont(), ImGui::GetFontSize(), + ImVec2(pos.x + (size - ImGui::CalcTextSize(Icons::sync.c_str()).x) / 2, + pos.y + (size - ImGui::GetFontSize()) / 2), + iconColor, Icons::sync.c_str()); - ImGui::SetCursorScreenPos(pos); - if (ImGui::InvisibleButton("##AsyncTaskLine", ImVec2(width, height))) { - ImGui::OpenPopup("AsyncTasksPopup"); + if (hasTasks) { + float circleRadius = 3.0f; + ImVec2 circlePos = ImVec2(pos.x + size / 2.0f, pos.y + size - circleRadius - 2.0f); + ImGui::GetWindowDrawList()->AddCircleFilled(circlePos, circleRadius, IM_COL32(0, 200, 255, 255)); } - ImGui::SameLine(); - ImGui::Dummy(ImVec2(0, UIUtil::ONLY_ICON_BUTTON_SIZE)); + ImGui::EndGroup(); UIUtil::RenderTooltip(Icons::sync + " " + std::to_string(tasks.size()) + " processes running..."); @@ -52,8 +43,9 @@ namespace Metal { ImGui::Text("%s", task->name.c_str()); ImVec2 p = ImGui::GetCursorScreenPos(); + float height = 10.0f; float w = ImGui::GetContentRegionAvail().x - UIUtil::ONLY_ICON_BUTTON_SIZE - ImGui::GetStyle().ItemSpacing.x; - ImGui::GetWindowDrawList()->AddRectFilled(p, ImVec2(p.x + w, p.y + height), ImGui::ColorConvertFloat4ToU32(color), 5.0f); + ImGui::GetWindowDrawList()->AddRectFilled(p, ImVec2(p.x + w, p.y + height), IM_COL32(50, 150, 255, 255), 5.0f); ImGui::Dummy(ImVec2(w, height)); ImGui::SameLine(); diff --git a/src/editor/dock-spaces/header/EditorHeaderPanel.cpp b/src/editor/dock-spaces/header/EditorHeaderPanel.cpp index 6f7be23b..c1f57417 100644 --- a/src/editor/dock-spaces/header/EditorHeaderPanel.cpp +++ b/src/editor/dock-spaces/header/EditorHeaderPanel.cpp @@ -1,5 +1,4 @@ #include "EditorHeaderPanel.h" -#include "AsyncTaskPanel.h" #include "../../util/UIUtil.h" #include "../../../ApplicationContext.h" #include "../../../core/DirectoryService.h" @@ -12,19 +11,10 @@ namespace Metal { ImGui::Dummy(ImVec2(0, UIUtil::ONLY_ICON_BUTTON_SIZE)); ImGui::Dummy(ImVec2(2, 0)); ImGui::Separator(); - - // Window dragging logic - if (ImGui::IsWindowHovered() && ImGui::IsMouseDragging(ImGuiMouseButton_Left)) { - ImVec2 delta = ImGui::GetIO().MouseDelta; - GLFWwindow *window = glfwContext->getWindow(); - int x, y; - glfwGetWindowPos(window, &x, &y); - glfwSetWindowPos(window, x + (int) delta.x, y + (int) delta.y); - } } void EditorHeaderPanel::renderWindowControls() { - ImGui::SameLine(ImGui::GetWindowWidth() - (UIUtil::ONLY_ICON_BUTTON_SIZE * 3 + 10)); + ImGui::SameLine(ImGui::GetWindowWidth() - (UIUtil::ONLY_ICON_BUTTON_SIZE * 3 + 20)); GLFWwindow *window = glfwContext->getWindow(); @@ -72,26 +62,61 @@ namespace Metal { ImGui::EndMenu(); } - // Create an "Edit" menu + // Edit menu if (ImGui::BeginMenu("Edit")) { if (ImGui::MenuItem("Compile shaders")) { engineContext->dispose(); - // TODO - CREATE NEW FRAME } ImGui::EndMenu(); } - UIUtil::LargeSpacing(); + // --- Drag handle area --- + // Use remaining width (minus the space reserved for window controls) + float controlsWidth = UIUtil::ONLY_ICON_BUTTON_SIZE * 3 + 20; // approximate width of minimize/maximize/close + float dragHandleWidth = ImGui::GetContentRegionAvail().x - controlsWidth; + if (dragHandleWidth > 0) { + ImGui::SameLine(); + dragHandleScreenPos = ImGui::GetCursorScreenPos(); + ImGui::InvisibleButton("##header_drag_handle", ImVec2(dragHandleWidth, ImGui::GetFrameHeight())); + + GLFWwindow *window = glfwContext->getWindow(); + if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) { + if (!glfwGetWindowAttrib(window, GLFW_MAXIMIZED)) { + isDragging = true; + dragStartMousePos = ImGui::GetIO().MousePos; + glfwGetWindowPos(window, &dragStartWindowX, &dragStartWindowY); + lastWindowX = dragStartWindowX; + lastWindowY = dragStartWindowY; + } + } + + if (isDragging) { + if (ImGui::IsMouseDown(ImGuiMouseButton_Left)) { + ImVec2 currentMousePos = ImGui::GetIO().MousePos; + + // Calculate how much the mouse has moved relative to the drag handle's CURRENT screen position + // This compensates for the window's own movement + float deltaX = currentMousePos.x - dragStartMousePos.x; + float deltaY = currentMousePos.y - dragStartMousePos.y; - asyncTask->onSync(); + int newWindowX = lastWindowX + (int)deltaX; + int newWindowY = lastWindowY + (int)deltaY; + if (newWindowX != lastWindowX || newWindowY != lastWindowY) { + glfwSetWindowPos(window, newWindowX, newWindowY); + lastWindowX = newWindowX; + lastWindowY = newWindowY; + } + } else { + isDragging = false; + } + } + } + + // Window controls (minimize, maximize, close) renderWindowControls(); ImGui::EndMainMenuBar(); } } - - void EditorHeaderPanel::onInitialize() { - initializePanel(asyncTask = new AsyncTaskPanel()); - } } diff --git a/src/editor/dock-spaces/header/EditorHeaderPanel.h b/src/editor/dock-spaces/header/EditorHeaderPanel.h index 230591f9..3e385bee 100644 --- a/src/editor/dock-spaces/header/EditorHeaderPanel.h +++ b/src/editor/dock-spaces/header/EditorHeaderPanel.h @@ -2,6 +2,7 @@ #define METAL_ENGINE_EDITORHEADERPANEL_H #include "../../abstract/AbstractPanel.h" +#include namespace Metal { class GLFWContext; @@ -9,12 +10,22 @@ namespace Metal { struct DirectoryService; class EditorHeaderPanel final : public AbstractPanel { - AbstractPanel *asyncTask = nullptr; - GLFWContext *glfwContext = nullptr; EngineContext *engineContext = nullptr; DirectoryService *directoryService = nullptr; + ImVec2 dragStartMousePos; + int dragStartWindowX = 0; + int dragStartWindowY = 0; + bool isDragging = false; + + double dragStartGlobalMouseX = 0; + double dragStartGlobalMouseY = 0; + int lastWindowX = 0; + int lastWindowY = 0; + + ImVec2 dragHandleScreenPos; + void renderFileTab(); void renderWindowControls(); @@ -28,8 +39,6 @@ namespace Metal { }; } - void onInitialize() override; - void onSync() override; }; } // Metal diff --git a/src/editor/passes/GridPass.cpp b/src/editor/passes/GridPass.cpp index 3dfcc2a9..4a919feb 100644 --- a/src/editor/passes/GridPass.cpp +++ b/src/editor/passes/GridPass.cpp @@ -1,5 +1,4 @@ #include "GridPass.h" -#include "../../ApplicationContext.h" #include "../../engine/dto/PipelineBuilder.h" #include "../../engine/service/PipelineService.h" #include "../repository/EditorRepository.h" @@ -20,7 +19,7 @@ namespace Metal { } bool GridPass::shouldRun() { - return applicationContext->isDebugMode() && editorRepository->showGrid; + return editorRepository->showGrid; } void GridPass::onSync() { diff --git a/src/editor/passes/GridPass.h b/src/editor/passes/GridPass.h index f9f2a635..4be4e4c5 100644 --- a/src/editor/passes/GridPass.h +++ b/src/editor/passes/GridPass.h @@ -5,21 +5,18 @@ namespace Metal { class PipelineService; - class ApplicationContext; struct EditorRepository; class GridPass final : public AbstractRenderPass { GridPushConstant pushConstant{}; PipelineService *pipelineService = nullptr; - ApplicationContext *applicationContext = nullptr; EditorRepository *editorRepository = nullptr; public: std::vector getDependencies() override { return { {"PipelineService", &pipelineService}, - {"ApplicationContext", &applicationContext}, {"EditorRepository", &editorRepository} }; } diff --git a/src/editor/passes/SelectionOutlinePass.cpp b/src/editor/passes/SelectionOutlinePass.cpp index f44c9289..7726eb9e 100644 --- a/src/editor/passes/SelectionOutlinePass.cpp +++ b/src/editor/passes/SelectionOutlinePass.cpp @@ -12,7 +12,7 @@ namespace Metal { PipelineBuilder builder = PipelineBuilder::Of( getScopedResourceId(RID_POST_PROCESSING_FBO), "QUAD.vert", - "tools/SelectedDot.frag" + "tools/SelectionOutline.frag" ) .setBlendEnabled() .setPushConstantsSize(sizeof(SelectedDotPushConstant)) diff --git a/src/main.cpp b/src/main.cpp index 3fd38ca0..8e452fdc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,10 +1,3 @@ -#define STB_IMAGE_IMPLEMENTATION -#include "stb_image.h" -#define STB_IMAGE_WRITE_IMPLEMENTATION -#include "stb_image_write.h" -#define VMA_IMPLEMENTATION -#define GLM_FORCE_RADIANS -#define GLM_FORCE_DEPTH_ZERO_TO_ONE #include "ApplicationContext.h" #include "core/DirectoryService.h" #include "core/FrameService.h" diff --git a/tests/ApplicationContextTest.cpp b/tests/ApplicationContextTest.cpp new file mode 100644 index 00000000..699f0f04 --- /dev/null +++ b/tests/ApplicationContextTest.cpp @@ -0,0 +1,39 @@ +#include +#include +#include "../src/ApplicationContext.h" +#include "../src/common/IContextMember.h" +#include + +using namespace Metal; + +class MockContextMember : public IContextMember { +public: + int value = 0; +}; + +TEST(ApplicationContextTest, RegisterAndGetSingleton) { + ApplicationContext ctx(true); + auto member = std::make_shared(); + member->value = 42; + + ctx.registerSingleton(member); + + MockContextMember& retrieved = ctx.getSingleton(); + EXPECT_EQ(retrieved.value, 42); +} + +TEST(ApplicationContextTest, GetSingletonByName) { + ApplicationContext ctx(true); + auto member = std::make_shared(); + + ctx.registerSingleton(member); + + void* ptr = ctx.getSingletonByName("MockContextMember"); + EXPECT_NE(ptr, nullptr); + EXPECT_EQ(static_cast(ptr), member.get()); +} + +TEST(ApplicationContextTest, ThrowsWhenSingletonNotFound) { + ApplicationContext ctx(true); + EXPECT_THROW(ctx.getSingleton(), std::runtime_error); +} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..a80f315c --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,21 @@ +find_package(GTest REQUIRED) + +add_executable(metal_engine_tests + ApplicationContextTest.cpp + WorldRepositoryTest.cpp +) + +target_link_libraries(metal_engine_tests + PRIVATE + metal_engine_lib + GTest::gtest_main +) +add_dependencies(metal_engine_tests copy_resources) + +add_custom_command(TARGET metal_engine_tests POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + "${CMAKE_BINARY_DIR}/resources" + "$/resources") + +include(GoogleTest) +gtest_discover_tests(metal_engine_tests) diff --git a/tests/WorldRepositoryTest.cpp b/tests/WorldRepositoryTest.cpp new file mode 100644 index 00000000..efc8a4b9 --- /dev/null +++ b/tests/WorldRepositoryTest.cpp @@ -0,0 +1,64 @@ +#include +#include +#include "../src/ApplicationContext.h" +#include "../src/engine/repository/WorldRepository.h" +#include "../src/engine/dto/MetadataComponent.h" +#include "../src/engine/service/RayTracingService.h" +#include "../src/core/DirectoryService.h" +#include "../src/engine/EngineContext.h" +#include + +using namespace Metal; + +class WorldRepositoryTest : public ::testing::Test { +protected: + std::unique_ptr context; + WorldRepository* repo; + + void SetUp() override { + context = std::make_unique(true); + + auto worldRepo = std::make_shared(); + auto rayTracingService = std::make_shared(); + auto directoryService = std::make_shared(); + auto engineContext = std::make_shared(); + + context->registerSingleton(worldRepo); + context->registerSingleton(rayTracingService); + context->registerSingleton(directoryService); + context->registerSingleton(engineContext); + + context->injectDependencies(worldRepo.get()); + + repo = worldRepo.get(); + } +}; + +TEST_F(WorldRepositoryTest, CreateEntity) { + entt::entity entity = repo->createEntity(); + EXPECT_NE(entity, static_cast(entt::null)); + EXPECT_TRUE(repo->registry.valid(entity)); +} + +TEST_F(WorldRepositoryTest, GetEntityMetadata) { + entt::entity entity = repo->createEntity(); + MetadataComponent* metadata = repo->getEntity(entity); + EXPECT_NE(metadata, nullptr); +} + +TEST_F(WorldRepositoryTest, DeleteEntity) { + entt::entity entity = repo->createEntity(); + repo->deleteEntities({entity}); + EXPECT_FALSE(repo->registry.valid(entity)); +} + +TEST_F(WorldRepositoryTest, ChangeVisibility) { + entt::entity entity = repo->createEntity(); + + repo->changeVisibility(entity, false); + EXPECT_EQ(repo->hiddenEntities.count(entity), 1); + EXPECT_TRUE(repo->hiddenEntities.at(entity)); + + repo->changeVisibility(entity, true); + EXPECT_EQ(repo->hiddenEntities.count(entity), 0); +} diff --git a/vcpkg.json b/vcpkg.json index e5abb844..5b0cea8f 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -18,9 +18,6 @@ }, { "name" : "glm", "version>=" : "1.0.1#3" - }, { - "name" : "spdlog", - "version>=" : "1.15.0#1" }, { "name" : "spirv-tools", "version>=" : "1.3.296.0" @@ -51,5 +48,8 @@ }, { "name" : "entt", "version>=" : "3.16.0" - } ] + }, { + "name" : "gtest", + "version>=" : "1.15.2" + }] } \ No newline at end of file From 4a1f7971154b92dda308883b45e4e826f6ca2468 Mon Sep 17 00:00:00 2001 From: facobackup Date: Sat, 14 Mar 2026 20:24:20 -0300 Subject: [PATCH 10/11] Drag --- .../dock-spaces/header/EditorHeaderPanel.cpp | 42 ------------------- .../dock-spaces/header/EditorHeaderPanel.h | 12 ------ 2 files changed, 54 deletions(-) diff --git a/src/editor/dock-spaces/header/EditorHeaderPanel.cpp b/src/editor/dock-spaces/header/EditorHeaderPanel.cpp index c1f57417..ae5ee5f4 100644 --- a/src/editor/dock-spaces/header/EditorHeaderPanel.cpp +++ b/src/editor/dock-spaces/header/EditorHeaderPanel.cpp @@ -70,48 +70,6 @@ namespace Metal { ImGui::EndMenu(); } - // --- Drag handle area --- - // Use remaining width (minus the space reserved for window controls) - float controlsWidth = UIUtil::ONLY_ICON_BUTTON_SIZE * 3 + 20; // approximate width of minimize/maximize/close - float dragHandleWidth = ImGui::GetContentRegionAvail().x - controlsWidth; - if (dragHandleWidth > 0) { - ImGui::SameLine(); - dragHandleScreenPos = ImGui::GetCursorScreenPos(); - ImGui::InvisibleButton("##header_drag_handle", ImVec2(dragHandleWidth, ImGui::GetFrameHeight())); - - GLFWwindow *window = glfwContext->getWindow(); - if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) { - if (!glfwGetWindowAttrib(window, GLFW_MAXIMIZED)) { - isDragging = true; - dragStartMousePos = ImGui::GetIO().MousePos; - glfwGetWindowPos(window, &dragStartWindowX, &dragStartWindowY); - lastWindowX = dragStartWindowX; - lastWindowY = dragStartWindowY; - } - } - - if (isDragging) { - if (ImGui::IsMouseDown(ImGuiMouseButton_Left)) { - ImVec2 currentMousePos = ImGui::GetIO().MousePos; - - // Calculate how much the mouse has moved relative to the drag handle's CURRENT screen position - // This compensates for the window's own movement - float deltaX = currentMousePos.x - dragStartMousePos.x; - float deltaY = currentMousePos.y - dragStartMousePos.y; - - int newWindowX = lastWindowX + (int)deltaX; - int newWindowY = lastWindowY + (int)deltaY; - - if (newWindowX != lastWindowX || newWindowY != lastWindowY) { - glfwSetWindowPos(window, newWindowX, newWindowY); - lastWindowX = newWindowX; - lastWindowY = newWindowY; - } - } else { - isDragging = false; - } - } - } // Window controls (minimize, maximize, close) renderWindowControls(); diff --git a/src/editor/dock-spaces/header/EditorHeaderPanel.h b/src/editor/dock-spaces/header/EditorHeaderPanel.h index 3e385bee..032e7ab5 100644 --- a/src/editor/dock-spaces/header/EditorHeaderPanel.h +++ b/src/editor/dock-spaces/header/EditorHeaderPanel.h @@ -14,18 +14,6 @@ namespace Metal { EngineContext *engineContext = nullptr; DirectoryService *directoryService = nullptr; - ImVec2 dragStartMousePos; - int dragStartWindowX = 0; - int dragStartWindowY = 0; - bool isDragging = false; - - double dragStartGlobalMouseX = 0; - double dragStartGlobalMouseY = 0; - int lastWindowX = 0; - int lastWindowY = 0; - - ImVec2 dragHandleScreenPos; - void renderFileTab(); void renderWindowControls(); From 3c20e57c0249ea0229ec2e8a47c7b1da58290d71 Mon Sep 17 00:00:00 2001 From: facobackup Date: Sat, 14 Mar 2026 22:09:25 -0300 Subject: [PATCH 11/11] New UI layout Theme json configuration file Fixing window dragging and border --- resources/theme.json | 22 ++ src/CMakeLists.txt | 3 + src/core/glfw/GLFWContext.cpp | 308 ++++++++++++++++++ src/core/glfw/GLFWContext.h | 86 +++++ src/editor/EditorPanel.cpp | 14 +- src/editor/EditorPanel.h | 2 +- .../dock-spaces/docks/DockSpacePanel.cpp | 158 ++++++--- src/editor/dock-spaces/docks/DockSpacePanel.h | 6 +- .../dock-spaces/footer/EditorFooterPanel.cpp | 9 +- .../dock-spaces/footer/EditorFooterPanel.h | 8 +- .../dock-spaces/header/EditorHeaderPanel.cpp | 118 ++++--- .../dock-spaces/header/EditorHeaderPanel.h | 11 +- .../dock-spaces/viewport/EngineFramePanel.cpp | 14 +- src/editor/dto/DockDTO.h | 1 + src/editor/service/DockService.cpp | 26 +- src/editor/service/DockService.h | 1 - src/editor/service/ThemeService.cpp | 90 +++-- src/editor/service/ThemeService.h | 12 +- src/main.cpp | 2 +- 19 files changed, 752 insertions(+), 139 deletions(-) create mode 100644 resources/theme.json diff --git a/resources/theme.json b/resources/theme.json new file mode 100644 index 00000000..0beeb31b --- /dev/null +++ b/resources/theme.json @@ -0,0 +1,22 @@ +{ + "dark": { + "palette0": "#18191b", + "palette1": "#08080a", + "palette2": "#161616", + "palette3": "#232323", + "palette4": "#414141", + "palette5": "#777777", + "palette6": "#E0E0E0", + "neutralPalette": "#161616" + }, + "light": { + "palette0": "#EBEBEB", + "palette1": "#F5F5F5", + "palette2": "#E1E1E1", + "palette3": "#C8C8C8", + "palette4": "#A0A0A0", + "palette5": "#787878", + "palette6": "#0A0A0A", + "neutralPalette": "#E1E1E1" + } +} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e2b3bc36..d1998475 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -288,6 +288,9 @@ target_link_libraries(metal_engine_lib PUBLIC ${COMMON_LIBRARIES}) add_executable(metal_engine main.cpp) target_link_libraries(metal_engine PRIVATE metal_engine_lib) +if (WIN32) + target_link_libraries(metal_engine PRIVATE dwmapi) +endif() add_dependencies(metal_engine copy_resources) add_custom_command(TARGET metal_engine POST_BUILD diff --git a/src/core/glfw/GLFWContext.cpp b/src/core/glfw/GLFWContext.cpp index 7a3a6e26..4c2509de 100644 --- a/src/core/glfw/GLFWContext.cpp +++ b/src/core/glfw/GLFWContext.cpp @@ -1,4 +1,8 @@ #include +#define GLFW_EXPOSE_NATIVE_WIN32 +#include +#include +#include #include "GLFWContext.h" #include "../../ApplicationContext.h" #include "../vulkan/VulkanUtils.h" @@ -43,6 +47,7 @@ namespace Metal { } void GLFWContext::disposeManually() { + disposeCursors(); glfwDestroyWindow(window); glfwTerminate(); } @@ -97,8 +102,311 @@ namespace Metal { const char **glfw_extensions = glfwGetRequiredInstanceExtensions(&extensions_count); for (unsigned int i = 0; i < extensions_count; i++) instance_extensions.push_back(glfw_extensions[i]); + + glfwSetWindowUserPointer(window, this); + glfwSetMouseButtonCallback(window, [](GLFWwindow *win, int button, int action, int mods) { + auto *ctx = static_cast(glfwGetWindowUserPointer(win)); + ctx->handleWindowManagement(button, action, mods); + for (auto &callback: ctx->getMouseButtonCallbacks()) { + callback(button, action, mods); + } + }); + glfwSetCursorPosCallback(window, [](GLFWwindow *win, double xpos, double ypos) { + auto *ctx = static_cast(glfwGetWindowUserPointer(win)); + ctx->handleCursorPos(xpos, ypos); + ctx->updateCursorShape(xpos, ypos); + for (auto &callback: ctx->getCursorPosCallbacks()) { + callback(xpos, ypos); + } + }); + + hResizeCursor = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR); + vResizeCursor = glfwCreateStandardCursor(GLFW_VRESIZE_CURSOR); + nwseResizeCursor = glfwCreateStandardCursor(GLFW_RESIZE_NWSE_CURSOR); + neswResizeCursor = glfwCreateStandardCursor(GLFW_RESIZE_NESW_CURSOR); + + // Enable Windows 11 rounded corners + HWND hwnd = glfwGetWin32Window(window); + if (hwnd) { + DWM_WINDOW_CORNER_PREFERENCE preference = DWMWCP_ROUND; + DwmSetWindowAttribute(hwnd, DWMWA_WINDOW_CORNER_PREFERENCE, &preference, sizeof(preference)); + } + } + } + } + + void GLFWContext::handleWindowManagement(int button, int action, int mods) { + if (button != GLFW_MOUSE_BUTTON_LEFT) return; + + double xpos, ypos; + glfwGetCursorPos(window, &xpos, &ypos); + + if (action == GLFW_PRESS) { + resizeRegion = getResizeRegion(xpos, ypos); + if (resizeRegion != ResizeRegion::None) { + isDragging = false; + glfwGetWindowPos(window, &dragStartWindowX, &dragStartWindowY); + glfwGetWindowSize(window, &dragStartWindowWidth, &dragStartWindowHeight); + dragStartCursorX = xpos; + dragStartCursorY = ypos; + return; + } + + bool isInTitleBar = ypos >= 0 && ypos < static_cast(windowManagerInfo.menuBarHeight); + + auto isInRect = [](const ImRect &rect, double x, double y) { + return x >= rect.Min.x && x <= rect.Max.x && y >= rect.Min.y && y <= rect.Max.y; + }; + + bool isOverButton = isInRect(windowManagerInfo.minimizeBtnRect, xpos, ypos) || + isInRect(windowManagerInfo.maximizeBtnRect, xpos, ypos) || + isInRect(windowManagerInfo.closeBtnRect, xpos, ypos); + + if (isInTitleBar && !isOverButton) { + double currentTime = glfwGetTime(); + if (currentTime - lastClickTime < 0.3) { + if (glfwGetWindowAttrib(window, GLFW_MAXIMIZED)) { + glfwRestoreWindow(window); + } else { + glfwMaximizeWindow(window); + } + isDragging = false; + lastClickTime = 0; + return; + } + lastClickTime = currentTime; + + isDragging = true; + dragStartCursorX = xpos; + dragStartCursorY = ypos; + glfwGetWindowPos(window, &dragStartWindowX, &dragStartWindowY); + + if (glfwGetWindowAttrib(window, GLFW_MAXIMIZED)) { + int windowWidth, windowHeight; + glfwGetWindowSize(window, &windowWidth, &windowHeight); + glfwRestoreWindow(window); + int restoredWidth, restoredHeight; + glfwGetWindowSize(window, &restoredWidth, &restoredHeight); + + double relativeX = dragStartCursorX / static_cast(windowWidth); + dragStartCursorX = relativeX * restoredWidth; + dragStartWindowX = static_cast(xpos - dragStartCursorX); + dragStartWindowY = static_cast(ypos - dragStartCursorY); + glfwSetWindowPos(window, dragStartWindowX, dragStartWindowY); + } + } + } else if (action == GLFW_RELEASE) { + if (isDragging && currentSnapTarget.active) { + applySnap(currentSnapTarget); + } + isDragging = false; + resizeRegion = ResizeRegion::None; + currentSnapTarget.active = false; + } + } + + void GLFWContext::handleCursorPos(double xpos, double ypos) { + if (isDragging) { + int wx, wy; + glfwGetWindowPos(window, &wx, &wy); + int newX = wx + static_cast(xpos - dragStartCursorX); + int newY = wy + static_cast(ypos - dragStartCursorY); + glfwSetWindowPos(window, newX, newY); + currentSnapTarget = calculateSnapTarget(xpos, ypos); + } else if (resizeRegion != ResizeRegion::None) { + int dx = static_cast(xpos - dragStartCursorX); + int dy = static_cast(ypos - dragStartCursorY); + + int newX = dragStartWindowX; + int newY = dragStartWindowY; + int newW = dragStartWindowWidth; + int newH = dragStartWindowHeight; + + const int minW = 400; + const int minH = 300; + + switch (resizeRegion) { + case ResizeRegion::Left: + newX += dx; + newW -= dx; + break; + case ResizeRegion::Right: + newW += dx; + break; + case ResizeRegion::Top: + newY += dy; + newH -= dy; + break; + case ResizeRegion::Bottom: + newH += dy; + break; + case ResizeRegion::TopLeft: + newX += dx; + newW -= dx; + newY += dy; + newH -= dy; + break; + case ResizeRegion::TopRight: + newW += dx; + newY += dy; + newH -= dy; + break; + case ResizeRegion::BottomLeft: + newX += dx; + newW -= dx; + newH += dy; + break; + case ResizeRegion::BottomRight: + newW += dx; + newH += dy; + break; + default: + break; + } + + if (newW < minW) { + if (resizeRegion == ResizeRegion::Left || resizeRegion == ResizeRegion::TopLeft || resizeRegion == ResizeRegion::BottomLeft) { + newX = dragStartWindowX + (dragStartWindowWidth - minW); + } + newW = minW; + } + if (newH < minH) { + if (resizeRegion == ResizeRegion::Top || resizeRegion == ResizeRegion::TopLeft || resizeRegion == ResizeRegion::TopRight) { + newY = dragStartWindowY + (dragStartWindowHeight - minH); + } + newH = minH; + } + + int curX, curY, curW, curH; + glfwGetWindowPos(window, &curX, &curY); + glfwGetWindowSize(window, &curW, &curH); + + if (newX != curX || newY != curY) glfwSetWindowPos(window, newX, newY); + if (newW != curW || newH != curH) glfwSetWindowSize(window, newW, newH); + } + } + + void GLFWContext::updateCursorShape(double xpos, double ypos) { + if (isDragging) return; + + ResizeRegion region = (resizeRegion != ResizeRegion::None) ? resizeRegion : getResizeRegion(xpos, ypos); + GLFWcursor *cursor = nullptr; + + switch (region) { + case ResizeRegion::Left: + case ResizeRegion::Right: + cursor = hResizeCursor; + break; + case ResizeRegion::Top: + case ResizeRegion::Bottom: + cursor = vResizeCursor; + break; + case ResizeRegion::TopLeft: + case ResizeRegion::BottomRight: + cursor = nwseResizeCursor; + break; + case ResizeRegion::TopRight: + case ResizeRegion::BottomLeft: + cursor = neswResizeCursor; + break; + default: + break; + } + + glfwSetCursor(window, cursor); + } + + ResizeRegion GLFWContext::getResizeRegion(double xpos, double ypos) { + if (glfwGetWindowAttrib(window, GLFW_MAXIMIZED)) return ResizeRegion::None; + + int w, h; + glfwGetWindowSize(window, &w, &h); + const double thickness = 8.0; + + bool left = xpos < thickness; + bool right = xpos > w - thickness; + bool top = ypos < thickness; + bool bottom = ypos > h - thickness; + + if (left && top) return ResizeRegion::TopLeft; + if (right && top) return ResizeRegion::TopRight; + if (left && bottom) return ResizeRegion::BottomLeft; + if (right && bottom) return ResizeRegion::BottomRight; + if (left) return ResizeRegion::Left; + if (right) return ResizeRegion::Right; + if (top) return ResizeRegion::Top; + if (bottom) return ResizeRegion::Bottom; + + return ResizeRegion::None; + } + + void GLFWContext::applySnap(const SnapTarget &target) { + if (target.isMaximized) { + glfwMaximizeWindow(window); + } else { + glfwRestoreWindow(window); + glfwSetWindowPos(window, target.x, target.y); + glfwSetWindowSize(window, target.width, target.height); + } + } + + SnapTarget GLFWContext::calculateSnapTarget(double xpos, double ypos) { + SnapTarget target; + int wx, wy; + glfwGetWindowPos(window, &wx, &wy); + double screenX = wx + xpos; + double screenY = wy + ypos; + + int screenW = windowManagerInfo.screenWidth; + int screenH = windowManagerInfo.screenHeight; + + const int threshold = 10; + + if (screenY < threshold) { + target.active = true; + target.isMaximized = true; + return target; + } + + if (screenX < threshold) { + target.active = true; + target.x = 0; + target.y = 0; + target.width = screenW / 2; + target.height = screenH; + if (screenY < threshold * 5) { + target.height = screenH / 2; + } else if (screenY > screenH - threshold * 5) { + target.y = screenH / 2; + target.height = screenH / 2; + } + return target; + } + + if (screenX > screenW - threshold) { + target.active = true; + target.x = screenW / 2; + target.y = 0; + target.width = screenW / 2; + target.height = screenH; + if (screenY < threshold * 5) { + target.height = screenH / 2; + } else if (screenY > screenH - threshold * 5) { + target.y = screenH / 2; + target.height = screenH / 2; } + return target; } + + return target; + } + + void GLFWContext::disposeCursors() { + if (hResizeCursor) glfwDestroyCursor(hResizeCursor); + if (vResizeCursor) glfwDestroyCursor(vResizeCursor); + if (nwseResizeCursor) glfwDestroyCursor(nwseResizeCursor); + if (neswResizeCursor) glfwDestroyCursor(neswResizeCursor); + hResizeCursor = vResizeCursor = nwseResizeCursor = neswResizeCursor = nullptr; } const ImVector &GLFWContext::getInstanceExtensions() const { diff --git a/src/core/glfw/GLFWContext.h b/src/core/glfw/GLFWContext.h index 33ad1dc3..faae8ae7 100644 --- a/src/core/glfw/GLFWContext.h +++ b/src/core/glfw/GLFWContext.h @@ -6,18 +6,51 @@ #include #include +#include #include "../../common/IContextMember.h" #include "../../common/IDisposable.h" #include "../../common/IInit.h" +#include +#include + struct ImGui_ImplVulkanH_Window; namespace Metal { class ApplicationContext; class VulkanContext; + enum class ResizeRegion { + None, + Left, + Right, + Top, + Bottom, + TopLeft, + TopRight, + BottomLeft, + BottomRight + }; + + struct SnapTarget { + int x, y, width, height; + bool active = false; + bool isMaximized = false; + }; + + struct WindowManagerInfo { + float menuBarHeight = 0; + ImRect minimizeBtnRect; + ImRect maximizeBtnRect; + ImRect closeBtnRect; + int windowWidth = 0; + int windowHeight = 0; + int screenWidth = 0; + int screenHeight = 0; + }; + class GLFWContext final : public IContextMember, public IInit { VulkanContext *vulkanContext = nullptr; GLFWwindow *window = nullptr; @@ -25,11 +58,46 @@ namespace Metal { bool swapChainRebuild = false; ImVector instance_extensions{}; + std::vector> mouseButtonCallbacks; + std::vector> cursorPosCallbacks; + + // Window management state + WindowManagerInfo windowManagerInfo; + bool isDragging = false; + ResizeRegion resizeRegion = ResizeRegion::None; + double dragStartCursorX = 0; + double dragStartCursorY = 0; + int dragStartWindowX = 0; + int dragStartWindowY = 0; + int dragStartWindowWidth = 0; + int dragStartWindowHeight = 0; + double lastClickTime = 0; + + // Snapping state + SnapTarget currentSnapTarget; + + // Cursor shapes + GLFWcursor *hResizeCursor = nullptr; + GLFWcursor *vResizeCursor = nullptr; + GLFWcursor *nwseResizeCursor = nullptr; + GLFWcursor *neswResizeCursor = nullptr; + + void handleWindowManagement(int button, int action, int mods); + void handleCursorPos(double xpos, double ypos); + void updateCursorShape(double xpos, double ypos); + ResizeRegion getResizeRegion(double xpos, double ypos); + void applySnap(const SnapTarget& target); + SnapTarget calculateSnapTarget(double xpos, double ypos); + public: std::vector getDependencies() override { return {{"VulkanContext", &vulkanContext}}; } + void updateWindowManagerInfo(const WindowManagerInfo& info) { + windowManagerInfo = info; + } + void setSwapChainRebuild(bool val); void presentFrame(); @@ -47,6 +115,24 @@ namespace Metal { void disposeManually(); [[nodiscard]] ImGui_ImplVulkanH_Window &getGUIWindow() const; + + void addMouseButtonCallback(std::function callback) { + mouseButtonCallbacks.push_back(std::move(callback)); + } + + void addCursorPosCallback(std::function callback) { + cursorPosCallbacks.push_back(std::move(callback)); + } + + const std::vector> &getMouseButtonCallbacks() const { + return mouseButtonCallbacks; + } + + const std::vector> &getCursorPosCallbacks() const { + return cursorPosCallbacks; + } + + void disposeCursors(); }; } diff --git a/src/editor/EditorPanel.cpp b/src/editor/EditorPanel.cpp index 8626f437..714361f6 100644 --- a/src/editor/EditorPanel.cpp +++ b/src/editor/EditorPanel.cpp @@ -20,7 +20,7 @@ namespace Metal { const char *EditorPanel::NAME_HEADER = "##header_window"; const char *EditorPanel::NAME_FOOTER = "##footer_window"; ImVec2 EditorPanel::CENTER(0.0f, 0.0f); - float EditorPanel::HEADER_HEIGHT = 25; + float EditorPanel::HEADER_HEIGHT = 35; float EditorPanel::FOOTER_HEIGHT = 30; @@ -37,7 +37,7 @@ namespace Metal { UIUtil::AUX_VEC2.y = HEADER_HEIGHT; ImGui::SetNextWindowSize(UIUtil::AUX_VEC2); - SetWindowStyle(); + SetWindowStyle(UIUtil::VEC2_ZERO); ImGui::Begin(NAME_HEADER, &UIUtil::OPEN, FLAGS | ImGuiWindowFlags_NoScrollbar); ImGui::PopStyleVar(3); @@ -56,7 +56,9 @@ namespace Metal { ImGui::SetNextWindowSize(UIUtil::AUX_VEC2); ImGui::SetNextWindowViewport(viewport->ID); - SetWindowStyle(); + UIUtil::AUX_VEC2.x = 4.0f; + UIUtil::AUX_VEC2.y = .0f; + SetWindowStyle(UIUtil::AUX_VEC2); ImGui::Begin(NAME, &UIUtil::OPEN, FLAGS); windowId = ImGui::GetID(NAME); ImGui::PopStyleVar(3); @@ -81,7 +83,7 @@ namespace Metal { UIUtil::AUX_VEC2.y = FOOTER_HEIGHT; ImGui::SetNextWindowSize(UIUtil::AUX_VEC2); - SetWindowStyle(); + SetWindowStyle(UIUtil::VEC2_ZERO); ImGui::Begin(NAME_FOOTER, &UIUtil::OPEN, FLAGS | ImGuiWindowFlags_NoScrollbar); ImGui::PopStyleVar(3); @@ -90,10 +92,10 @@ namespace Metal { } } - void EditorPanel::SetWindowStyle() { + void EditorPanel::SetWindowStyle(const ImVec2 &padding) { ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); - ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, UIUtil::VEC2_ZERO); + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, padding); } void EditorPanel::onSync() { diff --git a/src/editor/EditorPanel.h b/src/editor/EditorPanel.h index f3a97a12..63d4a653 100644 --- a/src/editor/EditorPanel.h +++ b/src/editor/EditorPanel.h @@ -25,7 +25,7 @@ namespace Metal { DockService *dockService = nullptr; ThemeService *themeService = nullptr; - static void SetWindowStyle(); + static void SetWindowStyle(const ImVec2 &padding); void renderDockSpaces(); diff --git a/src/editor/dock-spaces/docks/DockSpacePanel.cpp b/src/editor/dock-spaces/docks/DockSpacePanel.cpp index 60f9c479..4962e07f 100644 --- a/src/editor/dock-spaces/docks/DockSpacePanel.cpp +++ b/src/editor/dock-spaces/docks/DockSpacePanel.cpp @@ -11,6 +11,9 @@ #include "../../../common/LoggerUtil.h" #include "../../repository/EditorRepository.h" #include "../../service/ThemeService.h" +#define BORDER_RADIUS 8.0f +#define OUTSIDE_PADDING 2.0f +#define INSIDE_PADDING 8.0f namespace Metal { const ImVec2 DockSpacePanel::DEFAULT{-1.f, -1.f}; @@ -75,18 +78,22 @@ namespace Metal { initializeView(); } ImGui::SetNextWindowSizeConstraints(MIN_SIZE, MAX_SIZE); - if (padding.x != DEFAULT.x || padding.y != DEFAULT.y) { - ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, padding); - stylePushCount++; - } if (!sizeInitialized && dock->sizeX > 0 && dock->sizeY > 0) { UIUtil::AUX_VEC2.x = dock->sizeX; UIUtil::AUX_VEC2.y = dock->sizeY; ImGui::SetNextWindowSize(UIUtil::AUX_VEC2); sizeInitialized = true; } + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); + ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, BORDER_RADIUS); + ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0)); + ImGui::PushStyleColor(ImGuiCol_Border, themeService->palette3); + ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); + stylePushCount = 3; + styleColorPushCount = 2; beforeWindow(); - if (ImGui::Begin(dock->internalId.c_str(), &UIUtil::OPEN, FLAGS)) { + if (ImGui::Begin(dock->internalId.c_str(), &UIUtil::OPEN, + (FLAGS & ~ImGuiWindowFlags_MenuBar) | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) { handleShortcut(); sizeInternal = ImGui::GetWindowSize(); size.x = sizeInternal.x; @@ -96,73 +103,130 @@ namespace Metal { dock->sizeY = size.y; position = ImGui::GetWindowPos(); - renderHeader(); - if (view != nullptr) { - view->onSync(); + + ImGui::SetCursorPos(ImVec2(OUTSIDE_PADDING, OUTSIDE_PADDING)); + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, BORDER_RADIUS); + ImGui::PushStyleColor(ImGuiCol_ChildBg, themeService->palette0); + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(INSIDE_PADDING, INSIDE_PADDING)); + if (ImGui::BeginChild((dock->internalId + "island").c_str(), ImVec2(size.x - OUTSIDE_PADDING * 2, size.y - OUTSIDE_PADDING * 2), + ImGuiChildFlags_None, ImGuiWindowFlags_None)) { + if (!dock->isCenter) { + renderCustomHeader(); + } + + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, padding.x != DEFAULT.x ? padding : ImVec2(INSIDE_PADDING, INSIDE_PADDING)); + if (ImGui::BeginChild((dock->internalId + "content").c_str(), ImVec2(0, 0), ImGuiChildFlags_None, + ImGuiWindowFlags_None)) { + if (view != nullptr) { + view->onSync(); + } + } + ImGui::EndChild(); + ImGui::PopStyleVar(); } + ImGui::EndChild(); + ImGui::PopStyleColor(); + ImGui::PopStyleVar(2); } ImGui::End(); + ImGui::PopStyleColor(styleColorPushCount); ImGui::PopStyleVar(stylePushCount); stylePushCount = 0; + styleColorPushCount = 0; } AbstractDockPanel *DockSpacePanel::getView() const { return view; } - void DockSpacePanel::renderHeader() { - headerPadding.x = ImGui::GetStyle().FramePadding.x; + void DockSpacePanel::renderCustomHeader() { + const float buttonWidth = 23.0f; + const float headerPaddingY = (headerHeight - ImGui::GetFrameHeight()) * 0.5f; - if (ImGui::BeginMenuBar()) { - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, headerPadding); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(ImGui::GetStyle().FramePadding.x, headerPaddingY)); + + // Tab Bar Area + ImGui::BeginGroup(); + + const float availableWidth = ImGui::GetContentRegionAvail().x - buttonWidth - ImGui::GetStyle().ItemSpacing.x; + + if (ImGui::BeginChild((id + "tabs_scroll").c_str(), ImVec2(availableWidth, headerHeight), ImGuiChildFlags_None, + ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_NoBackground)) { const bool isFocused = ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows); - ImGui::PushStyleColor(ImGuiCol_TabActive, - isFocused ? editorRepository->accent : themeService->palette0); - if (ImGui::BeginTabBar((id + "dockTabs").c_str(), ImGuiTabBarFlags_AutoSelectNewTabs)) { - for (auto *space: dock->dockSpaces) { - if (space == nullptr) { - continue; - } - const std::string label = space->icon + " " + space->name + id + - std::to_string(space->index); + for (auto *space: dock->dockSpaces) { + if (space == nullptr) continue; - if (ImGui::BeginTabItem(label.c_str(), nullptr)) { - if (dock->selectedOption != space->index) { - dock->selectedOption = space->index; - initializeView(); - } - ImGui::EndTabItem(); - } + const std::string label = space->icon + " " + space->name + "##" + std::to_string(space->index); + const bool isSelected = (dock->selectedOption == space->index); + + if (isSelected) { + ImGui::PushStyleColor(ImGuiCol_Button, + isFocused ? editorRepository->accent : themeService->palette3); + } else { + ImGui::PushStyleColor(ImGuiCol_Button, themeService->palette3); } - ImGui::SetNextItemWidth(23); - if (ImGui::TabItemButton((Icons::add.c_str() + id + "addTab").c_str(), - ImGuiTabItemFlags_Trailing | ImGuiTabItemFlags_NoReorder)) { - ImGui::OpenPopup((id + "NewTabDropdown").c_str()); + + if (ImGui::Button(label.c_str(), ImVec2(0, headerHeight))) { + dock->selectedOption = space->index; + initializeView(); } - if (ImGui::BeginPopup((id + "NewTabDropdown").c_str())) { - ImGui::Text("New Tab"); - ImGui::Separator(); - for (auto *option: DockSpace::OPTIONS_LIST) { - const bool exists = hasDockSpace(option->index); - const std::string label = option->icon + " " + option->name; - if (ImGui::MenuItem(label.c_str(), nullptr, false, !exists)) { - dock->dockSpaces.emplace_back(option); - dock->selectedOption = option->index; - initializeView(); + if (dock->dockSpaces.size() > 1) { + ImGui::SameLine(0, 0); + ImGui::PushStyleColor(ImGuiCol_Button, isSelected ? (isFocused ? editorRepository->accent : themeService->palette3) : themeService->palette3); + if (ImGui::Button((Icons::close + "##close" + std::to_string(space->index) + id).c_str(), ImVec2(0, headerHeight))) { + int indexToRemove = -1; + for (int i = 0; i < dock->dockSpaces.size(); i++) { + if (dock->dockSpaces[i]->index == space->index) { + indexToRemove = i; + break; + } + } + if (indexToRemove != -1) { + dock->dockSpaces.erase(dock->dockSpaces.begin() + indexToRemove); + if (isSelected && !dock->dockSpaces.empty()) { + dock->selectedOption = dock->dockSpaces.front()->index; + initializeView(); + } } } - ImGui::EndPopup(); + ImGui::PopStyleColor(); } - ImGui::EndTabBar(); + ImGui::PopStyleColor(); + ImGui::SameLine(); } - ImGui::PopStyleColor(); - ImGui::PopStyleVar(); - ImGui::EndMenuBar(); } + ImGui::EndChild(); + + ImGui::SameLine(); + + // Add Tab Button + if (UIUtil::ButtonSimple(Icons::add + "##addTab" + id, buttonWidth, headerHeight)) { + ImGui::OpenPopup((id + "NewTabDropdown").c_str()); + } + + if (ImGui::BeginPopup((id + "NewTabDropdown").c_str())) { + ImGui::Text("New Tab"); + ImGui::Separator(); + for (auto *option: DockSpace::OPTIONS_LIST) { + const bool exists = hasDockSpace(option->index); + const std::string label = option->icon + " " + option->name; + if (ImGui::MenuItem(label.c_str(), nullptr, false, !exists)) { + dock->dockSpaces.emplace_back(option); + dock->selectedOption = option->index; + initializeView(); + } + } + ImGui::EndPopup(); + } + + ImGui::EndGroup(); + ImGui::PopStyleVar(); + + ImGui::Separator(); } DockSpace *DockSpacePanel::getSelectedDockSpace() const { diff --git a/src/editor/dock-spaces/docks/DockSpacePanel.h b/src/editor/dock-spaces/docks/DockSpacePanel.h index 911e94bc..cd5f4616 100644 --- a/src/editor/dock-spaces/docks/DockSpacePanel.h +++ b/src/editor/dock-spaces/docks/DockSpacePanel.h @@ -22,11 +22,13 @@ namespace Metal { bool isDownDirection = false; bool sizeInitialized = false; int stylePushCount = 0; + int styleColorPushCount = 0; DockSpacePanel *mainWindow = nullptr; DockDTO *dock = nullptr; AbstractDockPanel *view = nullptr; std::unordered_map views{}; ImVec2 headerPadding{0, 3}; + float headerHeight = 25.0f; EditorRepository *editorRepository = nullptr; ThemeService *themeService = nullptr; @@ -35,6 +37,8 @@ namespace Metal { bool hasDockSpace(int index) const; + void renderCustomHeader(); + public: std::vector getDependencies() override { return { @@ -67,8 +71,6 @@ namespace Metal { [[nodiscard]] AbstractDockPanel *getView() const; - void renderHeader(); - void beforeWindow() const; ImVec2 &getPosition(); diff --git a/src/editor/dock-spaces/footer/EditorFooterPanel.cpp b/src/editor/dock-spaces/footer/EditorFooterPanel.cpp index 0a427db7..adae38ea 100644 --- a/src/editor/dock-spaces/footer/EditorFooterPanel.cpp +++ b/src/editor/dock-spaces/footer/EditorFooterPanel.cpp @@ -3,10 +3,10 @@ #include "../../util/UIUtil.h" #include "../../../ApplicationContext.h" #include "../../repository/EditorRepository.h" +#include "../../service/ThemeService.h" namespace Metal { void EditorFooterPanel::onSync() { - ImGui::Separator(); asyncTaskPanel->onSync(); ImGui::SameLine(); renderShortcuts(); @@ -20,8 +20,13 @@ namespace Metal { void EditorFooterPanel::framerate() { const int framerate = static_cast(round(ImGui::GetIO().Framerate)); if (framerate > 0) { - ImGui::SameLine(ImGui::GetWindowWidth() - 100); + ImGui::SameLine(ImGui::GetWindowWidth() - 130); ImGui::Text("%i ms | %i fps", 1000 / framerate, framerate); + ImGui::SameLine(); + if (UIUtil::ButtonSimple((editorRepository->isDarkMode ? Icons::light_mode : Icons::dark_mode) + id + "theme", + UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE)) { + editorRepository->isDarkMode = !editorRepository->isDarkMode; + } } } diff --git a/src/editor/dock-spaces/footer/EditorFooterPanel.h b/src/editor/dock-spaces/footer/EditorFooterPanel.h index 9f4ec717..2e12a08a 100644 --- a/src/editor/dock-spaces/footer/EditorFooterPanel.h +++ b/src/editor/dock-spaces/footer/EditorFooterPanel.h @@ -5,20 +5,22 @@ namespace Metal { struct EditorRepository; - + class ThemeService; class AsyncTaskPanel; class EditorFooterPanel final : public AbstractPanel { EditorRepository *editorRepository = nullptr; + ThemeService *themeService = nullptr; AsyncTaskPanel *asyncTaskPanel = nullptr; void renderShortcuts(); - static void framerate(); + void framerate(); public: std::vector getDependencies() override { return { - {"EditorRepository", &editorRepository} + {"EditorRepository", &editorRepository}, + {"ThemeService", &themeService} }; } diff --git a/src/editor/dock-spaces/header/EditorHeaderPanel.cpp b/src/editor/dock-spaces/header/EditorHeaderPanel.cpp index ae5ee5f4..6aba4425 100644 --- a/src/editor/dock-spaces/header/EditorHeaderPanel.cpp +++ b/src/editor/dock-spaces/header/EditorHeaderPanel.cpp @@ -4,77 +4,121 @@ #include "../../../core/DirectoryService.h" #include "../../../core/glfw/GLFWContext.h" #include "../../../engine/EngineContext.h" +#include "editor/service/ThemeService.h" +#define HEIGHT 35.0f namespace Metal { void EditorHeaderPanel::onSync() { + ImGui::SetCursorPosX(5); + ImGui::SetCursorPosY(0); renderFileTab(); - ImGui::Dummy(ImVec2(0, UIUtil::ONLY_ICON_BUTTON_SIZE)); - ImGui::Dummy(ImVec2(2, 0)); - ImGui::Separator(); + renderWindowControls(); } void EditorHeaderPanel::renderWindowControls() { - ImGui::SameLine(ImGui::GetWindowWidth() - (UIUtil::ONLY_ICON_BUTTON_SIZE * 3 + 20)); + ImGui::SameLine(ImGui::GetWindowWidth() - (HEIGHT * 3)); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0)); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); + ImGui::PushStyleColor(ImGuiCol_Border, themeService->palette1); + ImGui::PushStyleColor(ImGuiCol_Button, themeService->palette1); GLFWwindow *window = glfwContext->getWindow(); - if (UIUtil::ButtonSimple((Icons::minimize + id + "min"), UIUtil::ONLY_ICON_BUTTON_SIZE, - UIUtil::ONLY_ICON_BUTTON_SIZE)) { + WindowManagerInfo info; + info.menuBarHeight = HEIGHT; + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, themeService->palette3); + + if (UIUtil::ButtonSimple((Icons::minimize + id + "min"), HEIGHT, HEIGHT)) { glfwIconifyWindow(window); } + info.minimizeBtnRect = ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax()); ImGui::SameLine(); bool isMaximized = glfwGetWindowAttrib(window, GLFW_MAXIMIZED); if (UIUtil::ButtonSimple((isMaximized ? Icons::filter_none : Icons::crop_square) + id + "max", - UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE)) { + HEIGHT, HEIGHT)) { if (isMaximized) { glfwRestoreWindow(window); } else { glfwMaximizeWindow(window); } } + ImGui::PopStyleColor(); + + info.maximizeBtnRect = ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax()); ImGui::SameLine(); - if (UIUtil::ButtonSimple(Icons::close + id + "close", UIUtil::ONLY_ICON_BUTTON_SIZE, - UIUtil::ONLY_ICON_BUTTON_SIZE)) { + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.9f, 0.1f, 0.1f, 1.0f)); + if (UIUtil::ButtonSimple(Icons::close + id + "close", HEIGHT, HEIGHT)) { glfwSetWindowShouldClose(window, GLFW_TRUE); } + info.closeBtnRect = ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax()); + ImGui::PopStyleColor(); + + ImGui::PopStyleColor(2); + ImGui::PopStyleVar(2); + + int w, h; + glfwGetWindowSize(window, &w, &h); + info.windowWidth = w; + info.windowHeight = h; + + GLFWmonitor *monitor = glfwGetPrimaryMonitor(); + const GLFWvidmode *mode = glfwGetVideoMode(monitor); + if (mode) { + info.screenWidth = mode->width; + info.screenHeight = mode->height; + } + + glfwContext->updateWindowManagerInfo(info); + } + + void EditorHeaderPanel::renderMenu(const char *label, std::function itemsFunc) { + if (ImGui::Button(label, ImVec2(0, HEIGHT))) { + ImGui::OpenPopup(label); + } + if (ImGui::BeginPopup(label)) { + itemsFunc(); + ImGui::EndPopup(); + } } void EditorHeaderPanel::renderFileTab() { - if (ImGui::BeginMainMenuBar()) { - if (UIUtil::ButtonSimple(Icons::save, UIUtil::ONLY_ICON_BUTTON_SIZE, UIUtil::ONLY_ICON_BUTTON_SIZE)) { - directoryService->save(); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10, 10)); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(10, 0)); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); + + if (UIUtil::ButtonSimple(Icons::save, HEIGHT, HEIGHT)) { + directoryService->save(); + } + ImGui::SameLine(); + + ImGui::SetCursorPosY(0); + + + renderMenu("File", [this] { + if (ImGui::MenuItem("Open", "Ctrl+O")) { + engineContext->dispose(); + directoryService->updateRootPath(true); } - ImGui::SameLine(); - if (ImGui::BeginMenu("File")) { - if (ImGui::MenuItem("Open", "Ctrl+O")) { - engineContext->dispose(); - directoryService->updateRootPath(true); - } - if (ImGui::MenuItem("Save", "Ctrl+S")) { - directoryService->save(); - } - ImGui::Separator(); - if (ImGui::MenuItem("Exit")) { - exit(0); - } - ImGui::EndMenu(); + if (ImGui::MenuItem("Save", "Ctrl+S")) { + directoryService->save(); } - - // Edit menu - if (ImGui::BeginMenu("Edit")) { - if (ImGui::MenuItem("Compile shaders")) { - engineContext->dispose(); - } - ImGui::EndMenu(); + ImGui::Separator(); + if (ImGui::MenuItem("Exit")) { + exit(0); } + }); + ImGui::SameLine(); - // Window controls (minimize, maximize, close) - renderWindowControls(); + renderMenu("Edit", [this] { + if (ImGui::MenuItem("Compile shaders")) { + engineContext->dispose(); + } + }); - ImGui::EndMainMenuBar(); - } + ImGui::PopStyleColor(); + ImGui::PopStyleVar(2); } } diff --git a/src/editor/dock-spaces/header/EditorHeaderPanel.h b/src/editor/dock-spaces/header/EditorHeaderPanel.h index 032e7ab5..7973077c 100644 --- a/src/editor/dock-spaces/header/EditorHeaderPanel.h +++ b/src/editor/dock-spaces/header/EditorHeaderPanel.h @@ -1,10 +1,13 @@ #ifndef METAL_ENGINE_EDITORHEADERPANEL_H #define METAL_ENGINE_EDITORHEADERPANEL_H +#include + #include "../../abstract/AbstractPanel.h" #include namespace Metal { + class ThemeService; class GLFWContext; class EngineContext; struct DirectoryService; @@ -13,17 +16,23 @@ namespace Metal { GLFWContext *glfwContext = nullptr; EngineContext *engineContext = nullptr; DirectoryService *directoryService = nullptr; + ThemeService *themeService = nullptr; + + float menuBarHeight = 0; void renderFileTab(); void renderWindowControls(); + void renderMenu(const char *label, std::function itemsFunc); + public: std::vector getDependencies() override { return { {"GLFWContext", &glfwContext}, {"EngineContext", &engineContext}, - {"DirectoryService", &directoryService} + {"DirectoryService", &directoryService}, + {"ThemeService", &themeService} }; } diff --git a/src/editor/dock-spaces/viewport/EngineFramePanel.cpp b/src/editor/dock-spaces/viewport/EngineFramePanel.cpp index 12f6587c..acb2ebbb 100644 --- a/src/editor/dock-spaces/viewport/EngineFramePanel.cpp +++ b/src/editor/dock-spaces/viewport/EngineFramePanel.cpp @@ -76,11 +76,17 @@ namespace Metal { auto *framebuffer = engineContext->currentFrame->getResourceAs(RID_POST_PROCESSING_FBO); if (framebuffer) { descriptorSetService->setImageDescriptor(framebuffer, 0); - ImGui::Image(reinterpret_cast(framebuffer->attachments[0]->imageDescriptor->vkDescriptorSet), - viewportSize); + + const ImVec2 pos = ImGui::GetCursorScreenPos(); + const auto textureId = reinterpret_cast(framebuffer->attachments[0]->imageDescriptor->vkDescriptorSet); + + ImGui::GetWindowDrawList()->AddImageRounded(textureId, pos, ImVec2(pos.x + viewportSize.x, pos.y + viewportSize.y), + ImVec2(0, 0), ImVec2(1, 1), IM_COL32_WHITE, 8.0f); + + ImGui::Dummy(viewportSize); - const ImVec2 imageMin = ImGui::GetItemRectMin(); - const ImVec2 imageMax = ImGui::GetItemRectMax(); + const ImVec2 imageMin = pos; + const ImVec2 imageMax = ImVec2(pos.x + viewportSize.x, pos.y + viewportSize.y); handleViewportPicking(imageMin, imageMax); } } diff --git a/src/editor/dto/DockDTO.h b/src/editor/dto/DockDTO.h index 1d3b84f3..92edec34 100644 --- a/src/editor/dto/DockDTO.h +++ b/src/editor/dto/DockDTO.h @@ -9,6 +9,7 @@ namespace Metal { struct DockDTO { + bool isCenter = false; const std::string id = Util::uuidV4(); ImGuiID nodeId{}; int selectedOption; diff --git a/src/editor/service/DockService.cpp b/src/editor/service/DockService.cpp index cf2f9182..b259d216 100644 --- a/src/editor/service/DockService.cpp +++ b/src/editor/service/DockService.cpp @@ -10,24 +10,26 @@ namespace Metal { void DockService::onInitialize() { auto *rightT = new DockDTO{&DockSpace::WORLD}; - auto *leftTop = new DockDTO{&DockSpace::REPOSITORIES}; - auto *leftDown = new DockDTO{&DockSpace::INSPECTOR}; - auto *downLeft = new DockDTO{&DockSpace::CONSOLE}; - auto *downRight = new DockDTO{&DockSpace::FILES}; + auto *leftT = new DockDTO{&DockSpace::REPOSITORIES}; + auto *leftB = new DockDTO{&DockSpace::INSPECTOR}; + auto *rightB = new DockDTO{&DockSpace::CONSOLE}; + auto *b = new DockDTO{&DockSpace::FILES}; + center.isCenter = true; center.sizeRatioForNodeAtDir = 0.5f; rightT->sizeRatioForNodeAtDir = 0.25f; - leftTop->sizeRatioForNodeAtDir = 0.2f; - leftDown->sizeRatioForNodeAtDir = 0.5f; - downLeft->sizeRatioForNodeAtDir = 0.25f; - downRight->sizeRatioForNodeAtDir = 0.5f; + leftT->sizeRatioForNodeAtDir = 0.2f; + leftB->sizeRatioForNodeAtDir = 0.5f; + rightB->sizeRatioForNodeAtDir = 0.25f; + b->sizeRatioForNodeAtDir = 0.25f; right.push_back(rightT); - left.push_back(leftTop); - left.push_back(leftDown); + right.push_back(rightB); - bottom.push_back(downLeft); - bottom.push_back(downRight); + left.push_back(leftT); + left.push_back(leftB); + + bottom.push_back(b); } void DockService::buildViews(ImGuiID windowId, AbstractPanel *panel) { diff --git a/src/editor/service/DockService.h b/src/editor/service/DockService.h index c8b8de89..23d585dc 100644 --- a/src/editor/service/DockService.h +++ b/src/editor/service/DockService.h @@ -15,7 +15,6 @@ namespace Metal { std::vector left; std::vector right; - bool isInitialized = false; public: diff --git a/src/editor/service/ThemeService.cpp b/src/editor/service/ThemeService.cpp index d508d959..fc1bb51b 100644 --- a/src/editor/service/ThemeService.cpp +++ b/src/editor/service/ThemeService.cpp @@ -1,13 +1,57 @@ #include "ThemeService.h" #include +#include +#include +#include #include "../repository/EditorRepository.h" namespace Metal { glm::vec3 ThemeService::BACKGROUND_COLOR = glm::vec3(0.f); + void ThemeService::loadTheme() { + if (themeLoaded) return; + + std::string filename = "theme.json"; + if (!std::filesystem::exists(filename)) { + filename = "resources/theme.json"; + } + + if (std::filesystem::exists(filename)) { + try { + std::ifstream f(filename); + themeData = nlohmann::json::parse(f); + themeLoaded = true; + } catch (const std::exception& e) { + std::cerr << "Failed to parse theme.json: " << e.what() << std::endl; + } + } else { + std::cerr << "theme.json not found in root or resources directory." << std::endl; + } + } + + ImVec4 ThemeService::hexToRGBA(const std::string& hex) { + std::string h = hex; + if (h[0] == '#') h = h.substr(1); + + if (h.length() == 6) { + int r = std::stoi(h.substr(0, 2), nullptr, 16); + int g = std::stoi(h.substr(2, 2), nullptr, 16); + int b = std::stoi(h.substr(4, 2), nullptr, 16); + return ImVec4(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f); + } else if (h.length() == 8) { + int r = std::stoi(h.substr(0, 2), nullptr, 16); + int g = std::stoi(h.substr(2, 2), nullptr, 16); + int b = std::stoi(h.substr(4, 2), nullptr, 16); + int a = std::stoi(h.substr(6, 2), nullptr, 16); + return ImVec4(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f); + } + return ImVec4(1.0f, 1.0f, 1.0f, 1.0f); // Default white + } + void ThemeService::onSync() { + loadTheme(); if (previousTheme == editorRepository->isDarkMode && glm::length(editorRepository->accentColor) == prevLength) { return; } @@ -31,7 +75,7 @@ namespace Metal { colors[ImGuiCol_WindowBg] = palette1; colors[ImGuiCol_ChildBg] = palette1; colors[ImGuiCol_PopupBg] = palette1; - colors[ImGuiCol_Border] = palette3; + colors[ImGuiCol_Border] = palette1; colors[ImGuiCol_BorderShadow] = ImVec4(0.f, 0.f, 0.f, 0.f); colors[ImGuiCol_FrameBg] = palette2; colors[ImGuiCol_TitleBg] = palette1; @@ -44,10 +88,8 @@ namespace Metal { colors[ImGuiCol_ScrollbarGrabActive] = palette2; colors[ImGuiCol_SliderGrab] = palette4; colors[ImGuiCol_ButtonActive] = palette2; - colors[ImGuiCol_Separator] = palette5; - colors[ImGuiCol_SeparatorHovered] = palette6; - colors[ImGuiCol_SeparatorActive] = palette6; - colors[ImGuiCol_ResizeGrip] = palette4; + colors[ImGuiCol_Separator] = palette1; + colors[ImGuiCol_ResizeGrip] = palette1; colors[ImGuiCol_Tab] = palette2; colors[ImGuiCol_TabHovered] = palette3; colors[ImGuiCol_DockingPreview] = palette4; @@ -87,24 +129,30 @@ namespace Metal { } void ThemeService::setDarkMode() { - palette0 = ImVec4(10.0f / 255.0f, 10.0f / 255.0f, 10.0f / 255.0f, 1.0f); - palette1 = ImVec4(18.0f / 255.0f, 18.0f / 255.0f, 18.0f / 255.0f, 1.0f); - palette2 = ImVec4(22.0f / 255.0f, 22.0f / 255.0f, 22.0f / 255.0f, 1.0f); - neutralPalette = palette2; - palette3 = ImVec4(35.0f / 255.0f, 35.0f / 255.0f, 35.0f / 255.0f, 1.0f); - palette4 = ImVec4(65.0f / 255.0f, 65.0f / 255.0f, 65.0f / 255.0f, 1.0f); - palette5 = ImVec4(119.0f / 255.0f, 119.0f / 255.0f, 119.0f / 255.0f, 1.0f); - palette6 = ImVec4(224.0f / 255.0f, 224.0f / 255.0f, 224.0f / 255.0f, 1.0f); + if (themeLoaded && themeData.contains("dark")) { + auto& dark = themeData["dark"]; + palette0 = hexToRGBA(dark.value("palette0", "#121212")); + palette1 = hexToRGBA(dark.value("palette1", "#0A0A0A")); + palette2 = hexToRGBA(dark.value("palette2", "#161616")); + palette3 = hexToRGBA(dark.value("palette3", "#232323")); + palette4 = hexToRGBA(dark.value("palette4", "#414141")); + palette5 = hexToRGBA(dark.value("palette5", "#777777")); + palette6 = hexToRGBA(dark.value("palette6", "#E0E0E0")); + neutralPalette = hexToRGBA(dark.value("neutralPalette", "#161616")); + } } void ThemeService::setLightMode() { - palette0 = ImVec4(245.0f / 255.0f, 245.0f / 255.0f, 245.0f / 255.0f, 1.0f); // light gray - palette1 = ImVec4(235.0f / 255.0f, 235.0f / 255.0f, 235.0f / 255.0f, 1.0f); // slightly darker gray - palette2 = ImVec4(225.0f / 255.0f, 225.0f / 255.0f, 225.0f / 255.0f, 1.0f); // medium gray - neutralPalette = palette2; - palette3 = ImVec4(200.0f / 255.0f, 200.0f / 255.0f, 200.0f / 255.0f, 1.0f); // darker gray - palette4 = ImVec4(160.0f / 255.0f, 160.0f / 255.0f, 160.0f / 255.0f, 1.0f); // even darker gray - palette5 = ImVec4(120.0f / 255.0f, 120.0f / 255.0f, 120.0f / 255.0f, 1.0f); // dark gray - palette6 = ImVec4(10.0f / 255.0f, 10.0f / 255.0f, 10.0f / 255.0f, 1.0f); // very dark gray + if (themeLoaded && themeData.contains("light")) { + auto& light = themeData["light"]; + palette0 = hexToRGBA(light.value("palette0", "#EBEBEB")); + palette1 = hexToRGBA(light.value("palette1", "#F5F5F5")); + palette2 = hexToRGBA(light.value("palette2", "#E1E1E1")); + palette3 = hexToRGBA(light.value("palette3", "#C8C8C8")); + palette4 = hexToRGBA(light.value("palette4", "#A0A0A0")); + palette5 = hexToRGBA(light.value("palette5", "#787878")); + palette6 = hexToRGBA(light.value("palette6", "#0A0A0A")); + neutralPalette = hexToRGBA(light.value("neutralPalette", "#E1E1E1")); + } } } // Metal diff --git a/src/editor/service/ThemeService.h b/src/editor/service/ThemeService.h index 4ccf93a6..52953edc 100644 --- a/src/editor/service/ThemeService.h +++ b/src/editor/service/ThemeService.h @@ -2,14 +2,24 @@ #define THEMESERVICE_H #include #include +#include +#include + #include "../../common/IService.h" #include "../../common/ISync.h" - namespace Metal { struct EditorRepository; + class ThemeService final : public IService, public ISync { EditorRepository *editorRepository = nullptr; + nlohmann::json themeData; + bool themeLoaded = false; + + void loadTheme(); + + static ImVec4 hexToRGBA(const std::string &hex); + public: ImVec4 neutralPalette{}; ImVec4 palette0{}; diff --git a/src/main.cpp b/src/main.cpp index 8e452fdc..9202828c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,7 +43,7 @@ #include "engine/EngineContext.h" int main(int, char **) { - std::shared_ptr context = std::make_shared(false); + std::shared_ptr context = std::make_shared(true); // --- ORDER MATTERS context->registerSingleton(context);