| 1355 | } |
| 1356 | |
| 1357 | bool Terrain::Chunk::getIntersectPointWithRay(const Ray& ray, Vec3& intersectPoint) |
| 1358 | { |
| 1359 | if (!ray.intersects(_aabb)) |
| 1360 | return false; |
| 1361 | |
| 1362 | float minDist = FLT_MAX; |
| 1363 | bool isFind = false; |
| 1364 | for (const auto& triangle : _trianglesList) |
| 1365 | { |
| 1366 | Vec3 p; |
| 1367 | if (triangle.getIntersectPoint(ray, p)) |
| 1368 | { |
| 1369 | float dist = ray._origin.distance(p); |
| 1370 | if (dist < minDist) |
| 1371 | { |
| 1372 | intersectPoint = p; |
| 1373 | minDist = dist; |
| 1374 | } |
| 1375 | isFind = true; |
| 1376 | } |
| 1377 | } |
| 1378 | |
| 1379 | return isFind; |
| 1380 | } |
| 1381 | |
| 1382 | void Terrain::Chunk::updateVerticesForLOD() |
| 1383 | { |
no test coverage detected