Give more appropriate names for some model-related constants and move them into HFM.h

This commit is contained in:
sabrina-shanman 2018-12-07 12:11:19 -08:00
parent c41174a823
commit ec748c60cf
3 changed files with 27 additions and 27 deletions

View file

@ -19,20 +19,6 @@
#include <glm/glm.hpp>
#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 ");

View file

@ -42,16 +42,6 @@
using vec2h = glm::tvec2<glm::detail::hdata>;
#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));

View file

@ -25,6 +25,30 @@
#include <graphics/Geometry.h>
#include <graphics/Material.h>
#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