Merge remote-tracking branch 'origin/master' into Importer

# Conflicts:
#	assets
This commit is contained in:
antc13
2016-02-11 00:08:17 +01:00
11 changed files with 74 additions and 33 deletions
+2 -1
View File
@@ -79,7 +79,8 @@ bool AABBVsAABB(const AABB& a, const AABB& b);
bool AABBVsAABB(const AABB& a, const AABB& b, glm::vec3& minimumTranslation); bool AABBVsAABB(const AABB& a, const AABB& b, glm::vec3& minimumTranslation);
// Calculates an absolute AABB from an entity AABB component // Calculates an absolute AABB from an entity AABB component
boost::optional<EntityAABB> EntityAbsoluteAABB(EntityWrapper& entity); boost::optional<EntityAABB> EntityAbsoluteAABB(EntityWrapper& entity, bool takeModelBox = false);
boost::optional<EntityAABB> AbsoluteAABBExplosionEffect(EntityWrapper& entity);
} }
+1 -1
View File
@@ -4,7 +4,7 @@
// } // }
// NOTE: condition statement is not executed at all in release mode. // NOTE: condition statement is not executed at all in release mode.
#ifndef DEBUG_IF #ifndef DEBUG_IF
#ifndef DEBUG #ifdef DEBUG
#define DEBUG_IF(c) if(c) #define DEBUG_IF(c) if(c)
#else #else
#define DEBUG_IF(c) if(false) #define DEBUG_IF(c) if(false)
@@ -4,5 +4,8 @@
<xs:import schemaLocation="../Types.xsd" namespace="types"/> <xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="Collidable"> <xs:element name="Collidable">
<xs:annotation>
<xs:documentation>Needs a Model or AABB component to work, uses AABB if both are attached.</xs:documentation>
</xs:annotation>
</xs:element> </xs:element>
</xs:schema> </xs:schema>
+3
View File
@@ -4,5 +4,8 @@
<xs:import schemaLocation="../Types.xsd" namespace="types"/> <xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="Trigger"> <xs:element name="Trigger">
<xs:annotation>
<xs:documentation>Needs a Model or AABB component to work, uses AABB if both are attached.</xs:documentation>
</xs:annotation>
</xs:element> </xs:element>
</xs:schema> </xs:schema>
@@ -9,8 +9,14 @@
<Entity> <Entity>
<Components> <Components>
<c:SceneLight/> <c:SceneLight/>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Model> <c:Model>
<Resource>Models/Test/SplatMapTest.mesh</Resource> <Resource>Models/Ground.mesh</Resource>
</c:Model> </c:Model>
<c:Transform/> <c:Transform/>
</Components> </Components>
+10 -10
View File
@@ -151,8 +151,6 @@ vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textu
return vec4(TBN * normalize(NormalMap), 0.0); return vec4(TBN * normalize(NormalMap), 0.0);
} }
#define TEXTURE_TILE 5.0
vec4 CalcBlendedTexel(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B, sampler2D A, sampler2D D, vec4 CalcBlendedTexel(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B, sampler2D A, sampler2D D,
vec2 R_TileValues, vec2 G_TileValues, vec2 B_TileValues, vec2 A_TileValues, vec2 D_TileValues){ vec2 R_TileValues, vec2 G_TileValues, vec2 B_TileValues, vec2 A_TileValues, vec2 D_TileValues){
vec4 R_Channel = texture2D(R, Input.TextureCoordinate * R_TileValues); vec4 R_Channel = texture2D(R, Input.TextureCoordinate * R_TileValues);
@@ -163,10 +161,11 @@ vec4 CalcBlendedTexel(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B, sa
float total = blendValue.r + blendValue.g + blendValue.b + blendValue.a; float total = blendValue.r + blendValue.g + blendValue.b + blendValue.a;
if(total > 1.0f){ if(total > 1.0f){
blendValue.r / total; float totalDiv = 1.0f / total;
blendValue.g / total; blendValue.r = blendValue.r * totalDiv;
blendValue.b / total; blendValue.g = blendValue.g * totalDiv;
blendValue.a / total; blendValue.b = blendValue.b * totalDiv;
blendValue.a = blendValue.a * totalDiv;
} }
float D_percent = clamp( 1.0f - total, 0.0f, 1.0f); float D_percent = clamp( 1.0f - total, 0.0f, 1.0f);
@@ -188,10 +187,11 @@ vec4 CalcBlendedNormal(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B, s
float total = blendValue.r + blendValue.g + blendValue.b + blendValue.a; float total = blendValue.r + blendValue.g + blendValue.b + blendValue.a;
if(total > 1.0f){ if(total > 1.0f){
blendValue.r / total; float totalDiv = 1 / total;
blendValue.g / total; blendValue.r = blendValue.r * totalDiv;
blendValue.b / total; blendValue.g = blendValue.g * totalDiv;
blendValue.a / total; blendValue.b = blendValue.b * totalDiv;
blendValue.a = blendValue.a * totalDiv;
} }
float D_percent = clamp( 1.0f - total, 0.0f, 1.0f); float D_percent = clamp( 1.0f - total, 0.0f, 1.0f);
+28 -2
View File
@@ -565,10 +565,10 @@ bool AABBvsTriangles(const AABB& box,
return hit; return hit;
} }
boost::optional<EntityAABB> EntityAbsoluteAABB(EntityWrapper& entity) boost::optional<EntityAABB> EntityAbsoluteAABB(EntityWrapper& entity, bool takeModelBox)
{ {
AABB modelSpaceBox; AABB modelSpaceBox;
if (entity.HasComponent("AABB")) { if (entity.HasComponent("AABB") && !takeModelBox) {
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")) {
@@ -612,4 +612,30 @@ boost::optional<EntityAABB> EntityAbsoluteAABB(EntityWrapper& entity)
return aabb; return aabb;
} }
boost::optional<EntityAABB> AbsoluteAABBExplosionEffect(EntityWrapper& entity)
{
boost::optional<EntityAABB> modelBox = EntityAbsoluteAABB(entity, true);
if (!modelBox) {
return boost::none;
}
bool isRandom = (bool)entity["ExplosionEffect"]["Randomness"];
float random = isRandom ? (float)(double)entity["ExplosionEffect"]["RandomnessScalar"] : 0;
glm::vec3 origin = (glm::vec3)entity["ExplosionEffect"]["ExplosionOrigin"];
glm::vec3 randomVel = (glm::vec3)entity["ExplosionEffect"]["Velocity"];
randomVel *= (random + 1);
float endVelocity = randomVel.y;
if ((bool)entity["ExplosionEffect"]["ExponentialAccelaration"]) {
endVelocity *= endVelocity / 2.f;
}
float maxRadius = (float)(double)entity["ExplosionEffect"]["ExplosionDuration"] * endVelocity;
glm::vec3 size;
AABB explosionBox(origin - (size / 2.f), origin + (size / 2.f));
glm::vec3 mini = glm::min(explosionBox.MinCorner(), (*modelBox).MinCorner());
glm::vec3 maxi = glm::max(explosionBox.MaxCorner(), (*modelBox).MaxCorner());
EntityAABB aabb = AABB(mini, maxi);
aabb.Entity = entity;
return aabb;
}
} }
@@ -7,15 +7,13 @@ void FillFrustumOctreeSystem::Update(double dt)
void FillFrustumOctreeSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) void FillFrustumOctreeSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt)
{ {
boost::optional<EntityAABB> absoluteAABB;
if (entity.HasComponent("ExplosionEffect")) { if (entity.HasComponent("ExplosionEffect")) {
//TODO: Fix hack, get real box by using shader equation. absoluteAABB = Collision::AbsoluteAABBExplosionEffect(entity);
EntityAABB aabb = AABB(glm::vec3(-300), glm::vec3(300));
aabb.Entity = entity;
m_Octree->AddDynamicObject(aabb);
} else { } else {
boost::optional<EntityAABB> absoluteAABB = Collision::EntityAbsoluteAABB(entity); absoluteAABB = Collision::EntityAbsoluteAABB(entity, true);
if (absoluteAABB) { }
m_Octree->AddDynamicObject(*absoluteAABB); if (absoluteAABB) {
} m_Octree->AddDynamicObject(*absoluteAABB);
} }
} }
+1 -1
View File
@@ -135,7 +135,7 @@ Model::Model(std::string fileName)
maxi = glm::max(maxi, v.Position); maxi = glm::max(maxi, v.Position);
} }
m_Box = AABB(maxi, mini); m_Box = AABB(mini, maxi);
} }
Model::~Model() Model::~Model()
+2 -1
View File
@@ -30,9 +30,10 @@ Texture::Texture(std::string path)
glBindTexture(GL_TEXTURE_2D, m_Texture); glBindTexture(GL_TEXTURE_2D, m_Texture);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, format, image.Width, image.Height, 0, format, GL_UNSIGNED_BYTE, image.Data); glTexImage2D(GL_TEXTURE_2D, 0, format, image.Width, image.Height, 0, format, GL_UNSIGNED_BYTE, image.Data);
glGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
GLERROR("Texture load"); GLERROR("Texture load");
} }
+9 -6
View File
@@ -25,7 +25,7 @@ void SoundSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cComp
void SoundSystem::Update(double dt) void SoundSystem::Update(double dt)
{ {
// Temp for play test. // Temp for play test.
if(m_DrumsIsPlaying) { if (m_DrumsIsPlaying) {
m_DrumsIsPlaying = !drumTimer(dt); m_DrumsIsPlaying = !drumTimer(dt);
} }
} }
@@ -69,6 +69,9 @@ bool SoundSystem::OnInputCommand(const Events::InputCommand & e)
void SoundSystem::playerJumps() void SoundSystem::playerJumps()
{ {
if (!m_LocalPlayer.Valid()) {
return;
}
bool grounded = (bool)m_World->GetComponent(m_LocalPlayer.ID, "Physics")["IsOnGround"]; bool grounded = (bool)m_World->GetComponent(m_LocalPlayer.ID, "Physics")["IsOnGround"];
if (grounded) { if (grounded) {
Events::PlaySoundOnEntity e; Events::PlaySoundOnEntity e;
@@ -124,11 +127,11 @@ bool SoundSystem::OnPlayerDamage(const Events::PlayerDamage & e)
std::vector<std::string> paths; std::vector<std::string> paths;
paths.push_back("Audio/hurt/hurt" + std::to_string(rand) + ".wav"); paths.push_back("Audio/hurt/hurt" + std::to_string(rand) + ".wav");
// // Breathe // // Breathe
// int ammountOfbreaths = (static_cast<int>(e.Damage) / 10) + 2; // TEMP: Idk something stupid like this shit // int ammountOfbreaths = (static_cast<int>(e.Damage) / 10) + 2; // TEMP: Idk something stupid like this shit
// for (int i = 0; i < ammountOfbreaths; i++) { // for (int i = 0; i < ammountOfbreaths; i++) {
// paths.push_back("Audio/exhausted/breath.wav"); // paths.push_back("Audio/exhausted/breath.wav");
// } // }
Events::PlayQueueOnEntity ev; Events::PlayQueueOnEntity ev;
ev.Emitter = m_LocalPlayer; ev.Emitter = m_LocalPlayer;
ev.FilePaths = paths; ev.FilePaths = paths;