Compare commits

..

1 Commits

Author SHA1 Message Date
verysecrethero 6f739e22f3 Crash fix for: if you delete a team component in editor. 2016-01-22 10:10:39 +01:00
6 changed files with 10 additions and 28 deletions
+1 -1
Submodule assets updated: f7e349a316...6ffb46e155
-1
View File
@@ -27,7 +27,6 @@ private:
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
Texture* m_WhiteTexture;
Texture* m_NeutralNormalMap;
const IRenderer* m_Renderer;
const LightCullingPass* m_LightCullingPass;
+3 -12
View File
@@ -5,8 +5,7 @@ uniform mat4 V;
uniform mat4 P;
uniform vec4 Color;
uniform vec2 ScreenDimensions;
layout(binding = 0) uniform sampler2D DiffuseTexture;
layout(binding = 1) uniform sampler2D NormalMapTexture;
uniform sampler2D texture0;
#define TILE_SIZE 16
@@ -45,8 +44,6 @@ layout (std430, binding = 4) buffer LightIndexBuffer
in VertexData{
vec3 Position;
vec3 Normal;
vec3 Tangent;
vec3 BiTangent;
vec2 TextureCoordinate;
vec4 DiffuseColor;
}Input;
@@ -99,18 +96,12 @@ LightResult CalcDirectionalLightSource(vec4 direction, vec4 color, float intensi
return result;
}
vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textureCoordinate, sampler2D normalMap)
{
mat3 TBN = mat3(tangent, bitangent, normal);
vec3 NormalMap = texture(normalMap, textureCoordinate).xyz * 2.0 - vec3(1.0);
return vec4(TBN * normalize(NormalMap), 0.0);
}
void main()
{
vec4 texel = texture2D(DiffuseTexture, Input.TextureCoordinate);
vec4 texel = texture2D(texture0, Input.TextureCoordinate);
vec4 position = V * M * vec4(Input.Position, 1.0);
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, NormalMapTexture);
vec4 normal = V * vec4(Input.Normal, 0.0);
vec4 viewVec = normalize(-position);
vec2 tilePos;
-4
View File
@@ -19,8 +19,6 @@ layout(location = 10) in vec4 BoneWeights2;
out VertexData{
vec3 Position;
vec3 Normal;
vec3 Tangent;
vec3 BiTangent;
vec2 TextureCoordinate;
vec4 DiffuseColor;
}Output;
@@ -32,7 +30,5 @@ void main()
Output.Position = Position;
Output.TextureCoordinate = TextureCoords;
Output.Normal = vec3(M * vec4(Normal, 0.0));
Output.Tangent = vec3(M * vec4(Tangent, 0.0));
Output.BiTangent = vec3(M * vec4(BiTangent, 0.0));
Output.DiffuseColor = DiffuseVertexColor;
}
-10
View File
@@ -11,7 +11,6 @@ DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCulling
void DrawFinalPass::InitializeTextures()
{
m_WhiteTexture = ResourceManager::Load<Texture>("Textures/Core/Blank.png");
m_NeutralNormalMap = ResourceManager::Load<Texture>("Textures/Core/NeutralNormalMap.png");
}
void DrawFinalPass::InitializeShaderPrograms()
@@ -60,15 +59,6 @@ void DrawFinalPass::Draw(RenderScene& scene)
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
}
if (modelJob->NormalTexture != nullptr) {
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, modelJob->NormalTexture->m_Texture);
}
else {
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, m_NeutralNormalMap->m_Texture);
}
glBindVertexArray(modelJob->Model->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
glDrawElementsBaseVertex(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, 0, modelJob->StartIndex);
+6
View File
@@ -66,6 +66,9 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper
nextPossibleCapturePoint["Blue"] = -1;
for (size_t i = 0; i < m_NumberOfCapturePoints; i++)
{
if (!m_World->HasComponent(m_CapturePointNumberToEntityIDMap[i], "Team")) {
continue;
}
ComponentWrapper& capturePointOwnedBy = m_World->GetComponent(m_CapturePointNumberToEntityIDMap[i], "Team");
if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint == 0) {
nextPossibleCapturePoint["Red"] = i + 1;
@@ -76,6 +79,9 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper
}
for (int i = m_NumberOfCapturePoints - 1; i >= 0; i--)
{
if (!m_World->HasComponent(m_CapturePointNumberToEntityIDMap[i], "Team")) {
continue;
}
ComponentWrapper& capturePointOwnedBy = m_World->GetComponent(m_CapturePointNumberToEntityIDMap[i], "Team");
if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint != 0) {
nextPossibleCapturePoint["Red"] = i - 1;