MCPcopy Create free account
hub / github.com/axmolengine/axmol / getIntersectPointWithRay

Method getIntersectPointWithRay

core/3d/Terrain.cpp:1357–1380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1355}
1356
1357bool 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
1382void Terrain::Chunk::updateVerticesForLOD()
1383{

Callers 1

getIntersectionPointMethod · 0.80

Calls 3

intersectsMethod · 0.45
getIntersectPointMethod · 0.45
distanceMethod · 0.45

Tested by

no test coverage detected