MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / ActorsEditor_AddEntity

Function ActorsEditor_AddEntity

Source/Editors/actors_editor.cpp:127–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125}
126
127bool ActorsEditor_AddEntity(SceneGraph* scenegraph, Object* o, std::map<int, int>* id_remap, bool group_addition, bool level_loading) {
128 if (o->GetType() == _env_object && !((EnvObject*)o)->ofr->dynamic) {
129 shadow_cache_dirty = true;
130 }
131 std::vector<Object*> children;
132 o->GetChildren(&children);
133 for (auto& child : children) {
134 int old_id = child->GetID();
135 if (ActorsEditor_AddEntity(scenegraph, child, id_remap, group_addition, level_loading) == false) {
136 LOGE << "Failed adding child entity, removing from self" << std::endl;
137 o->ChildLost(child);
138 delete child;
139 child = NULL;
140 } else {
141 if (old_id != child->GetID() && id_remap == NULL) {
142 LOGW << "id_remap is NULL when adding entity with children" << std::endl;
143 continue;
144 }
145
146 if (id_remap != NULL)
147 id_remap->insert(std::pair<int, int>(old_id, child->GetID()));
148 }
149 }
150
151 if (o->GetType() == _env_object) {
152 ((EnvObject*)o)->added_to_physics_scene_ = false;
153 }
154
155 if (!level_loading || o->GetID() == -1) {
156 scenegraph->AssignID(o);
157 }
158
159 if (scenegraph->addObject(o)) {
160 if (!level_loading) {
161 static const int kBufSize = 256;
162 char msg[kBufSize];
163 FormatString(msg, kBufSize, "added_object %d", o->GetID());
164 scenegraph->level->Message(msg);
165 }
166 return true;
167 } else {
168 LOGE << "Failed at adding entity" << std::endl;
169 for (auto& child : children) {
170 if (child) {
171 child->SetParent(NULL);
172 }
173 }
174 return false;
175 }
176}
177
178static void GetFlattenedDescList(EntityDescriptionList* desc_list, std::vector<EntityDescription*>* flat_desc_list) {
179 for (auto& desc_index : *desc_list) {

Callers 10

AddDynamicDecalMethod · 0.85
PlaceLightProbesFunction · 0.85
GroupSelectedMethod · 0.85
PrefabSelectedMethod · 0.85
HandleShortcutsMethod · 0.85
AddEntityFromDescMethod · 0.85
UpdateTransformToolMethod · 0.85

Calls 10

FormatStringFunction · 0.85
AssignIDMethod · 0.80
addObjectMethod · 0.80
GetTypeMethod · 0.45
GetChildrenMethod · 0.45
GetIDMethod · 0.45
ChildLostMethod · 0.45
insertMethod · 0.45
MessageMethod · 0.45
SetParentMethod · 0.45

Tested by

no test coverage detected