Added Queues for the models with shield and shielded components.
This commit is contained in:
@@ -19,22 +19,30 @@
|
|||||||
struct RenderScene
|
struct RenderScene
|
||||||
{
|
{
|
||||||
::Camera* Camera = nullptr;
|
::Camera* Camera = nullptr;
|
||||||
std::list<std::shared_ptr<RenderJob>> OpaqueObjects;
|
struct Queues {
|
||||||
std::list<std::shared_ptr<RenderJob>> TransparentObjects;
|
std::list<std::shared_ptr<RenderJob>> OpaqueObjects;
|
||||||
std::list<std::shared_ptr<RenderJob>> PointLightJobs;
|
std::list<std::shared_ptr<RenderJob>> TransparentObjects;
|
||||||
std::list<std::shared_ptr<RenderJob>> TextJobs;
|
std::list<std::shared_ptr<RenderJob>> OpaqueShieldedObjects;
|
||||||
std::list<std::shared_ptr<RenderJob>> DirectionalLightJobs;
|
std::list<std::shared_ptr<RenderJob>> TransparentShieldedObjects;
|
||||||
|
std::list<std::shared_ptr<RenderJob>> ShieldObjects;
|
||||||
|
std::list<std::shared_ptr<RenderJob>> PointLight;
|
||||||
|
std::list<std::shared_ptr<RenderJob>> Text;
|
||||||
|
std::list<std::shared_ptr<RenderJob>> DirectionalLight;
|
||||||
|
} Jobs;
|
||||||
|
|
||||||
Rectangle Viewport;
|
Rectangle Viewport;
|
||||||
bool ClearDepth = false;
|
bool ClearDepth = false;
|
||||||
glm::vec4 AmbientColor;
|
glm::vec4 AmbientColor;
|
||||||
|
|
||||||
void Clear()
|
void Clear()
|
||||||
{
|
{
|
||||||
OpaqueObjects.clear();
|
Jobs.OpaqueObjects.clear();
|
||||||
TransparentObjects.clear();
|
Jobs.TransparentObjects.clear();
|
||||||
PointLightJobs.clear();
|
Jobs.OpaqueShieldedObjects.clear();
|
||||||
TextJobs.clear();
|
Jobs.TransparentShieldedObjects.clear();
|
||||||
DirectionalLightJobs.clear();
|
Jobs.ShieldObjects.clear();
|
||||||
|
Jobs.Text.clear();
|
||||||
|
Jobs.DirectionalLight.clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ private:
|
|||||||
EventRelay<RenderSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
EventRelay<RenderSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||||
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
||||||
|
|
||||||
void fillModels(std::list<std::shared_ptr<RenderJob>>& opaqueJobs, std::list<std::shared_ptr<RenderJob>>& transparentJobs);
|
void fillModels(RenderScene::Queues &jobs);
|
||||||
void fillText(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
void fillText(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||||
void fillPointLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
void fillPointLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||||
void fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
void fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||||
|
|||||||
@@ -56,9 +56,9 @@ void EditorRenderSystem::Update(double dt)
|
|||||||
for (auto matGroup : model->MaterialGroups()) {
|
for (auto matGroup : model->MaterialGroups()) {
|
||||||
std::shared_ptr<ModelJob> modelJob = std::make_shared<ModelJob>(model, scene.Camera, modelMatrix, matGroup, cModel, entity.World, glm::vec4(0), 0.f);
|
std::shared_ptr<ModelJob> modelJob = std::make_shared<ModelJob>(model, scene.Camera, modelMatrix, matGroup, cModel, entity.World, glm::vec4(0), 0.f);
|
||||||
if (cModel["Transparent"]) {
|
if (cModel["Transparent"]) {
|
||||||
scene.TransparentObjects.push_back(modelJob);
|
scene.Jobs.TransparentObjects.push_back(modelJob);
|
||||||
} else {
|
} else {
|
||||||
scene.OpaqueObjects.push_back(modelJob);
|
scene.Jobs.OpaqueObjects.push_back(modelJob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ void EditorRenderSystem::Update(double dt)
|
|||||||
EntityWrapper entity(m_World, cPointLight.EntityID);
|
EntityWrapper entity(m_World, cPointLight.EntityID);
|
||||||
ComponentWrapper& cTransform = entity["Transform"];
|
ComponentWrapper& cTransform = entity["Transform"];
|
||||||
std::shared_ptr<PointLightJob> pointLightJob = std::make_shared<PointLightJob>(cTransform, cPointLight, entity.World);
|
std::shared_ptr<PointLightJob> pointLightJob = std::make_shared<PointLightJob>(cTransform, cPointLight, entity.World);
|
||||||
scene.PointLightJobs.push_back(pointLightJob);
|
scene.Jobs.PointLight.push_back(pointLightJob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
|||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawModelRenderQueues(scene.OpaqueObjects, scene);
|
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
|
||||||
GLERROR("OpaqueObjects");
|
GLERROR("OpaqueObjects");
|
||||||
DrawModelRenderQueues(scene.TransparentObjects, scene);
|
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
|
||||||
GLERROR("TransparentObjects");
|
GLERROR("TransparentObjects");
|
||||||
|
|
||||||
delete state;
|
delete state;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ LightCullingPass::~LightCullingPass()
|
|||||||
|
|
||||||
void LightCullingPass::GenerateNewFrustum(RenderScene& scene)
|
void LightCullingPass::GenerateNewFrustum(RenderScene& scene)
|
||||||
{
|
{
|
||||||
if (scene.PointLightJobs.size() == 0)
|
if (scene.Jobs.PointLight.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GLERROR("CalculateFrustum Error: Pre");
|
GLERROR("CalculateFrustum Error: Pre");
|
||||||
@@ -83,7 +83,7 @@ void LightCullingPass::FillLightList(RenderScene& scene)
|
|||||||
{
|
{
|
||||||
m_LightSources.clear();
|
m_LightSources.clear();
|
||||||
|
|
||||||
for(auto &job : scene.PointLightJobs) {
|
for(auto &job : scene.Jobs.PointLight) {
|
||||||
auto pointLightjob = std::dynamic_pointer_cast<PointLightJob>(job);
|
auto pointLightjob = std::dynamic_pointer_cast<PointLightJob>(job);
|
||||||
if (pointLightjob) {
|
if (pointLightjob) {
|
||||||
LightSource p;
|
LightSource p;
|
||||||
@@ -97,7 +97,7 @@ void LightCullingPass::FillLightList(RenderScene& scene)
|
|||||||
m_LightSources.push_back(p);
|
m_LightSources.push_back(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(auto &job : scene.DirectionalLightJobs) {
|
for(auto &job : scene.Jobs.DirectionalLight) {
|
||||||
auto directionalLightJob = std::dynamic_pointer_cast<DirectionalLightJob>(job);
|
auto directionalLightJob = std::dynamic_pointer_cast<DirectionalLightJob>(job);
|
||||||
if(directionalLightJob) {
|
if(directionalLightJob) {
|
||||||
LightSource p;
|
LightSource p;
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
}
|
}
|
||||||
m_Camera = scene.Camera;
|
m_Camera = scene.Camera;
|
||||||
|
|
||||||
for (auto &job : scene.OpaqueObjects) {
|
for (auto &job : scene.Jobs.OpaqueObjects) {
|
||||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
|
|
||||||
if (modelJob) {
|
if (modelJob) {
|
||||||
@@ -102,7 +102,7 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &job : scene.TransparentObjects) {
|
for (auto &job : scene.Jobs.TransparentObjects) {
|
||||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
|
|
||||||
if (modelJob) {
|
if (modelJob) {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ bool RenderSystem::isChildOfCurrentCamera(EntityWrapper entity)
|
|||||||
return entity == m_CurrentCamera || entity.IsChildOf(m_CurrentCamera);
|
return entity == m_CurrentCamera || entity.IsChildOf(m_CurrentCamera);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& opaqueJobs, std::list<std::shared_ptr<RenderJob>>& transparentJobs)
|
void RenderSystem::fillModels(RenderScene::Queues &Jobs)
|
||||||
{
|
{
|
||||||
auto models = m_World->GetComponents("Model");
|
auto models = m_World->GetComponents("Model");
|
||||||
if (models == nullptr) {
|
if (models == nullptr) {
|
||||||
@@ -106,14 +106,15 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& opaqueJobs,
|
|||||||
fillColor,
|
fillColor,
|
||||||
fillPercentage
|
fillPercentage
|
||||||
));
|
));
|
||||||
|
|
||||||
if(explosionEffectJob->Color.a != 1.f || explosionEffectJob->EndColor.a != 1.f || explosionEffectJob->DiffuseColor.a != 1.f) {
|
if(explosionEffectJob->Color.a != 1.f || explosionEffectJob->EndColor.a != 1.f || explosionEffectJob->DiffuseColor.a != 1.f) {
|
||||||
cModel["Transparent"] = true;
|
cModel["Transparent"] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cModel["Transparent"]) {
|
if (cModel["Transparent"]) {
|
||||||
transparentJobs.push_back(explosionEffectJob);
|
Jobs.TransparentObjects.push_back(explosionEffectJob);
|
||||||
} else {
|
} else {
|
||||||
opaqueJobs.push_back(explosionEffectJob);
|
Jobs.OpaqueObjects.push_back(explosionEffectJob);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::shared_ptr<ModelJob> modelJob = std::shared_ptr<ModelJob>(new ModelJob(
|
std::shared_ptr<ModelJob> modelJob = std::shared_ptr<ModelJob>(new ModelJob(
|
||||||
@@ -130,9 +131,9 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& opaqueJobs,
|
|||||||
cModel["Transparent"] = true;
|
cModel["Transparent"] = true;
|
||||||
}
|
}
|
||||||
if (cModel["Transparent"]) {
|
if (cModel["Transparent"]) {
|
||||||
transparentJobs.push_back(modelJob);
|
Jobs.TransparentObjects.push_back(modelJob);
|
||||||
} else {
|
} else {
|
||||||
opaqueJobs.push_back(modelJob);
|
Jobs.OpaqueObjects.push_back(modelJob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,10 +252,10 @@ void RenderSystem::Update(double dt)
|
|||||||
scene.AmbientColor = (glm::vec4)(*cSceneLight->begin())["AmbientColor"];
|
scene.AmbientColor = (glm::vec4)(*cSceneLight->begin())["AmbientColor"];
|
||||||
}
|
}
|
||||||
|
|
||||||
fillModels(scene.OpaqueObjects, scene.TransparentObjects);
|
fillModels(scene.Jobs);
|
||||||
fillPointLights(scene.PointLightJobs, m_World);
|
fillPointLights(scene.Jobs.PointLight, m_World);
|
||||||
fillDirectionalLights(scene.DirectionalLightJobs, m_World);
|
fillDirectionalLights(scene.Jobs.DirectionalLight, m_World);
|
||||||
fillText(scene.TextJobs, m_World);
|
fillText(scene.Jobs.Text, m_World);
|
||||||
m_RenderFrame->Add(scene);
|
m_RenderFrame->Add(scene);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ void Renderer::InitializeTextures()
|
|||||||
void Renderer::SortRenderJobsByDepth(RenderScene &scene)
|
void Renderer::SortRenderJobsByDepth(RenderScene &scene)
|
||||||
{
|
{
|
||||||
//Sort all forward jobs so transparency is good.
|
//Sort all forward jobs so transparency is good.
|
||||||
scene.TransparentObjects.sort(Renderer::DepthSort);
|
scene.Jobs.TransparentObjects.sort(Renderer::DepthSort);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type)
|
void Renderer::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ void TextPass::Draw(RenderScene& scene, FrameBuffer& frameBuffer)
|
|||||||
{
|
{
|
||||||
GLERROR("Derp1");
|
GLERROR("Derp1");
|
||||||
TextPassState* state = new TextPassState(frameBuffer.GetHandle());
|
TextPassState* state = new TextPassState(frameBuffer.GetHandle());
|
||||||
for (auto &job : scene.TextJobs) {
|
for (auto &job : scene.Jobs.Text) {
|
||||||
auto textJob = std::dynamic_pointer_cast<TextJob>(job);
|
auto textJob = std::dynamic_pointer_cast<TextJob>(job);
|
||||||
if (textJob) {
|
if (textJob) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user