mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-19 00:06:42 +08:00
[cpp] Fix float exception, closes #2583
This commit is contained in:
parent
cd8dadc02a
commit
aca86fa588
@ -88,6 +88,8 @@ namespace spine {
|
|||||||
|
|
||||||
static bool isNan(float v);
|
static bool isNan(float v);
|
||||||
|
|
||||||
|
static float quietNan();
|
||||||
|
|
||||||
static float random();
|
static float random();
|
||||||
|
|
||||||
static float randomTriangular(float min, float max);
|
static float randomTriangular(float min, float max);
|
||||||
|
|||||||
@ -921,7 +921,7 @@ void AnimationState::setAttachment(Skeleton &skeleton, Slot &slot, const String
|
|||||||
void AnimationState::queueEvents(TrackEntry *entry, float animationTime) {
|
void AnimationState::queueEvents(TrackEntry *entry, float animationTime) {
|
||||||
float animationStart = entry->_animationStart, animationEnd = entry->_animationEnd;
|
float animationStart = entry->_animationStart, animationEnd = entry->_animationEnd;
|
||||||
float duration = animationEnd - animationStart;
|
float duration = animationEnd - animationStart;
|
||||||
float trackLastWrapped = MathUtil::fmod(entry->_trackLast, duration);
|
float trackLastWrapped = duration != 0 ? MathUtil::fmod(entry->_trackLast, duration) : MathUtil::quietNan();
|
||||||
|
|
||||||
// Queue events before complete.
|
// Queue events before complete.
|
||||||
size_t i = 0, n = _events.size();
|
size_t i = 0, n = _events.size();
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
#include <spine/MathUtil.h>
|
#include <spine/MathUtil.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
// Required for division by 0 in _isNaN on MSVC
|
// Required for division by 0 in _isNaN on MSVC
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@ -99,14 +100,12 @@ float MathUtil::cosDeg(float degrees) {
|
|||||||
return (float) ::cos(degrees * MathUtil::Deg_Rad);
|
return (float) ::cos(degrees * MathUtil::Deg_Rad);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Need to pass 0 as an argument, so VC++ doesn't error with C2124 */
|
bool MathUtil::isNan(float v) {
|
||||||
static bool _isNan(float value, float zero) {
|
return std::isnan(v);
|
||||||
float _nan = (float) 0.0 / zero;
|
|
||||||
return 0 == memcmp((void *) &value, (void *) &_nan, sizeof(value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MathUtil::isNan(float v) {
|
float MathUtil::quietNan() {
|
||||||
return _isNan(v, 0);
|
return std::nan("");
|
||||||
}
|
}
|
||||||
|
|
||||||
float MathUtil::random() {
|
float MathUtil::random() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user