Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3f9866b334 |
@@ -4,11 +4,11 @@
|
|||||||
#include "../GLM.h"
|
#include "../GLM.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "EntityWrapper.h"
|
#include "EntityWrapper.h"
|
||||||
|
#include "System.h"
|
||||||
|
|
||||||
namespace Transform
|
namespace Transform
|
||||||
{
|
{
|
||||||
|
|
||||||
glm::mat4 AbsoluteTransformation(EntityWrapper entity);
|
|
||||||
glm::vec3 AbsolutePosition(EntityWrapper entity);
|
glm::vec3 AbsolutePosition(EntityWrapper entity);
|
||||||
glm::vec3 AbsolutePosition(World* world, EntityID entity);
|
glm::vec3 AbsolutePosition(World* world, EntityID entity);
|
||||||
glm::vec3 AbsoluteOrientationEuler(EntityWrapper entity);
|
glm::vec3 AbsoluteOrientationEuler(EntityWrapper entity);
|
||||||
@@ -20,6 +20,16 @@ glm::mat4 ModelMatrix(EntityWrapper entity);
|
|||||||
glm::mat4 ModelMatrix(EntityID entity, World* world);
|
glm::mat4 ModelMatrix(EntityID entity, World* world);
|
||||||
glm::vec3 TransformPoint(const glm::vec3& point, const glm::mat4& matrix);
|
glm::vec3 TransformPoint(const glm::vec3& point, const glm::mat4& matrix);
|
||||||
|
|
||||||
|
class ClearCache : public ImpureSystem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ClearCache(SystemParams params)
|
||||||
|
: System(params)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
virtual void Update(double dt) override;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -13,7 +13,6 @@
|
|||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
#include "ShadowPass.h"
|
#include "ShadowPass.h"
|
||||||
#include "BlurHUD.h"
|
#include "BlurHUD.h"
|
||||||
#include "TextPass.h"
|
|
||||||
|
|
||||||
class DrawFinalPass
|
class DrawFinalPass
|
||||||
{
|
{
|
||||||
@@ -23,7 +22,7 @@ public:
|
|||||||
void InitializeTextures();
|
void InitializeTextures();
|
||||||
void InitializeFrameBuffers();
|
void InitializeFrameBuffers();
|
||||||
void InitializeShaderPrograms();
|
void InitializeShaderPrograms();
|
||||||
void Draw(RenderScene& scene, BlurHUD* blurHUDPass, TextPass* textPass);
|
void Draw(RenderScene& scene, BlurHUD* blurHUDPass);
|
||||||
void ClearBuffer();
|
void ClearBuffer();
|
||||||
void OnWindowResize();
|
void OnWindowResize();
|
||||||
|
|
||||||
|
|||||||
@@ -621,7 +621,7 @@ boost::optional<EntityAABB> EntityAbsoluteAABB(EntityWrapper& entity, bool takeM
|
|||||||
ComponentWrapper& cAABB = entity["AABB"];
|
ComponentWrapper& cAABB = entity["AABB"];
|
||||||
modelSpaceBox = EntityAABB::FromOriginSize((glm::vec3)cAABB["Origin"], (glm::vec3)cAABB["Size"]);
|
modelSpaceBox = EntityAABB::FromOriginSize((glm::vec3)cAABB["Origin"], (glm::vec3)cAABB["Size"]);
|
||||||
} else if (entity.HasComponent("Model")) {
|
} else if (entity.HasComponent("Model")) {
|
||||||
std::string res = entity["Model"]["Resource"];
|
const std::string& res = entity["Model"]["Resource"];
|
||||||
if (res.empty()) {
|
if (res.empty()) {
|
||||||
return boost::none;
|
return boost::none;
|
||||||
}
|
}
|
||||||
@@ -638,7 +638,7 @@ boost::optional<EntityAABB> EntityAbsoluteAABB(EntityWrapper& entity, bool takeM
|
|||||||
return boost::none;
|
return boost::none;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 modelMat = Transform::AbsoluteTransformation(entity);
|
glm::mat4 modelMat = Transform::ModelMatrix(entity);
|
||||||
glm::vec3 mini(INFINITY);
|
glm::vec3 mini(INFINITY);
|
||||||
glm::vec3 maxi(-INFINITY);
|
glm::vec3 maxi(-INFINITY);
|
||||||
glm::vec3 maxCorner = modelSpaceBox.MaxCorner();
|
glm::vec3 maxCorner = modelSpaceBox.MaxCorner();
|
||||||
|
|||||||
@@ -1,16 +1,6 @@
|
|||||||
#include "Core/Transform.h"
|
#include "Core/Transform.h"
|
||||||
|
|
||||||
glm::mat4 Transform::AbsoluteTransformation(EntityWrapper entity)
|
static std::unordered_map<EntityWrapper, glm::mat4> MatrixCache;
|
||||||
{
|
|
||||||
glm::mat4 t = glm::mat4(1.f);
|
|
||||||
|
|
||||||
while (entity.Valid()) {
|
|
||||||
t = glm::translate((glm::vec3&)entity["Transform"]["Position"]) * glm::toMat4(glm::quat((glm::vec3&)entity["Transform"]["Orientation"])) * glm::scale((glm::vec3&)entity["Transform"]["Scale"]) * t;
|
|
||||||
entity = entity.Parent();
|
|
||||||
}
|
|
||||||
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 Transform::AbsolutePosition(EntityWrapper entity)
|
glm::vec3 Transform::AbsolutePosition(EntityWrapper entity)
|
||||||
{
|
{
|
||||||
@@ -80,24 +70,36 @@ glm::vec3 Transform::AbsoluteScale(World* world, EntityID entity)
|
|||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 Transform::ModelMatrix(EntityWrapper entity)
|
|
||||||
{
|
|
||||||
return ModelMatrix(entity.ID, entity.World);
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::mat4 Transform::ModelMatrix(EntityID entity, World* world)
|
glm::mat4 Transform::ModelMatrix(EntityID entity, World* world)
|
||||||
{
|
{
|
||||||
return AbsoluteTransformation(EntityWrapper(world, entity));
|
return ModelMatrix(EntityWrapper(world, entity));
|
||||||
|
|
||||||
//glm::vec3 position = Transform::AbsolutePosition(world, entity);
|
|
||||||
//glm::quat orientation = Transform::AbsoluteOrientation(world, entity);
|
|
||||||
//glm::vec3 scale = Transform::AbsoluteScale(world, entity);
|
|
||||||
|
|
||||||
//glm::mat4 modelMatrix = glm::translate(glm::mat4(), position) * glm::toMat4(orientation) * glm::scale(scale);
|
|
||||||
//return modelMatrix;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 Transform::TransformPoint(const glm::vec3& point, const glm::mat4& matrix)
|
glm::vec3 Transform::TransformPoint(const glm::vec3& point, const glm::mat4& matrix)
|
||||||
{
|
{
|
||||||
return glm::vec3(matrix * glm::vec4(point.x, point.y, point.z, 1));
|
return glm::vec3(matrix * glm::vec4(point.x, point.y, point.z, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::mat4 Transform::ModelMatrix(EntityWrapper entity)
|
||||||
|
{
|
||||||
|
auto cacheIt = MatrixCache.find(entity);
|
||||||
|
if (cacheIt != MatrixCache.end()) {
|
||||||
|
return cacheIt->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
ComponentWrapper cTransform = entity["Transform"];
|
||||||
|
glm::mat4 t = glm::translate((const glm::vec3&)cTransform["Position"]) * glm::toMat4(glm::quat((const glm::vec3&)cTransform["Orientation"])) * glm::scale((const glm::vec3&)cTransform["Scale"]);
|
||||||
|
|
||||||
|
EntityWrapper parent = entity.Parent();
|
||||||
|
if (parent.Valid()) {
|
||||||
|
t = ModelMatrix(parent) * t;
|
||||||
|
}
|
||||||
|
|
||||||
|
MatrixCache[entity] = t;
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Transform::ClearCache::Update(double dt)
|
||||||
|
{
|
||||||
|
MatrixCache.clear();
|
||||||
|
}
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ void DrawFinalPass::InitializeShaderPrograms()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFinalPass::Draw(RenderScene& scene, BlurHUD* blurHUDPass, TextPass* textPass)
|
void DrawFinalPass::Draw(RenderScene& scene, BlurHUD* blurHUDPass)
|
||||||
{
|
{
|
||||||
GLERROR("Pre");
|
GLERROR("Pre");
|
||||||
DrawFinalPassState* stateDethp = new DrawFinalPassState(m_ShieldDepthFrameBuffer.GetHandle());
|
DrawFinalPassState* stateDethp = new DrawFinalPassState(m_ShieldDepthFrameBuffer.GetHandle());
|
||||||
@@ -282,36 +282,10 @@ void DrawFinalPass::Draw(RenderScene& scene, BlurHUD* blurHUDPass, TextPass* tex
|
|||||||
//state->StencilMask(0x00);
|
//state->StencilMask(0x00);
|
||||||
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
|
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
|
||||||
GLERROR("OpaqueObjects");
|
GLERROR("OpaqueObjects");
|
||||||
delete state;
|
|
||||||
|
|
||||||
DrawFinalPassState* stateSprite = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle());
|
|
||||||
if (scene.ShouldBlur) {
|
|
||||||
//Combine nonblur and blur texture
|
|
||||||
stateSprite->Disable(GL_DEPTH_TEST);
|
|
||||||
stateSprite->Disable(GL_STENCIL_TEST);
|
|
||||||
m_CombinedTexture = blurHUDPass->CombineTextures(m_SceneTexture, m_FullBlurredTexture);
|
|
||||||
|
|
||||||
}
|
|
||||||
//Draw Transparen objects
|
|
||||||
//state->BlendFunc(GL_ONE, GL_ONE);
|
|
||||||
//state->StencilFunc(GL_EQUAL, 1, 0xFF);
|
|
||||||
//DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
|
|
||||||
GLERROR("TransparentObjects");
|
|
||||||
//state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
stateSprite->Enable(GL_DEPTH_TEST);
|
|
||||||
//stateSprite->AlphaFunc(GL_GEQUAL, 0.05f);
|
|
||||||
//stateSprite->Enable(GL_ALPHA_TEST);
|
|
||||||
DrawSprites(scene.Jobs.SpriteJob, scene);
|
|
||||||
GLERROR("SpriteJobs");
|
|
||||||
|
|
||||||
delete stateSprite;
|
|
||||||
|
|
||||||
state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle());
|
|
||||||
|
|
||||||
//state->Disable(GL_STENCIL_TEST);
|
//state->Disable(GL_STENCIL_TEST);
|
||||||
//Draw Transparen Shielded objects
|
//Draw Transparen Shielded objects
|
||||||
state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
textPass->Draw(scene, m_FinalPassFrameBuffer);
|
|
||||||
DrawModelRenderQueuesWithShieldCheck(scene.Jobs.TransparentObjects, scene); //might need changing
|
DrawModelRenderQueuesWithShieldCheck(scene.Jobs.TransparentObjects, scene); //might need changing
|
||||||
GLERROR("Shielded Transparent objects");
|
GLERROR("Shielded Transparent objects");
|
||||||
|
|
||||||
@@ -322,7 +296,27 @@ void DrawFinalPass::Draw(RenderScene& scene, BlurHUD* blurHUDPass, TextPass* tex
|
|||||||
m_FullBlurredTexture = blurHUDPass->Draw(m_SceneTexture, scene);
|
m_FullBlurredTexture = blurHUDPass->Draw(m_SceneTexture, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DrawFinalPassState* stateSprite = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle());
|
||||||
|
if(scene.ShouldBlur) {
|
||||||
|
//Combine nonblur and blur texture
|
||||||
|
stateSprite->Disable(GL_DEPTH_TEST);
|
||||||
|
stateSprite->Disable(GL_STENCIL_TEST);
|
||||||
|
m_CombinedTexture = blurHUDPass->CombineTextures(m_SceneTexture, m_FullBlurredTexture);
|
||||||
|
|
||||||
|
}
|
||||||
|
//Draw Transparen objects
|
||||||
|
//state->BlendFunc(GL_ONE, GL_ONE);
|
||||||
|
//state->StencilFunc(GL_EQUAL, 1, 0xFF);
|
||||||
|
//DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
|
||||||
|
GLERROR("TransparentObjects");
|
||||||
|
//state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
stateSprite->Enable(GL_DEPTH_TEST);
|
||||||
|
//stateSprite->AlphaFunc(GL_GEQUAL, 0.05f);
|
||||||
|
//stateSprite->Enable(GL_ALPHA_TEST);
|
||||||
|
DrawSprites(scene.Jobs.SpriteJob, scene);
|
||||||
|
GLERROR("SpriteJobs");
|
||||||
|
|
||||||
|
delete stateSprite;
|
||||||
GLERROR("END");
|
GLERROR("END");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ bool RenderSystem::isEntityVisible(EntityWrapper& entity)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Hide things parented to local player if they have the HiddenFromLocalPlayer component
|
// Hide things parented to local player if they have the HiddenFromLocalPlayer component
|
||||||
bool outOfBodyExperience = ResourceManager::Load<ConfigFile>("Config.ini")->Get<bool>("Debug.OutOfBodyExperience", false);
|
bool outOfBodyExperience = false; // ResourceManager::Load<ConfigFile>("Config.ini")->Get<bool>("Debug.OutOfBodyExperience", false); // APPARENTLY THIS IS REALLY SLOW
|
||||||
if (
|
if (
|
||||||
(entity.HasComponent("HiddenForLocalPlayer") || entity.FirstParentWithComponent("HiddenForLocalPlayer").Valid())
|
(entity.HasComponent("HiddenForLocalPlayer") || entity.FirstParentWithComponent("HiddenForLocalPlayer").Valid())
|
||||||
&& (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer))
|
&& (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer))
|
||||||
|
|||||||
@@ -210,15 +210,14 @@ void Renderer::Draw(RenderFrame& frame)
|
|||||||
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Light Culling");
|
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Light Culling");
|
||||||
m_LightCullingPass->CullLights(*scene);
|
m_LightCullingPass->CullLights(*scene);
|
||||||
GLERROR("LightCulling");
|
GLERROR("LightCulling");
|
||||||
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Draw Text");
|
|
||||||
//m_TextPass->Draw(*scene, *m_DrawFinalPass->FinalPassFrameBuffer());
|
|
||||||
GLERROR("Draw Text");
|
|
||||||
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Draw Geometry+Light");
|
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Draw Geometry+Light");
|
||||||
m_DrawFinalPass->Draw(*scene, m_BlurHUDPass, m_TextPass);
|
m_DrawFinalPass->Draw(*scene, m_BlurHUDPass);
|
||||||
GLERROR("Draw Geometry+Light");
|
GLERROR("Draw Geometry+Light");
|
||||||
//m_DrawScenePass->Draw(*scene);
|
//m_DrawScenePass->Draw(*scene);
|
||||||
|
|
||||||
|
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Draw Text");
|
||||||
|
m_TextPass->Draw(*scene, *m_DrawFinalPass->FinalPassFrameBuffer());
|
||||||
|
GLERROR("Draw Text");
|
||||||
PerformanceTimer::StopTimer("Renderer-Draw Text");
|
PerformanceTimer::StopTimer("Renderer-Draw Text");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ void TextPass::Update()
|
|||||||
void TextPass::Draw(RenderScene& scene, FrameBuffer& frameBuffer)
|
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.Jobs.Text) {
|
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) {
|
||||||
@@ -43,7 +43,7 @@ void TextPass::Draw(RenderScene& scene, FrameBuffer& frameBuffer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
GLERROR("Derp2");
|
GLERROR("Derp2");
|
||||||
// delete state;
|
delete state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextPass::renderText(std::string text, Font* font, TextJob::AlignmentEnum alignment, glm::vec4 color, glm::mat4 modelMatrix, glm::mat4 projectionMatrix, glm::mat4 viewMatrix)
|
void TextPass::renderText(std::string text, Font* font, TextJob::AlignmentEnum alignment, glm::vec4 color, glm::mat4 modelMatrix, glm::mat4 projectionMatrix, glm::mat4 viewMatrix)
|
||||||
|
|||||||
@@ -4,13 +4,10 @@
|
|||||||
TextPassState::TextPassState(GLuint frameBuffer)
|
TextPassState::TextPassState(GLuint frameBuffer)
|
||||||
{
|
{
|
||||||
BindFramebuffer(frameBuffer);
|
BindFramebuffer(frameBuffer);
|
||||||
Enable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
Disable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
Enable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
Enable(GL_ALPHA_TEST);
|
|
||||||
AlphaFunc(GL_GEQUAL, 0.05f);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextPassState::~TextPassState()
|
TextPassState::~TextPassState()
|
||||||
|
|||||||
+4
-1
@@ -42,7 +42,6 @@
|
|||||||
#include "Game/Systems/StartSystem.h"
|
#include "Game/Systems/StartSystem.h"
|
||||||
#include "Rendering/TextureSprite.h"
|
#include "Rendering/TextureSprite.h"
|
||||||
|
|
||||||
|
|
||||||
Game::Game(int argc, char* argv[])
|
Game::Game(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
parseArgs(argc, argv);
|
parseArgs(argc, argv);
|
||||||
@@ -159,6 +158,8 @@ Game::Game(int argc, char* argv[])
|
|||||||
m_SystemPipeline->AddSystem<StartSystem>(updateOrderLevel);
|
m_SystemPipeline->AddSystem<StartSystem>(updateOrderLevel);
|
||||||
// Populate Octree with collidables
|
// Populate Octree with collidables
|
||||||
++updateOrderLevel;
|
++updateOrderLevel;
|
||||||
|
m_SystemPipeline->AddSystem<Transform::ClearCache>(updateOrderLevel);
|
||||||
|
++updateOrderLevel;
|
||||||
m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeCollision, "Collidable");
|
m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeCollision, "Collidable");
|
||||||
m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeTrigger, "Player");
|
m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeTrigger, "Player");
|
||||||
m_SystemPipeline->AddSystem<AnimationSystem>(updateOrderLevel);
|
m_SystemPipeline->AddSystem<AnimationSystem>(updateOrderLevel);
|
||||||
@@ -174,6 +175,8 @@ Game::Game(int argc, char* argv[])
|
|||||||
++updateOrderLevel;
|
++updateOrderLevel;
|
||||||
m_SystemPipeline->AddSystem<FillFrustumOctreeSystem>(updateOrderLevel, m_OctreeFrustrumCulling);
|
m_SystemPipeline->AddSystem<FillFrustumOctreeSystem>(updateOrderLevel, m_OctreeFrustrumCulling);
|
||||||
++updateOrderLevel;
|
++updateOrderLevel;
|
||||||
|
m_SystemPipeline->AddSystem<Transform::ClearCache>(updateOrderLevel);
|
||||||
|
++updateOrderLevel;
|
||||||
m_SystemPipeline->AddSystem<RenderSystem>(updateOrderLevel, m_Renderer, m_RenderFrame, m_OctreeFrustrumCulling);
|
m_SystemPipeline->AddSystem<RenderSystem>(updateOrderLevel, m_Renderer, m_RenderFrame, m_OctreeFrustrumCulling);
|
||||||
++updateOrderLevel;
|
++updateOrderLevel;
|
||||||
m_SystemPipeline->AddSystem<EditorSystem>(updateOrderLevel, m_Renderer, m_RenderFrame);
|
m_SystemPipeline->AddSystem<EditorSystem>(updateOrderLevel, m_Renderer, m_RenderFrame);
|
||||||
|
|||||||
Reference in New Issue
Block a user