11 protected ref array<IEntity> m_aExcludeArray;
22 static SCR_BasePreviewEntity SpawnPreviewFromEditableOwner(IEntity entity, ResourceName previewPrefab, BaseWorld world =
null, EntitySpawnParams spawnParams =
null, ResourceName material = ResourceName.Empty,
EPreviewEntityFlag flags = 0)
26 return SpawnPreviewFromEditableEntity(editableEntity, previewPrefab, world, spawnParams, material, flags);
43 Print(
"No entity defined", LogLevel.WARNING);
46 array<ref SCR_BasePreviewEntry> entries = GetPreviewEntriesFromEditableEntity(entity, spawnParams, flags);
47 return SpawnPreview(entries, previewPrefab, world, spawnParams, material, flags);
58 static SCR_BasePreviewEntity SpawnPreviewFromEditableEntities(notnull set<SCR_EditableEntityComponent> entities, ResourceName previewPrefab, BaseWorld world =
null, EntitySpawnParams spawnParams =
null, ResourceName material = ResourceName.Empty,
EPreviewEntityFlag flags = 0)
60 if (!entities || entities.IsEmpty())
62 Print(
"No editable entities defined", LogLevel.WARNING);
66 EntitySpawnParams spawnParamsLocal = spawnParams;
67 if (!spawnParamsLocal)
68 spawnParamsLocal =
new EntitySpawnParams();
71 array<IEntity> excludeArray = {};
73 trace =
new TraceParam();
75 array<ref SCR_BasePreviewEntry> entries = {};
76 set<SCR_EditableEntityComponent> entitiesCopy =
new set<SCR_EditableEntityComponent>;
77 entitiesCopy.Copy(entities);
79 while (!entitiesCopy.IsEmpty())
83 if (entityParent && entitiesCopy.Find(entityParent) != -1)
91 GetPreviewEntries(entity, entries, spawnParamsLocal.Transform, -1, flags, trace);
92 entitiesCopy.Remove(
index);
96 return SpawnPreview(entries, previewPrefab, world, spawnParamsLocal, material, flags);
109 spawnParams =
new EntitySpawnParams();
113 trace =
new TraceParam();
115 array<ref SCR_BasePreviewEntry> entries = {};
116 GetPreviewEntries(entity, entries, spawnParams.Transform, -1, flags, trace);
126 static void GetPreviewEntries(
SCR_EditableEntityComponent entity, out notnull array<ref SCR_BasePreviewEntry> outEntries, out vector rootTransform[4],
int parentID = -1,
EPreviewEntityFlag flags = 0, TraceParam trace =
null)
128 IEntity owner = entity.GetOwner();
132 entity.GetTransform(transform);
133 SaveRootTransform(transform, rootTransform);
148 (!owner.GetVObject().ToMeshObject())
151 (!(owner.GetFlags() & EntityFlags.VISIBLE) || (owner.GetFlags() & EntityFlags.EDITOR_ONLY))
156 entity.GetLocalTransform(transform);
160 entry.m_iParentID = parentID;
161 parentID = outEntries.Insert(entry);
163 entry.m_Entity = owner;
164 entry.SaveTransform(transform);
165 entry.SetScale(GetLocalScale(entry.m_Entity));
166 entry.m_iPivotID = GetPivotName(entry.m_Entity);
168 if (GetMesh(entry.m_Entity, flags, entry, outEntries))
182 SaveTerrainTransform(entry.m_Entity, entry, isUnderwater, trace);
187 entry.m_vAnglesTerrain = Vector(0, entry.m_vAngles[1], entry.m_vAngles[2]);
188 entry.m_vHeightTerrain = entry.m_vPosition[1];
194 set<IEntity> childOwners =
new set<IEntity>();
199 set<SCR_EditableEntityComponent> children = entity.GetChildrenRef();
202 for (
int i = 0, count = children.Count(); i < count; i++)
204 GetPreviewEntries(children[i], outEntries, rootTransform, parentID, flags);
205 childOwners.Insert(children[i].
GetOwner());
213 IEntity child = entry.m_Entity.GetChildren();
216 if (!childOwners.Contains(child))
217 GetPreviewEntries(child, outEntries, rootTransform, parentID, flags);
219 child = child.GetSibling();
231 return m_EditableEntity;
237 array<IEntity> GetExcludeArray()
239 return m_aExcludeArray;
244 super.EOnPreviewInit(entry, root);
250 SCR_EditablePreviewComponent previewEditableEntity = SCR_EditablePreviewComponent.Cast(FindComponent(SCR_EditablePreviewComponent));
251 if (previewEditableEntity)
253 if (m_EditableEntity)
254 previewEditableEntity.InitFromEntity(m_EditableEntity);
260 override protected void EOnRootPreviewInit(array<ref SCR_BasePreviewEntry> entries)
262 m_aExcludeArray = {};
265 m_aExcludeArray.Insert(entry.m_Entity);