Coverage Report

Created: 2025-11-11 06:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/assimp/code/PostProcessing/ConvertToLHProcess.h
Line
Count
Source
1
/*
2
Open Asset Import Library (assimp)
3
----------------------------------------------------------------------
4
5
Copyright (c) 2006-2025, 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  MakeLeftHandedProcess.h
43
 *  @brief Defines a bunch of post-processing steps to handle
44
 *    coordinate system conversions.
45
 *
46
 *  - LH to RH
47
 *  - UV origin upper-left to lower-left
48
 *  - face order cw to ccw
49
 */
50
#ifndef AI_CONVERTTOLHPROCESS_H_INC
51
#define AI_CONVERTTOLHPROCESS_H_INC
52
53
#include <assimp/types.h>
54
55
#include "Common/BaseProcess.h"
56
57
struct aiMesh;
58
struct aiNodeAnim;
59
struct aiNode;
60
struct aiMaterial;
61
struct aiCamera;
62
63
namespace Assimp {
64
65
// -----------------------------------------------------------------------------------
66
/** @brief The MakeLeftHandedProcess converts all imported data to a left-handed
67
 *   coordinate system.
68
 *
69
 * This implies a mirroring of the Z axis of the coordinate system. But to keep
70
 * transformation matrices free from reflections we shift the reflection to other
71
 * places. We mirror the meshes and adapt the rotations.
72
 *
73
 * @note RH-LH and LH-RH is the same, so this class can be used for both
74
 */
75
class MakeLeftHandedProcess final : public BaseProcess {
76
public:
77
1.18k
    MakeLeftHandedProcess() = default;
78
    ~MakeLeftHandedProcess() override = default;
79
80
    // -------------------------------------------------------------------
81
    bool IsActive( unsigned int pFlags) const override;
82
83
    // -------------------------------------------------------------------
84
    void Execute( aiScene* pScene) override;
85
86
protected:
87
    // -------------------------------------------------------------------
88
    /** Recursively converts a node and all of its children
89
     */
90
    void ProcessNode( aiNode* pNode, const aiMatrix4x4& pParentGlobalRotation);
91
92
    // -------------------------------------------------------------------
93
    /** Converts a single mesh to left handed coordinates.
94
     * This means that positions, normals and tangents are mirrored at
95
     * the local Z axis and the order of all faces are inverted.
96
     * @param pMesh The mesh to convert.
97
     */
98
    void ProcessMesh( aiMesh* pMesh);
99
100
    // -------------------------------------------------------------------
101
    /** Converts a single material to left-handed coordinates
102
     * @param pMat Material to convert
103
     */
104
    void ProcessMaterial( aiMaterial* pMat);
105
106
    // -------------------------------------------------------------------
107
    /** Converts the given animation to LH coordinates.
108
     * The rotation and translation keys are transformed, the scale keys
109
     * work in local space and can therefore be left untouched.
110
     * @param pAnim The bone animation to transform
111
     */
112
    void ProcessAnimation( aiNodeAnim* pAnim);
113
114
    // -------------------------------------------------------------------
115
    /** Converts a single camera to left handed coordinates.
116
     * The camera viewing direction is inverted by reflecting mLookAt
117
     * across mPosition.
118
     * @param pCam The camera to convert
119
     */
120
    void ProcessCamera( aiCamera* pCam);
121
};
122
123
124
// ---------------------------------------------------------------------------
125
/** Postprocessing step to flip the face order of the imported data
126
 */
127
class FlipWindingOrderProcess : public BaseProcess {
128
    friend class Importer;
129
130
public:
131
    /** Constructor to be privately used by Importer */
132
1.18k
    FlipWindingOrderProcess() = default;
133
134
    /** Destructor, private as well */
135
    ~FlipWindingOrderProcess() override = default;
136
137
    // -------------------------------------------------------------------
138
    bool IsActive( unsigned int pFlags) const override;
139
140
    // -------------------------------------------------------------------
141
    void Execute( aiScene* pScene) override;
142
143
    /** Some other types of post-processing require winding order flips */
144
    static void ProcessMesh( aiMesh* pMesh);
145
};
146
147
// ---------------------------------------------------------------------------
148
/** Postprocessing step to flip the UV coordinate system of the import data
149
 */
150
class FlipUVsProcess final : public BaseProcess
151
{
152
    friend class Importer;
153
154
public:
155
    /** Constructor to be privately used by Importer */
156
    FlipUVsProcess();
157
158
    /** Destructor, private as well */
159
    ~FlipUVsProcess() override;
160
161
    // -------------------------------------------------------------------
162
    bool IsActive( unsigned int pFlags) const override;
163
164
    // -------------------------------------------------------------------
165
    void Execute( aiScene* pScene) override;
166
167
protected:
168
    void ProcessMesh( aiMesh* pMesh);
169
    void ProcessMaterial( aiMaterial* mat);
170
};
171
172
} // end of namespace Assimp
173
174
#endif // AI_CONVERTTOLHPROCESS_H_INC