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; }; // -------------------------------------------------------------------------------