mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-27 16:17:12 +03:00
Various fixes:
- removal of entity crash - play mode corrupt scene graph - Added dither effect on selected entity
This commit is contained in:
@@ -19,11 +19,12 @@
|
||||
#include <src/Rendering/Renderer.h>
|
||||
#include "src/UI/UserInterface.h"
|
||||
#include "src/NewEditor.h"
|
||||
#include <src/Scene/Components/BSPBrushComponent.h>
|
||||
|
||||
void OpenProject()
|
||||
{
|
||||
// Parse the project and load it.
|
||||
std::string projectPath = Nuake::FileDialog::OpenFile(".project");
|
||||
std::string projectPath = Nuake::FileDialog::OpenFile("Project file|*.project;");
|
||||
|
||||
Nuake::FileSystem::SetRootDirectory(projectPath + "/../");
|
||||
Ref<Nuake::Project> project = Nuake::Project::New();
|
||||
@@ -55,9 +56,11 @@ int main()
|
||||
Ref<Nuake::Texture> lightTexture = Nuake::TextureManager::Get()->GetTexture("resources/Icons/Gizmo/Light.png");
|
||||
Ref<Nuake::Texture> camTexture = Nuake::TextureManager::Get()->GetTexture("resources/Icons/Gizmo/Camera.png");
|
||||
Ref<Nuake::Shader> GuizmoShader = Nuake::ShaderManager::GetShader("resources/Shaders/gizmo.shader");
|
||||
Ref<Nuake::Shader> ditherShader = Nuake::ShaderManager::GetShader("resources/Shaders/dither.shader");
|
||||
|
||||
Nuake::NewEditor newEditor = Nuake::NewEditor();
|
||||
//Nuake::NewEditor newEditor = Nuake::NewEditor();
|
||||
|
||||
// Register shaders
|
||||
while (!Nuake::Engine::GetCurrentWindow()->ShouldClose())
|
||||
{
|
||||
Nuake::RenderCommand::Clear();
|
||||
@@ -115,8 +118,23 @@ int main()
|
||||
}
|
||||
|
||||
glEnable(GL_CULL_FACE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
GuizmoShader->Unbind();
|
||||
|
||||
ditherShader->Bind();
|
||||
ditherShader->SetUniformMat4f("u_View", Nuake::Engine::GetCurrentScene()->m_EditorCamera->GetTransform());
|
||||
ditherShader->SetUniformMat4f("u_Projection", Nuake::Engine::GetCurrentScene()->m_EditorCamera->GetPerspective());
|
||||
ditherShader->SetUniform1f("u_Time", Nuake::Engine::GetTime());
|
||||
ditherShader->SetUniform4f("u_Color", 252.0 / 255.0, 3.0 / 255.0, 65.0 / 255.0, 1.0);
|
||||
|
||||
if (editor.m_IsEntitySelected && editor.m_SelectedEntity.HasComponent<Nuake::BSPBrushComponent>())
|
||||
{
|
||||
for (auto& m : editor.m_SelectedEntity.GetComponent<Nuake::BSPBrushComponent>().Meshes)
|
||||
Nuake::Renderer::SubmitMesh(m, editor.m_SelectedEntity.GetComponent<Nuake::TransformComponent>().GetTransform());
|
||||
|
||||
Nuake::Renderer::Flush(ditherShader, true);
|
||||
}
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
sceneFramebuffer->Unbind();
|
||||
|
||||
|
||||
32
Editor/resources/Shaders/dither.shader
Normal file
32
Editor/resources/Shaders/dither.shader
Normal file
@@ -0,0 +1,32 @@
|
||||
#shader vertex
|
||||
#version 460 core
|
||||
|
||||
|
||||
layout(location = 0) in vec3 VertexPosition;
|
||||
|
||||
uniform mat4 u_Projection;
|
||||
uniform mat4 u_View;
|
||||
uniform mat4 u_Model;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_Projection * u_View * u_Model * vec4(VertexPosition, 1.0f);
|
||||
}
|
||||
|
||||
#shader fragment
|
||||
#version 460 core
|
||||
|
||||
uniform vec4 u_Color;
|
||||
uniform float u_Time;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (mod(gl_FragCoord.x + gl_FragCoord.y, 4.0) < 2.0)
|
||||
discard;
|
||||
|
||||
vec4 finalColor = u_Color;
|
||||
finalColor.a = (sin(u_Time * 4.0) + 1.0) / 4.0 + 0.1;
|
||||
FragColor = finalColor;
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ layout(location = 0) in vec3 VertexPosition;
|
||||
uniform mat4 u_Projection;
|
||||
uniform mat4 u_View;
|
||||
uniform mat4 u_Model;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_Projection * u_View * u_Model * vec4(VertexPosition, 1.0f);
|
||||
@@ -16,9 +17,13 @@ void main()
|
||||
#version 460 core
|
||||
|
||||
uniform vec4 u_Color;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
if(mod(gl_FragCoord.x / 4.0 + gl_FragCoord.y / 4.0, 4.0) < 2.0)
|
||||
discard;
|
||||
|
||||
FragColor = u_Color;
|
||||
}
|
||||
@@ -213,7 +213,7 @@ float ShadowCalculation(Light light, vec3 FragPos, vec3 normal)
|
||||
int shadowmap = -1;
|
||||
|
||||
// Get CSM depth
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
float CSMDepth = light.CascadeDepth[i] ;
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#include "UIComponents/Viewport.h"
|
||||
#include <src/Resource/Prefab.h>
|
||||
#include <src/Scene/Components/PrefabComponent.h>
|
||||
#include <src/Rendering/Shaders/ShaderManager.h>
|
||||
#include "src/Rendering/Renderer.h"
|
||||
|
||||
namespace Nuake {
|
||||
Ref<UI::UserInterface> userInterface;
|
||||
@@ -224,7 +226,6 @@ namespace Nuake {
|
||||
if (ImGui::Selectable("Remove")) {
|
||||
|
||||
QueueDeletion = e;
|
||||
open = false;
|
||||
}
|
||||
|
||||
if (ImGui::Selectable("Move to root"))
|
||||
@@ -359,7 +360,7 @@ namespace Nuake {
|
||||
m_SelectedEntity = scene->GetAllEntities().at(0);
|
||||
|
||||
QueueDeletion = Entity{ (entt::entity)0, scene.get() };
|
||||
ImGui::TreePop();
|
||||
//ImGui::TreePop();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -453,7 +454,8 @@ namespace Nuake {
|
||||
ImGui::Separator();
|
||||
}
|
||||
|
||||
if (m_SelectedEntity.HasComponent<MeshComponent>()) {
|
||||
if (m_SelectedEntity.HasComponent<MeshComponent>())
|
||||
{
|
||||
std::string icon = ICON_FA_MALE;
|
||||
if (ImGui::CollapsingHeader((icon + " " + "Mesh").c_str(), ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
@@ -623,6 +625,7 @@ namespace Nuake {
|
||||
}
|
||||
if (m_SelectedEntity.HasComponent<QuakeMapComponent>())
|
||||
{
|
||||
|
||||
std::string icon = ICON_FA_BROOM;
|
||||
if (ImGui::CollapsingHeader((icon + " " + "Quake map").c_str(), ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
@@ -1110,7 +1113,7 @@ namespace Nuake {
|
||||
void OpenProject()
|
||||
{
|
||||
// Parse the project and load it.
|
||||
std::string projectPath = FileDialog::OpenFile(".project");
|
||||
std::string projectPath = FileDialog::OpenFile("Project file\0*.project");
|
||||
|
||||
FileSystem::SetRootDirectory(projectPath + "/../");
|
||||
Ref<Project> project = Project::New();
|
||||
@@ -1124,12 +1127,6 @@ namespace Nuake {
|
||||
Engine::LoadProject(project);
|
||||
|
||||
pInterface.m_CurrentProject = project;
|
||||
// Create new interface named test.
|
||||
//userInterface = UI::UserInterface::New("test");
|
||||
|
||||
|
||||
// Set current interface running.
|
||||
//Engine::GetCurrentScene()->AddInterface(userInterface);
|
||||
}
|
||||
|
||||
void OpenScene()
|
||||
@@ -1138,7 +1135,8 @@ namespace Nuake {
|
||||
std::string projectPath = FileDialog::OpenFile(".scene");
|
||||
|
||||
Ref<Scene> scene = Scene::New();
|
||||
if (!scene->Deserialize(FileSystem::ReadFile(projectPath, true))) {
|
||||
if (!scene->Deserialize(FileSystem::ReadFile(projectPath, true)))
|
||||
{
|
||||
Logger::Log("Error failed loading scene: " + projectPath, CRITICAL);
|
||||
return;
|
||||
}
|
||||
@@ -1159,15 +1157,16 @@ namespace Nuake {
|
||||
|
||||
if (ImGui::BeginPopupModal("Welcome", NULL, flags))
|
||||
{
|
||||
ImGui::Text("Welcome to");
|
||||
ImGui::Text("Nuake engine");
|
||||
ImGui::Text("Welcome to Nuake Engine");
|
||||
ImGui::Text("Developement build");
|
||||
|
||||
ImGui::Text("Would you like to");
|
||||
if (ImGui::Button("Start a new project"))
|
||||
ImGui::Text("This project is still very early in developement and is not stable!");
|
||||
if (ImGui::Button("New Project"))
|
||||
NewProject();
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Open a project")) {
|
||||
if (ImGui::Button("Open Project"))
|
||||
{
|
||||
OpenProject();
|
||||
filesystem.m_CurrentDirectory = FileSystem::RootDirectory;
|
||||
}
|
||||
@@ -1175,10 +1174,10 @@ namespace Nuake {
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
if (!Engine::GetProject())
|
||||
{
|
||||
ImGui::OpenPopup("Welcome");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ namespace Nuake {
|
||||
{
|
||||
private:
|
||||
FileSystemUI filesystem = FileSystemUI();
|
||||
Entity m_SelectedEntity;
|
||||
bool m_IsEntitySelected = false;
|
||||
|
||||
|
||||
bool m_DrawGrid = false;
|
||||
bool m_ShowImGuiDemo = false;
|
||||
bool m_DebugCollisions = false;
|
||||
@@ -27,6 +27,8 @@ namespace Nuake {
|
||||
bool m_IsMaterialSelected = false;
|
||||
|
||||
public:
|
||||
bool m_IsEntitySelected = false;
|
||||
Entity m_SelectedEntity;
|
||||
static ImFont* bigIconFont;
|
||||
void BuildFonts();
|
||||
void Init();
|
||||
|
||||
Reference in New Issue
Block a user