Merge branch 'master' into BoxModelCollision

# Conflicts:
#	src/Engine/Collision/CollisionSystem.cpp
This commit is contained in:
William Moberg
2016-01-21 17:16:55 +01:00
135 changed files with 5112 additions and 2254 deletions
@@ -1,11 +1,11 @@
#include "Collision/CollidableOctreeSystem.h"
void CollidableOctreeSystem::Update(World* world, double dt)
void CollidableOctreeSystem::Update(double dt)
{
m_Octree->ClearDynamicObjects();
}
void CollidableOctreeSystem::UpdateComponent(World* world, EntityWrapper& entity, ComponentWrapper& component, double dt)
void CollidableOctreeSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt)
{
if (entity.HasComponent("AABB")) {
boost::optional<AABB> absoluteAABB = Collision::EntityAbsoluteAABB(entity);
+2 -2
View File
@@ -3,7 +3,7 @@
#include "Core/AABB.h"
#include "Rendering/Model.h"
void CollisionSystem::UpdateComponent(World* world, EntityWrapper& entity, ComponentWrapper& component, double dt)
void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt)
{
if (!entity.HasComponent("Physics")) {
return;
@@ -24,7 +24,7 @@ void CollisionSystem::UpdateComponent(World* world, EntityWrapper& entity, Compo
// Collide against octree
//std::vector<AABB> octreeResult;
//m_Octree->BoxesInSameRegion(*boundingBox, octreeResult);
//m_Octree->ObjectsInSameRegion(*boundingBox, octreeResult);
//for (auto& boxB : octreeResult) {
// glm::vec3 resolutionVector;
// if (Collision::IsSameBoxProbably(boxA, boxB)) {
+9 -6
View File
@@ -3,10 +3,10 @@
#include "Core/AABB.h"
#include "Rendering/Model.h"
void TriggerSystem::UpdateComponent(World* world, EntityWrapper& entity, ComponentWrapper& component, double dt)
void TriggerSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt)
{
//Currently only players can trigger things.
auto players = world->GetComponents("Player");
auto players = m_World->GetComponents("Player");
if (players == nullptr) {
return;
}
@@ -18,7 +18,7 @@ void TriggerSystem::UpdateComponent(World* world, EntityWrapper& entity, Compone
}
for (auto& pc : *players) {
EntityID pId = pc.EntityID;
boost::optional<AABB> playerBox = Collision::EntityAbsoluteAABB(EntityWrapper(world, pId));
boost::optional<AABB> playerBox = Collision::EntityAbsoluteAABB(EntityWrapper(m_World, pId));
//The player can't trigger anything without an AABB.
if (!playerBox) {
continue;
@@ -34,9 +34,12 @@ void TriggerSystem::UpdateComponent(World* world, EntityWrapper& entity, Compone
throwLeaveIfWasInTrigger(m_EntitiesCompletelyInTrigger[tId], pId, tId);
} else {
//Entity is at least touching the trigger.
AABB completelyInsideBox = AABB::FromOriginSize((*triggerBox).Origin(), (*triggerBox).Size() - 2.0f * (*playerBox).Size());
if (Collision::AABBVsAABB(completelyInsideBox, *playerBox) &&
glm::all(glm::greaterThan((*triggerBox).Size(), (*playerBox).Size()))) {
AABB completelyInsideBox;
bool playerFitsInTrigger = glm::all(glm::greaterThan((*triggerBox).Size(), (*playerBox).Size()));
if (playerFitsInTrigger) {
completelyInsideBox = AABB::FromOriginSize((*triggerBox).Origin(), (*triggerBox).Size() - 2.0f * (*playerBox).Size());
}
if (playerFitsInTrigger && Collision::AABBVsAABB(completelyInsideBox, *playerBox)) {
//Entity is completely inside the trigger.
//If it was only touching before, it is erased.
m_EntitiesTouchingTrigger[tId].erase(pId);