case props::BOOL: case props::INT:
case props::LONG: case props::FLOAT:
case props::DOUBLE:
- return naNum(p->getDoubleValue());
-
+ {
+ double dv = p->getDoubleValue();
+ if (osg::isNaN(dv)) {
+ SG_LOG(SG_GENERAL, SG_ALERT, "Nasal getprop: property " << p->getPath() << " is NaN");
+ naRuntimeError(c, "getprop() would have read NaN");
+ }
+
+ return naNum(dv);
+ }
+
case props::STRING:
case props::UNSPECIFIED:
{
naRef n = naNumValue(val);
if(naIsNil(n))
naRuntimeError(c, "setprop() value is not string or number");
+
+ if (osg::isNaN(n.num)) {
+ naRuntimeError(c, "setprop() passed a NaN");
+ }
+
result = props->setDoubleValue(buf, n.num);
}
} catch (const string& err) {
case props::BOOL: case props::INT:
case props::LONG: case props::FLOAT:
case props::DOUBLE:
- return naNum((*node)->getDoubleValue());
+ {
+ double dv = (*node)->getDoubleValue();
+ if (osg::isNaN(dv)) {
+ SG_LOG(SG_GENERAL, SG_ALERT, "Nasal getValue: property " << (*node)->getPath() << " is NaN");
+ naRuntimeError(c, "props.getValue() would have read NaN");
+ }
+
+ return naNum(dv);
+ }
+
case props::STRING:
case props::UNSPECIFIED:
return NASTR((*node)->getStringValue());
naRef n = naNumValue(val);
if(naIsNil(n))
naRuntimeError(c, "props.setValue() with non-number");
- result = (*node)->setDoubleValue(naNumValue(val).num);
+
+ double d = naNumValue(val).num;
+ if (osg::isNaN(d)) {
+ naRuntimeError(c, "props.setValue() passed a NaN");
+ }
+
+ result = (*node)->setDoubleValue(d);
}
return naNum(result);
}
{
NODEARG();
naRef r = naNumValue(naVec_get(argv, 0));
- if(naIsNil(r))
+ if (naIsNil(r))
naRuntimeError(c, "props.setDoubleValue() with non-number");
+
+ if (osg::isNaN(r.num)) {
+ naRuntimeError(c, "props.setDoubleValue() passed a NaN");
+ }
+
return naNum((*node)->setDoubleValue(r.num));
}