Coverage Report

Created: 2024-08-02 07:04

/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-2024, assimp team
6
7
8
All rights reserved.
9
10
Redistribution and use of this software in source and binary forms,
11
with or without modification, are permitted provided that the
12
following conditions are met:
13
14
* Redistributions of source code must retain the above
15
  copyright notice, this list of conditions and the
16
  following disclaimer.
17
18
* Redistributions in binary form must reproduce the above
19
  copyright notice, this list of conditions and the
20
  following disclaimer in the documentation and/or other
21
  materials provided with the distribution.
22
23
* Neither the name of the assimp team, nor the names of its
24
  contributors may be used to endorse or promote products
25
  derived from this software without specific prior
26
  written permission of the assimp team.
27
28
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
40
----------------------------------------------------------------------
41
*/
42
43
/** @file  BlenderModifier.h
44
 *  @brief Declare dedicated helper classes to simulate some blender modifiers (i.e. mirror)
45
 */
46
#ifndef INCLUDED_AI_BLEND_MODIFIER_H
47
#define INCLUDED_AI_BLEND_MODIFIER_H
48
49
#include "BlenderIntermediate.h"
50
51
namespace Assimp {
52
namespace Blender {
53
54
// -------------------------------------------------------------------------------------------
55
/**
56
 *  Dummy base class for all blender modifiers. Modifiers are reused between imports, so
57
 *  they should be stateless and not try to cache model data.
58
 */
59
// -------------------------------------------------------------------------------------------
60
class BlenderModifier {
61
public:
62
    /**
63
     *  The class destructor, virtual.
64
     */
65
0
    virtual ~BlenderModifier() = default;
66
67
    // --------------------
68
    /**
69
     *  Check if *this* modifier is active, given a ModifierData& block.
70
     */
71
0
    virtual bool IsActive( const ModifierData& /*modin*/) {
72
0
        return false;
73
0
    }
74
75
    // --------------------
76
    /**
77
     *  Apply the modifier to a given output node. The original data used
78
     *  to construct the node is given as well. Not called unless IsActive()
79
     *  was called and gave positive response.
80
     */
81
    virtual void DoIt(aiNode& /*out*/,
82
        ConversionData& /*conv_data*/,
83
        const ElemBase& orig_modifier,
84
        const Scene& /*in*/,
85
        const Object& /*orig_object*/
86
0
    ) {
87
0
        ASSIMP_LOG_INFO("This modifier is not supported, skipping: ",orig_modifier.dna_type );
88
0
        return;
89
0
    }
90
};
91
92
// -------------------------------------------------------------------------------------------
93
/**
94
 *  Manage all known modifiers and instance and apply them if necessary
95
 */
96
// -------------------------------------------------------------------------------------------
97
class BlenderModifierShowcase {
98
public:
99
    // --------------------
100
    /** Apply all requested modifiers provided we support them. */
101
    void ApplyModifiers(aiNode& out,
102
        ConversionData& conv_data,
103
        const Scene& in,
104
        const Object& orig_object
105
    );
106
107
private:
108
    TempArray< std::vector,BlenderModifier > cached_modifiers;
109
};
110
111
// MODIFIERS /////////////////////////////////////////////////////////////////////////////////
112
113
// -------------------------------------------------------------------------------------------
114
/**
115
 *  Mirror modifier. Status: implemented.
116
 */
117
// -------------------------------------------------------------------------------------------
118
class BlenderModifier_Mirror : public BlenderModifier {
119
public:
120
    // --------------------
121
    virtual bool IsActive( const ModifierData& modin);
122
123
    // --------------------
124
    virtual void DoIt(aiNode& out,
125
        ConversionData& conv_data,
126
        const ElemBase& orig_modifier,
127
        const Scene& in,
128
        const Object& orig_object
129
    ) ;
130
};
131
132
// -------------------------------------------------------------------------------------------
133
/** Subdivision modifier. Status: dummy. */
134
// -------------------------------------------------------------------------------------------
135
class BlenderModifier_Subdivision : public BlenderModifier {
136
public:
137
138
    // --------------------
139
    virtual bool IsActive( const ModifierData& modin);
140
141
    // --------------------
142
    virtual void DoIt(aiNode& out,
143
        ConversionData& conv_data,
144
        const ElemBase& orig_modifier,
145
        const Scene& in,
146
        const Object& orig_object
147
    ) ;
148
};
149
150
}
151
}
152
153
#endif // !INCLUDED_AI_BLEND_MODIFIER_H