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
8ded15b0
Unverified
Commit
8ded15b0
authored
Mar 08, 2018
by
Rémi Verschelde
Committed by
GitHub
Mar 08, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16485 from poke1024/vector2-cross
Bring back Vector2.cross()
parents
079b919b
9d785662
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
10 deletions
+18
-10
math_2d.cpp
core/math/math_2d.cpp
+0
-5
math_2d.h
core/math/math_2d.h
+0
-1
variant_call.cpp
core/variant_call.cpp
+2
-2
Vector2.xml
doc/classes/Vector2.xml
+9
-0
joints_2d_sw.cpp
servers/physics_2d/joints_2d_sw.cpp
+7
-2
No files found.
core/math/math_2d.cpp
View file @
8ded15b0
...
...
@@ -98,11 +98,6 @@ real_t Vector2::cross(const Vector2 &p_other) const {
return
x
*
p_other
.
y
-
y
*
p_other
.
x
;
}
Vector2
Vector2
::
cross
(
real_t
p_other
)
const
{
return
Vector2
(
p_other
*
y
,
-
p_other
*
x
);
}
Vector2
Vector2
::
floor
()
const
{
return
Vector2
(
Math
::
floor
(
x
),
Math
::
floor
(
y
));
...
...
core/math/math_2d.h
View file @
8ded15b0
...
...
@@ -104,7 +104,6 @@ struct Vector2 {
real_t
dot
(
const
Vector2
&
p_other
)
const
;
real_t
cross
(
const
Vector2
&
p_other
)
const
;
Vector2
cross
(
real_t
p_other
)
const
;
Vector2
project
(
const
Vector2
&
p_vec
)
const
;
Vector2
plane_project
(
real_t
p_d
,
const
Vector2
&
p_vec
)
const
;
...
...
core/variant_call.cpp
View file @
8ded15b0
...
...
@@ -347,7 +347,7 @@ struct _VariantCall {
VCALL_LOCALMEM1R
(
Vector2
,
bounce
);
VCALL_LOCALMEM1R
(
Vector2
,
reflect
);
VCALL_LOCALMEM0R
(
Vector2
,
angle
);
//VCALL_LOCALMEM1R(Vector2,
cross);
VCALL_LOCALMEM1R
(
Vector2
,
cross
);
VCALL_LOCALMEM0R
(
Vector2
,
abs
);
VCALL_LOCALMEM1R
(
Vector2
,
clamped
);
...
...
@@ -1517,7 +1517,7 @@ void register_variant_methods() {
ADDFUNC1R
(
VECTOR2
,
VECTOR2
,
Vector2
,
slide
,
VECTOR2
,
"n"
,
varray
());
ADDFUNC1R
(
VECTOR2
,
VECTOR2
,
Vector2
,
bounce
,
VECTOR2
,
"n"
,
varray
());
ADDFUNC1R
(
VECTOR2
,
VECTOR2
,
Vector2
,
reflect
,
VECTOR2
,
"n"
,
varray
());
//ADDFUNC1R(VECTOR2,REAL,Vector2,cross,VECTOR2,"with",
varray());
ADDFUNC1R
(
VECTOR2
,
REAL
,
Vector2
,
cross
,
VECTOR2
,
"with"
,
varray
());
ADDFUNC0R
(
VECTOR2
,
VECTOR2
,
Vector2
,
abs
,
varray
());
ADDFUNC1R
(
VECTOR2
,
VECTOR2
,
Vector2
,
clamped
,
REAL
,
"length"
,
varray
());
...
...
doc/classes/Vector2.xml
View file @
8ded15b0
...
...
@@ -81,6 +81,15 @@
Returns the vector with a maximum length.
</description>
</method>
<method
name=
"cross"
>
<return
type=
"float"
>
</return>
<argument
index=
"0"
name=
"b"
type=
"Vector2"
>
</argument>
<description>
Returns the 2-dimensional analog of the cross product with [code]b[/code].
</description>
</method>
<method
name=
"cubic_interpolate"
>
<return
type=
"Vector2"
>
</return>
...
...
servers/physics_2d/joints_2d_sw.cpp
View file @
8ded15b0
...
...
@@ -146,14 +146,19 @@ bool PinJoint2DSW::setup(real_t p_step) {
return
true
;
}
inline
Vector2
custom_cross
(
const
Vector2
&
p_vec
,
real_t
p_other
)
{
return
Vector2
(
p_other
*
p_vec
.
y
,
-
p_other
*
p_vec
.
x
);
}
void
PinJoint2DSW
::
solve
(
real_t
p_step
)
{
// compute relative velocity
Vector2
vA
=
A
->
get_linear_velocity
()
-
rA
.
cross
(
A
->
get_angular_velocity
());
Vector2
vA
=
A
->
get_linear_velocity
()
-
custom_cross
(
rA
,
A
->
get_angular_velocity
());
Vector2
rel_vel
;
if
(
B
)
rel_vel
=
B
->
get_linear_velocity
()
-
rB
.
cross
(
B
->
get_angular_velocity
())
-
vA
;
rel_vel
=
B
->
get_linear_velocity
()
-
custom_cross
(
rB
,
B
->
get_angular_velocity
())
-
vA
;
else
rel_vel
=
-
vA
;
...
...
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