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
26963473
Commit
26963473
authored
May 04, 2018
by
Alexander Alekseev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Vector3::round, Vector2::round & Vector2::ceil methods were added.
Now both structs (Vector2 & Vector3) have round, floor & ceil methods. (see #18603)
parent
d6ddfdf0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
0 deletions
+24
-0
math_2d.cpp
core/math/math_2d.cpp
+10
-0
math_2d.h
core/math/math_2d.h
+2
-0
vector3.h
core/math/vector3.h
+6
-0
variant_call.cpp
core/variant_call.cpp
+6
-0
No files found.
core/math/math_2d.cpp
View file @
26963473
...
...
@@ -103,6 +103,16 @@ Vector2 Vector2::floor() const {
return
Vector2
(
Math
::
floor
(
x
),
Math
::
floor
(
y
));
}
Vector2
Vector2
::
ceil
()
const
{
return
Vector2
(
Math
::
ceil
(
x
),
Math
::
ceil
(
y
));
}
Vector2
Vector2
::
round
()
const
{
return
Vector2
(
Math
::
round
(
x
),
Math
::
round
(
y
));
}
Vector2
Vector2
::
rotated
(
real_t
p_by
)
const
{
Vector2
v
;
...
...
core/math/math_2d.h
View file @
26963473
...
...
@@ -162,6 +162,8 @@ struct Vector2 {
}
Vector2
floor
()
const
;
Vector2
ceil
()
const
;
Vector2
round
()
const
;
Vector2
snapped
(
const
Vector2
&
p_by
)
const
;
real_t
aspect
()
const
{
return
width
/
height
;
}
...
...
core/math/vector3.h
View file @
26963473
...
...
@@ -103,6 +103,7 @@ struct Vector3 {
_FORCE_INLINE_
Vector3
floor
()
const
;
_FORCE_INLINE_
Vector3
sign
()
const
;
_FORCE_INLINE_
Vector3
ceil
()
const
;
_FORCE_INLINE_
Vector3
round
()
const
;
_FORCE_INLINE_
real_t
distance_to
(
const
Vector3
&
p_b
)
const
;
_FORCE_INLINE_
real_t
distance_squared_to
(
const
Vector3
&
p_b
)
const
;
...
...
@@ -204,6 +205,11 @@ Vector3 Vector3::ceil() const {
return
Vector3
(
Math
::
ceil
(
x
),
Math
::
ceil
(
y
),
Math
::
ceil
(
z
));
}
Vector3
Vector3
::
round
()
const
{
return
Vector3
(
Math
::
round
(
x
),
Math
::
round
(
y
),
Math
::
round
(
z
));
}
Vector3
Vector3
::
linear_interpolate
(
const
Vector3
&
p_b
,
real_t
p_t
)
const
{
return
Vector3
(
...
...
core/variant_call.cpp
View file @
26963473
...
...
@@ -344,6 +344,8 @@ struct _VariantCall {
VCALL_LOCALMEM1R
(
Vector2
,
rotated
);
VCALL_LOCALMEM0R
(
Vector2
,
tangent
);
VCALL_LOCALMEM0R
(
Vector2
,
floor
);
VCALL_LOCALMEM0R
(
Vector2
,
ceil
);
VCALL_LOCALMEM0R
(
Vector2
,
round
);
VCALL_LOCALMEM1R
(
Vector2
,
snapped
);
VCALL_LOCALMEM0R
(
Vector2
,
aspect
);
VCALL_LOCALMEM1R
(
Vector2
,
dot
);
...
...
@@ -386,6 +388,7 @@ struct _VariantCall {
VCALL_LOCALMEM0R
(
Vector3
,
abs
);
VCALL_LOCALMEM0R
(
Vector3
,
floor
);
VCALL_LOCALMEM0R
(
Vector3
,
ceil
);
VCALL_LOCALMEM0R
(
Vector3
,
round
);
VCALL_LOCALMEM1R
(
Vector3
,
distance_to
);
VCALL_LOCALMEM1R
(
Vector3
,
distance_squared_to
);
VCALL_LOCALMEM1R
(
Vector3
,
angle_to
);
...
...
@@ -1519,6 +1522,8 @@ void register_variant_methods() {
ADDFUNC1R
(
VECTOR2
,
VECTOR2
,
Vector2
,
rotated
,
REAL
,
"phi"
,
varray
());
ADDFUNC0R
(
VECTOR2
,
VECTOR2
,
Vector2
,
tangent
,
varray
());
ADDFUNC0R
(
VECTOR2
,
VECTOR2
,
Vector2
,
floor
,
varray
());
ADDFUNC0R
(
VECTOR2
,
VECTOR2
,
Vector2
,
ceil
,
varray
());
ADDFUNC0R
(
VECTOR2
,
VECTOR2
,
Vector2
,
round
,
varray
());
ADDFUNC1R
(
VECTOR2
,
VECTOR2
,
Vector2
,
snapped
,
VECTOR2
,
"by"
,
varray
());
ADDFUNC0R
(
VECTOR2
,
REAL
,
Vector2
,
aspect
,
varray
());
ADDFUNC1R
(
VECTOR2
,
REAL
,
Vector2
,
dot
,
VECTOR2
,
"with"
,
varray
());
...
...
@@ -1560,6 +1565,7 @@ void register_variant_methods() {
ADDFUNC0R
(
VECTOR3
,
VECTOR3
,
Vector3
,
abs
,
varray
());
ADDFUNC0R
(
VECTOR3
,
VECTOR3
,
Vector3
,
floor
,
varray
());
ADDFUNC0R
(
VECTOR3
,
VECTOR3
,
Vector3
,
ceil
,
varray
());
ADDFUNC0R
(
VECTOR3
,
VECTOR3
,
Vector3
,
round
,
varray
());
ADDFUNC1R
(
VECTOR3
,
REAL
,
Vector3
,
distance_to
,
VECTOR3
,
"b"
,
varray
());
ADDFUNC1R
(
VECTOR3
,
REAL
,
Vector3
,
distance_squared_to
,
VECTOR3
,
"b"
,
varray
());
ADDFUNC1R
(
VECTOR3
,
REAL
,
Vector3
,
angle_to
,
VECTOR3
,
"to"
,
varray
());
...
...
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