From 24507691900a280abc432f37d62989b246461090 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Tue, 12 Jan 2016 11:51:47 +0100 Subject: [PATCH] some cleanup --- include/Engine/Rendering/ModelJob.h | 5 ---- include/Engine/Rendering/RenderQueue.h | 33 ------------------------- include/Engine/Rendering/RenderSystem.h | 10 ++++---- src/Engine/Rendering/RenderSystem.cpp | 28 ++++++++++----------- 4 files changed, 19 insertions(+), 57 deletions(-) diff --git a/include/Engine/Rendering/ModelJob.h b/include/Engine/Rendering/ModelJob.h index fcb68244..845a85bb 100644 --- a/include/Engine/Rendering/ModelJob.h +++ b/include/Engine/Rendering/ModelJob.h @@ -8,7 +8,6 @@ #include "../Core/ComponentWrapper.h" #include "Texture.h" #include "Model.h" - #include "RenderJob.h" #include "../Core/ResourceManager.h" #include "Camera.h" @@ -30,7 +29,6 @@ struct ModelJob : RenderJob Entity = modelComponent.EntityID; }; - unsigned int TextureID; unsigned int ShaderID; @@ -45,13 +43,10 @@ struct ModelJob : RenderJob unsigned int StartIndex = 0; unsigned int EndIndex = 0; - void CalculateHash() override { Hash = TextureID; } - - }; #endif \ No newline at end of file diff --git a/include/Engine/Rendering/RenderQueue.h b/include/Engine/Rendering/RenderQueue.h index 4ffb55f2..cd008340 100644 --- a/include/Engine/Rendering/RenderQueue.h +++ b/include/Engine/Rendering/RenderQueue.h @@ -15,39 +15,6 @@ /* - - -struct TransparentModelJob : RenderJob -{ - unsigned int ShaderID = 0; - unsigned int TextureID = 0; - - //TODO: RENDERER: Not sure if the best solution for pickingColor to entity link is this - EntityID Entity; - - glm::mat4 Matrix; - const Texture* DiffuseTexture; - const Texture* NormalTexture; - const Texture* SpecularTexture; - float Shininess = 0.f; - glm::vec4 Color; - const Model* Model = nullptr; - unsigned int StartIndex = 0; - unsigned int EndIndex = 0; - - // Animation - Skeleton* Skeleton = nullptr; - bool NoRootMotion = true; - std::string AnimationName; - double AnimationTime = 0; - - void CalculateHash() override - { - Hash = TextureID; - } -}; - - struct SpriteJob : RenderJob { unsigned int ShaderID = 0; diff --git a/include/Engine/Rendering/RenderSystem.h b/include/Engine/Rendering/RenderSystem.h index 2fa7b6f5..a6137b67 100644 --- a/include/Engine/Rendering/RenderSystem.h +++ b/include/Engine/Rendering/RenderSystem.h @@ -42,16 +42,16 @@ private: bool OnSetCamera(const Events::SetCamera &event); EntityID m_CurrentCamera = -1; - void SwitchCamera(EntityID entity); + void switchCamera(EntityID entity); - void Initialize(); - void UpdateCamera(World* world, double dt); - void UpdateProjectionMatrix(ComponentWrapper& cameraComponent); + void initialize(); + void updateCamera(World* world, double dt); + void updateProjectionMatrix(ComponentWrapper& cameraComponent); glm::mat4 m_ViewMatrix; glm::mat4 m_ProjectionMatrix; glm::mat4 ModelMatrix(EntityID entity); - void FillModels(std::list>& jobs); + void fillModels(std::list>& jobs); EventRelay m_EInputCommand; bool OnInputCommand(const Events::InputCommand& e); diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index b9d63552..3fe71f42 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -5,7 +5,7 @@ RenderSystem::RenderSystem(EventBroker* eventBrokerer, const IRenderer* renderer { m_Renderer = renderer; m_RenderFrame = renderFrame; - Initialize(); + initialize(); EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &RenderSystem::OnSetCamera); EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &RenderSystem::OnInputCommand); @@ -16,7 +16,6 @@ RenderSystem::RenderSystem(EventBroker* eventBrokerer, const IRenderer* renderer } } - bool RenderSystem::OnSetCamera(const Events::SetCamera &event) { auto cameras = m_World->GetComponents("Camera"); @@ -24,14 +23,14 @@ bool RenderSystem::OnSetCamera(const Events::SetCamera &event) if (cameras != nullptr) { for (auto it = cameras->begin(); it != cameras->end(); it++) { if ((std::string)(*it)["Name"] == event.Name) { - SwitchCamera((*it).EntityID); + switchCamera((*it).EntityID); } } } return true; } -void RenderSystem::SwitchCamera(EntityID entity) +void RenderSystem::switchCamera(EntityID entity) { if(m_World->HasComponent(entity, "Camera")) { if (m_World->HasComponent(m_CurrentCamera, "Model")) { @@ -50,12 +49,12 @@ void RenderSystem::SwitchCamera(EntityID entity) } } -void RenderSystem::Initialize() +void RenderSystem::initialize() { } -void RenderSystem::UpdateProjectionMatrix(ComponentWrapper& cameraComponent) +void RenderSystem::updateProjectionMatrix(ComponentWrapper& cameraComponent) { double fov = cameraComponent["FOV"]; double aspectRatio = m_Renderer->Resolution().Width / m_Renderer->Resolution().Height; @@ -126,7 +125,7 @@ glm::mat4 RenderSystem::ModelMatrix(EntityID entity) return modelMatrix; } -void RenderSystem::FillModels(std::list>& jobs) +void RenderSystem::fillModels(std::list>& jobs) { auto models = m_World->GetComponents("Model"); if (models == nullptr) { @@ -173,18 +172,19 @@ void RenderSystem::Update(World* world, double dt) m_World = world; m_EventBroker->Process(); - UpdateCamera(world, dt); + updateCamera(world, dt); + //Only supports opaque geometry atm m_RenderFrame->Clear(); RenderScene* rs = new RenderScene(); rs->Camera = m_Camera; rs->ViewPort = Rectangle(1280, 720); - FillModels(rs->ForwardJobs); + fillModels(rs->ForwardJobs); m_RenderFrame->Add(*rs); delete rs; } -void RenderSystem::UpdateCamera(World* world, double dt) +void RenderSystem::updateCamera(World* world, double dt) { static DebugCameraInputController firstPersonInputController(m_EventBroker, -1); @@ -196,9 +196,9 @@ void RenderSystem::UpdateCamera(World* world, double dt) if ((*it).EntityID == m_CurrentCamera) { it++; if (it != cameras->end()) { - SwitchCamera((*it).EntityID); + switchCamera((*it).EntityID); } else { - SwitchCamera((*cameras->begin()).EntityID); + switchCamera((*cameras->begin()).EntityID); } break; } @@ -227,7 +227,7 @@ void RenderSystem::UpdateCamera(World* world, double dt) m_Camera->SetPosition(position); m_Camera->SetOrientation(orientation); - UpdateProjectionMatrix(cameraComponent); + updateProjectionMatrix(cameraComponent); m_Camera->UpdateViewMatrix(); } else { m_Camera = m_DefaultCamera; @@ -235,7 +235,7 @@ void RenderSystem::UpdateCamera(World* world, double dt) auto cameras = world->GetComponents("Camera"); if (cameras != nullptr) { ComponentWrapper& cameraC = *cameras->begin(); - SwitchCamera(cameraC.EntityID); + switchCamera(cameraC.EntityID); world->GetComponent(m_CurrentCamera, "Model")["Visible"] = false; } }