| 125 | } |
| 126 | |
| 127 | bool 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 | |
| 178 | static void GetFlattenedDescList(EntityDescriptionList* desc_list, std::vector<EntityDescription*>* flat_desc_list) { |
| 179 | for (auto& desc_index : *desc_list) { |
no test coverage detected