Start of a movement system with collisions against AABBs

This commit is contained in:
2016-01-13 17:53:54 +01:00
parent d6ef527f25
commit 71d936f8d1
10 changed files with 179 additions and 18 deletions
+23
View File
@@ -17,6 +17,7 @@ void CollisionSystem::UpdateComponent(World* world, ComponentWrapper& cAABB, dou
return;
}
// Collide against octree
std::vector<AABB> octreeResult;
m_Octree->BoxesInSameRegion(*boundingBox, octreeResult);
for (auto& boxB : octreeResult) {
@@ -28,6 +29,28 @@ void CollisionSystem::UpdateComponent(World* world, ComponentWrapper& cAABB, dou
(glm::vec3&)cTransform["Position"] += resolutionVector;
}
}
// HACK: Temporarily collide against all collidable models since they're not in the octree yet
//auto otherCollidables = world->GetComponents("Model");
//for (auto& cModel : *otherCollidables) {
// if (cModel.EntityID == entity) {
// continue;
// }
// if (!world->HasComponent(cModel.EntityID, "Collidable")) {
// continue;
// }
// auto absPosition = RenderQueueFactory::AbsolutePosition(world, cModel.EntityID);
// auto absOrientation = RenderQueueFactory::AbsoluteOrientation(world, cModel.EntityID);
// auto absScale = RenderQueueFactory::AbsoluteScale(world, cModel.EntityID);
// glm::mat4 modelMatrix = glm::translate(absPosition); // *glm::toMat4(absOrientation) * glm::scale(absScale);
// auto model = ResourceManager::Load<Model>(cModel["Resource"]);
// glm::vec3 resolutionVector;
// if (Collision::AABBvsTriangles(boxA, model->m_Vertices, model->m_Indices, modelMatrix, resolutionVector)) {
// (glm::vec3&)cTransform["Position"] += resolutionVector;
// }
//}
}
bool CollisionSystem::OnKeyUp(const Events::KeyUp & event)