Added Queues for the models with shield and shielded components.
This commit is contained in:
@@ -19,22 +19,30 @@
|
||||
struct RenderScene
|
||||
{
|
||||
::Camera* Camera = nullptr;
|
||||
std::list<std::shared_ptr<RenderJob>> OpaqueObjects;
|
||||
std::list<std::shared_ptr<RenderJob>> TransparentObjects;
|
||||
std::list<std::shared_ptr<RenderJob>> PointLightJobs;
|
||||
std::list<std::shared_ptr<RenderJob>> TextJobs;
|
||||
std::list<std::shared_ptr<RenderJob>> DirectionalLightJobs;
|
||||
struct Queues {
|
||||
std::list<std::shared_ptr<RenderJob>> OpaqueObjects;
|
||||
std::list<std::shared_ptr<RenderJob>> TransparentObjects;
|
||||
std::list<std::shared_ptr<RenderJob>> OpaqueShieldedObjects;
|
||||
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;
|
||||
bool ClearDepth = false;
|
||||
glm::vec4 AmbientColor;
|
||||
|
||||
void Clear()
|
||||
{
|
||||
OpaqueObjects.clear();
|
||||
TransparentObjects.clear();
|
||||
PointLightJobs.clear();
|
||||
TextJobs.clear();
|
||||
DirectionalLightJobs.clear();
|
||||
Jobs.OpaqueObjects.clear();
|
||||
Jobs.TransparentObjects.clear();
|
||||
Jobs.OpaqueShieldedObjects.clear();
|
||||
Jobs.TransparentShieldedObjects.clear();
|
||||
Jobs.ShieldObjects.clear();
|
||||
Jobs.Text.clear();
|
||||
Jobs.DirectionalLight.clear();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ private:
|
||||
EventRelay<RenderSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||
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 fillPointLights(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()) {
|
||||
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"]) {
|
||||
scene.TransparentObjects.push_back(modelJob);
|
||||
scene.Jobs.TransparentObjects.push_back(modelJob);
|
||||
} 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);
|
||||
ComponentWrapper& cTransform = entity["Transform"];
|
||||
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);
|
||||
}
|
||||
|
||||
DrawModelRenderQueues(scene.OpaqueObjects, scene);
|
||||
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
|
||||
GLERROR("OpaqueObjects");
|
||||
DrawModelRenderQueues(scene.TransparentObjects, scene);
|
||||
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
|
||||
GLERROR("TransparentObjects");
|
||||
|
||||
delete state;
|
||||
|
||||
@@ -16,7 +16,7 @@ LightCullingPass::~LightCullingPass()
|
||||
|
||||
void LightCullingPass::GenerateNewFrustum(RenderScene& scene)
|
||||
{
|
||||
if (scene.PointLightJobs.size() == 0)
|
||||
if (scene.Jobs.PointLight.size() == 0)
|
||||
return;
|
||||
|
||||
GLERROR("CalculateFrustum Error: Pre");
|
||||
@@ -83,7 +83,7 @@ void LightCullingPass::FillLightList(RenderScene& scene)
|
||||
{
|
||||
m_LightSources.clear();
|
||||
|
||||
for(auto &job : scene.PointLightJobs) {
|
||||
for(auto &job : scene.Jobs.PointLight) {
|
||||
auto pointLightjob = std::dynamic_pointer_cast<PointLightJob>(job);
|
||||
if (pointLightjob) {
|
||||
LightSource p;
|
||||
@@ -97,7 +97,7 @@ void LightCullingPass::FillLightList(RenderScene& scene)
|
||||
m_LightSources.push_back(p);
|
||||
}
|
||||
}
|
||||
for(auto &job : scene.DirectionalLightJobs) {
|
||||
for(auto &job : scene.Jobs.DirectionalLight) {
|
||||
auto directionalLightJob = std::dynamic_pointer_cast<DirectionalLightJob>(job);
|
||||
if(directionalLightJob) {
|
||||
LightSource p;
|
||||
|
||||
@@ -56,7 +56,7 @@ void PickingPass::Draw(RenderScene& scene)
|
||||
}
|
||||
m_Camera = scene.Camera;
|
||||
|
||||
for (auto &job : scene.OpaqueObjects) {
|
||||
for (auto &job : scene.Jobs.OpaqueObjects) {
|
||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||
|
||||
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);
|
||||
|
||||
if (modelJob) {
|
||||
|
||||
@@ -40,7 +40,7 @@ bool RenderSystem::isChildOfCurrentCamera(EntityWrapper entity)
|
||||
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");
|
||||
if (models == nullptr) {
|
||||
@@ -106,14 +106,15 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& opaqueJobs,
|
||||
fillColor,
|
||||
fillPercentage
|
||||
));
|
||||
|
||||
if(explosionEffectJob->Color.a != 1.f || explosionEffectJob->EndColor.a != 1.f || explosionEffectJob->DiffuseColor.a != 1.f) {
|
||||
cModel["Transparent"] = true;
|
||||
}
|
||||
|
||||
if (cModel["Transparent"]) {
|
||||
transparentJobs.push_back(explosionEffectJob);
|
||||
Jobs.TransparentObjects.push_back(explosionEffectJob);
|
||||
} else {
|
||||
opaqueJobs.push_back(explosionEffectJob);
|
||||
Jobs.OpaqueObjects.push_back(explosionEffectJob);
|
||||
}
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
if (cModel["Transparent"]) {
|
||||
transparentJobs.push_back(modelJob);
|
||||
Jobs.TransparentObjects.push_back(modelJob);
|
||||
} 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"];
|
||||
}
|
||||
|
||||
fillModels(scene.OpaqueObjects, scene.TransparentObjects);
|
||||
fillPointLights(scene.PointLightJobs, m_World);
|
||||
fillDirectionalLights(scene.DirectionalLightJobs, m_World);
|
||||
fillText(scene.TextJobs, m_World);
|
||||
fillModels(scene.Jobs);
|
||||
fillPointLights(scene.Jobs.PointLight, m_World);
|
||||
fillDirectionalLights(scene.Jobs.DirectionalLight, m_World);
|
||||
fillText(scene.Jobs.Text, m_World);
|
||||
m_RenderFrame->Add(scene);
|
||||
|
||||
}
|
||||
@@ -154,7 +154,7 @@ void Renderer::InitializeTextures()
|
||||
void Renderer::SortRenderJobsByDepth(RenderScene &scene)
|
||||
{
|
||||
//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)
|
||||
|
||||
@@ -35,7 +35,7 @@ void TextPass::Draw(RenderScene& scene, FrameBuffer& frameBuffer)
|
||||
{
|
||||
GLERROR("Derp1");
|
||||
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);
|
||||
if (textJob) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user