MCPcopy Create free account
hub / github.com/axmolengine/axmol / loadMeshDatasBinary

Method loadMeshDatasBinary

core/3d/Bundle3D.cpp:393–501  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

391 return true;
392}
393bool Bundle3D::loadMeshDatasBinary(MeshDatas& meshdatas)
394{
395 if (!seekToFirstType(BUNDLE_TYPE_MESH))
396 return false;
397 unsigned int meshSize = 0;
398 if (_binaryReader.read(&meshSize, 4, 1) != 1)
399 {
400 AXLOGW("warning: Failed to read meshdata: attribCount '{}'.", _path);
401 return false;
402 }
403 MeshData* meshData = nullptr;
404 for (unsigned int i = 0; i < meshSize; ++i)
405 {
406 unsigned int attribSize = 0;
407 // read mesh data
408 if (_binaryReader.read(&attribSize, 4, 1) != 1 || attribSize < 1)
409 {
410 AXLOGW("warning: Failed to read meshdata: attribCount '{}'.", _path);
411 goto FAILED;
412 }
413 meshData = new MeshData();
414 meshData->attribCount = attribSize;
415 meshData->attribs.resize(meshData->attribCount);
416 for (ssize_t j = 0; j < meshData->attribCount; ++j)
417 {
418 std::string attribute = "";
419 unsigned int vSize;
420 if (_binaryReader.read(&vSize, 4, 1) != 1)
421 {
422 AXLOGW("warning: Failed to read meshdata: usage or size '{}'.", _path);
423 goto FAILED;
424 }
425 std::string type = _binaryReader.readString();
426 attribute = _binaryReader.readString();
427 meshData->attribs[j].type = parseGLDataType(type, vSize);
428 meshData->attribs[j].vertexAttrib = parseGLProgramAttribute(attribute);
429 }
430 unsigned int vertexSizeInFloat = 0;
431 // Read vertex data
432 if (_binaryReader.read(&vertexSizeInFloat, 4, 1) != 1 || vertexSizeInFloat == 0)
433 {
434 AXLOGW("warning: Failed to read meshdata: vertexSizeInFloat '{}'.", _path);
435 goto FAILED;
436 }
437
438 meshData->vertex.resize(vertexSizeInFloat);
439 if (_binaryReader.read(&meshData->vertex[0], 4, vertexSizeInFloat) != vertexSizeInFloat)
440 {
441 AXLOGW("warning: Failed to read meshdata: vertex element '{}'.", _path);
442 goto FAILED;
443 }
444
445 // Read index data
446 unsigned int meshPartCount = 1;
447 _binaryReader.read(&meshPartCount, 4, 1);
448
449 for (unsigned int k = 0; k < meshPartCount; ++k)
450 {

Callers

nothing calls this directly

Calls 9

getPerVertexSizeMethod · 0.80
Vec3Function · 0.50
readMethod · 0.45
resizeMethod · 0.45
readStringMethod · 0.45
emplace_backMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected