update the entity-this is called every frame and updtae a bunch of various stuff /////////////////////////////////////////////////////////////////
| 1021 | // updtae a bunch of various stuff |
| 1022 | ////////////////////////////////////////////////////////////////////// |
| 1023 | void CEntity::Update( SEntityUpdateContext &ctx ) |
| 1024 | { |
| 1025 | ENTITY_PROFILER |
| 1026 | |
| 1027 | // Decrease awake counter. |
| 1028 | if (m_awakeCounter > 0) |
| 1029 | m_awakeCounter--; |
| 1030 | |
| 1031 | /* |
| 1032 | //[Timur] This is not optimal to do for every entity every frame. |
| 1033 | // [Sergiy] this is a safety check to avoid invalid numbers that come from outside |
| 1034 | // and result in "invisible character" bug (because the entity can't calculate the bbox correctly |
| 1035 | // and can't be registered in a sector |
| 1036 | m_angles = ValidateAngles(m_angles); |
| 1037 | */ |
| 1038 | |
| 1039 | if (m_bIsBound || m_bForceBindCalculation) |
| 1040 | { |
| 1041 | // Must be before potential visibilty check, otherwise child entity position will be wrong. |
| 1042 | // this entity is bound or is forced to be calculated as bound |
| 1043 | CalculateInWorld(); |
| 1044 | |
| 1045 | //[Timur] This is needed for binded Dynamic lights, or they are not passing CheckUpdateVisLevel check. |
| 1046 | if (m_bRecalcBBox) |
| 1047 | { |
| 1048 | // Reregister entity in sectors. |
| 1049 | UnregisterInSector(); |
| 1050 | RegisterInSector(); |
| 1051 | } |
| 1052 | } |
| 1053 | |
| 1054 | // [PETAR] commented out this temp var - not really needed anymore |
| 1055 | // bool bEntityVisible = (ctx.nFrameID == m_nLastVisibleFrameID); |
| 1056 | // m_bWasVisible = bEntityVisible; |
| 1057 | m_bWasVisible = m_bVisible; |
| 1058 | m_bVisible = (m_eUpdateVisLevel==eUT_Unconditional) ? true : ((ctx.nFrameID - m_nLastVisibleFrameID)<MAX_FRAME_ID_STEP_PER_FRAME); |
| 1059 | |
| 1060 | if (m_bVisible != m_bWasVisible) |
| 1061 | OnVisibilityChange(m_bVisible); |
| 1062 | |
| 1063 | // check if entity logic passes selected visibility test |
| 1064 | if (m_eUpdateVisLevel && m_eUpdateVisLevel!=eUT_PhysicsPostStep && m_pEntitySystem->m_pVisCheckForUpdate->GetIVal()) |
| 1065 | { |
| 1066 | if (!CheckUpdateVisLevel( ctx,m_eUpdateVisLevel )) |
| 1067 | { |
| 1068 | return; |
| 1069 | } |
| 1070 | } |
| 1071 | |
| 1072 | // Calculate how many entities where actually updated. |
| 1073 | ctx.numUpdatedEntities++; |
| 1074 | |
| 1075 | if (m_bUpdateSounds) |
| 1076 | UpdateSounds( ctx ); |
| 1077 | |
| 1078 | // should be called before any rendering |
| 1079 | if (m_bVisible) |
| 1080 | { |
no test coverage detected