Remove unlogical PrefabManager::IsNotCreatingPrefab (use IsCreatingPrefab flag)

This commit is contained in:
Wojtek Figat
2023-06-09 22:49:19 +02:00
parent a6430692d2
commit d798b10d4c
4 changed files with 4 additions and 11 deletions

View File

@@ -419,7 +419,7 @@ void StaticModel::Serialize(SerializeStream& stream, const void* otherObj)
if (HasLightmap() if (HasLightmap()
#if USE_EDITOR #if USE_EDITOR
&& PrefabManager::IsNotCreatingPrefab && !PrefabManager::IsCreatingPrefab
#endif #endif
) )
{ {

View File

@@ -21,7 +21,6 @@
#if USE_EDITOR #if USE_EDITOR
bool PrefabManager::IsCreatingPrefab = false; bool PrefabManager::IsCreatingPrefab = false;
bool PrefabManager::IsNotCreatingPrefab = true;
Dictionary<Guid, Array<Actor*>> PrefabManager::PrefabsReferences; Dictionary<Guid, Array<Actor*>> PrefabManager::PrefabsReferences;
CriticalSection PrefabManager::PrefabsReferencesLocker; CriticalSection PrefabManager::PrefabsReferencesLocker;
#endif #endif
@@ -316,8 +315,8 @@ bool PrefabManager::CreatePrefab(Actor* targetActor, const StringView& outputPat
LOG(Info, "Creating prefab from actor {0} (total objects count: {2}) to {1}...", targetActor->ToString(), outputPath, sceneObjects->Count()); LOG(Info, "Creating prefab from actor {0} (total objects count: {2}) to {1}...", targetActor->ToString(), outputPath, sceneObjects->Count());
// Serialize to json data // Serialize to json data
ASSERT(!IsCreatingPrefab);
IsCreatingPrefab = true; IsCreatingPrefab = true;
IsNotCreatingPrefab = false;
rapidjson_flax::StringBuffer actorsDataBuffer; rapidjson_flax::StringBuffer actorsDataBuffer;
{ {
CompactJsonWriter writerObj(actorsDataBuffer); CompactJsonWriter writerObj(actorsDataBuffer);
@@ -331,7 +330,6 @@ bool PrefabManager::CreatePrefab(Actor* targetActor, const StringView& outputPat
writer.EndArray(); writer.EndArray();
} }
IsCreatingPrefab = false; IsCreatingPrefab = false;
IsNotCreatingPrefab = true;
// Randomize the objects ids (prevent overlapping of the prefab instance objects ids and the prefab objects ids) // Randomize the objects ids (prevent overlapping of the prefab instance objects ids and the prefab objects ids)
Dictionary<Guid, Guid> objectInstanceIdToPrefabObjectId; Dictionary<Guid, Guid> objectInstanceIdToPrefabObjectId;

View File

@@ -20,7 +20,7 @@ struct Transform;
/// </summary> /// </summary>
API_CLASS(Static) class FLAXENGINE_API PrefabManager API_CLASS(Static) class FLAXENGINE_API PrefabManager
{ {
DECLARE_SCRIPTING_TYPE_NO_SPAWN(PrefabManager); DECLARE_SCRIPTING_TYPE_NO_SPAWN(PrefabManager);
/// <summary> /// <summary>
/// Spawns the instance of the prefab objects. Prefab will be spawned to the first loaded scene. /// Spawns the instance of the prefab objects. Prefab will be spawned to the first loaded scene.
@@ -92,11 +92,6 @@ DECLARE_SCRIPTING_TYPE_NO_SPAWN(PrefabManager);
/// </summary> /// </summary>
static bool IsCreatingPrefab; static bool IsCreatingPrefab;
/// <summary>
/// Helper global state flag set to false during prefab asset creation. Can be used to skip local objects data serialization to prefab data.
/// </summary>
static bool IsNotCreatingPrefab;
/// <summary> /// <summary>
/// Creates the prefab asset from the given root actor. Saves it to the output file path. /// Creates the prefab asset from the given root actor. Saves it to the output file path.
/// </summary> /// </summary>

View File

@@ -287,7 +287,7 @@ void TerrainChunk::Serialize(SerializeStream& stream, const void* otherObj)
if (HasLightmap() if (HasLightmap()
#if USE_EDITOR #if USE_EDITOR
&& PrefabManager::IsNotCreatingPrefab && !PrefabManager::IsCreatingPrefab
#endif #endif
) )
{ {