| 1087 | } |
| 1088 | |
| 1089 | void SceneGraph::UnlinkObject(Object* o) { |
| 1090 | int id = o->GetID(); |
| 1091 | Object* object_at_id = GetIdToObjectMapValue(object_from_id_map_, id); |
| 1092 | |
| 1093 | LOGD << "Unlinking object: " << *o << std::endl; |
| 1094 | destruction_sanity_insert_position = (destruction_sanity_insert_position + 1) % destruction_sanity_size; |
| 1095 | destruction_sanity[destruction_sanity_insert_position] = o; |
| 1096 | |
| 1097 | destruction_memory_insert_position = (destruction_memory_insert_position + 1) % destruction_memory_size; |
| 1098 | |
| 1099 | destruction_memory_ids[destruction_memory_insert_position] = o->GetID(); |
| 1100 | o->GetDisplayName(&destruction_memory_strings[destruction_memory_insert_position * destruction_memory_string_size], destruction_memory_string_size - 1); |
| 1101 | |
| 1102 | if (object_at_id != NULL) { |
| 1103 | if (o != object_at_id) { |
| 1104 | LOGW << "Object removal mismatch." << std::endl; |
| 1105 | } |
| 1106 | |
| 1107 | SetIdToObjectMapValue(object_from_id_map_, id, NULL); |
| 1108 | } |
| 1109 | |
| 1110 | if (o == terrain_object_) { |
| 1111 | terrain_object_ = NULL; |
| 1112 | } |
| 1113 | |
| 1114 | RemoveObjFromList(o, &visible_objects_); |
| 1115 | RemoveDerivedObjFromListAndIndex(_env_object, o, &visible_static_meshes_, &visible_static_meshes_shadow_cache_bounds_, &visible_static_mesh_indices_); |
| 1116 | RemoveDerivedObjFromList(_terrain_type, o, &terrain_objects_, &terrain_objects_shadow_cache_bounds_); |
| 1117 | RemoveObjFromList(o, &collide_objects_); |
| 1118 | RemoveObjFromList(o, &movement_objects_); |
| 1119 | RemoveObjFromList(o, &item_objects_); |
| 1120 | RemoveObjFromList(o, &decal_objects_); |
| 1121 | RemoveObjFromList(o, &objects_); |
| 1122 | if (RemoveObjFromList(o, &hotspots_)) |
| 1123 | hotspots_modified_ = true; |
| 1124 | RemoveObjFromList(o, &navmesh_hints_); |
| 1125 | RemoveObjFromList(o, &navmesh_connections_); |
| 1126 | RemoveObjFromList(o, &path_points_); |
| 1127 | RemoveDerivedObjFromList(_light_volume_object, o, &light_volume_objects_); |
| 1128 | |
| 1129 | for (decal_deque::iterator it = dynamic_decals.begin(); it != dynamic_decals.end();) { |
| 1130 | DecalObject* obj = *it; |
| 1131 | if (obj == o) { |
| 1132 | it = dynamic_decals.erase(it); |
| 1133 | } else { |
| 1134 | ++it; |
| 1135 | } |
| 1136 | } |
| 1137 | |
| 1138 | for (auto& i : sanity_list) { |
| 1139 | if (i.GetID() == id) { |
| 1140 | i = ObjectSanityState(); |
| 1141 | } |
| 1142 | } |
| 1143 | } |
| 1144 | |
| 1145 | Object* SceneGraph::GetObjectFromID(int object_id) { |
| 1146 | Object* object_at_id = GetIdToObjectMapValue(object_from_id_map_, object_id); |
no test coverage detected