From bcb86bcc352459a29e6a8aaed28d6ab6b3aa4a7d Mon Sep 17 00:00:00 2001 From: TrianglesPCT Date: Sun, 24 Jul 2016 02:23:59 -0600 Subject: [PATCH] Add files via upload fix blender vert colors being casted to signed char, which was causing negative values. Also fix blender vert colors being way outside of 0 to 1 range which aiColor specifies --- code/BlenderDNA.inl | 18 +++++++++++++++++- code/BlenderScene.h | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/code/BlenderDNA.inl b/code/BlenderDNA.inl index 0b3f2fd02..7397e291b 100644 --- a/code/BlenderDNA.inl +++ b/code/BlenderDNA.inl @@ -532,7 +532,7 @@ template struct signless; template <> struct signless {typedef unsigned char type;}; template <> struct signless {typedef unsigned short type;}; template <> struct signless {typedef unsigned int type;}; - +template <> struct signless { typedef unsigned char type; }; template struct static_cast_silent { template @@ -614,6 +614,22 @@ template <> inline void Structure :: Convert (char& dest,const FileDatab ConvertDispatcher(dest,*this,db); } +// ------------------------------------------------------------------------------------------------ +template <> inline void Structure::Convert(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(db.reader->GetF4() * 255.f); + return; + } + else if (name == "double") { + dest = static_cast(db.reader->GetF8() * 255.f); + return; + } + ConvertDispatcher(dest, *this, db); +} + + // ------------------------------------------------------------------------------------------------ template <> inline void Structure :: Convert (float& dest,const FileDatabase& db) const { diff --git a/code/BlenderScene.h b/code/BlenderScene.h index 9de0fcb39..765d95091 100644 --- a/code/BlenderScene.h +++ b/code/BlenderScene.h @@ -175,7 +175,7 @@ struct MLoopUV : ElemBase { // ------------------------------------------------------------------------------- // Note that red and blue are not swapped, as with MCol struct MLoopCol : ElemBase { - char r, g, b, a; + unsigned char r, g, b, a; }; // -------------------------------------------------------------------------------