From ec748c60cf00cd2515369c196f832e8eaa9c0d02 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Fri, 7 Dec 2018 12:11:19 -0800 Subject: [PATCH] Give more appropriate names for some model-related constants and move them into HFM.h --- libraries/fbx/src/FBX.h | 14 -------------- libraries/fbx/src/FBXSerializer_Mesh.cpp | 16 +++------------- libraries/hfm/src/hfm/HFM.h | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/libraries/fbx/src/FBX.h b/libraries/fbx/src/FBX.h index 157ca5b282..8ad419c7ec 100644 --- a/libraries/fbx/src/FBX.h +++ b/libraries/fbx/src/FBX.h @@ -19,20 +19,6 @@ #include -#if defined(Q_OS_ANDROID) -#define FBX_PACK_NORMALS 0 -#else -#define FBX_PACK_NORMALS 1 -#endif - -#if FBX_PACK_NORMALS -using NormalType = glm::uint32; -#define FBX_NORMAL_ELEMENT gpu::Element::VEC4F_NORMALIZED_XYZ10W2 -#else -using NormalType = glm::vec3; -#define FBX_NORMAL_ELEMENT gpu::Element::VEC3F_XYZ -#endif - // See comment in FBXSerializer::parseFBX(). static const int FBX_HEADER_BYTES_BEFORE_VERSION = 23; static const QByteArray FBX_BINARY_PROLOG("Kaydara FBX Binary "); diff --git a/libraries/fbx/src/FBXSerializer_Mesh.cpp b/libraries/fbx/src/FBXSerializer_Mesh.cpp index 38533dbc42..a71424e286 100644 --- a/libraries/fbx/src/FBXSerializer_Mesh.cpp +++ b/libraries/fbx/src/FBXSerializer_Mesh.cpp @@ -42,16 +42,6 @@ using vec2h = glm::tvec2; -#define HFM_PACK_COLORS 1 - -#if HFM_PACK_COLORS -using ColorType = glm::uint32; -#define FBX_COLOR_ELEMENT gpu::Element::COLOR_RGBA_32 -#else -using ColorType = glm::vec3; -#define FBX_COLOR_ELEMENT gpu::Element::VEC3F_XYZ -#endif - class Vertex { public: int originalIndex; @@ -608,7 +598,7 @@ void FBXSerializer::buildModelMesh(HFMMesh& extractedMesh, const QString& url) { const int positionsSize = numVerts * positionElement.getSize(); // Normal and tangent are always there together packed in normalized xyz32bits word (times 2) - const auto normalElement = FBX_NORMAL_ELEMENT; + const auto normalElement = HFM_NORMAL_ELEMENT; const int normalsSize = hfmMesh.normals.size() * normalElement.getSize(); const int tangentsSize = hfmMesh.tangents.size() * normalElement.getSize(); // If there are normals then there should be tangents @@ -619,7 +609,7 @@ void FBXSerializer::buildModelMesh(HFMMesh& extractedMesh, const QString& url) { const auto normalsAndTangentsSize = normalsSize + tangentsSize; // Color attrib - const auto colorElement = FBX_COLOR_ELEMENT; + const auto colorElement = HFM_COLOR_ELEMENT; const int colorsSize = hfmMesh.colors.size() * colorElement.getSize(); // Texture coordinates are stored in 2 half floats @@ -664,7 +654,7 @@ void FBXSerializer::buildModelMesh(HFMMesh& extractedMesh, const QString& url) { for (auto normalIt = hfmMesh.normals.constBegin(), tangentIt = hfmMesh.tangents.constBegin(); normalIt != hfmMesh.normals.constEnd(); ++normalIt, ++tangentIt) { -#if FBX_PACK_NORMALS +#if HFM_PACK_NORMALS const auto normal = normalizeDirForPacking(*normalIt); const auto tangent = normalizeDirForPacking(*tangentIt); const auto packedNormal = glm::packSnorm3x10_1x2(glm::vec4(normal, 0.0f)); diff --git a/libraries/hfm/src/hfm/HFM.h b/libraries/hfm/src/hfm/HFM.h index de58d864b3..738f055330 100644 --- a/libraries/hfm/src/hfm/HFM.h +++ b/libraries/hfm/src/hfm/HFM.h @@ -25,6 +25,30 @@ #include #include +#if defined(Q_OS_ANDROID) +#define HFM_PACK_NORMALS 0 +#else +#define HFM_PACK_NORMALS 1 +#endif + +#if HFM_PACK_NORMALS +using NormalType = glm::uint32; +#define HFM_NORMAL_ELEMENT gpu::Element::VEC4F_NORMALIZED_XYZ10W2 +#else +using NormalType = glm::vec3; +#define HFM_NORMAL_ELEMENT gpu::Element::VEC3F_XYZ +#endif + +#define HFM_PACK_COLORS 1 + +#if HFM_PACK_COLORS +using ColorType = glm::uint32; +#define HFM_COLOR_ELEMENT gpu::Element::COLOR_RGBA_32 +#else +using ColorType = glm::vec3; +#define HFM_COLOR_ELEMENT gpu::Element::VEC3F_XYZ +#endif + const int MAX_NUM_PIXELS_FOR_FBX_TEXTURE = 2048 * 2048; // High Fidelity Model namespace