Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
9d233910
Unverified
Commit
9d233910
authored
Jun 16, 2020
by
Rémi Verschelde
Committed by
GitHub
Jun 16, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #39517 from Calinou/editor-display-freelook-speed-zoom
Display freelook speed and zoom in units in the 3D editor viewport
parents
2ad7eb9b
eaae50fe
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
10 deletions
+27
-10
node_3d_editor_plugin.cpp
editor/plugins/node_3d_editor_plugin.cpp
+27
-10
No files found.
editor/plugins/node_3d_editor_plugin.cpp
View file @
9d233910
...
...
@@ -2583,14 +2583,14 @@ void Node3DEditorViewport::_notification(int p_what) {
}
}
static
void
draw_indicator_bar
(
Control
&
surface
,
real_t
fill
,
Ref
<
Texture2D
>
icon
)
{
static
void
draw_indicator_bar
(
Control
&
surface
,
real_t
fill
,
const
Ref
<
Texture2D
>
icon
,
const
Ref
<
Font
>
font
,
const
String
&
text
)
{
// Adjust bar size from control height
Vector2
surface_size
=
surface
.
get_size
();
real_t
h
=
surface_size
.
y
/
2.0
;
real_t
y
=
(
surface_size
.
y
-
h
)
/
2.0
;
const
Vector2
surface_size
=
surface
.
get_size
();
const
real_t
h
=
surface_size
.
y
/
2.0
;
const
real_t
y
=
(
surface_size
.
y
-
h
)
/
2.0
;
Rect2
r
(
10
,
y
,
6
,
h
);
real_t
sy
=
r
.
size
.
y
*
fill
;
const
Rect2
r
(
10
*
EDSCALE
,
y
,
6
*
EDSCALE
,
h
);
const
real_t
sy
=
r
.
size
.
y
*
fill
;
// Note: because this bar appears over the viewport, it has to stay readable for any background color
// Draw both neutral dark and bright colors to account this
...
...
@@ -2598,9 +2598,12 @@ static void draw_indicator_bar(Control &surface, real_t fill, Ref<Texture2D> ico
surface
.
draw_rect
(
Rect2
(
r
.
position
.
x
,
r
.
position
.
y
+
r
.
size
.
y
-
sy
,
r
.
size
.
x
,
sy
),
Color
(
1
,
1
,
1
,
0.6
));
surface
.
draw_rect
(
r
.
grow
(
1
),
Color
(
0
,
0
,
0
,
0.7
),
false
,
Math
::
round
(
EDSCALE
));
Vector2
icon_size
=
icon
->
get_size
();
Vector2
icon_pos
=
Vector2
(
r
.
position
.
x
-
(
icon_size
.
x
-
r
.
size
.
x
)
/
2
,
r
.
position
.
y
+
r
.
size
.
y
+
2
);
const
Vector2
icon_size
=
icon
->
get_size
();
const
Vector2
icon_pos
=
Vector2
(
r
.
position
.
x
-
(
icon_size
.
x
-
r
.
size
.
x
)
/
2
,
r
.
position
.
y
+
r
.
size
.
y
+
2
*
EDSCALE
);
surface
.
draw_texture
(
icon
,
icon_pos
);
// Draw text below the bar (for speed/zoom information).
surface
.
draw_string
(
font
,
Vector2
(
icon_pos
.
x
,
icon_pos
.
y
+
icon_size
.
y
+
16
*
EDSCALE
),
text
);
}
void
Node3DEditorViewport
::
_draw
()
{
...
...
@@ -2697,7 +2700,14 @@ void Node3DEditorViewport::_draw() {
logscale_t
=
0.25
*
Math
::
exp
(
4.0
*
logscale_t
-
1.0
);
}
draw_indicator_bar
(
*
surface
,
1.0
-
logscale_t
,
get_theme_icon
(
"ViewportSpeed"
,
"EditorIcons"
));
// Display the freelook speed to help the user get a better sense of scale.
const
int
precision
=
freelook_speed
<
1.0
?
2
:
1
;
draw_indicator_bar
(
*
surface
,
1.0
-
logscale_t
,
get_theme_icon
(
"ViewportSpeed"
,
"EditorIcons"
),
get_theme_font
(
"font"
,
"Label"
),
vformat
(
"%s u/s"
,
String
::
num
(
freelook_speed
).
pad_decimals
(
precision
)));
}
}
else
{
...
...
@@ -2716,7 +2726,14 @@ void Node3DEditorViewport::_draw() {
logscale_t
=
0.25
*
Math
::
exp
(
4.0
*
logscale_t
-
1.0
);
}
draw_indicator_bar
(
*
surface
,
logscale_t
,
get_theme_icon
(
"ViewportZoom"
,
"EditorIcons"
));
// Display the zoom center distance to help the user get a better sense of scale.
const
int
precision
=
cursor
.
distance
<
1.0
?
2
:
1
;
draw_indicator_bar
(
*
surface
,
logscale_t
,
get_theme_icon
(
"ViewportZoom"
,
"EditorIcons"
),
get_theme_font
(
"font"
,
"Label"
),
vformat
(
"%s u"
,
String
::
num
(
cursor
.
distance
).
pad_decimals
(
precision
)));
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment