Skip to content

Commit

Permalink
make guiInWorld tolerant to invalid rays
Browse files Browse the repository at this point in the history
  • Loading branch information
malytomas committed Nov 24, 2023
1 parent 99bdfb4 commit 8ba5fa6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sources/libsimple/guiInWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ namespace cage

struct Intersection
{
Vec3 wp; // world position
Vec3 wp = Vec3::Nan(); // world position
Vec2 gp; // gui position in 0*0 .. w*h
bool intersects = false;
};

CAGE_FORCE_INLINE Intersection detect(const Line &ray) const
{
Intersection res;
if (!ray.valid())
return res;
const Transform tr = config.renderEntity->value<TransformComponent>();
const Plane pl = Plane(tr.position, tr.orientation * Vec3(0, 0, -1));
res.wp = cage::intersection(pl, ray);
Expand Down

0 comments on commit 8ba5fa6

Please sign in to comment.