summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/assimp/code/BlenderDNA.inl
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/assimp/code/BlenderDNA.inl')
-rw-r--r--src/3rdparty/assimp/code/BlenderDNA.inl31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/3rdparty/assimp/code/BlenderDNA.inl b/src/3rdparty/assimp/code/BlenderDNA.inl
index 0b3f2fd02..c65ea81bc 100644
--- a/src/3rdparty/assimp/code/BlenderDNA.inl
+++ b/src/3rdparty/assimp/code/BlenderDNA.inl
@@ -2,7 +2,8 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2016, assimp team
+Copyright (c) 2006-2017, assimp team
+
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -46,9 +47,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define INCLUDED_AI_BLEND_DNA_INL
#include <memory>
+#include "TinyFormatter.h"
namespace Assimp {
- namespace Blender {
+namespace Blender {
//--------------------------------------------------------------------------------
const Field& Structure :: operator [] (const std::string& ss) const
@@ -532,7 +534,7 @@ template <typename T> struct signless;
template <> struct signless<char> {typedef unsigned char type;};
template <> struct signless<short> {typedef unsigned short type;};
template <> struct signless<int> {typedef unsigned int type;};
-
+template <> struct signless<unsigned char> { typedef unsigned char type; };
template <typename T>
struct static_cast_silent {
template <typename V>
@@ -583,11 +585,14 @@ template <> inline void Structure :: Convert<int> (int& dest,const FileDataba
}
// ------------------------------------------------------------------------------------------------
-template <> inline void Structure :: Convert<short> (short& dest,const FileDatabase& db) const
+template<> inline void Structure :: Convert<short> (short& dest,const FileDatabase& db) const
{
// automatic rescaling from short to float and vice versa (seems to be used by normals)
if (name == "float") {
- dest = static_cast<short>(db.reader->GetF4() * 32767.f);
+ float f = db.reader->GetF4();
+ if ( f > 1.0f )
+ f = 1.0f;
+ dest = static_cast<short>( f * 32767.f);
//db.reader->IncPtr(-4);
return;
}
@@ -615,6 +620,22 @@ template <> inline void Structure :: Convert<char> (char& dest,const FileDatab
}
// ------------------------------------------------------------------------------------------------
+template <> inline void Structure::Convert<unsigned char>(unsigned char& dest, const FileDatabase& db) const
+{
+ // automatic rescaling from char to float and vice versa (seems useful for RGB colors)
+ if (name == "float") {
+ dest = static_cast<unsigned char>(db.reader->GetF4() * 255.f);
+ return;
+ }
+ else if (name == "double") {
+ dest = static_cast<unsigned char>(db.reader->GetF8() * 255.f);
+ return;
+ }
+ ConvertDispatcher(dest, *this, db);
+}
+
+
+// ------------------------------------------------------------------------------------------------
template <> inline void Structure :: Convert<float> (float& dest,const FileDatabase& db) const
{
// automatic rescaling from char to float and vice versa (seems useful for RGB colors)