Dawn/archive/physics/ScenePhysicsManager.cpp

36 lines
892 B
C++

// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "ScenePhysicsManager.hpp"
#include "scene/Scene.hpp"
#include "scene/components/physics/3d/Collider3D.hpp"
using namespace Dawn;
ScenePhysicsManager::ScenePhysicsManager(Scene *scene) {
this->scene = scene;
}
void ScenePhysicsManager::update() {
}
std::vector<struct Collider3DRayResult> ScenePhysicsManager::raycast3DAll(
struct Ray3D ray
) {
// TODO: Optimize the crap out of this.
struct Collider3DRayResult result;
auto colliders = scene->findComponents<Collider3D>();
std::vector<struct Collider3DRayResult> results;
auto itCollider = colliders.begin();
while(itCollider != colliders.end()) {
if((*itCollider)->raycast(&result, ray)) {
results.push_back(result);
}
++itCollider;
}
return results;
}