KhronosGroup / OpenCOLLADA

652 stars 251 forks source link

<float_array>'s "digits" attribute is ignored both in Loader and Writer #652

Open Stanislav96 opened 3 years ago

Stanislav96 commented 3 years ago
  1. In COLLADAStreamWriter 's "digits" attribute is not written even if StreamWriter::mDoublePrecision is true. According to the specification "digits" should be set to 16-17 significant decimal digits for double instead of default value of 6 digits. I guess Source class in COLLADASWSource.h should write this attribute in prepareToAppendValues() depending on Type: 7-8 digits for float, 16-17 for double. const String CSWC::CSW_ATTRIBUTE_DIGITS = "digits"; should be also added to COLLADASWConstants.
  2. In COLLADASaxFrameworkLoader 's "digits" attribute is ignored. Namely, SourceArrayLoader::beginfloat_array ignores float_arrayAttributeData::digits field. It always calls beginArray<FloatSource>, while it, probably, should call beginArray<DoubleSource> if digits is big enough (more than 7-8). Ideally, Source class should also store digits value to truncate exact value by the number of digits (e.g., in datafloat_array). In any case, datafloat_array should accept const double* data parameter and be able to determine mCurrentSoure type (btw, there is a typo in its name). Moreover, ColladaParserAutoGen14Private::_datafloat_array as well as ColladaParserAutoGen15Private::_data__float_array should use characterData2DoubleData instead of characterData2FloatData so that 's string values can be read as double values. Unfortunately, ColladaParserAutoGen14Private::_datafloat_array doesn't know "digits" value so it probably can't determine whether to use float-s or double-s in each case.