Merge remote-tracking branch 'origin/master' into WeaponSystem
# Conflicts: # src/Game/Systems/SoundSystem.cpp
This commit is contained in:
@@ -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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -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>
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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()
|
||||||
|
|||||||
@@ -23,7 +23,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,6 +66,10 @@ bool SoundSystem::OnInputCommand(const Events::InputCommand & e)
|
|||||||
|
|
||||||
void SoundSystem::playerJumps()
|
void SoundSystem::playerJumps()
|
||||||
{
|
{
|
||||||
|
if (!LocalPlayer.Valid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bool grounded = (bool)m_World->GetComponent(LocalPlayer.ID, "Physics")["IsOnGround"];
|
bool grounded = (bool)m_World->GetComponent(LocalPlayer.ID, "Physics")["IsOnGround"];
|
||||||
if (grounded) {
|
if (grounded) {
|
||||||
Events::PlaySoundOnEntity e;
|
Events::PlaySoundOnEntity e;
|
||||||
@@ -121,11 +125,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 = LocalPlayer;
|
ev.Emitter = LocalPlayer;
|
||||||
ev.FilePaths = paths;
|
ev.FilePaths = paths;
|
||||||
|
|||||||
Reference in New Issue
Block a user