MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / add_object

Method add_object

editor/editor_data.cpp:114–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114void EditorSelectionHistory::add_object(ObjectID p_object, const String &p_property, bool p_inspector_only) {
115 Object *obj = ObjectDB::get_instance(p_object);
116 ERR_FAIL_NULL(obj);
117 RefCounted *r = Object::cast_to<RefCounted>(obj);
118 _Object o;
119 if (r) {
120 o.ref = Ref<RefCounted>(r);
121 }
122 o.object = p_object;
123 o.property = p_property;
124 o.inspector_only = p_inspector_only;
125
126 bool has_prev = current_elem_idx >= 0 && current_elem_idx < history.size();
127
128 if (has_prev) {
129 history.resize(current_elem_idx + 1); // Clip history to next.
130 }
131
132 HistoryElement h;
133 if (!p_property.is_empty() && has_prev) {
134 // Add a sub property.
135 HistoryElement &prev_element = history.write[current_elem_idx];
136 h = prev_element;
137 h.path.resize(h.level + 1);
138 h.path.push_back(o);
139 h.level++;
140
141 } else {
142 // Create a new history item.
143 h.path.push_back(o);
144 h.level = 0;
145 }
146
147 history.push_back(h);
148 current_elem_idx++;
149}
150
151void EditorSelectionHistory::replace_object(ObjectID p_old_object, ObjectID p_new_object) {
152 for (HistoryElement &element : history) {

Callers 3

_add_to_historyMethod · 0.45
load_sceneMethod · 0.45
_inspect_hovered_nodeMethod · 0.45

Calls 4

sizeMethod · 0.65
resizeMethod · 0.45
is_emptyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected