3D Editor treaks
This commit is contained in:
parent
0b279163de
commit
822c60d839
27 changed files with 254 additions and 124 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue