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 #include "revision.h"
50 
51 // --------------------------------------------------------------------------------
52 // Legal information string - don't remove this.
53 static const char* LEGAL_INFORMATION =
54 
55 "Open Asset Import Library (Assimp).\n"
56 "A free C/C++ library to import various 3D file formats into applications\n\n"
57 
58 "(c) 2006-2019, assimp team\n"
59 "License under the terms and conditions of the 3-clause BSD license\n"
60 "http://assimp.org\n"
61 ;
62 
63 // ------------------------------------------------------------------------------------------------
64 // Get legal string
aiGetLegalString()65 ASSIMP_API const char*  aiGetLegalString  ()    {
66     return LEGAL_INFORMATION;
67 }
68 
69 // ------------------------------------------------------------------------------------------------
70 // Get Assimp minor version
aiGetVersionMinor()71 ASSIMP_API unsigned int aiGetVersionMinor ()    {
72     return VER_MINOR;
73 }
74 
75 // ------------------------------------------------------------------------------------------------
76 // Get Assimp major version
aiGetVersionMajor()77 ASSIMP_API unsigned int aiGetVersionMajor ()    {
78     return VER_MAJOR;
79 }
80 
81 // ------------------------------------------------------------------------------------------------
82 // Get flags used for compilation
aiGetCompileFlags()83 ASSIMP_API unsigned int aiGetCompileFlags ()    {
84 
85     unsigned int flags = 0;
86 
87 #ifdef ASSIMP_BUILD_BOOST_WORKAROUND
88     flags |= ASSIMP_CFLAGS_NOBOOST;
89 #endif
90 #ifdef ASSIMP_BUILD_SINGLETHREADED
91     flags |= ASSIMP_CFLAGS_SINGLETHREADED;
92 #endif
93 #ifdef ASSIMP_BUILD_DEBUG
94     flags |= ASSIMP_CFLAGS_DEBUG;
95 #endif
96 #ifdef ASSIMP_BUILD_DLL_EXPORT
97     flags |= ASSIMP_CFLAGS_SHARED;
98 #endif
99 #ifdef _STLPORT_VERSION
100     flags |= ASSIMP_CFLAGS_STLPORT;
101 #endif
102 
103     return flags;
104 }
105 
106 // ------------------------------------------------------------------------------------------------
aiGetVersionRevision()107 ASSIMP_API unsigned int aiGetVersionRevision() {
108     return GitVersion;
109 }
110 
aiGetBranchName()111 ASSIMP_API const char *aiGetBranchName() {
112     return GitBranch;
113 }
114 
115 // ------------------------------------------------------------------------------------------------
aiScene()116 ASSIMP_API aiScene::aiScene()
117 : mFlags(0)
118 , mRootNode(nullptr)
119 , mNumMeshes(0)
120 , mMeshes(nullptr)
121 , mNumMaterials(0)
122 , mMaterials(nullptr)
123 , mNumAnimations(0)
124 , mAnimations(nullptr)
125 , mNumTextures(0)
126 , mTextures(nullptr)
127 , mNumLights(0)
128 , mLights(nullptr)
129 , mNumCameras(0)
130 , mCameras(nullptr)
131 , mMetaData(nullptr)
132 , mPrivate(new Assimp::ScenePrivateData()) {
133 	// empty
134 }
135 
136 // ------------------------------------------------------------------------------------------------
~aiScene()137 ASSIMP_API aiScene::~aiScene() {
138     // delete all sub-objects recursively
139     delete mRootNode;
140 
141     // To make sure we won't crash if the data is invalid it's
142     // much better to check whether both mNumXXX and mXXX are
143     // valid instead of relying on just one of them.
144     if (mNumMeshes && mMeshes)
145         for( unsigned int a = 0; a < mNumMeshes; a++)
146             delete mMeshes[a];
147     delete [] mMeshes;
148 
149     if (mNumMaterials && mMaterials) {
150         for (unsigned int a = 0; a < mNumMaterials; ++a ) {
151             delete mMaterials[ a ];
152         }
153     }
154     delete [] mMaterials;
155 
156     if (mNumAnimations && mAnimations)
157         for( unsigned int a = 0; a < mNumAnimations; a++)
158             delete mAnimations[a];
159     delete [] mAnimations;
160 
161     if (mNumTextures && mTextures)
162         for( unsigned int a = 0; a < mNumTextures; a++)
163             delete mTextures[a];
164     delete [] mTextures;
165 
166     if (mNumLights && mLights)
167         for( unsigned int a = 0; a < mNumLights; a++)
168             delete mLights[a];
169     delete [] mLights;
170 
171     if (mNumCameras && mCameras)
172         for( unsigned int a = 0; a < mNumCameras; a++)
173             delete mCameras[a];
174     delete [] mCameras;
175 
176     aiMetadata::Dealloc(mMetaData);
177     mMetaData = nullptr;
178 
179     delete static_cast<Assimp::ScenePrivateData*>( mPrivate );
180 }
181 
182