Skip to content
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

GuiTraceRay from theater ray intersection instead of camera position. #1782

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions rts/Game/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,16 @@ float3 CCamera::NearTheaterIntersection(const float3& dir, const float rayLength
if (pos.y < maxAltitude)
return pos;

const auto fv1 = TracePointToMaxAltitude(GetFrustumVert(CCamera::FRUSTUM_POINT_FBL), rayLength, maxAltitude);
const auto fv2 = TracePointToMaxAltitude(GetFrustumVert(CCamera::FRUSTUM_POINT_FBR), rayLength, maxAltitude);
const auto fbl = GetFrustumVert(CCamera::FRUSTUM_POINT_FBL);
const auto fbr = GetFrustumVert(CCamera::FRUSTUM_POINT_FBR);
const auto ftl = GetFrustumVert(CCamera::FRUSTUM_POINT_FTL);

// check the bottom frustum is parallel to ground and lower than the top frustum
if ((std::abs(fbl.y-fbr.y) > std::numeric_limits<float>::epsilon()) || (fbl.y >= ftl.y))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

epscmp exists, perhaps use that? Maybe std::numerlic_limits<T>::epsilon() could even become the default for its 3rd arg:

template<class T> inline bool epscmp(const T a, const T b, const T eps) {

return pos;

const auto fv1 = TracePointToMaxAltitude(fbl, rayLength, maxAltitude);
const auto fv2 = TracePointToMaxAltitude(fbr, rayLength, maxAltitude);
if (!fv1 || !fv2)
return pos;

Expand Down