2019-07-11 15:37:31 +00:00
|
|
|
/*
|
|
|
|
Assimp2Json
|
|
|
|
Copyright (c) 2011, Alexander C. Gessler
|
|
|
|
|
|
|
|
Licensed under a 3-clause BSD license. See the LICENSE file for more information.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INCLUDED_MESH_SPLITTER
|
|
|
|
#define INCLUDED_MESH_SPLITTER
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Note: this is largely based on assimp's SplitLargeMeshes_Vertex process.
|
|
|
|
// it is refactored and the coding style is slightly improved, though.
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
struct aiScene;
|
|
|
|
struct aiMesh;
|
|
|
|
struct aiNode;
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Splits meshes of unique vertices into meshes with no more vertices than
|
2021-07-29 11:28:51 +00:00
|
|
|
* a given, configurable threshold value.
|
2019-07-11 15:37:31 +00:00
|
|
|
*/
|
2021-09-13 20:38:20 +00:00
|
|
|
class MeshSplitter {
|
2019-07-11 15:37:31 +00:00
|
|
|
public:
|
2021-09-13 20:38:20 +00:00
|
|
|
unsigned int LIMIT;
|
2021-07-29 11:28:51 +00:00
|
|
|
|
2021-09-13 20:38:20 +00:00
|
|
|
void SetLimit(unsigned int l) {
|
|
|
|
LIMIT = l;
|
|
|
|
}
|
2019-07-11 15:37:31 +00:00
|
|
|
|
2021-09-13 20:38:20 +00:00
|
|
|
unsigned int GetLimit() const {
|
|
|
|
return LIMIT;
|
|
|
|
}
|
2019-07-11 15:37:31 +00:00
|
|
|
|
2021-09-13 20:38:20 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
/** Executes the post processing step on the given imported data.
|
2019-07-11 15:37:31 +00:00
|
|
|
* At the moment a process is not supposed to fail.
|
|
|
|
* @param pScene The imported data to work at.
|
|
|
|
*/
|
2021-09-13 20:38:20 +00:00
|
|
|
void Execute(aiScene *pScene);
|
2019-07-11 15:37:31 +00:00
|
|
|
|
|
|
|
private:
|
2021-09-13 20:38:20 +00:00
|
|
|
void UpdateNode(aiNode *pcNode, const std::vector<std::pair<aiMesh *, unsigned int>> &source_mesh_map);
|
|
|
|
void SplitMesh(unsigned int index, aiMesh *mesh, std::vector<std::pair<aiMesh *, unsigned int>> &source_mesh_map);
|
2019-07-11 15:37:31 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDED_MESH_SPLITTER
|