1 | /* |
2 | --------------------------------------------------------------------------- |
3 | Open Asset Import Library (assimp) |
4 | --------------------------------------------------------------------------- |
5 | |
6 | Copyright (c) 2006-2019, assimp team |
7 | |
8 | |
9 | All rights reserved. |
10 | |
11 | Redistribution and use of this software in source and binary forms, |
12 | with or without modification, are permitted provided that the following |
13 | conditions are met: |
14 | |
15 | * Redistributions of source code must retain the above |
16 | copyright notice, this list of conditions and the |
17 | following disclaimer. |
18 | |
19 | * Redistributions in binary form must reproduce the above |
20 | copyright notice, this list of conditions and the |
21 | following disclaimer in the documentation and/or other |
22 | materials provided with the distribution. |
23 | |
24 | * Neither the name of the assimp team, nor the names of its |
25 | contributors may be used to endorse or promote products |
26 | derived from this software without specific prior |
27 | written permission of the assimp team. |
28 | |
29 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
30 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
31 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
32 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
33 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
34 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
35 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
36 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
37 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
38 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
39 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
40 | --------------------------------------------------------------------------- |
41 | */ |
42 | |
43 | // Actually just a dummy, used by the compiler to build the precompiled header. |
44 | |
45 | #include <assimp/version.h> |
46 | #include <assimp/scene.h> |
47 | #include "ScenePrivate.h" |
48 | |
49 | static const unsigned int MajorVersion = 5; |
50 | static const unsigned int MinorVersion = 0; |
51 | |
52 | // -------------------------------------------------------------------------------- |
53 | // Legal information string - don't remove this. |
54 | static const char* LEGAL_INFORMATION = |
55 | |
56 | "Open Asset Import Library (Assimp).\n" |
57 | "A free C/C++ library to import various 3D file formats into applications\n\n" |
58 | |
59 | "(c) 2008-2020, assimp team\n" |
60 | "License under the terms and conditions of the 3-clause BSD license\n" |
61 | "https://github.com/assimp/assimp\n" |
62 | ; |
63 | |
64 | // ------------------------------------------------------------------------------------------------ |
65 | // Get legal string |
66 | ASSIMP_API const char* aiGetLegalString () { |
67 | return LEGAL_INFORMATION; |
68 | } |
69 | |
70 | // ------------------------------------------------------------------------------------------------ |
71 | // Get Assimp minor version |
72 | ASSIMP_API unsigned int aiGetVersionMinor () { |
73 | return MinorVersion; |
74 | } |
75 | |
76 | // ------------------------------------------------------------------------------------------------ |
77 | // Get Assimp major version |
78 | ASSIMP_API unsigned int aiGetVersionMajor () { |
79 | return MajorVersion; |
80 | } |
81 | |
82 | // ------------------------------------------------------------------------------------------------ |
83 | // Get flags used for compilation |
84 | ASSIMP_API unsigned int aiGetCompileFlags () { |
85 | |
86 | unsigned int flags = 0; |
87 | |
88 | #ifdef ASSIMP_BUILD_BOOST_WORKAROUND |
89 | flags |= ASSIMP_CFLAGS_NOBOOST; |
90 | #endif |
91 | #ifdef ASSIMP_BUILD_SINGLETHREADED |
92 | flags |= ASSIMP_CFLAGS_SINGLETHREADED; |
93 | #endif |
94 | #ifdef ASSIMP_BUILD_DEBUG |
95 | flags |= ASSIMP_CFLAGS_DEBUG; |
96 | #endif |
97 | #ifdef ASSIMP_BUILD_DLL_EXPORT |
98 | flags |= ASSIMP_CFLAGS_SHARED; |
99 | #endif |
100 | #ifdef _STLPORT_VERSION |
101 | flags |= ASSIMP_CFLAGS_STLPORT; |
102 | #endif |
103 | |
104 | return flags; |
105 | } |
106 | |
107 | // include current build revision, which is even updated from time to time -- :-) |
108 | #include "revision.h" |
109 | |
110 | // ------------------------------------------------------------------------------------------------ |
111 | ASSIMP_API unsigned int aiGetVersionRevision() { |
112 | return GitVersion; |
113 | } |
114 | |
115 | ASSIMP_API const char *aiGetBranchName() { |
116 | return GitBranch; |
117 | } |
118 | |
119 | // ------------------------------------------------------------------------------------------------ |
120 | ASSIMP_API aiScene::aiScene() |
121 | : mFlags(0) |
122 | , mRootNode(nullptr) |
123 | , mNumMeshes(0) |
124 | , mMeshes(nullptr) |
125 | , mNumMaterials(0) |
126 | , mMaterials(nullptr) |
127 | , mNumAnimations(0) |
128 | , mAnimations(nullptr) |
129 | , mNumTextures(0) |
130 | , mTextures(nullptr) |
131 | , mNumLights(0) |
132 | , mLights(nullptr) |
133 | , mNumCameras(0) |
134 | , mCameras(nullptr) |
135 | , mMetaData(nullptr) |
136 | , mPrivate(new Assimp::ScenePrivateData()) { |
137 | // empty |
138 | } |
139 | |
140 | // ------------------------------------------------------------------------------------------------ |
141 | ASSIMP_API aiScene::~aiScene() { |
142 | // delete all sub-objects recursively |
143 | delete mRootNode; |
144 | |
145 | // To make sure we won't crash if the data is invalid it's |
146 | // much better to check whether both mNumXXX and mXXX are |
147 | // valid instead of relying on just one of them. |
148 | if (mNumMeshes && mMeshes) |
149 | for( unsigned int a = 0; a < mNumMeshes; a++) |
150 | delete mMeshes[a]; |
151 | delete [] mMeshes; |
152 | |
153 | if (mNumMaterials && mMaterials) { |
154 | for (unsigned int a = 0; a < mNumMaterials; ++a ) { |
155 | delete mMaterials[ a ]; |
156 | } |
157 | } |
158 | delete [] mMaterials; |
159 | |
160 | if (mNumAnimations && mAnimations) |
161 | for( unsigned int a = 0; a < mNumAnimations; a++) |
162 | delete mAnimations[a]; |
163 | delete [] mAnimations; |
164 | |
165 | if (mNumTextures && mTextures) |
166 | for( unsigned int a = 0; a < mNumTextures; a++) |
167 | delete mTextures[a]; |
168 | delete [] mTextures; |
169 | |
170 | if (mNumLights && mLights) |
171 | for( unsigned int a = 0; a < mNumLights; a++) |
172 | delete mLights[a]; |
173 | delete [] mLights; |
174 | |
175 | if (mNumCameras && mCameras) |
176 | for( unsigned int a = 0; a < mNumCameras; a++) |
177 | delete mCameras[a]; |
178 | delete [] mCameras; |
179 | |
180 | aiMetadata::Dealloc(metadata: mMetaData); |
181 | mMetaData = nullptr; |
182 | |
183 | delete static_cast<Assimp::ScenePrivateData*>( mPrivate ); |
184 | } |
185 | |
186 | |