-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FrustumIntersection does not have testLine #292
Comments
Hey @xupwup , |
This is as fast as I can get it (twice as fast as your version (11.824 ns/op vs. 22.818 ns/op in JMH) with the Vector3f objects):
public boolean testLine(float aX, float aY, float aZ, float bX, float bY, float bZ) {
float da, db;
da = Math.fma(nxX, aX, Math.fma(nxY, aY, Math.fma(nxZ, aZ, nxW)));
db = Math.fma(nxX, bX, Math.fma(nxY, bY, Math.fma(nxZ, bZ, nxW)));
if (da < 0.0f && db < 0.0f)
return false;
if (da * db < 0.0f) {
float p = Math.abs(da) / Math.abs(db - da);
float dx = Math.fma(bX - aX, p, aX), dy = Math.fma(bY - aY, p, aY), dz = Math.fma(bZ - aZ, p, aZ);
if (da < 0.0f) {
aX = dx; aY = dy; aZ = dz;
} else {
bX = dx; bY = dy; bZ = dz;
}
}
da = Math.fma(pxX, aX, Math.fma(pxY, aY, Math.fma(pxZ, aZ, pxW)));
db = Math.fma(pxX, bX, Math.fma(pxY, bY, Math.fma(pxZ, bZ, pxW)));
if (da < 0.0f && db < 0.0f)
return false;
if (da * db < 0.0f) {
float p = Math.abs(da) / Math.abs(db - da);
float dx = Math.fma(bX - aX, p, aX), dy = Math.fma(bY - aY, p, aY), dz = Math.fma(bZ - aZ, p, aZ);
if (da < 0.0f) {
aX = dx; aY = dy; aZ = dz;
} else {
bX = dx; bY = dy; bZ = dz;
}
}
da = Math.fma(nyX, aX, Math.fma(nyY, aY, Math.fma(nyZ, aZ, nyW)));
db = Math.fma(nyX, bX, Math.fma(nyY, bY, Math.fma(nyZ, bZ, nyW)));
if (da < 0.0f && db < 0.0f)
return false;
if (da * db < 0.0f) {
float p = Math.abs(da) / Math.abs(db - da);
float dx = Math.fma(bX - aX, p, aX), dy = Math.fma(bY - aY, p, aY), dz = Math.fma(bZ - aZ, p, aZ);
if (da < 0.0f) {
aX = dx; aY = dy; aZ = dz;
} else {
bX = dx; bY = dy; bZ = dz;
}
}
da = Math.fma(pyX, aX, Math.fma(pyY, aY, Math.fma(pyZ, aZ, pyW)));
db = Math.fma(pyX, bX, Math.fma(pyY, bY, Math.fma(pyZ, bZ, pyW)));
if (da < 0.0f && db < 0.0f)
return false;
if (da * db < 0.0f) {
float p = Math.abs(da) / Math.abs(db - da);
float dx = Math.fma(bX - aX, p, aX), dy = Math.fma(bY - aY, p, aY), dz = Math.fma(bZ - aZ, p, aZ);
if (da < 0.0f) {
aX = dx; aY = dy; aZ = dz;
} else {
bX = dx; bY = dy; bZ = dz;
}
}
da = Math.fma(nzX, aX, Math.fma(nzY, aY, Math.fma(nzZ, aZ, nzW)));
db = Math.fma(nzX, bX, Math.fma(nzY, bY, Math.fma(nzZ, bZ, nzW)));
if (da < 0.0f && db < 0.0f)
return false;
if (da * db < 0.0f) {
float p = Math.abs(da) / Math.abs(db - da);
float dx = Math.fma(bX - aX, p, aX), dy = Math.fma(bY - aY, p, aY), dz = Math.fma(bZ - aZ, p, aZ);
if (da < 0.0f) {
aX = dx; aY = dy; aZ = dz;
} else {
bX = dx; bY = dy; bZ = dz;
}
}
da = Math.fma(pzX, aX, Math.fma(pzY, aY, Math.fma(pzZ, aZ, pzW)));
db = Math.fma(pzX, bX, Math.fma(pzY, bY, Math.fma(pzZ, bZ, pzW)));
return da >= 0.0f || db >= 0.0f;
} |
Yep, you're right. Well spotted |
Could this be added? This is what I've been using until now, but it would be nice if it were included in JOML.
The text was updated successfully, but these errors were encountered: