Compare commits
58 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80b0b897ed | ||
|
|
572e31ddcb | ||
|
|
9dfd401624 | ||
|
|
5a46597e47 | ||
|
|
01f68dd916 | ||
|
|
7fc4603579 | ||
|
|
d7bf8d6e07 | ||
|
|
6693e7e08c | ||
|
|
3e97329fa1 | ||
|
|
c72e3905c2 | ||
|
|
2ffa0c59eb | ||
|
|
af42d53c92 | ||
|
|
c4d858cf4d | ||
|
|
7a29147095 | ||
|
|
46b28a442b | ||
|
|
26dc168449 | ||
|
|
92aef9236f | ||
|
|
8322e393c5 | ||
|
|
003942aafe | ||
|
|
0491eb3591 | ||
|
|
d619f7015a | ||
|
|
65bc801734 | ||
|
|
e4f38810ca | ||
|
|
cb657e4c13 | ||
|
|
052594568a | ||
|
|
54e60b031e | ||
|
|
4959924dab | ||
|
|
819d9f7257 | ||
|
|
33c6762272 | ||
|
|
6bb856335f | ||
|
|
68682d75b5 | ||
|
|
c2297e9199 | ||
|
|
d2c8cb755e | ||
|
|
ea2e442046 | ||
|
|
e51feac2c5 | ||
|
|
1e4861f86e | ||
|
|
2be6bac4b0 | ||
|
|
9a7ee0ac14 | ||
|
|
6e090c88b8 | ||
|
|
70f5cca9c3 | ||
|
|
983b20cda6 | ||
|
|
16149348ed | ||
|
|
0e2ac2a91c | ||
|
|
c8cdf3009e | ||
|
|
23d7811276 | ||
|
|
836963428e | ||
|
|
8c9a148776 | ||
|
|
834ec20008 | ||
|
|
cc05b4c8f1 | ||
|
|
d6f3f292f2 | ||
|
|
4a37aa2ef8 | ||
|
|
745f5e7e65 | ||
|
|
095bd67e10 | ||
|
|
e831ecf3c2 | ||
|
|
44fa1ec6a7 | ||
|
|
5e1188c44e | ||
|
|
0015823bef | ||
|
|
38382715f7 |
@@ -56,7 +56,7 @@ IF(ASSIMP_HUNTER_ENABLED)
|
||||
add_definitions(-DASSIMP_USE_HUNTER)
|
||||
ENDIF()
|
||||
|
||||
PROJECT(Assimp VERSION 5.1.0)
|
||||
PROJECT(Assimp VERSION 5.1.4)
|
||||
|
||||
# All supported options ###############################################
|
||||
|
||||
@@ -183,7 +183,9 @@ SET (ASSIMP_SOVERSION 5)
|
||||
SET( ASSIMP_PACKAGE_VERSION "0" CACHE STRING "the package-specific version used for uploading the sources" )
|
||||
if(NOT ASSIMP_HUNTER_ENABLED)
|
||||
# Enable C++11 support globally
|
||||
set_property( GLOBAL PROPERTY CXX_STANDARD 11 )
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
endif()
|
||||
|
||||
IF(NOT ASSIMP_IGNORE_GIT_HASH)
|
||||
@@ -762,7 +764,7 @@ if(WIN32)
|
||||
|
||||
IF(MSVC_TOOLSET_VERSION)
|
||||
SET(MSVC_PREFIX "vc${MSVC_TOOLSET_VERSION}")
|
||||
SET(ASSIMP_MSVC_VERSION ${MCVS_PREFIX})
|
||||
SET(ASSIMP_MSVC_VERSION ${MSVC_PREFIX})
|
||||
ELSE()
|
||||
IF(MSVC12)
|
||||
SET(ASSIMP_MSVC_VERSION "vc120")
|
||||
|
||||
@@ -318,42 +318,81 @@ void BlenderImporter::ExtractScene(Scene &out, const FileDatabase &file) {
|
||||
#endif
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void BlenderImporter::ParseSubCollection(const Blender::Scene &in, aiNode *root, std::shared_ptr<Collection> collection, ConversionData &conv_data) {
|
||||
|
||||
std::deque<Object *> root_objects;
|
||||
// Count number of objects
|
||||
for (std::shared_ptr<CollectionObject> cur = std::static_pointer_cast<CollectionObject>(collection->gobject.first); cur; cur = cur->next) {
|
||||
if (cur->ob) {
|
||||
root_objects.push_back(cur->ob);
|
||||
}
|
||||
}
|
||||
std::deque<Collection *> root_children;
|
||||
// Count number of child nodes
|
||||
for (std::shared_ptr<CollectionChild> cur = std::static_pointer_cast<CollectionChild>(collection->children.first); cur; cur = cur->next) {
|
||||
if (cur->collection) {
|
||||
root_children.push_back(cur->collection.get());
|
||||
}
|
||||
}
|
||||
root->mNumChildren = static_cast<unsigned int>(root_objects.size() + root_children.size());
|
||||
root->mChildren = new aiNode *[root->mNumChildren]();
|
||||
|
||||
for (unsigned int i = 0; i < static_cast<unsigned int>(root_objects.size()); ++i) {
|
||||
root->mChildren[i] = ConvertNode(in, root_objects[i], conv_data, aiMatrix4x4());
|
||||
root->mChildren[i]->mParent = root;
|
||||
}
|
||||
|
||||
// For each subcollection create a new node to represent it
|
||||
unsigned int iterator = static_cast<unsigned int>(root_objects.size());
|
||||
for (std::shared_ptr<CollectionChild> cur = std::static_pointer_cast<CollectionChild>(collection->children.first); cur; cur = cur->next) {
|
||||
if (cur->collection) {
|
||||
root->mChildren[iterator] = new aiNode(cur->collection->id.name + 2); // skip over the name prefix 'OB'
|
||||
root->mChildren[iterator]->mParent = root;
|
||||
ParseSubCollection(in, root->mChildren[iterator], cur->collection, conv_data);
|
||||
}
|
||||
iterator += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void BlenderImporter::ConvertBlendFile(aiScene *out, const Scene &in, const FileDatabase &file) {
|
||||
ConversionData conv(file);
|
||||
|
||||
// FIXME it must be possible to take the hierarchy directly from
|
||||
// the file. This is terrible. Here, we're first looking for
|
||||
// all objects which don't have parent objects at all -
|
||||
std::deque<const Object *> no_parents;
|
||||
for (std::shared_ptr<Base> cur = std::static_pointer_cast<Base>(in.base.first); cur; cur = cur->next) {
|
||||
if (cur->object) {
|
||||
if (!cur->object->parent) {
|
||||
no_parents.push_back(cur->object.get());
|
||||
} else {
|
||||
conv.objects.insert(cur->object.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (std::shared_ptr<Base> cur = in.basact; cur; cur = cur->next) {
|
||||
if (cur->object) {
|
||||
if (cur->object->parent) {
|
||||
conv.objects.insert(cur->object.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (no_parents.empty()) {
|
||||
ThrowException("Expected at least one object with no parent");
|
||||
}
|
||||
|
||||
aiNode *root = out->mRootNode = new aiNode("<BlenderRoot>");
|
||||
// Iterate over all objects directly under master_collection,
|
||||
// If in.master_collection == null, then we're parsing something older.
|
||||
if (in.master_collection) {
|
||||
ParseSubCollection(in, root, in.master_collection, conv);
|
||||
} else {
|
||||
std::deque<const Object *> no_parents;
|
||||
for (std::shared_ptr<Base> cur = std::static_pointer_cast<Base>(in.base.first); cur; cur = cur->next) {
|
||||
if (cur->object) {
|
||||
if (!cur->object->parent) {
|
||||
no_parents.push_back(cur->object.get());
|
||||
} else {
|
||||
conv.objects.insert(cur->object.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (std::shared_ptr<Base> cur = in.basact; cur; cur = cur->next) {
|
||||
if (cur->object) {
|
||||
if (cur->object->parent) {
|
||||
conv.objects.insert(cur->object.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
root->mNumChildren = static_cast<unsigned int>(no_parents.size());
|
||||
root->mChildren = new aiNode *[root->mNumChildren]();
|
||||
for (unsigned int i = 0; i < root->mNumChildren; ++i) {
|
||||
root->mChildren[i] = ConvertNode(in, no_parents[i], conv, aiMatrix4x4());
|
||||
root->mChildren[i]->mParent = root;
|
||||
if (no_parents.empty()) {
|
||||
ThrowException("Expected at least one object with no parent");
|
||||
}
|
||||
|
||||
root->mNumChildren = static_cast<unsigned int>(no_parents.size());
|
||||
root->mChildren = new aiNode *[root->mNumChildren]();
|
||||
for (unsigned int i = 0; i < root->mNumChildren; ++i) {
|
||||
root->mChildren[i] = ConvertNode(in, no_parents[i], conv, aiMatrix4x4());
|
||||
root->mChildren[i]->mParent = root;
|
||||
}
|
||||
}
|
||||
|
||||
BuildMaterials(conv);
|
||||
|
||||
@@ -78,6 +78,7 @@ struct ElemBase;
|
||||
namespace Blender {
|
||||
struct Scene;
|
||||
struct Object;
|
||||
struct Collection;
|
||||
struct Mesh;
|
||||
struct Camera;
|
||||
struct Lamp;
|
||||
@@ -116,6 +117,7 @@ protected:
|
||||
void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) override;
|
||||
void ParseBlendFile(Blender::FileDatabase &out, std::shared_ptr<IOStream> stream);
|
||||
void ExtractScene(Blender::Scene &out, const Blender::FileDatabase &file);
|
||||
void ParseSubCollection(const Blender::Scene &in, aiNode *root, std::shared_ptr<Blender::Collection> collection, Blender::ConversionData &conv_data);
|
||||
void ConvertBlendFile(aiScene *out, const Blender::Scene &in, const Blender::FileDatabase &file);
|
||||
|
||||
private:
|
||||
|
||||
@@ -94,6 +94,52 @@ void Structure ::Convert<Group>(
|
||||
db.reader->IncPtr(size);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
template <>
|
||||
void Structure::Convert<CollectionObject>(
|
||||
CollectionObject &dest,
|
||||
const FileDatabase &db) const {
|
||||
|
||||
ReadFieldPtr<ErrorPolicy_Fail>(dest.next, "*next", db);
|
||||
{
|
||||
//std::shared_ptr<CollectionObject> prev;
|
||||
//ReadFieldPtr<ErrorPolicy_Fail>(prev, "*prev", db);
|
||||
//dest.prev = prev.get();
|
||||
|
||||
std::shared_ptr<Object> ob;
|
||||
ReadFieldPtr<ErrorPolicy_Igno>(ob, "*ob", db);
|
||||
dest.ob = ob.get();
|
||||
}
|
||||
|
||||
db.reader->IncPtr(size);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
template <>
|
||||
void Structure::Convert<CollectionChild>(
|
||||
CollectionChild &dest,
|
||||
const FileDatabase &db) const {
|
||||
|
||||
ReadFieldPtr<ErrorPolicy_Fail>(dest.prev, "*prev", db);
|
||||
ReadFieldPtr<ErrorPolicy_Fail>(dest.next, "*next", db);
|
||||
ReadFieldPtr<ErrorPolicy_Igno>(dest.collection, "*collection", db);
|
||||
|
||||
db.reader->IncPtr(size);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
template <>
|
||||
void Structure::Convert<Collection>(
|
||||
Collection &dest,
|
||||
const FileDatabase &db) const {
|
||||
|
||||
ReadField<ErrorPolicy_Fail>(dest.id, "id", db);
|
||||
ReadField<ErrorPolicy_Fail>(dest.gobject, "gobject", db);
|
||||
ReadField<ErrorPolicy_Fail>(dest.children, "children", db);
|
||||
|
||||
db.reader->IncPtr(size);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
template <>
|
||||
void Structure ::Convert<MTex>(
|
||||
@@ -660,6 +706,7 @@ void Structure ::Convert<Scene>(
|
||||
ReadFieldPtr<ErrorPolicy_Warn>(dest.camera, "*camera", db);
|
||||
ReadFieldPtr<ErrorPolicy_Warn>(dest.world, "*world", db);
|
||||
ReadFieldPtr<ErrorPolicy_Warn>(dest.basact, "*basact", db);
|
||||
ReadFieldPtr<ErrorPolicy_Warn>(dest.master_collection, "*master_collection", db);
|
||||
ReadField<ErrorPolicy_Igno>(dest.base, "base", db);
|
||||
|
||||
db.reader->IncPtr(size);
|
||||
@@ -833,6 +880,9 @@ void DNA::RegisterConverters() {
|
||||
converters["Image"] = DNA::FactoryPair(&Structure::Allocate<Image>, &Structure::Convert<Image>);
|
||||
converters["CustomData"] = DNA::FactoryPair(&Structure::Allocate<CustomData>, &Structure::Convert<CustomData>);
|
||||
converters["CustomDataLayer"] = DNA::FactoryPair(&Structure::Allocate<CustomDataLayer>, &Structure::Convert<CustomDataLayer>);
|
||||
converters["Collection"] = DNA::FactoryPair(&Structure::Allocate<Collection>, &Structure::Convert<Collection>);
|
||||
converters["CollectionChild"] = DNA::FactoryPair(&Structure::Allocate<CollectionChild>, &Structure::Convert<CollectionChild>);
|
||||
converters["CollectionObject"] = DNA::FactoryPair(&Structure::Allocate<CollectionObject>, &Structure::Convert<CollectionObject>);
|
||||
}
|
||||
|
||||
#endif // ASSIMP_BUILD_NO_BLEND_IMPORTER
|
||||
|
||||
@@ -107,6 +107,7 @@ namespace Blender {
|
||||
struct Object;
|
||||
struct MTex;
|
||||
struct Image;
|
||||
struct Collection;
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -147,6 +148,26 @@ struct Group : ElemBase {
|
||||
std::shared_ptr<GroupObject> gobject;
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
struct CollectionObject : ElemBase {
|
||||
//CollectionObject* prev;
|
||||
std::shared_ptr<CollectionObject> next;
|
||||
Object *ob;
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
struct CollectionChild : ElemBase {
|
||||
std::shared_ptr<CollectionChild> next, prev;
|
||||
std::shared_ptr<Collection> collection;
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
struct Collection : ElemBase {
|
||||
ID id FAIL;
|
||||
ListBase gobject; // CollectionObject
|
||||
ListBase children; // CollectionChild
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
struct World : ElemBase {
|
||||
ID id FAIL;
|
||||
@@ -729,11 +750,12 @@ struct Scene : ElemBase {
|
||||
std::shared_ptr<Object> camera WARN;
|
||||
std::shared_ptr<World> world WARN;
|
||||
std::shared_ptr<Base> basact WARN;
|
||||
std::shared_ptr<Collection> master_collection WARN;
|
||||
|
||||
ListBase base;
|
||||
|
||||
Scene() :
|
||||
ElemBase(), camera(), world(), basact() {
|
||||
ElemBase(), camera(), world(), basact(), master_collection() {
|
||||
// empty
|
||||
}
|
||||
};
|
||||
|
||||
@@ -62,6 +62,12 @@ template <> void Structure :: Convert<Group> (
|
||||
) const
|
||||
;
|
||||
|
||||
template <> void Structure::Convert<Collection>(
|
||||
Collection& dest,
|
||||
const FileDatabase& db
|
||||
) const
|
||||
;
|
||||
|
||||
template <> void Structure :: Convert<MTex> (
|
||||
MTex& dest,
|
||||
const FileDatabase& db
|
||||
|
||||
@@ -378,6 +378,11 @@ void DXFImporter::ExpandBlockReferences(DXF::Block& bl,const DXF::BlockMap& bloc
|
||||
const DXF::Block& bl_src = *(*it).second;
|
||||
|
||||
for (std::shared_ptr<const DXF::PolyLine> pl_in : bl_src.lines) {
|
||||
if (!pl_in) {
|
||||
ASSIMP_LOG_ERROR("DXF: PolyLine instance is nullptr, skipping.");
|
||||
continue;
|
||||
}
|
||||
|
||||
std::shared_ptr<DXF::PolyLine> pl_out = std::shared_ptr<DXF::PolyLine>(new DXF::PolyLine(*pl_in));
|
||||
|
||||
if (bl_src.base.Length() || insert.scale.x!=1.f || insert.scale.y!=1.f || insert.scale.z!=1.f || insert.angle || insert.pos.Length()) {
|
||||
|
||||
@@ -79,7 +79,7 @@ using namespace Util;
|
||||
|
||||
#define MAGIC_NODE_TAG "_$AssimpFbx$"
|
||||
|
||||
#define CONVERT_FBX_TIME(time) (static_cast<double>(time) * 1000.0 / 46186158000LL)
|
||||
#define CONVERT_FBX_TIME(time) static_cast<double>(time) / 46186158000LL
|
||||
|
||||
FBXConverter::FBXConverter(aiScene *out, const Document &doc, bool removeEmptyBones) :
|
||||
defaultMaterialIndex(),
|
||||
@@ -2618,7 +2618,7 @@ void FBXConverter::ConvertAnimationStack(const AnimationStack &st) {
|
||||
meshMorphAnim->mKeys[j].mNumValuesAndWeights = numValuesAndWeights;
|
||||
meshMorphAnim->mKeys[j].mValues = new unsigned int[numValuesAndWeights];
|
||||
meshMorphAnim->mKeys[j].mWeights = new double[numValuesAndWeights];
|
||||
meshMorphAnim->mKeys[j].mTime = CONVERT_FBX_TIME(animIt.first);
|
||||
meshMorphAnim->mKeys[j].mTime = CONVERT_FBX_TIME(animIt.first) * anim_fps;
|
||||
for (unsigned int k = 0; k < numValuesAndWeights; k++) {
|
||||
meshMorphAnim->mKeys[j].mValues[k] = keyData->values.at(k);
|
||||
meshMorphAnim->mKeys[j].mWeights[k] = keyData->weights.at(k);
|
||||
@@ -2636,8 +2636,8 @@ void FBXConverter::ConvertAnimationStack(const AnimationStack &st) {
|
||||
return;
|
||||
}
|
||||
|
||||
double start_time_fps = has_local_startstop ? CONVERT_FBX_TIME(start_time) : min_time;
|
||||
double stop_time_fps = has_local_startstop ? CONVERT_FBX_TIME(stop_time) : max_time;
|
||||
double start_time_fps = has_local_startstop ? (CONVERT_FBX_TIME(start_time) * anim_fps) : min_time;
|
||||
double stop_time_fps = has_local_startstop ? (CONVERT_FBX_TIME(stop_time) * anim_fps) : max_time;
|
||||
|
||||
// adjust relative timing for animation
|
||||
for (unsigned int c = 0; c < anim->mNumChannels; c++) {
|
||||
@@ -3127,7 +3127,12 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
|
||||
if (chain[i] == iterEnd)
|
||||
continue;
|
||||
|
||||
keyframeLists[i] = GetKeyframeList((*chain[i]).second, start, stop);
|
||||
if (i == TransformationComp_Rotation || i == TransformationComp_PreRotation
|
||||
|| i == TransformationComp_PostRotation || i == TransformationComp_GeometricRotation) {
|
||||
keyframeLists[i] = GetRotationKeyframeList((*chain[i]).second, start, stop);
|
||||
} else {
|
||||
keyframeLists[i] = GetKeyframeList((*chain[i]).second, start, stop);
|
||||
}
|
||||
|
||||
for (KeyFrameListList::const_iterator it = keyframeLists[i].begin(); it != keyframeLists[i].end(); ++it) {
|
||||
const KeyTimeList& times = *std::get<0>(*it);
|
||||
@@ -3157,7 +3162,7 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
|
||||
InterpolateKeys(outTranslations, keytimes, keyframeLists[TransformationComp_Translation], defTranslate, maxTime, minTime);
|
||||
} else {
|
||||
for (size_t i = 0; i < keyCount; ++i) {
|
||||
outTranslations[i].mTime = CONVERT_FBX_TIME(keytimes[i]);
|
||||
outTranslations[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps;
|
||||
outTranslations[i].mValue = defTranslate;
|
||||
}
|
||||
}
|
||||
@@ -3166,7 +3171,7 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
|
||||
InterpolateKeys(outRotations, keytimes, keyframeLists[TransformationComp_Rotation], defRotation, maxTime, minTime, rotOrder);
|
||||
} else {
|
||||
for (size_t i = 0; i < keyCount; ++i) {
|
||||
outRotations[i].mTime = CONVERT_FBX_TIME(keytimes[i]);
|
||||
outRotations[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps;
|
||||
outRotations[i].mValue = defQuat;
|
||||
}
|
||||
}
|
||||
@@ -3175,7 +3180,7 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
|
||||
InterpolateKeys(outScales, keytimes, keyframeLists[TransformationComp_Scaling], defScale, maxTime, minTime);
|
||||
} else {
|
||||
for (size_t i = 0; i < keyCount; ++i) {
|
||||
outScales[i].mTime = CONVERT_FBX_TIME(keytimes[i]);
|
||||
outScales[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps;
|
||||
outScales[i].mValue = defScale;
|
||||
}
|
||||
}
|
||||
@@ -3274,6 +3279,79 @@ FBXConverter::KeyFrameListList FBXConverter::GetKeyframeList(const std::vector<c
|
||||
return inputs; // pray for NRVO :-)
|
||||
}
|
||||
|
||||
FBXConverter::KeyFrameListList FBXConverter::GetRotationKeyframeList(const std::vector<const AnimationCurveNode *> &nodes,
|
||||
int64_t start, int64_t stop) {
|
||||
KeyFrameListList inputs;
|
||||
inputs.reserve(nodes.size() * 3);
|
||||
|
||||
//give some breathing room for rounding errors
|
||||
const int64_t adj_start = start - 10000;
|
||||
const int64_t adj_stop = stop + 10000;
|
||||
|
||||
for (const AnimationCurveNode *node : nodes) {
|
||||
ai_assert(node);
|
||||
|
||||
const AnimationCurveMap &curves = node->Curves();
|
||||
for (const AnimationCurveMap::value_type &kv : curves) {
|
||||
|
||||
unsigned int mapto;
|
||||
if (kv.first == "d|X") {
|
||||
mapto = 0;
|
||||
} else if (kv.first == "d|Y") {
|
||||
mapto = 1;
|
||||
} else if (kv.first == "d|Z") {
|
||||
mapto = 2;
|
||||
} else {
|
||||
FBXImporter::LogWarn("ignoring scale animation curve, did not recognize target component");
|
||||
continue;
|
||||
}
|
||||
|
||||
const AnimationCurve *const curve = kv.second;
|
||||
ai_assert(curve->GetKeys().size() == curve->GetValues().size());
|
||||
ai_assert(curve->GetKeys().size());
|
||||
|
||||
//get values within the start/stop time window
|
||||
std::shared_ptr<KeyTimeList> Keys(new KeyTimeList());
|
||||
std::shared_ptr<KeyValueList> Values(new KeyValueList());
|
||||
const size_t count = curve->GetKeys().size();
|
||||
|
||||
int64_t tp = curve->GetKeys().at(0);
|
||||
float vp = curve->GetValues().at(0);
|
||||
Keys->push_back(tp);
|
||||
Values->push_back(vp);
|
||||
if (count > 1) {
|
||||
int64_t tc = curve->GetKeys().at(1);
|
||||
float vc = curve->GetValues().at(1);
|
||||
for (size_t n = 1; n < count; n++) {
|
||||
while (std::abs(vc - vp) >= 180.0f) {
|
||||
float step = std::floor(float(tc - tp) / (vc - vp) * 179.0f);
|
||||
int64_t tnew = tp + int64_t(step);
|
||||
float vnew = vp + (vc - vp) * step / float(tc - tp);
|
||||
if (tnew >= adj_start && tnew <= adj_stop) {
|
||||
Keys->push_back(tnew);
|
||||
Values->push_back(vnew);
|
||||
}
|
||||
tp = tnew;
|
||||
vp = vnew;
|
||||
}
|
||||
if (tc >= adj_start && tc <= adj_stop) {
|
||||
Keys->push_back(tc);
|
||||
Values->push_back(vc);
|
||||
}
|
||||
if (n + 1 < count) {
|
||||
tp = tc;
|
||||
vp = vc;
|
||||
tc = curve->GetKeys().at(n + 1);
|
||||
vc = curve->GetValues().at(n + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
inputs.push_back(std::make_tuple(Keys, Values, mapto));
|
||||
}
|
||||
}
|
||||
return inputs;
|
||||
}
|
||||
|
||||
KeyTimeList FBXConverter::GetKeyTimeList(const KeyFrameListList &inputs) {
|
||||
ai_assert(!inputs.empty());
|
||||
|
||||
@@ -3364,7 +3442,7 @@ void FBXConverter::InterpolateKeys(aiVectorKey *valOut, const KeyTimeList &keys,
|
||||
}
|
||||
|
||||
// magic value to convert fbx times to seconds
|
||||
valOut->mTime = CONVERT_FBX_TIME(time);
|
||||
valOut->mTime = CONVERT_FBX_TIME(time) * anim_fps;
|
||||
|
||||
min_time = std::min(min_time, valOut->mTime);
|
||||
max_time = std::max(max_time, valOut->mTime);
|
||||
@@ -3464,7 +3542,7 @@ void FBXConverter::ConvertRotationKeys(aiNodeAnim *na, const std::vector<const A
|
||||
ai_assert(nodes.size());
|
||||
|
||||
// XXX see notes in ConvertScaleKeys()
|
||||
const std::vector<KeyFrameList> &inputs = GetKeyframeList(nodes, start, stop);
|
||||
const std::vector<KeyFrameList> &inputs = GetRotationKeyframeList(nodes, start, stop);
|
||||
const KeyTimeList &keys = GetKeyTimeList(inputs);
|
||||
|
||||
na->mNumRotationKeys = static_cast<unsigned int>(keys.size());
|
||||
|
||||
@@ -361,6 +361,7 @@ private:
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
KeyFrameListList GetKeyframeList(const std::vector<const AnimationCurveNode*>& nodes, int64_t start, int64_t stop);
|
||||
KeyFrameListList GetRotationKeyframeList(const std::vector<const AnimationCurveNode*>& nodes, int64_t start, int64_t stop);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
KeyTimeList GetKeyTimeList(const KeyFrameListList& inputs);
|
||||
|
||||
@@ -473,16 +473,22 @@ void HMPImporter::ReadFirstSkin(unsigned int iNumSkins, const unsigned char *szC
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Generate proepr texture coords
|
||||
void HMPImporter::GenerateTextureCoords(
|
||||
const unsigned int width, const unsigned int height) {
|
||||
void HMPImporter::GenerateTextureCoords(const unsigned int width, const unsigned int height) {
|
||||
ai_assert(nullptr != pScene->mMeshes);
|
||||
ai_assert(nullptr != pScene->mMeshes[0]);
|
||||
ai_assert(nullptr != pScene->mMeshes[0]->mTextureCoords[0]);
|
||||
|
||||
aiVector3D *uv = pScene->mMeshes[0]->mTextureCoords[0];
|
||||
|
||||
const float fY = (1.0f / height) + (1.0f / height) / (height - 1);
|
||||
const float fX = (1.0f / width) + (1.0f / width) / (width - 1);
|
||||
if (uv == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (height == 0.0f || width == 0.0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const float fY = (1.0f / height) + (1.0f / height) / height;
|
||||
const float fX = (1.0f / width) + (1.0f / width) / width;
|
||||
|
||||
for (unsigned int y = 0; y < height; ++y) {
|
||||
for (unsigned int x = 0; x < width; ++x, ++uv) {
|
||||
|
||||
@@ -393,7 +393,7 @@ void LWOImporter::InternReadFile(const std::string &pFile,
|
||||
|
||||
// If a RGB color map is explicitly requested delete the
|
||||
// alpha channel - it could theoretically be != 1.
|
||||
if (_mSurfaces[i].mVCMapType == AI_LWO_RGB)
|
||||
if (_mSurfaces[j].mVCMapType == AI_LWO_RGB)
|
||||
pvVC[w]->a = 1.f;
|
||||
|
||||
pvVC[w]++;
|
||||
|
||||
@@ -235,10 +235,8 @@ void X3DImporter::ParseFile(const std::string &file, IOSystem *pIOHandler) {
|
||||
|
||||
bool X3DImporter::CanRead(const std::string &pFile, IOSystem * /*pIOHandler*/, bool checkSig) const {
|
||||
if (checkSig) {
|
||||
std::string::size_type pos = pFile.find_last_of(".x3d");
|
||||
if (pos != std::string::npos) {
|
||||
if (GetExtension(pFile) == "x3d")
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -482,6 +480,6 @@ void X3DImporter::ParseHelper_Node_Exit() {
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !ASSIMP_BUILD_NO_X3D_IMPORTER
|
||||
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // !ASSIMP_BUILD_NO_X3D_IMPORTER
|
||||
|
||||
@@ -879,7 +879,7 @@ void X3DImporter::readSphere(XmlNode &node) {
|
||||
X3DNodeElementBase *ne(nullptr);
|
||||
|
||||
MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
|
||||
XmlParser::getFloatAttribute(node, "radius", radius);
|
||||
XmlParser::getRealAttribute(node, "radius", radius);
|
||||
XmlParser::getBoolAttribute(node, "solid", solid);
|
||||
|
||||
// if "USE" defined then find already defined element.
|
||||
|
||||
@@ -72,7 +72,7 @@ void X3DImporter::startReadGroup(XmlNode &node) {
|
||||
|
||||
// if "USE" defined then find already defined element.
|
||||
if (!use.empty()) {
|
||||
X3DNodeElementBase *ne = nullptr;
|
||||
X3DNodeElementBase *ne(nullptr);
|
||||
ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Group, ne);
|
||||
} else {
|
||||
ParseHelper_Group_Begin(); // create new grouping element and go deeper if node has children.
|
||||
@@ -110,7 +110,7 @@ void X3DImporter::startReadStaticGroup(XmlNode &node) {
|
||||
|
||||
// if "USE" defined then find already defined element.
|
||||
if (!use.empty()) {
|
||||
X3DNodeElementBase *ne = nullptr;
|
||||
X3DNodeElementBase *ne(nullptr);
|
||||
|
||||
ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Group, ne);
|
||||
} else {
|
||||
@@ -153,7 +153,7 @@ void X3DImporter::startReadSwitch(XmlNode &node) {
|
||||
|
||||
// if "USE" defined then find already defined element.
|
||||
if (!use.empty()) {
|
||||
X3DNodeElementBase *ne=nullptr;
|
||||
X3DNodeElementBase *ne(nullptr);
|
||||
|
||||
ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Group, ne);
|
||||
} else {
|
||||
@@ -226,8 +226,13 @@ void X3DImporter::startReadTransform(XmlNode &node) {
|
||||
// if "USE" defined then find already defined element.
|
||||
if (!use.empty()) {
|
||||
X3DNodeElementBase *ne(nullptr);
|
||||
|
||||
bool newgroup = (nullptr == mNodeElementCur);
|
||||
if(newgroup)
|
||||
ParseHelper_Group_Begin();
|
||||
ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Group, ne);
|
||||
if (newgroup && isNodeEmpty(node)) {
|
||||
ParseHelper_Node_Exit();
|
||||
}
|
||||
} else {
|
||||
ParseHelper_Group_Begin(); // create new grouping element and go deeper if node has children.
|
||||
// at this place new group mode created and made current, so we can name it.
|
||||
|
||||
@@ -60,14 +60,12 @@ namespace Assimp {
|
||||
/// \param [in] pType - type of element to find.
|
||||
/// \param [out] pNE - pointer to found node element.
|
||||
inline X3DNodeElementBase *X3DImporter::MACRO_USE_CHECKANDAPPLY(XmlNode &node, std::string pDEF, std::string pUSE, X3DElemType pType, X3DNodeElementBase *pNE) {
|
||||
if (nullptr == mNodeElementCur) {
|
||||
printf("here\n");
|
||||
}
|
||||
checkNodeMustBeEmpty(node);
|
||||
if (!pDEF.empty())
|
||||
Assimp::Throw_DEF_And_USE(node.name());
|
||||
if (!FindNodeElement(pUSE, pType, &pNE))
|
||||
Assimp::Throw_USE_NotFound(node.name(), pUSE);
|
||||
ai_assert(nullptr != mNodeElementCur);
|
||||
mNodeElementCur->Children.push_back(pNE); /* add found object as child to current element */
|
||||
|
||||
return pNE;
|
||||
|
||||
@@ -300,7 +300,7 @@ public:
|
||||
|
||||
inline unsigned int GetIndex() const { return index; }
|
||||
|
||||
operator bool() const { return vector != 0; }
|
||||
operator bool() const { return vector != nullptr && index < vector->size(); }
|
||||
|
||||
T *operator->() { return (*vector)[index]; }
|
||||
|
||||
|
||||
@@ -600,6 +600,10 @@ inline void Buffer::Read(Value &obj, Asset &r) {
|
||||
inline bool Buffer::LoadFromStream(IOStream &stream, size_t length, size_t baseOffset) {
|
||||
byteLength = length ? length : stream.FileSize();
|
||||
|
||||
if (byteLength > stream.FileSize()) {
|
||||
throw DeadlyImportError("GLTF: Invalid byteLength exceeds size of actual data.");
|
||||
}
|
||||
|
||||
if (baseOffset) {
|
||||
stream.Seek(baseOffset, aiOrigin_SET);
|
||||
}
|
||||
|
||||
@@ -1410,7 +1410,7 @@ void glTF2Exporter::ExportMetadata() {
|
||||
}
|
||||
}
|
||||
|
||||
inline Ref<Accessor> GetSamplerInputRef(Asset &asset, std::string &animId, Ref<Buffer> &buffer, std::vector<float> ×) {
|
||||
inline Ref<Accessor> GetSamplerInputRef(Asset &asset, std::string &animId, Ref<Buffer> &buffer, std::vector<ai_real> ×) {
|
||||
return ExportData(asset, animId, buffer, (unsigned int)times.size(), ×[0], AttribType::SCALAR, AttribType::SCALAR, ComponentType_FLOAT);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,9 @@ class Ref;
|
||||
}
|
||||
|
||||
namespace glTF2 {
|
||||
|
||||
class Asset;
|
||||
|
||||
struct TexProperty;
|
||||
struct TextureInfo;
|
||||
struct NormalTextureInfo;
|
||||
@@ -84,6 +86,7 @@ struct MaterialIOR;
|
||||
typedef float(vec2)[2];
|
||||
typedef float(vec3)[3];
|
||||
typedef float(vec4)[4];
|
||||
|
||||
} // namespace glTF2
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
@@ -1172,7 +1172,7 @@ ELSE()
|
||||
ENDIF()
|
||||
|
||||
# adds C_FLAGS required to compile zip.c on old GCC 4.x compiler
|
||||
TARGET_COMPILE_FEATURES(assimp PUBLIC c_std_99)
|
||||
TARGET_COMPILE_FEATURES(assimp PRIVATE c_std_99)
|
||||
|
||||
TARGET_INCLUDE_DIRECTORIES ( assimp PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
|
||||
|
||||
@@ -4,7 +4,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,
|
||||
@@ -42,6 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
/** @file PolyTools.h, various utilities for our dealings with arbitrary polygons */
|
||||
|
||||
#pragma once
|
||||
#ifndef AI_POLYTOOLS_H_INCLUDED
|
||||
#define AI_POLYTOOLS_H_INCLUDED
|
||||
|
||||
@@ -55,8 +55,7 @@ namespace Assimp {
|
||||
* The function accepts an unconstrained template parameter for use with
|
||||
* both aiVector3D and aiVector2D, but generally ignores the third coordinate.*/
|
||||
template <typename T>
|
||||
inline double GetArea2D(const T& v1, const T& v2, const T& v3)
|
||||
{
|
||||
inline double GetArea2D(const T& v1, const T& v2, const T& v3) {
|
||||
return 0.5 * (v1.x * ((double)v3.y - v2.y) + v2.x * ((double)v1.y - v3.y) + v3.x * ((double)v2.y - v1.y));
|
||||
}
|
||||
|
||||
@@ -65,8 +64,7 @@ inline double GetArea2D(const T& v1, const T& v2, const T& v3)
|
||||
* The function accepts an unconstrained template parameter for use with
|
||||
* both aiVector3D and aiVector2D, but generally ignores the third coordinate.*/
|
||||
template <typename T>
|
||||
inline bool OnLeftSideOfLine2D(const T& p0, const T& p1,const T& p2)
|
||||
{
|
||||
inline bool OnLeftSideOfLine2D(const T& p0, const T& p1,const T& p2) {
|
||||
return GetArea2D(p0,p2,p1) > 0;
|
||||
}
|
||||
|
||||
@@ -75,20 +73,23 @@ inline bool OnLeftSideOfLine2D(const T& p0, const T& p1,const T& p2)
|
||||
* The function accepts an unconstrained template parameter for use with
|
||||
* both aiVector3D and aiVector2D, but generally ignores the third coordinate.*/
|
||||
template <typename T>
|
||||
inline bool PointInTriangle2D(const T& p0, const T& p1,const T& p2, const T& pp)
|
||||
{
|
||||
inline bool PointInTriangle2D(const T& p0, const T& p1,const T& p2, const T& pp) {
|
||||
// Point in triangle test using baryzentric coordinates
|
||||
const aiVector2D v0 = p1 - p0;
|
||||
const aiVector2D v1 = p2 - p0;
|
||||
const aiVector2D v2 = pp - p0;
|
||||
|
||||
double dot00 = v0 * v0;
|
||||
double dot01 = v0 * v1;
|
||||
double dot02 = v0 * v2;
|
||||
double dot11 = v1 * v1;
|
||||
double dot12 = v1 * v2;
|
||||
|
||||
const double invDenom = 1 / (dot00 * dot11 - dot01 * dot01);
|
||||
const double dot01 = v0 * v1;
|
||||
const double dot02 = v0 * v2;
|
||||
const double dot12 = v1 * v2;
|
||||
const double denom = dot00 * dot11 - dot01 * dot01;
|
||||
if (denom == 0.0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const double invDenom = 1.0 / denom;
|
||||
dot11 = (dot11 * dot02 - dot01 * dot12) * invDenom;
|
||||
dot00 = (dot00 * dot12 - dot01 * dot02) * invDenom;
|
||||
|
||||
@@ -133,8 +134,7 @@ inline bool IsCCW(T* in, size_t npoints) {
|
||||
// in[i+2].x, in[i+2].y)) {
|
||||
convex_turn = AI_MATH_PI_F - theta;
|
||||
convex_sum += convex_turn;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
convex_sum -= AI_MATH_PI_F - theta;
|
||||
}
|
||||
}
|
||||
@@ -161,15 +161,13 @@ inline bool IsCCW(T* in, size_t npoints) {
|
||||
if (OnLeftSideOfLine2D(in[npoints-2],in[1],in[0])) {
|
||||
convex_turn = AI_MATH_PI_F - theta;
|
||||
convex_sum += convex_turn;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
convex_sum -= AI_MATH_PI_F - theta;
|
||||
}
|
||||
|
||||
return convex_sum >= (2 * AI_MATH_PI_F);
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
/** Compute the normal of an arbitrary polygon in R3.
|
||||
*
|
||||
@@ -186,8 +184,7 @@ inline bool IsCCW(T* in, size_t npoints) {
|
||||
* this method is much faster than the 'other' NewellNormal()
|
||||
*/
|
||||
template <int ofs_x, int ofs_y, int ofs_z, typename TReal>
|
||||
inline void NewellNormal (aiVector3t<TReal>& out, int num, TReal* x, TReal* y, TReal* z)
|
||||
{
|
||||
inline void NewellNormal (aiVector3t<TReal>& out, int num, TReal* x, TReal* y, TReal* z) {
|
||||
// Duplicate the first two vertices at the end
|
||||
x[(num+0)*ofs_x] = x[0];
|
||||
x[(num+1)*ofs_x] = x[ofs_x];
|
||||
@@ -224,6 +221,6 @@ inline void NewellNormal (aiVector3t<TReal>& out, int num, TReal* x, TReal* y, T
|
||||
out = aiVector3t<TReal>(sum_yz,sum_zx,sum_xy);
|
||||
}
|
||||
|
||||
} // ! Assimp
|
||||
} // ! namespace Assimp
|
||||
|
||||
#endif
|
||||
#endif // AI_POLYTOOLS_H_INCLUDED
|
||||
|
||||
@@ -1101,6 +1101,14 @@ void SceneCombiner::Copy(aiMesh **_dest, const aiMesh *src) {
|
||||
|
||||
// make a deep copy of all blend shapes
|
||||
CopyPtrArray(dest->mAnimMeshes, dest->mAnimMeshes, dest->mNumAnimMeshes);
|
||||
|
||||
// make a deep copy of all texture coordinate names
|
||||
if (src->mTextureCoordsNames != nullptr) {
|
||||
dest->mTextureCoordsNames = new aiString *[AI_MAX_NUMBER_OF_TEXTURECOORDS] {};
|
||||
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
|
||||
Copy(&dest->mTextureCoordsNames[i], src->mTextureCoordsNames[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@@ -1348,6 +1356,18 @@ void SceneCombiner::Copy(aiMetadata **_dest, const aiMetadata *src) {
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void SceneCombiner::Copy(aiString **_dest, const aiString *src) {
|
||||
if (nullptr == _dest || nullptr == src) {
|
||||
return;
|
||||
}
|
||||
|
||||
aiString *dest = *_dest = new aiString();
|
||||
|
||||
// get a flat copy
|
||||
*dest = *src;
|
||||
}
|
||||
|
||||
#if (__GNUC__ >= 8 && __GNUC_MINOR__ >= 0)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
@@ -50,6 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include "ProcessHelper.h"
|
||||
#include "Material/MaterialSystem.h"
|
||||
#include <assimp/Exceptional.h>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace Assimp;
|
||||
@@ -171,6 +172,8 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene)
|
||||
}
|
||||
// If the new material count differs from the original,
|
||||
// we need to rebuild the material list and remap mesh material indexes.
|
||||
if(iNewNum < 1)
|
||||
throw DeadlyImportError("No materials remaining");
|
||||
if (iNewNum != pScene->mNumMaterials) {
|
||||
ai_assert(iNewNum > 0);
|
||||
aiMaterial** ppcMaterials = new aiMaterial*[iNewNum];
|
||||
|
||||
@@ -361,6 +361,7 @@ public:
|
||||
static void Copy(aiNodeAnim **dest, const aiNodeAnim *src);
|
||||
static void Copy(aiMeshMorphAnim **dest, const aiMeshMorphAnim *src);
|
||||
static void Copy(aiMetadata **dest, const aiMetadata *src);
|
||||
static void Copy(aiString **dest, const aiString *src);
|
||||
|
||||
// recursive, of course
|
||||
static void Copy(aiNode **dest, const aiNode *src);
|
||||
|
||||
@@ -6,7 +6,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,
|
||||
@@ -102,7 +101,7 @@ protected:
|
||||
/** Creates a dummy material and returns it. */
|
||||
aiMaterial *CreateMaterial();
|
||||
|
||||
protected:
|
||||
private:
|
||||
/** space to assemble the mesh data: points */
|
||||
std::vector<aiVector3D> mVertices;
|
||||
|
||||
|
||||
@@ -135,7 +135,9 @@ public:
|
||||
/** Extract a particular vertex from a anim mesh and interleave all components */
|
||||
explicit Vertex(const aiAnimMesh* msh, unsigned int idx) {
|
||||
ai_assert(idx < msh->mNumVertices);
|
||||
position = msh->mVertices[idx];
|
||||
if (msh->HasPositions()) {
|
||||
position = msh->mVertices[idx];
|
||||
}
|
||||
|
||||
if (msh->HasNormals()) {
|
||||
normal = msh->mNormals[idx];
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -255,5 +255,4 @@ struct aiLight {
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // !! AI_LIGHT_H_INC
|
||||
|
||||
@@ -44,21 +44,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef AI_MATERIAL_INL_INC
|
||||
#define AI_MATERIAL_INL_INC
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiPropertyTypeInfo ai_real_to_property_type_info(float) {
|
||||
AI_FORCE_INLINE aiPropertyTypeInfo ai_real_to_property_type_info(float) {
|
||||
return aiPTI_Float;
|
||||
}
|
||||
|
||||
AI_FORCE_INLINE
|
||||
aiPropertyTypeInfo ai_real_to_property_type_info(double) {
|
||||
AI_FORCE_INLINE aiPropertyTypeInfo ai_real_to_property_type_info(double) {
|
||||
return aiPTI_Double;
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -66,8 +62,7 @@ aiPropertyTypeInfo ai_real_to_property_type_info(double) {
|
||||
//! @cond never
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::GetTexture( aiTextureType type,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::GetTexture( aiTextureType type,
|
||||
unsigned int index,
|
||||
C_STRUCT aiString* path,
|
||||
aiTextureMapping* mapping /*= NULL*/,
|
||||
@@ -79,15 +74,13 @@ aiReturn aiMaterial::GetTexture( aiTextureType type,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
unsigned int aiMaterial::GetTextureCount(aiTextureType type) const {
|
||||
AI_FORCE_INLINE unsigned int aiMaterial::GetTextureCount(aiTextureType type) const {
|
||||
return ::aiGetMaterialTextureCount(this,type);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
template <typename Type>
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
unsigned int idx, Type* pOut,
|
||||
unsigned int* pMax) const {
|
||||
unsigned int iNum = pMax ? *pMax : 1;
|
||||
@@ -105,7 +98,7 @@ aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
return AI_FAILURE;
|
||||
}
|
||||
|
||||
iNum = std::min((size_t)iNum,prop->mDataLength / sizeof(Type));
|
||||
iNum = static_cast<unsigned int>(std::min(static_cast<size_t>(iNum),prop->mDataLength / sizeof(Type)));
|
||||
::memcpy(pOut,prop->mData,iNum * sizeof(Type));
|
||||
if (pMax) {
|
||||
*pMax = iNum;
|
||||
@@ -116,8 +109,7 @@ aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
template <typename Type>
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
unsigned int idx,Type& pOut) const {
|
||||
const aiMaterialProperty* prop;
|
||||
const aiReturn ret = ::aiGetMaterialProperty(this,pKey,type,idx,
|
||||
@@ -138,34 +130,29 @@ aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
unsigned int idx,ai_real* pOut,
|
||||
unsigned int* pMax) const {
|
||||
return ::aiGetMaterialFloatArray(this,pKey,type,idx,pOut,pMax);
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
unsigned int idx,int* pOut,
|
||||
unsigned int* pMax) const {
|
||||
return ::aiGetMaterialIntegerArray(this,pKey,type,idx,pOut,pMax);
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
unsigned int idx,ai_real& pOut) const {
|
||||
return aiGetMaterialFloat(this,pKey,type,idx,&pOut);
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
unsigned int idx,int& pOut) const {
|
||||
return aiGetMaterialInteger(this,pKey,type,idx,&pOut);
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
unsigned int idx,aiColor4D& pOut) const {
|
||||
return aiGetMaterialColor(this,pKey,type,idx,&pOut);
|
||||
}
|
||||
@@ -190,14 +177,10 @@ AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
template<class TYPE>
|
||||
aiReturn aiMaterial::AddProperty (const TYPE* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
unsigned int index)
|
||||
{
|
||||
return AddBinaryProperty((const void*)pInput,
|
||||
pNumValues * sizeof(TYPE),
|
||||
aiReturn aiMaterial::AddProperty (const TYPE* pInput,
|
||||
const unsigned int pNumValues, const char* pKey, unsigned int type,
|
||||
unsigned int index) {
|
||||
return AddBinaryProperty((const void*)pInput, pNumValues * sizeof(TYPE),
|
||||
pKey,type,index,aiPTI_Buffer);
|
||||
}
|
||||
|
||||
@@ -213,8 +196,7 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const float* pInput,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty(const double* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const double* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
@@ -225,8 +207,7 @@ aiReturn aiMaterial::AddProperty(const double* pInput,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
@@ -237,8 +218,7 @@ aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty(const aiColor4D* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiColor4D* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
@@ -249,8 +229,7 @@ aiReturn aiMaterial::AddProperty(const aiColor4D* pInput,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty(const aiColor3D* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiColor3D* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
@@ -261,8 +240,7 @@ aiReturn aiMaterial::AddProperty(const aiColor3D* pInput,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty(const aiVector3D* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiVector3D* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
@@ -273,8 +251,7 @@ aiReturn aiMaterial::AddProperty(const aiVector3D* pInput,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty(const int* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const int* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
@@ -293,8 +270,7 @@ aiReturn aiMaterial::AddProperty(const int* pInput,
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
template<>
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty<float>(const float* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<float>(const float* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
@@ -306,8 +282,7 @@ aiReturn aiMaterial::AddProperty<float>(const float* pInput,
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
template<>
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty<double>(const double* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<double>(const double* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
@@ -319,8 +294,7 @@ aiReturn aiMaterial::AddProperty<double>(const double* pInput,
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
template<>
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty<aiUVTransform>(const aiUVTransform* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiUVTransform>(const aiUVTransform* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
@@ -332,8 +306,7 @@ aiReturn aiMaterial::AddProperty<aiUVTransform>(const aiUVTransform* pInput,
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
template<>
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty<aiColor4D>(const aiColor4D* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiColor4D>(const aiColor4D* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
@@ -345,8 +318,7 @@ aiReturn aiMaterial::AddProperty<aiColor4D>(const aiColor4D* pInput,
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
template<>
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty<aiColor3D>(const aiColor3D* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiColor3D>(const aiColor3D* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
@@ -358,8 +330,7 @@ aiReturn aiMaterial::AddProperty<aiColor3D>(const aiColor3D* pInput,
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
template<>
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty<aiVector3D>(const aiVector3D* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiVector3D>(const aiVector3D* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
@@ -371,8 +342,7 @@ aiReturn aiMaterial::AddProperty<aiVector3D>(const aiVector3D* pInput,
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
template<>
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty<int>(const int* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<int>(const int* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
@@ -383,5 +353,3 @@ aiReturn aiMaterial::AddProperty<int>(const int* pInput,
|
||||
}
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif //! AI_MATERIAL_INL_INC
|
||||
|
||||
@@ -92,22 +92,19 @@ struct aiTexel {
|
||||
|
||||
#ifdef __cplusplus
|
||||
//! Comparison operator
|
||||
bool operator== (const aiTexel& other) const
|
||||
{
|
||||
bool operator== (const aiTexel& other) const {
|
||||
return b == other.b && r == other.r &&
|
||||
g == other.g && a == other.a;
|
||||
}
|
||||
|
||||
//! Inverse comparison operator
|
||||
bool operator!= (const aiTexel& other) const
|
||||
{
|
||||
bool operator!= (const aiTexel& other) const {
|
||||
return b != other.b || r != other.r ||
|
||||
g != other.g || a != other.a;
|
||||
}
|
||||
|
||||
//! Conversion to a floating-point 4d color
|
||||
operator aiColor4D() const
|
||||
{
|
||||
operator aiColor4D() const {
|
||||
return aiColor4D(r/255.f,g/255.f,b/255.f,a/255.f);
|
||||
}
|
||||
#endif // __cplusplus
|
||||
@@ -202,11 +199,11 @@ struct aiTexture {
|
||||
}
|
||||
|
||||
// Construction
|
||||
aiTexture() AI_NO_EXCEPT
|
||||
: mWidth(0)
|
||||
, mHeight(0)
|
||||
, pcData(nullptr)
|
||||
, mFilename() {
|
||||
aiTexture() AI_NO_EXCEPT :
|
||||
mWidth(0),
|
||||
mHeight(0),
|
||||
pcData(nullptr),
|
||||
mFilename() {
|
||||
memset(achFormatHint, 0, sizeof(achFormatHint));
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -54,8 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
/** Transformation of a vector by a 3x3 matrix */
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator * (const aiMatrix3x3t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator * (const aiMatrix3x3t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) {
|
||||
aiVector3t<TReal> res;
|
||||
res.x = pMatrix.a1 * pVector.x + pMatrix.a2 * pVector.y + pMatrix.a3 * pVector.z;
|
||||
res.y = pMatrix.b1 * pVector.x + pMatrix.b2 * pVector.y + pMatrix.b3 * pVector.z;
|
||||
@@ -66,8 +65,7 @@ aiVector3t<TReal> operator * (const aiMatrix3x3t<TReal>& pMatrix, const aiVector
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
/** Transformation of a vector by a 4x4 matrix */
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator * (const aiMatrix4x4t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator * (const aiMatrix4x4t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) {
|
||||
aiVector3t<TReal> res;
|
||||
res.x = pMatrix.a1 * pVector.x + pMatrix.a2 * pVector.y + pMatrix.a3 * pVector.z + pMatrix.a4;
|
||||
res.y = pMatrix.b1 * pVector.x + pMatrix.b2 * pVector.y + pMatrix.b3 * pVector.z + pMatrix.b4;
|
||||
@@ -82,36 +80,35 @@ aiVector3t<TReal>::operator aiVector3t<TOther> () const {
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
void aiVector3t<TReal>::Set( TReal pX, TReal pY, TReal pZ) {
|
||||
AI_FORCE_INLINE void aiVector3t<TReal>::Set( TReal pX, TReal pY, TReal pZ) {
|
||||
x = pX;
|
||||
y = pY;
|
||||
z = pZ;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
TReal aiVector3t<TReal>::SquareLength() const {
|
||||
AI_FORCE_INLINE TReal aiVector3t<TReal>::SquareLength() const {
|
||||
return x*x + y*y + z*z;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
TReal aiVector3t<TReal>::Length() const {
|
||||
AI_FORCE_INLINE TReal aiVector3t<TReal>::Length() const {
|
||||
return std::sqrt( SquareLength());
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal>& aiVector3t<TReal>::Normalize() {
|
||||
aiVector3t<TReal>& aiVector3t<TReal>::Normalize() {
|
||||
const TReal l = Length();
|
||||
if (l == 0) {
|
||||
return *this;
|
||||
}
|
||||
*this /= Length();
|
||||
|
||||
return *this;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal>& aiVector3t<TReal>::NormalizeSafe() {
|
||||
AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::NormalizeSafe() {
|
||||
TReal len = Length();
|
||||
if ( len > static_cast< TReal >( 0 ) ) {
|
||||
*this /= len;
|
||||
@@ -120,8 +117,7 @@ aiVector3t<TReal>& aiVector3t<TReal>::NormalizeSafe() {
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
const aiVector3t<TReal>& aiVector3t<TReal>::operator += (const aiVector3t<TReal>& o) {
|
||||
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator += (const aiVector3t<TReal>& o) {
|
||||
x += o.x;
|
||||
y += o.y;
|
||||
z += o.z;
|
||||
@@ -130,8 +126,7 @@ const aiVector3t<TReal>& aiVector3t<TReal>::operator += (const aiVector3t<TReal>
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
const aiVector3t<TReal>& aiVector3t<TReal>::operator -= (const aiVector3t<TReal>& o) {
|
||||
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator -= (const aiVector3t<TReal>& o) {
|
||||
x -= o.x;
|
||||
y -= o.y;
|
||||
z -= o.z;
|
||||
@@ -140,8 +135,7 @@ const aiVector3t<TReal>& aiVector3t<TReal>::operator -= (const aiVector3t<TReal>
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
const aiVector3t<TReal>& aiVector3t<TReal>::operator *= (TReal f) {
|
||||
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator *= (TReal f) {
|
||||
x *= f;
|
||||
y *= f;
|
||||
z *= f;
|
||||
@@ -150,8 +144,7 @@ const aiVector3t<TReal>& aiVector3t<TReal>::operator *= (TReal f) {
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
const aiVector3t<TReal>& aiVector3t<TReal>::operator /= (TReal f) {
|
||||
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator /= (TReal f) {
|
||||
if ( f == static_cast<TReal>(0.0)) {
|
||||
return *this;
|
||||
}
|
||||
@@ -164,20 +157,17 @@ const aiVector3t<TReal>& aiVector3t<TReal>::operator /= (TReal f) {
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix3x3t<TReal>& mat){
|
||||
AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix3x3t<TReal>& mat){
|
||||
return (*this = mat * (*this));
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix4x4t<TReal>& mat){
|
||||
AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix4x4t<TReal>& mat){
|
||||
return (*this = mat * (*this));
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
TReal aiVector3t<TReal>::operator[](unsigned int i) const {
|
||||
AI_FORCE_INLINE TReal aiVector3t<TReal>::operator[](unsigned int i) const {
|
||||
switch (i) {
|
||||
case 0:
|
||||
return x;
|
||||
@@ -192,9 +182,7 @@ TReal aiVector3t<TReal>::operator[](unsigned int i) const {
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
TReal& aiVector3t<TReal>::operator[](unsigned int i) {
|
||||
// return *(&x + i);
|
||||
AI_FORCE_INLINE TReal& aiVector3t<TReal>::operator[](unsigned int i) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
return x;
|
||||
@@ -209,20 +197,17 @@ TReal& aiVector3t<TReal>::operator[](unsigned int i) {
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
bool aiVector3t<TReal>::operator== (const aiVector3t<TReal>& other) const {
|
||||
AI_FORCE_INLINE bool aiVector3t<TReal>::operator== (const aiVector3t<TReal>& other) const {
|
||||
return x == other.x && y == other.y && z == other.z;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
bool aiVector3t<TReal>::operator!= (const aiVector3t<TReal>& other) const {
|
||||
AI_FORCE_INLINE bool aiVector3t<TReal>::operator!= (const aiVector3t<TReal>& other) const {
|
||||
return x != other.x || y != other.y || z != other.z;
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
template<typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
bool aiVector3t<TReal>::Equal(const aiVector3t<TReal>& other, TReal epsilon) const {
|
||||
AI_FORCE_INLINE bool aiVector3t<TReal>::Equal(const aiVector3t<TReal>& other, TReal epsilon) const {
|
||||
return
|
||||
std::abs(x - other.x) <= epsilon &&
|
||||
std::abs(y - other.y) <= epsilon &&
|
||||
@@ -230,77 +215,66 @@ bool aiVector3t<TReal>::Equal(const aiVector3t<TReal>& other, TReal epsilon) con
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
bool aiVector3t<TReal>::operator < (const aiVector3t<TReal>& other) const {
|
||||
AI_FORCE_INLINE bool aiVector3t<TReal>::operator < (const aiVector3t<TReal>& other) const {
|
||||
return x != other.x ? x < other.x : y != other.y ? y < other.y : z < other.z;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
const aiVector3t<TReal> aiVector3t<TReal>::SymMul(const aiVector3t<TReal>& o) {
|
||||
AI_FORCE_INLINE const aiVector3t<TReal> aiVector3t<TReal>::SymMul(const aiVector3t<TReal>& o) {
|
||||
return aiVector3t<TReal>(x*o.x,y*o.y,z*o.z);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// symmetric addition
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator + (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator + (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
return aiVector3t<TReal>( v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// symmetric subtraction
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator - (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator - (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
return aiVector3t<TReal>( v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// scalar product
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
TReal operator * (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
AI_FORCE_INLINE TReal operator * (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// scalar multiplication
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator * ( TReal f, const aiVector3t<TReal>& v) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator * ( TReal f, const aiVector3t<TReal>& v) {
|
||||
return aiVector3t<TReal>( f*v.x, f*v.y, f*v.z);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// and the other way around
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator * ( const aiVector3t<TReal>& v, TReal f) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator * ( const aiVector3t<TReal>& v, TReal f) {
|
||||
return aiVector3t<TReal>( f*v.x, f*v.y, f*v.z);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// scalar division
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, TReal f) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, TReal f) {
|
||||
return v * (1/f);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// vector division
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, const aiVector3t<TReal>& v2) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, const aiVector3t<TReal>& v2) {
|
||||
return aiVector3t<TReal>(v.x / v2.x,v.y / v2.y,v.z / v2.z);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// cross product
|
||||
template<typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator ^ ( const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator ^ ( const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
return aiVector3t<TReal>( v1.y*v2.z - v1.z*v2.y, v1.z*v2.x - v1.x*v2.z, v1.x*v2.y - v1.y*v2.x);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// vector negation
|
||||
template<typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator - ( const aiVector3t<TReal>& v) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator - ( const aiVector3t<TReal>& v) {
|
||||
return aiVector3t<TReal>( -v.x, -v.y, -v.z);
|
||||
}
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Binary file not shown.
BIN
test/models/BLEND/BlenderDefault_276.blend
Normal file
BIN
test/models/BLEND/BlenderDefault_276.blend
Normal file
Binary file not shown.
Binary file not shown.
@@ -42,6 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "UnitTestPCH.h"
|
||||
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/SceneCombiner.h>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
@@ -88,5 +89,21 @@ TEST_F(utScene, getShortFilenameTest) {
|
||||
EXPECT_NE(nullptr, name2);
|
||||
}
|
||||
|
||||
TEST_F(utScene, deepCopyTest) {
|
||||
scene->mRootNode = new aiNode();
|
||||
|
||||
scene->mNumMeshes = 1;
|
||||
scene->mMeshes = new aiMesh *[scene->mNumMeshes] ();
|
||||
scene->mMeshes[0] = new aiMesh ();
|
||||
|
||||
scene->mMeshes[0]->SetTextureCoordsName (0, aiString ("test"));
|
||||
|
||||
{
|
||||
aiScene* copied = nullptr;
|
||||
SceneCombiner::CopyScene(&copied,scene);
|
||||
delete copied;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(utScene, getEmbeddedTextureTest) {
|
||||
}
|
||||
|
||||
@@ -114,6 +114,12 @@ TEST(utBlenderImporter, importBlenderDefault271) {
|
||||
ASSERT_NE(nullptr, scene);
|
||||
}
|
||||
|
||||
TEST(utBlenderImporter, importBlenderDefault293) {
|
||||
Assimp::Importer importer;
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_276.blend", aiProcess_ValidateDataStructure);
|
||||
ASSERT_NE(nullptr, scene);
|
||||
}
|
||||
|
||||
TEST(utBlenderImporter, importCubeHierarchy_248) {
|
||||
Assimp::Importer importer;
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/CubeHierarchy_248.blend", aiProcess_ValidateDataStructure);
|
||||
|
||||
@@ -73,7 +73,7 @@ TEST_F(MaterialSystemTest, testFloatArrayProperty) {
|
||||
pf[0] = pf[1] = pf[2] = pf[3] = 12.0f;
|
||||
|
||||
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey2", 0, 0, pf, &pMax));
|
||||
EXPECT_EQ(sizeof(pf) / sizeof(float), pMax);
|
||||
EXPECT_EQ(sizeof(pf) / sizeof(float), static_cast<size_t>(pMax));
|
||||
EXPECT_TRUE(!pf[0] && 1.0f == pf[1] && 2.0f == pf[2] && 3.0f == pf[3]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user