| 92 | } |
| 93 | |
| 94 | void CEntityLayer::Enable(bool bEnable, bool bSerialize /*=true*/, bool bAllowRecursive /*=true*/) |
| 95 | { |
| 96 | // Wait for the physics thread to avoid massive amounts of ChangeRequest queuing |
| 97 | gEnv->pSystem->SetThreadState(ESubsys_Physics, false); |
| 98 | |
| 99 | #ifdef ENABLE_PROFILING_CODE |
| 100 | bool bChanged = (m_isEnabledBrush != bEnable) || (m_isEnabled != bEnable); |
| 101 | float fStartTime = gEnv->pTimer->GetAsyncCurTime(); |
| 102 | #endif //ENABLE_PROFILING_CODE |
| 103 | |
| 104 | if (bEnable && IsSkippedBySpec()) |
| 105 | return; |
| 106 | |
| 107 | MEMSTAT_LABEL_FMT("Layer '%s' %s", m_name.c_str(), (bEnable ? "Activating" : "Deactivating")); |
| 108 | MEMSTAT_CONTEXT_FMT(EMemStatContextTypes::MSC_Entity, 0, "Layer '%s' %s", m_name.c_str(), (bEnable ? "Activating" : "Deactivating")); |
| 109 | |
| 110 | if (bEnable) |
| 111 | { |
| 112 | if (m_pHeap) |
| 113 | m_pGarbageHeaps->push_back(SEntityLayerGarbage(m_pHeap, m_name)); |
| 114 | } |
| 115 | else // make sure that children are hidden before parents and unhidden after them |
| 116 | { |
| 117 | if (bAllowRecursive && !gEnv->pSystem->IsSerializingFile()) // this check should not be needed now, because Enable() is not used in serialization anymore, but im keeping it for extra sanity check |
| 118 | { |
| 119 | for (std::vector<CEntityLayer*>::iterator it = m_childs.begin(); it != m_childs.end(); ++it) |
| 120 | (*it)->Enable(bEnable); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | EnableBrushes(bEnable); |
| 125 | EnableEntities(bEnable); |
| 126 | |
| 127 | if (bEnable) // make sure that children are hidden before parents and unhidden after them |
| 128 | { |
| 129 | if (bAllowRecursive && !gEnv->pSystem->IsSerializingFile()) // this check should not be needed now, because Enable() is not used in serialization anymore, but im keeping it for extra sanity check |
| 130 | { |
| 131 | for (std::vector<CEntityLayer*>::iterator it = m_childs.begin(); it != m_childs.end(); ++it) |
| 132 | (*it)->Enable(bEnable); |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | m_isSerialized = bSerialize; |
| 137 | |
| 138 | #ifdef ENABLE_PROFILING_CODE |
| 139 | if (CVar::es_LayerDebugInfo == 5 && bChanged) |
| 140 | { |
| 141 | float fTimeMS = (gEnv->pTimer->GetAsyncCurTime() - fStartTime) * 1000.0f; |
| 142 | CEntitySystem::SLayerProfile layerProfile; |
| 143 | layerProfile.pLayer = this; |
| 144 | layerProfile.fTimeOn = gEnv->pTimer->GetCurrTime(); |
| 145 | layerProfile.isEnable = bEnable; |
| 146 | layerProfile.fTimeMS = fTimeMS; |
| 147 | g_pIEntitySystem->m_layerProfiles.insert(g_pIEntitySystem->m_layerProfiles.begin(), layerProfile); |
| 148 | } |
| 149 | #endif //ENABLE_PROFILING_CODE |
| 150 | |
| 151 | if (m_pHeap && m_pHeap->Cleanup()) |
no test coverage detected