Compare commits
3 Commits
473ff0840d
...
v0.1.3
| Author | SHA256 | Date | |
|---|---|---|---|
| bf4189bba0 | |||
| 11e8d343af | |||
| 37958449a2 |
@@ -5,7 +5,7 @@ namespace TSE
|
||||
{
|
||||
#define TSE_VERSION_MAJOR 0
|
||||
#define TSE_VERSION_MINOR 1
|
||||
#define TSE_VERSION_BUILD 2
|
||||
#define TSE_VERSION_BUILD 3
|
||||
|
||||
#define TSE_VERSION_STRING std::to_string(TSE_VERSION_MAJOR) + "." + std::to_string(TSE_VERSION_MINOR) + "." + std::to_string(TSE_VERSION_BUILD)
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "interfaces/IRenderer.hpp"
|
||||
|
||||
TSE::Camera* TSE::Camera::mainCamera = nullptr;
|
||||
TSE::ICameraHelper* TSE::Camera::helper = nullptr;
|
||||
|
||||
float TSE::Camera::GetRenderScale() const
|
||||
{
|
||||
@@ -182,6 +183,7 @@ void TSE::Camera::PreDraw(IShader *shader)
|
||||
viewMatrix = BuildView_Zplus_RH(worlmatrix);
|
||||
|
||||
shader->SetUniform("camMatrix", &viewMatrix);
|
||||
helper->OnRenderTargetChanged(lastRtSize.x, lastRtSize.y);
|
||||
}
|
||||
|
||||
void TSE::Camera::PostDraw()
|
||||
|
||||
@@ -17,6 +17,12 @@ namespace TSE
|
||||
Perspective = 2,
|
||||
};
|
||||
|
||||
class ICameraHelper
|
||||
{
|
||||
public:
|
||||
inline virtual void OnRenderTargetChanged(float width, float height) {};
|
||||
};
|
||||
|
||||
class Camera : public IResizeNotifiable, public BehaviourScript
|
||||
{
|
||||
private:
|
||||
@@ -35,6 +41,7 @@ namespace TSE
|
||||
Vector2 lastRtSize = {0, 0};
|
||||
|
||||
public:
|
||||
static ICameraHelper* helper;
|
||||
static Camera* mainCamera;
|
||||
|
||||
// Getter
|
||||
|
||||
@@ -15,10 +15,10 @@ namespace TSE
|
||||
objectEntries[id] = this;
|
||||
}
|
||||
|
||||
Transformable::Transformable(uuids::uuid id)
|
||||
: id(id), position(0, 0, 0), scale(1, 1, 1), rotation(), name("")
|
||||
Transformable::Transformable(uuids::uuid _id)
|
||||
: id(_id), position(0, 0, 0), scale(1, 1, 1), rotation(), name("")
|
||||
{
|
||||
objectEntries[id] = this;
|
||||
objectEntries[_id] = this;
|
||||
}
|
||||
|
||||
Transformable::Transformable(const string &name)
|
||||
@@ -28,10 +28,14 @@ namespace TSE
|
||||
objectEntries[id] = this;
|
||||
}
|
||||
|
||||
Transformable::Transformable(const string &name, uuids::uuid id)
|
||||
: id(id), position(0, 0, 0), scale(1, 1, 1), rotation(), name(name)
|
||||
Transformable::Transformable(const string &name, uuids::uuid _id)
|
||||
: id(_id), position(0, 0, 0), scale(1, 1, 1), rotation(), name(name)
|
||||
{
|
||||
objectEntries[_id] = this;
|
||||
}
|
||||
|
||||
Transformable::~Transformable()
|
||||
{
|
||||
objectEntries[id] = this;
|
||||
}
|
||||
|
||||
Vector3 Transformable::forward() const
|
||||
@@ -366,14 +370,20 @@ namespace TSE
|
||||
{
|
||||
//deleting children
|
||||
if(!onlyThis)
|
||||
{
|
||||
for(auto child : t->children)
|
||||
{
|
||||
HardDelete(child);
|
||||
HardDelete(child, onlyThis);
|
||||
}
|
||||
t->children.clear();
|
||||
}
|
||||
|
||||
//deleting atteched scripts
|
||||
for (auto& [_, script] : t->components)
|
||||
{
|
||||
delete script;
|
||||
}
|
||||
t->components.clear();
|
||||
|
||||
//deleting self
|
||||
Delete(t);
|
||||
@@ -442,6 +452,19 @@ namespace TSE
|
||||
return objectEntries.size();
|
||||
}
|
||||
|
||||
Transformable *Transformable::GetTansformableAt(int i)
|
||||
{
|
||||
int x = 0;
|
||||
for(auto obj : objectEntries)
|
||||
{
|
||||
if(i == x++)
|
||||
{
|
||||
return obj.second;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Transformable *Transformable::Find(string name)
|
||||
{
|
||||
for(auto obj : objectEntries)
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace TSE
|
||||
Transformable(uuids::uuid id);
|
||||
Transformable(const string& name);
|
||||
Transformable(const string& name, uuids::uuid id);
|
||||
~Transformable() = default;
|
||||
~Transformable();
|
||||
|
||||
Vector3 forward() const;
|
||||
Vector3 right() const;
|
||||
@@ -100,6 +100,7 @@ namespace TSE
|
||||
public:
|
||||
|
||||
static int GetTansformableCount();
|
||||
static Transformable* GetTansformableAt(int i);
|
||||
static Transformable* Find(string name);
|
||||
static Transformable* Find(uuids::uuid id);
|
||||
};
|
||||
|
||||
@@ -22,6 +22,11 @@ void TSE::IWindow::BaseUpdate() const
|
||||
Time::Update();
|
||||
}
|
||||
|
||||
TSE::Vector2 TSE::IWindow::GetSize() const
|
||||
{
|
||||
return Vector2({width, height});
|
||||
}
|
||||
|
||||
TSE::IWindow::~IWindow()
|
||||
{
|
||||
AudioEngine::Destroy();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "IRenderTarget.hpp"
|
||||
#include "Types.hpp"
|
||||
#include "Vector2.hpp"
|
||||
|
||||
namespace TSE
|
||||
{
|
||||
@@ -20,6 +21,7 @@ namespace TSE
|
||||
|
||||
bool BaseInit() const;
|
||||
void BaseUpdate() const;
|
||||
Vector2 GetSize() const;
|
||||
~IWindow();
|
||||
};
|
||||
} // namespace TSE
|
||||
|
||||
@@ -17,7 +17,7 @@ void TSE::EDITOR::CameraView::Define()
|
||||
}
|
||||
|
||||
ImGuiWindowFlags flags2 = ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar;
|
||||
if(ImGui::BeginChild("##SceneChild", {0,0}, ImGuiChildFlags_None, flags2))
|
||||
if(ImGui::BeginChild("##CameraChild", {0,0}, ImGuiChildFlags_None, flags2))
|
||||
{
|
||||
ImGui::Image(fb->GetTextureId(), {fb->Width(), fb->Height()},{0,1}, {1,0});
|
||||
auto vec2 = ImGui::GetWindowSize();
|
||||
|
||||
@@ -11,6 +11,8 @@ void TSE::EDITOR::HirearchieView::SetScene(Scene *s)
|
||||
currentScene = s;
|
||||
}
|
||||
|
||||
bool selectedFound = false;
|
||||
|
||||
void TSE::EDITOR::HirearchieView::Define()
|
||||
{
|
||||
if(currentScene == nullptr) return;
|
||||
@@ -32,6 +34,7 @@ void TSE::EDITOR::HirearchieView::Define()
|
||||
if(collapseOpen)
|
||||
{
|
||||
int layerCount = currentScene->GetLayerCount();
|
||||
selectedFound = false;
|
||||
for (int i = 0; i < layerCount; i++)
|
||||
{
|
||||
auto layer = currentScene->GetLayerAt(i);
|
||||
@@ -123,6 +126,7 @@ void TSE::EDITOR::HirearchieView::MenuBar()
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
|
||||
void TSE::EDITOR::HirearchieView::DisplayLayer(Layer *l)
|
||||
{
|
||||
ImGui::Indent(20.0f);
|
||||
@@ -184,6 +188,10 @@ void TSE::EDITOR::HirearchieView::DisplayLayer(Layer *l)
|
||||
{
|
||||
DisplayObj(l->GetAllObjects()[i], l);
|
||||
}
|
||||
if(!selectedFound && PropertiesView::GetCurrentInspectableType() == InspectableType::Transformable)
|
||||
{
|
||||
PropertiesView::ForceClearInspectorElement();
|
||||
}
|
||||
}
|
||||
ImGui::Unindent(20.0f);
|
||||
}
|
||||
@@ -198,8 +206,10 @@ void TSE::EDITOR::HirearchieView::DisplayObj(Transformable *t, Layer *l)
|
||||
if(selected == t->id)
|
||||
{
|
||||
flags |= ImGuiTreeNodeFlags_Selected;
|
||||
selectedFound = true;
|
||||
}
|
||||
bool open = ImGui::TreeNodeEx((t->GetName() + "##" + to_string(t->id)).c_str(), flags);
|
||||
string name = t->GetName() + "##" + to_string(t->id);
|
||||
bool open = ImGui::TreeNodeEx((name).c_str(), flags);
|
||||
if(ImGui::BeginPopupContextItem())
|
||||
{
|
||||
bool disabled = false;
|
||||
@@ -281,6 +291,7 @@ void TSE::EDITOR::HirearchieView::DisplayObj(Transformable *t, Layer *l)
|
||||
{
|
||||
selected = t->id;
|
||||
PropertiesView::SetInspectorElement(InspectableType::Transformable, t);
|
||||
selectedFound = true;
|
||||
}
|
||||
if(open)
|
||||
{
|
||||
|
||||
@@ -30,6 +30,11 @@ void TSE::EDITOR::PropertiesView::MenuBar()
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
TSE::EDITOR::InspectableType TSE::EDITOR::PropertiesView::GetCurrentInspectableType()
|
||||
{
|
||||
return currentlyInspecting.type;
|
||||
}
|
||||
|
||||
void TSE::EDITOR::PropertiesView::SetInspectorElement(InspectableType type, void *element)
|
||||
{
|
||||
if(!locked)
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace TSE::EDITOR
|
||||
|
||||
void Define() override;
|
||||
void MenuBar();
|
||||
static InspectableType GetCurrentInspectableType();
|
||||
static void SetInspectorElement(InspectableType type, void* element);
|
||||
static void ClearInspectorElement();
|
||||
static void ForceClearInspectorElement();
|
||||
|
||||
17
TSE_GlfwOpenGlImpl/src/CameraHelperOpenGL.hpp
Normal file
17
TSE_GlfwOpenGlImpl/src/CameraHelperOpenGL.hpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "BehaviourScripts/Camera.hpp"
|
||||
#include "GL/gl3w.h"
|
||||
#include "GL/gl.h"
|
||||
|
||||
namespace TSE::GLFW
|
||||
{
|
||||
class CameraHelperOpenGL : public ICameraHelper
|
||||
{
|
||||
public:
|
||||
inline void OnRenderTargetChanged(float width, float height) override
|
||||
{
|
||||
glViewport(0, 0, width, height);
|
||||
};
|
||||
};
|
||||
} // namespace TSE::GLFW
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "interfaces/IRenderer.hpp"
|
||||
#include "BehaviourScripts/Camera.hpp"
|
||||
#include "RenderTextureCreatorOpenGL.hpp"
|
||||
#include "CameraHelperOpenGL.hpp"
|
||||
|
||||
TSE::GLFW::OpenGLRenderingBackend::OpenGLRenderingBackend(Color _backgroundColor, bool _vsync)
|
||||
: OpenGLRenderingBackend(_backgroundColor, _vsync, 0, false){ }
|
||||
@@ -39,6 +40,7 @@ void TSE::GLFW::OpenGLRenderingBackend::InitPreWindow()
|
||||
{
|
||||
IRenderTexture::factory = new RenderTextureCreatorOpenGL();
|
||||
Texture::helper = new TextureHelperOpenGL();
|
||||
Camera::helper = new CameraHelperOpenGL();
|
||||
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, TSE_OPENGL_VERSION_MAJOR);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, TSE_OPENGL_VERSION_MINOR);
|
||||
|
||||
Reference in New Issue
Block a user