mirror of
https://github.com/godotengine/godot.git
synced 2024-11-27 06:33:16 +00:00
Clean preview_node of all none VisualInstances
This commit is contained in:
parent
9f058674ac
commit
45b8bb745e
@ -3984,6 +3984,37 @@ AABB Node3DEditorViewport::_calculate_spatial_bounds(const Node3D *p_parent, boo
|
||||
return bounds;
|
||||
}
|
||||
|
||||
Node *Node3DEditorViewport::_sanitize_preview_node(Node *p_node) const {
|
||||
Node3D *node_3d = Object::cast_to<Node3D>(p_node);
|
||||
if (node_3d == nullptr) {
|
||||
Node3D *replacement_node = memnew(Node3D);
|
||||
replacement_node->set_name(p_node->get_name());
|
||||
p_node->replace_by(replacement_node);
|
||||
memdelete(p_node);
|
||||
p_node = replacement_node;
|
||||
} else {
|
||||
VisualInstance3D *visual_instance = Object::cast_to<VisualInstance3D>(node_3d);
|
||||
if (visual_instance == nullptr) {
|
||||
Node3D *replacement_node = memnew(Node3D);
|
||||
replacement_node->set_name(node_3d->get_name());
|
||||
replacement_node->set_visible(node_3d->is_visible());
|
||||
replacement_node->set_transform(node_3d->get_transform());
|
||||
replacement_node->set_rotation_edit_mode(node_3d->get_rotation_edit_mode());
|
||||
replacement_node->set_rotation_order(node_3d->get_rotation_order());
|
||||
replacement_node->set_as_top_level(node_3d->is_set_as_top_level());
|
||||
p_node->replace_by(replacement_node);
|
||||
memdelete(p_node);
|
||||
p_node = replacement_node;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < p_node->get_child_count(); i++) {
|
||||
_sanitize_preview_node(p_node->get_child(i));
|
||||
}
|
||||
|
||||
return p_node;
|
||||
}
|
||||
|
||||
void Node3DEditorViewport::_create_preview(const Vector<String> &files) const {
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
String path = files[i];
|
||||
@ -4000,6 +4031,7 @@ void Node3DEditorViewport::_create_preview(const Vector<String> &files) const {
|
||||
if (scene.is_valid()) {
|
||||
Node *instance = scene->instantiate();
|
||||
if (instance) {
|
||||
instance = _sanitize_preview_node(instance);
|
||||
preview_node->add_child(instance);
|
||||
}
|
||||
}
|
||||
|
@ -384,6 +384,9 @@ private:
|
||||
|
||||
Vector3 _get_instance_position(const Point2 &p_pos) const;
|
||||
static AABB _calculate_spatial_bounds(const Node3D *p_parent, bool p_exclude_top_level_transform = true);
|
||||
|
||||
Node *_sanitize_preview_node(Node *p_node) const;
|
||||
|
||||
void _create_preview(const Vector<String> &files) const;
|
||||
void _remove_preview();
|
||||
bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node);
|
||||
|
Loading…
Reference in New Issue
Block a user