mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-08 00:04:54 +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 float quietNan();
|
||||
|
||||
static float random();
|
||||
|
||||
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) {
|
||||
float animationStart = entry->_animationStart, animationEnd = entry->_animationEnd;
|
||||
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.
|
||||
size_t i = 0, n = _events.size();
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
#include <spine/MathUtil.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <cmath>
|
||||
|
||||
// Required for division by 0 in _isNaN on MSVC
|
||||
#ifdef _MSC_VER
|
||||
@ -99,14 +100,12 @@ float MathUtil::cosDeg(float degrees) {
|
||||
return (float) ::cos(degrees * MathUtil::Deg_Rad);
|
||||
}
|
||||
|
||||
/* Need to pass 0 as an argument, so VC++ doesn't error with C2124 */
|
||||
static bool _isNan(float value, float zero) {
|
||||
float _nan = (float) 0.0 / zero;
|
||||
return 0 == memcmp((void *) &value, (void *) &_nan, sizeof(value));
|
||||
bool MathUtil::isNan(float v) {
|
||||
return std::isnan(v);
|
||||
}
|
||||
|
||||
bool MathUtil::isNan(float v) {
|
||||
return _isNan(v, 0);
|
||||
float MathUtil::quietNan() {
|
||||
return std::nan("");
|
||||
}
|
||||
|
||||
float MathUtil::random() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user