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

Method getTrianglesList

core/3d/Bundle3D.cpp:2268–2313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2266}
2267
2268std::vector<Vec3> Bundle3D::getTrianglesList(std::string_view path)
2269{
2270 std::vector<Vec3> trianglesList;
2271
2272 if (path.length() <= 4)
2273 return trianglesList;
2274
2275 auto bundle = Bundle3D::createBundle();
2276 std::string ext = FileUtils::getPathExtension(path);
2277 MeshDatas meshs;
2278 if (ext == ".obj")
2279 {
2280 MaterialDatas materials;
2281 NodeDatas nodes;
2282 if (!Bundle3D::loadObj(meshs, materials, nodes, path))
2283 {
2284 Bundle3D::destroyBundle(bundle);
2285 return trianglesList;
2286 }
2287 }
2288 else
2289 {
2290 if (!bundle->load(path))
2291 {
2292 Bundle3D::destroyBundle(bundle);
2293 return trianglesList;
2294 }
2295
2296 bundle->loadMeshDatas(meshs);
2297 }
2298
2299 Bundle3D::destroyBundle(bundle);
2300 for (auto&& iter : meshs.meshDatas)
2301 {
2302 int preVertexSize = iter->getPerVertexSize() / sizeof(float);
2303 for (const auto& indices : iter->subMeshIndices)
2304 {
2305 indices.for_each([&](unsigned int ind) {
2306 trianglesList.emplace_back(Vec3(iter->vertex[ind * preVertexSize], iter->vertex[ind * preVertexSize + 1],
2307 iter->vertex[ind * preVertexSize + 2]));
2308 });
2309 }
2310 }
2311
2312 return trianglesList;
2313}
2314
2315Bundle3D::Bundle3D()
2316 : _modelPath(""), _path(""), _version(""), _referenceCount(0), _references(nullptr), _isBinary(false)

Callers

nothing calls this directly

Calls 7

loadMeshDatasMethod · 0.80
getPerVertexSizeMethod · 0.80
Vec3Function · 0.50
lengthMethod · 0.45
loadMethod · 0.45
for_eachMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected