MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / avoid_blocked_view

Method avoid_blocked_view

Engine/source/afx/afxCamera.cpp:660–678  ·  view source on GitHub ↗

See if the camera view is occluded by certain objects, and move the camera closer to the subject in that case

Source from the content-addressed store, hash-verified

658// See if the camera view is occluded by certain objects,
659// and move the camera closer to the subject in that case
660bool afxCamera::avoid_blocked_view(const Point3F& startpos, const Point3F& endpos, Point3F& newpos)
661{
662 // cast ray to check for intersection with potential blocker objects
663 RayInfo hit_info;
664 if (!getContainer()->castRay(startpos, endpos, afxCameraData::sCameraCollisionMask, &hit_info))
665 {
666 // no hit: just return original endpos
667 newpos = endpos;
668 return false;
669 }
670
671 // did hit: return the hit location nudged forward slightly
672 // to avoid seeing clipped portions of blocking object.
673 Point3F sight_line = startpos - hit_info.point;
674 sight_line.normalize();
675 newpos = hit_info.point + sight_line*0.4f;
676
677 return true;
678}
679
680bool afxCamera::test_blocked_line(const Point3F& startpos, const Point3F& endpos)
681{

Callers

nothing calls this directly

Calls 3

getContainerFunction · 0.50
castRayMethod · 0.45
normalizeMethod · 0.45

Tested by

no test coverage detected