You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if the ray hits something you have to recalculate the intersection point from scratch via distance * normDir + origin.
hit unit/feature is "returned" by the caller passing a reference, which is confusing and has to be passed even if you're not interested in the values. The types involved also don't make it obvious that they are exclusive since you always pass both.
In that vein how about making it more obvious? Something like (named definitions just for exposition):
using GroundOrWater = bool; // or maybe even std::monostate for a general "some surface"
using WhatWasHit = std::variant <CUnit*, CFeature*, GroundOrWater>;
using Distance = float;
using HitLocation = float3;
using Hit = std::tuple <Distance, HitLocation, WhatWasHit>;
using TraceRayResult = std::optional <Hit>; // empty if didnt hit anything
The text was updated successfully, but these errors were encountered:
Trace rays (
GuiTraceRay
, variousCGround
methods etc) return a float, which is the distance to ray intersection point.-1.0f
. The type doesn't make this magic value obvious and it can ruin math if you forget to take it into account.distance * normDir + origin
.In that vein how about making it more obvious? Something like (named definitions just for exposition):
The text was updated successfully, but these errors were encountered: