Skip to content

Commit 522445e

Browse files
committed
Cast several seen rays per frame to improve unseen responsiveness
1 parent 98544f4 commit 522445e

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

Source/Entities/ACrab.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,9 @@ bool ACrab::IsWithinRange(Vector& point) const {
689689
}
690690

691691
bool ACrab::Look(float FOVSpread, float range) {
692-
if (!g_SceneMan.AnythingUnseen(m_Team) || m_CanRevealUnseen == false)
692+
if (!g_SceneMan.AnythingUnseen(m_Team) || m_CanRevealUnseen == false) {
693693
return false;
694+
}
694695

695696
// Set the length of the look vector
696697
float aimDistance = m_AimDistance + range;

Source/Entities/AHuman.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1233,8 +1233,9 @@ bool AHuman::IsWithinRange(Vector& point) const {
12331233
}
12341234

12351235
bool AHuman::Look(float FOVSpread, float range) {
1236-
if (!g_SceneMan.AnythingUnseen(m_Team) || m_CanRevealUnseen == false)
1236+
if (!g_SceneMan.AnythingUnseen(m_Team) || m_CanRevealUnseen == false) {
12371237
return false;
1238+
}
12381239

12391240
// Set the length of the look vector
12401241
float aimDistance = m_AimDistance + range;

Source/Entities/Actor.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,9 @@ Controller::InputMode Actor::SwapControllerModes(Controller::InputMode newMode,
570570
}
571571

572572
bool Actor::Look(float FOVSpread, float range) {
573-
if (!g_SceneMan.AnythingUnseen(m_Team) || m_CanRevealUnseen == false)
573+
if (!g_SceneMan.AnythingUnseen(m_Team) || m_CanRevealUnseen == false) {
574574
return false;
575+
}
575576

576577
// Use the 'eyes' on the 'head', if applicable
577578
Vector aimPos = GetEyePos();
@@ -1090,12 +1091,18 @@ void Actor::Update() {
10901091
m_ViewPoint = m_Pos;
10911092

10921093
// "See" the location and surroundings of this actor on the unseen map
1093-
if (m_Status != Actor::INACTIVE)
1094-
Look(45 * m_Perceptiveness, g_FrameMan.GetPlayerScreenWidth() * 0.51 * m_Perceptiveness);
1094+
// Todo - split MT safe and potentially expensive stuff like this in a seperate ThreadedUpdate for the C++ side
1095+
if (m_Status != Actor::INACTIVE) {
1096+
const int lookIterations = 6; // How many see rays to cast per frame
1097+
for (int i = 0; i < lookIterations; ++i) {
1098+
Look(45 * m_Perceptiveness, g_FrameMan.GetPlayerScreenWidth() * 0.51 * m_Perceptiveness);
1099+
}
1100+
}
10951101

10961102
// Check if the MO we're following still exists, and if not, then clear the destination
1097-
if (m_pMOMoveTarget && !g_MovableMan.ValidMO(m_pMOMoveTarget))
1103+
if (m_pMOMoveTarget && !g_MovableMan.ValidMO(m_pMOMoveTarget)) {
10981104
m_pMOMoveTarget = 0;
1105+
}
10991106

11001107
///////////////////////////////////////////////////////////////////////////////
11011108
// Check for manual player-made progress made toward the set AI goal

0 commit comments

Comments
 (0)