Compare commits
1 Commits
master
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ebe2d6924 |
2
.github/workflows/ccpp.yml
vendored
2
.github/workflows/ccpp.yml
vendored
@@ -89,7 +89,7 @@ jobs:
|
||||
run: echo "args=-DBUILD_SHARED_LIBS=OFF -DASSIMP_HUNTER_ENABLED=ON -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/polly/${{ matrix.toolchain }}.cmake" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: configure and build
|
||||
uses: lukka/run-cmake@v3
|
||||
uses: lukka/run-cmake@v10
|
||||
env:
|
||||
DXSDK_DIR: '${{ github.workspace }}/DX_SDK'
|
||||
|
||||
|
||||
4
.github/workflows/sanitizer.yml
vendored
4
.github/workflows/sanitizer.yml
vendored
@@ -22,7 +22,7 @@ jobs:
|
||||
CC: clang
|
||||
|
||||
- name: configure and build
|
||||
uses: lukka/run-cmake@v3
|
||||
uses: lukka/run-cmake@v10
|
||||
with:
|
||||
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
|
||||
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
CC: clang
|
||||
|
||||
- name: configure and build
|
||||
uses: lukka/run-cmake@v3
|
||||
uses: lukka/run-cmake@v10
|
||||
with:
|
||||
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
|
||||
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
|
||||
|
||||
@@ -149,18 +149,11 @@ aiQuaternion Read<aiQuaternion>(IOStream *stream) {
|
||||
template <>
|
||||
aiString Read<aiString>(IOStream *stream) {
|
||||
aiString s;
|
||||
uint32_t len;
|
||||
if (stream->Read(&len, 4, 1) != 1) {
|
||||
throw DeadlyImportError("ASSBIN: Unexpected EOF reading string length");
|
||||
stream->Read(&s.length, 4, 1);
|
||||
if (s.length) {
|
||||
stream->Read(s.data, s.length, 1);
|
||||
}
|
||||
if (len >= AI_MAXLEN) {
|
||||
throw DeadlyImportError("ASSBIN: String length too large, potential buffer overflow attempt");
|
||||
}
|
||||
s.length = len;
|
||||
if ((s.length > 0) && (stream->Read(s.data, s.length, 1) != 1)) {
|
||||
throw DeadlyImportError("ASSBIN: Unexpected EOF reading string data");
|
||||
}
|
||||
s.data[s.length] = '\0';
|
||||
s.data[s.length] = 0;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -45,8 +45,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_FBX_IMPORTER
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "FBXParser.h"
|
||||
#include "FBXDocument.h"
|
||||
#include "FBXMeshGeometry.h"
|
||||
@@ -146,10 +144,8 @@ BlendShape::BlendShape(uint64_t id, const Element& element, const Document& doc,
|
||||
for (const Connection* con : conns) {
|
||||
const BlendShapeChannel* const bspc = ProcessSimpleConnection<BlendShapeChannel>(*con, false, "BlendShapeChannel -> BlendShape", element);
|
||||
if (bspc) {
|
||||
// Only add a channel if it doesn't exist already
|
||||
if (std::find(blendShapeChannels.begin(), blendShapeChannels.end(), bspc) == blendShapeChannels.end()) {
|
||||
blendShapeChannels.push_back(bspc);
|
||||
} else {
|
||||
auto pr = blendShapeChannels.insert(bspc);
|
||||
if (!pr.second) {
|
||||
FBXImporter::LogWarn("there is the same blendShapeChannel id ", bspc->ID());
|
||||
}
|
||||
}
|
||||
@@ -174,10 +170,8 @@ BlendShapeChannel::BlendShapeChannel(uint64_t id, const Element& element, const
|
||||
for (const Connection* con : conns) {
|
||||
const ShapeGeometry* const sg = ProcessSimpleConnection<ShapeGeometry>(*con, false, "Shape -> BlendShapeChannel", element);
|
||||
if (sg) {
|
||||
// Only add a geometry if it doesn't exist already
|
||||
if (std::find(shapeGeometries.begin(), shapeGeometries.end(), sg) == shapeGeometries.end()) {
|
||||
shapeGeometries.push_back(sg);
|
||||
} else {
|
||||
auto pr = shapeGeometries.insert(sg);
|
||||
if (!pr.second) {
|
||||
FBXImporter::LogWarn("there is the same shapeGeometrie id ", sg->ID());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -865,14 +865,14 @@ public:
|
||||
return fullWeights;
|
||||
}
|
||||
|
||||
const std::vector<const ShapeGeometry*>& GetShapeGeometries() const {
|
||||
const std::unordered_set<const ShapeGeometry*>& GetShapeGeometries() const {
|
||||
return shapeGeometries;
|
||||
}
|
||||
|
||||
private:
|
||||
float percent;
|
||||
WeightArray fullWeights;
|
||||
std::vector<const ShapeGeometry*> shapeGeometries;
|
||||
std::unordered_set<const ShapeGeometry*> shapeGeometries;
|
||||
};
|
||||
|
||||
/** DOM class for BlendShape deformers */
|
||||
@@ -882,12 +882,12 @@ public:
|
||||
|
||||
virtual ~BlendShape() = default;
|
||||
|
||||
const std::vector<const BlendShapeChannel*>& BlendShapeChannels() const {
|
||||
const std::unordered_set<const BlendShapeChannel*>& BlendShapeChannels() const {
|
||||
return blendShapeChannels;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<const BlendShapeChannel*> blendShapeChannels;
|
||||
std::unordered_set<const BlendShapeChannel*> blendShapeChannels;
|
||||
};
|
||||
|
||||
/** DOM class for skin deformer clusters (aka sub-deformers) */
|
||||
|
||||
@@ -45,7 +45,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_FBX_IMPORTER
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
#include "FBXMeshGeometry.h"
|
||||
@@ -70,10 +69,8 @@ Geometry::Geometry(uint64_t id, const Element& element, const std::string& name,
|
||||
}
|
||||
const BlendShape* const bsp = ProcessSimpleConnection<BlendShape>(*con, false, "BlendShape -> Geometry", element);
|
||||
if (bsp) {
|
||||
// Only add a blendshape if it doesn't exist already
|
||||
if (std::find(blendShapes.begin(), blendShapes.end(), bsp) == blendShapes.end()) {
|
||||
blendShapes.push_back(bsp);
|
||||
} else {
|
||||
auto pr = blendShapes.insert(bsp);
|
||||
if (!pr.second) {
|
||||
FBXImporter::LogWarn("there is the same blendShape id ", bsp->ID());
|
||||
}
|
||||
}
|
||||
@@ -81,7 +78,7 @@ Geometry::Geometry(uint64_t id, const Element& element, const std::string& name,
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const std::vector<const BlendShape*>& Geometry::GetBlendShapes() const {
|
||||
const std::unordered_set<const BlendShape*>& Geometry::GetBlendShapes() const {
|
||||
return blendShapes;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,11 +72,11 @@ public:
|
||||
|
||||
/// @brief Get the BlendShape attached to this geometry or nullptr
|
||||
/// @return The blendshape arrays.
|
||||
const std::vector<const BlendShape*>& GetBlendShapes() const;
|
||||
const std::unordered_set<const BlendShape*>& GetBlendShapes() const;
|
||||
|
||||
private:
|
||||
const Skin* skin;
|
||||
std::vector<const BlendShape*> blendShapes;
|
||||
std::unordered_set<const BlendShape*> blendShapes;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -58,55 +58,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <stack>
|
||||
|
||||
namespace Assimp {
|
||||
namespace {
|
||||
ai_real calculateInputACMR(aiMesh *pMesh, const aiFace *const pcEnd,
|
||||
unsigned int configCacheDepth, unsigned int meshNum) {
|
||||
ai_real fACMR = 0.0f;
|
||||
unsigned int *piFIFOStack = new unsigned int[configCacheDepth];
|
||||
memset(piFIFOStack, 0xff, configCacheDepth * sizeof(unsigned int));
|
||||
unsigned int *piCur = piFIFOStack;
|
||||
const unsigned int *const piCurEnd = piFIFOStack + configCacheDepth;
|
||||
|
||||
// count the number of cache misses
|
||||
unsigned int iCacheMisses = 0;
|
||||
for (const aiFace *pcFace = pMesh->mFaces; pcFace != pcEnd; ++pcFace) {
|
||||
for (unsigned int qq = 0; qq < 3; ++qq) {
|
||||
bool bInCache = false;
|
||||
for (unsigned int *pp = piFIFOStack; pp < piCurEnd; ++pp) {
|
||||
if (*pp == pcFace->mIndices[qq]) {
|
||||
// the vertex is in cache
|
||||
bInCache = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!bInCache) {
|
||||
++iCacheMisses;
|
||||
if (piCurEnd == piCur) {
|
||||
piCur = piFIFOStack;
|
||||
}
|
||||
*piCur++ = pcFace->mIndices[qq];
|
||||
}
|
||||
}
|
||||
}
|
||||
delete[] piFIFOStack;
|
||||
fACMR = (ai_real)iCacheMisses / pMesh->mNumFaces;
|
||||
if (3.0 == fACMR) {
|
||||
char szBuff[128]; // should be sufficiently large in every case
|
||||
|
||||
// the JoinIdenticalVertices process has not been executed on this
|
||||
// mesh, otherwise this value would normally be at least minimally
|
||||
// smaller than 3.0 ...
|
||||
ai_snprintf(szBuff, 128, "Mesh %u: Not suitable for vcache optimization", meshNum);
|
||||
ASSIMP_LOG_WARN(szBuff);
|
||||
return static_cast<ai_real>(0.f);
|
||||
}
|
||||
return fACMR;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
ImproveCacheLocalityProcess::ImproveCacheLocalityProcess() : mConfigCacheDepth(PP_ICL_PTCACHE_SIZE) {
|
||||
ImproveCacheLocalityProcess::ImproveCacheLocalityProcess() :
|
||||
mConfigCacheDepth(PP_ICL_PTCACHE_SIZE) {
|
||||
// empty
|
||||
}
|
||||
|
||||
@@ -151,6 +107,51 @@ void ImproveCacheLocalityProcess::Execute(aiScene *pScene) {
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static ai_real calculateInputACMR(aiMesh *pMesh, const aiFace *const pcEnd,
|
||||
unsigned int configCacheDepth, unsigned int meshNum) {
|
||||
ai_real fACMR = 0.0f;
|
||||
unsigned int *piFIFOStack = new unsigned int[configCacheDepth];
|
||||
memset(piFIFOStack, 0xff, configCacheDepth * sizeof(unsigned int));
|
||||
unsigned int *piCur = piFIFOStack;
|
||||
const unsigned int *const piCurEnd = piFIFOStack + configCacheDepth;
|
||||
|
||||
// count the number of cache misses
|
||||
unsigned int iCacheMisses = 0;
|
||||
for (const aiFace *pcFace = pMesh->mFaces; pcFace != pcEnd; ++pcFace) {
|
||||
for (unsigned int qq = 0; qq < 3; ++qq) {
|
||||
bool bInCache = false;
|
||||
for (unsigned int *pp = piFIFOStack; pp < piCurEnd; ++pp) {
|
||||
if (*pp == pcFace->mIndices[qq]) {
|
||||
// the vertex is in cache
|
||||
bInCache = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!bInCache) {
|
||||
++iCacheMisses;
|
||||
if (piCurEnd == piCur) {
|
||||
piCur = piFIFOStack;
|
||||
}
|
||||
*piCur++ = pcFace->mIndices[qq];
|
||||
}
|
||||
}
|
||||
}
|
||||
delete[] piFIFOStack;
|
||||
fACMR = (ai_real)iCacheMisses / pMesh->mNumFaces;
|
||||
if (3.0 == fACMR) {
|
||||
char szBuff[128]; // should be sufficiently large in every case
|
||||
|
||||
// the JoinIdenticalVertices process has not been executed on this
|
||||
// mesh, otherwise this value would normally be at least minimally
|
||||
// smaller than 3.0 ...
|
||||
ai_snprintf(szBuff, 128, "Mesh %u: Not suitable for vcache optimization", meshNum);
|
||||
ASSIMP_LOG_WARN(szBuff);
|
||||
return static_cast<ai_real>(0.f);
|
||||
}
|
||||
return fACMR;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Improves the cache coherency of a specific mesh
|
||||
ai_real ImproveCacheLocalityProcess::ProcessMesh(aiMesh *pMesh, unsigned int meshNum) {
|
||||
|
||||
@@ -182,7 +182,7 @@ public:
|
||||
// ---------------------------------------------------------------------
|
||||
/// Get the remaining stream size (to the end of the stream)
|
||||
size_t GetRemainingSize() const {
|
||||
return static_cast<size_t>(mEnd - mCurrent);
|
||||
return (unsigned int)(mEnd - mCurrent);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -190,29 +190,16 @@ public:
|
||||
* return value is the remaining size of the stream if no custom
|
||||
* read limit has been set. */
|
||||
size_t GetRemainingSizeToLimit() const {
|
||||
return static_cast<size_t>(mLimit - mCurrent);
|
||||
return (unsigned int)(mLimit - mCurrent);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Increase the file pointer (relative seeking) */
|
||||
void IncPtr(intptr_t plus) {
|
||||
// Ensure internal pointer invariants hold
|
||||
if (mCurrent < mBuffer || mCurrent > mLimit) {
|
||||
throw DeadlyImportError("StreamReader: Invalid internal pointer state");
|
||||
}
|
||||
|
||||
if (plus < 0) {
|
||||
const size_t absPlus = static_cast<size_t>(-(plus + 1)) + 1;
|
||||
if (absPlus > static_cast<size_t>(mCurrent - mBuffer)) {
|
||||
throw DeadlyImportError("StreamReader: Attempted to seek outside buffer bounds");
|
||||
}
|
||||
} else if (plus > 0) {
|
||||
if (static_cast<size_t>(plus) > static_cast<size_t>(mLimit - mCurrent)) {
|
||||
throw DeadlyImportError("StreamReader: Attempted to seek outside buffer bounds");
|
||||
}
|
||||
}
|
||||
|
||||
mCurrent += plus;
|
||||
if (mCurrent > mLimit) {
|
||||
throw DeadlyImportError("End of file or read limit was reached");
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -246,9 +233,8 @@ public:
|
||||
}
|
||||
|
||||
/// @brief Get the current offset from the beginning of the file
|
||||
/// @return The current offset from the beginning of the file.
|
||||
int GetCurrentPos() const {
|
||||
return static_cast<int>(mCurrent - mBuffer);
|
||||
return (unsigned int)(mCurrent - mBuffer);
|
||||
}
|
||||
|
||||
void SetCurrentPos(size_t pos) {
|
||||
@@ -258,10 +244,10 @@ public:
|
||||
// ---------------------------------------------------------------------
|
||||
/** Setup a temporary read limit
|
||||
*
|
||||
* @param _limit Maximum number of bytes to be read from
|
||||
* @param limit Maximum number of bytes to be read from
|
||||
* the beginning of the file. Specifying UINT_MAX
|
||||
* resets the limit to the original end of the stream.
|
||||
* @return The previously set limit. */
|
||||
* Returns the previously set limit. */
|
||||
unsigned int SetReadLimit(unsigned int _limit) {
|
||||
unsigned int prev = GetReadLimit();
|
||||
if (UINT_MAX == _limit) {
|
||||
@@ -278,10 +264,9 @@ public:
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Get the current read limit in bytes. Reading over this limit
|
||||
* accidentally raises an exception.
|
||||
* @return The current limit. */
|
||||
* accidentally raises an exception. */
|
||||
unsigned int GetReadLimit() const {
|
||||
return static_cast<unsigned int>(mLimit - mBuffer);
|
||||
return (unsigned int)(mLimit - mBuffer);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user