125 lines
3.1 KiB
C++
125 lines
3.1 KiB
C++
//
|
|
// Created by sfd on 25-11-29.
|
|
//
|
|
|
|
#ifndef EDITORLAYER_H
|
|
#define EDITORLAYER_H
|
|
|
|
#include "Prism.h"
|
|
#include "Prism/Editor/SceneHierachyPanel.h"
|
|
|
|
namespace Prism
|
|
{
|
|
class EditorLayer : public Layer
|
|
{
|
|
public:
|
|
EditorLayer();
|
|
virtual ~EditorLayer();
|
|
|
|
virtual void OnAttach() override;
|
|
virtual void OnDetach() override;
|
|
virtual void OnUpdate(TimeStep deltaTime) override;
|
|
virtual void OnImGuiRender() override;
|
|
virtual void OnEvent(Event& e) override;
|
|
|
|
private:
|
|
bool OnKeyPressedEvent(KeyPressedEvent& e);
|
|
bool OnMouseButtonPressedEvent(MouseButtonPressedEvent& e);
|
|
|
|
void ShowBoundingBoxes(bool show, bool onTop = false);
|
|
|
|
private:
|
|
std::pair<float, float> GetMouseViewportSpace() const;
|
|
std::pair<glm::vec3, glm::vec3> CastRay(float mx, float my);
|
|
|
|
private:
|
|
Scope<SceneHierarchyPanel> m_SceneHierarchyPanel;
|
|
|
|
Ref<Scene> m_Scene;
|
|
Ref<Scene> m_SphereScene;
|
|
Ref<Scene> m_ActiveScene;
|
|
|
|
Entity* m_MeshEntity = nullptr;
|
|
|
|
Ref<Mesh> m_PlaneMesh;
|
|
Ref<Material> m_SphereBaseMaterial;
|
|
|
|
Ref<Material> m_MeshMaterial;
|
|
|
|
std::vector<Ref<MaterialInstance>> m_MetalSphereMaterialInstances;
|
|
std::vector<Ref<MaterialInstance>> m_DielectricSphereMaterialInstances;
|
|
|
|
|
|
// Imguizmo
|
|
glm::vec2 m_ViewportBounds[2] = {};
|
|
int m_GizmoType = -1; // -1 = no gizmo
|
|
float m_SnapValue = 0.5f;
|
|
|
|
struct SelectedSubmesh
|
|
{
|
|
Submesh* Mesh;
|
|
float Distance;
|
|
};
|
|
std::vector<SelectedSubmesh> m_SelectedSubmeshes;
|
|
glm::mat4* m_CurrentlySelectedTransform = nullptr;
|
|
|
|
// configure button
|
|
bool m_AllowViewportCameraEvents = false;
|
|
bool m_DrawOnTopBoundingBoxes = false;
|
|
|
|
bool m_UIShowBoundingBoxes = false;
|
|
bool m_UIShowBoundingBoxesOnTop = false;
|
|
|
|
|
|
struct AlbedoInput
|
|
{
|
|
glm::vec3 Color = { 0.972f, 0.96f, 0.915f }; // Silver, from https://docs.unrealengine.com/en-us/Engine/Rendering/Materials/PhysicallyBased
|
|
Ref<Texture2D> TextureMap;
|
|
bool SRGB = true;
|
|
bool UseTexture = false;
|
|
};
|
|
AlbedoInput m_AlbedoInput;
|
|
|
|
struct NormalInput
|
|
{
|
|
Ref<Texture2D> TextureMap;
|
|
bool UseTexture = false;
|
|
};
|
|
NormalInput m_NormalInput;
|
|
|
|
struct MetalnessInput
|
|
{
|
|
float Value = 1.0f;
|
|
Ref<Texture2D> TextureMap;
|
|
bool UseTexture = false;
|
|
};
|
|
MetalnessInput m_MetalnessInput;
|
|
|
|
struct RoughnessInput
|
|
{
|
|
float Value = 0.5f;
|
|
Ref<Texture2D> TextureMap;
|
|
bool UseTexture = false;
|
|
};
|
|
RoughnessInput m_RoughnessInput;
|
|
|
|
|
|
// PBR params
|
|
bool m_RadiancePrefilter = false;
|
|
|
|
float m_EnvMapRotation = 0.0f;
|
|
|
|
enum class SceneType : uint32_t
|
|
{
|
|
Spheres = 0, Model = 1
|
|
};
|
|
SceneType m_SceneType;
|
|
|
|
// Editor resources
|
|
Ref<Texture2D> m_CheckerboardTex;
|
|
};
|
|
}
|
|
|
|
|
|
#endif //EDITORLAYER_H
|