1/*
2Open Asset Import Library (assimp)
3----------------------------------------------------------------------
4
5Copyright (c) 2006-2017, assimp team
6
7All rights reserved.
8
9Redistribution and use of this software in source and binary forms,
10with or without modification, are permitted provided that the
11following 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
27THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37OF 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 "BaseProcess.h"
49
50#include <assimp/mesh.h>
51#include <assimp/scene.h>
52
53namespace Assimp
54{
55
56
57/** Postprocessing filter to split meshes with many bones into submeshes
58 * so that each submesh has a certain max bone count.
59 *
60 * Applied BEFORE the JoinVertices-Step occurs.
61 * Returns NON-UNIQUE vertices, splits by bone count.
62*/
63class SplitByBoneCountProcess : public BaseProcess
64{
65public:
66
67 SplitByBoneCountProcess();
68 ~SplitByBoneCountProcess();
69
70public:
71 /** Returns whether the processing step is present in the given flag.
72 * @param pFlags The processing flags the importer was called with. A
73 * bitwise combination of #aiPostProcessSteps.
74 * @return true if the process is present in this flag fields,
75 * false if not.
76 */
77 bool IsActive( unsigned int pFlags) const;
78
79 /** Called prior to ExecuteOnScene().
80 * The function is a request to the process to update its configuration
81 * basing on the Importer's configuration property list.
82 */
83 virtual void SetupProperties(const Importer* pImp);
84
85protected:
86 /** Executes the post processing step on the given imported data.
87 * At the moment a process is not supposed to fail.
88 * @param pScene The imported data to work at.
89 */
90 void Execute( aiScene* pScene);
91
92 /// Splits the given mesh by bone count.
93 /// @param pMesh the Mesh to split. Is not changed at all, but might be superfluous in case it was split.
94 /// @param poNewMeshes Array of submeshes created in the process. Empty if splitting was not necessary.
95 void SplitMesh( const aiMesh* pMesh, std::vector<aiMesh*>& poNewMeshes) const;
96
97 /// Recursively updates the node's mesh list to account for the changed mesh list
98 void UpdateNode( aiNode* pNode) const;
99
100public:
101 /// Max bone count. Splitting occurs if a mesh has more than that number of bones.
102 size_t mMaxBoneCount;
103
104 /// Per mesh index: Array of indices of the new submeshes.
105 std::vector< std::vector<unsigned int> > mSubMeshIndices;
106};
107
108} // end of namespace Assimp
109
110#endif // !!AI_SPLITBYBONECOUNTPROCESS_H_INC
111