Eliminate interior mutability in get_selected_node_list.
This commit is contained in:
parent
701505eb4f
commit
df80265d3a
@ -1329,7 +1329,7 @@ TypedArray<Node> EditorSelection::get_selected_nodes() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
List<Node *> &EditorSelection::get_selected_node_list() {
|
||||
const List<Node *> &EditorSelection::get_selected_node_list() {
|
||||
if (changed) {
|
||||
update();
|
||||
} else {
|
||||
|
@ -318,7 +318,7 @@ public:
|
||||
TypedArray<Node> get_selected_nodes();
|
||||
// Returns only the top level selected nodes.
|
||||
// That is, if the selection includes some node and a child of that node, only the parent is returned.
|
||||
List<Node *> &get_selected_node_list();
|
||||
const List<Node *> &get_selected_node_list();
|
||||
// Returns all the selected nodes (list version of "get_selected_nodes").
|
||||
List<Node *> get_full_selected_node_list();
|
||||
// Returns the map of selected objects and their metadata.
|
||||
|
@ -662,10 +662,10 @@ int Node3DEditorViewport::get_selected_count() const {
|
||||
}
|
||||
|
||||
void Node3DEditorViewport::cancel_transform() {
|
||||
List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
const List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
|
||||
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
|
||||
Node3D *sp = Object::cast_to<Node3D>(E->get());
|
||||
for (Node *E : selection) {
|
||||
Node3D *sp = Object::cast_to<Node3D>(E);
|
||||
if (!sp) {
|
||||
continue;
|
||||
}
|
||||
@ -1227,10 +1227,10 @@ void Node3DEditorViewport::_compute_edit(const Point2 &p_point) {
|
||||
se->original_local = selected->get_transform();
|
||||
se->original = selected->get_global_transform();
|
||||
} else {
|
||||
List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
const List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
|
||||
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
|
||||
Node3D *sp = Object::cast_to<Node3D>(E->get());
|
||||
for (Node *E : selection) {
|
||||
Node3D *sp = Object::cast_to<Node3D>(E);
|
||||
if (!sp) {
|
||||
continue;
|
||||
}
|
||||
@ -2430,7 +2430,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
const List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
|
||||
for (Node *E : selection) {
|
||||
Node3D *sp = Object::cast_to<Node3D>(E);
|
||||
@ -3173,7 +3173,7 @@ void Node3DEditorViewport::_notification(int p_what) {
|
||||
selected_node = ruler_start_point;
|
||||
}
|
||||
} else {
|
||||
List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
const List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
if (selection.size() == 1) {
|
||||
selected_node = Object::cast_to<Node3D>(selection.front()->get());
|
||||
}
|
||||
@ -3566,7 +3566,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
|
||||
|
||||
Transform3D camera_transform = camera->get_global_transform();
|
||||
|
||||
List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
const List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
|
||||
undo_redo->create_action(TTR("Align Transform with View"));
|
||||
|
||||
@ -3612,7 +3612,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
|
||||
|
||||
Transform3D camera_transform = camera->get_global_transform();
|
||||
|
||||
List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
const List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
|
||||
undo_redo->create_action(TTR("Align Rotation with View"));
|
||||
for (Node *E : selection) {
|
||||
@ -4419,7 +4419,7 @@ Vector3 Node3DEditorViewport::_get_instance_position(const Point2 &p_pos, Node3D
|
||||
HashSet<RID> rids;
|
||||
|
||||
if (!preview_node->is_inside_tree() && !ruler->is_inside_tree()) {
|
||||
List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
const List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
|
||||
Node3D *first_selected_node = Object::cast_to<Node3D>(selection.front()->get());
|
||||
|
||||
@ -5078,10 +5078,10 @@ void Node3DEditorViewport::commit_transform() {
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(_transform_name[_edit.mode]);
|
||||
|
||||
List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
const List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
|
||||
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
|
||||
Node3D *sp = Object::cast_to<Node3D>(E->get());
|
||||
for (Node *E : selection) {
|
||||
Node3D *sp = Object::cast_to<Node3D>(E);
|
||||
if (!sp) {
|
||||
continue;
|
||||
}
|
||||
@ -5103,7 +5103,7 @@ void Node3DEditorViewport::commit_transform() {
|
||||
|
||||
void Node3DEditorViewport::apply_transform(Vector3 p_motion, double p_snap) {
|
||||
bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW);
|
||||
List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
const List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
for (Node *E : selection) {
|
||||
Node3D *sp = Object::cast_to<Node3D>(E);
|
||||
if (!sp) {
|
||||
@ -6297,9 +6297,9 @@ void Node3DEditor::update_transform_gizmo() {
|
||||
count++;
|
||||
}
|
||||
} else {
|
||||
List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
|
||||
Node3D *sp = Object::cast_to<Node3D>(E->get());
|
||||
const List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
for (Node *E : selection) {
|
||||
Node3D *sp = Object::cast_to<Node3D>(E);
|
||||
if (!sp) {
|
||||
continue;
|
||||
}
|
||||
@ -6979,7 +6979,7 @@ void Node3DEditor::_menu_item_pressed(int p_option) {
|
||||
case MENU_LOCK_SELECTED: {
|
||||
undo_redo->create_action(TTR("Lock Selected"));
|
||||
|
||||
List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
const List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
|
||||
for (Node *E : selection) {
|
||||
Node3D *spatial = Object::cast_to<Node3D>(E);
|
||||
@ -7000,7 +7000,7 @@ void Node3DEditor::_menu_item_pressed(int p_option) {
|
||||
case MENU_UNLOCK_SELECTED: {
|
||||
undo_redo->create_action(TTR("Unlock Selected"));
|
||||
|
||||
List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
const List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
|
||||
for (Node *E : selection) {
|
||||
Node3D *spatial = Object::cast_to<Node3D>(E);
|
||||
@ -7021,7 +7021,7 @@ void Node3DEditor::_menu_item_pressed(int p_option) {
|
||||
case MENU_GROUP_SELECTED: {
|
||||
undo_redo->create_action(TTR("Group Selected"));
|
||||
|
||||
List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
const List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
|
||||
for (Node *E : selection) {
|
||||
Node3D *spatial = Object::cast_to<Node3D>(E);
|
||||
@ -7041,7 +7041,7 @@ void Node3DEditor::_menu_item_pressed(int p_option) {
|
||||
} break;
|
||||
case MENU_UNGROUP_SELECTED: {
|
||||
undo_redo->create_action(TTR("Ungroup Selected"));
|
||||
List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
const List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
|
||||
for (Node *E : selection) {
|
||||
Node3D *spatial = Object::cast_to<Node3D>(E);
|
||||
@ -7957,7 +7957,7 @@ void Node3DEditor::_refresh_menu_icons() {
|
||||
bool all_grouped = true;
|
||||
bool has_node3d_item = false;
|
||||
|
||||
List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
const List<Node *> &selection = editor_selection->get_selected_node_list();
|
||||
|
||||
if (selection.is_empty()) {
|
||||
all_locked = false;
|
||||
|
@ -1392,7 +1392,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
||||
} break;
|
||||
case TOOL_TOGGLE_SCENE_UNIQUE_NAME: {
|
||||
// Enabling/disabling based on the same node based on which the checkbox in the menu is checked/unchecked.
|
||||
List<Node *>::Element *first_selected = editor_selection->get_selected_node_list().front();
|
||||
const List<Node *>::Element *first_selected = editor_selection->get_selected_node_list().front();
|
||||
if (first_selected == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user