/src/assimp/code/PostProcessing/SplitByBoneCountProcess.h
Line | Count | Source |
1 | | /* |
2 | | Open Asset Import Library (assimp) |
3 | | ---------------------------------------------------------------------- |
4 | | |
5 | | Copyright (c) 2006-2026, assimp team |
6 | | |
7 | | All rights reserved. |
8 | | |
9 | | Redistribution and use of this software in source and binary forms, |
10 | | with or without modification, are permitted provided that the |
11 | | following conditions are met: |
12 | | |
13 | | * Redistributions of source code must retain the above |
14 | | copyright notice, this list of conditions and the |
15 | | following disclaimer. |
16 | | |
17 | | * Redistributions in binary form must reproduce the above |
18 | | copyright notice, this list of conditions and the |
19 | | following disclaimer in the documentation and/or other |
20 | | materials provided with the distribution. |
21 | | |
22 | | * Neither the name of the assimp team, nor the names of its |
23 | | contributors may be used to endorse or promote products |
24 | | derived from this software without specific prior |
25 | | written permission of the assimp team. |
26 | | |
27 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
28 | | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
29 | | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
30 | | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
31 | | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
32 | | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
33 | | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
34 | | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
35 | | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
36 | | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
37 | | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
38 | | |
39 | | ---------------------------------------------------------------------- |
40 | | */ |
41 | | |
42 | | /// @file SplitByBoneCountProcess.h |
43 | | /// Defines a post processing step to split meshes with many bones into submeshes |
44 | | #ifndef AI_SPLITBYBONECOUNTPROCESS_H_INC |
45 | | #define AI_SPLITBYBONECOUNTPROCESS_H_INC |
46 | | |
47 | | #include <vector> |
48 | | #include "Common/BaseProcess.h" |
49 | | |
50 | | #include <assimp/mesh.h> |
51 | | #include <assimp/scene.h> |
52 | | |
53 | | namespace Assimp { |
54 | | |
55 | | /** Postprocessing filter to split meshes with many bones into submeshes |
56 | | * so that each submesh has a certain max bone count. |
57 | | * |
58 | | * Applied BEFORE the JoinVertices-Step occurs. |
59 | | * Returns NON-UNIQUE vertices, splits by bone count. |
60 | | */ |
61 | | class SplitByBoneCountProcess : public BaseProcess { |
62 | | public: |
63 | | // ------------------------------------------------------------------- |
64 | | /// The default class constructor / destructor. |
65 | | SplitByBoneCountProcess(); |
66 | 40.3k | ~SplitByBoneCountProcess() override = default; |
67 | | |
68 | | /// @brief Returns whether the processing step is present in the given flag. |
69 | | /// @param pFlags The processing flags the importer was called with. A |
70 | | /// bitwise combination of #aiPostProcessSteps. |
71 | | /// @return true if the process is present in this flag fields, false if not. |
72 | | bool IsActive( unsigned int pFlags) const override; |
73 | | |
74 | | /// @brief Called prior to ExecuteOnScene(). |
75 | | /// The function is a request to the process to update its configuration |
76 | | /// basing on the Importer's configuration property list. |
77 | | void SetupProperties(const Importer* pImp) override; |
78 | | |
79 | | /// @brief Will return the maximal number of bones. |
80 | | /// @return The maximal number of bones. |
81 | | size_t getMaxNumberOfBones() const; |
82 | | |
83 | | protected: |
84 | | /// Executes the post processing step on the given imported data. |
85 | | /// At the moment a process is not supposed to fail. |
86 | | /// @param pScene The imported data to work at. |
87 | | void Execute( aiScene* pScene) override; |
88 | | |
89 | | /// Splits the given mesh by bone count. |
90 | | /// @param pMesh the Mesh to split. Is not changed at all, but might be superfluous in case it was split. |
91 | | /// @param poNewMeshes Array of submeshes created in the process. Empty if splitting was not necessary. |
92 | | void SplitMesh( const aiMesh* pMesh, std::vector<aiMesh*>& poNewMeshes) const; |
93 | | |
94 | | /// Recursively updates the node's mesh list to account for the changed mesh list |
95 | | void UpdateNode( aiNode* pNode) const; |
96 | | |
97 | | private: |
98 | | /// Max bone count. Splitting occurs if a mesh has more than that number of bones. |
99 | | size_t mMaxBoneCount; |
100 | | |
101 | | /// Per mesh index: Array of indices of the new submeshes. |
102 | | using IndexArray = std::vector<unsigned int>; |
103 | | std::vector<IndexArray> mSubMeshIndices; |
104 | | }; |
105 | | |
106 | 0 | inline size_t SplitByBoneCountProcess::getMaxNumberOfBones() const { |
107 | 0 | return mMaxBoneCount; |
108 | 0 | } |
109 | | |
110 | | } // end of namespace Assimp |
111 | | |
112 | | #endif // !!AI_SPLITBYBONECOUNTPROCESS_H_INC |