Coverage Report

Created: 2025-06-22 07:30

/src/assimp/code/AssetLib/Blender/BlenderModifier.h
Line
Count
Source (jump to first uncovered line)
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  BlenderModifier.h
43
 *  @brief Declare dedicated helper classes to simulate some blender modifiers (i.e. mirror)
44
 */
45
#ifndef INCLUDED_AI_BLEND_MODIFIER_H
46
#define INCLUDED_AI_BLEND_MODIFIER_H
47
48
#include "BlenderIntermediate.h"
49
50
namespace Assimp {
51
namespace Blender {
52
53
// -------------------------------------------------------------------------------------------
54
/**
55
 *  Dummy base class for all blender modifiers. Modifiers are reused between imports, so
56
 *  they should be stateless and not try to cache model data.
57
 */
58
// -------------------------------------------------------------------------------------------
59
class BlenderModifier {
60
public:
61
    /**
62
     *  The class destructor, virtual.
63
     */
64
0
    virtual ~BlenderModifier() = default;
65
66
    // --------------------
67
    /**
68
     *  Check if *this* modifier is active, given a ModifierData& block.
69
     */
70
0
    virtual bool IsActive( const ModifierData& /*modin*/) {
71
0
        return false;
72
0
    }
73
74
    // --------------------
75
    /**
76
     *  Apply the modifier to a given output node. The original data used
77
     *  to construct the node is given as well. Not called unless IsActive()
78
     *  was called and gave positive response.
79
     */
80
    virtual void DoIt(aiNode& /*out*/,
81
        ConversionData& /*conv_data*/,
82
        const ElemBase& orig_modifier,
83
        const Scene& /*in*/,
84
        const Object& /*orig_object*/
85
0
    ) {
86
0
        ASSIMP_LOG_INFO("This modifier is not supported, skipping: ",orig_modifier.dna_type );
87
0
        return;
88
0
    }
89
};
90
91
// -------------------------------------------------------------------------------------------
92
/**
93
 *  Manage all known modifiers and instance and apply them if necessary
94
 */
95
// -------------------------------------------------------------------------------------------
96
class BlenderModifierShowcase {
97
public:
98
    // --------------------
99
    /** Apply all requested modifiers provided we support them. */
100
    void ApplyModifiers(aiNode& out,
101
        ConversionData& conv_data,
102
        const Scene& in,
103
        const Object& orig_object
104
    );
105
106
private:
107
    TempArray< std::vector,BlenderModifier > cached_modifiers;
108
};
109
110
// MODIFIERS /////////////////////////////////////////////////////////////////////////////////
111
112
// -------------------------------------------------------------------------------------------
113
/**
114
 *  Mirror modifier. Status: implemented.
115
 */
116
// -------------------------------------------------------------------------------------------
117
class BlenderModifier_Mirror : public BlenderModifier {
118
public:
119
    // --------------------
120
    virtual bool IsActive( const ModifierData& modin);
121
122
    // --------------------
123
    virtual void DoIt(aiNode& out,
124
        ConversionData& conv_data,
125
        const ElemBase& orig_modifier,
126
        const Scene& in,
127
        const Object& orig_object
128
    ) ;
129
};
130
131
// -------------------------------------------------------------------------------------------
132
/** Subdivision modifier. Status: dummy. */
133
// -------------------------------------------------------------------------------------------
134
class BlenderModifier_Subdivision : public BlenderModifier {
135
public:
136
137
    // --------------------
138
    virtual bool IsActive( const ModifierData& modin);
139
140
    // --------------------
141
    virtual void DoIt(aiNode& out,
142
        ConversionData& conv_data,
143
        const ElemBase& orig_modifier,
144
        const Scene& in,
145
        const Object& orig_object
146
    ) ;
147
};
148
149
}
150
}
151
152
#endif // !INCLUDED_AI_BLEND_MODIFIER_H