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

Method parseNodesRecursivelyBinary

core/3d/Bundle3D.cpp:1852–1998  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1850 return true;
1851}
1852NodeData* Bundle3D::parseNodesRecursivelyBinary(bool& skeleton, bool singleSprite)
1853{
1854 // id
1855 std::string id = _binaryReader.readString();
1856 // is skeleton
1857 bool skeleton_;
1858 if (_binaryReader.read(&skeleton_, 1, 1) != 1)
1859 {
1860 AXLOGW("warning: Failed to read is skeleton");
1861 return nullptr;
1862 }
1863 if (skeleton_)
1864 skeleton = true;
1865
1866 // transform
1867 Mat4 transform;
1868 if (!_binaryReader.readMatrix(transform.m))
1869 {
1870 AXLOGW("warning: Failed to read transform matrix");
1871 return nullptr;
1872 }
1873 // parts
1874 unsigned int partsSize = 0;
1875 if (_binaryReader.read(&partsSize, 4, 1) != 1)
1876 {
1877 AXLOGW("warning: Failed to read meshdata: attribCount '{}'.", _path);
1878 return nullptr;
1879 }
1880
1881 NodeData* nodedata = new NodeData();
1882 nodedata->id = id;
1883
1884 bool isSkin = false;
1885
1886 if (partsSize > 0)
1887 {
1888 for (unsigned int i = 0; i < partsSize; ++i)
1889 {
1890 auto modelnodedata = new ModelData();
1891 modelnodedata->subMeshId = _binaryReader.readString();
1892 modelnodedata->materialId = _binaryReader.readString();
1893
1894 if (modelnodedata->subMeshId.empty() || modelnodedata->materialId.empty())
1895 {
1896 AXLOGW("Node {} part is missing meshPartId or materialId", nodedata->id);
1897 AX_SAFE_DELETE(modelnodedata);
1898 AX_SAFE_DELETE(nodedata);
1899 return nullptr;
1900 }
1901
1902 // read bone
1903 unsigned int bonesSize = 0;
1904 if (_binaryReader.read(&bonesSize, 4, 1) != 1)
1905 {
1906 AXLOGW("warning: Failed to read meshdata: attribCount '{}'.", _path);
1907 AX_SAFE_DELETE(modelnodedata);
1908 AX_SAFE_DELETE(nodedata);
1909 return nullptr;

Callers

nothing calls this directly

Calls 5

readMatrixMethod · 0.80
readStringMethod · 0.45
readMethod · 0.45
emptyMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected