Fixed depth sorting for HUD elements.
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
struct SpriteJob : RenderJob
|
struct SpriteJob : RenderJob
|
||||||
{
|
{
|
||||||
SpriteJob(ComponentWrapper cSprite, Camera* camera, glm::mat4 matrix, World* world, glm::vec4 fillColor, float fillPercentage)
|
SpriteJob(ComponentWrapper cSprite, Camera* camera, glm::mat4 matrix, World* world, glm::vec4 fillColor, float fillPercentage, bool depthSorted)
|
||||||
: RenderJob()
|
: RenderJob()
|
||||||
{
|
{
|
||||||
Model = ResourceManager::Load<::Model>("Models/Core/UnitQuad.mesh");
|
Model = ResourceManager::Load<::Model>("Models/Core/UnitQuad.mesh");
|
||||||
@@ -34,8 +34,11 @@ struct SpriteJob : RenderJob
|
|||||||
Color = cSprite["Color"];
|
Color = cSprite["Color"];
|
||||||
Entity = cSprite.EntityID;
|
Entity = cSprite.EntityID;
|
||||||
Position = Transform::AbsolutePosition(world, cSprite.EntityID);
|
Position = Transform::AbsolutePosition(world, cSprite.EntityID);
|
||||||
glm::vec3 viewpos = glm::vec3(camera->ViewMatrix() * glm::vec4(Position, 1));
|
Depth = 0;
|
||||||
Depth = viewpos.z;
|
if (depthSorted) {
|
||||||
|
glm::vec3 viewpos = glm::vec3(camera->ViewMatrix() * glm::vec4(Position, 1));
|
||||||
|
Depth = viewpos.z;
|
||||||
|
}
|
||||||
World = world;
|
World = world;
|
||||||
|
|
||||||
FillColor = fillColor;
|
FillColor = fillColor;
|
||||||
|
|||||||
@@ -17,33 +17,6 @@ public:
|
|||||||
virtual void Update(double dt) override;
|
virtual void Update(double dt) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//methods which will take care of specific events
|
|
||||||
/* EventRelay<CapturePointSystem, Events::TriggerTouch> m_ETriggerTouch;
|
|
||||||
bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e);
|
|
||||||
EventRelay<CapturePointSystem, Events::TriggerLeave> m_ETriggerLeave;
|
|
||||||
bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e);
|
|
||||||
EventRelay<CapturePointSystem, Events::Captured> m_ECaptured;
|
|
||||||
bool CapturePointSystem::OnCaptured(const Events::Captured& e);*/
|
|
||||||
|
|
||||||
//bool m_WinnerWasFound = false;
|
|
||||||
////need to track these variables for the captureSystem to work as per design!
|
|
||||||
//const int m_NotACapturePoint = 999;
|
|
||||||
//int m_RedTeamNextPossibleCapturePoint = m_NotACapturePoint;
|
|
||||||
//int m_BlueTeamNextPossibleCapturePoint = m_NotACapturePoint;
|
|
||||||
//int m_RedTeamHomeCapturePoint = m_NotACapturePoint;
|
|
||||||
//int m_BlueTeamHomeCapturePoint = m_NotACapturePoint;
|
|
||||||
|
|
||||||
//int m_NumberOfCapturePoints = 0;
|
|
||||||
//std::map<int, EntityWrapper> m_CapturePointNumberToEntityMap;
|
|
||||||
|
|
||||||
////std::vector<ComponentWrapper>
|
|
||||||
|
|
||||||
//const double m_CaptureTimeToTakeOver = 15.0;
|
|
||||||
//bool m_ResetTimers = false;
|
|
||||||
|
|
||||||
////vectors which will keep track of enter/leave changes
|
|
||||||
//std::vector<std::tuple<EntityWrapper, EntityWrapper>> m_ETriggerTouchVector;
|
|
||||||
//std::vector<std::tuple<EntityWrapper, EntityWrapper>> m_ETriggerLeaveVector;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -4,4 +4,5 @@
|
|||||||
<GlowMap></GlowMap>
|
<GlowMap></GlowMap>
|
||||||
<Color R="1" G="1" B="1" A="1"/>
|
<Color R="1" G="1" B="1" A="1"/>
|
||||||
<Visible>true</Visible>
|
<Visible>true</Visible>
|
||||||
|
<DepthSort>true</DepthSort>
|
||||||
</Sprite>
|
</Sprite>
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
<xs:element name="Visible" type="t:bool" minOccurs="0">
|
<xs:element name="Visible" type="t:bool" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>Whether the model is visible or not</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>Whether the model is visible or not</xs:documentation></xs:annotation>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
<xs:element name="DepthSort" type="t:bool" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>Whether the sprite should be sorted with depth or not. Only use false for textures that are on HUD</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
</xs:all>
|
</xs:all>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|||||||
@@ -623,9 +623,13 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
|
|||||||
|
|
||||||
for(auto& job : jobs) {
|
for(auto& job : jobs) {
|
||||||
auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
|
auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
|
||||||
|
RenderState jobState;
|
||||||
|
|
||||||
if (spriteJob) {
|
if (spriteJob) {
|
||||||
|
if(spriteJob->Depth == 0)
|
||||||
|
{
|
||||||
|
jobState.Disable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(spriteJob->Matrix));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(spriteJob->Matrix));
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ void RenderSystem::fillSprites(std::list<std::shared_ptr<RenderJob>>& jobs, Worl
|
|||||||
|
|
||||||
std::string diffuseResource = cSprite["DiffuseTexture"];
|
std::string diffuseResource = cSprite["DiffuseTexture"];
|
||||||
std::string glowResource = cSprite["GlowMap"];
|
std::string glowResource = cSprite["GlowMap"];
|
||||||
|
bool depthSorted = cSprite["DepthSort"];
|
||||||
if (diffuseResource.empty() && glowResource.empty()) {
|
if (diffuseResource.empty() && glowResource.empty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -77,7 +78,8 @@ void RenderSystem::fillSprites(std::list<std::shared_ptr<RenderJob>>& jobs, Worl
|
|||||||
glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, world);
|
glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, world);
|
||||||
//modelMatrix *= m_Camera->BillboardMatrix();
|
//modelMatrix *= m_Camera->BillboardMatrix();
|
||||||
|
|
||||||
std::shared_ptr<SpriteJob> spriteJob = std::shared_ptr<SpriteJob>(new SpriteJob(cSprite, m_Camera, modelMatrix, world, fillColor, fillPercentage));
|
|
||||||
|
std::shared_ptr<SpriteJob> spriteJob = std::shared_ptr<SpriteJob>(new SpriteJob(cSprite, m_Camera, modelMatrix, world, fillColor, fillPercentage, depthSorted));
|
||||||
|
|
||||||
jobs.push_back(spriteJob);
|
jobs.push_back(spriteJob);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user