intersection.set(ray.origin); } else { ray.getEndPoint(intersection, t);
intersection.set(ray.origin); } else { ray.getEndPoint(intersection, t);
public Vector3 getRayIntersection(Vector3 out, Ray ray) { // TODO improve performance. use binary search float curDistance = 2; int rounds = 0; ray.getEndPoint(out, curDistance); boolean isUnder = isUnderTerrain(out); while (true) { rounds++; ray.getEndPoint(out, curDistance); boolean u = isUnderTerrain(out); if (u != isUnder || rounds == 10000) { return out; } curDistance += u ? -0.1f : 0.1f; } }
intersection.set(ray.origin); } else { ray.getEndPoint(intersection, t);
Vector3 rayEnd = getProjectManager().current().currScene.currentSelection.getLocalPosition(temp0); float dst = getProjectManager().current().currScene.cam.position.dst(rayEnd); rayEnd = ray.getEndPoint(rayEnd, dst);