Merge branch 'master' into master

pull/3967/head
Kim Kulling 2021-07-01 19:23:52 +02:00 committed by GitHub
commit 240eb36980
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 167 additions and 154 deletions

View File

@ -348,16 +348,16 @@ struct Texture {
// empty // empty
} }
Texture(Texture &&other) AI_NO_EXCEPT : mTextureBlend(std::move(other.mTextureBlend)), Texture(Texture &&other) AI_NO_EXCEPT : mTextureBlend(other.mTextureBlend),
mMapName(std::move(other.mMapName)), mMapName(std::move(other.mMapName)),
mOffsetU(std::move(other.mOffsetU)), mOffsetU(other.mOffsetU),
mOffsetV(std::move(other.mOffsetV)), mOffsetV(other.mOffsetV),
mScaleU(std::move(other.mScaleU)), mScaleU(other.mScaleU),
mScaleV(std::move(other.mScaleV)), mScaleV(other.mScaleV),
mRotation(std::move(other.mRotation)), mRotation(other.mRotation),
mMapMode(std::move(other.mMapMode)), mMapMode(other.mMapMode),
bPrivate(std::move(other.bPrivate)), bPrivate(other.bPrivate),
iUVSrc(std::move(other.iUVSrc)) { iUVSrc(other.iUVSrc) {
// empty // empty
} }
@ -366,16 +366,16 @@ struct Texture {
return *this; return *this;
} }
mTextureBlend = std::move(other.mTextureBlend); mTextureBlend = other.mTextureBlend;
mMapName = std::move(other.mMapName); mMapName = std::move(other.mMapName);
mOffsetU = std::move(other.mOffsetU); mOffsetU = other.mOffsetU;
mOffsetV = std::move(other.mOffsetV); mOffsetV = other.mOffsetV;
mScaleU = std::move(other.mScaleU); mScaleU = other.mScaleU;
mScaleV = std::move(other.mScaleV); mScaleV = other.mScaleV;
mRotation = std::move(other.mRotation); mRotation = other.mRotation;
mMapMode = std::move(other.mMapMode); mMapMode = other.mMapMode;
bPrivate = std::move(other.bPrivate); bPrivate = other.bPrivate;
iUVSrc = std::move(other.iUVSrc); iUVSrc = other.iUVSrc;
return *this; return *this;
} }
@ -461,13 +461,13 @@ struct Material {
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it //! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
Material(Material &&other) AI_NO_EXCEPT : mName(std::move(other.mName)), Material(Material &&other) AI_NO_EXCEPT : mName(std::move(other.mName)),
mDiffuse(std::move(other.mDiffuse)), mDiffuse(other.mDiffuse),
mSpecularExponent(std::move(other.mSpecularExponent)), mSpecularExponent(other.mSpecularExponent),
mShininessStrength(std::move(other.mShininessStrength)), mShininessStrength(other.mShininessStrength),
mSpecular(std::move(other.mSpecular)), mSpecular(other.mSpecular),
mAmbient(std::move(other.mAmbient)), mAmbient(other.mAmbient),
mShading(std::move(other.mShading)), mShading(other.mShading),
mTransparency(std::move(other.mTransparency)), mTransparency(other.mTransparency),
sTexDiffuse(std::move(other.sTexDiffuse)), sTexDiffuse(std::move(other.sTexDiffuse)),
sTexOpacity(std::move(other.sTexOpacity)), sTexOpacity(std::move(other.sTexOpacity)),
sTexSpecular(std::move(other.sTexSpecular)), sTexSpecular(std::move(other.sTexSpecular)),
@ -475,10 +475,10 @@ struct Material {
sTexBump(std::move(other.sTexBump)), sTexBump(std::move(other.sTexBump)),
sTexEmissive(std::move(other.sTexEmissive)), sTexEmissive(std::move(other.sTexEmissive)),
sTexShininess(std::move(other.sTexShininess)), sTexShininess(std::move(other.sTexShininess)),
mBumpHeight(std::move(other.mBumpHeight)), mBumpHeight(other.mBumpHeight),
mEmissive(std::move(other.mEmissive)), mEmissive(other.mEmissive),
sTexAmbient(std::move(other.sTexAmbient)), sTexAmbient(std::move(other.sTexAmbient)),
mTwoSided(std::move(other.mTwoSided)) { mTwoSided(other.mTwoSided) {
// empty // empty
} }
@ -488,13 +488,13 @@ struct Material {
} }
mName = std::move(other.mName); mName = std::move(other.mName);
mDiffuse = std::move(other.mDiffuse); mDiffuse = other.mDiffuse;
mSpecularExponent = std::move(other.mSpecularExponent); mSpecularExponent = other.mSpecularExponent;
mShininessStrength = std::move(other.mShininessStrength), mShininessStrength = other.mShininessStrength,
mSpecular = std::move(other.mSpecular); mSpecular = other.mSpecular;
mAmbient = std::move(other.mAmbient); mAmbient = other.mAmbient;
mShading = std::move(other.mShading); mShading = other.mShading;
mTransparency = std::move(other.mTransparency); mTransparency = other.mTransparency;
sTexDiffuse = std::move(other.sTexDiffuse); sTexDiffuse = std::move(other.sTexDiffuse);
sTexOpacity = std::move(other.sTexOpacity); sTexOpacity = std::move(other.sTexOpacity);
sTexSpecular = std::move(other.sTexSpecular); sTexSpecular = std::move(other.sTexSpecular);
@ -502,10 +502,10 @@ struct Material {
sTexBump = std::move(other.sTexBump); sTexBump = std::move(other.sTexBump);
sTexEmissive = std::move(other.sTexEmissive); sTexEmissive = std::move(other.sTexEmissive);
sTexShininess = std::move(other.sTexShininess); sTexShininess = std::move(other.sTexShininess);
mBumpHeight = std::move(other.mBumpHeight); mBumpHeight = other.mBumpHeight;
mEmissive = std::move(other.mEmissive); mEmissive = other.mEmissive;
sTexAmbient = std::move(other.sTexAmbient); sTexAmbient = std::move(other.sTexAmbient);
mTwoSided = std::move(other.mTwoSided); mTwoSided = other.mTwoSided;
return *this; return *this;
} }

