(reader.GetI1());
@@ -1170,13 +1175,13 @@ void COBImporter::ReadUnit_Binary(COB::Scene &out, StreamReaderLE &reader, const
if (nd->id == nfo.parent_id) {
const unsigned int t = reader.GetI2();
nd->unit_scale = t >= sizeof(units) / sizeof(units[0]) ? (
- ASSIMP_LOG_WARN_F(t, " is not a valid value for `Units` attribute in `Unit chunk` ", nfo.id), 1.f) :
+ ASSIMP_LOG_WARN(t, " is not a valid value for `Units` attribute in `Unit chunk` ", nfo.id), 1.f) :
units[t];
return;
}
}
- ASSIMP_LOG_WARN_F("`Unit` chunk ", nfo.id, " is a child of ", nfo.parent_id, " which does not exist");
+ ASSIMP_LOG_WARN("`Unit` chunk ", nfo.id, " is a child of ", nfo.parent_id, " which does not exist");
}
#endif // ASSIMP_BUILD_NO_COB_IMPORTER
diff --git a/code/AssetLib/Collada/ColladaLoader.cpp b/code/AssetLib/Collada/ColladaLoader.cpp
index 902eebc4b..492e6971f 100644
--- a/code/AssetLib/Collada/ColladaLoader.cpp
+++ b/code/AssetLib/Collada/ColladaLoader.cpp
@@ -75,7 +75,7 @@ static const aiImporterDesc desc = {
3,
1,
5,
- "dae zae"
+ "dae xml zae"
};
static const float kMillisecondsFromSeconds = 1000.f;
@@ -317,7 +317,7 @@ void ColladaLoader::ResolveNodeInstances(const ColladaParser &pParser, const Nod
nd = FindNode(pParser.mRootNode, nodeInst.mNode);
}
if (nullptr == nd) {
- ASSIMP_LOG_ERROR_F("Collada: Unable to resolve reference to instanced node ", nodeInst.mNode);
+ ASSIMP_LOG_ERROR("Collada: Unable to resolve reference to instanced node ", nodeInst.mNode);
} else {
// attach this node to the list of children
resolved.push_back(nd);
@@ -347,7 +347,7 @@ void ColladaLoader::BuildLightsForNode(const ColladaParser &pParser, const Node
// find the referred light
ColladaParser::LightLibrary::const_iterator srcLightIt = pParser.mLightLibrary.find(lid.mLight);
if (srcLightIt == pParser.mLightLibrary.end()) {
- ASSIMP_LOG_WARN_F("Collada: Unable to find light for ID \"", lid.mLight, "\". Skipping.");
+ ASSIMP_LOG_WARN("Collada: Unable to find light for ID \"", lid.mLight, "\". Skipping.");
continue;
}
const Collada::Light *srcLight = &srcLightIt->second;
@@ -412,7 +412,7 @@ void ColladaLoader::BuildCamerasForNode(const ColladaParser &pParser, const Node
// find the referred light
ColladaParser::CameraLibrary::const_iterator srcCameraIt = pParser.mCameraLibrary.find(cid.mCamera);
if (srcCameraIt == pParser.mCameraLibrary.end()) {
- ASSIMP_LOG_WARN_F("Collada: Unable to find camera for ID \"", cid.mCamera, "\". Skipping.");
+ ASSIMP_LOG_WARN("Collada: Unable to find camera for ID \"", cid.mCamera, "\". Skipping.");
continue;
}
const Collada::Camera *srcCamera = &srcCameraIt->second;
@@ -486,7 +486,7 @@ void ColladaLoader::BuildMeshesForNode(const ColladaParser &pParser, const Node
}
if (nullptr == srcMesh) {
- ASSIMP_LOG_WARN_F("Collada: Unable to find geometry for ID \"", mid.mMeshOrController, "\". Skipping.");
+ ASSIMP_LOG_WARN("Collada: Unable to find geometry for ID \"", mid.mMeshOrController, "\". Skipping.");
continue;
}
} else {
@@ -511,7 +511,7 @@ void ColladaLoader::BuildMeshesForNode(const ColladaParser &pParser, const Node
table = &meshMatIt->second;
meshMaterial = table->mMatName;
} else {
- ASSIMP_LOG_WARN_F("Collada: No material specified for subgroup <", submesh.mMaterial, "> in geometry <",
+ ASSIMP_LOG_WARN("Collada: No material specified for subgroup <", submesh.mMaterial, "> in geometry <",
mid.mMeshOrController, ">.");
if (!mid.mMaterials.empty()) {
meshMaterial = mid.mMaterials.begin()->second.mMatName;
@@ -883,7 +883,7 @@ aiMesh *ColladaLoader::CreateMesh(const ColladaParser &pParser, const Mesh *pSrc
if (nullptr != bnode) {
bone->mName.Set(FindNameForNode(bnode));
} else {
- ASSIMP_LOG_WARN_F("ColladaLoader::CreateMesh(): could not find corresponding node for joint \"", bone->mName.data, "\".");
+ ASSIMP_LOG_WARN("ColladaLoader::CreateMesh(): could not find corresponding node for joint \"", bone->mName.data, "\".");
}
// and insert bone
@@ -1184,7 +1184,7 @@ void ColladaLoader::CreateAnimation(aiScene *pScene, const ColladaParser &pParse
else if (subElement == "Z")
entry.mSubElement = 2;
else
- ASSIMP_LOG_WARN_F("Unknown anim subelement <", subElement, ">. Ignoring");
+ ASSIMP_LOG_WARN("Unknown anim subelement <", subElement, ">. Ignoring");
} else {
// no sub-element following, transformId is remaining string
entry.mTransformId = srcChannel.mTarget.substr(slashPos + 1);
@@ -1241,7 +1241,7 @@ void ColladaLoader::CreateAnimation(aiScene *pScene, const ColladaParser &pParse
continue;
}
entry.mTargetId = entry.mTransformId;
- entry.mTransformId = "";
+ entry.mTransformId = std::string();
}
entry.mChannel = &(*cit);
@@ -1711,7 +1711,7 @@ aiString ColladaLoader::FindFilenameForEffectTexture(const ColladaParser &pParse
// find the image referred by this name in the image library of the scene
ColladaParser::ImageLibrary::const_iterator imIt = pParser.mImageLibrary.find(name);
if (imIt == pParser.mImageLibrary.end()) {
- ASSIMP_LOG_WARN_F("Collada: Unable to resolve effect texture entry \"", pName, "\", ended up at ID \"", name, "\".");
+ ASSIMP_LOG_WARN("Collada: Unable to resolve effect texture entry \"", pName, "\", ended up at ID \"", name, "\".");
//set default texture file name
result.Set(name + ".jpg");
diff --git a/code/AssetLib/Collada/ColladaParser.cpp b/code/AssetLib/Collada/ColladaParser.cpp
index 42166fdd4..5dbf0a567 100644
--- a/code/AssetLib/Collada/ColladaParser.cpp
+++ b/code/AssetLib/Collada/ColladaParser.cpp
@@ -71,7 +71,7 @@ static void ReportWarning(const char *msg, ...) {
ai_assert(iLen > 0);
va_end(args);
- ASSIMP_LOG_WARN_F("Validation warning: ", std::string(szBuffer, iLen));
+ ASSIMP_LOG_WARN("Validation warning: ", std::string(szBuffer, iLen));
}
static bool FindCommonKey(const std::string &collada_key, const MetaKeyPairVector &key_renaming, size_t &found_index) {
@@ -234,7 +234,7 @@ void ColladaParser::UriDecodePath(aiString &ss) {
#if defined(_MSC_VER)
if (ss.data[0] == '/' && isalpha((unsigned char)ss.data[1]) && ss.data[2] == ':') {
#else
- if (ss.data[0] == '/' && isalpha(ss.data[1]) && ss.data[2] == ':') {
+ if (ss.data[0] == '/' && isalpha((unsigned char)ss.data[1]) && ss.data[2] == ':') {
#endif
--ss.length;
::memmove(ss.data, ss.data + 1, ss.length);
@@ -623,8 +623,7 @@ void ColladaParser::ReadController(XmlNode &node, Collada::Controller &controlle
controller.mType = Skin;
controller.mMethod = Normalized;
- XmlNodeIterator xmlIt(node);
- xmlIt.collectChildrenPreOrder(node);
+ XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
XmlNode currentNode;
while (xmlIt.getNext(currentNode)) {
@@ -929,8 +928,7 @@ void ColladaParser::ReadMaterial(XmlNode &node, Collada::Material &pMaterial) {
// ------------------------------------------------------------------------------------------------
// Reads a light entry into the given light
void ColladaParser::ReadLight(XmlNode &node, Collada::Light &pLight) {
- XmlNodeIterator xmlIt(node);
- xmlIt.collectChildrenPreOrder(node);
+ XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
XmlNode currentNode;
while (xmlIt.getNext(currentNode)) {
const std::string ¤tName = currentNode.name();
@@ -991,10 +989,8 @@ void ColladaParser::ReadLight(XmlNode &node, Collada::Light &pLight) {
// ------------------------------------------------------------------------------------------------
// Reads a camera entry into the given light
void ColladaParser::ReadCamera(XmlNode &node, Collada::Camera &camera) {
- XmlNodeIterator xmlIt(node);
- xmlIt.collectChildrenPreOrder(node);
+ XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
XmlNode currentNode;
-
while (xmlIt.getNext(currentNode)) {
const std::string ¤tName = currentNode.name();
if (currentName == "orthographic") {
@@ -1050,11 +1046,10 @@ void ColladaParser::ReadEffect(XmlNode &node, Collada::Effect &pEffect) {
// ------------------------------------------------------------------------------------------------
// Reads an COMMON effect profile
void ColladaParser::ReadEffectProfileCommon(XmlNode &node, Collada::Effect &pEffect) {
- XmlNodeIterator xmlIt(node);
- xmlIt.collectChildrenPreOrder(node);
+ XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
XmlNode currentNode;
while (xmlIt.getNext(currentNode)) {
- const std::string ¤tName = currentNode.name();
+ const std::string currentName = currentNode.name();
if (currentName == "newparam") {
// save ID
std::string sid = currentNode.attribute("sid").as_string();
@@ -1145,10 +1140,9 @@ void ColladaParser::ReadSamplerProperties(XmlNode &node, Sampler &out) {
if (node.empty()) {
return;
}
- XmlNodeIterator xmlIt(node);
- xmlIt.collectChildrenPreOrder(node);
- XmlNode currentNode;
+ XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
+ XmlNode currentNode;
while (xmlIt.getNext(currentNode)) {
const std::string ¤tName = currentNode.name();
// MAYA extensions
@@ -1208,10 +1202,9 @@ void ColladaParser::ReadEffectColor(XmlNode &node, aiColor4D &pColor, Sampler &p
if (node.empty()) {
return;
}
- XmlNodeIterator xmlIt(node);
- xmlIt.collectChildrenPreOrder(node);
- XmlNode currentNode;
+ XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
+ XmlNode currentNode;
while (xmlIt.getNext(currentNode)) {
const std::string ¤tName = currentNode.name();
if (currentName == "color") {
@@ -1273,8 +1266,7 @@ void ColladaParser::ReadEffectParam(XmlNode &node, Collada::EffectParam &pParam)
return;
}
- XmlNodeIterator xmlIt(node);
- xmlIt.collectChildrenPreOrder(node);
+ XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
XmlNode currentNode;
while (xmlIt.getNext(currentNode)) {
const std::string ¤tName = currentNode.name();
@@ -1360,8 +1352,7 @@ void ColladaParser::ReadMesh(XmlNode &node, Mesh &pMesh) {
return;
}
- XmlNodeIterator xmlIt(node);
- xmlIt.collectChildrenPreOrder(node);
+ XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
XmlNode currentNode;
while (xmlIt.getNext(currentNode)) {
const std::string ¤tName = currentNode.name();
@@ -1386,8 +1377,7 @@ void ColladaParser::ReadSource(XmlNode &node) {
std::string sourceID;
XmlParser::getStdStrAttribute(node, "id", sourceID);
- XmlNodeIterator xmlIt(node);
- xmlIt.collectChildrenPreOrder(node);
+ XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
XmlNode currentNode;
while (xmlIt.getNext(currentNode)) {
const std::string ¤tName = currentNode.name();
@@ -1490,8 +1480,7 @@ void ColladaParser::ReadAccessor(XmlNode &node, const std::string &pID) {
acc.mSource = source.c_str() + 1; // ignore the leading '#'
acc.mSize = 0; // gets incremented with every param
- XmlNodeIterator xmlIt(node);
- xmlIt.collectChildrenPreOrder(node);
+ XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
XmlNode currentNode;
while (xmlIt.getNext(currentNode)) {
const std::string ¤tName = currentNode.name();
@@ -1608,8 +1597,7 @@ void ColladaParser::ReadIndexData(XmlNode &node, Mesh &pMesh) {
ai_assert(primType != Prim_Invalid);
// also a number of elements, but in addition a primitive collection and probably index counts for all primitives
- XmlNodeIterator xmlIt(node);
- xmlIt.collectChildrenPreOrder(node);
+ XmlNodeIterator xmlIt(node, XmlNodeIterator::PreOrderMode);
XmlNode currentNode;
while (xmlIt.getNext(currentNode)) {
const std::string ¤tName = currentNode.name();
@@ -2400,7 +2388,7 @@ Collada::InputType ColladaParser::GetTypeForSemantic(const std::string &semantic
else if (semantic == "TANGENT" || semantic == "TEXTANGENT")
return IT_Tangent;
- ASSIMP_LOG_WARN_F("Unknown vertex input type \"", semantic, "\". Ignoring.");
+ ASSIMP_LOG_WARN("Unknown vertex input type \"", semantic, "\". Ignoring.");
return IT_Invalid;
}
diff --git a/code/AssetLib/DXF/DXFHelper.h b/code/AssetLib/DXF/DXFHelper.h
index f7fc470e8..c7e75c3b1 100644
--- a/code/AssetLib/DXF/DXFHelper.h
+++ b/code/AssetLib/DXF/DXFHelper.h
@@ -135,7 +135,7 @@ public:
for(;splitter->length() && splitter->at(0) != '}'; splitter++, cnt++);
splitter++;
- ASSIMP_LOG_VERBOSE_DEBUG((Formatter::format("DXF: skipped over control group ("),cnt," lines)"));
+ ASSIMP_LOG_VERBOSE_DEBUG("DXF: skipped over control group (",cnt," lines)");
}
} catch(std::logic_error&) {
ai_assert(!splitter);
diff --git a/code/AssetLib/DXF/DXFLoader.cpp b/code/AssetLib/DXF/DXFLoader.cpp
index d4a6be4ad..49d572b0b 100644
--- a/code/AssetLib/DXF/DXFLoader.cpp
+++ b/code/AssetLib/DXF/DXFLoader.cpp
@@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2021, assimp team
-
-
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -63,11 +61,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp;
// AutoCAD Binary DXF
-const std::string AI_DXF_BINARY_IDENT = std::string("AutoCAD Binary DXF\r\n\x1a\0");
-const size_t AI_DXF_BINARY_IDENT_LEN = 24u;
+static constexpr char AI_DXF_BINARY_IDENT[] = "AutoCAD Binary DXF\r\n\x1a";
+static constexpr size_t AI_DXF_BINARY_IDENT_LEN = sizeof AI_DXF_BINARY_IDENT;
// default vertex color that all uncolored vertices will receive
-const aiColor4D AI_DXF_DEFAULT_COLOR(aiColor4D(0.6f, 0.6f, 0.6f, 0.6f));
+static const aiColor4D AI_DXF_DEFAULT_COLOR(aiColor4D(0.6f, 0.6f, 0.6f, 0.6f));
// color indices for DXF - 16 are supported, the table is
// taken directly from the DXF spec.
@@ -156,10 +154,10 @@ void DXFImporter::InternReadFile( const std::string& filename, aiScene* pScene,
}
// Check whether this is a binary DXF file - we can't read binary DXF files :-(
- char buff[AI_DXF_BINARY_IDENT_LEN+1] = {0};
+ char buff[AI_DXF_BINARY_IDENT_LEN] = {0};
file->Read(buff,AI_DXF_BINARY_IDENT_LEN,1);
- if (0 == strncmp(AI_DXF_BINARY_IDENT.c_str(),buff,AI_DXF_BINARY_IDENT_LEN)) {
+ if (0 == memcmp(AI_DXF_BINARY_IDENT,buff,AI_DXF_BINARY_IDENT_LEN)) {
throw DeadlyImportError("DXF: Binary files are not supported at the moment");
}
@@ -202,7 +200,7 @@ void DXFImporter::InternReadFile( const std::string& filename, aiScene* pScene,
// comments
else if (reader.Is(999)) {
- ASSIMP_LOG_INFO_F("DXF Comment: ", reader.Value());
+ ASSIMP_LOG_INFO("DXF Comment: ", reader.Value());
}
// don't read past the official EOF sign
@@ -241,7 +239,7 @@ void DXFImporter::ConvertMeshes(aiScene* pScene, DXF::FileData& output) {
}
}
- ASSIMP_LOG_VERBOSE_DEBUG_F("DXF: Unexpanded polycount is ", icount, ", vertex count is ", vcount);
+ ASSIMP_LOG_VERBOSE_DEBUG("DXF: Unexpanded polycount is ", icount, ", vertex count is ", vcount);
}
if (! output.blocks.size() ) {
@@ -372,7 +370,7 @@ void DXFImporter::ExpandBlockReferences(DXF::Block& bl,const DXF::BlockMap& bloc
// first check if the referenced blocks exists ...
const DXF::BlockMap::const_iterator it = blocks_by_name.find(insert.name);
if (it == blocks_by_name.end()) {
- ASSIMP_LOG_ERROR_F("DXF: Failed to resolve block reference: ", insert.name,"; skipping" );
+ ASSIMP_LOG_ERROR("DXF: Failed to resolve block reference: ", insert.name,"; skipping" );
continue;
}
@@ -473,7 +471,7 @@ void DXFImporter::ParseBlocks(DXF::LineReader& reader, DXF::FileData& output) {
++reader;
}
- ASSIMP_LOG_VERBOSE_DEBUG_F("DXF: got ", output.blocks.size()," entries in BLOCKS" );
+ ASSIMP_LOG_VERBOSE_DEBUG("DXF: got ", output.blocks.size()," entries in BLOCKS" );
}
// ------------------------------------------------------------------------------------------------
@@ -549,7 +547,7 @@ void DXFImporter::ParseEntities(DXF::LineReader& reader, DXF::FileData& output)
++reader;
}
- ASSIMP_LOG_VERBOSE_DEBUG_F( "DXF: got ", block.lines.size()," polylines and ", block.insertions.size(),
+ ASSIMP_LOG_VERBOSE_DEBUG( "DXF: got ", block.lines.size()," polylines and ", block.insertions.size(),
" inserted blocks in ENTITIES" );
}
@@ -654,7 +652,7 @@ void DXFImporter::ParsePolyLine(DXF::LineReader& reader, DXF::FileData& output)
//}
if (vguess && line.positions.size() != vguess) {
- ASSIMP_LOG_WARN_F("DXF: unexpected vertex count in polymesh: ",
+ ASSIMP_LOG_WARN("DXF: unexpected vertex count in polymesh: ",
line.positions.size(),", expected ", vguess );
}
@@ -670,7 +668,7 @@ void DXFImporter::ParsePolyLine(DXF::LineReader& reader, DXF::FileData& output)
// to set the 71 and 72 fields, respectively, to valid values.
// So just fire a warning.
if (iguess && line.counts.size() != iguess) {
- ASSIMP_LOG_WARN_F( "DXF: unexpected face count in polymesh: ", line.counts.size(),", expected ", iguess );
+ ASSIMP_LOG_WARN( "DXF: unexpected face count in polymesh: ", line.counts.size(),", expected ", iguess );
}
}
else if (!line.indices.size() && !line.counts.size()) {
diff --git a/code/AssetLib/FBX/FBXBinaryTokenizer.cpp b/code/AssetLib/FBX/FBXBinaryTokenizer.cpp
index 800d0014d..348812054 100644
--- a/code/AssetLib/FBX/FBXBinaryTokenizer.cpp
+++ b/code/AssetLib/FBX/FBXBinaryTokenizer.cpp
@@ -459,7 +459,7 @@ void TokenizeBinary(TokenList& output_tokens, const char* input, size_t length)
/*Result ignored*/ ReadByte(input, cursor, input + length);
/*Result ignored*/ ReadByte(input, cursor, input + length);
const uint32_t version = ReadWord(input, cursor, input + length);
- ASSIMP_LOG_DEBUG_F("FBX version: ", version);
+ ASSIMP_LOG_DEBUG("FBX version: ", version);
const bool is64bits = version >= 7500;
const char *end = input + length;
try
diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp
index cb033a651..a564b3e9b 100644
--- a/code/AssetLib/FBX/FBXConverter.cpp
+++ b/code/AssetLib/FBX/FBXConverter.cpp
@@ -811,7 +811,7 @@ bool FBXConverter::GenerateTransformationNodeChain(const Model &model, const std
// we need to generate a full node chain to accommodate for assimp's
// lack to express pivots and offsets.
if ((chainBits & chainMaskComplex) && doc.Settings().preservePivots) {
- FBXImporter::LogInfo("generating full transformation chain for node: " + name);
+ FBXImporter::LogInfo("generating full transformation chain for node: ", name);
// query the anim_chain_bits dictionary to find out which chain elements
// have associated node animation channels. These can not be dropped
@@ -918,7 +918,7 @@ void FBXConverter::ConvertModel(const Model &model, aiNode *parent, aiNode *root
const std::vector &indices = ConvertLine(*line, root_node);
std::copy(indices.begin(), indices.end(), std::back_inserter(meshes));
} else {
- FBXImporter::LogWarn("ignoring unrecognized geometry: " + geo->Name());
+ FBXImporter::LogWarn("ignoring unrecognized geometry: ", geo->Name());
}
}
@@ -944,7 +944,7 @@ FBXConverter::ConvertMesh(const MeshGeometry &mesh, const Model &model, aiNode *
const std::vector &vertices = mesh.GetVertices();
const std::vector &faces = mesh.GetFaceIndexCounts();
if (vertices.empty() || faces.empty()) {
- FBXImporter::LogWarn("ignoring empty geometry: " + mesh.Name());
+ FBXImporter::LogWarn("ignoring empty geometry: ", mesh.Name());
return temp;
}
@@ -971,7 +971,7 @@ std::vector FBXConverter::ConvertLine(const LineGeometry &line, ai
const std::vector &vertices = line.GetVertices();
const std::vector &indices = line.GetIndices();
if (vertices.empty() || indices.empty()) {
- FBXImporter::LogWarn("ignoring empty line: " + line.Name());
+ FBXImporter::LogWarn("ignoring empty line: ", line.Name());
return temp;
}
@@ -1126,6 +1126,8 @@ unsigned int FBXConverter::ConvertMeshSingleMaterial(const MeshGeometry &mesh, c
*out_uv++ = aiVector3D(v.x, v.y, 0.0f);
}
+ out_mesh->mTextureCoordsNames[i] = mesh.GetTextureCoordChannelName(i);
+
out_mesh->mNumUVComponents[i] = 2;
}
@@ -1542,10 +1544,10 @@ void FBXConverter::ConvertCluster(std::vector &local_mesh_bones, const
aiBone *bone = nullptr;
if (bone_map.count(deformer_name)) {
- ASSIMP_LOG_VERBOSE_DEBUG_F("retrieved bone from lookup ", bone_name.C_Str(), ". Deformer:", deformer_name);
+ ASSIMP_LOG_VERBOSE_DEBUG("retrieved bone from lookup ", bone_name.C_Str(), ". Deformer:", deformer_name);
bone = bone_map[deformer_name];
} else {
- ASSIMP_LOG_VERBOSE_DEBUG_F("created new bone ", bone_name.C_Str(), ". Deformer: ", deformer_name);
+ ASSIMP_LOG_VERBOSE_DEBUG("created new bone ", bone_name.C_Str(), ". Deformer: ", deformer_name);
bone = new aiBone();
bone->mName = bone_name;
@@ -1591,7 +1593,7 @@ void FBXConverter::ConvertCluster(std::vector &local_mesh_bones, const
bone_map.insert(std::pair(deformer_name, bone));
}
- ASSIMP_LOG_DEBUG_F("bone research: Indicies size: ", out_indices.size());
+ ASSIMP_LOG_DEBUG("bone research: Indicies size: ", out_indices.size());
// lookup must be populated in case something goes wrong
// this also allocates bones to mesh instance outside
@@ -1815,14 +1817,14 @@ void FBXConverter::TrySetTextureProperties(aiMaterial *out_mat, const TextureMap
}
}
if (index == -1) {
- FBXImporter::LogWarn("did not find UV channel named " + uvSet + " in a mesh using this material");
+ FBXImporter::LogWarn("did not find UV channel named ", uvSet, " in a mesh using this material");
continue;
}
if (uvIndex == -1) {
uvIndex = index;
} else {
- FBXImporter::LogWarn("the UV channel named " + uvSet +
+ FBXImporter::LogWarn("the UV channel named ", uvSet,
" appears at different positions in meshes, results will be wrong");
}
}
@@ -1839,7 +1841,7 @@ void FBXConverter::TrySetTextureProperties(aiMaterial *out_mat, const TextureMap
}
}
if (index == -1) {
- FBXImporter::LogWarn("did not find UV channel named " + uvSet + " in a mesh using this material");
+ FBXImporter::LogWarn("did not find UV channel named ", uvSet, " in a mesh using this material");
}
if (uvIndex == -1) {
@@ -1848,7 +1850,7 @@ void FBXConverter::TrySetTextureProperties(aiMaterial *out_mat, const TextureMap
}
if (uvIndex == -1) {
- FBXImporter::LogWarn("failed to resolve UV channel " + uvSet + ", using first UV channel");
+ FBXImporter::LogWarn("failed to resolve UV channel ", uvSet, ", using first UV channel");
uvIndex = 0;
}
}
@@ -1934,14 +1936,14 @@ void FBXConverter::TrySetTextureProperties(aiMaterial *out_mat, const LayeredTex
}
}
if (index == -1) {
- FBXImporter::LogWarn("did not find UV channel named " + uvSet + " in a mesh using this material");
+ FBXImporter::LogWarn("did not find UV channel named ", uvSet, " in a mesh using this material");
continue;
}
if (uvIndex == -1) {
uvIndex = index;
} else {
- FBXImporter::LogWarn("the UV channel named " + uvSet +
+ FBXImporter::LogWarn("the UV channel named ", uvSet,
" appears at different positions in meshes, results will be wrong");
}
}
@@ -1958,7 +1960,7 @@ void FBXConverter::TrySetTextureProperties(aiMaterial *out_mat, const LayeredTex
}
}
if (index == -1) {
- FBXImporter::LogWarn("did not find UV channel named " + uvSet + " in a mesh using this material");
+ FBXImporter::LogWarn("did not find UV channel named ", uvSet, " in a mesh using this material");
}
if (uvIndex == -1) {
@@ -1967,7 +1969,7 @@ void FBXConverter::TrySetTextureProperties(aiMaterial *out_mat, const LayeredTex
}
if (uvIndex == -1) {
- FBXImporter::LogWarn("failed to resolve UV channel " + uvSet + ", using first UV channel");
+ FBXImporter::LogWarn("failed to resolve UV channel ", uvSet, ", using first UV channel");
uvIndex = 0;
}
}
@@ -2126,7 +2128,12 @@ void FBXConverter::SetShadingPropertiesCommon(aiMaterial *out_mat, const Propert
const aiColor3D &Emissive = GetColorPropertyFromMaterial(props, "Emissive", ok);
if (ok) {
out_mat->AddProperty(&Emissive, 1, AI_MATKEY_COLOR_EMISSIVE);
- }
+ } else {
+ const aiColor3D &emissiveColor = GetColorPropertyFromMaterial(props, "Maya|emissive", ok);
+ if (ok) {
+ out_mat->AddProperty(&emissiveColor, 1, AI_MATKEY_COLOR_EMISSIVE);
+ }
+ }
const aiColor3D &Ambient = GetColorPropertyFromMaterial(props, "Ambient", ok);
if (ok) {
@@ -2207,6 +2214,52 @@ void FBXConverter::SetShadingPropertiesCommon(aiMaterial *out_mat, const Propert
if (ok) {
out_mat->AddProperty(&DispFactor, 1, "$mat.displacementscaling", 0, 0);
}
+
+ // PBR material information
+ const aiColor3D &baseColor = GetColorPropertyFromMaterial(props, "Maya|base_color", ok);
+ if (ok) {
+ out_mat->AddProperty(&baseColor, 1, AI_MATKEY_BASE_COLOR);
+ }
+
+ const float useColorMap = PropertyGet(props, "Maya|use_color_map", ok);
+ if (ok) {
+ out_mat->AddProperty(&useColorMap, 1, AI_MATKEY_USE_COLOR_MAP);
+ }
+
+ const float useMetallicMap = PropertyGet(props, "Maya|use_metallic_map", ok);
+ if (ok) {
+ out_mat->AddProperty(&useMetallicMap, 1, AI_MATKEY_USE_METALLIC_MAP);
+ }
+
+ const float metallicFactor = PropertyGet(props, "Maya|metallic", ok);
+ if (ok) {
+ out_mat->AddProperty(&metallicFactor, 1, AI_MATKEY_METALLIC_FACTOR);
+ }
+
+ const float useRoughnessMap = PropertyGet(props, "Maya|use_roughness_map", ok);
+ if (ok) {
+ out_mat->AddProperty(&useRoughnessMap, 1, AI_MATKEY_USE_ROUGHNESS_MAP);
+ }
+
+ const float roughnessFactor = PropertyGet(props, "Maya|roughness", ok);
+ if (ok) {
+ out_mat->AddProperty(&roughnessFactor, 1, AI_MATKEY_ROUGHNESS_FACTOR);
+ }
+
+ const float useEmissiveMap = PropertyGet(props, "Maya|use_emissive_map", ok);
+ if (ok) {
+ out_mat->AddProperty(&useEmissiveMap, 1, AI_MATKEY_USE_EMISSIVE_MAP);
+ }
+
+ const float emissiveIntensity = PropertyGet(props, "Maya|emissive_intensity", ok);
+ if (ok) {
+ out_mat->AddProperty(&emissiveIntensity, 1, AI_MATKEY_EMISSIVE_INTENSITY);
+ }
+
+ const float useAOMap = PropertyGet(props, "Maya|use_ao_map", ok);
+ if (ok) {
+ out_mat->AddProperty(&useAOMap, 1, AI_MATKEY_USE_AO_MAP);
+ }
}
void FBXConverter::SetShadingPropertiesRaw(aiMaterial *out_mat, const PropertyTable &props, const TextureMap &_textures, const MeshGeometry *const mesh) {
@@ -2319,14 +2372,14 @@ void FBXConverter::SetShadingPropertiesRaw(aiMaterial *out_mat, const PropertyTa
}
}
if (index == -1) {
- FBXImporter::LogWarn("did not find UV channel named " + uvSet + " in a mesh using this material");
+ FBXImporter::LogWarn("did not find UV channel named ", uvSet, " in a mesh using this material");
continue;
}
if (uvIndex == -1) {
uvIndex = index;
} else {
- FBXImporter::LogWarn("the UV channel named " + uvSet + " appears at different positions in meshes, results will be wrong");
+ FBXImporter::LogWarn("the UV channel named ", uvSet, " appears at different positions in meshes, results will be wrong");
}
}
} else {
@@ -2342,7 +2395,7 @@ void FBXConverter::SetShadingPropertiesRaw(aiMaterial *out_mat, const PropertyTa
}
}
if (index == -1) {
- FBXImporter::LogWarn("did not find UV channel named " + uvSet + " in a mesh using this material");
+ FBXImporter::LogWarn("did not find UV channel named ", uvSet, " in a mesh using this material");
}
if (uvIndex == -1) {
@@ -2351,7 +2404,7 @@ void FBXConverter::SetShadingPropertiesRaw(aiMaterial *out_mat, const PropertyTa
}
if (uvIndex == -1) {
- FBXImporter::LogWarn("failed to resolve UV channel " + uvSet + ", using first UV channel");
+ FBXImporter::LogWarn("failed to resolve UV channel ", uvSet, ", using first UV channel");
uvIndex = 0;
}
}
@@ -2574,7 +2627,7 @@ void FBXConverter::ConvertAnimationStack(const AnimationStack &st) {
// empty animations would fail validation, so drop them
delete anim;
animations.pop_back();
- FBXImporter::LogInfo("ignoring empty AnimationStack (using IK?): " + name);
+ FBXImporter::LogInfo("ignoring empty AnimationStack (using IK?): ", name);
return;
}
@@ -2707,13 +2760,13 @@ void FBXConverter::GenerateNodeAnimations(std::vector &node_anims,
ai_assert(node);
if (node->TargetProperty().empty()) {
- FBXImporter::LogWarn("target property for animation curve not set: " + node->Name());
+ FBXImporter::LogWarn("target property for animation curve not set: ", node->Name());
continue;
}
curve_node = node;
if (node->Curves().empty()) {
- FBXImporter::LogWarn("no animation curves assigned to AnimationCurveNode: " + node->Name());
+ FBXImporter::LogWarn("no animation curves assigned to AnimationCurveNode: ", node->Name());
continue;
}
@@ -2748,7 +2801,7 @@ void FBXConverter::GenerateNodeAnimations(std::vector &node_anims,
if (doc.Settings().optimizeEmptyAnimationCurves &&
IsRedundantAnimationData(target, comp, (chain[i]->second))) {
- FBXImporter::LogVerboseDebug("dropping redundant animation channel for node " + target.Name());
+ FBXImporter::LogVerboseDebug("dropping redundant animation channel for node ", target.Name());
continue;
}
diff --git a/code/AssetLib/FBX/FBXDocument.cpp b/code/AssetLib/FBX/FBXDocument.cpp
index a9eb3ad15..7adaadf6c 100644
--- a/code/AssetLib/FBX/FBXDocument.cpp
+++ b/code/AssetLib/FBX/FBXDocument.cpp
@@ -312,7 +312,7 @@ void Document::ReadHeader() {
const Scope& shead = *ehead->Compound();
fbxVersion = ParseTokenAsInt(GetRequiredToken(GetRequiredElement(shead,"FBXVersion",ehead),0));
- ASSIMP_LOG_DEBUG_F("FBX Version: ", fbxVersion);
+ ASSIMP_LOG_DEBUG("FBX Version: ", fbxVersion);
// While we may have some success with newer files, we don't support
// the older 6.n fbx format
diff --git a/code/AssetLib/FBX/FBXDocumentUtil.cpp b/code/AssetLib/FBX/FBXDocumentUtil.cpp
index 6ba01aa47..ab15298a8 100644
--- a/code/AssetLib/FBX/FBXDocumentUtil.cpp
+++ b/code/AssetLib/FBX/FBXDocumentUtil.cpp
@@ -79,7 +79,7 @@ void DOMError(const std::string& message, const Element* element /*= nullptr*/)
void DOMWarning(const std::string& message, const Token& token)
{
if(DefaultLogger::get()) {
- ASSIMP_LOG_WARN_F("FBX-DOM", Util::GetTokenText(&token), message);
+ ASSIMP_LOG_WARN("FBX-DOM", Util::GetTokenText(&token), message);
}
}
@@ -91,7 +91,7 @@ void DOMWarning(const std::string& message, const Element* element /*= nullptr*/
return;
}
if(DefaultLogger::get()) {
- ASSIMP_LOG_WARN("FBX-DOM: " + message);
+ ASSIMP_LOG_WARN("FBX-DOM: ", message);
}
}
diff --git a/code/AssetLib/FBX/FBXExporter.cpp b/code/AssetLib/FBX/FBXExporter.cpp
index 322161411..f7beee2e0 100644
--- a/code/AssetLib/FBX/FBXExporter.cpp
+++ b/code/AssetLib/FBX/FBXExporter.cpp
@@ -541,10 +541,17 @@ void FBXExporter::WriteReferences ()
// (before any actual data is written)
// ---------------------------------------------------------------
-size_t count_nodes(const aiNode* n) {
- size_t count = 1;
+size_t count_nodes(const aiNode* n, const aiNode* root) {
+ size_t count;
+ if (n == root) {
+ count = n->mNumMeshes; // (not counting root node)
+ } else if (n->mNumMeshes > 1) {
+ count = n->mNumMeshes + 1;
+ } else {
+ count = 1;
+ }
for (size_t i = 0; i < n->mNumChildren; ++i) {
- count += count_nodes(n->mChildren[i]);
+ count += count_nodes(n->mChildren[i], root);
}
return count;
}
@@ -714,7 +721,7 @@ void FBXExporter::WriteDefinitions ()
// Model / FbxNode
// <~~ node hierarchy
- count = int32_t(count_nodes(mScene->mRootNode)) - 1; // (not counting root node)
+ count = int32_t(count_nodes(mScene->mRootNode, mScene->mRootNode));
if (count) {
n = FBX::Node("ObjectType", "Model");
n.AddChild("Count", count);
@@ -1789,13 +1796,13 @@ void FBXExporter::WriteObjects ()
blendchannel_uid, blendshape_name + FBX::SEPARATOR + "SubDeformer", "BlendShapeChannel"
);
sdnode.AddChild("Version", int32_t(100));
- sdnode.AddChild("DeformPercent", int32_t(100));
+ sdnode.AddChild("DeformPercent", float_t(0.0));
FBX::Node p("Properties70");
- p.AddP70numberA("DeformPercent", 100.);
+ p.AddP70numberA("DeformPercent", 0.0);
sdnode.AddChild(p);
// TODO: Normally just one weight per channel, adding stub for later development
std::vectorfFullWeights;
- fFullWeights.push_back(0.);
+ fFullWeights.push_back(100.);
sdnode.AddChild("FullWeights", fFullWeights);
sdnode.Dump(outstream, binary, indent);
@@ -2625,17 +2632,14 @@ void FBXExporter::WriteModelNodes(
],
new_node_uid
);
- // write model node
- FBX::Node m("Model");
+
+ aiNode new_node;
// take name from mesh name, if it exists
- std::string name = mScene->mMeshes[node->mMeshes[i]]->mName.C_Str();
- name += FBX::SEPARATOR + "Model";
- m.AddProperties(new_node_uid, name, "Mesh");
- m.AddChild("Version", int32_t(232));
- FBX::Node p("Properties70");
- p.AddP70enum("InheritType", 1);
- m.AddChild(p);
- m.Dump(outstream, binary, 1);
+ new_node.mName = mScene->mMeshes[node->mMeshes[i]]->mName;
+ // write model node
+ WriteModelNode(
+ outstream, binary, &new_node, new_node_uid, "Mesh", std::vector>()
+ );
}
}
diff --git a/code/AssetLib/FBX/FBXMaterial.cpp b/code/AssetLib/FBX/FBXMaterial.cpp
index 3af014bc3..6ada9630b 100644
--- a/code/AssetLib/FBX/FBXMaterial.cpp
+++ b/code/AssetLib/FBX/FBXMaterial.cpp
@@ -82,7 +82,7 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con
// lower-case shading because Blender (for example) writes "Phong"
for (size_t i = 0; i < shading.length(); ++i) {
- shading[i] = static_cast(tolower(shading[i]));
+ shading[i] = static_cast(tolower(static_cast(shading[i])));
}
std::string templateName;
if(shading == "phong") {
@@ -352,7 +352,7 @@ Video::Video(uint64_t id, const Element& element, const Document& doc, const std
}
} catch (const runtime_error& runtimeError) {
//we don't need the content data for contents that has already been loaded
- ASSIMP_LOG_VERBOSE_DEBUG_F("Caught exception in FBXMaterial (likely because content was already loaded): ",
+ ASSIMP_LOG_VERBOSE_DEBUG("Caught exception in FBXMaterial (likely because content was already loaded): ",
runtimeError.what());
}
}
diff --git a/code/AssetLib/FBX/FBXMeshGeometry.cpp b/code/AssetLib/FBX/FBXMeshGeometry.cpp
index fd8a0ff98..5aecb61b5 100644
--- a/code/AssetLib/FBX/FBXMeshGeometry.cpp
+++ b/code/AssetLib/FBX/FBXMeshGeometry.cpp
@@ -307,8 +307,8 @@ void MeshGeometry::ReadLayerElement(const Scope& layerElement)
}
}
- FBXImporter::LogError(Formatter::format("failed to resolve vertex layer element: ")
- << type << ", index: " << typedIndex);
+ FBXImporter::LogError("failed to resolve vertex layer element: ",
+ type, ", index: ", typedIndex);
}
// ------------------------------------------------------------------------------------------------
@@ -324,13 +324,13 @@ void MeshGeometry::ReadVertexData(const std::string& type, int index, const Scop
if (type == "LayerElementUV") {
if(index >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
- FBXImporter::LogError(Formatter::format("ignoring UV layer, maximum number of UV channels exceeded: ")
- << index << " (limit is " << AI_MAX_NUMBER_OF_TEXTURECOORDS << ")" );
+ FBXImporter::LogError("ignoring UV layer, maximum number of UV channels exceeded: ",
+ index, " (limit is ", AI_MAX_NUMBER_OF_TEXTURECOORDS, ")" );
return;
}
const Element* Name = source["Name"];
- m_uvNames[index] = "";
+ m_uvNames[index] = std::string();
if(Name) {
m_uvNames[index] = ParseTokenAsString(GetRequiredToken(*Name,0));
}
@@ -402,8 +402,8 @@ void MeshGeometry::ReadVertexData(const std::string& type, int index, const Scop
}
else if (type == "LayerElementColor") {
if(index >= AI_MAX_NUMBER_OF_COLOR_SETS) {
- FBXImporter::LogError(Formatter::format("ignoring vertex color layer, maximum number of color sets exceeded: ")
- << index << " (limit is " << AI_MAX_NUMBER_OF_COLOR_SETS << ")" );
+ FBXImporter::LogError("ignoring vertex color layer, maximum number of color sets exceeded: ",
+ index, " (limit is ", AI_MAX_NUMBER_OF_COLOR_SETS, ")" );
return;
}
@@ -449,8 +449,8 @@ void ResolveVertexDataArray(std::vector& data_out, const Scope& source,
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
if (tempData.size() != mapping_offsets.size()) {
- FBXImporter::LogError(Formatter::format("length of input data unexpected for ByVertice mapping: ")
- << tempData.size() << ", expected " << mapping_offsets.size());
+ FBXImporter::LogError("length of input data unexpected for ByVertice mapping: ",
+ tempData.size(), ", expected ", mapping_offsets.size());
return;
}
@@ -470,8 +470,8 @@ void ResolveVertexDataArray(std::vector& data_out, const Scope& source,
ParseVectorDataArray(uvIndices,GetRequiredElement(source,indexDataElementName));
if (uvIndices.size() != vertex_count) {
- FBXImporter::LogError(Formatter::format("length of input data unexpected for ByVertice mapping: ")
- << uvIndices.size() << ", expected " << vertex_count);
+ FBXImporter::LogError("length of input data unexpected for ByVertice mapping: ",
+ uvIndices.size(), ", expected ", vertex_count);
return;
}
@@ -493,8 +493,8 @@ void ResolveVertexDataArray(std::vector& data_out, const Scope& source,
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
if (tempData.size() != vertex_count) {
- FBXImporter::LogError(Formatter::format("length of input data unexpected for ByPolygon mapping: ")
- << tempData.size() << ", expected " << vertex_count
+ FBXImporter::LogError("length of input data unexpected for ByPolygon mapping: ",
+ tempData.size(), ", expected ", vertex_count
);
return;
}
@@ -509,14 +509,14 @@ void ResolveVertexDataArray(std::vector& data_out, const Scope& source,
ParseVectorDataArray(uvIndices,GetRequiredElement(source,indexDataElementName));
if (uvIndices.size() > vertex_count) {
- FBXImporter::LogWarn(Formatter::format("trimming length of input array for ByPolygonVertex mapping: ")
- << uvIndices.size() << ", expected " << vertex_count);
+ FBXImporter::LogWarn("trimming length of input array for ByPolygonVertex mapping: ",
+ uvIndices.size(), ", expected ", vertex_count);
uvIndices.resize(vertex_count);
}
if (uvIndices.size() != vertex_count) {
- FBXImporter::LogError(Formatter::format("length of input data unexpected for ByPolygonVertex mapping: ")
- << uvIndices.size() << ", expected " << vertex_count);
+ FBXImporter::LogError("length of input data unexpected for ByPolygonVertex mapping: ",
+ uvIndices.size(), ", expected ", vertex_count);
return;
}
@@ -537,8 +537,8 @@ void ResolveVertexDataArray(std::vector& data_out, const Scope& source,
}
}
else {
- FBXImporter::LogError(Formatter::format("ignoring vertex data channel, access type not implemented: ")
- << MappingInformationType << "," << ReferenceInformationType);
+ FBXImporter::LogError("ignoring vertex data channel, access type not implemented: ",
+ MappingInformationType, ",", ReferenceInformationType);
}
}
@@ -604,15 +604,15 @@ void MeshGeometry::ReadVertexDataTangents(std::vector& tangents_out,
}
// ------------------------------------------------------------------------------------------------
-static const std::string BinormalIndexToken = "BinormalIndex";
-static const std::string BinormalsIndexToken = "BinormalsIndex";
+static const char * BinormalIndexToken = "BinormalIndex";
+static const char * BinormalsIndexToken = "BinormalsIndex";
void MeshGeometry::ReadVertexDataBinormals(std::vector& binormals_out, const Scope& source,
const std::string& MappingInformationType,
const std::string& ReferenceInformationType)
{
const char * str = source.Elements().count( "Binormals" ) > 0 ? "Binormals" : "Binormal";
- const char * strIdx = source.Elements().count( "Binormals" ) > 0 ? BinormalsIndexToken.c_str() : BinormalIndexToken.c_str();
+ const char * strIdx = source.Elements().count( "Binormals" ) > 0 ? BinormalsIndexToken : BinormalIndexToken;
ResolveVertexDataArray(binormals_out,source,MappingInformationType,ReferenceInformationType,
str,
strIdx,
@@ -642,10 +642,10 @@ void MeshGeometry::ReadVertexDataMaterials(std::vector& materials_out, cons
if (MappingInformationType == "AllSame") {
// easy - same material for all faces
if (materials_out.empty()) {
- FBXImporter::LogError(Formatter::format("expected material index, ignoring"));
+ FBXImporter::LogError("expected material index, ignoring");
return;
} else if (materials_out.size() > 1) {
- FBXImporter::LogWarn(Formatter::format("expected only a single material index, ignoring all except the first one"));
+ FBXImporter::LogWarn("expected only a single material index, ignoring all except the first one");
materials_out.clear();
}
@@ -655,14 +655,14 @@ void MeshGeometry::ReadVertexDataMaterials(std::vector& materials_out, cons
materials_out.resize(face_count);
if(materials_out.size() != face_count) {
- FBXImporter::LogError(Formatter::format("length of input data unexpected for ByPolygon mapping: ")
- << materials_out.size() << ", expected " << face_count
+ FBXImporter::LogError("length of input data unexpected for ByPolygon mapping: ",
+ materials_out.size(), ", expected ", face_count
);
return;
}
} else {
- FBXImporter::LogError(Formatter::format("ignoring material assignments, access type not implemented: ")
- << MappingInformationType << "," << ReferenceInformationType);
+ FBXImporter::LogError("ignoring material assignments, access type not implemented: ",
+ MappingInformationType, ",", ReferenceInformationType);
}
}
// ------------------------------------------------------------------------------------------------
diff --git a/code/AssetLib/FBX/FBXParser.cpp b/code/AssetLib/FBX/FBXParser.cpp
index 046d26c95..37cf83cf9 100644
--- a/code/AssetLib/FBX/FBXParser.cpp
+++ b/code/AssetLib/FBX/FBXParser.cpp
@@ -462,7 +462,7 @@ std::string ParseTokenAsString(const Token& t, const char*& err_out)
if (t.Type() != TokenType_DATA) {
err_out = "expected TOK_DATA token";
- return "";
+ return std::string();
}
if(t.IsBinary())
@@ -470,7 +470,7 @@ std::string ParseTokenAsString(const Token& t, const char*& err_out)
const char* data = t.begin();
if (data[0] != 'S') {
err_out = "failed to parse S(tring), unexpected data type (binary)";
- return "";
+ return std::string();
}
// read string length
@@ -484,13 +484,13 @@ std::string ParseTokenAsString(const Token& t, const char*& err_out)
const size_t length = static_cast(t.end() - t.begin());
if(length < 2) {
err_out = "token is too short to hold a string";
- return "";
+ return std::string();
}
const char* s = t.begin(), *e = t.end() - 1;
if (*s != '\"' || *e != '\"') {
err_out = "expected double quoted string";
- return "";
+ return std::string();
}
return std::string(s+1,length-2);
diff --git a/code/AssetLib/FBX/FBXProperties.cpp b/code/AssetLib/FBX/FBXProperties.cpp
index 2f39fc7dc..1a5ebffd1 100644
--- a/code/AssetLib/FBX/FBXProperties.cpp
+++ b/code/AssetLib/FBX/FBXProperties.cpp
@@ -131,7 +131,7 @@ Property* ReadTypedProperty(const Element& element)
ParseTokenAsFloat(*tok[6]))
);
}
- else if (!strcmp(cs,"double") || !strcmp(cs,"Number") || !strcmp(cs,"Float") || !strcmp(cs,"FieldOfView") || !strcmp( cs, "UnitScaleFactor" ) ) {
+ else if (!strcmp(cs,"double") || !strcmp(cs,"Number") || !strcmp(cs,"float") || !strcmp(cs,"Float") || !strcmp(cs,"FieldOfView") || !strcmp( cs, "UnitScaleFactor" ) ) {
checkTokenCount(tok, 5);
return new TypedProperty(ParseTokenAsFloat(*tok[4]));
}
@@ -155,7 +155,7 @@ std::string PeekPropertyName(const Element& element)
ai_assert(element.KeyToken().StringContents() == "P");
const TokenList& tok = element.Tokens();
if(tok.size() < 4) {
- return "";
+ return std::string();
}
return ParseTokenAsString(*tok[0]);
diff --git a/code/AssetLib/HMP/HMPLoader.cpp b/code/AssetLib/HMP/HMPLoader.cpp
index 56401f5c9..cd14cb9c3 100644
--- a/code/AssetLib/HMP/HMPLoader.cpp
+++ b/code/AssetLib/HMP/HMPLoader.cpp
@@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AssetLib/HMP/HMPLoader.h"
#include "AssetLib/MD2/MD2FileData.h"
+#include
#include
#include
#include
@@ -151,12 +152,7 @@ void HMPImporter::InternReadFile(const std::string &pFile,
InternReadFile_HMP7();
} else {
// Print the magic word to the logger
- char szBuffer[5];
- szBuffer[0] = ((char *)&iMagic)[0];
- szBuffer[1] = ((char *)&iMagic)[1];
- szBuffer[2] = ((char *)&iMagic)[2];
- szBuffer[3] = ((char *)&iMagic)[3];
- szBuffer[4] = '\0';
+ std::string szBuffer = ai_str_toprintable((const char *)&iMagic, sizeof(iMagic));
delete[] mBuffer;
mBuffer = nullptr;
diff --git a/code/AssetLib/IFC/IFCBoolean.cpp b/code/AssetLib/IFC/IFCBoolean.cpp
index 6015920c1..86cac7f46 100644
--- a/code/AssetLib/IFC/IFCBoolean.cpp
+++ b/code/AssetLib/IFC/IFCBoolean.cpp
@@ -715,7 +715,7 @@ void ProcessBoolean(const Schema_2x3::IfcBooleanResult &boolean, TempMesh &resul
// DIFFERENCE
if (const Schema_2x3::IfcBooleanResult *const clip = boolean.ToPtr()) {
if (clip->Operator != "DIFFERENCE") {
- IFCImporter::LogWarn("encountered unsupported boolean operator: " + (std::string)clip->Operator);
+ IFCImporter::LogWarn("encountered unsupported boolean operator: ", (std::string)clip->Operator);
return;
}
@@ -756,7 +756,7 @@ void ProcessBoolean(const Schema_2x3::IfcBooleanResult &boolean, TempMesh &resul
ProcessBooleanExtrudedAreaSolidDifference(as, result, first_operand, conv);
}
} else {
- IFCImporter::LogWarn("skipping unknown IfcBooleanResult entity, type is " + boolean.GetClassName());
+ IFCImporter::LogWarn("skipping unknown IfcBooleanResult entity, type is ", boolean.GetClassName());
}
}
diff --git a/code/AssetLib/IFC/IFCGeometry.cpp b/code/AssetLib/IFC/IFCGeometry.cpp
index 664444443..6e645f1ae 100644
--- a/code/AssetLib/IFC/IFCGeometry.cpp
+++ b/code/AssetLib/IFC/IFCGeometry.cpp
@@ -216,7 +216,7 @@ void ProcessConnectedFaceSet(const Schema_2x3::IfcConnectedFaceSet& fset, TempMe
}
}
else {
- IFCImporter::LogWarn("skipping unknown IfcFaceBound entity, type is " + bound.Bound->GetClassName());
+ IFCImporter::LogWarn("skipping unknown IfcFaceBound entity, type is ", bound.Bound->GetClassName());
continue;
}
@@ -729,7 +729,7 @@ void ProcessSweptAreaSolid(const Schema_2x3::IfcSweptAreaSolid& swept, TempMesh&
ProcessRevolvedAreaSolid(*rev,meshout,conv);
}
else {
- IFCImporter::LogWarn("skipping unknown IfcSweptAreaSolid entity, type is " + swept.GetClassName());
+ IFCImporter::LogWarn("skipping unknown IfcSweptAreaSolid entity, type is ", swept.GetClassName());
}
}
@@ -781,7 +781,7 @@ bool ProcessGeometricItem(const Schema_2x3::IfcRepresentationItem& geo, unsigned
return false;
}
else {
- IFCImporter::LogWarn("skipping unknown IfcGeometricRepresentationItem entity, type is " + geo.GetClassName());
+ IFCImporter::LogWarn("skipping unknown IfcGeometricRepresentationItem entity, type is ", geo.GetClassName());
return false;
}
diff --git a/code/AssetLib/IFC/IFCLoader.cpp b/code/AssetLib/IFC/IFCLoader.cpp
index be100df57..daf2cc946 100644
--- a/code/AssetLib/IFC/IFCLoader.cpp
+++ b/code/AssetLib/IFC/IFCLoader.cpp
@@ -115,7 +115,7 @@ static const aiImporterDesc desc = {
0,
0,
0,
- "ifc ifczip stp"
+ "ifc ifczip step stp"
};
// ------------------------------------------------------------------------------------------------
@@ -243,12 +243,12 @@ void IFCImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
}
if (!DefaultLogger::isNullLogger()) {
- LogDebug("File schema is \'" + head.fileSchema + '\'');
+ LogDebug("File schema is \'", head.fileSchema, '\'');
if (head.timestamp.length()) {
- LogDebug("Timestamp \'" + head.timestamp + '\'');
+ LogDebug("Timestamp \'", head.timestamp, '\'');
}
if (head.app.length()) {
- LogDebug("Application/Exporter identline is \'" + head.app + '\'');
+ LogDebug("Application/Exporter identline is \'", head.app, '\'');
}
}
@@ -315,7 +315,7 @@ void IFCImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// this must be last because objects are evaluated lazily as we process them
if (!DefaultLogger::isNullLogger()) {
- LogDebug((Formatter::format(), "STEP: evaluated ", db->GetEvaluatedObjectCount(), " object records"));
+ LogDebug("STEP: evaluated ", db->GetEvaluatedObjectCount(), " object records");
}
}
@@ -403,7 +403,7 @@ void ResolveObjectPlacement(aiMatrix4x4 &m, const Schema_2x3::IfcObjectPlacement
m = tmpM * m;
}
} else {
- IFCImporter::LogWarn("skipping unknown IfcObjectPlacement entity, type is " + place.GetClassName());
+ IFCImporter::LogWarn("skipping unknown IfcObjectPlacement entity, type is ", place.GetClassName());
}
}
@@ -438,7 +438,7 @@ bool ProcessMappedItem(const Schema_2x3::IfcMappedItem &mapped, aiNode *nd_src,
bool got = false;
for (const Schema_2x3::IfcRepresentationItem &item : repr.Items) {
if (!ProcessRepresentationItem(item, localmatid, meshes, conv)) {
- IFCImporter::LogWarn("skipping mapped entity of type " + item.GetClassName() + ", no representations could be generated");
+ IFCImporter::LogWarn("skipping mapped entity of type ", item.GetClassName(), ", no representations could be generated");
} else
got = true;
}
@@ -567,7 +567,7 @@ typedef std::map Metadata;
// ------------------------------------------------------------------------------------------------
void ProcessMetadata(const Schema_2x3::ListOf, 1, 0> &set, ConversionData &conv, Metadata &properties,
- const std::string &prefix = "",
+ const std::string &prefix = std::string(),
unsigned int nest = 0) {
for (const Schema_2x3::IfcProperty &property : set) {
const std::string &key = prefix.length() > 0 ? (prefix + "." + property.Name) : property.Name;
@@ -618,7 +618,7 @@ void ProcessMetadata(const Schema_2x3::ListOfHasProperties, conv, properties, key, nest + 1);
}
} else {
- properties[key] = "";
+ properties[key] = std::string();
}
}
}
@@ -856,7 +856,7 @@ void ProcessSpatialStructures(ConversionData &conv) {
if (!prod) {
continue;
}
- IFCImporter::LogVerboseDebug("looking at spatial structure `" + (prod->Name ? prod->Name.Get() : "unnamed") + "`" + (prod->ObjectType ? " which is of type " + prod->ObjectType.Get() : ""));
+ IFCImporter::LogVerboseDebug("looking at spatial structure `", (prod->Name ? prod->Name.Get() : "unnamed"), "`", (prod->ObjectType ? " which is of type " + prod->ObjectType.Get() : ""));
// the primary sites are referenced by an IFCRELAGGREGATES element which assigns them to the IFCPRODUCT
const STEP::DB::RefMap &refs = conv.db.GetRefs();
diff --git a/code/AssetLib/IFC/IFCMaterial.cpp b/code/AssetLib/IFC/IFCMaterial.cpp
index e0146b887..2a79f0754 100644
--- a/code/AssetLib/IFC/IFCMaterial.cpp
+++ b/code/AssetLib/IFC/IFCMaterial.cpp
@@ -64,7 +64,7 @@ static int ConvertShadingMode(const std::string& name) {
else if (name == "PHONG") {
return aiShadingMode_Phong;
}
- IFCImporter::LogWarn("shading mode "+name+" not recognized by Assimp, using Phong instead");
+ IFCImporter::LogWarn("shading mode ", name, " not recognized by Assimp, using Phong instead");
return aiShadingMode_Phong;
}
@@ -145,7 +145,7 @@ unsigned int ProcessMaterials(uint64_t id, unsigned int prevMatId, ConversionDat
// not found, create new material
const std::string side = static_cast(surf->Side);
if( side != "BOTH" ) {
- IFCImporter::LogWarn("ignoring surface side marker on IFC::IfcSurfaceStyle: " + side);
+ IFCImporter::LogWarn("ignoring surface side marker on IFC::IfcSurfaceStyle: ", side);
}
std::unique_ptr mat(new aiMaterial());
diff --git a/code/AssetLib/IFC/IFCProfile.cpp b/code/AssetLib/IFC/IFCProfile.cpp
index f33f8cdbe..4235be181 100644
--- a/code/AssetLib/IFC/IFCProfile.cpp
+++ b/code/AssetLib/IFC/IFCProfile.cpp
@@ -68,7 +68,7 @@ bool ProcessCurve(const Schema_2x3::IfcCurve& curve, TempMesh& meshout, Convers
{
std::unique_ptr cv(Curve::Convert(curve,conv));
if (!cv) {
- IFCImporter::LogWarn("skipping unknown IfcCurve entity, type is " + curve.GetClassName());
+ IFCImporter::LogWarn("skipping unknown IfcCurve entity, type is ", curve.GetClassName());
return false;
}
@@ -78,7 +78,7 @@ bool ProcessCurve(const Schema_2x3::IfcCurve& curve, TempMesh& meshout, Convers
bc->SampleDiscrete(meshout);
}
catch(const CurveError& cv) {
- IFCImporter::LogError(cv.mStr + " (error occurred while processing curve)");
+ IFCImporter::LogError(cv.mStr, " (error occurred while processing curve)");
return false;
}
meshout.mVertcnt.push_back(static_cast(meshout.mVerts.size()));
@@ -152,7 +152,7 @@ void ProcessParametrizedProfile(const Schema_2x3::IfcParameterizedProfileDef& de
meshout.mVertcnt.push_back(12);
}
else {
- IFCImporter::LogWarn("skipping unknown IfcParameterizedProfileDef entity, type is " + def.GetClassName());
+ IFCImporter::LogWarn("skipping unknown IfcParameterizedProfileDef entity, type is ", def.GetClassName());
return;
}
@@ -174,7 +174,7 @@ bool ProcessProfile(const Schema_2x3::IfcProfileDef& prof, TempMesh& meshout, Co
ProcessParametrizedProfile(*cparam,meshout,conv);
}
else {
- IFCImporter::LogWarn("skipping unknown IfcProfileDef entity, type is " + prof.GetClassName());
+ IFCImporter::LogWarn("skipping unknown IfcProfileDef entity, type is ", prof.GetClassName());
return false;
}
meshout.RemoveAdjacentDuplicates();
diff --git a/code/AssetLib/IFC/IFCUtil.cpp b/code/AssetLib/IFC/IFCUtil.cpp
index b451262e9..8c37cebed 100644
--- a/code/AssetLib/IFC/IFCUtil.cpp
+++ b/code/AssetLib/IFC/IFCUtil.cpp
@@ -506,7 +506,7 @@ IfcFloat ConvertSIPrefix(const std::string& prefix)
return 1e-18f;
}
else {
- IFCImporter::LogError("Unrecognized SI prefix: " + prefix);
+ IFCImporter::LogError("Unrecognized SI prefix: ", prefix);
return 1;
}
}
diff --git a/code/AssetLib/Irr/IRRLoader.cpp b/code/AssetLib/Irr/IRRLoader.cpp
index 9c1136499..cb383e936 100644
--- a/code/AssetLib/Irr/IRRLoader.cpp
+++ b/code/AssetLib/Irr/IRRLoader.cpp
@@ -639,7 +639,7 @@ void IRRImporter::GenerateGraph(Node *root, aiNode *rootOut, aiScene *scene,
// graph we're currently building
aiScene *localScene = batch.GetImport(root->id);
if (!localScene) {
- ASSIMP_LOG_ERROR("IRR: Unable to load external file: " + root->meshPath);
+ ASSIMP_LOG_ERROR("IRR: Unable to load external file: ", root->meshPath);
break;
}
attach.push_back(AttachmentInfo(localScene, rootOut));
@@ -859,13 +859,13 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// Check whether we can read from the file
if (file.get() == nullptr) {
- throw DeadlyImportError("Failed to open IRR file " + pFile + "");
+ throw DeadlyImportError("Failed to open IRR file ", pFile);
}
// Construct the irrXML parser
XmlParser st;
if (!st.parse( file.get() )) {
- return;
+ throw DeadlyImportError("XML parse error while loading IRR file ", pFile);
}
pugi::xml_node rootElement = st.getRootNode();
@@ -963,7 +963,7 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
ASSIMP_LOG_ERROR("IRR: Billboards are not supported by Assimp");
nd = new Node(Node::DUMMY);
} else {
- ASSIMP_LOG_WARN("IRR: Found unknown node: " + std::string(attrib.name()));
+ ASSIMP_LOG_WARN("IRR: Found unknown node: ", attrib.name());
/* We skip the contents of nodes we don't know.
* We parse the transformation and all animators
@@ -1181,7 +1181,7 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
lights.pop_back();
curNode->type = Node::DUMMY;
- ASSIMP_LOG_ERROR("Ignoring light of unknown type: " + prop.value);
+ ASSIMP_LOG_ERROR("Ignoring light of unknown type: ", prop.value);
}
} else if ((prop.name == "Mesh" && Node::MESH == curNode->type) ||
Node::ANIMMESH == curNode->type) {
@@ -1225,7 +1225,7 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
} else if (prop.value == "followSpline") {
curAnim->type = Animator::FOLLOW_SPLINE;
} else {
- ASSIMP_LOG_WARN("IRR: Ignoring unknown animator: " + prop.value);
+ ASSIMP_LOG_WARN("IRR: Ignoring unknown animator: ", prop.value);
curAnim->type = Animator::UNKNOWN;
}
diff --git a/code/AssetLib/Irr/IRRMeshLoader.cpp b/code/AssetLib/Irr/IRRMeshLoader.cpp
index 97d74026f..9350e07b8 100644
--- a/code/AssetLib/Irr/IRRMeshLoader.cpp
+++ b/code/AssetLib/Irr/IRRMeshLoader.cpp
@@ -135,12 +135,12 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
// Check whether we can read from the file
if (file.get() == NULL)
- throw DeadlyImportError("Failed to open IRRMESH file " + pFile + "");
+ throw DeadlyImportError("Failed to open IRRMESH file ", pFile);
// Construct the irrXML parser
XmlParser parser;
if (!parser.parse( file.get() )) {
- return;
+ throw DeadlyImportError("XML parse error while loading IRRMESH file ", pFile);
}
XmlNode root = parser.getRootNode();
diff --git a/code/AssetLib/Irr/IRRShared.cpp b/code/AssetLib/Irr/IRRShared.cpp
index b119b063a..b42f34b65 100644
--- a/code/AssetLib/Irr/IRRShared.cpp
+++ b/code/AssetLib/Irr/IRRShared.cpp
@@ -260,7 +260,7 @@ aiMaterial* IrrlichtBase::ParseMaterial(unsigned int& matFlags) {
prop.value == "parallaxmap_trans_add") {
matFlags = AI_IRRMESH_MAT_normalmap_ta;
} else {
- ASSIMP_LOG_WARN("IRRMat: Unrecognized material type: " + prop.value);
+ ASSIMP_LOG_WARN("IRRMat: Unrecognized material type: ", prop.value);
}
}
diff --git a/code/AssetLib/LWO/LWOBLoader.cpp b/code/AssetLib/LWO/LWOBLoader.cpp
index 2654eccf4..8ef40fc21 100644
--- a/code/AssetLib/LWO/LWOBLoader.cpp
+++ b/code/AssetLib/LWO/LWOBLoader.cpp
@@ -242,7 +242,7 @@ LWO::Texture* LWOImporter::SetupNewTextureLWOB(LWO::TextureList& list,unsigned i
else
{
// procedural or gradient, not supported
- ASSIMP_LOG_ERROR_F("LWOB: Unsupported legacy texture: ", type);
+ ASSIMP_LOG_ERROR("LWOB: Unsupported legacy texture: ", type);
}
return tex;
diff --git a/code/AssetLib/LWO/LWOFileData.h b/code/AssetLib/LWO/LWOFileData.h
index 70642c537..93ac1a236 100644
--- a/code/AssetLib/LWO/LWOFileData.h
+++ b/code/AssetLib/LWO/LWOFileData.h
@@ -502,7 +502,7 @@ struct Surface {
Surface() :
mColor(0.78431f, 0.78431f, 0.78431f), bDoubleSided(false), mDiffuseValue(1.f), mSpecularValue(0.f), mTransparency(0.f), mGlossiness(0.4f), mLuminosity(0.f), mColorHighlights(0.f), mMaximumSmoothAngle(0.f) // 0 == not specified, no smoothing
,
- mVCMap(""),
+ mVCMap(),
mVCMapType(AI_LWO_RGBA),
mIOR(1.f) // vakuum
,
diff --git a/code/AssetLib/LWO/LWOLoader.cpp b/code/AssetLib/LWO/LWOLoader.cpp
index a9fa08f11..bc62152c5 100644
--- a/code/AssetLib/LWO/LWOLoader.cpp
+++ b/code/AssetLib/LWO/LWOLoader.cpp
@@ -961,7 +961,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) {
switch (type) {
case AI_LWO_TXUV:
if (dims != 2) {
- ASSIMP_LOG_WARN("LWO2: Skipping UV channel \'" + name + "\' with !2 components");
+ ASSIMP_LOG_WARN("LWO2: Skipping UV channel \'", name, "\' with !2 components");
return;
}
base = FindEntry(mCurLayer->mUVChannels, name, perPoly);
@@ -969,7 +969,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) {
case AI_LWO_WGHT:
case AI_LWO_MNVW:
if (dims != 1) {
- ASSIMP_LOG_WARN("LWO2: Skipping Weight Channel \'" + name + "\' with !1 components");
+ ASSIMP_LOG_WARN("LWO2: Skipping Weight Channel \'", name, "\' with !1 components");
return;
}
base = FindEntry((type == AI_LWO_WGHT ? mCurLayer->mWeightChannels : mCurLayer->mSWeightChannels), name, perPoly);
@@ -977,7 +977,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) {
case AI_LWO_RGB:
case AI_LWO_RGBA:
if (dims != 3 && dims != 4) {
- ASSIMP_LOG_WARN("LWO2: Skipping Color Map \'" + name + "\' with a dimension > 4 or < 3");
+ ASSIMP_LOG_WARN("LWO2: Skipping Color Map \'", name, "\' with a dimension > 4 or < 3");
return;
}
base = FindEntry(mCurLayer->mVColorChannels, name, perPoly);
@@ -1006,7 +1006,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) {
if (name == "APS.Level") {
// XXX handle this (seems to be subdivision-related).
}
- ASSIMP_LOG_WARN_F("LWO2: Skipping unknown VMAP/VMAD channel \'", name, "\'");
+ ASSIMP_LOG_WARN("LWO2: Skipping unknown VMAP/VMAD channel \'", name, "\'");
return;
};
base->Allocate((unsigned int)mCurLayer->mTempPoints.size());
@@ -1026,7 +1026,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) {
unsigned int idx = ReadVSizedIntLWO2(mFileBuffer) + mCurLayer->mPointIDXOfs;
if (idx >= numPoints) {
- ASSIMP_LOG_WARN_F("LWO2: Failure evaluating VMAP/VMAD entry \'", name, "\', vertex index is out of range");
+ ASSIMP_LOG_WARN("LWO2: Failure evaluating VMAP/VMAD entry \'", name, "\', vertex index is out of range");
mFileBuffer += base->dims << 2u;
continue;
}
@@ -1036,7 +1036,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) {
// we have already a VMAP entry for this vertex - thus
// we need to duplicate the corresponding polygon.
if (polyIdx >= numFaces) {
- ASSIMP_LOG_WARN_F("LWO2: Failure evaluating VMAD entry \'", name, "\', polygon index is out of range");
+ ASSIMP_LOG_WARN("LWO2: Failure evaluating VMAD entry \'", name, "\', polygon index is out of range");
mFileBuffer += base->dims << 2u;
continue;
}
@@ -1076,7 +1076,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly) {
CreateNewEntry(mCurLayer->mNormals, srcIdx);
}
if (!had) {
- ASSIMP_LOG_WARN_F("LWO2: Failure evaluating VMAD entry \'", name, "\', vertex index wasn't found in that polygon");
+ ASSIMP_LOG_WARN("LWO2: Failure evaluating VMAD entry \'", name, "\', vertex index wasn't found in that polygon");
ai_assert(had);
}
}
diff --git a/code/AssetLib/LWO/LWOMaterial.cpp b/code/AssetLib/LWO/LWOMaterial.cpp
index 9d51438d7..178f24265 100644
--- a/code/AssetLib/LWO/LWOMaterial.cpp
+++ b/code/AssetLib/LWO/LWOMaterial.cpp
@@ -335,7 +335,7 @@ void LWOImporter::ConvertMaterial(const LWO::Surface &surf, aiMaterial *pcMat) {
m = aiShadingMode_Fresnel;
break;
} else {
- ASSIMP_LOG_WARN_F("LWO2: Unknown surface shader: ", shader.functionName);
+ ASSIMP_LOG_WARN("LWO2: Unknown surface shader: ", shader.functionName);
}
}
if (surf.mMaximumSmoothAngle <= 0.0)
@@ -711,7 +711,7 @@ void LWOImporter::LoadLWO2Surface(unsigned int size) {
}
}
if (derived.size()) {
- ASSIMP_LOG_WARN("LWO2: Unable to find source surface: " + derived);
+ ASSIMP_LOG_WARN("LWO2: Unable to find source surface: ", derived);
}
}
diff --git a/code/AssetLib/LWS/LWSLoader.cpp b/code/AssetLib/LWS/LWSLoader.cpp
index a75b90ef9..d469a1064 100644
--- a/code/AssetLib/LWS/LWSLoader.cpp
+++ b/code/AssetLib/LWS/LWSLoader.cpp
@@ -346,7 +346,7 @@ void LWSImporter::BuildGraph(aiNode *nd, LWS::NodeDesc &src, std::vectormRootNode->mNumChildren == 1) {
@@ -538,7 +538,7 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// get file format version and print to log
++it;
unsigned int version = strtoul10((*it).tokens[0].c_str());
- ASSIMP_LOG_INFO("LWS file format version is " + (*it).tokens[0]);
+ ASSIMP_LOG_INFO("LWS file format version is ", (*it).tokens[0]);
first = 0.;
last = 60.;
fps = 25.; // seems to be a good default frame rate
diff --git a/code/AssetLib/LWS/LWSLoader.h b/code/AssetLib/LWS/LWSLoader.h
index 93251cd5d..cd7a0543e 100644
--- a/code/AssetLib/LWS/LWSLoader.h
+++ b/code/AssetLib/LWS/LWSLoader.h
@@ -88,7 +88,7 @@ struct NodeDesc {
id(),
number(0),
parent(0),
- name(""),
+ name(),
isPivotSet(false),
lightColor(1.f, 1.f, 1.f),
lightIntensity(1.f),
diff --git a/code/AssetLib/M3D/M3DExporter.cpp b/code/AssetLib/M3D/M3DExporter.cpp
index 856932947..bcac1d98a 100644
--- a/code/AssetLib/M3D/M3DExporter.cpp
+++ b/code/AssetLib/M3D/M3DExporter.cpp
@@ -294,21 +294,17 @@ void ExportSceneM3D(
// Worker function for exporting a scene to ASCII A3D.
// Prototyped and registered in Exporter.cpp
void ExportSceneM3DA(
- const char *,
- IOSystem *,
- const aiScene *,
- const ExportProperties *
+ const char *pFile,
+ IOSystem *pIOSystem,
+ const aiScene *pScene,
+ const ExportProperties *pProperties
) {
-#ifdef M3D_ASCII
// initialize the exporter
M3DExporter exporter(pScene, pProperties);
// perform ascii export
exporter.doExport(pFile, pIOSystem, true);
-#else
- throw DeadlyExportError("Assimp configured without M3D_ASCII support");
-#endif
}
// ------------------------------------------------------------------------------------------------
diff --git a/code/AssetLib/M3D/M3DImporter.cpp b/code/AssetLib/M3D/M3DImporter.cpp
index 8cbda23cb..38bbd1d4a 100644
--- a/code/AssetLib/M3D/M3DImporter.cpp
+++ b/code/AssetLib/M3D/M3DImporter.cpp
@@ -95,11 +95,7 @@ static const aiImporterDesc desc = {
0,
0,
0,
-#ifdef M3D_ASCII
"m3d a3d"
-#else
- "m3d"
-#endif
};
namespace Assimp {
@@ -119,9 +115,7 @@ bool M3DImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
const std::string extension = GetExtension(pFile);
if (extension == "m3d"
-#ifdef M3D_ASCII
|| extension == "a3d"
-#endif
)
return true;
else if (!extension.length() || checkSig) {
@@ -137,13 +131,11 @@ bool M3DImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
*/
std::unique_ptr pStream(pIOHandler->Open(pFile, "rb"));
unsigned char data[4];
- if (4 != pStream->Read(data, 1, 4)) {
+ if (!pStream || 4 != pStream->Read(data, 1, 4)) {
return false;
}
return !memcmp(data, "3DMO", 4) /* bin */
-#ifdef M3D_ASCII
|| !memcmp(data, "3dmo", 4) /* ASCII */
-#endif
;
}
return false;
@@ -176,12 +168,10 @@ void M3DImporter::InternReadFile(const std::string &file, aiScene *pScene, IOSys
if (!memcmp(buffer.data(), "3DMO", 4) && memcmp(buffer.data() + 4, &fileSize, 4)) {
throw DeadlyImportError("Bad binary header in file ", file, ".");
}
-#ifdef M3D_ASCII
// make sure there's a terminator zero character, as input must be ASCIIZ
if (!memcmp(buffer.data(), "3dmo", 4)) {
buffer.push_back(0);
}
-#endif
// Get the path for external assets
std::string folderName("./");
@@ -194,7 +184,7 @@ void M3DImporter::InternReadFile(const std::string &file, aiScene *pScene, IOSys
}
//DefaultLogger::create("/dev/stderr", Logger::VERBOSE);
- ASSIMP_LOG_DEBUG_F("M3D: loading ", file);
+ ASSIMP_LOG_DEBUG("M3D: loading ", file);
// let the C SDK do the hard work for us
M3DWrapper m3d(pIOHandler, buffer);
@@ -210,7 +200,7 @@ void M3DImporter::InternReadFile(const std::string &file, aiScene *pScene, IOSys
pScene->mRootNode->mNumChildren = 0;
mScene = pScene;
- ASSIMP_LOG_DEBUG("M3D: root node " + m3d.Name());
+ ASSIMP_LOG_DEBUG("M3D: root node ", m3d.Name());
// now we just have to fill up the Assimp structures in pScene
importMaterials(m3d);
@@ -240,7 +230,7 @@ void M3DImporter::importMaterials(const M3DWrapper &m3d) {
mScene->mNumMaterials = m3d->nummaterial + 1;
mScene->mMaterials = new aiMaterial *[mScene->mNumMaterials];
- ASSIMP_LOG_DEBUG_F("M3D: importMaterials ", mScene->mNumMaterials);
+ ASSIMP_LOG_DEBUG("M3D: importMaterials ", mScene->mNumMaterials);
// add a default material as first
aiMaterial *mat = new aiMaterial;
@@ -335,7 +325,7 @@ void M3DImporter::importTextures(const M3DWrapper &m3d) {
ai_assert(m3d);
mScene->mNumTextures = m3d->numtexture;
- ASSIMP_LOG_DEBUG_F("M3D: importTextures ", mScene->mNumTextures);
+ ASSIMP_LOG_DEBUG("M3D: importTextures ", mScene->mNumTextures);
if (!m3d->numtexture || !m3d->texture) {
return;
@@ -390,7 +380,7 @@ void M3DImporter::importTextures(const M3DWrapper &m3d) {
// individually. In assimp there're per mesh vertex and UV lists, and they must be
// indexed simultaneously.
void M3DImporter::importMeshes(const M3DWrapper &m3d) {
- ASSIMP_LOG_DEBUG_F("M3D: importMeshes ", m3d->numface);
+ ASSIMP_LOG_DEBUG("M3D: importMeshes ", m3d->numface);
if (!m3d->numface || !m3d->face || !m3d->numvertex || !m3d->vertex) {
return;
@@ -509,7 +499,7 @@ void M3DImporter::importBones(const M3DWrapper &m3d, unsigned int parentid, aiNo
ai_assert(mScene != nullptr);
ai_assert(m3d);
- ASSIMP_LOG_DEBUG_F("M3D: importBones ", m3d->numbone, " parentid ", (int)parentid);
+ ASSIMP_LOG_DEBUG("M3D: importBones ", m3d->numbone, " parentid ", (int)parentid);
if (!m3d->numbone || !m3d->bone) {
return;
@@ -550,7 +540,7 @@ void M3DImporter::importAnimations(const M3DWrapper &m3d) {
mScene->mNumAnimations = m3d->numaction;
- ASSIMP_LOG_DEBUG_F("M3D: importAnimations ", mScene->mNumAnimations);
+ ASSIMP_LOG_DEBUG("M3D: importAnimations ", mScene->mNumAnimations);
if (!m3d->numaction || !m3d->action || !m3d->numbone || !m3d->bone || !m3d->vertex) {
return;
@@ -713,7 +703,7 @@ void M3DImporter::populateMesh(const M3DWrapper &m3d, aiMesh *pMesh, std::vector
ai_assert(vertexids != nullptr);
ai_assert(m3d);
- ASSIMP_LOG_DEBUG_F("M3D: populateMesh numvertices ", vertices->size(), " numfaces ", faces->size(),
+ ASSIMP_LOG_DEBUG("M3D: populateMesh numvertices ", vertices->size(), " numfaces ", faces->size(),
" numnormals ", normals->size(), " numtexcoord ", texcoords->size(), " numbones ", m3d->numbone);
if (vertices->size() && faces->size()) {
diff --git a/code/AssetLib/M3D/M3DWrapper.h b/code/AssetLib/M3D/M3DWrapper.h
index 5c370e607..782e908d2 100644
--- a/code/AssetLib/M3D/M3DWrapper.h
+++ b/code/AssetLib/M3D/M3DWrapper.h
@@ -54,7 +54,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Assimp specific M3D configuration. Comment out these defines to remove functionality
//#define ASSIMP_USE_M3D_READFILECB
-//#define M3D_ASCII
#include "m3d.h"
diff --git a/code/AssetLib/M3D/m3d.h b/code/AssetLib/M3D/m3d.h
index dfc30aec3..68265959e 100644
--- a/code/AssetLib/M3D/m3d.h
+++ b/code/AssetLib/M3D/m3d.h
@@ -231,14 +231,9 @@ enum {
typedef struct {
uint8_t format;
uint8_t id;
-#ifdef M3D_ASCII
#define M3D_PROPERTYDEF(f, i, n) \
{ (f), (i), (char *)(n) }
char *key;
-#else
-#define M3D_PROPERTYDEF(f, i, n) \
- { (f), (i) }
-#endif
} m3dpd_t;
/* material property types */
@@ -376,18 +371,11 @@ enum {
#define M3D_CMDMAXARG 8 /* if you increase this, add more arguments to the macro below */
typedef struct {
-#ifdef M3D_ASCII
#define M3D_CMDDEF(t, n, p, a, b, c, d, e, f, g, h) \
{ \
(char *)(n), (p), { (a), (b), (c), (d), (e), (f), (g), (h) } \
}
char *key;
-#else
-#define M3D_CMDDEF(t, n, p, a, b, c, d, e, f, g, h) \
- { \
- (p), { (a), (b), (c), (d), (e), (f), (g), (h) } \
- }
-#endif
uint8_t p;
uint8_t a[M3D_CMDMAXARG];
} m3dcd_t;
@@ -2059,15 +2047,13 @@ unsigned char *_m3dstbi_zlib_compress(unsigned char *data, int data_len, int *ou
#define M3D_CHUNKMAGIC(m, a, b, c, d) ((m)[0] == (a) && (m)[1] == (b) && (m)[2] == (c) && (m)[3] == (d))
-#ifdef M3D_ASCII
#include /* sprintf and strtod cares about number locale */
#include /* get sprintf */
-#endif
#ifdef M3D_PROFILING
#include
#endif
-#if !defined(M3D_NOIMPORTER) && defined(M3D_ASCII)
+#if !defined(M3D_NOIMPORTER)
/* helper functions for the ASCII parser */
static char *_m3d_findarg(char *s) {
while (s && *s && *s != ' ' && *s != '\t' && *s != '\r' && *s != '\n')
@@ -2118,7 +2104,7 @@ static char *_m3d_getfloat(char *s, M3D_FLOAT *ret) {
return _m3d_findarg(e);
}
#endif
-#if !defined(M3D_NODUP) && (!defined(M3D_NOIMPORTER) || defined(M3D_ASCII) || defined(M3D_EXPORTER))
+#if !defined(M3D_NODUP) && (!defined(M3D_NOIMPORTER) || defined(M3D_EXPORTER))
/* helper function to create safe strings */
char *_m3d_safestr(char *in, int morelines) {
char *out, *o, *i = in;
@@ -2426,21 +2412,17 @@ m3d_t *m3d_load(unsigned char *data, m3dread_t readfilecb, m3dfree_t freecb, m3d
#ifndef M3D_NOWEIGHTS
m3ds_t *sk;
#endif
-#ifdef M3D_ASCII
m3ds_t s;
M3D_INDEX bi[M3D_BONEMAXLEVEL + 1], level;
const char *ol;
char *ptr, *pe, *fn;
-#endif
#ifdef M3D_PROFILING
struct timeval tv0, tv1, tvd;
gettimeofday(&tv0, NULL);
#endif
if (!data || (!M3D_CHUNKMAGIC(data, '3', 'D', 'M', 'O')
-#ifdef M3D_ASCII
&& !M3D_CHUNKMAGIC(data, '3', 'd', 'm', 'o')
-#endif
))
return NULL;
model = (m3d_t *)M3D_MALLOC(sizeof(m3d_t));
@@ -2457,7 +2439,6 @@ m3d_t *m3d_load(unsigned char *data, m3dread_t readfilecb, m3dfree_t freecb, m3d
model->texture = mtllib->texture;
model->flags |= M3D_FLG_MTLLIB;
}
-#ifdef M3D_ASCII
/* ASCII variant? */
if (M3D_CHUNKMAGIC(data, '3', 'd', 'm', 'o')) {
model->errcode = M3D_ERR_BADFILE;
@@ -3034,7 +3015,6 @@ m3d_t *m3d_load(unsigned char *data, m3dread_t readfilecb, m3dfree_t freecb, m3d
setlocale(LC_NUMERIC, ol);
goto postprocess;
}
-#endif
/* Binary variant */
if (!M3D_CHUNKMAGIC(data + 8, 'H', 'E', 'A', 'D')) {
buff = (unsigned char *)stbi_zlib_decode_malloc_guesssize_headerflag((const char *)data + 8, ((m3dchunk_t *)data)->length - 8,
@@ -3698,9 +3678,7 @@ m3d_t *m3d_load(unsigned char *data, m3dread_t readfilecb, m3dfree_t freecb, m3d
}
}
/* calculate normals, normalize skin weights, create bone/vertex cross-references and calculate transform matrices */
-#ifdef M3D_ASCII
postprocess:
-#endif
if (model) {
M3D_LOG("Post-process");
#ifdef M3D_PROFILING
@@ -3989,7 +3967,6 @@ void m3d_free(m3d_t *model) {
unsigned int i, j;
if (!model) return;
-#ifdef M3D_ASCII
/* if model imported from ASCII, we have to free all strings as well */
if (model->flags & M3D_FLG_FREESTR) {
if (model->name) M3D_FREE(model->name);
@@ -4047,7 +4024,6 @@ void m3d_free(m3d_t *model) {
if (model->preview.data)
M3D_FREE(model->preview.data);
}
-#endif
if (model->flags & M3D_FLG_FREERAW) M3D_FREE(model->raw);
if (model->tmap) M3D_FREE(model->tmap);
@@ -4315,7 +4291,6 @@ static void _m3d_round(int quality, m3dv_t *src, m3dv_t *dst) {
if (dst->w == (M3D_FLOAT)-0.0) dst->w = (M3D_FLOAT)0.0;
}
-#ifdef M3D_ASCII
/* add a bone to ascii output */
static char *_m3d_prtbone(char *ptr, m3db_t *bone, M3D_INDEX numbone, M3D_INDEX parent, uint32_t level, M3D_INDEX *vrtxidx) {
uint32_t i, j;
@@ -4334,16 +4309,13 @@ static char *_m3d_prtbone(char *ptr, m3db_t *bone, M3D_INDEX numbone, M3D_INDEX
}
return ptr;
}
-#endif
/**
* Function to encode an in-memory model into on storage Model 3D format
*/
unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size) {
-#ifdef M3D_ASCII
const char *ol;
char *ptr;
-#endif
char vc_s, vi_s, si_s, ci_s, ti_s, bi_s, nb_s, sk_s, fc_s, hi_s, fi_s;
char *sn = NULL, *sl = NULL, *sa = NULL, *sd = NULL;
unsigned char *out = NULL, *z = NULL, weights[M3D_NUMBONE], *norm = NULL;
@@ -4369,9 +4341,7 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
return NULL;
}
model->errcode = M3D_SUCCESS;
-#ifdef M3D_ASCII
if (flags & M3D_EXP_ASCII) quality = M3D_EXP_DOUBLE;
-#endif
vrtxidx = (M3D_INDEX *)M3D_MALLOC(model->numvertex * sizeof(M3D_INDEX));
if (!vrtxidx) goto memerr;
memset(vrtxidx, 255, model->numvertex * sizeof(M3D_INDEX));
@@ -4800,7 +4770,6 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
}
M3D_LOG("Serializing model");
-#ifdef M3D_ASCII
if (flags & M3D_EXP_ASCII) {
/* use CRLF to make model creators on Win happy... */
sd = _m3d_safestr(model->desc, 1);
@@ -5073,7 +5042,7 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
ptr += sprintf(ptr, "\r\n");
}
/* mathematical shapes face */
- if (model->numshape !(flags & M3D_EXP_NOFACE)) {
+ if (model->numshape && (!(flags & M3D_EXP_NOFACE))) {
for (j = 0; j < model->numshape; j++) {
sn = _m3d_safestr(model->shape[j].name, 0);
if (!sn) {
@@ -5287,7 +5256,6 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
if (!out) goto memerr;
out[len] = 0;
} else
-#endif
{
/* stricly only use LF (newline) in binary */
sd = _m3d_safestr(model->desc, 3);
diff --git a/code/AssetLib/MD2/MD2Loader.cpp b/code/AssetLib/MD2/MD2Loader.cpp
index 9ccbcdfca..b7bf24ef7 100644
--- a/code/AssetLib/MD2/MD2Loader.cpp
+++ b/code/AssetLib/MD2/MD2Loader.cpp
@@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include
#include
#include
+#include
#include
@@ -148,46 +149,39 @@ void MD2Importer::ValidateHeader( )
if (m_pcHeader->magic != AI_MD2_MAGIC_NUMBER_BE &&
m_pcHeader->magic != AI_MD2_MAGIC_NUMBER_LE)
{
- char szBuffer[5];
- szBuffer[0] = ((char*)&m_pcHeader->magic)[0];
- szBuffer[1] = ((char*)&m_pcHeader->magic)[1];
- szBuffer[2] = ((char*)&m_pcHeader->magic)[2];
- szBuffer[3] = ((char*)&m_pcHeader->magic)[3];
- szBuffer[4] = '\0';
-
- throw DeadlyImportError("Invalid MD2 magic word: should be IDP2, the "
- "magic word found is " + std::string(szBuffer));
+ throw DeadlyImportError("Invalid MD2 magic word: expected IDP2, found ",
+ ai_str_toprintable((char *)&m_pcHeader->magic, 4));
}
// check file format version
if (m_pcHeader->version != 8)
- ASSIMP_LOG_WARN( "Unsupported md2 file version. Continuing happily ...");
+ ASSIMP_LOG_WARN( "Unsupported MD2 file version. Continuing happily ...");
// check some values whether they are valid
if (0 == m_pcHeader->numFrames)
- throw DeadlyImportError( "Invalid md2 file: NUM_FRAMES is 0");
+ throw DeadlyImportError( "Invalid MD2 file: NUM_FRAMES is 0");
if (m_pcHeader->offsetEnd > (uint32_t)fileSize)
- throw DeadlyImportError( "Invalid md2 file: File is too small");
+ throw DeadlyImportError( "Invalid MD2 file: File is too small");
if (m_pcHeader->numSkins > AI_MAX_ALLOC(MD2::Skin)) {
- throw DeadlyImportError("Invalid MD2 header: too many skins, would overflow");
+ throw DeadlyImportError("Invalid MD2 header: Too many skins, would overflow");
}
if (m_pcHeader->numVertices > AI_MAX_ALLOC(MD2::Vertex)) {
- throw DeadlyImportError("Invalid MD2 header: too many vertices, would overflow");
+ throw DeadlyImportError("Invalid MD2 header: Too many vertices, would overflow");
}
if (m_pcHeader->numTexCoords > AI_MAX_ALLOC(MD2::TexCoord)) {
- throw DeadlyImportError("Invalid MD2 header: too many texcoords, would overflow");
+ throw DeadlyImportError("Invalid MD2 header: Too many texcoords, would overflow");
}
if (m_pcHeader->numTriangles > AI_MAX_ALLOC(MD2::Triangle)) {
- throw DeadlyImportError("Invalid MD2 header: too many triangles, would overflow");
+ throw DeadlyImportError("Invalid MD2 header: Too many triangles, would overflow");
}
if (m_pcHeader->numFrames > AI_MAX_ALLOC(MD2::Frame)) {
- throw DeadlyImportError("Invalid MD2 header: too many frames, would overflow");
+ throw DeadlyImportError("Invalid MD2 header: Too many frames, would overflow");
}
// -1 because Frame already contains one
@@ -199,7 +193,7 @@ void MD2Importer::ValidateHeader( )
m_pcHeader->offsetFrames + m_pcHeader->numFrames * frameSize >= fileSize ||
m_pcHeader->offsetEnd > fileSize)
{
- throw DeadlyImportError("Invalid MD2 header: some offsets are outside the file");
+ throw DeadlyImportError("Invalid MD2 header: Some offsets are outside the file");
}
if (m_pcHeader->numSkins > AI_MD2_MAX_SKINS)
@@ -210,7 +204,7 @@ void MD2Importer::ValidateHeader( )
ASSIMP_LOG_WARN("The model contains more vertices than Quake 2 supports");
if (m_pcHeader->numFrames <= configFrameID )
- throw DeadlyImportError("The requested frame is not existing the file");
+ throw DeadlyImportError("MD2: The requested frame (", configFrameID, ") does not exist in the file");
}
// ------------------------------------------------------------------------------------------------
@@ -433,10 +427,6 @@ void MD2Importer::InternReadFile( const std::string& pFile,
aiVector3D& vNormal = pcMesh->mNormals[iCurrent];
LookupNormalIndex(pcVerts[iIndex].lightNormalIndex,vNormal);
- // flip z and y to become right-handed
- std::swap((float&)vNormal.z,(float&)vNormal.y);
- std::swap((float&)vec.z,(float&)vec.y);
-
if (m_pcHeader->numTexCoords) {
// validate texture coordinates
iIndex = pcTriangles[i].textureIndices[c];
@@ -454,7 +444,15 @@ void MD2Importer::InternReadFile( const std::string& pFile,
}
pScene->mMeshes[0]->mFaces[i].mIndices[c] = iCurrent;
}
+ // flip the face order
+ std::swap( pScene->mMeshes[0]->mFaces[i].mIndices[0], pScene->mMeshes[0]->mFaces[i].mIndices[2] );
}
+ // Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system
+ pScene->mRootNode->mTransformation = aiMatrix4x4(
+ 1.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 1.f, 0.f,
+ 0.f, -1.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 1.f);
}
#endif // !! ASSIMP_BUILD_NO_MD2_IMPORTER
diff --git a/code/AssetLib/MD2/MD2NormalTable.h b/code/AssetLib/MD2/MD2NormalTable.h
index 3eff0d666..b2330d862 100644
--- a/code/AssetLib/MD2/MD2NormalTable.h
+++ b/code/AssetLib/MD2/MD2NormalTable.h
@@ -51,7 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_MDL_NORMALTABLE_H_INC
-float g_avNormals[162][3] = {
+const float g_avNormals[162][3] = {
{ -0.525731f, 0.000000f, 0.850651f },
{ -0.442863f, 0.238856f, 0.864188f },
{ -0.295242f, 0.000000f, 0.955423f },
diff --git a/code/AssetLib/MD3/MD3Loader.cpp b/code/AssetLib/MD3/MD3Loader.cpp
index e27079766..abaabe47f 100644
--- a/code/AssetLib/MD3/MD3Loader.cpp
+++ b/code/AssetLib/MD3/MD3Loader.cpp
@@ -101,7 +101,7 @@ Q3Shader::BlendFunc StringToBlendFunc(const std::string &m) {
if (m == "GL_ONE_MINUS_DST_COLOR") {
return Q3Shader::BLEND_GL_ONE_MINUS_DST_COLOR;
}
- ASSIMP_LOG_ERROR("Q3Shader: Unknown blend function: " + m);
+ ASSIMP_LOG_ERROR("Q3Shader: Unknown blend function: ", m);
return Q3Shader::BLEND_NONE;
}
@@ -112,7 +112,7 @@ bool Q3Shader::LoadShader(ShaderData &fill, const std::string &pFile, IOSystem *
if (!file.get())
return false; // if we can't access the file, don't worry and return
- ASSIMP_LOG_INFO_F("Loading Quake3 shader file ", pFile);
+ ASSIMP_LOG_INFO("Loading Quake3 shader file ", pFile);
// read file in memory
const size_t s = file->FileSize();
@@ -196,11 +196,11 @@ bool Q3Shader::LoadShader(ShaderData &fill, const std::string &pFile, IOSystem *
// 'cull' specifies culling behaviour for the model
else if (TokenMatchI(buff, "cull", 4)) {
SkipSpaces(&buff);
- if (!ASSIMP_strincmp(buff, "back", 4)) {
+ if (!ASSIMP_strincmp(buff, "back", 4)) { // render face's backside, does not function in Q3 engine (bug)
curData->cull = Q3Shader::CULL_CCW;
- } else if (!ASSIMP_strincmp(buff, "front", 5)) {
+ } else if (!ASSIMP_strincmp(buff, "front", 5)) { // is not valid keyword in Q3, but occurs in shaders
curData->cull = Q3Shader::CULL_CW;
- } else if (!ASSIMP_strincmp(buff, "none", 4) || !ASSIMP_strincmp(buff, "disable", 7)) {
+ } else if (!ASSIMP_strincmp(buff, "none", 4) || !ASSIMP_strincmp(buff, "twosided", 8) || !ASSIMP_strincmp(buff, "disable", 7)) {
curData->cull = Q3Shader::CULL_NONE;
} else {
ASSIMP_LOG_ERROR("Q3Shader: Unrecognized cull mode");
@@ -226,7 +226,7 @@ bool Q3Shader::LoadSkin(SkinData &fill, const std::string &pFile, IOSystem *io)
if (!file.get())
return false; // if we can't access the file, don't worry and return
- ASSIMP_LOG_INFO("Loading Quake3 skin file " + pFile);
+ ASSIMP_LOG_INFO("Loading Quake3 skin file ", pFile);
// read file in memory
const size_t s = file->FileSize();
@@ -450,6 +450,9 @@ void MD3Importer::SetupProperties(const Importer *pImp) {
// AI_CONFIG_IMPORT_MD3_SKIN_NAME
configSkinFile = (pImp->GetPropertyString(AI_CONFIG_IMPORT_MD3_SKIN_NAME, "default"));
+ // AI_CONFIG_IMPORT_MD3_LOAD_SHADERS
+ configLoadShaders = (pImp->GetPropertyBool(AI_CONFIG_IMPORT_MD3_LOAD_SHADERS, true));
+
// AI_CONFIG_IMPORT_MD3_SHADER_SRC
configShaderFile = (pImp->GetPropertyString(AI_CONFIG_IMPORT_MD3_SHADER_SRC, ""));
@@ -483,8 +486,9 @@ void MD3Importer::ReadShader(Q3Shader::ShaderData &fill) const {
// If no specific dir or file is given, use our default search behaviour
if (!configShaderFile.length()) {
- if (!Q3Shader::LoadShader(fill, path + "..\\..\\..\\scripts\\" + model_file + ".shader", mIOHandler)) {
- Q3Shader::LoadShader(fill, path + "..\\..\\..\\scripts\\" + filename + ".shader", mIOHandler);
+ const char sep = mIOHandler->getOsSeparator();
+ if (!Q3Shader::LoadShader(fill, path + ".." + sep + ".." + sep + ".." + sep + "scripts" + sep + model_file + ".shader", mIOHandler)) {
+ Q3Shader::LoadShader(fill, path + ".." + sep + ".." + sep + ".." + sep + "scripts" + sep + filename + ".shader", mIOHandler);
}
} else {
// If the given string specifies a file, load this file.
@@ -702,7 +706,7 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
}
filename = mFile.substr(s), path = mFile.substr(0, s);
for (std::string::iterator it = filename.begin(); it != filename.end(); ++it) {
- *it = static_cast(tolower(*it));
+ *it = static_cast(tolower(static_cast(*it)));
}
// Load multi-part model file, if necessary
@@ -780,7 +784,9 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// And check whether we can locate a shader file for this model
Q3Shader::ShaderData shaders;
- ReadShader(shaders);
+ if (configLoadShaders){
+ ReadShader(shaders);
+ }
// Adjust all texture paths in the shader
const char *header_name = pcHeader->NAME;
@@ -851,7 +857,7 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
if (it != skins.textures.end()) {
texture_name = &*(_texture_name = (*it).second).begin();
- ASSIMP_LOG_VERBOSE_DEBUG_F("MD3: Assigning skin texture ", (*it).second, " to surface ", pcSurfaces->NAME);
+ ASSIMP_LOG_VERBOSE_DEBUG("MD3: Assigning skin texture ", (*it).second, " to surface ", pcSurfaces->NAME);
(*it).resolved = true; // mark entry as resolved
}
@@ -862,7 +868,12 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
std::string convertedPath;
if (texture_name) {
- ConvertPath(texture_name, header_name, convertedPath);
+ if (configLoadShaders){
+ ConvertPath(texture_name, header_name, convertedPath);
+ }
+ else{
+ convertedPath = texture_name;
+ }
}
const Q3Shader::ShaderDataBlock *shader = nullptr;
@@ -880,9 +891,9 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
if (dit != shaders.blocks.end()) {
// We made it!
shader = &*dit;
- ASSIMP_LOG_INFO("Found shader record for " + without_ext);
+ ASSIMP_LOG_INFO("Found shader record for ", without_ext);
} else {
- ASSIMP_LOG_WARN("Unable to find shader record for " + without_ext);
+ ASSIMP_LOG_WARN("Unable to find shader record for ", without_ext);
}
}
@@ -985,8 +996,8 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
pcMesh->mTextureCoords[0][iCurrent].x = pcUVs[index].U;
pcMesh->mTextureCoords[0][iCurrent].y = 1.0f - pcUVs[index].V;
}
- // Flip face order if necessary
- if (!shader || shader->cull == Q3Shader::CULL_CW) {
+ // Flip face order normally, unless shader is backfacing
+ if (!(shader && shader->cull == Q3Shader::CULL_CCW)) {
std::swap(pcMesh->mFaces[i].mIndices[2], pcMesh->mFaces[i].mIndices[1]);
}
++pcTriangles;
@@ -1000,7 +1011,7 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
if (!DefaultLogger::isNullLogger()) {
for (std::list::const_iterator it = skins.textures.begin(); it != skins.textures.end(); ++it) {
if (!(*it).resolved) {
- ASSIMP_LOG_ERROR_F("MD3: Failed to match skin ", (*it).first, " to surface ", (*it).second);
+ ASSIMP_LOG_ERROR("MD3: Failed to match skin ", (*it).first, " to surface ", (*it).second);
}
}
}
diff --git a/code/AssetLib/MD3/MD3Loader.h b/code/AssetLib/MD3/MD3Loader.h
index d34df2d77..1a4e5982c 100644
--- a/code/AssetLib/MD3/MD3Loader.h
+++ b/code/AssetLib/MD3/MD3Loader.h
@@ -297,6 +297,9 @@ protected:
/** Configuration option: name of skin file to be read */
std::string configSkinFile;
+ /** Configuration option: whether to load shaders */
+ bool configLoadShaders;
+
/** Configuration option: name or path of shader */
std::string configShaderFile;
diff --git a/code/AssetLib/MD5/MD5Loader.cpp b/code/AssetLib/MD5/MD5Loader.cpp
index b99638cd2..0d9c77b71 100644
--- a/code/AssetLib/MD5/MD5Loader.cpp
+++ b/code/AssetLib/MD5/MD5Loader.cpp
@@ -345,7 +345,7 @@ void MD5Importer::LoadMD5MeshFile() {
// Check whether we can read from the file
if (file.get() == nullptr || !file->FileSize()) {
- ASSIMP_LOG_WARN("Failed to access MD5MESH file: " + filename);
+ ASSIMP_LOG_WARN("Failed to access MD5MESH file: ", filename);
return;
}
mHadMD5Mesh = true;
@@ -567,7 +567,7 @@ void MD5Importer::LoadMD5AnimFile() {
// Check whether we can read from the file
if (!file.get() || !file->FileSize()) {
- ASSIMP_LOG_WARN("Failed to read MD5ANIM file: " + pFile);
+ ASSIMP_LOG_WARN("Failed to read MD5ANIM file: ", pFile);
return;
}
diff --git a/code/AssetLib/MDC/MDCLoader.cpp b/code/AssetLib/MDC/MDCLoader.cpp
index 17a349768..8f089bbd8 100644
--- a/code/AssetLib/MDC/MDCLoader.cpp
+++ b/code/AssetLib/MDC/MDCLoader.cpp
@@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include
#include
#include
+#include
#include
@@ -143,16 +144,8 @@ void MDCImporter::ValidateHeader() {
if (pcHeader->ulIdent != AI_MDC_MAGIC_NUMBER_BE &&
pcHeader->ulIdent != AI_MDC_MAGIC_NUMBER_LE) {
- char szBuffer[5];
- szBuffer[0] = ((char *)&pcHeader->ulIdent)[0];
- szBuffer[1] = ((char *)&pcHeader->ulIdent)[1];
- szBuffer[2] = ((char *)&pcHeader->ulIdent)[2];
- szBuffer[3] = ((char *)&pcHeader->ulIdent)[3];
- szBuffer[4] = '\0';
-
- throw DeadlyImportError("Invalid MDC magic word: should be IDPC, the "
- "magic word found is " +
- std::string(szBuffer));
+ throw DeadlyImportError("Invalid MDC magic word: expected IDPC, found ",
+ ai_str_toprintable((char *)&pcHeader->ulIdent, 4));
}
if (pcHeader->ulVersion != AI_MDC_VERSION) {
@@ -465,6 +458,13 @@ void MDCImporter::InternReadFile(
pcMat->AddProperty(&path, AI_MATKEY_TEXTURE_DIFFUSE(0));
}
}
+
+ // Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system
+ pScene->mRootNode->mTransformation = aiMatrix4x4(
+ 1.f, 0.f, 0.f, 0.f,
+ 0.f, 0.f, 1.f, 0.f,
+ 0.f, -1.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 1.f);
}
#endif // !! ASSIMP_BUILD_NO_MDC_IMPORTER
diff --git a/code/AssetLib/MDC/MDCNormalTable.h b/code/AssetLib/MDC/MDCNormalTable.h
index f47e97f33..c96eba7bd 100644
--- a/code/AssetLib/MDC/MDCNormalTable.h
+++ b/code/AssetLib/MDC/MDCNormalTable.h
@@ -36,7 +36,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define MDC_NORMAL_TABLE_INCLUDED
/* mdc decoding normal table */
-float mdcNormals[ 256 ][ 3 ] =
+const float mdcNormals[ 256 ][ 3 ] =
{
{ 1.000000f, 0.000000f, 0.000000f },
{ 0.980785f, 0.195090f, 0.000000f },
diff --git a/code/AssetLib/MDL/HalfLife/HL1MDLLoader.cpp b/code/AssetLib/MDL/HalfLife/HL1MDLLoader.cpp
index 4df0d0d1d..e6576b344 100644
--- a/code/AssetLib/MDL/HalfLife/HL1MDLLoader.cpp
+++ b/code/AssetLib/MDL/HalfLife/HL1MDLLoader.cpp
@@ -57,6 +57,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include
#include
+#include