MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / HasLineOfSight

Function HasLineOfSight

TombEngine/Scripting/Internal/TEN/Util/Util.cpp:47–55  ·  view source on GitHub ↗

Determine if there is a clear line of sight between two positions. Limited to room geometry. Objects are ignored. @function HasLineOfSight @tparam float roomID Room ID of the first position's room. @tparam Vec3 posA First position. @tparam Vec3 posB Second position. @treturn bool true if there is a line of sight, false if not. @usage local flamePlinthPos = flamePlinth:GetPosition() + Vec3(0, flame

Source from the content-addressed store, hash-verified

45 // local test = TEN.Util.HasLineOfSight(enemyHead:GetRoomNumber(), enemyHead:GetPosition(), flamePlinthPos);
46 // print(tostring(test))
47 static bool HasLineOfSight(int roomID, const Vec3& posA, const Vec3& posB)
48 {
49 auto vector0 = posA.ToGameVector();
50 auto vector1 = posB.ToGameVector();
51
52 StaticMesh* mesh = nullptr;
53 auto vector = Vector3i::Zero;
54 return (LOS(&vector0, &vector1) && ObjectOnLOS2(&vector0, &vector1, &vector, &mesh) == NO_LOS_ITEM);
55 }
56
57 /// Calculate the horizontal distance between two positions.
58 // @function CalculateHorizontalDistance

Callers

nothing calls this directly

Calls 3

LOSFunction · 0.85
ObjectOnLOS2Function · 0.85
ToGameVectorMethod · 0.80

Tested by

no test coverage detected