Merge branch 'master' into clean-up-ctors-dtors
This commit is contained in:
@@ -160,7 +160,7 @@ D3MFOpcPackage::D3MFOpcPackage(IOSystem *pIOHandler, const std::string &rFile) :
|
||||
// deal with zip-bug
|
||||
rootFile = rootFile.substr(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ASSIMP_LOG_VERBOSE_DEBUG(rootFile);
|
||||
|
||||
|
||||
@@ -216,7 +216,7 @@ void XmlSerializer::ImportXml(aiScene *scene) {
|
||||
if (nullptr == scene) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
scene->mRootNode = new aiNode(XmlTag::RootTag);
|
||||
XmlNode node = mXmlParser->getRootNode().child(XmlTag::model);
|
||||
if (node.empty()) {
|
||||
@@ -444,7 +444,7 @@ void XmlSerializer::ImportTriangles(XmlNode &node, aiMesh *mesh) {
|
||||
}
|
||||
mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,5 +56,5 @@ namespace Assimp {
|
||||
void ASSIMP_API ExportSceneAssbin(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/);
|
||||
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif // AI_ASSBINEXPORTER_H_INC
|
||||
|
||||
@@ -291,15 +291,15 @@ public:
|
||||
size_t Read(void * /*pvBuffer*/, size_t /*pSize*/, size_t /*pCount*/) override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
aiReturn Seek(size_t /*pOffset*/, aiOrigin /*pOrigin*/) override {
|
||||
return aiReturn_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
size_t Tell() const override {
|
||||
return cursor;
|
||||
}
|
||||
|
||||
|
||||
void Flush() override {
|
||||
// not implemented
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
Flag_WriteSpecialFloats = 0x2,
|
||||
Flag_SkipWhitespaces = 0x4
|
||||
};
|
||||
|
||||
|
||||
JSONWriter(Assimp::IOStream &out, unsigned int flags = 0u) :
|
||||
out(out), indent (""), newline("\n"), space(" "), buff (), first(false), flags(flags) {
|
||||
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
||||
@@ -499,18 +499,18 @@ static void Write(JSONWriter &out, const aiMaterial &ai, bool is_elem = true) {
|
||||
}
|
||||
break;
|
||||
|
||||
case aiPTI_String:
|
||||
case aiPTI_String:
|
||||
{
|
||||
aiString s;
|
||||
aiGetMaterialString(&ai, prop->mKey.data, prop->mSemantic, prop->mIndex, &s);
|
||||
out.SimpleValue(s);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case aiPTI_Buffer:
|
||||
case aiPTI_Buffer:
|
||||
{
|
||||
// binary data is written as series of hex-encoded octets
|
||||
out.SimpleValue(prop->mData, prop->mDataLength);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ai_assert(false);
|
||||
|
||||
@@ -52,8 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
namespace Assimp {
|
||||
template <>
|
||||
const char *LogFunctions<BlenderBMeshConverter>::Prefix() {
|
||||
static auto prefix = "BLEND_BMESH: ";
|
||||
return prefix;
|
||||
return "BLEND_BMESH: ";
|
||||
}
|
||||
} // namespace Assimp
|
||||
|
||||
|
||||
@@ -80,8 +80,7 @@ namespace Assimp {
|
||||
|
||||
template <>
|
||||
const char *LogFunctions<BlenderImporter>::Prefix() {
|
||||
static auto prefix = "BLEND: ";
|
||||
return prefix;
|
||||
return "BLEND: ";
|
||||
}
|
||||
|
||||
} // namespace Assimp
|
||||
|
||||
@@ -62,8 +62,7 @@ namspace Assimp
|
||||
{
|
||||
template< > const char* LogFunctions< BlenderTessellatorGL >::Prefix()
|
||||
{
|
||||
static auto prefix = "BLEND_TESS_GL: ";
|
||||
return prefix;
|
||||
return "BLEND_TESS_GL: ";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,8 +256,7 @@ namespace Assimp
|
||||
{
|
||||
template< > const char* LogFunctions< BlenderTessellatorP2T >::Prefix()
|
||||
{
|
||||
static auto prefix = "BLEND_TESS_P2T: ";
|
||||
return prefix;
|
||||
return "BLEND_TESS_P2T: ";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,8 +86,7 @@ void GetWriterInfo(int &id, String &appname) {
|
||||
|
||||
namespace Assimp {
|
||||
template<> const char* LogFunctions<C4DImporter>::Prefix() {
|
||||
static auto prefix = "C4D: ";
|
||||
return prefix;
|
||||
return "C4D: ";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +118,7 @@ bool C4DImporter::CanRead( const std::string& pFile, IOSystem* /*pIOHandler*/, b
|
||||
} else if ((!extension.length() || checkSig) && pIOHandler) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1514,7 +1514,7 @@ void ColladaLoader::AddTexture(aiMaterial &mat,
|
||||
map = -1;
|
||||
for (std::string::const_iterator it = sampler.mUVChannel.begin(); it != sampler.mUVChannel.end(); ++it) {
|
||||
if (IsNumeric(*it)) {
|
||||
map = strtoul10(&(*it));
|
||||
map = strtoul10(&(*it));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -762,6 +762,7 @@ void ColladaParser::ReadControllerWeights(XmlNode &node, Collada::Controller &pC
|
||||
if (text == nullptr) {
|
||||
throw DeadlyImportError("Out of data while reading <vertex_weights>");
|
||||
}
|
||||
SkipSpacesAndLineEnd(&text);
|
||||
it->first = strtoul10(text, &text);
|
||||
SkipSpacesAndLineEnd(&text);
|
||||
if (*text == 0) {
|
||||
|
||||
@@ -371,7 +371,7 @@ void DXFImporter::ExpandBlockReferences(DXF::Block& bl,const DXF::BlockMap& bloc
|
||||
ASSIMP_LOG_ERROR("DXF: PolyLine instance is nullptr, skipping.");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<DXF::PolyLine> pl_out = std::shared_ptr<DXF::PolyLine>(new DXF::PolyLine(*pl_in));
|
||||
|
||||
if (bl_src.base.Length() || insert.scale.x!=1.f || insert.scale.y!=1.f || insert.scale.z!=1.f || insert.angle || insert.pos.Length()) {
|
||||
|
||||
@@ -1563,7 +1563,7 @@ void FBXConverter::ConvertWeights(aiMesh *out, const MeshGeometry &geo, const ai
|
||||
out->mBones = nullptr;
|
||||
out->mNumBones = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
out->mBones = new aiBone *[bones.size()]();
|
||||
out->mNumBones = static_cast<unsigned int>(bones.size());
|
||||
@@ -3228,7 +3228,7 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
|
||||
}
|
||||
|
||||
bool ok = false;
|
||||
|
||||
|
||||
const auto zero_epsilon = ai_epsilon;
|
||||
|
||||
const aiVector3D& preRotation = PropertyGet<aiVector3D>(props, "PreRotation", ok);
|
||||
|
||||
@@ -62,8 +62,7 @@ namespace Assimp {
|
||||
|
||||
template <>
|
||||
const char *LogFunctions<FBXImporter>::Prefix() {
|
||||
static auto prefix = "FBX: ";
|
||||
return prefix;
|
||||
return "FBX: ";
|
||||
}
|
||||
|
||||
} // namespace Assimp
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2022, assimp team
|
||||
|
||||
Copyright (c) 2006-2023, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -53,22 +52,26 @@ namespace Assimp {
|
||||
namespace FBX {
|
||||
|
||||
/**
|
||||
* DOM base class for all kinds of FBX geometry
|
||||
* @brief DOM base class for all kinds of FBX geometry
|
||||
*/
|
||||
class Geometry : public Object {
|
||||
public:
|
||||
/// @brief The class constructor with all parameters.
|
||||
/// @param id The id.
|
||||
/// @param element
|
||||
/// @param name
|
||||
/// @param doc
|
||||
/// @param element The element instance
|
||||
/// @param name The name instance
|
||||
/// @param doc The document instance
|
||||
Geometry( uint64_t id, const Element& element, const std::string& name, const Document& doc );
|
||||
|
||||
/// @brief The class destructor, default.
|
||||
virtual ~Geometry() = default;
|
||||
|
||||
/// Get the Skin attached to this geometry or nullptr
|
||||
/// @brief Get the Skin attached to this geometry or nullptr.
|
||||
/// @return The deformer skip instance as a pointer, nullptr if none.
|
||||
const Skin* DeformerSkin() const;
|
||||
|
||||
/// Get the BlendShape attached to this geometry or nullptr
|
||||
/// @brief Get the BlendShape attached to this geometry or nullptr
|
||||
/// @return The blendshape arrays.
|
||||
const std::vector<const BlendShape*>& GetBlendShapes() const;
|
||||
|
||||
private:
|
||||
@@ -78,59 +81,71 @@ private:
|
||||
|
||||
typedef std::vector<int> MatIndexArray;
|
||||
|
||||
|
||||
/**
|
||||
* DOM class for FBX geometry of type "Mesh"
|
||||
* @brief DOM class for FBX geometry of type "Mesh"
|
||||
*/
|
||||
class MeshGeometry : public Geometry {
|
||||
public:
|
||||
/** The class constructor */
|
||||
/// @brief The class constructor
|
||||
/// @param id The id.
|
||||
/// @param element The element instance
|
||||
/// @param name The name instance
|
||||
/// @param doc The document instance
|
||||
MeshGeometry( uint64_t id, const Element& element, const std::string& name, const Document& doc );
|
||||
|
||||
/** The class destructor */
|
||||
/// @brief The class destructor, default.
|
||||
virtual ~MeshGeometry() = default;
|
||||
|
||||
/** Get a list of all vertex points, non-unique*/
|
||||
/// brief Get a vector of all vertex points, non-unique.
|
||||
/// @return The vertices vector.
|
||||
const std::vector<aiVector3D>& GetVertices() const;
|
||||
|
||||
/** Get a list of all vertex normals or an empty array if
|
||||
* no normals are specified. */
|
||||
/// @brief Get a vector of all vertex normals or an empty array if no normals are specified.
|
||||
/// @return The normal vector.
|
||||
const std::vector<aiVector3D>& GetNormals() const;
|
||||
|
||||
/** Get a list of all vertex tangents or an empty array
|
||||
* if no tangents are specified */
|
||||
/// @brief Get a vector of all vertex tangents or an empty array if no tangents are specified.
|
||||
/// @return The vertex tangents vector.
|
||||
const std::vector<aiVector3D>& GetTangents() const;
|
||||
|
||||
/** Get a list of all vertex bi-normals or an empty array
|
||||
* if no bi-normals are specified */
|
||||
/// @brief Get a vector of all vertex bi-normals or an empty array if no bi-normals are specified.
|
||||
/// @return The binomal vector.
|
||||
const std::vector<aiVector3D>& GetBinormals() const;
|
||||
|
||||
/** Return list of faces - each entry denotes a face and specifies
|
||||
* how many vertices it has. Vertices are taken from the
|
||||
* vertex data arrays in sequential order. */
|
||||
/// @brief Return list of faces - each entry denotes a face and specifies how many vertices it has.
|
||||
/// Vertices are taken from the vertex data arrays in sequential order.
|
||||
/// @return The face indices vector.
|
||||
const std::vector<unsigned int>& GetFaceIndexCounts() const;
|
||||
|
||||
/** Get a UV coordinate slot, returns an empty array if
|
||||
* the requested slot does not exist. */
|
||||
/// @brief Get a UV coordinate slot, returns an empty array if the requested slot does not exist.
|
||||
/// @param index The requested texture coordinate slot.
|
||||
/// @return The texture coordinates.
|
||||
const std::vector<aiVector2D>& GetTextureCoords( unsigned int index ) const;
|
||||
|
||||
/** Get a UV coordinate slot, returns an empty array if
|
||||
* the requested slot does not exist. */
|
||||
/// @brief Get a UV coordinate slot, returns an empty array if the requested slot does not exist.
|
||||
/// @param index The requested texture coordinate slot.
|
||||
/// @return The texture coordinate channel name.
|
||||
std::string GetTextureCoordChannelName( unsigned int index ) const;
|
||||
|
||||
/** Get a vertex color coordinate slot, returns an empty array if
|
||||
* the requested slot does not exist. */
|
||||
/// @brief Get a vertex color coordinate slot, returns an empty array if the requested slot does not exist.
|
||||
/// @param index The requested texture coordinate slot.
|
||||
/// @return The vertex color vector.
|
||||
const std::vector<aiColor4D>& GetVertexColors( unsigned int index ) const;
|
||||
|
||||
/** Get per-face-vertex material assignments */
|
||||
/// @brief Get per-face-vertex material assignments.
|
||||
/// @return The Material indices Array.
|
||||
const MatIndexArray& GetMaterialIndices() const;
|
||||
|
||||
/** Convert from a fbx file vertex index (for example from a #Cluster weight) or nullptr
|
||||
* if the vertex index is not valid. */
|
||||
/// @brief Convert from a fbx file vertex index (for example from a #Cluster weight) or nullptr if the vertex index is not valid.
|
||||
/// @param in_index The requested input index.
|
||||
/// @param count The number of indices.
|
||||
/// @return The indices.
|
||||
const unsigned int* ToOutputVertexIndex( unsigned int in_index, unsigned int& count ) const;
|
||||
|
||||
/** Determine the face to which a particular output vertex index belongs.
|
||||
* This mapping is always unique. */
|
||||
/// @brief Determine the face to which a particular output vertex index belongs.
|
||||
/// This mapping is always unique.
|
||||
/// @param in_index The requested input index.
|
||||
/// @return The face-to-vertex index.
|
||||
unsigned int FaceForVertexIndex( unsigned int in_index ) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -187,7 +187,7 @@ Scope::Scope(Parser& parser,bool topLevel)
|
||||
if (str.empty()) {
|
||||
ParseError("unexpected content: empty string.");
|
||||
}
|
||||
|
||||
|
||||
elements.insert(ElementMap::value_type(str,new_Element(*n,parser)));
|
||||
|
||||
// Element() should stop at the next Key token (or right after a Close token)
|
||||
|
||||
@@ -327,7 +327,7 @@ void HMPImporter::CreateMaterial(const unsigned char *szCurrent,
|
||||
ReadFirstSkin(pcHeader->numskins, szCurrent, &szCurrent);
|
||||
*szCurrentOut = szCurrent;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// generate a default material
|
||||
const int iMode = (int)aiShadingMode_Gouraud;
|
||||
@@ -484,11 +484,11 @@ void HMPImporter::GenerateTextureCoords(const unsigned int width, const unsigned
|
||||
if (uv == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (height == 0.0f || width == 0.0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const float fY = (1.0f / height) + (1.0f / height) / height;
|
||||
const float fX = (1.0f / width) + (1.0f / width) / width;
|
||||
|
||||
|
||||
@@ -73,8 +73,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
namespace Assimp {
|
||||
template <>
|
||||
const char *LogFunctions<IFCImporter>::Prefix() {
|
||||
static auto prefix = "IFC: ";
|
||||
return prefix;
|
||||
return "IFC: ";
|
||||
}
|
||||
} // namespace Assimp
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ void AnimResolver::UpdateAnimRangeSetup() {
|
||||
if (delta == 0.0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
const size_t old_size = (*it).keys.size();
|
||||
const float value_delta = (*it).keys.back().value - (*it).keys.front().value;
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ void LWOImporter::InternReadFile(const std::string &pFile,
|
||||
} else {
|
||||
mIsLWO2 = true;
|
||||
}
|
||||
|
||||
|
||||
LoadLWO2File();
|
||||
|
||||
// The newer lightwave format allows the user to configure the
|
||||
|
||||
@@ -39,8 +39,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef ASSIMP_BUILD_NO_M3D_IMPORTER
|
||||
#if !(ASSIMP_BUILD_NO_EXPORT || ASSIMP_BUILD_NO_M3D_EXPORTER)
|
||||
#if !defined ASSIMP_BUILD_NO_M3D_IMPORTER || !(defined ASSIMP_BUILD_NO_EXPORT || defined ASSIMP_BUILD_NO_M3D_EXPORTER)
|
||||
|
||||
#include "M3DWrapper.h"
|
||||
|
||||
@@ -149,4 +148,3 @@ void M3DWrapper::ClearSave() {
|
||||
} // namespace Assimp
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -47,8 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef AI_M3DWRAPPER_H_INC
|
||||
#define AI_M3DWRAPPER_H_INC
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_M3D_IMPORTER
|
||||
#if !(ASSIMP_BUILD_NO_EXPORT || ASSIMP_BUILD_NO_M3D_EXPORTER)
|
||||
#if !defined ASSIMP_BUILD_NO_M3D_IMPORTER || !(defined ASSIMP_BUILD_NO_EXPORT || defined ASSIMP_BUILD_NO_M3D_EXPORTER)
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
@@ -126,7 +125,6 @@ inline m3d_t *M3DWrapper::M3D() const {
|
||||
|
||||
} // namespace Assimp
|
||||
|
||||
#endif
|
||||
#endif // ASSIMP_BUILD_NO_M3D_IMPORTER
|
||||
|
||||
#endif // AI_M3DWRAPPER_H_INC
|
||||
|
||||
@@ -394,7 +394,7 @@ private:
|
||||
|
||||
bool SkipLine(const char* in, const char** out);
|
||||
bool SkipLine( );
|
||||
bool SkipSpacesAndLineEnd( const char* in, const char** out);
|
||||
bool SkipSpacesAndLineEnd( const char* in, const char** out);
|
||||
bool SkipSpacesAndLineEnd();
|
||||
bool SkipSpaces();
|
||||
|
||||
|
||||
@@ -470,7 +470,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7(
|
||||
ASSIMP_LOG_ERROR("Found a reference to an embedded DDS texture, but texture width is zero, aborting import.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
pcNew.reset(new aiTexture);
|
||||
pcNew->mHeight = 0;
|
||||
pcNew->mWidth = iWidth;
|
||||
|
||||
@@ -107,7 +107,7 @@ private:
|
||||
|
||||
aiColor3D color, diffuse, specular, ambient, emissive;
|
||||
ai_real refracti;
|
||||
std::string texFile;
|
||||
std::string texFile;
|
||||
bool twoSided; // For NFF2
|
||||
bool shaded;
|
||||
ai_real opacity, shininess;
|
||||
|
||||
@@ -514,16 +514,16 @@ void ObjFileMtlImporter::getTextureOption(bool &clamp, int &clampIndex, aiString
|
||||
DataArrayIt it = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
|
||||
getFloat(it, m_DataItEnd, m_pModel->mCurrentMaterial->bump_multiplier);
|
||||
skipToken = 2;
|
||||
} else if (!ASSIMP_strincmp(pPtr, BlendUOption, static_cast<unsigned int>(strlen(BlendUOption))) ||
|
||||
} else if (!ASSIMP_strincmp(pPtr, BlendUOption, static_cast<unsigned int>(strlen(BlendUOption))) ||
|
||||
!ASSIMP_strincmp(pPtr, BlendVOption, static_cast<unsigned int>(strlen(BlendVOption))) ||
|
||||
!ASSIMP_strincmp(pPtr, BoostOption, static_cast<unsigned int>(strlen(BoostOption))) ||
|
||||
!ASSIMP_strincmp(pPtr, ResolutionOption, static_cast<unsigned int>(strlen(ResolutionOption))) ||
|
||||
!ASSIMP_strincmp(pPtr, BoostOption, static_cast<unsigned int>(strlen(BoostOption))) ||
|
||||
!ASSIMP_strincmp(pPtr, ResolutionOption, static_cast<unsigned int>(strlen(ResolutionOption))) ||
|
||||
!ASSIMP_strincmp(pPtr, ChannelOption, static_cast<unsigned int>(strlen(ChannelOption)))) {
|
||||
skipToken = 2;
|
||||
} else if (!ASSIMP_strincmp(pPtr, ModifyMapOption, static_cast<unsigned int>(strlen(ModifyMapOption)))) {
|
||||
skipToken = 3;
|
||||
} else if (!ASSIMP_strincmp(pPtr, OffsetOption, static_cast<unsigned int>(strlen(OffsetOption))) ||
|
||||
!ASSIMP_strincmp(pPtr, ScaleOption, static_cast<unsigned int>(strlen(ScaleOption))) ||
|
||||
} else if (!ASSIMP_strincmp(pPtr, OffsetOption, static_cast<unsigned int>(strlen(OffsetOption))) ||
|
||||
!ASSIMP_strincmp(pPtr, ScaleOption, static_cast<unsigned int>(strlen(ScaleOption))) ||
|
||||
!ASSIMP_strincmp(pPtr, TurbulenceOption, static_cast<unsigned int>(strlen(TurbulenceOption)))) {
|
||||
skipToken = 4;
|
||||
}
|
||||
|
||||
@@ -458,7 +458,7 @@ void ObjFileParser::getFace(aiPrimitiveType type) {
|
||||
//OBJ USES 1 Base ARRAYS!!!!
|
||||
const char *token = &(*m_DataIt);
|
||||
const int iVal = ::atoi(token);
|
||||
|
||||
|
||||
// increment iStep position based off of the sign and # of digits
|
||||
int tmp = iVal;
|
||||
if (iVal < 0) {
|
||||
|
||||
@@ -51,7 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Returns true, if the last entry of the buffer is reached.
|
||||
* @param[in] it Iterator of current position.
|
||||
* @param[in] end Iterator with end of buffer.
|
||||
@@ -67,7 +67,7 @@ inline bool isEndOfBuffer(char_t it, char_t end) {
|
||||
return (it == end);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Returns next word separated by a space
|
||||
* @param[in] pBuffer Pointer to data buffer
|
||||
* @param[in] pEnd Pointer to end of buffer
|
||||
@@ -85,7 +85,7 @@ inline Char_T getNextWord(Char_T pBuffer, Char_T pEnd) {
|
||||
return pBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Returns pointer a next token
|
||||
* @param[in] pBuffer Pointer to data buffer
|
||||
* @param[in] pEnd Pointer to end of buffer
|
||||
@@ -102,7 +102,7 @@ inline Char_T getNextToken(Char_T pBuffer, Char_T pEnd) {
|
||||
return getNextWord(pBuffer, pEnd);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Skips a line
|
||||
* @param[in] it Iterator set to current position
|
||||
* @param[in] end Iterator set to end of scratch buffer for readout
|
||||
@@ -131,7 +131,7 @@ inline char_t skipLine(char_t it, char_t end, unsigned int &uiLine) {
|
||||
return it;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Get a name from the current line. Preserve space in the middle,
|
||||
* but trim it at the end.
|
||||
* @param[in] it set to current position
|
||||
@@ -162,13 +162,13 @@ inline char_t getName(char_t it, char_t end, std::string &name) {
|
||||
std::string strName(pStart, &(*it));
|
||||
if (!strName.empty()) {
|
||||
name = strName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Get a name from the current line. Do not preserve space
|
||||
* in the middle, but trim it at the end.
|
||||
* @param it set to current position
|
||||
@@ -202,11 +202,11 @@ inline char_t getNameNoSpace(char_t it, char_t end, std::string &name) {
|
||||
if (!strName.empty()) {
|
||||
name = strName;
|
||||
}
|
||||
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Get next word from given line
|
||||
* @param[in] it set to current position
|
||||
* @param[in] end set to end of scratch buffer for readout
|
||||
@@ -230,7 +230,7 @@ inline char_t CopyNextWord(char_t it, char_t end, char *pBuffer, size_t length)
|
||||
return it;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Get next float from given line
|
||||
* @param[in] it set to current position
|
||||
* @param[in] end set to end of scratch buffer for readout
|
||||
|
||||
@@ -60,17 +60,17 @@ namespace Ogre {
|
||||
class OgreImporter : public BaseImporter {
|
||||
public:
|
||||
/// BaseImporter override.
|
||||
virtual bool CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const override;
|
||||
bool CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const override;
|
||||
|
||||
protected:
|
||||
/// BaseImporter override.
|
||||
virtual void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) override;
|
||||
void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) override;
|
||||
|
||||
/// BaseImporter override.
|
||||
virtual const aiImporterDesc *GetInfo() const override;
|
||||
const aiImporterDesc *GetInfo() const override;
|
||||
|
||||
/// BaseImporter override.
|
||||
virtual void SetupProperties(const Importer *pImp) override;
|
||||
void SetupProperties(const Importer *pImp) override;
|
||||
|
||||
private:
|
||||
/// Read materials referenced by the @c mesh to @c pScene.
|
||||
|
||||
@@ -87,7 +87,7 @@ SMDImporter::SMDImporter() :
|
||||
iFileSize( 0 ),
|
||||
iSmallestFrame( INT_MAX ),
|
||||
dLengthOfAnim( 0.0 ),
|
||||
bHasUVs(false ),
|
||||
bHasUVs(false ),
|
||||
iLineNumber((unsigned int)-1) {
|
||||
// empty
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ struct Face {
|
||||
iTexture(0x0) {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
//! Texture index for the face
|
||||
unsigned int iTexture;
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace STEP {
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
/** Exception class used by the STEP loading & parsing code. It is typically
|
||||
* coupled with a line number.
|
||||
* coupled with a line number.
|
||||
*/
|
||||
// -------------------------------------------------------------------------------
|
||||
struct SyntaxError : DeadlyImportError {
|
||||
@@ -230,7 +230,7 @@ private:
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
/** Shared implementation for some of the primitive data type, i.e. int, float
|
||||
/** Shared implementation for some of the primitive data type, i.e. int, float
|
||||
*/
|
||||
// -------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
@@ -278,7 +278,7 @@ public:
|
||||
typedef ENUMERATION BOOLEAN;
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
/** This is just a reference to an entity/object somewhere else
|
||||
/** This is just a reference to an entity/object somewhere else
|
||||
*/
|
||||
// -------------------------------------------------------------------------------
|
||||
class ENTITY : public PrimitiveDataType<uint64_t> {
|
||||
@@ -302,7 +302,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
/** @see DaraType::Parse
|
||||
/** @see DaraType::Parse
|
||||
*/
|
||||
static std::shared_ptr<const EXPRESS::LIST> Parse(const char *&inout,
|
||||
uint64_t line = SyntaxError::LINE_NOT_SPECIFIED,
|
||||
@@ -322,7 +322,7 @@ public:
|
||||
// -------------------------------------------------------------------------------
|
||||
/* Not exactly a full EXPRESS schema but rather a list of conversion functions
|
||||
* to extract valid C++ objects out of a STEP file. Those conversion functions
|
||||
* may, however, perform further schema validations.
|
||||
* may, however, perform further schema validations.
|
||||
*/
|
||||
// -------------------------------------------------------------------------------
|
||||
class ConversionSchema {
|
||||
@@ -384,7 +384,7 @@ struct HeaderInfo {
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
/** Base class for all concrete object instances
|
||||
/** Base class for all concrete object instances
|
||||
*/
|
||||
// ------------------------------------------------------------------------------
|
||||
class Object {
|
||||
@@ -511,7 +511,7 @@ private:
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
/** A LazyObject is created when needed. Before this happens, we just keep
|
||||
* the text line that contains the object definition.
|
||||
* the text line that contains the object definition.
|
||||
*/
|
||||
// -------------------------------------------------------------------------------
|
||||
class LazyObject {
|
||||
|
||||
@@ -183,7 +183,7 @@ XFileParser::XFileParser(const std::vector<char> &pBuffer) :
|
||||
P1 += ofs;
|
||||
est_out += MSZIP_BLOCK; // one decompressed block is 327861 in size
|
||||
}
|
||||
|
||||
|
||||
// Allocate storage and terminating zero and do the actual uncompressing
|
||||
Compression compression;
|
||||
uncompressed.resize(est_out + 1);
|
||||
|
||||
@@ -471,7 +471,7 @@ void X3DImporter::ParseHelper_Node_Enter(X3DNodeElementBase *pNode) {
|
||||
|
||||
mNodeElementCur->Children.push_back(pNode); // add new element to current element child list.
|
||||
mNodeElementCur = pNode; // switch current element to new one.
|
||||
}
|
||||
}
|
||||
|
||||
void X3DImporter::ParseHelper_Node_Exit() {
|
||||
// check if we can walk up.
|
||||
|
||||
@@ -263,7 +263,7 @@ void X3DImporter::readDisk2D(XmlNode &node) {
|
||||
//
|
||||
if (tlist_i.size() < 2) {
|
||||
// tlist_i and tlist_o has equal size.
|
||||
throw DeadlyImportError("Disk2D. Not enough points for creating quad list.");
|
||||
throw DeadlyImportError("Disk2D. Not enough points for creating quad list.");
|
||||
}
|
||||
|
||||
// add all quads except last
|
||||
|
||||
@@ -65,8 +65,7 @@ namespace Assimp { // this has to be in here because LogFunctions is in ::Assimp
|
||||
|
||||
template <>
|
||||
const char *LogFunctions<XGLImporter>::Prefix() {
|
||||
static auto prefix = "XGL: ";
|
||||
return prefix;
|
||||
return "XGL: ";
|
||||
}
|
||||
|
||||
} // namespace Assimp
|
||||
|
||||
@@ -260,7 +260,7 @@ public:
|
||||
VEC4,
|
||||
MAT2,
|
||||
MAT3,
|
||||
MAT4
|
||||
MAT4
|
||||
};
|
||||
|
||||
inline static Value FromString(const char *str) {
|
||||
@@ -288,8 +288,8 @@ private:
|
||||
};
|
||||
|
||||
template <int N>
|
||||
struct data {
|
||||
static const Info infos[NUM_VALUES];
|
||||
struct data {
|
||||
static const Info infos[NUM_VALUES];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -297,11 +297,11 @@ private:
|
||||
template <int N>
|
||||
const AttribType::Info AttribType::data<N>::infos[AttribType::NUM_VALUES] = {
|
||||
{ "SCALAR", 1 },
|
||||
{ "VEC2", 2 },
|
||||
{ "VEC3", 3 },
|
||||
{ "VEC4", 4 },
|
||||
{ "MAT2", 4 },
|
||||
{ "MAT3", 9 },
|
||||
{ "VEC2", 2 },
|
||||
{ "VEC3", 3 },
|
||||
{ "VEC4", 4 },
|
||||
{ "MAT2", 4 },
|
||||
{ "MAT3", 9 },
|
||||
{ "MAT4", 16 }
|
||||
};
|
||||
|
||||
|
||||
@@ -322,7 +322,7 @@ void glTFExporter::GetTexSampler(const aiMaterial* mat, glTF::TexProperty& prop)
|
||||
prop.texture->sampler->minFilter = SamplerMinFilter_Linear;
|
||||
}
|
||||
|
||||
void glTFExporter::GetMatColorOrTex(const aiMaterial* mat, glTF::TexProperty& prop,
|
||||
void glTFExporter::GetMatColorOrTex(const aiMaterial* mat, glTF::TexProperty& prop,
|
||||
const char* propName, int type, int idx, aiTextureType tt) {
|
||||
aiString tex;
|
||||
aiColor4D col;
|
||||
@@ -370,9 +370,9 @@ void glTFExporter::GetMatColorOrTex(const aiMaterial* mat, glTF::TexProperty& pr
|
||||
}
|
||||
|
||||
if (mat->Get(propName, type, idx, col) == AI_SUCCESS) {
|
||||
prop.color[0] = col.r;
|
||||
prop.color[0] = col.r;
|
||||
prop.color[1] = col.g;
|
||||
prop.color[2] = col.b;
|
||||
prop.color[2] = col.b;
|
||||
prop.color[3] = col.a;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1113,13 +1113,13 @@ public:
|
||||
bool KHR_texture_basisu;
|
||||
|
||||
Extensions() :
|
||||
KHR_materials_pbrSpecularGlossiness(false),
|
||||
KHR_materials_unlit(false),
|
||||
KHR_lights_punctual(false),
|
||||
KHR_texture_transform(false),
|
||||
KHR_materials_sheen(false),
|
||||
KHR_materials_clearcoat(false),
|
||||
KHR_materials_transmission(false),
|
||||
KHR_materials_pbrSpecularGlossiness(false),
|
||||
KHR_materials_unlit(false),
|
||||
KHR_lights_punctual(false),
|
||||
KHR_texture_transform(false),
|
||||
KHR_materials_sheen(false),
|
||||
KHR_materials_clearcoat(false),
|
||||
KHR_materials_transmission(false),
|
||||
KHR_materials_volume(false),
|
||||
KHR_materials_ior(false),
|
||||
KHR_materials_emissive_strength(false),
|
||||
|
||||
@@ -1903,7 +1903,7 @@ inline void Asset::Load(const std::string &pFile, bool isBinary)
|
||||
std::vector<char> sceneData;
|
||||
rapidjson::Document doc = ReadDocument(*stream, isBinary, sceneData);
|
||||
|
||||
// If a schemaDocumentProvider is available, see if the glTF schema is present.
|
||||
// If a schemaDocumentProvider is available, see if the glTF schema is present.
|
||||
// If so, use it to validate the document.
|
||||
if (mSchemaDocumentProvider) {
|
||||
if (const rapidjson::SchemaDocument *gltfSchema = mSchemaDocumentProvider->GetRemoteDocument("glTF.schema.json", 16)) {
|
||||
|
||||
@@ -516,7 +516,7 @@ void glTF2Exporter::GetMatTex(const aiMaterial &mat, Ref<Texture> &texture, unsi
|
||||
if (mat.GetTextureCount(tt) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
aiString tex;
|
||||
|
||||
// Read texcoord (UV map index)
|
||||
@@ -855,13 +855,13 @@ void glTF2Exporter::ExportMaterials() {
|
||||
mAsset->extensionsUsed.KHR_materials_transmission = true;
|
||||
m->materialTransmission = Nullable<MaterialTransmission>(transmission);
|
||||
}
|
||||
|
||||
|
||||
MaterialVolume volume;
|
||||
if (GetMatVolume(mat, volume)) {
|
||||
mAsset->extensionsUsed.KHR_materials_volume = true;
|
||||
m->materialVolume = Nullable<MaterialVolume>(volume);
|
||||
}
|
||||
|
||||
|
||||
MaterialIOR ior;
|
||||
if (GetMatIOR(mat, ior)) {
|
||||
mAsset->extensionsUsed.KHR_materials_ior = true;
|
||||
@@ -921,7 +921,7 @@ Ref<Node> FindSkeletonRootJoint(Ref<Skin> &skinRef) {
|
||||
return parentNodeRef;
|
||||
}
|
||||
|
||||
void ExportSkin(Asset &mAsset, const aiMesh *aimesh, Ref<Mesh> &meshRef, Ref<Buffer> &bufferRef, Ref<Skin> &skinRef,
|
||||
void ExportSkin(Asset &mAsset, const aiMesh *aimesh, Ref<Mesh> &meshRef, Ref<Buffer> &bufferRef, Ref<Skin> &skinRef,
|
||||
std::vector<aiMatrix4x4> &inverseBindMatricesData) {
|
||||
if (aimesh->mNumBones < 1) {
|
||||
return;
|
||||
@@ -985,14 +985,14 @@ void ExportSkin(Asset &mAsset, const aiMesh *aimesh, Ref<Mesh> &meshRef, Ref<Buf
|
||||
vertexJointData[vertexId][jointsPerVertex[vertexId]] = static_cast<float>(jointNamesIndex);
|
||||
vertexWeightData[vertexId][jointsPerVertex[vertexId]] = vertWeight;
|
||||
|
||||
jointsPerVertex[vertexId] += 1;
|
||||
jointsPerVertex[vertexId] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
} // End: for-loop mNumMeshes
|
||||
|
||||
Mesh::Primitive &p = meshRef->primitives.back();
|
||||
Ref<Accessor> vertexJointAccessor = ExportData(mAsset, skinRef->id, bufferRef, aimesh->mNumVertices,
|
||||
Ref<Accessor> vertexJointAccessor = ExportData(mAsset, skinRef->id, bufferRef, aimesh->mNumVertices,
|
||||
vertexJointData, AttribType::VEC4, AttribType::VEC4, ComponentType_FLOAT);
|
||||
if (vertexJointAccessor) {
|
||||
size_t offset = vertexJointAccessor->bufferView->byteOffset;
|
||||
@@ -1090,7 +1090,7 @@ void glTF2Exporter::ExportMeshes() {
|
||||
}
|
||||
}
|
||||
|
||||
Ref<Accessor> n = ExportData(*mAsset, meshId, b, aim->mNumVertices, aim->mNormals, AttribType::VEC3,
|
||||
Ref<Accessor> n = ExportData(*mAsset, meshId, b, aim->mNumVertices, aim->mNormals, AttribType::VEC3,
|
||||
AttribType::VEC3, ComponentType_FLOAT, BufferViewTarget_ARRAY_BUFFER);
|
||||
if (n) {
|
||||
p.attributes.normal.push_back(n);
|
||||
@@ -1112,7 +1112,7 @@ void glTF2Exporter::ExportMeshes() {
|
||||
if (aim->mNumUVComponents[i] > 0) {
|
||||
AttribType::Value type = (aim->mNumUVComponents[i] == 2) ? AttribType::VEC2 : AttribType::VEC3;
|
||||
|
||||
Ref<Accessor> tc = ExportData(*mAsset, meshId, b, aim->mNumVertices, aim->mTextureCoords[i],
|
||||
Ref<Accessor> tc = ExportData(*mAsset, meshId, b, aim->mNumVertices, aim->mTextureCoords[i],
|
||||
AttribType::VEC3, type, ComponentType_FLOAT, BufferViewTarget_ARRAY_BUFFER);
|
||||
if (tc) {
|
||||
p.attributes.texcoord.push_back(tc);
|
||||
@@ -1140,7 +1140,7 @@ void glTF2Exporter::ExportMeshes() {
|
||||
}
|
||||
}
|
||||
|
||||
p.indices = ExportData(*mAsset, meshId, b, indices.size(), &indices[0], AttribType::SCALAR, AttribType::SCALAR,
|
||||
p.indices = ExportData(*mAsset, meshId, b, indices.size(), &indices[0], AttribType::SCALAR, AttribType::SCALAR,
|
||||
ComponentType_UNSIGNED_INT, BufferViewTarget_ELEMENT_ARRAY_BUFFER);
|
||||
}
|
||||
|
||||
|
||||
@@ -182,7 +182,6 @@ static void SetMaterialTextureProperty(std::vector<int> &embeddedTexIdxs, Asset
|
||||
const ai_real rsin(sin(-transform.mRotation));
|
||||
transform.mTranslation.x = (static_cast<ai_real>(0.5) * transform.mScaling.x) * (-rcos + rsin + 1) + prop.TextureTransformExt_t.offset[0];
|
||||
transform.mTranslation.y = ((static_cast<ai_real>(0.5) * transform.mScaling.y) * (rsin + rcos - 1)) + 1 - transform.mScaling.y - prop.TextureTransformExt_t.offset[1];
|
||||
;
|
||||
|
||||
mat->AddProperty(&transform, 1, _AI_MATKEY_UVTRANSFORM_BASE, texType, texSlot);
|
||||
}
|
||||
@@ -850,7 +849,7 @@ void glTF2Importer::ImportCameras(glTF2::Asset &r) {
|
||||
|
||||
if (cam.type == Camera::Perspective) {
|
||||
aicam->mAspect = cam.cameraProperties.perspective.aspectRatio;
|
||||
aicam->mHorizontalFOV = cam.cameraProperties.perspective.yfov * ((aicam->mAspect == 0.f) ? 1.f : aicam->mAspect);
|
||||
aicam->mHorizontalFOV = 2.0f * std::atan(std::tan(cam.cameraProperties.perspective.yfov * 0.5f) * ((aicam->mAspect == 0.f) ? 1.f : aicam->mAspect));
|
||||
aicam->mClipPlaneFar = cam.cameraProperties.perspective.zfar;
|
||||
aicam->mClipPlaneNear = cam.cameraProperties.perspective.znear;
|
||||
} else {
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
protected:
|
||||
const aiImporterDesc *GetInfo() const override;
|
||||
void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) override;
|
||||
virtual void SetupProperties(const Importer *pImp) override;
|
||||
void SetupProperties(const Importer *pImp) override;
|
||||
|
||||
private:
|
||||
void ImportEmbeddedTextures(glTF2::Asset &a);
|
||||
|
||||
@@ -247,7 +247,7 @@ void BaseImporter::GetExtensionList(std::set<std::string> &extensions) {
|
||||
}
|
||||
|
||||
if (ext2 && !ASSIMP_stricmp(ext_real, ext2)) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -1118,7 +1118,7 @@ bool Importer::SetPropertyMatrix(const char* szName, const aiMatrix4x4& value) {
|
||||
// Set a configuration property
|
||||
bool Importer::SetPropertyPointer(const char* szName, void* value) {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
|
||||
bool existing;
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
existing = SetGenericProperty<void*>(pimpl->mPointerProperties, szName,value);
|
||||
@@ -1162,7 +1162,7 @@ aiMatrix4x4 Importer::GetPropertyMatrix(const char* szName, const aiMatrix4x4& i
|
||||
// Get a configuration property
|
||||
void* Importer::GetPropertyPointer(const char* szName, void* iErrorReturn /*= nullptr*/) const {
|
||||
ai_assert(nullptr != pimpl);
|
||||
|
||||
|
||||
return GetGenericProperty<void*>(pimpl->mPointerProperties,szName,iErrorReturn);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ inline bool PointInTriangle2D(const T& p0, const T& p1,const T& p2, const T& pp)
|
||||
if (denom == 0.0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
const double invDenom = 1.0 / denom;
|
||||
dot11 = (dot11 * dot02 - dot01 * dot12) * invDenom;
|
||||
dot00 = (dot00 * dot12 - dot01 * dot02) * invDenom;
|
||||
|
||||
@@ -39,7 +39,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
/**
|
||||
* @file RemoveComments.cpp
|
||||
* @brief Defines the CommentRemover utility class
|
||||
*/
|
||||
|
||||
@@ -106,7 +106,7 @@ void ScenePreprocessor::ProcessMesh(aiMesh *mesh) {
|
||||
if (!mesh->mTextureCoords[i]) {
|
||||
mesh->mNumUVComponents[i] = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mesh->mNumUVComponents[i]) {
|
||||
mesh->mNumUVComponents[i] = 2;
|
||||
|
||||
@@ -94,7 +94,7 @@ ai_real SpatialSort::CalculateDistance(const aiVector3D &pPosition) const {
|
||||
void SpatialSort::Finalize() {
|
||||
const ai_real scale = 1.0f / mPositions.size();
|
||||
for (unsigned int i = 0; i < mPositions.size(); i++) {
|
||||
mCentroid += scale * mPositions[i].mPosition;
|
||||
mCentroid += scale * mPositions[i].mPosition;
|
||||
}
|
||||
for (unsigned int i = 0; i < mPositions.size(); i++) {
|
||||
mPositions[i].mDistance = CalculateDistance(mPositions[i].mPosition);
|
||||
|
||||
@@ -185,6 +185,6 @@ ASSIMP_API aiScene::~aiScene() {
|
||||
aiMetadata::Dealloc(mMetaData);
|
||||
|
||||
delete[] mSkeletons;
|
||||
|
||||
|
||||
delete static_cast<Assimp::ScenePrivateData *>(mPrivate);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ void JoinVerticesProcess::Execute( aiScene* pScene) {
|
||||
ASSIMP_LOG_DEBUG("JoinVerticesProcess finished ");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Show statistics
|
||||
ASSIMP_LOG_INFO("JoinVerticesProcess finished | Verts in: ", iNumOldVertices,
|
||||
" out: ", iNumVertices, " | ~",
|
||||
@@ -105,7 +105,11 @@ void JoinVerticesProcess::Execute( aiScene* pScene) {
|
||||
|
||||
namespace {
|
||||
|
||||
bool areVerticesEqual(const Vertex &lhs, const Vertex &rhs, bool complex) {
|
||||
bool areVerticesEqual(
|
||||
const Vertex &lhs,
|
||||
const Vertex &rhs,
|
||||
unsigned numUVChannels,
|
||||
unsigned numColorChannels) {
|
||||
// A little helper to find locally close vertices faster.
|
||||
// Try to reuse the lookup table from the last step.
|
||||
const static float epsilon = 1e-5f;
|
||||
@@ -124,10 +128,6 @@ bool areVerticesEqual(const Vertex &lhs, const Vertex &rhs, bool complex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((lhs.texcoords[0] - rhs.texcoords[0]).SquareLength() > squareEpsilon) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((lhs.tangent - rhs.tangent).SquareLength() > squareEpsilon) {
|
||||
return false;
|
||||
}
|
||||
@@ -136,19 +136,18 @@ bool areVerticesEqual(const Vertex &lhs, const Vertex &rhs, bool complex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Usually we won't have vertex colors or multiple UVs, so we can skip from here
|
||||
// Actually this increases runtime performance slightly, at least if branch
|
||||
// prediction is on our side.
|
||||
if (complex) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (i > 0 && (lhs.texcoords[i] - rhs.texcoords[i]).SquareLength() > squareEpsilon) {
|
||||
return false;
|
||||
}
|
||||
if (GetColorDifference(lhs.colors[i], rhs.colors[i]) > squareEpsilon) {
|
||||
return false;
|
||||
}
|
||||
for (unsigned i = 0; i < numUVChannels; i++) {
|
||||
if ((lhs.texcoords[i] - rhs.texcoords[i]).SquareLength() > squareEpsilon) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < numColorChannels; i++) {
|
||||
if (GetColorDifference(lhs.colors[i], rhs.colors[i]) > squareEpsilon) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -235,15 +234,22 @@ struct std::hash<Vertex> {
|
||||
std::size_t operator()(Vertex const& v) const noexcept {
|
||||
size_t seed = 0;
|
||||
hash_combine(seed, v.position.x ,v.position.y,v.position.z);
|
||||
return seed;
|
||||
return seed;
|
||||
}
|
||||
};
|
||||
//template specialization for std::equal_to for Vertex
|
||||
template<>
|
||||
struct std::equal_to<Vertex> {
|
||||
equal_to(unsigned numUVChannels, unsigned numColorChannels) :
|
||||
mNumUVChannels(numUVChannels),
|
||||
mNumColorChannels(numColorChannels) {}
|
||||
bool operator()(const Vertex &lhs, const Vertex &rhs) const {
|
||||
return areVerticesEqual(lhs, rhs, false);
|
||||
return areVerticesEqual(lhs, rhs, mNumUVChannels, mNumColorChannels);
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned mNumUVChannels;
|
||||
unsigned mNumColorChannels;
|
||||
};
|
||||
// now start the JoinVerticesProcess
|
||||
int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) {
|
||||
@@ -316,8 +322,13 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) {
|
||||
uniqueAnimatedVertices[animMeshIndex].reserve(pMesh->mNumVertices);
|
||||
}
|
||||
}
|
||||
// a map that maps a vertix to its new index
|
||||
std::unordered_map<Vertex,int> vertex2Index;
|
||||
// a map that maps a vertex to its new index
|
||||
const auto numBuckets = pMesh->mNumVertices;
|
||||
const auto hasher = std::hash<Vertex>();
|
||||
const auto comparator = std::equal_to<Vertex>(
|
||||
pMesh->GetNumUVChannels(),
|
||||
pMesh->GetNumColorChannels());
|
||||
std::unordered_map<Vertex, int> vertex2Index(numBuckets, hasher, comparator);
|
||||
// we can not end up with more vertices than we started with
|
||||
vertex2Index.reserve(pMesh->mNumVertices);
|
||||
// Now check each vertex if it brings something new to the table
|
||||
@@ -399,7 +410,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) {
|
||||
}
|
||||
if (weightAlreadyExists) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
aiVertexWeight nw;
|
||||
nw.mVertexId = replaceIndex[ ow.mVertexId ];
|
||||
nw.mWeight = ow.mWeight;
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2022, assimp team
|
||||
|
||||
Copyright (c) 2006-2023, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -36,13 +35,7 @@ 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** Implementation of the LimitBoneWeightsProcess post processing step */
|
||||
|
||||
|
||||
---------------------------------------------------------------------- */
|
||||
#include "LimitBoneWeightsProcess.h"
|
||||
#include <assimp/SmallVector.h>
|
||||
#include <assimp/StringUtils.h>
|
||||
@@ -51,14 +44,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <assimp/scene.h>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace Assimp;
|
||||
namespace Assimp {
|
||||
|
||||
// Make sure this value is set.
|
||||
#ifndef AI_LMW_MAX_WEIGHTS
|
||||
# define AI_LMW_MAX_WEIGHTS 16
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
LimitBoneWeightsProcess::LimitBoneWeightsProcess()
|
||||
{
|
||||
mMaxWeights = AI_LMW_MAX_WEIGHTS;
|
||||
}
|
||||
LimitBoneWeightsProcess::LimitBoneWeightsProcess() : mMaxWeights(AI_LMW_MAX_WEIGHTS) {}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor, private as well
|
||||
@@ -66,15 +61,15 @@ LimitBoneWeightsProcess::~LimitBoneWeightsProcess() = default;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the processing step is present in the given flag field.
|
||||
bool LimitBoneWeightsProcess::IsActive( unsigned int pFlags) const
|
||||
{
|
||||
bool LimitBoneWeightsProcess::IsActive( unsigned int pFlags) const {
|
||||
return (pFlags & aiProcess_LimitBoneWeights) != 0;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Executes the post processing step on the given imported data.
|
||||
void LimitBoneWeightsProcess::Execute( aiScene* pScene)
|
||||
{
|
||||
void LimitBoneWeightsProcess::Execute( aiScene* pScene) {
|
||||
ai_assert(pScene != nullptr);
|
||||
|
||||
ASSIMP_LOG_DEBUG("LimitBoneWeightsProcess begin");
|
||||
|
||||
for (unsigned int m = 0; m < pScene->mNumMeshes; ++m) {
|
||||
@@ -86,16 +81,30 @@ void LimitBoneWeightsProcess::Execute( aiScene* pScene)
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Executes the post processing step on the given imported data.
|
||||
void LimitBoneWeightsProcess::SetupProperties(const Importer* pImp)
|
||||
{
|
||||
// get the current value of the property
|
||||
void LimitBoneWeightsProcess::SetupProperties(const Importer* pImp) {
|
||||
this->mMaxWeights = pImp->GetPropertyInteger(AI_CONFIG_PP_LBW_MAX_WEIGHTS,AI_LMW_MAX_WEIGHTS);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static unsigned int removeEmptyBones(aiMesh *pMesh) {
|
||||
ai_assert(pMesh != nullptr);
|
||||
|
||||
unsigned int writeBone = 0;
|
||||
for (unsigned int readBone = 0; readBone< pMesh->mNumBones; ++readBone) {
|
||||
aiBone* bone = pMesh->mBones[readBone];
|
||||
if (bone->mNumWeights > 0) {
|
||||
pMesh->mBones[writeBone++] = bone;
|
||||
} else {
|
||||
delete bone;
|
||||
}
|
||||
}
|
||||
|
||||
return writeBone;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Unites identical vertices in the given mesh
|
||||
void LimitBoneWeightsProcess::ProcessMesh(aiMesh* pMesh)
|
||||
{
|
||||
void LimitBoneWeightsProcess::ProcessMesh(aiMesh* pMesh) {
|
||||
if (!pMesh->HasBones())
|
||||
return;
|
||||
|
||||
@@ -105,11 +114,9 @@ void LimitBoneWeightsProcess::ProcessMesh(aiMesh* pMesh)
|
||||
WeightsPerVertex vertexWeights(pMesh->mNumVertices);
|
||||
size_t maxVertexWeights = 0;
|
||||
|
||||
for (unsigned int b = 0; b < pMesh->mNumBones; ++b)
|
||||
{
|
||||
for (unsigned int b = 0; b < pMesh->mNumBones; ++b) {
|
||||
const aiBone* bone = pMesh->mBones[b];
|
||||
for (unsigned int w = 0; w < bone->mNumWeights; ++w)
|
||||
{
|
||||
for (unsigned int w = 0; w < bone->mNumWeights; ++w) {
|
||||
const aiVertexWeight& vw = bone->mWeights[w];
|
||||
|
||||
if (vertexWeights.size() <= vw.mVertexId)
|
||||
@@ -126,8 +133,7 @@ void LimitBoneWeightsProcess::ProcessMesh(aiMesh* pMesh)
|
||||
unsigned int removed = 0, old_bones = pMesh->mNumBones;
|
||||
|
||||
// now cut the weight count if it exceeds the maximum
|
||||
for (WeightsPerVertex::iterator vit = vertexWeights.begin(); vit != vertexWeights.end(); ++vit)
|
||||
{
|
||||
for (WeightsPerVertex::iterator vit = vertexWeights.begin(); vit != vertexWeights.end(); ++vit) {
|
||||
if (vit->size() <= mMaxWeights)
|
||||
continue;
|
||||
|
||||
@@ -154,40 +160,27 @@ void LimitBoneWeightsProcess::ProcessMesh(aiMesh* pMesh)
|
||||
}
|
||||
|
||||
// clear weight count for all bone
|
||||
for (unsigned int a = 0; a < pMesh->mNumBones; ++a)
|
||||
{
|
||||
for (unsigned int a = 0; a < pMesh->mNumBones; ++a) {
|
||||
pMesh->mBones[a]->mNumWeights = 0;
|
||||
}
|
||||
|
||||
// rebuild the vertex weight array for all bones
|
||||
for (unsigned int a = 0; a < vertexWeights.size(); ++a)
|
||||
{
|
||||
for (unsigned int a = 0; a < vertexWeights.size(); ++a) {
|
||||
const VertexWeightArray& vw = vertexWeights[a];
|
||||
for (const Weight* it = vw.begin(); it != vw.end(); ++it)
|
||||
{
|
||||
for (const Weight* it = vw.begin(); it != vw.end(); ++it) {
|
||||
aiBone* bone = pMesh->mBones[it->mBone];
|
||||
bone->mWeights[bone->mNumWeights++] = aiVertexWeight(a, it->mWeight);
|
||||
}
|
||||
}
|
||||
|
||||
// remove empty bones
|
||||
unsigned int writeBone = 0;
|
||||
|
||||
for (unsigned int readBone = 0; readBone< pMesh->mNumBones; ++readBone)
|
||||
{
|
||||
aiBone* bone = pMesh->mBones[readBone];
|
||||
if (bone->mNumWeights > 0)
|
||||
{
|
||||
pMesh->mBones[writeBone++] = bone;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete bone;
|
||||
}
|
||||
}
|
||||
pMesh->mNumBones = writeBone;
|
||||
#ifdef AI_CONFIG_IMPORT_REMOVE_EMPTY_BONES
|
||||
pMesh->mNumBones = removeEmptyBones(pMesh);
|
||||
#endif // AI_CONFIG_IMPORT_REMOVE_EMPTY_BONES
|
||||
|
||||
if (!DefaultLogger::isNullLogger()) {
|
||||
ASSIMP_LOG_INFO("Removed ", removed, " weights. Input bones: ", old_bones, ". Output bones: ", pMesh->mNumBones);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Assimp
|
||||
|
||||
Reference in New Issue
Block a user