27#ifndef ICB_LINEOFSIGHT_H_INCLUDED
28#define ICB_LINEOFSIGHT_H_INCLUDED
30#include "engines/icb/p4.h"
31#include "engines/icb/debug.h"
32#include "engines/icb/event_list.h"
33#include "engines/icb/event_manager.h"
34#include "engines/icb/common/px_linkeddatafile.h"
35#include "engines/icb/common/px_route_barriers.h"
36#include "engines/icb/common/px_string.h"
37#include "engines/icb/common/px_3drealpoint.h"
41#define LOS_LOG "LOS_log.txt"
44#define LOS_DEFAULT_MEGA_FIELD_OF_VIEW 180
49#define LOS_DEFAULT_OBJECT_HEIGHT_OF_VIEW (100 * REAL_ONE)
52#define LOS_DEFAULT_OBJECT_SEEING_DISTANCE 2000
55#define LOS_DEFAULT_SUBSCRIBERS_PER_CYCLE 3
58#define LOS_1D_SIZE (MAX_session_objects)
59#define LOS_2D_ROWSIZE_PACKED (MAX_session_objects / 8)
60#define LOS_2D_SIZE_PACKED (MAX_session_objects * LOS_2D_ROWSIZE_PACKED)
67 enum { ACTOR_EYE_HEIGHT = 160 };
68 enum { ACTOR_CROUCHED_HEIGHT = 61 };
69 enum ActorEyeMode { USE_OBJECT_VALUE = 0, FORCE_EYE_HEIGHT, FORCE_CROUCHED_HEIGHT };
79 void Subscribe(uint32 nObserverID, uint32 nTargetID);
80 void UnSubscribe(uint32 nObserverID, uint32 nTargetID);
84 void Suspend(uint32 nObserverID);
85 inline void Unsuspend(uint32 nObserverID);
90 void SwitchOn() { m_bSwitchedOn = TRUE8; }
97 inline void SetDutyCycle(uint32 nSubsPerCycle) { m_nSubsPerCycle = nSubsPerCycle; }
100 void SetFieldOfView(uint32 nID, uint32 nFieldOfView);
103 void SetSightRange(uint32 nID, uint32 nRange);
106 void SetSightHeight(uint32 nID, uint32 nHeight);
109 inline void SetCanSeeInDarkFlag(uint32 nID, bool8 bState);
112 inline void SetNeverInShadowFlag(uint32 nID, bool8 bState);
115 inline void ShadowsOnOff(bool8 bState) { m_bHandleShadows = bState; }
118 bool8 ObjectToObject(uint32 nObserverID, uint32 nTargetID, eBarrierRayType eRayType, bool8 bCanSeeUs, ActorEyeMode eEyeMode, bool8 bOverrideHeightLimit = FALSE8);
121 inline bool8 LineOfSight(uint32 nObserverID, uint32 nTargetID);
124 const px3DRealPoint GetLastImpactPoint()
const {
return (m_oImpactPoint); }
125 eBarrierLogicValue GetLastImpactType()
const {
return (m_eImpactType); }
128 LinkedDataFile *GetSlicesPointer()
const {
return (m_pyLOSData); }
130 bool8 FailingOnHeight()
const {
return (m_bFailingOnHeight); }
134 uint32 m_nSubsPerCycle;
135 uint32 m_nFirstSubscriber;
136 uint32 m_nNumObjects;
137 uint32 m_nTotalCurrentSubscribers;
138 uint32 m_pnFieldOfView[LOS_1D_SIZE];
139 uint32 m_pnSeeingDistance[LOS_1D_SIZE];
140 PXreal m_pfHeightOfView[LOS_1D_SIZE];
141 int32 m_pnSubscribeNum[LOS_1D_SIZE];
142 uint8 m_pnTable[LOS_2D_SIZE_PACKED];
143 uint8 m_pnSubscribers[LOS_2D_SIZE_PACKED];
144 bool8 m_pbSuspended[LOS_1D_SIZE];
145 bool8 m_pbCanSeeInDark[LOS_1D_SIZE];
146 bool8 m_pbIgnoreShadows[LOS_1D_SIZE];
148 eBarrierLogicValue m_eImpactType;
150 bool8 m_bFailingOnHeight;
151 bool8 m_bHandleShadows;
161 bool8 InFieldOfView(PXreal fLookingX, PXreal fLookingZ, PXfloat fLookingDirection, PXreal fObservedX, PXreal fObservedZ, uint32 nFieldOfView)
const;
163 inline void SetPackedBit(uint8 *pnArray, uint32 i, uint32 j, bool8 bValue);
164 inline bool8 GetPackedBit(uint8 *pnArray, uint32 i, uint32 j)
const;
169inline _line_of_sight::_line_of_sight() {
170 m_bSwitchedOn = TRUE8;
171 m_nSubsPerCycle = LOS_DEFAULT_SUBSCRIBERS_PER_CYCLE;
172 m_nFirstSubscriber = 0;
175 m_nTotalCurrentSubscribers = 0;
176 m_bHandleShadows = TRUE8;
180inline _line_of_sight::~_line_of_sight() {
184 Zdebug(
"Destroyed line-of-sight object");
187inline void _line_of_sight::Unsuspend(uint32 nObserverID) {
189 m_pbSuspended[nObserverID] = FALSE8;
192inline void _line_of_sight::SetCanSeeInDarkFlag(uint32 nID, bool8 bState) {
194 m_pbCanSeeInDark[nID] = bState;
197inline void _line_of_sight::SetNeverInShadowFlag(uint32 nID, bool8 bState) {
199 m_pbIgnoreShadows[nID] = bState;
202inline bool8 _line_of_sight::LineOfSight(uint32 nObserverID, uint32 nTargetID) {
return (GetPackedBit(m_pnTable, nObserverID, nTargetID)); }
204inline void _line_of_sight::SwitchOff() {
205 m_bSwitchedOn = FALSE8;
207 memset((uint8 *)m_pnTable, 0, (
size_t)(LOS_2D_SIZE_PACKED *
sizeof(uint8)));
210inline void _line_of_sight::SetPackedBit(uint8 *pnArray, uint32 i, uint32 j, bool8 bValue) {
211 uint32 nJIndex = j >> 3;
212 uint32 nJRemainder = (j & 0x00000007);
215 pnArray[i * LOS_2D_ROWSIZE_PACKED + nJIndex] |= (uint8)(1 << nJRemainder);
217 pnArray[i * LOS_2D_ROWSIZE_PACKED + nJIndex] &= (uint8)(~(1 << nJRemainder));
220inline bool8 _line_of_sight::GetPackedBit(uint8 *pnArray, uint32 i, uint32 j)
const {
221 uint32 nJIndex = j >> 3;
222 uint32 nJRemainder = (j & 0x00000007);
224 if ((pnArray[i * LOS_2D_ROWSIZE_PACKED + nJIndex] & (uint8)(1 << nJRemainder)) != 0)
Definition: line_of_sight.h:64
Definition: px_3drealpoint.h:45
Definition: px_linkeddatafile.h:53