Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

…lines 1–27 unchanged (27 lines)
28/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29/**************************************************************************/
30
31#include "camera_3d_editor_plugin.h"
32
33#include "core/config/project_settings.h"
34#include "editor/editor_node.h"
35#include "node_3d_editor_plugin.h"
36#include "scene/gui/texture_rect.h"
37#include "scene/main/viewport.h"
38
39void Camera3DEditor::_node_removed(Node *p_node) {
40 if (p_node == node) {
41 node = nullptr;
42 Node3DEditor::get_singleton()->set_custom_camera(nullptr);
…lines 43–74 unchanged (32 lines)
75 preview->set_offset(SIDE_LEFT, -60);
76 preview->set_offset(SIDE_RIGHT, 0);
77 preview->set_offset(SIDE_TOP, 0);
78 preview->set_offset(SIDE_BOTTOM, 10);
79 preview->connect(SceneStringName(pressed), callable_mp(this, &Camera3DEditor::_pressed));
80}
81
82void Camera3DPreview::_update_sub_viewport_size() {
83 sub_viewport->set_size(Node3DEditor::get_camera_viewport_size(camera));
84}
85
86Camera3DPreview::Camera3DPreview(Camera3D *p_camera) :
87 TexturePreview(nullptr, false), camera(p_camera), sub_viewport(memnew(SubViewport)) {
88 RenderingServer::get_singleton()->viewport_attach_camera(sub_viewport->get_viewport_rid(), camera->get_camera());
89 add_child(sub_viewport);
90
91 TextureRect *display = get_texture_display();
92 display->set_texture(sub_viewport->get_texture());
93 sub_viewport->connect("size_changed", callable_mp((CanvasItem *)display, &CanvasItem::queue_redraw));
94 sub_viewport->get_texture()->connect_changed(callable_mp((TexturePreview *)this, &Camera3DPreview::_update_texture_display_ratio));
95
96 ProjectSettings::get_singleton()->connect("settings_changed", callable_mp(this, &Camera3DPreview::_project_settings_changed));
97 _project_settings_changed();
98}
99
100void Camera3DPreview::_project_settings_changed() {
…lines 101–137 unchanged (37 lines)

After

…lines 1–27 unchanged (27 lines)
28/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29/**************************************************************************/
30
31#include "camera_3d_editor_plugin.h"
32
33#include "core/config/project_settings.h"
34#include "node_3d_editor_plugin.h"
35#include "scene/gui/aspect_ratio_container.h"
36#include "scene/gui/foldable_container.h"
37#include "scene/gui/subviewport_container.h"
38#include "scene/main/viewport.h"
39
40void Camera3DEditor::_node_removed(Node *p_node) {
41 if (p_node == node) {
42 node = nullptr;
43 Node3DEditor::get_singleton()->set_custom_camera(nullptr);
…lines 44–76 unchanged (33 lines)
77 preview->set_offset(SIDE_RIGHT, 0);
78 preview->set_offset(SIDE_TOP, 0);
79 preview->set_offset(SIDE_BOTTOM, 10);
80 preview->connect(SceneStringName(pressed), callable_mp(this, &Camera3DEditor::_pressed));
81}
82
83bool Camera3DPreview::camera_preview_folded = false;
84
85void Camera3DPreview::_update_sub_viewport_size() {
86 const Size2i camera_size = Node3DEditor::get_camera_viewport_size(camera);
87 centering_container->set_ratio(camera_size.aspect());
88}
89
90void Camera3DPreview::_toggle_folding(bool p_folded) {
91 camera_preview_folded = p_folded;
92}
93
94Camera3DPreview::Camera3DPreview(Camera3D *p_camera) {
95 camera = p_camera;
96
97 FoldableContainer *folder = memnew(FoldableContainer);
98 folder->set_title(TTRC("Camera Preview"));
99 folder->set_title_text_overrun_behavior(TextServer::OVERRUN_TRIM_ELLIPSIS);
100 folder->set_folded(camera_preview_folded);
101 folder->connect("folding_changed", callable_mp(this, &Camera3DPreview::_toggle_folding));
102 add_child(folder);
103
104 centering_container = memnew(AspectRatioContainer);
105 centering_container->set_custom_minimum_size(Size2(0.0, 256.0) * EDSCALE);
106 folder->add_child(centering_container);
107
108 SubViewportContainer *sub_viewport_container = memnew(SubViewportContainer);
109 sub_viewport_container->set_stretch(true);
110 sub_viewport_container->set_texture_filter(TEXTURE_FILTER_NEAREST_WITH_MIPMAPS);
111 centering_container->add_child(sub_viewport_container);
112
113 sub_viewport = memnew(SubViewport);
114 sub_viewport_container->add_child(sub_viewport);
115
116 RenderingServer::get_singleton()->viewport_attach_camera(sub_viewport->get_viewport_rid(), camera->get_camera());
117
118 ProjectSettings::get_singleton()->connect("settings_changed", callable_mp(this, &Camera3DPreview::_project_settings_changed));
119 _project_settings_changed();
120}
121
122void Camera3DPreview::_project_settings_changed() {
123 _update_sub_viewport_size();
…lines 124–159 unchanged (36 lines)

Before

translation_unit
comment "/***********************************************************"...
comment "/* camera_3d_editor_plugin.cpp "...
comment "/***********************************************************"...
comment "/* This file is part of: "...
comment "/* GODOT ENGINE "...
comment "/* https://godotengine.org "...
comment "/***********************************************************"...
comment "/* Copyright (c) 2014-present Godot Engine contributors (see"...
comment "/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. "...
comment "/* "...
comment "/* Permission is hereby granted, free of charge, to any pers"...
comment "/* a copy of this software and associated documentation file"...
comment "/* \"Software\"), to deal in the Software without restriction,"...
comment "/* without limitation the rights to use, copy, modify, merge"...
comment "/* distribute, sublicense, and/or sell copies of the Softwar"...
comment "/* permit persons to whom the Software is furnished to do so"...
comment "/* the following conditions: "...
comment "/* "...
comment "/* The above copyright notice and this permission notice sha"...
comment "/* included in all copies or substantial portions of the Sof"...
comment "/* "...
comment "/* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY"...
comment "/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARR"...
comment "/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON"...
comment "/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIA"...
comment "/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION O"...
comment "/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION "...
comment "/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. "...
comment "/***********************************************************"...
preproc_include
#include "#include"
string_literal
" "\""
string_content "camera_3d_editor_plugin.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "core/config/project_settings.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "editor/editor_node.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "node_3d_editor_plugin.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "scene/gui/texture_rect.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "scene/main/viewport.h"
" "\""
function_definition (+63 nodes collapsed)
function_definition (+59 nodes collapsed)
function_definition (+128 nodes collapsed)
function_definition (+175 nodes collapsed)
function_definition
primitive_type "void"
function_declarator
qualified_identifier
namespace_identifier "Camera3DPreview"
:: "::"
identifier "_update_sub_viewport_size"
parameter_list
( "("
) ")"
compound_statement
{ "{"
expression_statement
call_expression
field_expression
identifier "sub_viewport"
-> "->"
field_identifier "set_size"
argument_list
( "("
call_expression
qualified_identifier
namespace_identifier "Node3DEditor"
:: "::"
identifier "get_camera_viewport_size"
argument_list
( "("
identifier "camera"
) ")"
) ")"
; ";"
} "}"
function_definition
function_declarator
qualified_identifier
namespace_identifier "Camera3DPreview"
:: "::"
identifier "Camera3DPreview"
parameter_list
( "("
parameter_declaration
type_identifier "Camera3D"
pointer_declarator
* "*"
identifier "p_camera"
) ")"
field_initializer_list
: ":"
field_initializer
field_identifier "TexturePreview"
argument_list
( "("
null
nullptr "nullptr"
, ","
false "false"
) ")"
, ","
field_initializer
field_identifier "camera"
argument_list
( "("
identifier "p_camera"
) ")"
, ","
field_initializer
field_identifier "sub_viewport"
argument_list
( "("
call_expression
identifier "memnew"
argument_list
( "("
identifier "SubViewport"
) ")"
) ")"
compound_statement
{ "{"
expression_statement (+34 nodes collapsed)
expression_statement
call_expression
identifier "add_child"
argument_list
( "("
identifier "sub_viewport"
) ")"
; ";"
declaration
type_identifier "TextureRect"
init_declarator
pointer_declarator
* "*"
identifier "display"
= "="
call_expression
identifier "get_texture_display"
argument_list
( "("
) ")"
; ";"
expression_statement
call_expression
field_expression
identifier "display"
-> "->"
field_identifier "set_texture"
argument_list
( "("
call_expression
field_expression
identifier "sub_viewport"
-> "->"
field_identifier "get_texture"
argument_list
( "("
) ")"
) ")"
; ";"
expression_statement
call_expression
field_expression
identifier "sub_viewport"
-> "->"
field_identifier "connect"
argument_list
( "("
string_literal
" "\""
string_content "size_changed"
" "\""
, ","
call_expression
identifier "callable_mp"
argument_list
( "("
cast_expression
( "("
type_descriptor
type_identifier "CanvasItem"
abstract_pointer_declarator
* "*"
) ")"
identifier "display"
, ","
pointer_expression
& "&"
qualified_identifier
namespace_identifier "CanvasItem"
:: "::"
identifier "queue_redraw"
) ")"
) ")"
; ";"
expression_statement
call_expression
field_expression
call_expression
field_expression
identifier "sub_viewport"
-> "->"
field_identifier "get_texture"
argument_list
( "("
) ")"
-> "->"
field_identifier "connect_changed"
argument_list
( "("
call_expression
identifier "callable_mp"
argument_list
( "("
cast_expression
( "("
type_descriptor
type_identifier "TexturePreview"
abstract_pointer_declarator
* "*"
) ")"
this "this"
, ","
pointer_expression
& "&"
qualified_identifier
namespace_identifier "Camera3DPreview"
:: "::"
identifier "_update_texture_display_ratio"
) ")"
) ")"
; ";"
expression_statement (+35 nodes collapsed)
expression_statement
call_expression
identifier "_project_settings_changed"
argument_list
( "("
) ")"
; ";"
} "}"
function_definition (+68 nodes collapsed)
function_definition (+40 nodes collapsed)
function_definition (+68 nodes collapsed)
function_definition (+50 nodes collapsed)
function_definition (+35 nodes collapsed)
function_definition (+46 nodes collapsed)
function_definition (+40 nodes collapsed)

After

translation_unit
comment "/***********************************************************"...
comment "/* camera_3d_editor_plugin.cpp "...
comment "/***********************************************************"...
comment "/* This file is part of: "...
comment "/* GODOT ENGINE "...
comment "/* https://godotengine.org "...
comment "/***********************************************************"...
comment "/* Copyright (c) 2014-present Godot Engine contributors (see"...
comment "/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. "...
comment "/* "...
comment "/* Permission is hereby granted, free of charge, to any pers"...
comment "/* a copy of this software and associated documentation file"...
comment "/* \"Software\"), to deal in the Software without restriction,"...
comment "/* without limitation the rights to use, copy, modify, merge"...
comment "/* distribute, sublicense, and/or sell copies of the Softwar"...
comment "/* permit persons to whom the Software is furnished to do so"...
comment "/* the following conditions: "...
comment "/* "...
comment "/* The above copyright notice and this permission notice sha"...
comment "/* included in all copies or substantial portions of the Sof"...
comment "/* "...
comment "/* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY"...
comment "/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARR"...
comment "/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON"...
comment "/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIA"...
comment "/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION O"...
comment "/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION "...
comment "/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. "...
comment "/***********************************************************"...
preproc_include
#include "#include"
string_literal
" "\""
string_content "camera_3d_editor_plugin.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "core/config/project_settings.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "node_3d_editor_plugin.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "scene/gui/aspect_ratio_container.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "scene/gui/foldable_container.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "scene/gui/subviewport_container.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "scene/main/viewport.h"
" "\""
function_definition (+63 nodes collapsed)
function_definition (+59 nodes collapsed)
function_definition (+128 nodes collapsed)
function_definition (+175 nodes collapsed)
declaration
primitive_type "bool"
init_declarator
qualified_identifier
namespace_identifier "Camera3DPreview"
:: "::"
identifier "camera_preview_folded"
= "="
false "false"
; ";"
function_definition
primitive_type "void"
function_declarator
qualified_identifier
namespace_identifier "Camera3DPreview"
:: "::"
identifier "_update_sub_viewport_size"
parameter_list
( "("
) ")"
compound_statement
{ "{"
declaration
type_qualifier
const "const"
type_identifier "Size2i"
init_declarator
identifier "camera_size"
= "="
call_expression
qualified_identifier
namespace_identifier "Node3DEditor"
:: "::"
identifier "get_camera_viewport_size"
argument_list
( "("
identifier "camera"
) ")"
; ";"
expression_statement
call_expression
field_expression
identifier "centering_container"
-> "->"
field_identifier "set_ratio"
argument_list
( "("
call_expression
field_expression
identifier "camera_size"
. "."
field_identifier "aspect"
argument_list
( "("
) ")"
) ")"
; ";"
} "}"
function_definition
primitive_type "void"
function_declarator
qualified_identifier
namespace_identifier "Camera3DPreview"
:: "::"
identifier "_toggle_folding"
parameter_list
( "("
parameter_declaration
primitive_type "bool"
identifier "p_folded"
) ")"
compound_statement
{ "{"
expression_statement
assignment_expression
identifier "camera_preview_folded"
= "="
identifier "p_folded"
; ";"
} "}"
function_definition
function_declarator
qualified_identifier
namespace_identifier "Camera3DPreview"
:: "::"
identifier "Camera3DPreview"
parameter_list
( "("
parameter_declaration
type_identifier "Camera3D"
pointer_declarator
* "*"
identifier "p_camera"
) ")"
compound_statement
{ "{"
expression_statement
assignment_expression
identifier "camera"
= "="
identifier "p_camera"
; ";"
declaration
type_identifier "FoldableContainer"
init_declarator
pointer_declarator
* "*"
identifier "folder"
= "="
call_expression
identifier "memnew"
argument_list
( "("
identifier "FoldableContainer"
) ")"
; ";"
expression_statement
call_expression
field_expression
identifier "folder"
-> "->"
field_identifier "set_title"
argument_list
( "("
call_expression
identifier "TTRC"
argument_list
( "("
string_literal
" "\""
string_content "Camera Preview"
" "\""
) ")"
) ")"
; ";"
expression_statement
call_expression
field_expression
identifier "folder"
-> "->"
field_identifier "set_title_text_overrun_behavior"
argument_list
( "("
qualified_identifier
namespace_identifier "TextServer"
:: "::"
identifier "OVERRUN_TRIM_ELLIPSIS"
) ")"
; ";"
expression_statement
call_expression
field_expression
identifier "folder"
-> "->"
field_identifier "set_folded"
argument_list
( "("
identifier "camera_preview_folded"
) ")"
; ";"
expression_statement
call_expression
field_expression
identifier "folder"
-> "->"
field_identifier "connect"
argument_list
( "("
string_literal
" "\""
string_content "folding_changed"
" "\""
, ","
call_expression
identifier "callable_mp"
argument_list
( "("
this "this"
, ","
pointer_expression
& "&"
qualified_identifier
namespace_identifier "Camera3DPreview"
:: "::"
identifier "_toggle_folding"
) ")"
) ")"
; ";"
expression_statement
call_expression
identifier "add_child"
argument_list
( "("
identifier "folder"
) ")"
; ";"
expression_statement
assignment_expression
identifier "centering_container"
= "="
call_expression
identifier "memnew"
argument_list
( "("
identifier "AspectRatioContainer"
) ")"
; ";"
expression_statement
call_expression
field_expression
identifier "centering_container"
-> "->"
field_identifier "set_custom_minimum_size"
argument_list
( "("
binary_expression
call_expression
identifier "Size2"
argument_list
( "("
number_literal "0.0"
, ","
number_literal "256.0"
) ")"
* "*"
identifier "EDSCALE"
) ")"
; ";"
expression_statement
call_expression
field_expression
identifier "folder"
-> "->"
field_identifier "add_child"
argument_list
( "("
identifier "centering_container"
) ")"
; ";"
declaration
type_identifier "SubViewportContainer"
init_declarator
pointer_declarator
* "*"
identifier "sub_viewport_container"
= "="
call_expression
identifier "memnew"
argument_list
( "("
identifier "SubViewportContainer"
) ")"
; ";"
expression_statement
call_expression
field_expression
identifier "sub_viewport_container"
-> "->"
field_identifier "set_stretch"
argument_list
( "("
true "true"
) ")"
; ";"
expression_statement
call_expression
field_expression
identifier "sub_viewport_container"
-> "->"
field_identifier "set_texture_filter"
argument_list
( "("
identifier "TEXTURE_FILTER_NEAREST_WITH_MIPMAPS"
) ")"
; ";"
expression_statement
call_expression
field_expression
identifier "centering_container"
-> "->"
field_identifier "add_child"
argument_list
( "("
identifier "sub_viewport_container"
) ")"
; ";"
expression_statement
assignment_expression
identifier "sub_viewport"
= "="
call_expression
identifier "memnew"
argument_list
( "("
identifier "SubViewport"
) ")"
; ";"
expression_statement
call_expression
field_expression
identifier "sub_viewport_container"
-> "->"
field_identifier "add_child"
argument_list
( "("
identifier "sub_viewport"
) ")"
; ";"
expression_statement (+34 nodes collapsed)
expression_statement (+35 nodes collapsed)
expression_statement
call_expression
identifier "_project_settings_changed"
argument_list
( "("
) ")"
; ";"
} "}"
function_definition (+68 nodes collapsed)
function_definition (+40 nodes collapsed)
function_definition (+68 nodes collapsed)
function_definition (+50 nodes collapsed)
function_definition (+35 nodes collapsed)
function_definition (+46 nodes collapsed)
function_definition (+40 nodes collapsed)