View File

@ -95,8 +95,8 @@ struct Material : public D3DS::Material {
Material(Material &&other) AI_NO_EXCEPT Material(Material &&other) AI_NO_EXCEPT
: D3DS::Material(std::move(other)), : D3DS::Material(std::move(other)),
avSubMaterials(std::move(other.avSubMaterials)), avSubMaterials(std::move(other.avSubMaterials)),
pcInstance(std::move(other.pcInstance)), pcInstance(other.pcInstance),
bNeed(std::move(other.bNeed)) { bNeed(other.bNeed) {
other.pcInstance = nullptr; other.pcInstance = nullptr;
} }
@ -108,8 +108,8 @@ struct Material : public D3DS::Material {
//D3DS::Material::operator=(std::move(other)); //D3DS::Material::operator=(std::move(other));
avSubMaterials = std::move(other.avSubMaterials); avSubMaterials = std::move(other.avSubMaterials);
pcInstance = std::move(other.pcInstance); pcInstance = other.pcInstance;
bNeed = std::move(other.bNeed); bNeed = other.bNeed;
other.pcInstance = nullptr; other.pcInstance = nullptr;

View File

@ -143,7 +143,7 @@ AI_WONT_RETURN void B3DImporter::Oops() {
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
AI_WONT_RETURN void B3DImporter::Fail(string str) { AI_WONT_RETURN void B3DImporter::Fail(const string &str) {
#ifdef DEBUG_B3D #ifdef DEBUG_B3D
ASSIMP_LOG_ERROR("Error in B3D file data: ", str); ASSIMP_LOG_ERROR("Error in B3D file data: ", str);
#endif #endif

View File

@ -96,7 +96,7 @@ private:
}; };
AI_WONT_RETURN void Oops() AI_WONT_RETURN_SUFFIX; AI_WONT_RETURN void Oops() AI_WONT_RETURN_SUFFIX;
AI_WONT_RETURN void Fail( std::string str ) AI_WONT_RETURN_SUFFIX; AI_WONT_RETURN void Fail(const std::string &str) AI_WONT_RETURN_SUFFIX;
void ReadTEXS(); void ReadTEXS();
void ReadBRUS(); void ReadBRUS();

View File

@ -679,7 +679,7 @@ void BlenderImporter::BuildMaterials(ConversionData &conv_data) {
BuildDefaultMaterial(conv_data); BuildDefaultMaterial(conv_data);
for (std::shared_ptr<Material> mat : conv_data.materials_raw) { for (const std::shared_ptr<Material> &mat : conv_data.materials_raw) {
// reset per material global counters // reset per material global counters
for (size_t i = 0; i < sizeof(conv_data.next_texture) / sizeof(conv_data.next_texture[0]); ++i) { for (size_t i = 0; i < sizeof(conv_data.next_texture) / sizeof(conv_data.next_texture[0]); ++i) {

View File

@ -230,7 +230,7 @@ void COBImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void ConvertTexture(std::shared_ptr<Texture> tex, aiMaterial *out, aiTextureType type) { void ConvertTexture(const std::shared_ptr<Texture> &tex, aiMaterial *out, aiTextureType type) {
const aiString path(tex->path); const aiString path(tex->path);
out->AddProperty(&path, AI_MATKEY_TEXTURE(type, 0)); out->AddProperty(&path, AI_MATKEY_TEXTURE(type, 0));
out->AddProperty(&tex->transform, 1, AI_MATKEY_UVTRANSFORM(type, 0)); out->AddProperty(&tex->transform, 1, AI_MATKEY_UVTRANSFORM(type, 0));

View File

@ -453,7 +453,7 @@ void ColladaParser::PostProcessRootAnimations() {
temp.mSubAnims.push_back(clip); temp.mSubAnims.push_back(clip);
for (std::string animationID : it.second) { for (const std::string &animationID : it.second) {
AnimationLibrary::iterator animation = mAnimationLibrary.find(animationID); AnimationLibrary::iterator animation = mAnimationLibrary.find(animationID);
if (animation != mAnimationLibrary.end()) { if (animation != mAnimationLibrary.end()) {

View File

@ -1766,6 +1766,7 @@ void FBXConverter::TrySetTextureProperties(aiMaterial *out_mat, const TextureMap
// XXX handle all kinds of UV transformations // XXX handle all kinds of UV transformations
uvTrafo.mScaling = tex->UVScaling(); uvTrafo.mScaling = tex->UVScaling();
uvTrafo.mTranslation = tex->UVTranslation(); uvTrafo.mTranslation = tex->UVTranslation();
uvTrafo.mRotation = tex->UVRotation();
out_mat->AddProperty(&uvTrafo, 1, _AI_MATKEY_UVTRANSFORM_BASE, target, 0); out_mat->AddProperty(&uvTrafo, 1, _AI_MATKEY_UVTRANSFORM_BASE, target, 0);
const PropertyTable &props = tex->Props(); const PropertyTable &props = tex->Props();
@ -1885,6 +1886,7 @@ void FBXConverter::TrySetTextureProperties(aiMaterial *out_mat, const LayeredTex
// XXX handle all kinds of UV transformations // XXX handle all kinds of UV transformations
uvTrafo.mScaling = tex->UVScaling(); uvTrafo.mScaling = tex->UVScaling();
uvTrafo.mTranslation = tex->UVTranslation(); uvTrafo.mTranslation = tex->UVTranslation();
uvTrafo.mRotation = tex->UVRotation();
out_mat->AddProperty(&uvTrafo, 1, _AI_MATKEY_UVTRANSFORM_BASE, target, texIndex); out_mat->AddProperty(&uvTrafo, 1, _AI_MATKEY_UVTRANSFORM_BASE, target, texIndex);
const PropertyTable &props = tex->Props(); const PropertyTable &props = tex->Props();
@ -2324,6 +2326,7 @@ void FBXConverter::SetShadingPropertiesRaw(aiMaterial *out_mat, const PropertyTa
// XXX handle all kinds of UV transformations // XXX handle all kinds of UV transformations
uvTrafo.mScaling = tex->UVScaling(); uvTrafo.mScaling = tex->UVScaling();
uvTrafo.mTranslation = tex->UVTranslation(); uvTrafo.mTranslation = tex->UVTranslation();
uvTrafo.mRotation = tex->UVRotation();
out_mat->AddProperty(&uvTrafo, 1, (name + "|uvtrafo").c_str(), aiTextureType_UNKNOWN, 0); out_mat->AddProperty(&uvTrafo, 1, (name + "|uvtrafo").c_str(), aiTextureType_UNKNOWN, 0);
int uvIndex = 0; int uvIndex = 0;
@ -2599,7 +2602,7 @@ void FBXConverter::ConvertAnimationStack(const AnimationStack &st) {
anim->mMorphMeshChannels = new aiMeshMorphAnim *[numMorphMeshChannels]; anim->mMorphMeshChannels = new aiMeshMorphAnim *[numMorphMeshChannels];
anim->mNumMorphMeshChannels = numMorphMeshChannels; anim->mNumMorphMeshChannels = numMorphMeshChannels;
unsigned int i = 0; unsigned int i = 0;
for (auto morphAnimIt : morphAnimDatas) { for (const auto &morphAnimIt : morphAnimDatas) {
morphAnimData *animData = morphAnimIt.second; morphAnimData *animData = morphAnimIt.second;
unsigned int numKeys = static_cast<unsigned int>(animData->size()); unsigned int numKeys = static_cast<unsigned int>(animData->size());
aiMeshMorphAnim *meshMorphAnim = new aiMeshMorphAnim(); aiMeshMorphAnim *meshMorphAnim = new aiMeshMorphAnim();

View File

@ -57,9 +57,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
#include <memory>
#include <functional> #include <functional>
#include <map> #include <map>
#include <memory>
#include <utility>
namespace Assimp { namespace Assimp {
namespace FBX { namespace FBX {
@ -248,10 +249,8 @@ Object::~Object()
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
FileGlobalSettings::FileGlobalSettings(const Document& doc, std::shared_ptr<const PropertyTable> props) FileGlobalSettings::FileGlobalSettings(const Document &doc, std::shared_ptr<const PropertyTable> props) :
: props(props) props(std::move(props)), doc(doc) {
, doc(doc)
{
// empty // empty
} }

View File

@ -500,6 +500,10 @@ public:
return uvScaling; return uvScaling;
} }
const ai_real &UVRotation() const {
return uvRotation;
}
const PropertyTable& Props() const { const PropertyTable& Props() const {
ai_assert(props.get()); ai_assert(props.get());
return *props.get(); return *props.get();
@ -517,6 +521,7 @@ public:
private: private:
aiVector2D uvTrans; aiVector2D uvTrans;
aiVector2D uvScaling; aiVector2D uvScaling;
ai_real uvRotation;
std::string type; std::string type;
std::string relativeFileName; std::string relativeFileName;

View File

@ -144,9 +144,8 @@ void FBX::Node::AddP70time(
// public member functions for writing nodes to stream // public member functions for writing nodes to stream
void FBX::Node::Dump( void FBX::Node::Dump(
std::shared_ptr<Assimp::IOStream> outfile, const std::shared_ptr<Assimp::IOStream> &outfile,
bool binary, int indent bool binary, int indent) {
) {
if (binary) { if (binary) {
Assimp::StreamWriterLE outstream(outfile); Assimp::StreamWriterLE outstream(outfile);
DumpBinary(outstream); DumpBinary(outstream);

View File

@ -157,9 +157,8 @@ public: // member functions for writing data to a file or stream
// write the full node to the given file or stream // write the full node to the given file or stream
void Dump( void Dump(
std::shared_ptr<Assimp::IOStream> outfile, const std::shared_ptr<Assimp::IOStream> &outfile,
bool binary, int indent bool binary, int indent);
);
void Dump(Assimp::StreamWriterLE &s, bool binary, int indent); void Dump(Assimp::StreamWriterLE &s, bool binary, int indent);
// these other functions are for writing data piece by piece. // these other functions are for writing data piece by piece.

View File

@ -1688,6 +1688,10 @@ void FBXExporter::WriteObjects ()
// link the image data to the texture // link the image data to the texture
connections.emplace_back("C", "OO", image_uid, texture_uid); connections.emplace_back("C", "OO", image_uid, texture_uid);
aiUVTransform trafo;
unsigned int max = sizeof(aiUVTransform);
aiGetMaterialFloatArray(mat, AI_MATKEY_UVTRANSFORM(aiTextureType_DIFFUSE, 0), (float *)&trafo, &max);
// now write the actual texture node // now write the actual texture node
FBX::Node tnode("Texture"); FBX::Node tnode("Texture");
// TODO: some way to determine texture name? // TODO: some way to determine texture name?
@ -1698,6 +1702,9 @@ void FBXExporter::WriteObjects ()
tnode.AddChild("Version", int32_t(202)); tnode.AddChild("Version", int32_t(202));
tnode.AddChild("TextureName", texture_name); tnode.AddChild("TextureName", texture_name);
FBX::Node p("Properties70"); FBX::Node p("Properties70");
p.AddP70vectorA("Translation", trafo.mTranslation[0], trafo.mTranslation[1], 0.0);
p.AddP70vectorA("Rotation", 0, 0, trafo.mRotation);
p.AddP70vectorA("Scaling", trafo.mScaling[0], trafo.mScaling[1], 0.0);
p.AddP70enum("CurrentTextureBlendMode", 0); // TODO: verify p.AddP70enum("CurrentTextureBlendMode", 0); // TODO: verify
//p.AddP70string("UVSet", ""); // TODO: how should this work? //p.AddP70string("UVSet", ""); // TODO: how should this work?
p.AddP70bool("UseMaterial", 1); p.AddP70bool("UseMaterial", 1);
@ -2718,16 +2725,14 @@ void FBXExporter::WriteModelNodes(
} }
} }
void FBXExporter::WriteAnimationCurveNode( void FBXExporter::WriteAnimationCurveNode(
StreamWriterLE &outstream, StreamWriterLE &outstream,
int64_t uid, int64_t uid,
const std::string &name, // "T", "R", or "S" const std::string &name, // "T", "R", or "S"
aiVector3D default_value, aiVector3D default_value,
std::string property_name, // "Lcl Translation" etc const std::string &property_name, // "Lcl Translation" etc
int64_t layer_uid, int64_t layer_uid,
int64_t node_uid int64_t node_uid) {
) {
FBX::Node n("AnimationCurveNode"); FBX::Node n("AnimationCurveNode");
n.AddProperties(uid, name + FBX::SEPARATOR + "AnimCurveNode", ""); n.AddProperties(uid, name + FBX::SEPARATOR + "AnimCurveNode", "");
FBX::Node p("Properties70"); FBX::Node p("Properties70");
@ -2742,7 +2747,6 @@ void FBXExporter::WriteAnimationCurveNode(
this->connections.emplace_back("C", "OP", uid, node_uid, property_name); this->connections.emplace_back("C", "OP", uid, node_uid, property_name);
} }
void FBXExporter::WriteAnimationCurve( void FBXExporter::WriteAnimationCurve(
StreamWriterLE& outstream, StreamWriterLE& outstream,
double default_value, double default_value,

View File

@ -158,10 +158,9 @@ namespace Assimp {
int64_t uid, int64_t uid,
const std::string &name, // "T", "R", or "S" const std::string &name, // "T", "R", or "S"
aiVector3D default_value, aiVector3D default_value,
std::string property_name, // "Lcl Translation" etc const std::string &property_name, // "Lcl Translation" etc
int64_t animation_layer_uid, int64_t animation_layer_uid,
int64_t node_uid int64_t node_uid);
);
void WriteAnimationCurve( void WriteAnimationCurve(
StreamWriterLE& outstream, StreamWriterLE& outstream,
double default_value, double default_value,

View File

@ -210,6 +210,11 @@ Texture::Texture(uint64_t id, const Element& element, const Document& doc, const
uvTrans.y = trans.y; uvTrans.y = trans.y;
} }
const aiVector3D &rotation = PropertyGet<aiVector3D>(*props, "Rotation", ok);
if (ok) {
uvRotation = rotation.z;
}
// resolve video links // resolve video links
if(doc.Settings().readTextures) { if(doc.Settings().readTextures) {
const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID()); const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID());

View File

@ -52,6 +52,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FBXDocumentUtil.h" #include "FBXDocumentUtil.h"
#include "FBXProperties.h" #include "FBXProperties.h"
#include <utility>
namespace Assimp { namespace Assimp {
namespace FBX { namespace FBX {
@ -172,10 +174,8 @@ PropertyTable::PropertyTable()
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
PropertyTable::PropertyTable(const Element& element, std::shared_ptr<const PropertyTable> templateProps) PropertyTable::PropertyTable(const Element &element, std::shared_ptr<const PropertyTable> templateProps) :
: templateProps(templateProps) templateProps(std::move(templateProps)), element(&element) {
, element(&element)
{
const Scope& scope = GetRequiredScope(element); const Scope& scope = GetRequiredScope(element);
for(const ElementMap::value_type& v : scope.Elements()) { for(const ElementMap::value_type& v : scope.Elements()) {
if(v.first != "P") { if(v.first != "P") {
@ -199,7 +199,6 @@ PropertyTable::PropertyTable(const Element& element, std::shared_ptr<const Prope
} }
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
PropertyTable::~PropertyTable() PropertyTable::~PropertyTable()
{ {

View File

@ -740,7 +740,7 @@ bool ProcessGeometricItem(const Schema_2x3::IfcRepresentationItem& geo, unsigned
bool fix_orientation = false; bool fix_orientation = false;
std::shared_ptr< TempMesh > meshtmp = std::make_shared<TempMesh>(); std::shared_ptr< TempMesh > meshtmp = std::make_shared<TempMesh>();
if(const Schema_2x3::IfcShellBasedSurfaceModel* shellmod = geo.ToPtr<Schema_2x3::IfcShellBasedSurfaceModel>()) { if(const Schema_2x3::IfcShellBasedSurfaceModel* shellmod = geo.ToPtr<Schema_2x3::IfcShellBasedSurfaceModel>()) {
for(std::shared_ptr<const Schema_2x3::IfcShell> shell :shellmod->SbsmBoundary) { for (const std::shared_ptr<const Schema_2x3::IfcShell> &shell : shellmod->SbsmBoundary) {
try { try {
const ::Assimp::STEP::EXPRESS::ENTITY& e = shell->To<::Assimp::STEP::EXPRESS::ENTITY>(); const ::Assimp::STEP::EXPRESS::ENTITY& e = shell->To<::Assimp::STEP::EXPRESS::ENTITY>();
const Schema_2x3::IfcConnectedFaceSet& fs = conv.db.MustGetObject(e).To<Schema_2x3::IfcConnectedFaceSet>(); const Schema_2x3::IfcConnectedFaceSet& fs = conv.db.MustGetObject(e).To<Schema_2x3::IfcConnectedFaceSet>();

View File

@ -75,7 +75,7 @@ static void FillMaterial(aiMaterial* mat,const IFC::Schema_2x3::IfcSurfaceStyle*
mat->AddProperty(&name,AI_MATKEY_NAME); mat->AddProperty(&name,AI_MATKEY_NAME);
// now see which kinds of surface information are present // now see which kinds of surface information are present
for(std::shared_ptr< const IFC::Schema_2x3::IfcSurfaceStyleElementSelect > sel2 : surf->Styles) { for (const std::shared_ptr<const IFC::Schema_2x3::IfcSurfaceStyleElementSelect> &sel2 : surf->Styles) {
if (const IFC::Schema_2x3::IfcSurfaceStyleShading* shade = sel2->ResolveSelectPtr<IFC::Schema_2x3::IfcSurfaceStyleShading>(conv.db)) { if (const IFC::Schema_2x3::IfcSurfaceStyleShading* shade = sel2->ResolveSelectPtr<IFC::Schema_2x3::IfcSurfaceStyleShading>(conv.db)) {
aiColor4D col_base,col; aiColor4D col_base,col;
@ -134,7 +134,7 @@ unsigned int ProcessMaterials(uint64_t id, unsigned int prevMatId, ConversionDat
for(;range.first != range.second; ++range.first) { for(;range.first != range.second; ++range.first) {
if(const IFC::Schema_2x3::IfcStyledItem* const styled = conv.db.GetObject((*range.first).second)->ToPtr<IFC::Schema_2x3::IfcStyledItem>()) { if(const IFC::Schema_2x3::IfcStyledItem* const styled = conv.db.GetObject((*range.first).second)->ToPtr<IFC::Schema_2x3::IfcStyledItem>()) {
for(const IFC::Schema_2x3::IfcPresentationStyleAssignment& as : styled->Styles) { for(const IFC::Schema_2x3::IfcPresentationStyleAssignment& as : styled->Styles) {
for(std::shared_ptr<const IFC::Schema_2x3::IfcPresentationStyleSelect> sel : as.Styles) { for (const std::shared_ptr<const IFC::Schema_2x3::IfcPresentationStyleSelect> &sel : as.Styles) {
if( const IFC::Schema_2x3::IfcSurfaceStyle* const surf = sel->ResolveSelectPtr<IFC::Schema_2x3::IfcSurfaceStyle>(conv.db) ) { if( const IFC::Schema_2x3::IfcSurfaceStyle* const surf = sel->ResolveSelectPtr<IFC::Schema_2x3::IfcSurfaceStyle>(conv.db) ) {
// try to satisfy from cache // try to satisfy from cache

View File

@ -54,6 +54,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/mesh.h> #include <assimp/mesh.h>
#include <assimp/material.h> #include <assimp/material.h>
#include <utility>
struct aiNode; struct aiNode;
namespace Assimp { namespace Assimp {
@ -139,12 +141,8 @@ struct TempOpening
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
TempOpening(const IFC::Schema_2x3::IfcSolidModel *solid, IfcVector3 extrusionDir, TempOpening(const IFC::Schema_2x3::IfcSolidModel *solid, IfcVector3 extrusionDir,
std::shared_ptr<TempMesh> profileMesh, std::shared_ptr<TempMesh> profileMesh,
std::shared_ptr<TempMesh> profileMesh2D) std::shared_ptr<TempMesh> profileMesh2D) :
: solid(solid) solid(solid), extrusionDir(extrusionDir), profileMesh(std::move(profileMesh)), profileMesh2D(std::move(profileMesh2D)) {
, extrusionDir(extrusionDir)
, profileMesh(profileMesh)
, profileMesh2D(profileMesh2D)
{
} }
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------

View File

@ -318,7 +318,7 @@ void LWSImporter::SetupNodeName(aiNode *nd, LWS::NodeDesc &src) {
} else { } else {
++s; ++s;
} }
std::string::size_type t = src.path.substr(s).find_last_of("."); std::string::size_type t = src.path.substr(s).find_last_of('.');
nd->mName.length = ::ai_snprintf(nd->mName.data, MAXLEN, "%s_(%08X)", src.path.substr(s).substr(0, t).c_str(), combined); nd->mName.length = ::ai_snprintf(nd->mName.data, MAXLEN, "%s_(%08X)", src.path.substr(s).substr(0, t).c_str(), combined);
return; return;

View File

@ -655,7 +655,7 @@ void M3DImporter::convertPose(const M3DWrapper &m3d, aiMatrix4x4 *m, unsigned in
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// find a node by name // find a node by name
aiNode *M3DImporter::findNode(aiNode *pNode, aiString name) { aiNode *M3DImporter::findNode(aiNode *pNode, const aiString &name) {
ai_assert(pNode != nullptr); ai_assert(pNode != nullptr);
ai_assert(mScene != nullptr); ai_assert(mScene != nullptr);

View File

@ -89,7 +89,7 @@ private:
// helper functions // helper functions
aiColor4D mkColor(uint32_t c); aiColor4D mkColor(uint32_t c);
void convertPose(const M3DWrapper &m3d, aiMatrix4x4 *m, unsigned int posid, unsigned int orientid); void convertPose(const M3DWrapper &m3d, aiMatrix4x4 *m, unsigned int posid, unsigned int orientid);
aiNode *findNode(aiNode *pNode, aiString name); aiNode *findNode(aiNode *pNode, const aiString &name);
void calculateOffsetMatrix(aiNode *pNode, aiMatrix4x4 *m); void calculateOffsetMatrix(aiNode *pNode, aiMatrix4x4 *m);
void populateMesh(const M3DWrapper &m3d, aiMesh *pMesh, std::vector<aiFace> *faces, std::vector<aiVector3D> *verteces, void populateMesh(const M3DWrapper &m3d, aiMesh *pMesh, std::vector<aiFace> *faces, std::vector<aiVector3D> *verteces,
std::vector<aiVector3D> *normals, std::vector<aiVector3D> *texcoords, std::vector<aiColor4D> *colors, std::vector<aiVector3D> *normals, std::vector<aiVector3D> *texcoords, std::vector<aiColor4D> *colors,

View File

@ -415,8 +415,8 @@ bool OgreImporter::ReadTextureUnit(const std::string &textureUnitName, stringstr
// User defined Assimp config property to detect texture type from filename. // User defined Assimp config property to detect texture type from filename.
if (m_detectTextureTypeFromFilename) { if (m_detectTextureTypeFromFilename) {
size_t posSuffix = textureRef.find_last_of("."); size_t posSuffix = textureRef.find_last_of('.');
size_t posUnderscore = textureRef.find_last_of("_"); size_t posUnderscore = textureRef.find_last_of('_');
if (posSuffix != string::npos && posUnderscore != string::npos && posSuffix > posUnderscore) { if (posSuffix != string::npos && posUnderscore != string::npos && posSuffix > posUnderscore) {
string identifier = ai_tolower(textureRef.substr(posUnderscore, posSuffix - posUnderscore)); string identifier = ai_tolower(textureRef.substr(posUnderscore, posSuffix - posUnderscore));

View File

@ -99,7 +99,7 @@ static void extractIds(const std::string &key, int &id1, int &id2) {
return; return;
} }
const std::string::size_type pos = key.find("."); const std::string::size_type pos = key.find('.');
if (std::string::npos == pos) { if (std::string::npos == pos) {
return; return;
} }
@ -208,7 +208,7 @@ void Q3BSPFileImporter::separateMapName(const std::string &importName, std::stri
return; return;
} }
const std::string::size_type pos = importName.rfind(","); const std::string::size_type pos = importName.rfind(',');
if (std::string::npos == pos) { if (std::string::npos == pos) {
archiveName = importName; archiveName = importName;
return; return;

View File

@ -49,8 +49,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "STEPFileEncoding.h" #include "STEPFileEncoding.h"
#include <assimp/TinyFormatter.h> #include <assimp/TinyFormatter.h>
#include <assimp/fast_atof.h> #include <assimp/fast_atof.h>
#include <memory>
#include <functional> #include <functional>
#include <memory>
#include <utility>
using namespace Assimp; using namespace Assimp;
@ -87,7 +88,7 @@ static const char *ISO_Token = "ISO-10303-21;";
static const char *FILE_SCHEMA_Token = "FILE_SCHEMA"; static const char *FILE_SCHEMA_Token = "FILE_SCHEMA";
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
STEP::DB* STEP::ReadFileHeader(std::shared_ptr<IOStream> stream) { STEP::DB* STEP::ReadFileHeader(std::shared_ptr<IOStream> stream) {
std::shared_ptr<StreamReaderLE> reader = std::shared_ptr<StreamReaderLE>(new StreamReaderLE(stream)); std::shared_ptr<StreamReaderLE> reader = std::shared_ptr<StreamReaderLE>(new StreamReaderLE(std::move(stream)));
std::unique_ptr<STEP::DB> db = std::unique_ptr<STEP::DB>(new STEP::DB(reader)); std::unique_ptr<STEP::DB> db = std::unique_ptr<STEP::DB>(new STEP::DB(reader));
LineSplitter &splitter = db->GetSplitter(); LineSplitter &splitter = db->GetSplitter();

View File

@ -634,7 +634,7 @@ private:
}; };
template <typename T> template <typename T>
inline bool operator==(std::shared_ptr<LazyObject> lo, T whatever) { inline bool operator==(const std::shared_ptr<LazyObject> &lo, T whatever) {
return *lo == whatever; // XXX use std::forward if we have 0x return *lo == whatever; // XXX use std::forward if we have 0x
} }
@ -816,7 +816,7 @@ public:
typedef std::pair<RefMap::const_iterator, RefMap::const_iterator> RefMapRange; typedef std::pair<RefMap::const_iterator, RefMap::const_iterator> RefMapRange;
private: private:
DB(std::shared_ptr<StreamReaderLE> reader) : DB(const std::shared_ptr<StreamReaderLE> &reader) :
reader(reader), splitter(*reader, true, true), evaluated_count(), schema(nullptr) {} reader(reader), splitter(*reader, true, true), evaluated_count(), schema(nullptr) {}
public: public:

View File

@ -530,8 +530,8 @@ void XFileExporter::writePath(const aiString &path)
while( str.find( "\\\\") != std::string::npos) while( str.find( "\\\\") != std::string::npos)
str.replace( str.find( "\\\\"), 2, "\\"); str.replace( str.find( "\\\\"), 2, "\\");
while( str.find( "\\") != std::string::npos) while (str.find('\\') != std::string::npos)
str.replace( str.find( "\\"), 1, "/"); str.replace(str.find('\\'), 1, "/");
mOutput << str; mOutput << str;

View File

@ -63,9 +63,9 @@ class X3DExporter {
// empty // empty
} }
SAttribute(SAttribute && rhs) : SAttribute(SAttribute &&rhs) AI_NO_EXCEPT :
Name(std::move(rhs.Name)), Name(rhs.Name),
Value(std::move(rhs.Value)) { Value(rhs.Value) {
// empty // empty
} }
}; };

View File

@ -456,9 +456,8 @@ namespace glTF
/// \param [in] pDecodedData - pointer to decoded data array. /// \param [in] pDecodedData - pointer to decoded data array.
/// \param [in] pDecodedData_Length - size of encoded region, in bytes. /// \param [in] pDecodedData_Length - size of encoded region, in bytes.
/// \param [in] pID - ID of the region. /// \param [in] pID - ID of the region.
SEncodedRegion(const size_t pOffset, const size_t pEncodedData_Length, uint8_t* pDecodedData, const size_t pDecodedData_Length, const std::string pID) SEncodedRegion(const size_t pOffset, const size_t pEncodedData_Length, uint8_t *pDecodedData, const size_t pDecodedData_Length, const std::string &pID) :
: Offset(pOffset), EncodedData_Length(pEncodedData_Length), DecodedData(pDecodedData), DecodedData_Length(pDecodedData_Length), ID(pID) Offset(pOffset), EncodedData_Length(pEncodedData_Length), DecodedData(pDecodedData), DecodedData_Length(pDecodedData_Length), ID(pID) {}
{}
/// \fn ~SEncodedRegion() /// \fn ~SEncodedRegion()
/// Destructor. /// Destructor.
@ -1149,8 +1148,7 @@ namespace glTF
void ReadExtensionsUsed(Document& doc); void ReadExtensionsUsed(Document& doc);
IOStream *OpenFile(const std::string &path, const char *mode, bool absolute = false);
IOStream* OpenFile(std::string path, const char* mode, bool absolute = false);
}; };
} }

View File

@ -1377,7 +1377,7 @@ inline void Asset::ReadExtensionsUsed(Document &doc) {
#undef CHECK_EXT #undef CHECK_EXT
} }
inline IOStream *Asset::OpenFile(std::string path, const char *mode, bool absolute) { inline IOStream *Asset::OpenFile(const std::string& path, const char *mode, bool absolute) {
#ifdef ASSIMP_API #ifdef ASSIMP_API
(void)absolute; (void)absolute;
return mIOSystem->Open(path, mode); return mIOSystem->Open(path, mode);

View File

@ -405,8 +405,7 @@ void glTFExporter::ExportMaterials()
* Search through node hierarchy and find the node containing the given meshID. * Search through node hierarchy and find the node containing the given meshID.
* Returns true on success, and false otherwise. * Returns true on success, and false otherwise.
*/ */
bool FindMeshNode(Ref<Node>& nodeIn, Ref<Node>& meshNode, std::string meshID) bool FindMeshNode(Ref<Node> &nodeIn, Ref<Node> &meshNode, const std::string &meshID) {
{
for (unsigned int i = 0; i < nodeIn->meshes.size(); ++i) { for (unsigned int i = 0; i < nodeIn->meshes.size(); ++i) {
if (meshID.compare(nodeIn->meshes[i]->id) == 0) { if (meshID.compare(nodeIn->meshes[i]->id) == 0) {
meshNode = nodeIn; meshNode = nodeIn;

View File

@ -459,7 +459,7 @@ public:
/// \param [in] pDecodedData - pointer to decoded data array. /// \param [in] pDecodedData - pointer to decoded data array.
/// \param [in] pDecodedData_Length - size of encoded region, in bytes. /// \param [in] pDecodedData_Length - size of encoded region, in bytes.
/// \param [in] pID - ID of the region. /// \param [in] pID - ID of the region.
SEncodedRegion(const size_t pOffset, const size_t pEncodedData_Length, uint8_t *pDecodedData, const size_t pDecodedData_Length, const std::string pID) : SEncodedRegion(const size_t pOffset, const size_t pEncodedData_Length, uint8_t *pDecodedData, const size_t pDecodedData_Length, const std::string &pID) :
Offset(pOffset), Offset(pOffset),
EncodedData_Length(pEncodedData_Length), EncodedData_Length(pEncodedData_Length),
DecodedData(pDecodedData), DecodedData(pDecodedData),
@ -1193,7 +1193,7 @@ private:
void ReadExtensionsUsed(Document &doc); void ReadExtensionsUsed(Document &doc);
void ReadExtensionsRequired(Document &doc); void ReadExtensionsRequired(Document &doc);
IOStream *OpenFile(std::string path, const char *mode, bool absolute = false); IOStream *OpenFile(const std::string &path, const char *mode, bool absolute = false);
}; };
inline std::string getContextForErrorMessages(const std::string &id, const std::string &name) { inline std::string getContextForErrorMessages(const std::string &id, const std::string &name) {

View File

@ -2143,7 +2143,7 @@ inline void Asset::ReadExtensionsUsed(Document &doc) {
#undef CHECK_EXT #undef CHECK_EXT
} }
inline IOStream *Asset::OpenFile(std::string path, const char *mode, bool /*absolute*/) { inline IOStream *Asset::OpenFile(const std::string& path, const char *mode, bool /*absolute*/) {
#ifdef ASSIMP_API #ifdef ASSIMP_API
return mIOSystem->Open(path, mode); return mIOSystem->Open(path, mode);
#else #else

View File

@ -837,8 +837,7 @@ void glTF2Exporter::ExportMaterials()
* Search through node hierarchy and find the node containing the given meshID. * Search through node hierarchy and find the node containing the given meshID.
* Returns true on success, and false otherwise. * Returns true on success, and false otherwise.
*/ */
bool FindMeshNode(Ref<Node>& nodeIn, Ref<Node>& meshNode, std::string meshID) bool FindMeshNode(Ref<Node> &nodeIn, Ref<Node> &meshNode, const std::string &meshID) {
{
for (unsigned int i = 0; i < nodeIn->meshes.size(); ++i) { for (unsigned int i = 0; i < nodeIn->meshes.size(); ++i) {
if (meshID.compare(nodeIn->meshes[i]->id) == 0) { if (meshID.compare(nodeIn->meshes[i]->id) == 0) {
meshNode = nodeIn; meshNode = nodeIn;

View File

@ -108,12 +108,11 @@ void ExportScenePbrt (
// Constructor // Constructor
PbrtExporter::PbrtExporter( PbrtExporter::PbrtExporter(
const aiScene *pScene, IOSystem *pIOSystem, const aiScene *pScene, IOSystem *pIOSystem,
const std::string path, const std::string file) const std::string &path, const std::string &file) :
: mScene(pScene), mScene(pScene),
mIOSystem(pIOSystem), mIOSystem(pIOSystem),
mPath(path), mPath(path),
mFile(file) mFile(file) {
{
// Export embedded textures. // Export embedded textures.
if (mScene->mNumTextures > 0) if (mScene->mNumTextures > 0)
if (!mIOSystem->CreateDirectory("textures")) if (!mIOSystem->CreateDirectory("textures"))
@ -210,12 +209,12 @@ void PbrtExporter::WriteMetaData() {
aiString* value = aiString* value =
static_cast<aiString*>(pMetaData->mValues[i].mData); static_cast<aiString*>(pMetaData->mValues[i].mData);
std::string svalue = value->C_Str(); std::string svalue = value->C_Str();
std::size_t found = svalue.find_first_of("\n"); std::size_t found = svalue.find_first_of('\n');
mOutput << "\n"; mOutput << "\n";
while (found != std::string::npos) { while (found != std::string::npos) {
mOutput << "# " << svalue.substr(0, found) << "\n"; mOutput << "# " << svalue.substr(0, found) << "\n";
svalue = svalue.substr(found + 1); svalue = svalue.substr(found + 1);
found = svalue.find_first_of("\n"); found = svalue.find_first_of('\n');
} }
mOutput << "# " << svalue << "\n"; mOutput << "# " << svalue << "\n";
break; break;
@ -596,8 +595,8 @@ void PbrtExporter::WriteMaterial(int m) {
} }
mOutput << "\n"; mOutput << "\n";
auto White = [](aiColor3D c) { return c.r == 1 && c.g == 1 && c.b == 1; }; auto White = [](const aiColor3D &c) { return c.r == 1 && c.g == 1 && c.b == 1; };
auto Black = [](aiColor3D c) { return c.r == 0 && c.g == 0 && c.b == 0; }; auto Black = [](const aiColor3D &c) { return c.r == 0 && c.g == 0 && c.b == 0; };
aiColor3D diffuse, specular, transparency; aiColor3D diffuse, specular, transparency;
bool constantDiffuse = (material->Get(AI_MATKEY_COLOR_DIFFUSE, diffuse) == AI_SUCCESS && bool constantDiffuse = (material->Get(AI_MATKEY_COLOR_DIFFUSE, diffuse) == AI_SUCCESS &&

View File

@ -75,7 +75,7 @@ class PbrtExporter
public: public:
/// Constructor for a specific scene to export /// Constructor for a specific scene to export
PbrtExporter(const aiScene *pScene, IOSystem *pIOSystem, PbrtExporter(const aiScene *pScene, IOSystem *pIOSystem,
const std::string path, const std::string file); const std::string &path, const std::string &file);
/// Destructor /// Destructor
virtual ~PbrtExporter(); virtual ~PbrtExporter();

View File

@ -100,7 +100,7 @@ void EmbedTexturesProcess::Execute(aiScene* pScene) {
ASSIMP_LOG_INFO("EmbedTexturesProcess finished. Embedded ", embeddedTexturesCount, " textures." ); ASSIMP_LOG_INFO("EmbedTexturesProcess finished. Embedded ", embeddedTexturesCount, " textures." );
} }
bool EmbedTexturesProcess::addTexture(aiScene* pScene, std::string path) const { bool EmbedTexturesProcess::addTexture(aiScene *pScene, const std::string &path) const {
std::streampos imageSize = 0; std::streampos imageSize = 0;
std::string imagePath = path; std::string imagePath = path;

View File

@ -78,7 +78,7 @@ public:
private: private:
// Resolve the path and add the file content to the scene as a texture. // Resolve the path and add the file content to the scene as a texture.
bool addTexture(aiScene* pScene, std::string path) const; bool addTexture(aiScene *pScene, const std::string &path) const;
private: private:
std::string mRootPath; std::string mRootPath;

View File

@ -53,7 +53,7 @@ class utTypes : public ::testing::Test {
TEST_F( utTypes, Color3dCpmpareOpTest ) { TEST_F( utTypes, Color3dCpmpareOpTest ) {
aiColor3D col1( 1, 2, 3 ); aiColor3D col1( 1, 2, 3 );
aiColor3D col2( 4, 5, 6 ); aiColor3D col2( 4, 5, 6 );
aiColor3D col3( col1 ); const aiColor3D &col3(col1);
EXPECT_FALSE( col1 == col2 ); EXPECT_FALSE( col1 == col2 );
EXPECT_FALSE( col2 == col3 ); EXPECT_FALSE( col2 == col3 );

View File

@ -39,9 +39,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
*/ */
#include "assimp_view.h" #include "AnimEvaluator.h"
#include <tuple> #include <assimp/anim.h>
#include <assimp/ai_assert.h>
using namespace AssimpView; using namespace AssimpView;

View File

@ -1,4 +1,3 @@
/** Calculates a pose for a given time of an animation */
/* /*
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
@ -40,11 +39,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
*/ */
#pragma once
#ifndef AV_ANIMEVALUATOR_H_INCLUDED #ifndef AV_ANIMEVALUATOR_H_INCLUDED
#define AV_ANIMEVALUATOR_H_INCLUDED #define AV_ANIMEVALUATOR_H_INCLUDED
/** Calculates a pose for a given time of an animation */
#include <tuple> #include <tuple>
#include <vector> #include <vector>
#include <assimp/matrix4x4.h>
struct aiAnimation;
namespace AssimpView { namespace AssimpView {
@ -63,18 +68,19 @@ public:
/// @brief The class destructor. /// @brief The class destructor.
~AnimEvaluator(); ~AnimEvaluator();
/** Evaluates the animation tracks for a given time stamp. The calculated pose can be retrieved as a /// @brief Evaluates the animation tracks for a given time stamp.
* array of transformation matrices afterwards by calling GetTransformations(). /// The calculated pose can be retrieved as an array of transformation
* @param pTime The time for which you want to evaluate the animation, in seconds. Will be mapped into the animation cycle, so /// matrices afterwards by calling GetTransformations().
* it can be an arbitrary value. Best use with ever-increasing time stamps. /// @param pTime The time for which you want to evaluate the animation, in seconds.
*/ /// Will be mapped into the animation cycle, so it can get an arbitrary
/// value. Best use with ever-increasing time stamps.
void Evaluate(double pTime); void Evaluate(double pTime);
/** Returns the transform matrices calculated at the last Evaluate() call. The array matches the mChannels array of /// @brief Returns the transform matrices calculated at the last Evaluate() call.
* the aiAnimation. */ /// The array matches the mChannels array of the aiAnimation.
const std::vector<aiMatrix4x4> &GetTransformations() const { return mTransforms; } const std::vector<aiMatrix4x4> &GetTransformations() const { return mTransforms; }
protected: private:
const aiAnimation *mAnim; const aiAnimation *mAnim;
double mLastTime; double mLastTime;
std::vector<std::tuple<unsigned int, unsigned int, unsigned int>> mLastPositions; std::vector<std::tuple<unsigned int, unsigned int, unsigned int>> mLastPositions;