Introduce interpolation mode to vectro and quaternion keys (#5674)

* Introduce interpolation mode to vectro and quaternion keys

* Update USDLoader.cpp

Fix review finding

* Update USDLoader.h

Fix review finding,
pull/5658/head^2
Kim Kulling 2024-07-18 23:54:31 +02:00 committed by GitHub
parent 91e93578c7
commit 9cf03b4ddc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 302 additions and 213 deletions

View File

@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2024, assimp team Copyright (c) 2006-2024, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,
@ -37,11 +36,9 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@author: Richard Steffen, 2015
---------------------------------------------------------------------- ----------------------------------------------------------------------
*/ */
#ifndef ASSIMP_BUILD_NO_EXPORT #ifndef ASSIMP_BUILD_NO_EXPORT
#ifndef ASSIMP_BUILD_NO_STEP_EXPORTER #ifndef ASSIMP_BUILD_NO_STEP_EXPORTER

View File

@ -1,15 +1,14 @@
/* /*
---------------------------------------------------------------------------
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2024, assimp team Copyright (c) 2006-2024, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following with or without modification, are permitted provided that the
conditions are met: following conditions are met:
* Redistributions of source code must retain the above * Redistributions of source code must retain the above
copyright notice, this list of conditions and the copyright notice, this list of conditions and the
@ -36,7 +35,7 @@ Copyright (c) 2006-2024, assimp team
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------- ----------------------------------------------------------------------
*/ */
/** @file USDLoader.cpp /** @file USDLoader.cpp
@ -87,8 +86,7 @@ USDImporter::USDImporter() :
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
bool USDImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const { bool USDImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool) const {
UNUSED(checkSig);
// Based on token // Based on token
static const uint32_t usdcTokens[] = { AI_MAKE_MAGIC("PXR-USDC") }; static const uint32_t usdcTokens[] = { AI_MAKE_MAGIC("PXR-USDC") };
bool canRead = CheckMagicToken(pIOHandler, pFile, usdcTokens, AI_COUNT_OF(usdcTokens)); bool canRead = CheckMagicToken(pIOHandler, pFile, usdcTokens, AI_COUNT_OF(usdcTokens));

View File

@ -1,15 +1,14 @@
/* /*
---------------------------------------------------------------------------
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2024, assimp team Copyright (c) 2006-2024, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following with or without modification, are permitted provided that the
conditions are met: following conditions are met:
* Redistributions of source code must retain the above * Redistributions of source code must retain the above
copyright notice, this list of conditions and the copyright notice, this list of conditions and the
@ -36,7 +35,8 @@ Copyright (c) 2006-2024, assimp team
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
----------------------------------------------------------------------
*/ */
/** @file USDLoader.cpp /** @file USDLoader.cpp
@ -72,7 +72,7 @@ Copyright (c) 2006-2024, assimp team
#include "../../../contrib/tinyusdz/assimp_tinyusdz_logging.inc" #include "../../../contrib/tinyusdz/assimp_tinyusdz_logging.inc"
namespace { namespace {
const char *const TAG = "tinyusdz loader"; static constexpr char Tag[] = "tinyusdz loader";
} }
namespace Assimp { namespace Assimp {
@ -81,9 +81,7 @@ using namespace std;
void USDImporterImplTinyusdz::InternReadFile( void USDImporterImplTinyusdz::InternReadFile(
const std::string &pFile, const std::string &pFile,
aiScene *pScene, aiScene *pScene,
IOSystem *pIOHandler) { IOSystem *) {
UNUSED(pIOHandler);
UNUSED(TAG); // Ignore unused variable when -Werror enabled
// Grab filename for logging purposes // Grab filename for logging purposes
size_t pos = pFile.find_last_of('/'); size_t pos = pFile.find_last_of('/');
string basePath = pFile.substr(0, pos); string basePath = pFile.substr(0, pos);

View File

@ -35,6 +35,7 @@ Copyright (c) 2006-2024, assimp team
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------- ----------------------------------------------------------------------
*/ */

View File

@ -1,3 +1,44 @@
/*
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2024, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
#ifndef ASSIMP_BUILD_NO_USD_IMPORTER #ifndef ASSIMP_BUILD_NO_USD_IMPORTER
#include "USDLoaderImplTinyusdzHelper.h" #include "USDLoaderImplTinyusdzHelper.h"

View File

@ -1,3 +1,44 @@
/*
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2024, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
#pragma once #pragma once
#ifndef AI_USDLOADER_IMPL_TINYUSDZ_HELPER_H_INCLUDED #ifndef AI_USDLOADER_IMPL_TINYUSDZ_HELPER_H_INCLUDED
#define AI_USDLOADER_IMPL_TINYUSDZ_HELPER_H_INCLUDED #define AI_USDLOADER_IMPL_TINYUSDZ_HELPER_H_INCLUDED

View File

@ -1,15 +1,14 @@
/* /*
---------------------------------------------------------------------------
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2024, assimp team Copyright (c) 2006-2024, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following with or without modification, are permitted provided that the
conditions are met: following conditions are met:
* Redistributions of source code must retain the above * Redistributions of source code must retain the above
copyright notice, this list of conditions and the copyright notice, this list of conditions and the
@ -36,7 +35,8 @@ Copyright (c) 2006-2024, assimp team
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
----------------------------------------------------------------------
*/ */
/** @file USDLoader.cpp /** @file USDLoader.cpp

View File

@ -35,6 +35,7 @@ Copyright (c) 2006-2024, assimp team
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------- ----------------------------------------------------------------------
*/ */
@ -45,15 +46,15 @@ Copyright (c) 2006-2024, assimp team
#ifndef AI_USDLOADER_UTIL_H_INCLUDED #ifndef AI_USDLOADER_UTIL_H_INCLUDED
#define AI_USDLOADER_UTIL_H_INCLUDED #define AI_USDLOADER_UTIL_H_INCLUDED
#include <assimp/BaseImporter.h> #include <string>
#include <assimp/types.h>
#include <vector>
#include <cstdint>
namespace Assimp { namespace Assimp {
bool isUsda(const std::string &pFile); bool isUsda(const std::string &pFile);
bool isUsdc(const std::string &pFile); bool isUsdc(const std::string &pFile);
bool isUsdz(const std::string &pFile); bool isUsdz(const std::string &pFile);
bool isUsd(const std::string &pFile); bool isUsd(const std::string &pFile);
} // namespace Assimp } // namespace Assimp
#endif // AI_USDLOADER_UTIL_H_INCLUDED #endif // AI_USDLOADER_UTIL_H_INCLUDED

View File

@ -71,10 +71,6 @@ SpatialSort::SpatialSort() :
mPlaneNormal.Normalize(); mPlaneNormal.Normalize();
} }
// ------------------------------------------------------------------------------------------------
// Destructor
SpatialSort::~SpatialSort() = default;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void SpatialSort::Fill(const aiVector3D *pPositions, unsigned int pNumPositions, void SpatialSort::Fill(const aiVector3D *pPositions, unsigned int pNumPositions,
unsigned int pElementOffset, unsigned int pElementOffset,

View File

@ -79,7 +79,7 @@ public:
unsigned int pElementOffset); unsigned int pElementOffset);
/** Destructor */ /** Destructor */
~SpatialSort(); ~SpatialSort() = default;
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
/** Sets the input data for the SpatialSort. This replaces existing data, if any. /** Sets the input data for the SpatialSort. This replaces existing data, if any.

View File

@ -59,6 +59,28 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
extern "C" { extern "C" {
#endif #endif
// ---------------------------------------------------------------------------
/**
*/
enum aiAnimInterpolation {
/** */
aiAnimInterpolation_Step,
/** */
aiAnimInterpolation_Linear,
/** */
aiAnimInterpolation_Spherical_Linear,
/** */
aiAnimInterpolation_Cubic_Spline,
/** */
#ifndef SWIG
_aiAnimInterpolation_Force32Bit = INT_MAX
#endif
};
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** A time-value pair specifying a certain 3D vector for the given time. */ /** A time-value pair specifying a certain 3D vector for the given time. */
struct aiVectorKey { struct aiVectorKey {
@ -68,21 +90,18 @@ struct aiVectorKey {
/** The value of this key */ /** The value of this key */
C_STRUCT aiVector3D mValue; C_STRUCT aiVector3D mValue;
/** The interpolation setting of this key */
C_ENUM aiAnimInterpolation mInterpolation;
#ifdef __cplusplus #ifdef __cplusplus
/// @brief The default constructor. /// @brief The default constructor.
aiVectorKey() AI_NO_EXCEPT aiVectorKey() AI_NO_EXCEPT
: mTime(0.0), : mTime(0.0), mValue(), mInterpolation(aiAnimInterpolation_Linear) {}
mValue() {
// empty
}
/// @brief Construction from a given time and key value. /// @brief Construction from a given time and key value.
aiVectorKey(double time, const aiVector3D &value) : aiVectorKey(double time, const aiVector3D &value) :
mTime(time), mValue(value) { mTime(time), mValue(value), mInterpolation(aiAnimInterpolation_Linear){}
// empty
}
typedef aiVector3D elem_type; typedef aiVector3D elem_type;
@ -116,16 +135,16 @@ struct aiQuatKey {
/** The value of this key */ /** The value of this key */
C_STRUCT aiQuaternion mValue; C_STRUCT aiQuaternion mValue;
/** The interpolation setting of this key */
C_ENUM aiAnimInterpolation mInterpolation;
#ifdef __cplusplus #ifdef __cplusplus
aiQuatKey() AI_NO_EXCEPT aiQuatKey() AI_NO_EXCEPT
: mTime(0.0), : mTime(0.0), mValue(), mInterpolation(aiAnimInterpolation_Linear) {}
mValue() {
// empty
}
/** Construction from a given time and key value */ /** Construction from a given time and key value */
aiQuatKey(double time, const aiQuaternion &value) : aiQuatKey(double time, const aiQuaternion &value) :
mTime(time), mValue(value) {} mTime(time), mValue(value), mInterpolation(aiAnimInterpolation_Linear) {}
typedef aiQuaternion elem_type; typedef aiQuaternion elem_type;

View File

@ -1527,7 +1527,7 @@ ASSIMP_API C_ENUM aiReturn aiGetMaterialFloatArray(
const char *pKey, const char *pKey,
unsigned int type, unsigned int type,
unsigned int index, unsigned int index,
ai_real *pOut, float *pOut,
unsigned int *pMax); unsigned int *pMax);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -1553,7 +1553,7 @@ inline aiReturn aiGetMaterialFloat(const C_STRUCT aiMaterial *pMat,
const char *pKey, const char *pKey,
unsigned int type, unsigned int type,
unsigned int index, unsigned int index,
ai_real *pOut) { float *pOut) {
return aiGetMaterialFloatArray(pMat, pKey, type, index, pOut, (unsigned int *)0x0); return aiGetMaterialFloatArray(pMat, pKey, type, index, pOut, (unsigned int *)0x0);
} }

View File

@ -67,7 +67,7 @@ AI_FORCE_INLINE aiReturn aiMaterial::GetTexture( aiTextureType type,
C_STRUCT aiString* path, C_STRUCT aiString* path,
aiTextureMapping* mapping /*= NULL*/, aiTextureMapping* mapping /*= NULL*/,
unsigned int* uvindex /*= NULL*/, unsigned int* uvindex /*= NULL*/,
ai_real* blend /*= NULL*/, float* blend /*= NULL*/,
aiTextureOp* op /*= NULL*/, aiTextureOp* op /*= NULL*/,
aiTextureMapMode* mapmode /*= NULL*/) const { aiTextureMapMode* mapmode /*= NULL*/) const {
return ::aiGetMaterialTexture(this,type,index,path,mapping,uvindex,blend,op,mapmode); return ::aiGetMaterialTexture(this,type,index,path,mapping,uvindex,blend,op,mapmode);
@ -136,9 +136,7 @@ AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
// Specialisation for a single bool. // Specialisation for a single bool.
// Casts floating point and integer to bool // Casts floating point and integer to bool
template <> template <>
AI_FORCE_INLINE AI_FORCE_INLINE aiReturn aiMaterial::Get(const char *pKey, unsigned int type,
aiReturn
aiMaterial::Get(const char *pKey, unsigned int type,
unsigned int idx, bool &pOut) const { unsigned int idx, bool &pOut) const {
const aiMaterialProperty *prop; const aiMaterialProperty *prop;
const aiReturn ret = ::aiGetMaterialProperty(this, pKey, type, idx, const aiReturn ret = ::aiGetMaterialProperty(this, pKey, type, idx,
@ -193,7 +191,7 @@ AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type, AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
unsigned int idx,ai_real& pOut) const { unsigned int idx, float& pOut) const {
return aiGetMaterialFloat(this,pKey,type,idx,&pOut); return aiGetMaterialFloat(this,pKey,type,idx,&pOut);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -312,7 +310,6 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const int* pInput,
pKey,type,index,aiPTI_Integer); pKey,type,index,aiPTI_Integer);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// The template specializations below are for backwards compatibility. // The template specializations below are for backwards compatibility.
// The recommended way to add material properties is using the non-template // The recommended way to add material properties is using the non-template