3D Editor treaks

This commit is contained in:
IlyaShurupov 2024-11-05 12:26:48 +03:00 committed by Ilya Shurupov
parent 8d167b960a
commit 573541ba2d
27 changed files with 254 additions and 124 deletions

View file

@ -48,4 +48,39 @@ bool tp::Scene::loadOBJFormat(const std::string& objetsPath) {
}
return mObjects.size();
}
const tp::RayCastData& tp::Scene::castRay(const Ray& ray, alnf farVal) {
auto& out = mRayCastData;
out.hit = false;
out.obj = nullptr;
farVal *= farVal;
for (auto obj : mObjects) {
for (auto trig : obj->mCache.TrigCaches) {
if (trig->castRay(ray)) {
auto dist = (TrigCache::getHitPos() - ray.pos).length2();
if (farVal > dist && dist > EPSILON) {
out.trig = &trig.data();
out.hitPos = TrigCache::getHitPos();
out.obj = &obj.data();
out.hit = true;
farVal = dist;
}
}
}
}
return mRayCastData;
}
void tp::Scene::updateCache() {
for (auto obj : mObjects) {
obj->mCache.updateCache();
}
}