some cleanup

This commit is contained in:
viktorljung
2016-01-12 11:51:47 +01:00
parent d469fe6e9a
commit 2450769190
4 changed files with 19 additions and 57 deletions
-5
View File
@@ -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
-33
View File
@@ -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;
+5 -5
View File
@@ -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<std::shared_ptr<RenderJob>>& jobs);
void fillModels(std::list<std::shared_ptr<RenderJob>>& jobs);
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
bool OnInputCommand(const Events::InputCommand& e);
+14 -14
View File
@@ -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<std::shared_ptr<RenderJob>>& jobs)
void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& 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<RenderSystem>();
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<RenderSystem> 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;
}
}