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
18b90508
Unverified
Commit
18b90508
authored
Feb 22, 2019
by
Hugo Locurcio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix crash when using `wrapi()` with a range of zero
`wrapi()` and `wrapf()` will now return the value of the `min` parameter if the range is equal to zero.
parent
16e67388
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
math_funcs.h
core/math/math_funcs.h
+3
-3
No files found.
core/math/math_funcs.h
View file @
18b90508
...
...
@@ -219,15 +219,15 @@ public:
static
_ALWAYS_INLINE_
int
wrapi
(
int
value
,
int
min
,
int
max
)
{
int
rng
=
max
-
min
;
return
min
+
((((
value
-
min
)
%
rng
)
+
rng
)
%
rng
)
;
return
(
rng
!=
0
)
?
min
+
((((
value
-
min
)
%
rng
)
+
rng
)
%
rng
)
:
min
;
}
static
_ALWAYS_INLINE_
double
wrapf
(
double
value
,
double
min
,
double
max
)
{
double
rng
=
max
-
min
;
return
value
-
(
rng
*
Math
::
floor
((
value
-
min
)
/
rng
))
;
return
(
!
is_equal_approx
(
rng
,
0
.
0
))
?
value
-
(
rng
*
Math
::
floor
((
value
-
min
)
/
rng
))
:
min
;
}
static
_ALWAYS_INLINE_
float
wrapf
(
float
value
,
float
min
,
float
max
)
{
float
rng
=
max
-
min
;
return
value
-
(
rng
*
Math
::
floor
((
value
-
min
)
/
rng
))
;
return
(
!
is_equal_approx
(
rng
,
0
.
0
f
))
?
value
-
(
rng
*
Math
::
floor
((
value
-
min
)
/
rng
))
:
min
;
}
// double only, as these functions are mainly used by the editor and not performance-critical,
...
...
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