else if(!strcmp(a, "trace-read")) attr = SGPropertyNode::TRACE_READ;
else if(!strcmp(a, "trace-write")) attr = SGPropertyNode::TRACE_WRITE;
else if(!strcmp(a, "userarchive")) attr = SGPropertyNode::USERARCHIVE;
+ else if(!strcmp(a, "preserve")) attr = SGPropertyNode::PRESERVE;
else {
naRuntimeError(c, "props.getAttribute() with invalid attribute");
return naNil();
else if(!strcmp(a, "trace-read")) attr = SGPropertyNode::TRACE_READ;
else if(!strcmp(a, "trace-write")) attr = SGPropertyNode::TRACE_WRITE;
else if(!strcmp(a, "userarchive")) attr = SGPropertyNode::USERARCHIVE;
+ else if(!strcmp(a, "preserve")) attr = SGPropertyNode::PRESERVE;
else {
naRuntimeError(c, "props.setAttribute() with invalid attribute");
return naNil();
const int num_components
= sizeof(vec.data()) / sizeof(typename T::value_type);
naRef vector = naNewVector(c);
- naVec_setsize(vector, num_components);
+ naVec_setsize(c, vector, num_components);
for (int i = 0; i < num_components; ++i)
naVec_set(vector, i, naNum(vec[i]));
return vector;
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_NASAL, SG_ALERT, "Nasal getValue: property " << (*node)->getPath() << " is NaN");
+ return naNil();
+ }
+
+ 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));
}