mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
[c] Fixed _isNan. VC++ evaluates 0/0 at compile time and errors out with C2124 as the constant is a division by zero.
This commit is contained in:
parent
686b2b551d
commit
69711476fc
@ -198,8 +198,9 @@ static void _addAfterPosition (float p, float* temp, int i, float* out, int o) {
|
||||
out[o + 2] = r;
|
||||
}
|
||||
|
||||
static int _isNan(float value) {
|
||||
float _nan = (float)0.0/(float)0.0;
|
||||
// Need to pass 0 as an argument, so VC++ doesn't error with C2124
|
||||
static int _isNan(float value, float zero) {
|
||||
float _nan = (float)0.0 / zero;
|
||||
return 0 == memcmp((void*)&value, (void*)&_nan, sizeof(value));
|
||||
}
|
||||
|
||||
@ -208,7 +209,7 @@ static void _addCurvePosition (float p, float x1, float y1, float cx1, float cy1
|
||||
float tt, ttt, u, uu, uuu;
|
||||
float ut, ut3, uut3, utt3;
|
||||
float x, y;
|
||||
if (p == 0 || _isNan(p)) p = 0.0001f;
|
||||
if (p == 0 || _isNan(p, 0)) p = 0.0001f;
|
||||
tt = p * p, ttt = tt * p, u = 1 - p, uu = u * u, uuu = uu * u;
|
||||
ut = u * p, ut3 = ut * 3, uut3 = u * ut3, utt3 = ut3 * p;
|
||||
x = x1 * uuu + cx1 * uut3 + cx2 * utt3 + x2 * ttt, y = y1 * uuu + cy1 * uut3 + cy2 * utt3 + y2 * ttt;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user