├── .Brewfile ├── .appveyor.yml ├── .gitattributes ├── .gitignore ├── .gitmodules ├── .travis.yml ├── LICENSE ├── Media ├── PolyEngine_logo_black.png ├── PolyEngine_logo_black.svg ├── PolyEngine_logo_yellow.png ├── PolyEngine_logo_yellow.svg ├── splash_00.psd └── splash_00.tga ├── PolyEngine ├── CMakeLists.txt ├── CMakeListsCommon.cmake ├── CMakeModules │ ├── cotire.cmake │ └── process_template.cmake ├── Core │ ├── CMakeLists.txt │ └── Src │ │ ├── BaseObject.cpp │ │ ├── BaseObject.hpp │ │ ├── Collections │ │ ├── BTreePrimitives.hpp │ │ ├── Dynarray.hpp │ │ ├── OrderedMap.hpp │ │ ├── PriorityQueue.hpp │ │ ├── Queue.hpp │ │ ├── String.cpp │ │ ├── String.hpp │ │ ├── StringBuilder.cpp │ │ └── StringBuilder.hpp │ │ ├── CorePCH.cpp │ │ ├── CorePCH.hpp │ │ ├── Defines.hpp │ │ ├── Math │ │ ├── AABox.cpp │ │ ├── AABox.hpp │ │ ├── AARect.cpp │ │ ├── AARect.hpp │ │ ├── Angle.hpp │ │ ├── BasicMath.hpp │ │ ├── Color.cpp │ │ ├── Color.hpp │ │ ├── Frustum.cpp │ │ ├── Frustum.hpp │ │ ├── Matrix.cpp │ │ ├── Matrix.hpp │ │ ├── Plane.cpp │ │ ├── Plane.hpp │ │ ├── Quaternion.cpp │ │ ├── Quaternion.hpp │ │ ├── Random.hpp │ │ ├── SimdMath.cpp │ │ ├── SimdMath.hpp │ │ ├── Vector.cpp │ │ ├── Vector.hpp │ │ ├── Vector2f.cpp │ │ ├── Vector2f.hpp │ │ ├── Vector2i.cpp │ │ ├── Vector2i.hpp │ │ ├── Vector3f.cpp │ │ └── Vector3f.hpp │ │ ├── Memory │ │ ├── Allocator.hpp │ │ ├── BinaryBuffer.cpp │ │ ├── BinaryBuffer.hpp │ │ ├── IterablePoolAllocator.hpp │ │ ├── ObjectLifetimeHelpers.hpp │ │ ├── PoolAllocator.hpp │ │ ├── RefCountedBase.cpp │ │ ├── RefCountedBase.hpp │ │ ├── SafePtr.hpp │ │ ├── SafePtrRoot.cpp │ │ ├── SafePtrRoot.hpp │ │ └── UnsafeStorage.hpp │ │ ├── RTTI │ │ ├── CustomTypeTraits.hpp │ │ ├── RTTI.cpp │ │ ├── RTTI.hpp │ │ ├── RTTICast.hpp │ │ ├── RTTIProperty.hpp │ │ ├── RTTISerialization.cpp │ │ ├── RTTISerialization.hpp │ │ ├── RTTITypeInfo.cpp │ │ ├── RTTITypeInfo.hpp │ │ └── RTTITypeInfoImpl.hpp │ │ ├── UniqueID.cpp │ │ ├── UniqueID.hpp │ │ └── Utils │ │ ├── EnumUtils.hpp │ │ ├── FileIO.hpp │ │ ├── HexUtils.hpp │ │ ├── LibraryLoader.hpp │ │ ├── Logger.cpp │ │ ├── Logger.hpp │ │ ├── Optional.hpp │ │ ├── OutputStream.cpp │ │ └── OutputStream.hpp ├── Editor │ ├── CMakeLists.txt │ ├── Src-macOS │ │ ├── MacOSHelper.hpp │ │ └── MacOSHelper.mm │ └── Src │ │ ├── Configs │ │ ├── ProjectConfig.cpp │ │ └── ProjectConfig.hpp │ │ ├── Controllers │ │ ├── IEngineController.hpp │ │ └── Impl │ │ │ ├── EngineController.cpp │ │ │ └── EngineController.hpp │ │ ├── Controls │ │ ├── ControlBase.hpp │ │ ├── CoreControls │ │ │ ├── BoolControl.cpp │ │ │ ├── BoolControl.hpp │ │ │ ├── EnumControl.cpp │ │ │ ├── EnumControl.hpp │ │ │ ├── NumberControl.cpp │ │ │ ├── NumberControl.hpp │ │ │ ├── PlaceHolderControl.cpp │ │ │ ├── PlaceHolderControl.hpp │ │ │ ├── StringControl.cpp │ │ │ ├── StringControl.hpp │ │ │ ├── Vector2Control.cpp │ │ │ ├── Vector2Control.hpp │ │ │ ├── Vector3Control.cpp │ │ │ └── Vector3Control.hpp │ │ ├── EngineControls │ │ │ ├── TransformControl.cpp │ │ │ └── TransformControl.hpp │ │ ├── IControlBase.hpp │ │ └── RTTIRegisteredControl.hpp │ │ ├── Dialogs │ │ └── IDialog.h │ │ ├── EditorApp.cpp │ │ ├── EditorApp.hpp │ │ ├── EditorUi.cpp │ │ ├── EditorUi.hpp │ │ ├── GlobalEventFilter.cpp │ │ ├── GlobalEventFilter.hpp │ │ ├── IEditor.hpp │ │ ├── Main.cpp │ │ ├── Managers │ │ ├── CmdManager.cpp │ │ ├── CmdManager.hpp │ │ ├── CommandManager.cpp │ │ ├── CommandManager.hpp │ │ ├── CommandsImpl.hpp │ │ ├── DockManager.cpp │ │ ├── DockManager.hpp │ │ └── Project │ │ │ ├── Dialogs │ │ │ ├── ComponentDialog.cpp │ │ │ ├── ComponentDialog.hpp │ │ │ ├── CreateProjectDialog.cpp │ │ │ ├── CreateProjectDialog.hpp │ │ │ ├── EntityDialog.cpp │ │ │ ├── EntityDialog.hpp │ │ │ ├── IComponentDialog.hpp │ │ │ ├── IEntityDialog.hpp │ │ │ └── ISceneDialog.hpp │ │ │ ├── InspectorManager.cpp │ │ │ ├── InspectorManager.hpp │ │ │ ├── ProjectManager.cpp │ │ │ └── ProjectManager.hpp │ │ ├── PolyEditorPCH.cpp │ │ ├── PolyEditorPCH.hpp │ │ ├── Systems │ │ ├── Camera │ │ │ ├── EditorCameraMovementComponent.cpp │ │ │ ├── EditorCameraMovementComponent.hpp │ │ │ ├── EditorCameraMovementSystem.cpp │ │ │ └── EditorCameraMovementSystem.hpp │ │ └── Gizmo │ │ │ ├── GizmoSystem.cpp │ │ │ ├── GizmoSystem.hpp │ │ │ ├── GizmoWorldComponent.cpp │ │ │ └── GizmoWorldComponent.hpp │ │ ├── Widgets │ │ ├── Containers │ │ │ ├── SectionContainer.cpp │ │ │ └── SectionContainer.hpp │ │ ├── Inspectors │ │ │ ├── EntityInspectorWidget.cpp │ │ │ ├── EntityInspectorWidget.hpp │ │ │ ├── InspectorWidgetBase.cpp │ │ │ ├── InspectorWidgetBase.hpp │ │ │ ├── RTTIInspectorWidget.cpp │ │ │ ├── RTTIInspectorWidget.hpp │ │ │ ├── ResourceInspectorWidget.cpp │ │ │ ├── ResourceInspectorWidget.hpp │ │ │ ├── ViewportInspectorWidget.cpp │ │ │ ├── ViewportInspectorWidget.hpp │ │ │ ├── WorldInspectorWidget.cpp │ │ │ └── WorldInspectorWidget.hpp │ │ ├── LoggerWidget.cpp │ │ ├── LoggerWidget.hpp │ │ └── PolyWidget.hpp │ │ └── Windows │ │ ├── CustomSDLWindow.cpp │ │ ├── CustomSDLWindow.hpp │ │ ├── PolyDockWindow.cpp │ │ ├── PolyDockWindow.hpp │ │ ├── PolyMainWindow.cpp │ │ ├── PolyMainWindow.hpp │ │ ├── PolyWindow.cpp │ │ └── PolyWindow.hpp ├── Engine │ ├── AssetsPathConfig.json.in │ ├── CMakeLists.txt │ ├── Res │ │ ├── Configs │ │ │ └── DebugConfig.json │ │ ├── Cubemaps │ │ │ ├── miramar │ │ │ │ ├── README.TXT │ │ │ │ ├── miramar_bk.jpg │ │ │ │ ├── miramar_dn.jpg │ │ │ │ ├── miramar_ft.jpg │ │ │ │ ├── miramar_lt.jpg │ │ │ │ ├── miramar_rt.jpg │ │ │ │ └── miramar_up.jpg │ │ │ └── stormydays │ │ │ │ ├── README.TXT │ │ │ │ ├── stormydays_bk.jpg │ │ │ │ ├── stormydays_dn.jpg │ │ │ │ ├── stormydays_ft.jpg │ │ │ │ ├── stormydays_lt.jpg │ │ │ │ ├── stormydays_rt.jpg │ │ │ │ └── stormydays_up.jpg │ │ ├── Fonts │ │ │ └── Raleway │ │ │ │ ├── OFL.txt │ │ │ │ ├── Raleway-Bold.ttf │ │ │ │ ├── Raleway-ExtraBold.ttf │ │ │ │ ├── Raleway-ExtraLight.ttf │ │ │ │ ├── Raleway-Heavy.ttf │ │ │ │ ├── Raleway-Light.ttf │ │ │ │ ├── Raleway-Medium.ttf │ │ │ │ ├── Raleway-Regular.ttf │ │ │ │ ├── Raleway-SemiBold.ttf │ │ │ │ └── Raleway-Thin.ttf │ │ ├── HDR │ │ │ └── HDR.hdr │ │ ├── Models │ │ │ ├── player.mtl │ │ │ └── player.obj │ │ ├── Shaders │ │ │ ├── Hoskings_MysteryMountains.frag.glsl │ │ │ ├── bg.frag.glsl │ │ │ ├── bgAlienc.frag.glsl │ │ │ ├── bgFractal.frag.glsl │ │ │ ├── bgLight.frag.glsl │ │ │ ├── bgSea.frag.glsl │ │ │ ├── blinn-phong.frag.glsl │ │ │ ├── blinn-phong.vert.glsl │ │ │ ├── bloom_pass_apply.frag.glsl │ │ │ ├── bloom_pass_blur.frag.glsl │ │ │ ├── bloom_pass_bright.frag.glsl │ │ │ ├── cubemapIrradiance.frag.glsl │ │ │ ├── cubemapIrradiance.vert.glsl │ │ │ ├── debug.frag.glsl │ │ │ ├── debug.vert.glsl │ │ │ ├── debugLightAccum.frag.glsl │ │ │ ├── debugLightAccum.vert.glsl │ │ │ ├── debugNormals.frag.glsl │ │ │ ├── debugNormals.geom.glsl │ │ │ ├── debugNormals.vert.glsl │ │ │ ├── debugQuadDepthPrepass.frag.glsl │ │ │ ├── debugQuadDepthPrepass.vert.glsl │ │ │ ├── debugQuadLightCulling.frag.glsl │ │ │ ├── debugQuadLightCulling.vert.glsl │ │ │ ├── depth.frag.glsl │ │ │ ├── depth.vert.glsl │ │ │ ├── dof_pass_apply.frag.glsl │ │ │ ├── dof_pass_bokeh.frag.glsl │ │ │ ├── equiHdr.frag.glsl │ │ │ ├── equiHdr.vert.glsl │ │ │ ├── equiToCubemap.frag.glsl │ │ │ ├── equiToCubemap.vert.glsl │ │ │ ├── evsm.blur.frag.glsl │ │ │ ├── evsm.inc.glsl │ │ │ ├── evsm.resolve.frag.glsl │ │ │ ├── fg.frag.glsl │ │ │ ├── fgLight.frag.glsl │ │ │ ├── fxaa.frag.glsl │ │ │ ├── fxaa.inc.glsl │ │ │ ├── gamma.frag.glsl │ │ │ ├── hdr.frag.glsl │ │ │ ├── hdr.vert.glsl │ │ │ ├── instanced.frag.glsl │ │ │ ├── instanced.vert.glsl │ │ │ ├── integrateBRDF.frag.glsl │ │ │ ├── iq_clouds.frag.glsl │ │ │ ├── lightAccumulation.frag.glsl │ │ │ ├── lightAccumulation.vert.glsl │ │ │ ├── lightAccumulationTexDebug.frag.glsl │ │ │ ├── lightCulling.comp.glsl │ │ │ ├── linearizeDepth.frag.glsl │ │ │ ├── motionblur.frag.glsl │ │ │ ├── normals.frag.glsl │ │ │ ├── normals.vert.glsl │ │ │ ├── pass.frag.glsl │ │ │ ├── pcf.inc.glsl │ │ │ ├── postprocessCommon.vert.glsl │ │ │ ├── prefilterCubemap.frag.glsl │ │ │ ├── prefilterCubemap.vert.glsl │ │ │ ├── shadowMap.frag.glsl │ │ │ ├── shadowMap.vert.glsl │ │ │ ├── skybox.frag.glsl │ │ │ ├── skybox.vert.glsl │ │ │ ├── spritesheet.frag.glsl │ │ │ ├── spritesheet.vert.glsl │ │ │ ├── test.comp.glsl │ │ │ ├── text2D.frag.glsl │ │ │ ├── text2D.vert.glsl │ │ │ ├── translucent.frag.glsl │ │ │ ├── translucent.vert.glsl │ │ │ ├── unlit.frag.glsl │ │ │ ├── unlit.vert.glsl │ │ │ └── vinette.frag.glsl │ │ └── Textures │ │ │ ├── RGBANoise256x256.png │ │ │ ├── splash_00.png │ │ │ └── splash_00.tga │ └── Src │ │ ├── AI │ │ ├── PathfindingComponent.cpp │ │ ├── PathfindingComponent.hpp │ │ ├── PathfindingSystem.cpp │ │ └── PathfindingSystem.hpp │ │ ├── Audio │ │ ├── OpenALDevice.cpp │ │ ├── OpenALDevice.hpp │ │ ├── SoundEmitterComponent.cpp │ │ ├── SoundEmitterComponent.hpp │ │ ├── SoundListenerComponent.cpp │ │ ├── SoundListenerComponent.hpp │ │ ├── SoundSystem.cpp │ │ ├── SoundSystem.hpp │ │ ├── SoundWorldComponent.cpp │ │ └── SoundWorldComponent.hpp │ │ ├── Configs │ │ ├── AssetsPathConfig.cpp │ │ ├── AssetsPathConfig.hpp │ │ ├── ConfigBase.cpp │ │ ├── ConfigBase.hpp │ │ ├── DebugConfig.cpp │ │ └── DebugConfig.hpp │ │ ├── Debugging │ │ ├── DebugDrawComponents.cpp │ │ ├── DebugDrawComponents.hpp │ │ ├── DebugDrawSystem.cpp │ │ ├── DebugDrawSystem.hpp │ │ ├── DebugWorldComponent.cpp │ │ ├── DebugWorldComponent.hpp │ │ ├── FPSSystem.cpp │ │ └── FPSSystem.hpp │ │ ├── ECS │ │ ├── ComponentBase.cpp │ │ ├── ComponentBase.hpp │ │ ├── ComponentIDGenerator.cpp │ │ ├── ComponentIDGenerator.hpp │ │ ├── ComponentIDGeneratorImpl.hpp │ │ ├── DeferredTaskBase.hpp │ │ ├── DeferredTaskImplementation.hpp │ │ ├── DeferredTaskSystem.cpp │ │ ├── DeferredTaskSystem.hpp │ │ ├── DeferredTaskWorldComponent.cpp │ │ ├── DeferredTaskWorldComponent.hpp │ │ ├── Entity.cpp │ │ ├── Entity.hpp │ │ ├── EntityTransform.cpp │ │ ├── EntityTransform.hpp │ │ ├── ISystem.hpp │ │ ├── LambdaSystem.hpp │ │ ├── Scene.cpp │ │ └── Scene.hpp │ │ ├── Editor │ │ └── IEditor.hpp │ │ ├── Engine.cpp │ │ ├── Engine.hpp │ │ ├── EnginePCH.cpp │ │ ├── EnginePCH.hpp │ │ ├── Imgui │ │ ├── ImguiSystem.cpp │ │ └── ImguiSystem.hpp │ │ ├── Input │ │ ├── InputQueue.hpp │ │ ├── InputSystem.cpp │ │ ├── InputSystem.hpp │ │ ├── InputWorldComponent.cpp │ │ ├── InputWorldComponent.hpp │ │ ├── KeyBindings.hpp │ │ └── OutputQueue.hpp │ │ ├── Movement │ │ ├── FreeFloatMovementComponent.cpp │ │ ├── FreeFloatMovementComponent.hpp │ │ ├── MovementSystem.cpp │ │ └── MovementSystem.hpp │ │ ├── Physics2D │ │ ├── Physics2DColliders.cpp │ │ ├── Physics2DColliders.hpp │ │ ├── Physics2DSystem.cpp │ │ ├── Physics2DSystem.hpp │ │ ├── Physics2DWorldComponent.cpp │ │ ├── Physics2DWorldComponent.hpp │ │ ├── RigidBody2DImpl.hpp │ │ ├── Rigidbody2DComponent.cpp │ │ └── Rigidbody2DComponent.hpp │ │ ├── Physics3D │ │ ├── Collider3DComponent.cpp │ │ ├── Collider3DComponent.hpp │ │ ├── Collider3DImpl.hpp │ │ ├── Physics3DShapes.cpp │ │ ├── Physics3DShapes.hpp │ │ ├── Physics3DShapesImpl.hpp │ │ ├── Physics3DSystem.cpp │ │ ├── Physics3DSystem.hpp │ │ ├── Physics3DWorldComponent.cpp │ │ ├── Physics3DWorldComponent.hpp │ │ ├── Rigidbody3DComponent.cpp │ │ ├── Rigidbody3DComponent.hpp │ │ └── Rigidbody3DImpl.hpp │ │ ├── Rendering │ │ ├── Camera │ │ │ ├── CameraComponent.cpp │ │ │ ├── CameraComponent.hpp │ │ │ ├── CameraSystem.cpp │ │ │ └── CameraSystem.hpp │ │ ├── IRenderingDevice.hpp │ │ ├── Lighting │ │ │ ├── LightSourceComponent.cpp │ │ │ └── LightSourceComponent.hpp │ │ ├── MeshRenderingComponent.cpp │ │ ├── MeshRenderingComponent.hpp │ │ ├── Particles │ │ │ ├── ParticleComponent.cpp │ │ │ ├── ParticleComponent.hpp │ │ │ ├── ParticleEmitter.cpp │ │ │ ├── ParticleEmitter.hpp │ │ │ ├── ParticleUpdateSystem.cpp │ │ │ └── ParticleUpdateSystem.hpp │ │ ├── PostprocessSettingsComponent.cpp │ │ ├── PostprocessSettingsComponent.hpp │ │ ├── RenderingSettingsComponent.cpp │ │ ├── RenderingSettingsComponent.hpp │ │ ├── RenderingSystem.cpp │ │ ├── RenderingSystem.hpp │ │ ├── SkyboxWorldComponent.cpp │ │ ├── SkyboxWorldComponent.hpp │ │ ├── SpritesheetComponent.cpp │ │ ├── SpritesheetComponent.hpp │ │ ├── Viewport.hpp │ │ ├── ViewportWorldComponent.cpp │ │ └── ViewportWorldComponent.hpp │ │ ├── Resources │ │ ├── CubemapResource.cpp │ │ ├── CubemapResource.hpp │ │ ├── FontResource.cpp │ │ ├── FontResource.hpp │ │ ├── Mesh.cpp │ │ ├── Mesh.hpp │ │ ├── MeshResource.cpp │ │ ├── MeshResource.hpp │ │ ├── ResourceBase.hpp │ │ ├── ResourceManager.cpp │ │ ├── ResourceManager.hpp │ │ ├── SoundResource.cpp │ │ ├── SoundResource.hpp │ │ ├── TextureResource.cpp │ │ └── TextureResource.hpp │ │ ├── Time │ │ ├── TimeSystem.cpp │ │ ├── TimeSystem.hpp │ │ ├── TimeWorldComponent.cpp │ │ ├── TimeWorldComponent.hpp │ │ └── Timer.hpp │ │ └── UI │ │ ├── ScreenSpaceTextComponent.cpp │ │ ├── ScreenSpaceTextComponent.hpp │ │ ├── Text2D.cpp │ │ └── Text2D.hpp ├── RenderingDevice │ └── OpenGL │ │ ├── CMakeLists.txt │ │ └── Src │ │ ├── Common │ │ ├── DebugRenderingBuffers.cpp │ │ ├── DebugRenderingBuffers.hpp │ │ ├── GLUtils.hpp │ │ ├── PrimitiveCube.cpp │ │ ├── PrimitiveCube.hpp │ │ ├── PrimitiveQuad.cpp │ │ └── PrimitiveQuad.hpp │ │ ├── ForwardRenderer.cpp │ │ ├── ForwardRenderer.hpp │ │ ├── GLRenderingDevice.cpp │ │ ├── GLRenderingDevice.hpp │ │ ├── GLWorldRendering.cpp │ │ ├── IRendererInterface.cpp │ │ ├── IRendererInterface.hpp │ │ ├── Pipeline │ │ ├── BlinnPhongRenderingPass.cpp │ │ ├── BlinnPhongRenderingPass.hpp │ │ ├── DebugNormalsRenderingPass.cpp │ │ ├── DebugNormalsRenderingPass.hpp │ │ ├── DebugNormalsWireframeRenderingPass.cpp │ │ ├── DebugNormalsWireframeRenderingPass.hpp │ │ ├── DebugRenderingPass.cpp │ │ ├── DebugRenderingPass.hpp │ │ ├── EnvCapture.cpp │ │ ├── EnvCapture.hpp │ │ ├── ParticlesRenderingPass.cpp │ │ ├── ParticlesRenderingPass.hpp │ │ ├── PostprocessRenderingPass.cpp │ │ ├── PostprocessRenderingPass.hpp │ │ ├── RenderingPassBase.cpp │ │ ├── RenderingPassBase.hpp │ │ ├── ShadowMapPass.cpp │ │ ├── ShadowMapPass.hpp │ │ ├── SkyboxRenderingPass.cpp │ │ ├── SkyboxRenderingPass.hpp │ │ ├── SpritesheetRenderingPass.cpp │ │ ├── SpritesheetRenderingPass.hpp │ │ ├── Text2DRenderingPass.cpp │ │ ├── Text2DRenderingPass.hpp │ │ ├── TransparentRenderingPass.cpp │ │ ├── TransparentRenderingPass.hpp │ │ ├── UnlitRenderingPass.cpp │ │ └── UnlitRenderingPass.hpp │ │ ├── PolyRenderingDeviceGLPCH.cpp │ │ ├── PolyRenderingDeviceGLPCH.hpp │ │ ├── Proxy │ │ ├── GLCubemapDeviceProxy.cpp │ │ ├── GLCubemapDeviceProxy.hpp │ │ ├── GLMeshDeviceProxy.cpp │ │ ├── GLMeshDeviceProxy.hpp │ │ ├── GLParticleDeviceProxy.cpp │ │ ├── GLParticleDeviceProxy.hpp │ │ ├── GLShaderProgram.cpp │ │ ├── GLShaderProgram.hpp │ │ ├── GLTextFieldBufferDeviceProxy.cpp │ │ ├── GLTextFieldBufferDeviceProxy.hpp │ │ ├── GLTextureDeviceProxy.cpp │ │ ├── GLTextureDeviceProxy.hpp │ │ ├── imgui_impl_opengl3.cpp │ │ └── imgui_impl_opengl3.h │ │ ├── TiledForwardRenderer.cpp │ │ └── TiledForwardRenderer.hpp ├── Scripts │ ├── Docker │ │ ├── ubuntu18-base.dockerfile │ │ ├── ubuntu18-clang5.dockerfile │ │ └── ubuntu18-gcc8.dockerfile │ ├── Game.cpp.in │ ├── Game.hpp.in │ ├── InitializeSubmodules.py │ ├── Proj-CMakeLists.txt.in │ ├── ProjectTool.py │ ├── RunDocker.py │ └── Sln-CMakeLists.txt.in ├── Standalone │ ├── CMakeLists.txt │ └── Src │ │ └── Main.cpp ├── ThirdParty │ ├── .gitignore │ ├── CMakeLists.txt │ ├── cmake-modules │ │ ├── assimp.cmake │ │ ├── box2d.cmake │ │ ├── bullet3.cmake │ │ ├── catch2.cmake │ │ ├── freetype2.cmake │ │ ├── galogen.cmake │ │ ├── imgui.cmake │ │ ├── khronos.cmake │ │ ├── ogg.cmake │ │ ├── openal-soft.cmake │ │ ├── rapidjson.cmake │ │ ├── sdl2.cmake │ │ ├── stb.cmake │ │ └── vorbis.cmake │ ├── khronos │ │ ├── gl.xml │ │ └── khrplatform.h │ └── patches │ │ ├── imgui.patch │ │ └── openal-soft.patch └── UnitTests │ ├── CMakeLists.txt │ └── Src │ ├── AABoxTests.cpp │ ├── AARectTests.cpp │ ├── AllocatorTests.cpp │ ├── AngleTests.cpp │ ├── BasicMathTests.cpp │ ├── ComponentIterationTests.cpp │ ├── ConfigTests.cpp │ ├── CoordinateSystemTests.cpp │ ├── DynarrayTests.cpp │ ├── EntityTransformTests.cpp │ ├── EnumUtilsTests.cpp │ ├── FrustumTests.cpp │ ├── HexUtilsTests.cpp │ ├── MatrixTests.cpp │ ├── OptionalTests.cpp │ ├── OrderedMapTests.cpp │ ├── PlaneTests.cpp │ ├── PriorityQueueTests.cpp │ ├── QuaternionTests.cpp │ ├── QueueTests.cpp │ ├── RTTITests.cpp │ ├── RandomTests.cpp │ ├── ResourceManagerTests.cpp │ ├── SafePtrTests.cpp │ ├── SceneSerializationTests.cpp │ ├── StringBuilderTests.cpp │ ├── StringTests.cpp │ ├── UniqueIDTests.cpp │ ├── UnsafeStorageTests.cpp │ ├── Vector2fTests.cpp │ ├── Vector2iTests.cpp │ ├── VectorTests.cpp │ └── main.cpp └── README.md /.Brewfile: -------------------------------------------------------------------------------- 1 | brew 'pkgconfig' 2 | brew 'qt5' 3 | brew 'cmake' -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set. 2 | * text=auto 3 | 4 | # Explicitly declare text files you want to always be normalized and converted 5 | # to native line endings on checkout. 6 | *.c text diff=cpp 7 | *.h text diff=cpp 8 | *.cpp text diff=cpp 9 | *.hpp text diff=cpp 10 | *.txt text 11 | 12 | # Declare files that will always have CRLF line endings on checkout. 13 | *.sln text eol=crlf 14 | *.vcxproj text eol=crlf 15 | *.vcxproj.filters text eol=crlf 16 | 17 | # Denote all files that are truly binary and should not be modified. 18 | *.dll binary 19 | *.lib binary 20 | *.lib binary 21 | 22 | # Vendor specific folders 23 | PolyEngine/ThirdParty/* linguist-vendored -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # User-specific files 2 | *.suo 3 | *.user 4 | *.userosscache 5 | *.sln.docstates 6 | 7 | # Engine specific files 8 | console.log 9 | # shader content dumps for debuging 10 | *.dump 11 | 12 | # Engine local configurations 13 | AssetsPathConfig.json 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Dd]ist/ 25 | [Oo]bj/ 26 | [Ll]og/ 27 | [Bb]uild/ 28 | [Bb]uild*/ 29 | cmake-build-* 30 | 31 | # Windows specific stuff 32 | [Tt]humbs.db 33 | 34 | # Qt 5 generated files 35 | moc_*.cpp 36 | qrc_*.cpp 37 | ui_*.h 38 | 39 | # Visual Studio 2015 cache/options directory 40 | .vs/ 41 | 42 | # VS Code directory 43 | .vscode/ 44 | 45 | # CLion project data 46 | .idea/ 47 | 48 | # Visual C++ cache files 49 | ipch/ 50 | *.aps 51 | *.ncb 52 | *.opendb 53 | *.opensdf 54 | *.sdf 55 | *.cachefile 56 | *.VC.db 57 | *.VC.VC.opendb 58 | 59 | # macOS stuff 60 | .DS_Store 61 | 62 | # Xcode stuff 63 | *.pbxuser 64 | *.mode1v3 65 | *.mode2v3 66 | *.perspectivev3 67 | xcuserdata/ 68 | *.xccheckout 69 | 70 | # Vim stuff 71 | *.stackdump 72 | 73 | # Exculdes from ignore 74 | !**/ThirdParty/** 75 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 KNTGPolygon 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Media/PolyEngine_logo_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/Media/PolyEngine_logo_black.png -------------------------------------------------------------------------------- /Media/PolyEngine_logo_yellow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/Media/PolyEngine_logo_yellow.png -------------------------------------------------------------------------------- /Media/splash_00.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/Media/splash_00.psd -------------------------------------------------------------------------------- /Media/splash_00.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/Media/splash_00.tga -------------------------------------------------------------------------------- /PolyEngine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | project(PolyEngine VERSION 0.1.2 LANGUAGES CXX C) #note(vuko): without C older CMake versions fail to process FindX11 the first time 3 | 4 | ## 5 | # Initial setup: C++ standard version, build types, CMake modules 6 | ## 7 | set(ENGINE_ROOT_DIR ${CMAKE_SOURCE_DIR}) 8 | set(DIST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Dist") 9 | 10 | include(${ENGINE_ROOT_DIR}/CMakeListsCommon.cmake) 11 | 12 | ## 13 | # Finally, meat and potatoes 14 | ## 15 | add_subdirectory(Core) 16 | add_subdirectory(Engine) 17 | add_subdirectory(RenderingDevice/OpenGL) 18 | add_subdirectory(Editor) 19 | add_subdirectory(Standalone) 20 | enable_testing() 21 | add_subdirectory(UnitTests) 22 | 23 | ## 24 | # Doxygen 25 | ## 26 | if(GENERATE_DOXYGEN) 27 | find_package(Doxygen) 28 | if(DOXYGEN_FOUND AND false) #TODO(vuko): reenable after Doxyfile.in gets written 29 | set(DOC_DIR ${PROJECT_BINARY_DIR}/doc) 30 | configure_file(${PROJECT_SOURCE_DIR}/Doxygen/Doxyfile.in ${DOC_DIR}/Doxyfile @ONLY) 31 | add_custom_target(docs 32 | COMMAND ${DOXYGEN_EXECUTABLE} 33 | WORKING_DIRECTORY ${DOC_DIR} 34 | COMMENT "Building doxygen documentation" 35 | SOURCES ${PROJECT_SOURCE_DIR}/Doxygen/Doxyfile.in 36 | ) 37 | source_group("" FILES ${PROJECT_SOURCE_DIR}/Docs/Doxyfile.in) 38 | endif() 39 | endif() -------------------------------------------------------------------------------- /PolyEngine/CMakeModules/process_template.cmake: -------------------------------------------------------------------------------- 1 | configure_file("${INPUT_FILE}" "${OUTPUT_FILE}" @ONLY) -------------------------------------------------------------------------------- /PolyEngine/Core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(POLYCORE_INCLUDE ${CMAKE_CURRENT_LIST_DIR}/Src) 2 | 3 | file(GLOB_RECURSE POLYCORE_SRCS RELATIVE ${CMAKE_CURRENT_LIST_DIR} 4 | ${POLYCORE_INCLUDE}/*.cpp 5 | ${POLYCORE_INCLUDE}/*.hpp 6 | ${POLYCORE_INCLUDE}/*.h) 7 | GenerateSourceGoups("${POLYCORE_SRCS}") 8 | 9 | add_library(${CORE_TARGET} SHARED ${POLYCORE_SRCS}) 10 | target_compile_options(${CORE_TARGET} PRIVATE $<$:${SIMD_FLAGS}>) 11 | target_compile_definitions(${CORE_TARGET} PRIVATE _CORE DISABLE_SIMD=$>) 12 | target_include_directories(${CORE_TARGET} PUBLIC ${POLYCORE_INCLUDE} PRIVATE ${RapidJSON_INCLUDE_DIRS}) 13 | 14 | set_target_properties(${CORE_TARGET} PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "${CMAKE_CURRENT_LIST_DIR}/Src/CorePCH.hpp") 15 | set_target_properties(${CORE_TARGET} PROPERTIES FOLDER "Engine" ) 16 | 17 | cotire(${CORE_TARGET}) -------------------------------------------------------------------------------- /PolyEngine/Core/Src/BaseObject.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | 7 | void * Poly::CustomAlocatedObject::operator new(size_t size) 8 | { 9 | //TODO use custom allocator 10 | void* mem = AllocateSlab(size); 11 | HEAVY_ASSERTE(mem, "Couldn't allocate memory!"); 12 | return mem; 13 | } 14 | 15 | void Poly::CustomAlocatedObject::operator delete(void * ptr) 16 | { 17 | //TODO use custom allocator 18 | HEAVY_ASSERTE(ptr, ""); 19 | Deallocate(ptr); 20 | } 21 | -------------------------------------------------------------------------------- /PolyEngine/Core/Src/Collections/StringBuilder.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | using namespace Poly; 6 | 7 | //---------------------------------------------------------------------------- 8 | StringBuilder& StringBuilder::Append(const char* str, const size_t length) 9 | { 10 | Buffer.Reserve(Buffer.GetSize() + length); 11 | for (size_t i = 0; i < length; ++i) 12 | Append(str[i]); 13 | return *this; 14 | } 15 | 16 | //---------------------------------------------------------------------------- 17 | StringBuilder& StringBuilder::Append(f32 val, size_t precission) 18 | { 19 | if (precission != DEFAULT_FLT_PRECISION) 20 | { 21 | CharBuffer precissionBuffer = CreateBufferFromFormat(precission, "%%." "%u" "f"); 22 | FillBufferWithFormat(val, precissionBuffer.Data.get()); 23 | } 24 | else 25 | { 26 | FillBufferWithFormat(val, "%f"); 27 | } 28 | 29 | return *this; 30 | } 31 | 32 | //---------------------------------------------------------------------------- 33 | StringBuilder& StringBuilder::Append(f64 val, size_t precission) 34 | { 35 | if (precission != DEFAULT_FLT_PRECISION) 36 | { 37 | CharBuffer precissionBuffer = CreateBufferFromFormat(precission, "%%." "%u" "f"); 38 | FillBufferWithFormat(val, precissionBuffer.Data.get()); 39 | } 40 | else 41 | { 42 | FillBufferWithFormat(val, "%f"); 43 | } 44 | 45 | return *this; 46 | } -------------------------------------------------------------------------------- /PolyEngine/Core/Src/CorePCH.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /PolyEngine/Core/Src/CorePCH.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // rapidjson 6 | SILENCE_GCC_WARNING(-Wclass-memaccess, "Rapidjson has no release containing fix to this issue (01.09.18).") 7 | #include 8 | #include 9 | #include 10 | UNSILENCE_GCC_WARNING() -------------------------------------------------------------------------------- /PolyEngine/Core/Src/Math/Color.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | using namespace Poly; 6 | 7 | const Color Color::WHITE = Color(1.0f, 1.0f, 1.0f); 8 | const Color Color::BLACK = Color(0.0f, 0.0f, 0.0f); 9 | const Color Color::RED = Color(1.0f, 0.0f, 0.0f); 10 | const Color Color::GREEN = Color(0.0f, 1.0f, 0.0f); 11 | const Color Color::BLUE = Color(0.0f, 0.0f, 1.0f); 12 | 13 | namespace Poly { 14 | std::ostream& operator<< (std::ostream& stream, const Color& color) 15 | { 16 | return stream << "Color[ " << color.R << " " << color.G << " " << color.B << " " << color.A << " ]"; 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /PolyEngine/Core/Src/Math/Plane.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | using namespace Poly; 6 | 7 | Plane::eObjectLocation Plane::GetAABoxLocation(const AABox& box) const 8 | { 9 | auto vertices = box.GetVertices(); 10 | 11 | eObjectLocation guessedLocation = GetPointLocation(vertices[0]); 12 | for (Vector vert : vertices) 13 | { 14 | eObjectLocation loc = GetPointLocation(vert); 15 | 16 | if (loc == eObjectLocation::INTERSECTS || loc != guessedLocation) 17 | return eObjectLocation::INTERSECTS; 18 | } 19 | 20 | // guess was ok 21 | return guessedLocation; 22 | } 23 | 24 | Plane::eObjectLocation Plane::GetPointLocation(const Vector& point) const 25 | { 26 | const float dot = (point - Point).Dot(Normal); 27 | 28 | if (dot > 0) 29 | return eObjectLocation::FRONT; 30 | else if (dot < 0) 31 | return eObjectLocation::BEHIND; 32 | else 33 | return eObjectLocation::INTERSECTS; 34 | } 35 | 36 | //------------------------------------------------------------------------------ 37 | namespace Poly { 38 | std::ostream & operator<<(std::ostream& stream, const Plane& rect) 39 | { 40 | return stream << "Plane[Point: " << rect.Point << " Normal: " << rect.Normal << " ]"; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /PolyEngine/Core/Src/Math/Plane.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace Poly { 10 | /// Class representing axis aligned box. 11 | class CORE_DLLEXPORT Plane final : public BaseObjectLiteralType<> 12 | { 13 | public: 14 | Plane() : Plane(Vector::ZERO, Vector::UNIT_Z) {} 15 | Plane(const Vector& point, const Vector& normal) 16 | : Point(point), Normal(normal) 17 | { 18 | HEAVY_ASSERTE(Cmpf(Normal.LengthSquared(), 1.0f), "Versor is not normalized!"); 19 | } 20 | 21 | enum class eObjectLocation 22 | { 23 | FRONT, 24 | INTERSECTS, 25 | BEHIND, 26 | _COUNT 27 | }; 28 | 29 | eObjectLocation GetAABoxLocation(const AABox& point) const; 30 | eObjectLocation GetPointLocation(const Vector& point) const; 31 | 32 | const Vector& GetPoint() const { return Point; } 33 | const Vector& GetNormal() const { return Normal; } 34 | 35 | CORE_DLLEXPORT friend std::ostream& operator<< (std::ostream& stream, const Plane& color); 36 | private: 37 | Vector Point; 38 | Vector Normal; 39 | }; 40 | } -------------------------------------------------------------------------------- /PolyEngine/Core/Src/Math/Random.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace Poly { 8 | 9 | inline void RandomSetSeed(int value) 10 | { 11 | srand(value); 12 | } 13 | 14 | inline float Random() 15 | { 16 | float rnd = static_cast (rand()) / static_cast (RAND_MAX); 17 | return rnd - floor(rnd); 18 | } 19 | 20 | template inline T RandomRange(const T& min, const T& max) 21 | { 22 | float rnd = Random(); 23 | return Lerp(min, max, rnd); 24 | } 25 | 26 | inline Vector RandomVectorRange(float min, float max) 27 | { 28 | return Vector(RandomRange(min, max), RandomRange(min, max), RandomRange(min, max)); 29 | } 30 | 31 | inline Vector RandomVector() 32 | { 33 | return RandomVectorRange(0.0f, 1.0f); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /PolyEngine/Core/Src/Math/SimdMath.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | using namespace Poly; 7 | 8 | #if !DISABLE_SIMD 9 | 10 | //------------------------------------------------------------------------------ 11 | __m128 _mm_dot_ps(__m128 a, __m128 b) { 12 | __m128 mult = _mm_mul_ps(a, b); //multiply x,y,z 13 | __m128 tmp_y = _mm_shuffle_ps(mult, mult, _MM_SHUFFLE(0, 0, 0, 1)); // get y to first position 14 | __m128 tmp_x = _mm_shuffle_ps(mult, mult, _MM_SHUFFLE(0, 0, 0, 2)); // get z to first position 15 | __m128 sum = _mm_add_ps(mult, _mm_add_ps(tmp_x, tmp_y)); // sum x, y and z 16 | return _mm_shuffle_ps(sum, sum, _MM_SHUFFLE(0, 0, 0, 0)); 17 | } 18 | 19 | //------------------------------------------------------------------------------ 20 | __m128 _mm_cmpf_ps(__m128 a, __m128 b) { 21 | static const __m128 simd_eps = {CMPF_EPS, CMPF_EPS, CMPF_EPS, CMPF_EPS}; 22 | static const __m128 simd_eps_neg = {-CMPF_EPS, -CMPF_EPS, -CMPF_EPS, -CMPF_EPS}; 23 | __m128 sub = _mm_sub_ps(a, b); 24 | __m128 lower = _mm_cmplt_ps(sub, simd_eps); 25 | __m128 greater = _mm_cmpgt_ps(sub, simd_eps_neg); 26 | return _mm_and_ps(lower, greater); 27 | } 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /PolyEngine/Core/Src/Math/SimdMath.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | 6 | #if !DISABLE_SIMD 7 | 8 | #include 9 | 10 | /// SIMD intristic dot product of 3D vector. 11 | __m128 _mm_dot_ps(__m128 a, __m128 b); 12 | 13 | /// SIMD intristic compare two floats with given precission. 14 | __m128 _mm_cmpf_ps(__m128 a, __m128 b); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /PolyEngine/Core/Src/Math/Vector3f.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /PolyEngine/Core/Src/Math/Vector3f.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace Poly 7 | { 8 | /// Class representing 3D float vector. 9 | class CORE_DLLEXPORT Vector3f final : public BaseObjectLiteralType<> 10 | { 11 | public: 12 | /// Creates zero vector. 13 | explicit constexpr Vector3f() : X(0.f), Y(0.f), Z(0.f) {} 14 | 15 | /// Creates vector from float values. 16 | explicit constexpr Vector3f(float x, float y, float z) : X(x), Y(y), Z(z) {} 17 | 18 | explicit constexpr Vector3f(Vector v) : X(v.X), Y(v.Y), Z(v.Z) {} 19 | 20 | Vector3f(const Vector3f& rhs) : X(rhs.X), Y(rhs.Y), Z(rhs.Z) {} 21 | 22 | /// Helper method for getting a copy of Vector3f as Vector. 23 | Vector GetVector() const { return Vector(X, Y, Z); } 24 | 25 | // This structure allows to access vector elements by index or name. 26 | float X = 0.0f, Y = 0.0f, Z = 0.0f; 27 | }; 28 | } -------------------------------------------------------------------------------- /PolyEngine/Core/Src/Memory/Allocator.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Poly 6 | { 7 | namespace Impl 8 | { 9 | constexpr size_t MEM_ALIGNMENT = 16; 10 | } 11 | 12 | template 13 | T* Allocate(size_t count) 14 | { 15 | using AlignedT = typename std::aligned_storage::type; 16 | auto fresh = new(std::nothrow) AlignedT[count]; 17 | return reinterpret_cast(fresh); 18 | } 19 | 20 | inline char* AllocateSlab(size_t size) { return Allocate(size); } 21 | 22 | 23 | template void Deallocate(T* memory) 24 | { 25 | using AlignedT = typename std::aligned_storage::type; 26 | delete[] reinterpret_cast(memory); 27 | } 28 | 29 | inline void Deallocate(void* memory) { Deallocate(static_cast(memory)); } 30 | } //namespace Poly 31 | -------------------------------------------------------------------------------- /PolyEngine/Core/Src/Memory/BinaryBuffer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | using namespace Poly; 7 | 8 | BinaryBuffer::BinaryBuffer(size_t size) 9 | : Size(size) 10 | { 11 | HEAVY_ASSERTE(size > 0, "Creating buffer with size == 0!"); 12 | Data = AllocateSlab(size); 13 | HEAVY_ASSERTE(Data, "Couldn't allocate memory!"); 14 | } 15 | 16 | BinaryBuffer::~BinaryBuffer() 17 | { 18 | if(Data) 19 | Deallocate(Data); 20 | } 21 | 22 | BinaryBuffer& Poly::BinaryBuffer::operator=(const BinaryBuffer& rhs) 23 | { 24 | if(Data) 25 | Deallocate(Data); 26 | Data = AllocateSlab(rhs.Size); 27 | memcpy(Data, rhs.Data, rhs.Size); 28 | Size = rhs.Size; 29 | return *this; 30 | } 31 | 32 | BinaryBuffer& Poly::BinaryBuffer::operator=(BinaryBuffer&& rhs) 33 | { 34 | if (Data) 35 | Deallocate(Data); 36 | Data = rhs.Data; 37 | Size = rhs.Size; 38 | rhs.Data = nullptr; 39 | rhs.Size = 0; 40 | return *this; 41 | } 42 | -------------------------------------------------------------------------------- /PolyEngine/Core/Src/Memory/BinaryBuffer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace Poly 7 | { 8 | 9 | class CORE_DLLEXPORT BinaryBuffer final : public BaseObjectLiteralType<> 10 | { 11 | public: 12 | BinaryBuffer(size_t size); 13 | ~BinaryBuffer(); 14 | 15 | BinaryBuffer(const BinaryBuffer& rhs) { *this = rhs; } 16 | BinaryBuffer(BinaryBuffer&& rhs) { *this = std::move(rhs); } 17 | 18 | BinaryBuffer& operator=(const BinaryBuffer& rhs); 19 | BinaryBuffer& operator=(BinaryBuffer&& rhs); 20 | 21 | char* GetData() { return Data; } 22 | const char* GetData() const { return Data; } 23 | size_t GetSize() const { return Size; } 24 | 25 | private: 26 | char* Data; 27 | size_t Size; 28 | }; 29 | 30 | } // namespace Poly -------------------------------------------------------------------------------- /PolyEngine/Core/Src/Memory/RefCountedBase.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | using namespace Poly; 6 | 7 | //------------------------------------------------------------------------------ 8 | void RefCountedBase::AddRef() 9 | { 10 | ++RefCount; 11 | HEAVY_ASSERTE(RefCount > 0, "Reference counter overflow!"); 12 | } 13 | 14 | //------------------------------------------------------------------------------ 15 | bool RefCountedBase::RemoveRef() 16 | { 17 | HEAVY_ASSERTE(RefCount > 0, "Cannot remove any more references!"); 18 | --RefCount; 19 | return RefCount == 0; 20 | } 21 | 22 | //------------------------------------------------------------------------------ 23 | RefCountedBase::~RefCountedBase() 24 | { 25 | HEAVY_ASSERTE(RefCount == 0, "Ref counted object was removed but reference count was greater than 0!"); 26 | } 27 | -------------------------------------------------------------------------------- /PolyEngine/Core/Src/Memory/RefCountedBase.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace Poly 7 | { 8 | class CORE_DLLEXPORT RefCountedBase : public BaseObject<> 9 | { 10 | public: 11 | virtual ~RefCountedBase(); 12 | 13 | void AddRef(); 14 | bool RemoveRef(); 15 | 16 | size_t GetRefCount() const { return RefCount; } 17 | 18 | private: 19 | size_t RefCount = 0; 20 | }; 21 | } -------------------------------------------------------------------------------- /PolyEngine/Core/Src/Memory/SafePtrRoot.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace Poly { 8 | /// Base class for all objects which require safe pointer 9 | class CORE_DLLEXPORT SafePtrRoot : public RTTIBase 10 | { 11 | RTTI_DECLARE_TYPE_DERIVED(::Poly::SafePtrRoot, ::Poly::RTTIBase) 12 | { NO_RTTI_PROPERTY(); } 13 | public: 14 | /// Registers given pointer 15 | /// Pointer to be registered 16 | /// ID of registered pointer 17 | static size_t RegisterPointer(SafePtrRoot *pointer); 18 | 19 | 20 | /// Gets pointer with given ID 21 | /// ID of requested pointer 22 | /// Pointer stored at given ID 23 | static SafePtrRoot *GetPointer(size_t idx); 24 | 25 | virtual ~SafePtrRoot(); 26 | 27 | private: 28 | static void ClearPointer(SafePtrRoot *pointer); 29 | 30 | static Dynarray Pointers; 31 | static std::unordered_map PointersMap; 32 | }; 33 | } -------------------------------------------------------------------------------- /PolyEngine/Core/Src/UniqueID.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace Poly 8 | { 9 | class CORE_DLLEXPORT UniqueID final : public BaseObjectLiteralType<> 10 | { 11 | public: 12 | static const UniqueID INVALID; 13 | 14 | UniqueID(); 15 | static UniqueID Generate(); 16 | 17 | bool operator==(const UniqueID& rhs) const; 18 | bool operator!=(const UniqueID& rhs) const; 19 | 20 | bool IsValid() const; 21 | explicit operator bool() const; 22 | 23 | size_t GetHash() const; 24 | String ToString() const; 25 | static Optional FromString(const String& str); 26 | CORE_DLLEXPORT friend std::ostream& operator<< (std::ostream& stream, const UniqueID& uuid); 27 | private: 28 | // 128-bit RFC4122 compliant uuid 29 | std::array UUID; 30 | }; 31 | } 32 | 33 | DECLARE_STD_HASHER(Poly::UniqueID) -------------------------------------------------------------------------------- /PolyEngine/Core/Src/Utils/HexUtils.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Poly { 6 | 7 | constexpr u8 HexCharToValue(char c) 8 | { 9 | if (c >= '0' && c <= '9') 10 | return c - '0'; 11 | else if (c >= 'a' && c <= 'f') 12 | return 0x0A + c - 'a'; 13 | else if (c >= 'A' && c <= 'F') 14 | return 0x0A + c - 'A'; 15 | else 16 | HEAVY_ASSERTE(false, "Not a hex value"); 17 | return 0xF0; 18 | } 19 | 20 | constexpr bool IsValidHex(char c) 21 | { 22 | return (c >= '0' && c <= '9') 23 | || (c >= 'a' && c <= 'f') 24 | || (c >= 'A' && c <= 'F'); 25 | } 26 | } -------------------------------------------------------------------------------- /PolyEngine/Core/Src/Utils/Logger.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | using namespace Poly; 6 | 7 | namespace Poly { 8 | Console gConsole; 9 | } 10 | -------------------------------------------------------------------------------- /PolyEngine/Core/Src/Utils/OutputStream.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Poly { 6 | 7 | class CORE_DLLEXPORT OutputStream : public BaseObject<>, public std::streambuf 8 | { 9 | public: 10 | virtual void OnUnregister() {} 11 | virtual void Append(const char*) = 0; 12 | protected: 13 | std::streamsize xsputn(const char_type* s, std::streamsize n) override final; 14 | int_type overflow(int_type c) override final; 15 | }; 16 | 17 | class CORE_DLLEXPORT FileOutputStream : public OutputStream 18 | { 19 | public: 20 | FileOutputStream(const char* name); 21 | FileOutputStream& operator=(FileOutputStream&& rhs); 22 | FileOutputStream(FileOutputStream&& rhs); 23 | FileOutputStream() = default; 24 | ~FileOutputStream() { EnsureFileClosed(); } 25 | void OnUnregister() override { EnsureFileClosed(); } 26 | void EnsureFileClosed(); 27 | bool IsFileOpen() const { return FileHandle != nullptr; } 28 | void Append(const char*) override; 29 | private: 30 | FILE* FileHandle = nullptr; 31 | }; 32 | } -------------------------------------------------------------------------------- /PolyEngine/Editor/Src-macOS/MacOSHelper.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void* GetNSWindowFromNSView(void* nsview); -------------------------------------------------------------------------------- /PolyEngine/Editor/Src-macOS/MacOSHelper.mm: -------------------------------------------------------------------------------- 1 | #import 2 | #import "MacOSHelper.hpp" 3 | 4 | void* GetNSWindowFromNSView(void* nsview) 5 | { 6 | return (void*)[(NSView*) nsview window]; 7 | } -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Controllers/IEngineController.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Poly 4 | { 5 | class Engine; 6 | } 7 | 8 | namespace editor::controllers 9 | { 10 | class IEngineController 11 | { 12 | public: 13 | virtual ~IEngineController() = default; 14 | 15 | virtual void SetEngine(std::unique_ptr engineToControl) = 0; 16 | virtual void Play() = 0; 17 | virtual void Pause() = 0; 18 | virtual void Edit() = 0; 19 | }; 20 | } -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Controllers/Impl/EngineController.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // qt 4 | #include 5 | 6 | // interface 7 | #include 8 | 9 | #include 10 | 11 | //------------------------------------------------------------------------------ 12 | namespace PolyEditor 13 | { 14 | class IEditor; 15 | } 16 | 17 | //------------------------------------------------------------------------------ 18 | namespace editor::controllers::impl 19 | { 20 | class EngineController final : public IEngineController 21 | { 22 | public: 23 | static std::unique_ptr Create(const ProjectConfig& projectConfig); 24 | 25 | EngineController(); 26 | 27 | void SetEngine(std::unique_ptr engineToControl) final; 28 | void Edit() final; 29 | void Play() final; 30 | void Pause() final; 31 | 32 | // TODO(squeras): remove this 33 | Poly::Engine* GetEngine() { return ControlledEngine.get(); } 34 | 35 | private: 36 | void OnEngineUpdateTimerTick(); 37 | 38 | std::unique_ptr ControlledEngine; 39 | PolyEditor::IEditor* Editor = nullptr; 40 | QTimer EngineUpdateTimer; 41 | 42 | }; // class EngineController 43 | 44 | } // namespace editor::controllers::impl -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Controls/CoreControls/BoolControl.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Controls/ControlBase.hpp" 4 | 5 | #include 6 | #include 7 | 8 | class Command; 9 | 10 | class BoolControl : public ControlBase 11 | { 12 | public: 13 | BoolControl(QWidget* parent); 14 | 15 | void UpdateControl() override; 16 | 17 | private: 18 | void UpdateObject(); 19 | 20 | QPushButton* Button; 21 | QStateMachine* Machine; 22 | 23 | QState* False; 24 | QState* True; 25 | 26 | bool InitializationConfirm = false; 27 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Controls/CoreControls/EnumControl.cpp: -------------------------------------------------------------------------------- 1 | #include "PolyEditorPCH.hpp" 2 | 3 | #include 4 | 5 | //ASSIGN_CONTROL(EnumControl, ENUM) 6 | 7 | //------------------------------------------------------------------------------ 8 | void EnumControl::Reset() 9 | { 10 | } 11 | 12 | //------------------------------------------------------------------------------ 13 | void EnumControl::UpdateControl() 14 | { 15 | } 16 | 17 | //------------------------------------------------------------------------------ 18 | void EnumControl::UpdateObject() 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Controls/CoreControls/EnumControl.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Controls/ControlBase.hpp" 4 | 5 | using namespace Poly; 6 | 7 | class EnumControl : public ControlBase 8 | { 9 | public: 10 | EnumControl(QWidget* parent) : ControlBase(parent) {} 11 | 12 | void Reset() override; 13 | 14 | void UpdateControl() override; 15 | 16 | protected: 17 | void UpdateObject(); 18 | 19 | private: 20 | //QComboBox* ComboBox; fix for clang compiler (unused private field) 21 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Controls/CoreControls/NumberControl.cpp: -------------------------------------------------------------------------------- 1 | #include "PolyEditorPCH.hpp" 2 | 3 | #include 4 | #include 5 | 6 | #include "Managers/CommandsImpl.hpp" 7 | 8 | ASSIGN_PARAMETRIZED_CONTROL(NumberControl, i8, RTTI::eCorePropertyType::INT8, INT8) 9 | ASSIGN_PARAMETRIZED_CONTROL(NumberControl, i16, RTTI::eCorePropertyType::INT16, INT16) 10 | ASSIGN_PARAMETRIZED_CONTROL(NumberControl, i32, RTTI::eCorePropertyType::INT32, INT32) 11 | ASSIGN_PARAMETRIZED_CONTROL(NumberControl, i64, RTTI::eCorePropertyType::INT64, INT64) 12 | ASSIGN_PARAMETRIZED_CONTROL(NumberControl, u8, RTTI::eCorePropertyType::UINT8, UINT8) 13 | ASSIGN_PARAMETRIZED_CONTROL(NumberControl, u16, RTTI::eCorePropertyType::UINT16, UINT16) 14 | ASSIGN_PARAMETRIZED_CONTROL(NumberControl, u32, RTTI::eCorePropertyType::UINT32, UINT32) 15 | ASSIGN_PARAMETRIZED_CONTROL(NumberControl, u64, RTTI::eCorePropertyType::UINT64, UINT64) 16 | ASSIGN_PARAMETRIZED_CONTROL(NumberControl, f32, RTTI::eCorePropertyType::FLOAT, FLOAT) 17 | ASSIGN_PARAMETRIZED_CONTROL(NumberControl, f64, RTTI::eCorePropertyType::DOUBLE, DOUBLE) 18 | -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Controls/CoreControls/NumberControl.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Controls/ControlBase.hpp" 4 | 5 | #include 6 | 7 | template 8 | class NumberControl : public ControlBase 9 | { 10 | using Base = ControlBase; 11 | 12 | public: 13 | NumberControl(QWidget* parent) 14 | : ControlBase(parent) 15 | { 16 | Field = new QLineEdit(this); 17 | Base::connect(Field, &QLineEdit::editingFinished, this, &NumberControl::UpdateObject); 18 | 19 | Base::Layout->addWidget(Field, 0, 1); 20 | } 21 | 22 | void Reset() override 23 | { 24 | Base::Reset(); 25 | 26 | Field->setText(""); 27 | } 28 | 29 | void UpdateControl() override 30 | { 31 | if (Field->hasFocus() || Base::DisableUpdateControl) 32 | return; 33 | 34 | Field->setText(QString::number(*Base::Object)); 35 | } 36 | 37 | private: 38 | void UpdateObject() 39 | { 40 | auto val = (T)Field->text().toDouble(); 41 | 42 | if (Base::DisableEdit || *Base::Object == val) 43 | return; 44 | 45 | ControlCommand* cmd = new ControlCommand(); 46 | cmd->Object = Base::Object; 47 | cmd->Control = this; 48 | 49 | cmd->UndoValue = new T(*Base::Object); 50 | cmd->RedoValue = new T(val); 51 | 52 | *Base::Object = val; 53 | 54 | emit Base::ObjectUpdated(cmd); 55 | } 56 | 57 | QLineEdit* Field; 58 | 59 | QValidator* Validator; 60 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Controls/CoreControls/PlaceHolderControl.cpp: -------------------------------------------------------------------------------- 1 | #include "PlaceHolderControl.hpp" 2 | 3 | PlaceHolderControl::PlaceHolderControl(QWidget* parent) 4 | : ControlBase(parent) 5 | { 6 | QPalette disabledEditPalette; 7 | disabledEditPalette.setColor(QPalette::Base, QColor(218, 218, 218)); 8 | disabledEditPalette.setColor(QPalette::Text, Qt::black); 9 | 10 | Field = new QLineEdit(this); 11 | Field->setText("this is placeholder control for some type..."); 12 | Field->setReadOnly(true); 13 | Field->setPalette(disabledEditPalette); 14 | 15 | Layout->addWidget(Field, 0, 1); 16 | } 17 | 18 | void PlaceHolderControl::Reset() 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Controls/CoreControls/PlaceHolderControl.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Controls/ControlBase.hpp" 6 | 7 | class PlaceHolderControl : public ControlBase 8 | { 9 | public: 10 | PlaceHolderControl(QWidget* parent); 11 | 12 | void Reset() override; 13 | 14 | void UpdateControl() override {}; 15 | 16 | protected: 17 | void UpdateObject() {}; 18 | 19 | private: 20 | QLineEdit* Field; 21 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Controls/CoreControls/StringControl.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Controls/ControlBase.hpp" 6 | 7 | class StringControl : public ControlBase 8 | { 9 | public: 10 | StringControl(QWidget* parent); 11 | 12 | void Reset() override; 13 | void UpdateControl() override; 14 | 15 | void SetText(String text) { Field->setText(text.GetCStr()); } 16 | 17 | private: 18 | void UpdateObject(); 19 | 20 | QLineEdit* Field; 21 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Controls/CoreControls/Vector2Control.cpp: -------------------------------------------------------------------------------- 1 | #include "PolyEditorPCH.hpp" 2 | 3 | #include "Managers/CommandsImpl.hpp" 4 | 5 | #include "Math/Vector2f.hpp" 6 | #include "Math/Vector2i.hpp" 7 | 8 | ASSIGN_PARAMETRIZED_CONTROL(Vector2Control, Vector2f, RTTI::eCorePropertyType::VECTOR_2F, Vector2f) 9 | ASSIGN_PARAMETRIZED_CONTROL(Vector2Control, Vector2i, RTTI::eCorePropertyType::VECTOR_2I, Vector2i) -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Controls/CoreControls/Vector3Control.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Controls/ControlBase.hpp" 4 | 5 | #include 6 | 7 | class Vector3Control : public ControlBase 8 | { 9 | public: 10 | Vector3Control(QWidget* parent); 11 | 12 | void Reset() override; 13 | void UpdateControl() override; 14 | 15 | private: 16 | void UpdateObject(); 17 | 18 | QLineEdit* Field[3]; 19 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Controls/EngineControls/TransformControl.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Controls/ControlBase.hpp" 4 | 5 | #include 6 | 7 | class TransformControl : public ControlBase 8 | { 9 | public: 10 | TransformControl(QWidget* parent); 11 | 12 | void Reset() override; 13 | 14 | void UpdateControl() override; 15 | 16 | void UpdateObject() {}; 17 | 18 | private: 19 | void UodateTranslation(); 20 | void UodateRotation(); 21 | void UodateScale(); 22 | 23 | QGridLayout* Layout; 24 | QLabel * XYZLabels[3]; 25 | QLabel* TranslationLabel; QLineEdit* TranslationField[3]; 26 | QLabel* RotationLabel; QLineEdit* RotationField[3]; 27 | QLabel* ScaleLabel; QLineEdit* ScaleField[3]; 28 | 29 | public slots: 30 | void ConfirmTranslation() 31 | { 32 | QTimer::singleShot(1, this, [object = this]() { object->UodateTranslation(); }); 33 | } 34 | 35 | void ConfirmRotation() 36 | { 37 | QTimer::singleShot(1, this, [object = this]() { object->UodateRotation(); }); 38 | } 39 | 40 | void ConfirmScale() 41 | { 42 | QTimer::singleShot(1, this, [object = this]() { object->UodateScale(); }); 43 | } 44 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Controls/IControlBase.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | using namespace Poly; 10 | 11 | // This is base class for all controls for core types such as int, string or vector. 12 | // @see Poly::RTTI::eCorePropertyType 13 | class IControlBase 14 | { 15 | public: 16 | // Assigns given object to control and updates this control. 17 | virtual void SetObject(void* ptr) = 0; 18 | 19 | // Name of assigned property. 20 | virtual void SetName(String name) = 0; 21 | // Tool tip for this control. 22 | virtual void SetToolTip(String type) = 0; 23 | // If set to true then control will not permit changing its content. 24 | virtual void SetDisableEdit(bool disable) = 0; 25 | 26 | // Resets this control to initial state; 27 | virtual void Reset() = 0; 28 | 29 | // Call this to update control state from assigned object. 30 | virtual void UpdateControl() = 0; 31 | }; 32 | -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Dialogs/IDialog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class IDialog 4 | { 5 | public: 6 | // Resets everything so single dialog instance can be used multiple times. 7 | virtual void Reset() = 0; 8 | 9 | // If operation was canceled by user this function will return true. 10 | virtual void OperationCanceled() = 0; 11 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/EditorApp.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "EditorUi.hpp" 7 | #include "GlobalEventFilter.hpp" 8 | 9 | #include 10 | 11 | class DockManager; 12 | class CmdManager; 13 | class ProjectManager; 14 | class InspectorManager; 15 | class CommandManager; 16 | 17 | namespace editor::controllers 18 | { 19 | class IEngineController; 20 | } 21 | 22 | class EditorApp : public QApplication 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | EditorApp(int argc, char *argv[]); 28 | ~EditorApp(); 29 | 30 | EditorUi Ui; 31 | 32 | DockManager* DockMgr; 33 | CmdManager* CmdMgr; 34 | ProjectManager* ProjectMgr; 35 | InspectorManager* InspectorMgr; 36 | CommandManager* CommandMgr; 37 | 38 | std::unique_ptr EngineController; 39 | 40 | private: 41 | GlobalEventFilter EventFilter; 42 | }; 43 | 44 | extern EditorApp* gApp; 45 | -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/EditorUi.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | void EditorUi::Init() 10 | { 11 | MainWindow = new PolyMainWindow(); 12 | Windows.PushBack(std::move(MainWindow)); 13 | 14 | // main logger 15 | MainLogger = new LoggerWidget(eLoggerType::CONSOLE); 16 | PolyDockWindow* window = new PolyDockWindow("Console", MainLogger); 17 | MainWindow->AddDockWindow(Qt::DockWidgetArea::RightDockWidgetArea, window, true); 18 | window->hide(); 19 | 20 | // command logger 21 | CmdLogger = new LoggerWidget(eLoggerType::CMD); 22 | window = new PolyDockWindow("Cmd", CmdLogger); 23 | MainWindow->AddDockWindow(Qt::DockWidgetArea::RightDockWidgetArea, window, true); 24 | window->hide(); 25 | 26 | gApp->InspectorMgr->InitUi(); 27 | 28 | MainWindow->show(); 29 | } 30 | -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/EditorUi.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Windows/PolyMainWindow.hpp" 4 | #include "Widgets/LoggerWidget.hpp" 5 | 6 | class WorldInspectorWidget; 7 | class WorldComponentsInspectorWidget; 8 | class EntityInspectorWidget; 9 | class ResourceInspectorWidget; 10 | 11 | class EditorUi : public QObject 12 | { 13 | friend class DockManager; 14 | friend class PolyWindow; 15 | 16 | public: 17 | EditorUi() = default; 18 | 19 | void Init(); 20 | void AddWindow() { PolyWindow* wnd = new PolyWindow(); Windows.PushBack(wnd); wnd->show(); } 21 | 22 | LoggerWidget* MainLogger; 23 | LoggerWidget* CmdLogger; 24 | 25 | PolyMainWindow* MainWindow; 26 | 27 | private: 28 | Poly::Dynarray Windows; 29 | Poly::Dynarray DockWindows; 30 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/GlobalEventFilter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | bool GlobalEventFilter::eventFilter(QObject* watched, QEvent* event) 4 | { 5 | UNUSED(watched); 6 | gApp->DockMgr->ProcessEvent(event); 7 | gApp->CommandMgr->ProcessEvent(event); 8 | return false; // you should return false when you want qt to forward this event to receiver 9 | } 10 | -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/GlobalEventFilter.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class GlobalEventFilter : public QObject 4 | { 5 | public: 6 | GlobalEventFilter() = default; 7 | 8 | bool eventFilter(QObject* watched, QEvent* event) override; 9 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/IEditor.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace PolyEditor 7 | { 8 | enum class eEngineState 9 | { 10 | NONE, 11 | EDIT, 12 | GAMEPLAY, 13 | PAUSED_GAMEPLAY, 14 | _COUNT 15 | }; 16 | 17 | class IEditor : public Poly::IEditor 18 | { 19 | public: 20 | // Get all ID's of currently selected entties. 21 | virtual Poly::Dynarray GetSelectedEntities() = 0; 22 | 23 | // Set entities selection. 24 | virtual void SetSelectedEntities(Poly::Dynarray) = 0; 25 | 26 | // If we are in edit mode and user used gizmo then this method is called. 27 | virtual void UpdateInspectors() = 0; 28 | 29 | virtual void SetEngineState(eEngineState state) = 0; 30 | virtual eEngineState GetEngineState() = 0; 31 | }; 32 | } -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char *argv[]) 4 | { 5 | /* 6 | QSurfaceFormat format; 7 | format.setDepthBufferSize(32); 8 | format.setRenderableType(QSurfaceFormat::OpenGL); 9 | format.setVersion(3, 3); 10 | format.setProfile(QSurfaceFormat::CoreProfile); 11 | format.setSwapBehavior(QSurfaceFormat::DoubleBuffer); 12 | QSurfaceFormat::setDefaultFormat(format); 13 | */ 14 | 15 | EditorApp app(argc, argv); 16 | auto exitCode = app.exec(); 17 | 18 | // Clean managers, otherwise their constructors crash due to messed deinitialization order across shared libraries 19 | Poly::ComponentManager::Get().Clear(); 20 | Poly::RTTI::Impl::TypeManager::Get().Clear(); 21 | 22 | return exitCode; 23 | } 24 | -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Managers/CmdManager.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | CmdManager::CmdManager() 4 | { 5 | // setup timer for reading from stream 6 | Timer = std::make_unique(this); 7 | connect(Timer.get(), &QTimer::timeout, this, &CmdManager::ReadStdout); 8 | } 9 | 10 | void CmdManager::RunCommand(const String& cmd) 11 | { 12 | Command = cmd; 13 | 14 | // execute command and return output stream 15 | #ifdef _WIN32 16 | Stream = _popen((Command + String(" 2>&1")).GetCStr(), "r"); 17 | #else 18 | Stream = popen((Command + String(" 2>&1")).GetCStr(), "r"); 19 | #endif 20 | 21 | // display some nice info 22 | *Ostream << "\n\n> ---------- \"" << Command << "\" started... ----------\n"; 23 | 24 | Running = true; 25 | Timer->start(0); 26 | } 27 | 28 | void CmdManager::ReadStdout() 29 | { 30 | if (Running && !feof(Stream)) 31 | { 32 | if (fgets(Buffer, MaxBuffer, Stream) != NULL) 33 | *Ostream << "> " << Buffer; 34 | } 35 | else if (Running) 36 | { 37 | #ifdef _WIN32 38 | _pclose(Stream); 39 | #else 40 | pclose(Stream); 41 | #endif 42 | *Ostream << "\n> ---------- \"" << Command << "\" finished. ----------\n\n"; 43 | 44 | Running = false; 45 | Timer->stop(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Managers/CommandManager.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | using namespace Poly; 8 | 9 | class Command; 10 | 11 | class CommandManager 12 | { 13 | public: 14 | CommandManager(); 15 | ~CommandManager(); 16 | 17 | void ProcessEvent(QEvent* event); 18 | 19 | void AddCommand(Command* cmd); 20 | 21 | private: 22 | void Undo(); 23 | void Redo(); 24 | 25 | Dynarray Commands; 26 | size_t CurrentCommand = 0; 27 | 28 | bool CtrlPressed = false; 29 | bool ShiftPressed = false; 30 | bool ZPressed = false; 31 | bool DuringEvent = false; 32 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Managers/DockManager.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class PolyWindow; 6 | class PolyDockWindow; 7 | 8 | class DockManager 9 | { 10 | public: 11 | DockManager() = default; 12 | 13 | void WidgetCatchEvent(PolyDockWindow* catched); 14 | void WidgetMoveEvent(QEvent* event); 15 | void WidgetDropEvent(); 16 | 17 | void ProcessEvent(QEvent* event); 18 | 19 | private: 20 | PolyWindow* MouseOver = nullptr; // over this window is currently dragged DraggedWidget 21 | PolyDockWindow* DraggedWidget = nullptr; 22 | Qt::DockWidgetArea DraggedWidgetDockArea = Qt::DockWidgetArea::TopDockWidgetArea; 23 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Managers/Project/Dialogs/CreateProjectDialog.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | class CreateProjectDialog : public QDialog 9 | { 10 | public: 11 | CreateProjectDialog(QWidget* parent); 12 | ~CreateProjectDialog(); 13 | 14 | bool OperationCanceled() { return Canceled; } 15 | QString GetProjectName() { return ProjectNameField->text(); } 16 | QString GetProjectDirectory() { return ProjectDirectoryField->text(); } 17 | QString GetEngineDirectory() { return EngineDirectoryField->text(); } 18 | 19 | private: 20 | QLabel* ProjectNameText; 21 | QLineEdit* ProjectNameField; 22 | 23 | QLabel* ProjectDirectoryText; 24 | QLineEdit* ProjectDirectoryField; 25 | QPushButton* BrowseDirectoryButton; 26 | 27 | QLabel* EngineDirectoryText; 28 | QLineEdit* EngineDirectoryField; 29 | QPushButton* EngineDirectoryButton; 30 | 31 | QPushButton* OkButton; 32 | QPushButton* CancelButton; 33 | 34 | bool Canceled = false; 35 | 36 | private slots: 37 | void BrowseProjectDirectory(); 38 | void BrowseEngineDirectory(); 39 | void Ok(); 40 | void Cancel(); 41 | }; 42 | -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Managers/Project/Dialogs/EntityDialog.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | using namespace Poly; 14 | 15 | class EntityDialog : public QDialog 16 | { 17 | public: 18 | EntityDialog() {} 19 | 20 | Dynarray SpawnEntities(Scene* scene, Dynarray parents); 21 | Dynarray GetEntitiesToDestroy(Scene* scene, Dynarray entities); 22 | Dynarray ReparentEntities(Scene* scene, Dynarray entities, Entity* parent = nullptr); 23 | 24 | bool OperationCanceled() { return Canceled; } 25 | 26 | private: 27 | void AddEntity(Entity* entity); 28 | void AddPrefab(QString prefabName); 29 | 30 | bool Canceled = true; 31 | Dynarray PredefinedEntities; 32 | std::map ItemToEntity; 33 | 34 | QGridLayout* MainLayout; 35 | QLabel* FirstLabel; 36 | QTreeWidget* EntitiesTree; 37 | QLabel* SecondLabel; 38 | QTreeWidget* PrefabTree; 39 | QPushButton* CancelButton; QPushButton* OkButton; 40 | 41 | private slots: 42 | void Ok(); 43 | void Cancel(); 44 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Managers/Project/Dialogs/IComponentDialog.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Dialogs/IDialog.h" 6 | 7 | class IComponentDialog : public IDialog 8 | { 9 | public: 10 | // Adds selected components to given entity and returns list of selected components' ids 11 | virtual Poly::Dynarray AddComponents(Poly::Entity* predefinedEntity = nullptr, Poly::Dynarray predefinedComponents = {}) = 0; 12 | // Removes selected components from entity. 13 | virtual void RemoveComponents(Poly::Entity* predefinedEntity = nullptr, Poly::Dynarray predefinedComponents = {}) = 0; 14 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Managers/Project/Dialogs/IEntityDialog.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Dialogs/IDialog.h" 6 | 7 | class IEntityDialog : public IDialog 8 | { 9 | public: 10 | // Spawns entities from selected prefabs in each of selected parents on given scene and returns dynarray with newly created entities. 11 | virtual Poly::Dynarray SpawnEntities(Poly::Scene* scene, Poly::Dynarray predefinedParents = {}) = 0; 12 | // Destroys recursively selected entities. 13 | virtual void DestroyEntities(Poly::Dynarray predefinedEntities = {}) = 0; 14 | // Reparents all selected entities to one selected parent. 15 | virtual void ReparentEntities(Poly::Entity* predefinedParent = nullptr, Poly::Dynarray predefinedEntities = {}) = 0; 16 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Managers/Project/Dialogs/ISceneDialog.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Dialogs/IDialog.h" 6 | 7 | class ISceneDialog : public IDialog 8 | { 9 | public: 10 | // Creates scene according to user preferences and returns pointer to this new scene. 11 | virtual Poly::Scene* AddScene() = 0; 12 | // Removes scene selected by user, if given scene can be highlighted at dialog startup for better experience. 13 | virtual void RemoveScene(Poly::Scene* predefinedScene = nullptr) = 0; 14 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Managers/Project/ProjectManager.cpp: -------------------------------------------------------------------------------- 1 | #include "PolyEditorPCH.hpp" 2 | 3 | //------------------------------------------------------------------------------ 4 | ProjectManager::ProjectManager(std::unique_ptr projectCfg) 5 | : ProjectCfg(std::move(projectCfg)) 6 | { 7 | } 8 | 9 | //------------------------------------------------------------------------------ 10 | void ProjectManager::Edit() 11 | { 12 | if (!gApp->EngineController) 13 | InitEngine(); 14 | 15 | gApp->EngineController->Edit(); 16 | 17 | emit EngineStateChanged(PolyEditor::eEngineState::EDIT); 18 | } 19 | 20 | //------------------------------------------------------------------------------ 21 | void ProjectManager::Play() 22 | { 23 | if (!gApp->EngineController) 24 | InitEngine(); 25 | 26 | // TODO(squares): fix problem with physics; Rigidbody and collider components are initialized in next frame 27 | // so when next frame never occur we try to delete empty ImplData 28 | gApp->EngineController->Play(); 29 | 30 | emit EngineStateChanged(PolyEditor::eEngineState::GAMEPLAY); 31 | } 32 | 33 | //------------------------------------------------------------------------------ 34 | void ProjectManager::InitEngine() 35 | { 36 | auto controller = editor::controllers::impl::EngineController::Create(*ProjectCfg); 37 | emit EngineInitialized(controller->GetEngine()); 38 | gApp->EngineController = std::move(controller); 39 | } 40 | -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Managers/Project/ProjectManager.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "Configs/ProjectConfig.hpp" 8 | 9 | using namespace Poly; 10 | 11 | class ProjectManagerException : public std::exception 12 | { 13 | public: 14 | ProjectManagerException(const String& msg) : Msg((const char*)msg.GetCStr()) {} 15 | const char* what() const noexcept override { return Msg.GetCStr(); } 16 | 17 | protected: 18 | String Msg; 19 | }; 20 | 21 | class ProjectManager : public QObject 22 | { 23 | Q_OBJECT 24 | 25 | public: 26 | ProjectManager(std::unique_ptr projectCfg); 27 | 28 | // go into edit mode 29 | void Edit(); 30 | // run game in editor's viewport 31 | void Play(); 32 | 33 | bool IsOpened() { return Opened; } 34 | 35 | const ProjectConfig& GetProjectConfig() const { return *ProjectCfg; } 36 | 37 | signals: 38 | void EngineInitialized(Engine* engine); 39 | void EngineDeinitialized(); 40 | void EngineStateChanged(PolyEditor::eEngineState state); 41 | 42 | private: 43 | void InitEngine(); 44 | 45 | bool Opened = false; 46 | std::unique_ptr ProjectCfg; 47 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/PolyEditorPCH.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Systems/Camera/EditorCameraMovementComponent.cpp: -------------------------------------------------------------------------------- 1 | #include "PolyEditorPCH.hpp" 2 | 3 | using namespace Poly; 4 | 5 | RTTI_DEFINE_COMPONENT(EditorCameraMovementComponent) 6 | 7 | EditorCameraMovementComponent::EditorCameraMovementComponent(float movementSpeed, float rotationSpeed, float wheelSensitivity) 8 | : MovementSpeed(movementSpeed), RotationSpeed(rotationSpeed), WheelSensitivity(wheelSensitivity) 9 | { 10 | } 11 | 12 | -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Systems/Camera/EditorCameraMovementComponent.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ECS/ComponentBase.hpp" 4 | #include "Systems/Camera/EditorCameraMovementSystem.hpp" 5 | 6 | class EditorCameraMovementComponent : public ComponentBase 7 | { 8 | friend void EditorCameraMovementSystem::Update(Poly::Scene*); 9 | public: 10 | RTTI_DECLARE_COMPONENT(EditorCameraMovementComponent) { NO_RTTI_PROPERTY(); } 11 | 12 | EditorCameraMovementComponent(float movementSpeed = 1.0f, float rotationSpeed = 1.0f, float wheelSensitivity = 1.0f); 13 | 14 | float GetMovementSpeed() const { return MovementSpeed; } 15 | void SetMovementSpeed(float value) { MovementSpeed = value; } 16 | float GetAngularVelocity() const { return RotationSpeed; } 17 | void SetAngularVelocity(float value) { RotationSpeed = value; } 18 | float GetWheelSensitivity() const { return WheelSensitivity; } 19 | void SetWheelSensitivity(float value) { WheelSensitivity = value; } 20 | 21 | private: 22 | float MovementSpeed = 1.0f; 23 | float RotationSpeed = 1.0f; 24 | float WheelSensitivity = 1.0f; 25 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Systems/Camera/EditorCameraMovementSystem.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Poly 6 | { 7 | class Scene; 8 | } 9 | 10 | namespace EditorCameraMovementSystem 11 | { 12 | void Update(Poly::Scene* scene); 13 | 14 | Vector GetLocalForward(const Poly::EntityTransform& transform); 15 | Vector GetLocalRight(const Poly::EntityTransform& transform); 16 | Vector GetLocalUp(const Poly::EntityTransform& transform); 17 | 18 | Vector GetGlobalForward(const Poly::EntityTransform& transform); 19 | Vector GetGlobalRight(const Poly::EntityTransform& transform); 20 | Vector GetGlobalUp(const Poly::EntityTransform& transform); 21 | } -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Systems/Gizmo/GizmoSystem.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ECS/Scene.hpp" 4 | 5 | using namespace Poly; 6 | 7 | namespace GizmoSystem 8 | { 9 | void Update(Scene* scene); 10 | } -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Systems/Gizmo/GizmoWorldComponent.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace Poly; 4 | 5 | GizmoWorldComponent::GizmoWorldComponent() 6 | { 7 | } 8 | -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Systems/Gizmo/GizmoWorldComponent.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ECS/ComponentBase.hpp" 4 | 5 | using namespace Poly; 6 | 7 | class GizmoWorldComponent : public ComponentBase 8 | { 9 | public: 10 | GizmoWorldComponent(); 11 | 12 | private: 13 | 14 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Widgets/Containers/SectionContainer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | // This container can be collapsed to one line. 11 | // If deleted deletes its whole content. 12 | class SectionContainer : public QWidget 13 | { 14 | public: 15 | SectionContainer(const QString& title, QWidget* parent = nullptr, int animationDuration = 100); 16 | ~SectionContainer(); 17 | 18 | void SetLayout(QLayout* layout); 19 | void SetWidget(QWidget* widget); 20 | 21 | private: 22 | void Init(); 23 | 24 | QLayout* ContentLayout = nullptr; 25 | 26 | QScrollArea* ScrollArea; 27 | QGridLayout* MainLayout; 28 | 29 | QToolButton* Button; 30 | QFrame* HLine; 31 | QParallelAnimationGroup* Animation; 32 | int AnimationDuration; 33 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Widgets/Inspectors/InspectorWidgetBase.cpp: -------------------------------------------------------------------------------- 1 | #include "PolyEditorPCH.hpp" 2 | 3 | InspectorWidgetBase::InspectorWidgetBase(QWidget* parent, InspectorManager* mgr) 4 | : PolyWidget(parent), 5 | Manager(mgr) 6 | { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Widgets/Inspectors/InspectorWidgetBase.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Widgets/PolyWidget.hpp" 4 | 5 | class InspectorManager; 6 | 7 | class InspectorWidgetBase : public PolyWidget 8 | { 9 | public: 10 | InspectorWidgetBase(QWidget* parent, InspectorManager* mgr); 11 | 12 | virtual void InitializeConnections() = 0; 13 | virtual void Reset() = 0; 14 | 15 | protected: 16 | InspectorManager* Manager; 17 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Widgets/Inspectors/ResourceInspectorWidget.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "Configs/ProjectConfig.hpp" 8 | #include "Widgets/Inspectors/InspectorWidgetBase.hpp" 9 | 10 | // File explorer with additional functionality, updates content ASAP. 11 | class ResourceInspectorWidget : public InspectorWidgetBase 12 | { 13 | public: 14 | ResourceInspectorWidget(QWidget* parent, InspectorManager* mgr); 15 | 16 | // Initializes object connections with other inspectors and inspector manager. 17 | void InitializeConnections() override; 18 | 19 | // Removes all items from viewer. 20 | void Reset() override; 21 | 22 | public slots: 23 | void ProjectOpened(); 24 | void ProjectClosed(); 25 | 26 | private: 27 | QGridLayout* Layout; 28 | 29 | QFileSystemModel* Model; 30 | QTreeView* Tree; 31 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Widgets/LoggerWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "PolyEditorPCH.hpp" 2 | 3 | class LoggerWidget; 4 | 5 | class EditorOutputStream : public Poly::FileOutputStream 6 | { 7 | public: 8 | EditorOutputStream(const char* name, LoggerWidget* widget) 9 | : FileOutputStream(name) 10 | { 11 | Logger = widget; 12 | } 13 | 14 | void Append(const char* data) override 15 | { 16 | Logger->AppendLog(data); 17 | Poly::FileOutputStream::Append(data); 18 | } 19 | private: 20 | LoggerWidget* Logger = nullptr; 21 | }; 22 | 23 | 24 | LoggerWidget::LoggerWidget(eLoggerType type) 25 | { 26 | Layout = new QBoxLayout(QBoxLayout::Direction::LeftToRight, this); 27 | TextEdit = new QTextEdit(this); 28 | TextEdit->setReadOnly(true); 29 | Layout->addWidget(TextEdit); 30 | 31 | switch (type) 32 | { 33 | case eLoggerType::CONSOLE: 34 | Poly::gConsole.RegisterStream("console.log", this); 35 | break; 36 | case eLoggerType::CMD: 37 | gApp->CmdMgr->RegisterStream("cmd.log", this); 38 | break; 39 | default: 40 | break; 41 | } 42 | } 43 | 44 | LoggerWidget::~LoggerWidget() 45 | { 46 | Poly::gConsole.RegisterDefaultStream(); 47 | } 48 | 49 | void LoggerWidget::AppendLog(const char * data) 50 | { 51 | TextEdit->moveCursor(QTextCursor::End); 52 | TextEdit->insertPlainText(QString::fromLocal8Bit(data)); 53 | TextEdit->moveCursor(QTextCursor::End); 54 | TextEdit->show(); 55 | } 56 | -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Widgets/LoggerWidget.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "Widgets/PolyWidget.hpp" 6 | 7 | enum class eLoggerType 8 | { 9 | CONSOLE, // gConsole output 10 | CMD, // command manager output 11 | _COUNT 12 | }; 13 | 14 | class LoggerWidget : public PolyWidget 15 | { 16 | public: 17 | explicit LoggerWidget(eLoggerType type); 18 | ~LoggerWidget(); 19 | 20 | void AppendLog(const char* data); 21 | protected: 22 | 23 | private: 24 | QTextEdit* TextEdit; 25 | QBoxLayout* Layout; 26 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Widgets/PolyWidget.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class PolyWidget : public QWidget 6 | { 7 | public: 8 | PolyWidget(QWidget* parent = nullptr) : QWidget(parent) {} 9 | }; 10 | -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Windows/CustomSDLWindow.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | struct SDL_Window; 5 | 6 | class CustomSDLWindow 7 | { 8 | public: 9 | static CustomSDLWindow CreateSDLWindowFromArgs(void* nativeHandle, uint32_t flags); 10 | 11 | CustomSDLWindow() = default; 12 | CustomSDLWindow(CustomSDLWindow&& rhs); 13 | CustomSDLWindow& operator=(CustomSDLWindow&& rhs); 14 | 15 | ~CustomSDLWindow(); 16 | 17 | inline bool IsValid() const { return MainWindow != nullptr; } 18 | SDL_Window* Get() { return MainWindow; } 19 | private: 20 | 21 | CustomSDLWindow(SDL_Window* mainWin, SDL_Window* helperWin); 22 | 23 | SDL_Window* MainWindow = nullptr; 24 | SDL_Window* HelperWindow = nullptr; 25 | }; 26 | 27 | typedef int32_t SDL_Keycode; 28 | SDL_Keycode QtKeyEventToSDLKeycode(Qt::Key key); -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Windows/PolyDockWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "PolyEditorPCH.hpp" 2 | 3 | #include "QtWidgets/QStylePainter" 4 | 5 | PolyDockWindow::PolyDockWindow(const QString& title, PolyWidget* widget) 6 | : QDockWidget(title), Title(title) 7 | { 8 | widget->setParent(this); 9 | 10 | setWidget(widget); 11 | 12 | connect(this, &QDockWidget::topLevelChanged, this, 13 | [object = this](bool topLevel) { if (topLevel) gApp->DockMgr->WidgetCatchEvent(object); }); 14 | } 15 | 16 | void PolyDockWindow::paintEvent(QPaintEvent *e) 17 | { 18 | QPainter painter(this); 19 | 20 | painter.setPen(QColor(225, 159, 4)); 21 | painter.drawLine(10, 20, width() - 10, 20); 22 | painter.setPen(Qt::lightGray); 23 | painter.setFont(QFont("Consolas", 9, QFont::Bold)); 24 | painter.drawText(QRect(10, 0, width(), 20), Title); 25 | 26 | QWidget::paintEvent(e); 27 | 28 | //QDockWidget::paintEvent(e); 29 | } -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Windows/PolyDockWindow.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class PolyWindow; 6 | class PolyWidget; 7 | 8 | class PolyDockWindow : public QDockWidget 9 | { 10 | public: 11 | PolyDockWindow(const QString& title, PolyWidget* widget); 12 | 13 | PolyWindow* GetOwner() const { return static_cast(parent()); } 14 | 15 | protected: 16 | void paintEvent(QPaintEvent *e) override; 17 | 18 | private: 19 | QString Title; 20 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Windows/PolyMainWindow.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "PolyWindow.hpp" 9 | 10 | // TODO(squares): exit app after closing this window 11 | 12 | class PolyMainWindow : public PolyWindow 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | PolyMainWindow(); 18 | 19 | private: 20 | // main window menu actions 21 | std::unique_ptr MenuBar; 22 | std::unique_ptr FileMenu; 23 | std::unique_ptr QuitAction; 24 | std::unique_ptr ProjectMenu; 25 | std::unique_ptr EditProjectAction; 26 | std::unique_ptr PlayProjectAction; 27 | std::unique_ptr ViewMenu; 28 | std::unique_ptr AddWindowAction; 29 | 30 | // toolbar 31 | 32 | // status bar 33 | std::unique_ptr StatusBar; 34 | 35 | private slots: 36 | // file 37 | void Quit(); 38 | 39 | // edit 40 | void Undo(); 41 | void Redo(); 42 | 43 | // view 44 | void AddWindow(); 45 | 46 | // projhect 47 | void EditProject(); 48 | void PlayProject(); 49 | 50 | // help 51 | void ContactUs(); 52 | 53 | protected: 54 | void closeEvent(QCloseEvent* event) override; 55 | }; -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Windows/PolyWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "PolyEditorPCH.hpp" 2 | 3 | #include 4 | 5 | PolyWindow::PolyWindow() 6 | { 7 | setAttribute(Qt::WA_DeleteOnClose); 8 | setDockOptions(QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks); 9 | } 10 | 11 | void PolyWindow::AddDockWindow(Qt::DockWidgetArea area, PolyDockWindow* wnd, bool isInitialization) 12 | { 13 | if(PolyWindow* window = dynamic_cast(wnd->parent())) 14 | window->RemoveDockWindow(wnd); 15 | 16 | if(isInitialization) 17 | addDockWidget(area, wnd); 18 | else 19 | QTimer::singleShot(1, this, [a = area, w = wnd, object = this]() 20 | { object->addDockWidget(a, w); w->show(); }); 21 | 22 | DockWindows.PushBack(wnd); 23 | } 24 | 25 | void PolyWindow::RemoveDockWindow(PolyDockWindow* wnd) 26 | { 27 | DockWindows.Remove(wnd); 28 | removeDockWidget(wnd); 29 | } 30 | 31 | void PolyWindow::closeEvent(QCloseEvent* event) 32 | { 33 | UNUSED(event); 34 | 35 | Poly::Dynarray windows = DockWindows; 36 | 37 | for (auto wnd : windows) 38 | gApp->Ui.MainWindow->AddDockWindow(Qt::DockWidgetArea::LeftDockWidgetArea, wnd); 39 | 40 | gApp->Ui.Windows.Remove(this); 41 | } 42 | -------------------------------------------------------------------------------- /PolyEngine/Editor/Src/Windows/PolyWindow.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | class PolyDockWindow; 8 | 9 | class PolyWindow : public QMainWindow 10 | { 11 | public: 12 | PolyWindow(); 13 | 14 | size_t DockWindowsCount() { return DockWindows.GetSize(); } 15 | 16 | void AddDockWindow(Qt::DockWidgetArea area, PolyDockWindow* wnd, bool isInitialization = false); 17 | void RemoveDockWindow(PolyDockWindow* widget); 18 | 19 | private: 20 | Poly::Dynarray DockWindows; 21 | 22 | void closeEvent(QCloseEvent* event) override; 23 | }; -------------------------------------------------------------------------------- /PolyEngine/Engine/AssetsPathConfig.json.in: -------------------------------------------------------------------------------- 1 | { 2 | "@type": "AssetsPathConfig", 3 | "EngineAssetsPath": "@ENGINE_ASSETS_PATHS@", 4 | "GameAssetsPath": "@GAME_ASSETS_PATHS@", 5 | "RenderingDeviceLibPath": "@RENDERING_DEVICE_LIB_PATH@", 6 | "GameLibPath": "@GAME_LIB_PATH@" 7 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(POLYENGINE_INCLUDE ${CMAKE_CURRENT_LIST_DIR}/Src) 2 | 3 | file(GLOB_RECURSE POLYENGINE_SRCS RELATIVE ${CMAKE_CURRENT_LIST_DIR} 4 | ${POLYENGINE_INCLUDE}/*.cpp 5 | ${POLYENGINE_INCLUDE}/*.hpp 6 | ${POLYENGINE_INCLUDE}/*.h 7 | ) 8 | GenerateSourceGoups("${POLYENGINE_SRCS}") 9 | 10 | add_library(${ENGINE_TARGET} SHARED ${POLYENGINE_SRCS}) 11 | target_compile_definitions(${ENGINE_TARGET} PRIVATE _ENGINE) 12 | 13 | target_include_directories(${ENGINE_TARGET} 14 | PUBLIC 15 | ${POLYENGINE_INCLUDE} 16 | PRIVATE 17 | ${BULLET_INCLUDE_DIRS} 18 | ${STB_INCLUDE_DIRS} ) 19 | 20 | target_link_libraries(${ENGINE_TARGET} 21 | PUBLIC ${CORE_TARGET} ${BEGIN_EXPORT_ALL_SYMBOLS} Imgui ${END_EXPORT_ALL_SYMBOLS} 22 | PRIVATE assimp freetype OpenAL ogg vorbis vorbisfile 23 | ${BEGIN_EXPORT_ALL_SYMBOLS} ${BOX2D_LIBRARIES} ${BULLET_LIBRARIES} ${END_EXPORT_ALL_SYMBOLS}) 24 | 25 | set_target_properties(${ENGINE_TARGET} PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "${CMAKE_CURRENT_LIST_DIR}/Src/EnginePCH.hpp") 26 | set_target_properties(${ENGINE_TARGET} PROPERTIES FOLDER "Engine" ) 27 | cotire(${ENGINE_TARGET}) 28 | -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Configs/DebugConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "@type": "DebugConfig", 3 | "UUID": "175c252a-fc71-4e01-8260-8791999a2aa9", 4 | "DisplayFPS": true 5 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Cubemaps/miramar/README.TXT: -------------------------------------------------------------------------------- 1 | THIS SKY WAS UPDATED AT THE 27TH 2 | THE ORIG HAD SOME ERRORS 3 | 4 | MIRAMAR 5 | high res 1024^2 environment map 6 | ships as TGA. 7 | 8 | 9 | By Jockum Skoglund aka hipshot 10 | hipshot@zfight.com 11 | www.zfight.com 12 | Stockholm, 2005 08 25 13 | 14 | 15 | Modify however you like, just cred me for my work, maybe link to my page. 16 | -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Cubemaps/miramar/miramar_bk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Cubemaps/miramar/miramar_bk.jpg -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Cubemaps/miramar/miramar_dn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Cubemaps/miramar/miramar_dn.jpg -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Cubemaps/miramar/miramar_ft.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Cubemaps/miramar/miramar_ft.jpg -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Cubemaps/miramar/miramar_lt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Cubemaps/miramar/miramar_lt.jpg -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Cubemaps/miramar/miramar_rt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Cubemaps/miramar/miramar_rt.jpg -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Cubemaps/miramar/miramar_up.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Cubemaps/miramar/miramar_up.jpg -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Cubemaps/stormydays/README.TXT: -------------------------------------------------------------------------------- 1 | STORMY DAYS 2 | high res 1024^2 environment map 3 | ships as TGA. 4 | 5 | 6 | By Jockum Skoglund aka hipshot 7 | hipshot@zfight.com 8 | www.zfight.com 9 | Stockholm, 2005 08 25 10 | 11 | 12 | Modify however you like, just cred me for my work, maybe link to my page. 13 | -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Cubemaps/stormydays/stormydays_bk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Cubemaps/stormydays/stormydays_bk.jpg -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Cubemaps/stormydays/stormydays_dn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Cubemaps/stormydays/stormydays_dn.jpg -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Cubemaps/stormydays/stormydays_ft.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Cubemaps/stormydays/stormydays_ft.jpg -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Cubemaps/stormydays/stormydays_lt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Cubemaps/stormydays/stormydays_lt.jpg -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Cubemaps/stormydays/stormydays_rt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Cubemaps/stormydays/stormydays_rt.jpg -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Cubemaps/stormydays/stormydays_up.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Cubemaps/stormydays/stormydays_up.jpg -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Fonts/Raleway/Raleway-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Fonts/Raleway/Raleway-Bold.ttf -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Fonts/Raleway/Raleway-ExtraBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Fonts/Raleway/Raleway-ExtraBold.ttf -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Fonts/Raleway/Raleway-ExtraLight.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Fonts/Raleway/Raleway-ExtraLight.ttf -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Fonts/Raleway/Raleway-Heavy.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Fonts/Raleway/Raleway-Heavy.ttf -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Fonts/Raleway/Raleway-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Fonts/Raleway/Raleway-Light.ttf -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Fonts/Raleway/Raleway-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Fonts/Raleway/Raleway-Medium.ttf -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Fonts/Raleway/Raleway-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Fonts/Raleway/Raleway-Regular.ttf -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Fonts/Raleway/Raleway-SemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Fonts/Raleway/Raleway-SemiBold.ttf -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Fonts/Raleway/Raleway-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Fonts/Raleway/Raleway-Thin.ttf -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/HDR/HDR.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/HDR/HDR.hdr -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Models/player.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'None' 2 | # Material Count: 1 3 | 4 | newmtl Material.003 5 | Ns 96.078431 6 | Ka 1.000000 1.000000 1.000000 7 | Kd 0.640000 0.640000 0.640000 8 | Ks 0.500000 0.500000 0.500000 9 | Ke 0.000000 0.000000 0.000000 10 | Ni 1.000000 11 | d 1.000000 12 | illum 2 13 | -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/Hoskings_MysteryMountains.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | uniform sampler2D i_color; 4 | uniform sampler2D i_noise; 5 | uniform float uTime; 6 | uniform vec2 uResolution; 7 | 8 | in vec2 vTexCoord; 9 | out vec4 o_color; 10 | 11 | #define F+texture(i_noise,.3+p.xz*s/3e3)/(s+=s) 12 | void main() 13 | { 14 | vec4 p = vec4(vTexCoord / uResolution.xy, 1, 1) - .5, d = p, t; 15 | p.z += uTime*20.; d.y -= .4; 16 | for (float i = 1.5; i>0.; i -= .002) 17 | { 18 | float s = .9; 19 | t = F F F F F F; 20 | o_color = vec4(1, 1., .9, 9) + d.x - t*i; 21 | if (t.x>p.y*.007 + 1.3)break; 22 | p += d; 23 | } 24 | } 25 | /* 26 | void main() 27 | { 28 | vec2 p = (vTexCoord - vec2(0.5)) * 2.0; 29 | p.x *= uResolution.x / uResolution.y; 30 | 31 | // o_color = vec4(p, 0.0, 1.0); 32 | // return; 33 | 34 | // camera 35 | vec3 ro = 4.0*normalize(vec3(sin(3.0), 0.0, cos(3.0))); 36 | vec3 ta = vec3(0.0, -1.0, 0.0); 37 | mat3 ca = setCamera(ro, ta, 0.0); 38 | // ray 39 | vec3 rd = ca * normalize(vec3(p.xy, 1.5)); 40 | 41 | o_color = render(ro, rd, ivec2(vTexCoord - 3.5)); 42 | } 43 | */ -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/bgFractal.frag.glsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Shaders/bgFractal.frag.glsl -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/bgLight.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec2 vTexCoord; 4 | out vec4 o_color; 5 | 6 | void main() 7 | { 8 | o_color = vec4(0.3); 9 | } 10 | -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/blinn-phong.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout(location = 0) in vec4 aPos; 3 | layout(location = 1) in vec2 aTexCoord; 4 | layout(location = 2) in vec3 aNormal; 5 | layout(location = 3) in vec3 aTangent; 6 | layout(location = 4) in vec3 aBitangent; 7 | 8 | uniform mat4 uMVPTransform; 9 | uniform mat4 uLocalTransform; 10 | uniform mat4 uTransform; 11 | 12 | out vec3 vVertexPos; 13 | out vec2 vTexCoord; 14 | out vec3 vNormal; // to remove 15 | out mat3 TBN; 16 | 17 | void main() { 18 | gl_Position = uMVPTransform * aPos; 19 | vTexCoord = aTexCoord; 20 | 21 | vec3 N = normalize(vec3(uTransform * vec4(aNormal, 0.0))); 22 | vec3 T = normalize(vec3(uTransform * vec4(aTangent, 0.0))); 23 | // vec3 B = normalize(vec3(uTransform * vec4(aBitangent, 0.0))); 24 | T = normalize(T - dot(T, N) * N); 25 | vec3 B = cross(N, T); 26 | TBN = mat3(T, B, N); 27 | 28 | vNormal = normalize(transpose(inverse(mat3(uTransform))) * aNormal); // to remove 29 | vVertexPos = aPos.xyz; 30 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/bloom_pass_apply.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec2 vUV; 4 | 5 | uniform sampler2D uImage; 6 | uniform sampler2D uBloom; 7 | uniform float uBloomScale; 8 | 9 | out vec4 oColor; 10 | 11 | void main() 12 | { 13 | vec3 image = texture(uImage, vUV).rgb; 14 | vec3 bloom = texture(uBloom, vUV).rgb; 15 | oColor = vec4(image + uBloomScale * bloom, 1.0); 16 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/bloom_pass_blur.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec2 vUV; 4 | 5 | uniform sampler2D uImage; 6 | uniform float uIsHorizontal; 7 | uniform float uBlurScale; 8 | uniform float uTime; 9 | 10 | uniform float weight[5] = float[] (0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216); 11 | 12 | out vec4 oColor; 13 | 14 | vec2 hash22(vec2 p) { 15 | p = fract(p * vec2(5.3983, 5.4427)); 16 | p += dot(p.yx, p.xy + vec2(21.5351, 14.3137)); 17 | return fract(vec2(p.x * p.y * 95.4337, p.x * p.y * 97.597)); 18 | } 19 | 20 | void main() 21 | { 22 | float rnd = hash22(vUV + vec2(0.01 * uTime)).x; 23 | vec2 texelSize = 1.0 / textureSize(uImage, 0); // gets size of single texel 24 | vec3 result = texture(uImage, vUV).rgb * weight[0]; // current fragment's contribution 25 | vec2 blurDir = mix(vec2(1.0, 0.0), vec2(0.0, 1.0), step(0.5, uIsHorizontal)); 26 | blurDir *= mix(uBlurScale, 1.0 + ((uBlurScale - 1.0) * rnd), step(1.0, uBlurScale)); 27 | float offset = mix(texelSize.x, texelSize.y, step(0.5, uIsHorizontal)); 28 | for(int i = 1; i < 5; ++i) 29 | { 30 | result += texture(uImage, vUV + blurDir * offset * i).rgb * weight[i]; 31 | result += texture(uImage, vUV - blurDir * offset * i).rgb * weight[i]; 32 | } 33 | oColor = vec4(result, 1.0); 34 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/bloom_pass_bright.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec2 vUV; 4 | 5 | uniform sampler2D uImage; 6 | uniform float uBrightThreshold; 7 | 8 | out vec4 oColor; 9 | 10 | void main() 11 | { 12 | vec3 inputTex = texture(uImage, vUV).rgb; 13 | float luminance = dot(inputTex, vec3(0.2126, 0.7152, 0.0722)); 14 | vec4 BrightColor = mix(vec4(0.0, 0.0, 0.0, 1.0), vec4(inputTex, 1.0), step(uBrightThreshold, luminance)); 15 | oColor = BrightColor; 16 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/cubemapIrradiance.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec3 vPositionInModel; 4 | 5 | uniform samplerCube uEnvCubemap; 6 | 7 | out vec4 color; 8 | 9 | const float PI = 3.14159265359; 10 | 11 | void main() 12 | { 13 | vec3 normal = normalize(vPositionInModel); 14 | vec3 irradiance = vec3(0.0); 15 | vec3 up = vec3(0.0, 1.0, 0.0); 16 | vec3 right = cross(up, normal); 17 | up = cross(normal, right); 18 | 19 | float sampleDelta = 0.025; 20 | float nrSamples = 0.0; 21 | for (float phi = 0.0; phi < 2.0 * PI; phi += sampleDelta) 22 | { 23 | for (float theta = 0.0; theta < 0.5 * PI; theta += sampleDelta) 24 | { 25 | float sinTheta = sin(theta); 26 | float cosTheta = cos(theta); 27 | float sinPhi = sin(phi); 28 | float cosPhi = cos(phi); 29 | 30 | // spherical to cartesian (in tangent space) 31 | vec3 tangentSample = vec3(sinTheta * cosPhi, sinTheta * sinPhi, cosTheta); 32 | // tangent space to world 33 | vec3 sampleVec = tangentSample.x * right + tangentSample.y * up + tangentSample.z * normal; 34 | 35 | irradiance += texture(uEnvCubemap, sampleVec).rgb * cosTheta * sinTheta; 36 | nrSamples++; 37 | } 38 | } 39 | irradiance = PI * irradiance * (1.0 / float(nrSamples)); 40 | 41 | color = vec4(irradiance, 1.0); 42 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/cubemapIrradiance.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout(location = 0) in vec3 aPositionInModel; 4 | 5 | out vec3 vPositionInModel; 6 | 7 | uniform mat4 uClipFromModel; 8 | 9 | void main() 10 | { 11 | vPositionInModel = aPositionInModel; 12 | gl_Position = uClipFromModel * vec4(aPositionInModel, 1.0f); 13 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/debug.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec4 vColor; 4 | 5 | out vec4 color; 6 | 7 | void main() 8 | { 9 | color = vColor; 10 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/debug.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout(location = 0) in vec3 aPos; 3 | layout(location = 1) in vec4 aColor; 4 | 5 | uniform mat4 uMVP; 6 | 7 | out vec4 vColor; 8 | 9 | void main() { 10 | gl_Position = uMVP * vec4(aPos, 1.0); 11 | vColor = aColor; 12 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/debugLightAccum.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 430 core 2 | layout(location = 0) in vec4 aPos; 3 | layout(location = 1) in vec2 aTexCoord; 4 | layout(location = 2) in vec3 aNormal; 5 | 6 | uniform mat4 uClipFromModel; 7 | uniform mat4 uWorldFromModel; 8 | 9 | out vec3 vVertexPos; 10 | out vec2 vTexCoord; 11 | 12 | void main() { 13 | vec4 vertexInModel = vec4(aPos.xyz, 1.0); 14 | gl_Position = uClipFromModel * vertexInModel; 15 | vVertexPos = (uWorldFromModel * vertexInModel).xyz; 16 | vTexCoord = aTexCoord; 17 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/debugNormals.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 color; 3 | 4 | void main() 5 | { 6 | color = vec4(1.0f, 1.0f, 0.0f, 1.0f); 7 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/debugNormals.geom.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (triangles) in; 3 | layout (line_strip, max_vertices = 6) out; 4 | 5 | in VS_OUT { 6 | vec3 normal; 7 | } gs_in[]; 8 | 9 | const float MAGNITUDE = 1.0f; 10 | 11 | void GenerateLine(int index) 12 | { 13 | gl_Position = gl_in[index].gl_Position; 14 | EmitVertex(); 15 | gl_Position = gl_in[index].gl_Position + vec4(gs_in[index].normal, 0.0f) * MAGNITUDE; 16 | EmitVertex(); 17 | EndPrimitive(); 18 | } 19 | 20 | void main() 21 | { 22 | GenerateLine(0); // First vertex normal 23 | GenerateLine(1); // Second vertex normal 24 | GenerateLine(2); // Third vertex normal 25 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/debugNormals.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 a_position; 3 | layout (location = 2) in vec3 a_normal; 4 | 5 | out VS_OUT { 6 | vec3 normal; 7 | } vs_out; 8 | 9 | uniform mat4 u_projection; 10 | uniform mat4 u_MVP; 11 | uniform mat4 u_normalMatrix4x4; 12 | 13 | void main() 14 | { 15 | gl_Position = u_MVP * vec4(a_position, 1.0f); 16 | mat3 normalMatrix = mat3(u_normalMatrix4x4); 17 | vs_out.normal = normalize(vec3(u_projection * vec4(normalMatrix * a_normal, 1.0))); 18 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/debugQuadDepthPrepass.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 430 core 2 | 3 | uniform float uNear; 4 | uniform float uFar; 5 | uniform sampler2D uTexture; 6 | 7 | in vec2 vUV; 8 | out vec4 fragColor; 9 | 10 | // Need to liuNearize the depth because we are using the projection 11 | float LinearizeDepth(float depth) 12 | { 13 | float z = depth * 2.0 - 1.0; 14 | return (2.0 * uNear * uFar) / (uFar + uNear - z * (uFar - uNear)); 15 | } 16 | 17 | void main() { 18 | vec3 tex = texture(uTexture, vUV).rgb; 19 | float depth = LinearizeDepth(tex.r)/uFar; 20 | // tex = pow(tex, vec3(0.45)); 21 | fragColor = vec4(vec3(depth), 1.0); 22 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/debugQuadDepthPrepass.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 430 core 2 | 3 | layout(location = 0) in vec3 aPos; 4 | layout(location = 1) in vec2 aUV; 5 | 6 | out vec2 vUV; 7 | 8 | void main() { 9 | gl_Position = vec4(aPos, 1.0); 10 | vUV = aUV; 11 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/debugQuadLightCulling.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 430 core 2 | 3 | layout(location = 0) in vec3 aPos; 4 | layout(location = 1) in vec2 aUV; 5 | 6 | out vec2 vUV; 7 | 8 | void main() { 9 | gl_Position = vec4(aPos, 1.0); 10 | vUV = aUV; 11 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/depth.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | void main() { 4 | // We are not drawing anything to the screen, so nothing to be done here 5 | } 6 | -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/depth.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | layout(location = 0) in vec4 aPos; 4 | layout(location = 1) in vec2 aTexCoord; 5 | layout(location = 2) in vec3 aNormal; 6 | 7 | uniform mat4 uScreenFromModel; 8 | 9 | void main() { 10 | gl_Position = uScreenFromModel * aPos; 11 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/dof_pass_apply.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec2 vUV; 4 | 5 | uniform sampler2D uImage; 6 | uniform sampler2D uDOF; 7 | uniform sampler2D uDepth; 8 | uniform float uDOFShow; 9 | uniform float uDOFPoint; 10 | uniform float uDOFRange; 11 | 12 | out vec4 oColor; 13 | 14 | float depthToMask(float depth) 15 | { 16 | float d = clamp(abs(depth - uDOFPoint) / uDOFRange, 0.0f, 1.0f); 17 | return smoothstep(0.5, 1.0, d); 18 | } 19 | 20 | void main() 21 | { 22 | float depth = texture(uDepth, vUV).g; 23 | float dofMask = depthToMask(depth); 24 | vec3 image = texture(uImage, vUV).rgb; 25 | vec3 dof = texture(uDOF, vUV).rgb; 26 | oColor = vec4(uDOFShow * vec3(dofMask, 0.0, 0.0) + mix(image, dof, dofMask), 1.0); 27 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/dof_pass_bokeh.frag.glsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Shaders/dof_pass_bokeh.frag.glsl -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/equiHdr.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec3 vPositionInModel; 4 | 5 | uniform sampler2D uEquirectangularMap; 6 | 7 | layout(location = 0) out vec4 color; 8 | layout(location = 1) out vec4 normal; 9 | 10 | const vec2 invAtan = vec2(0.1591, 0.3183); 11 | 12 | vec2 SampleSphericalMap(vec3 v) 13 | { 14 | vec2 uv = vec2(atan(v.z, v.x), asin(v.y)); 15 | uv *= invAtan; 16 | uv += 0.5; 17 | return uv; 18 | } 19 | 20 | void main() 21 | { 22 | vec2 uv = SampleSphericalMap(normalize(vPositionInModel)); // make sure to normalize localPos 23 | color.rgb = texture(uEquirectangularMap, uv).rgb; 24 | normal = vec4(0.0); 25 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/equiHdr.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout(location = 0) in vec3 aPositionInModel; 4 | 5 | out vec3 vPositionInModel; 6 | 7 | uniform mat4 uClipFromModel; 8 | 9 | void main() 10 | { 11 | vPositionInModel = aPositionInModel; 12 | gl_Position = uClipFromModel * vec4(aPositionInModel, 1.0f); 13 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/equiToCubemap.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec3 vPositionInModel; 4 | 5 | uniform sampler2D uEquirectangularMap; 6 | 7 | out vec4 color; 8 | 9 | const vec2 invAtan = vec2(0.1591, 0.3183); 10 | 11 | vec2 SampleSphericalMap(vec3 v) 12 | { 13 | vec2 uv = vec2(atan(v.z, v.x), asin(v.y)); 14 | uv *= invAtan; 15 | uv += 0.5; 16 | return uv; 17 | } 18 | 19 | void main() 20 | { 21 | vec2 uv = SampleSphericalMap(normalize(vPositionInModel)); // make sure to normalize localPos 22 | color.rgb = texture(uEquirectangularMap, uv).rgb; 23 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/equiToCubemap.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout(location = 0) in vec3 aPositionInModel; 4 | 5 | out vec3 vPositionInModel; 6 | 7 | uniform mat4 uClipFromModel; 8 | 9 | void main() 10 | { 11 | vPositionInModel = aPositionInModel; 12 | gl_Position = uClipFromModel * vec4(aPositionInModel, 1.0f); 13 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/evsm.blur.frag.glsl: -------------------------------------------------------------------------------- 1 | // based on: http://mynameismjp.wordpress.com/2013/09/10/shadow-maps/ 2 | // based on: https://github.com/bartwronski/CSharpRenderer 3 | 4 | #version 400 core 5 | 6 | in vec2 vUV; 7 | 8 | uniform sampler2D uEVSMap; 9 | uniform int uIsHorizontal; 10 | 11 | out vec4 oColor; 12 | 13 | const float gaussianWeights[6] = float[] ( 14 | 0.12801535629105684, 15 | 0.12299580237376932, 16 | 0.10908749075572069, 17 | 0.08931328345781858, 18 | 0.06750152753344589, 19 | 0.047094217733717074 20 | ); 21 | 22 | void main() 23 | { 24 | vec4 sum = vec4(0.0); 25 | 26 | for (int x = -5; x < 6; ++x) 27 | { 28 | // unoptimal 29 | // TDOO: bilinear filtering 30 | sum += gaussianWeights[abs(x)] * textureLodOffset(uEVSMap, vUV, 0, 31 | 1 == uIsHorizontal ? ivec2(x, 0) : ivec2(0, x) 32 | ); 33 | } 34 | 35 | oColor = sum; 36 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/evsm.resolve.frag.glsl: -------------------------------------------------------------------------------- 1 | // Based on: http://mynameismjp.wordpress.com/2013/09/10/shadow-maps/ 2 | // Based on: https://github.com/bartwronski/CSharpRenderer 3 | 4 | #version 400 core 5 | 6 | in vec2 vUV; 7 | 8 | uniform sampler2D uDepth; 9 | 10 | out vec4 oColor; 11 | 12 | #pragma include "evsm.inc.glsl" 13 | 14 | void main() 15 | { 16 | vec4 depth = textureGather(uDepth, vUV, 0); 17 | 18 | vec2 warpedDepth[4]; 19 | warpedDepth[0] = WarpDepth(depth.x); 20 | warpedDepth[1] = WarpDepth(depth.y); 21 | warpedDepth[2] = WarpDepth(depth.z); 22 | warpedDepth[3] = WarpDepth(depth.w); 23 | 24 | vec4 outputEVSM[4]; 25 | outputEVSM[0] = vec4(warpedDepth[0], warpedDepth[0] * warpedDepth[0]); 26 | outputEVSM[1] = vec4(warpedDepth[1], warpedDepth[1] * warpedDepth[1]); 27 | outputEVSM[2] = vec4(warpedDepth[2], warpedDepth[2] * warpedDepth[2]); 28 | outputEVSM[3] = vec4(warpedDepth[3], warpedDepth[3] * warpedDepth[3]); 29 | 30 | vec4 finalOutput = outputEVSM[0] + outputEVSM[1] + outputEVSM[2] + outputEVSM[3]; 31 | finalOutput *= 0.25f; 32 | 33 | oColor = finalOutput; 34 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/fgLight.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | uniform sampler2D i_color; 4 | 5 | in vec2 vTexCoord; 6 | out vec4 color; 7 | 8 | void main() 9 | { 10 | color = vec4(pow(texture(i_color, vTexCoord).rgb, vec3(1.0/2.2)), 1.0); 11 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/hdr.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 430 core 2 | 3 | in vec2 vUV; 4 | 5 | uniform sampler2D uHdrBuffer; 6 | 7 | uniform float uExposure; 8 | 9 | out vec4 fragColor; 10 | 11 | // Uses Reinhard tonemapping https://www.cs.utah.edu/~reinhard/cdrom/tonemap.pdf 12 | 13 | // linear white point 14 | const float W = 1.2; 15 | const float T2 = 7.5; 16 | 17 | float filmic_reinhard_curve(float x) 18 | { 19 | float q = (T2 * T2 + 1.0) * x * x; 20 | return q / (q + x + T2 * T2); 21 | } 22 | 23 | vec3 filmic_reinhard(vec3 x) 24 | { 25 | float w = filmic_reinhard_curve(W); 26 | return vec3( 27 | filmic_reinhard_curve(x.r), 28 | filmic_reinhard_curve(x.g), 29 | filmic_reinhard_curve(x.b)) / w; 30 | } 31 | 32 | void main() 33 | { 34 | vec3 color = texture(uHdrBuffer, vUV).rgb; 35 | vec3 result = filmic_reinhard(uExposure * color); 36 | // vec3 result = vec3(1.0) - exp(-color * uExposure); 37 | // vec3 result = vec3(1.0) - exp(-color * 2.0); 38 | 39 | fragColor = vec4(result, 1.0); 40 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/hdr.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 430 core 2 | 3 | layout(location = 0) in vec3 aPosition; 4 | layout(location = 1) in vec2 aUV; 5 | 6 | out vec2 vUV; 7 | 8 | void main() { 9 | gl_Position = vec4(aPosition, 1.0); 10 | vUV = aUV; 11 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/instanced.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout(location = 0) in vec3 aVertexInInstance; 4 | layout(location = 1) in vec2 aTexCoord; 5 | layout(location = 3) in mat4 aModelFromInstance; 6 | 7 | out vec2 vTexCoord; 8 | out float vInstanceID; 9 | 10 | uniform mat4 uScreenFromView; 11 | uniform mat4 uViewFromWorld; 12 | uniform mat4 uWorldFromModel; 13 | uniform float uTime; 14 | 15 | void main() 16 | { 17 | vec4 VertexInInstance = vec4(aVertexInInstance, 1.0); 18 | vec4 ParticleCenterInWorld = uWorldFromModel * aModelFromInstance * vec4(0.0, 0.0, 0.0, 1.0); 19 | 20 | vec3 CameraRightInWorld = vec3(uViewFromWorld[0][0], uViewFromWorld[1][0], uViewFromWorld[2][0]); 21 | vec3 CameraUpInWorld = vec3(uViewFromWorld[0][1], uViewFromWorld[1][1], uViewFromWorld[2][1]); 22 | vec2 BillboardSize = vec2(aModelFromInstance[0][0], aModelFromInstance[1][1]); 23 | vec4 VertexInWorld = ParticleCenterInWorld 24 | + vec4(CameraRightInWorld, 0.0) * aVertexInInstance.x * BillboardSize.x 25 | + vec4(CameraUpInWorld, 0.0) * aVertexInInstance.y * BillboardSize.y; 26 | 27 | vec4 VertexInScreen = uScreenFromView * uViewFromWorld * VertexInWorld; 28 | 29 | gl_Position = VertexInScreen; 30 | vTexCoord = aTexCoord; 31 | vInstanceID = gl_InstanceID; 32 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/linearizeDepth.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec2 vUV; 4 | 5 | uniform sampler2D uDepth; 6 | uniform float uNear; 7 | uniform float uFar; 8 | 9 | out vec4 oColor; 10 | 11 | float LinearizeDepth(float depth) { 12 | return -uFar * uNear / (depth * (uFar - uNear) - uFar); 13 | } 14 | 15 | void main() 16 | { 17 | float depth = texture(uDepth, vUV).r; 18 | float linDepth = LinearizeDepth(depth); 19 | oColor = vec4(depth, linDepth, linDepth / uFar, 1.0); 20 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/motionblur.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec2 vUV; 4 | 5 | uniform sampler2D uImage; 6 | uniform sampler2D uDepth; 7 | uniform mat4 uWorldFromView; 8 | uniform mat4 uPrevClipFromWorld; 9 | uniform float uScale; 10 | 11 | out vec4 oColor; 12 | 13 | void main() 14 | { 15 | float depth = texture(uDepth, vUV).g; 16 | vec2 screenPos = vUV * vec2(2.0) - vec2(1.0); 17 | vec4 invCoords = uWorldFromView * vec4(screenPos, depth, 1.0); 18 | 19 | vec4 coordsPrevFrame = uPrevClipFromWorld * invCoords; 20 | coordsPrevFrame.xyz /= coordsPrevFrame.www; 21 | 22 | vec2 blurDirection = coordsPrevFrame.xy * uScale * 0.5; 23 | 24 | vec4 result = texture(uImage, vUV); 25 | int nSamples = 20; 26 | float weight = 1.0; 27 | for (int i = 1; i < nSamples; ++i) 28 | { 29 | // get offset in range [-0.5, 0.5]: 30 | float t = float(i) / float(nSamples - 1); 31 | float sampleWeight = smoothstep(0.0, 1.0, 1.0 - abs(t * 2.0 - 1.0)); 32 | vec2 offset = blurDirection * (t - 0.5); 33 | 34 | // sample & add to result: 35 | result += sampleWeight * texture(uImage, vUV + offset); 36 | weight += sampleWeight; 37 | } 38 | 39 | result /= weight; 40 | 41 | oColor = vec4(result.rgb, 1.0); 42 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/normals.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec3 vVertexPos; 4 | in vec2 vTexCoord; 5 | in vec3 vNormal; 6 | 7 | layout(location = 0) out vec4 color; 8 | 9 | void main() { 10 | color.xyz = 0.5 + 0.5 * vNormal; 11 | color.w = 1.0; 12 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/normals.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout(location = 0) in vec4 aPos; 3 | layout(location = 1) in vec2 aTexCoord; 4 | layout(location = 2) in vec3 aNormal; 5 | 6 | uniform mat4 uMVPTransform; 7 | uniform mat4 uTransform; 8 | 9 | out vec3 vVertexPos; 10 | out vec2 vTexCoord; 11 | out vec3 vNormal; 12 | 13 | void main() { 14 | gl_Position = uMVPTransform * aPos; 15 | vTexCoord = aTexCoord; 16 | vNormal = normalize(transpose(inverse(mat3(uTransform))) * aNormal); 17 | vVertexPos = aPos.xyz; 18 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/pass.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | uniform sampler2D i_color; 4 | 5 | in vec2 vTexCoord; 6 | out vec4 color; 7 | 8 | void main() 9 | { 10 | color = texture(uv, i_color); 11 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/postprocessCommon.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout(location = 0) in vec3 aPos; 3 | layout(location = 1) in vec2 aTexCoord; 4 | 5 | out vec2 vTexCoord; 6 | 7 | void main(){ 8 | gl_Position = vec4(aPos, 1.0f); 9 | vTexCoord = aTexCoord; 10 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/prefilterCubemap.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout(location = 0) in vec3 aPositionInModel; 4 | 5 | out vec3 vPositionInModel; 6 | 7 | uniform mat4 uClipFromModel; 8 | 9 | void main() 10 | { 11 | vPositionInModel = aPositionInModel; 12 | gl_Position = uClipFromModel * vec4(aPositionInModel, 1.0f); 13 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/shadowMap.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | in vec4 vPosition; 4 | 5 | out vec4 oColor; 6 | 7 | void main() { 8 | float depth = vPosition.z / vPosition.w; 9 | depth = depth * 0.5 + 0.5; 10 | oColor = vec4(depth, 0.0, 0.0, 0.0); 11 | } 12 | -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/shadowMap.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | layout(location = 0) in vec4 aPos; 4 | 5 | uniform mat4 uClipFromModel; 6 | 7 | out vec4 vPosition; 8 | 9 | void main() { 10 | vPosition = uClipFromModel * aPos; 11 | gl_Position = vPosition; 12 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/skybox.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec3 vUV; 4 | 5 | uniform samplerCube uCubemap; 6 | uniform vec4 uTint; 7 | 8 | layout(location = 0) out vec4 color; 9 | layout(location = 1) out vec4 normal; 10 | 11 | void main() 12 | { 13 | color = vec4(uTint.rgb * texture(uCubemap, vUV).rgb, 1.0); 14 | normal = vec4(0.0); 15 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/skybox.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout(location = 0) in vec3 aPositionInModel; 4 | 5 | out vec3 vUV; 6 | 7 | uniform mat4 uClipFromWorld; 8 | 9 | void main() 10 | { 11 | vUV = normalize(aPositionInModel); 12 | vec4 pos = uClipFromWorld * vec4(aPositionInModel, 1.0f); 13 | gl_Position = pos.xyww; 14 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/spritesheet.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | uniform sampler2D i_color; 4 | uniform float uTime; 5 | uniform vec2 uSubImages; 6 | uniform vec4 uColor; 7 | uniform float uStartFrame; 8 | uniform float uSpeed; 9 | 10 | in vec2 vUV; 11 | out vec4 color; 12 | 13 | vec2 SubUV(vec2 uv, vec2 subImages, float frame) 14 | { 15 | vec2 resRcp = vec2(1.0) / subImages; 16 | float frameInt = frame - fract(frame); 17 | float uvTileX = mod(frameInt, subImages.x); 18 | float uvTileY = floor(frameInt * resRcp.x); 19 | 20 | vec2 uvTile = (vec2(uvTileX, uvTileY) + uv) * resRcp; 21 | return uvTile; 22 | } 23 | 24 | void main() 25 | { 26 | float frame = uStartFrame + uSubImages.x * uSubImages.y * fract(-1.0 * uSpeed * uTime); 27 | 28 | vec2 uvTile0 = SubUV(vUV, vec2(uSubImages), frame); 29 | vec2 uvTile1 = SubUV(vUV, vec2(uSubImages), frame + 1); 30 | 31 | vec4 tex0 = texture(i_color, uvTile0); 32 | vec4 tex1 = texture(i_color, uvTile1); 33 | 34 | vec4 tex = mix(tex0, tex1, fract(frame)); 35 | 36 | color = uColor * tex; 37 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/spritesheet.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout(location = 0) in vec3 aPos; 4 | layout(location = 1) in vec2 aUV; 5 | 6 | out vec2 vUV; 7 | 8 | uniform mat4 uP; 9 | uniform mat4 uMV; 10 | uniform vec2 uScale; 11 | 12 | void main() 13 | { 14 | vec4 p = vec4(aPos, 1.0); 15 | p = uP * (uMV * vec4(0.0, 0.0, 0.0, 1.0) 16 | + vec4(p.x, p.y, 0.0, 0.0) 17 | * vec4(uScale, 1.0, 1.0)); 18 | 19 | gl_Position = p; 20 | vUV = aUV; 21 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/text2D.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec2 v_texCoords; 4 | 5 | out vec4 color; 6 | 7 | uniform sampler2D u_texSampler; 8 | uniform vec4 u_textColor; 9 | 10 | void main() 11 | { 12 | vec4 sampled = vec4(1.0, 1.0, 1.0, texture(u_texSampler, v_texCoords).r); 13 | color = u_textColor * sampled; 14 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/text2D.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout (location = 0) in vec4 a_vertexPos; 4 | layout (location = 1) in vec2 a_texCoords; 5 | 6 | out vec2 v_texCoords; 7 | 8 | uniform mat4 u_projection; 9 | uniform vec4 u_position; 10 | 11 | void main() 12 | { 13 | gl_Position = u_projection * (u_position + a_vertexPos); 14 | v_texCoords = a_texCoords; 15 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/unlit.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | uniform sampler2D uTexture; 4 | 5 | uniform vec4 uColor; 6 | 7 | in vec3 vVertexPos; 8 | in vec2 vTexCoord; 9 | 10 | layout(location = 0) out vec4 color; 11 | 12 | void main() 13 | { 14 | vec4 texDiffuse = texture(uTexture, vTexCoord); 15 | color = texDiffuse; 16 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/unlit.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout(location = 0) in vec4 aPos; 3 | layout(location = 1) in vec2 aTexCoord; 4 | layout(location = 2) in vec3 aNormal; 5 | 6 | uniform mat4 uScreenFromModel; 7 | 8 | out vec3 vVertexPos; 9 | out vec2 vTexCoord; 10 | 11 | void main() 12 | { 13 | gl_Position = uScreenFromModel * aPos; 14 | vTexCoord = aTexCoord; 15 | vVertexPos = aPos.xyz; 16 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Shaders/vinette.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | uniform sampler2D i_color; 4 | 5 | in vec2 vTexCoord; 6 | 7 | out vec4 color; 8 | 9 | void main(){ 10 | vec4 texColor = texture(i_color, vTexCoord); 11 | float distFromCenter = length((vTexCoord - vec2(0.5, 0.5)) * 1.43f); 12 | color = texColor * (1.0 - distFromCenter * distFromCenter); 13 | } -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Textures/RGBANoise256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Textures/RGBANoise256x256.png -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Textures/splash_00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Textures/splash_00.png -------------------------------------------------------------------------------- /PolyEngine/Engine/Res/Textures/splash_00.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PolyEngineTeam/PolyEngine/573c453e9d1ae0a351ad14410595ff844e3b4620/PolyEngine/Engine/Res/Textures/splash_00.tga -------------------------------------------------------------------------------- /PolyEngine/Engine/Src/AI/PathfindingComponent.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | using namespace Poly; 6 | 7 | RTTI_DEFINE_COMPONENT(::Poly::PathfindingComponent) 8 | 9 | void Poly::PathfindingComponent::SetDestination(const Vector& pos) 10 | { 11 | if(!CurentDestination.HasValue() || CurentDestination.Value() != pos) 12 | RecalculateRequested = true; 13 | 14 | CurentDestination = pos; 15 | } 16 | 17 | void Poly::PathfindingComponent::ResetDestination() 18 | { 19 | CurentDestination = Optional(); 20 | CalculatedPath.Clear(); 21 | RecalculateRequested = false; 22 | } 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /PolyEngine/Engine/Src/AI/PathfindingSystem.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Poly 6 | { 7 | class Scene; 8 | 9 | namespace PathfindingSystem 10 | { 11 | ENGINE_DLLEXPORT void UpdatePhase(Scene* world); 12 | }; 13 | } 14 | -------------------------------------------------------------------------------- /PolyEngine/Engine/Src/Audio/OpenALDevice.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include