MCPcopy Create free account
hub / github.com/XJTU-Graphics/dandelion / ParseVectorDataArray

Function ParseVectorDataArray

deps/assimp/code/AssetLib/FBX/FBXParser.cpp:597–683  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------ read an array of float3 tuples

Source from the content-addressed store, hash-verified

595// ------------------------------------------------------------------------------------------------
596// read an array of float3 tuples
597void ParseVectorDataArray(std::vector<aiVector3D>& out, const Element& el)
598{
599 out.resize( 0 );
600
601 const TokenList& tok = el.Tokens();
602 if(tok.empty()) {
603 ParseError("unexpected empty element",&el);
604 }
605
606 if(tok[0]->IsBinary()) {
607 const char* data = tok[0]->begin(), *end = tok[0]->end();
608
609 char type;
610 uint32_t count;
611 ReadBinaryDataArrayHead(data, end, type, count, el);
612
613 if(count % 3 != 0) {
614 ParseError("number of floats is not a multiple of three (3) (binary)",&el);
615 }
616
617 if(!count) {
618 return;
619 }
620
621 if (type != 'd' && type != 'f') {
622 ParseError("expected float or double array (binary)",&el);
623 }
624
625 std::vector<char> buff;
626 ReadBinaryDataArray(type, count, data, end, buff, el);
627
628 ai_assert(data == end);
629 uint64_t dataToRead = static_cast<uint64_t>(count) * (type == 'd' ? 8 : 4);
630 if (dataToRead != buff.size()) {
631 ParseError("Invalid read size (binary)",&el);
632 }
633
634 const uint32_t count3 = count / 3;
635 out.reserve(count3);
636
637 if (type == 'd') {
638 const double* d = reinterpret_cast<const double*>(&buff[0]);
639 for (unsigned int i = 0; i < count3; ++i, d += 3) {
640 out.emplace_back(static_cast<ai_real>(d[0]),
641 static_cast<ai_real>(d[1]),
642 static_cast<ai_real>(d[2]));
643 }
644 // for debugging
645 /*for ( size_t i = 0; i < out.size(); i++ ) {
646 aiVector3D vec3( out[ i ] );
647 std::stringstream stream;
648 stream << " vec3.x = " << vec3.x << " vec3.y = " << vec3.y << " vec3.z = " << vec3.z << std::endl;
649 DefaultLogger::get()->info( stream.str() );
650 }*/
651 }
652 else if (type == 'f') {
653 const float* f = reinterpret_cast<const float*>(&buff[0]);
654 for (unsigned int i = 0; i < count3; ++i, f += 3) {

Callers 9

ClusterMethod · 0.85
BlendShapeChannelMethod · 0.85
AnimationCurveMethod · 0.85
ReadMatrixFunction · 0.85
MeshGeometryMethod · 0.85
ResolveVertexDataArrayFunction · 0.85
ShapeGeometryMethod · 0.85
LineGeometryMethod · 0.85

Calls 15

ParseErrorFunction · 0.85
ReadBinaryDataArrayHeadFunction · 0.85
ReadBinaryDataArrayFunction · 0.85
ParseTokenAsDimFunction · 0.85
ParseTokenAsFloatFunction · 0.85
ParseTokenAsIntFunction · 0.85
ParseTokenAsIDFunction · 0.85
ParseTokenAsInt64Function · 0.85
emplace_backMethod · 0.80
resizeMethod · 0.45
emptyMethod · 0.45
IsBinaryMethod · 0.45

Tested by

no test coverage detected