Fix various tabs vs spaces formatting inconsistencies
This commit is contained in:
parent
8b081a5fc3
commit
f2cb6a1010
|
@ -57,10 +57,10 @@ GetMaterialType(const RawModel &raw, const int textures[RAW_TEXTURE_USAGE_MAX],
|
||||||
: (skinned ? RAW_MATERIAL_TYPE_SKINNED_TRANSPARENT : RAW_MATERIAL_TYPE_TRANSPARENT);
|
: (skinned ? RAW_MATERIAL_TYPE_SKINNED_TRANSPARENT : RAW_MATERIAL_TYPE_TRANSPARENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// else if there is any vertex transparency, treat whole mesh as transparent
|
// else if there is any vertex transparency, treat whole mesh as transparent
|
||||||
if (vertexTransparency) {
|
if (vertexTransparency) {
|
||||||
return skinned ? RAW_MATERIAL_TYPE_SKINNED_TRANSPARENT : RAW_MATERIAL_TYPE_TRANSPARENT;
|
return skinned ? RAW_MATERIAL_TYPE_SKINNED_TRANSPARENT : RAW_MATERIAL_TYPE_TRANSPARENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Default to simply opaque.
|
// Default to simply opaque.
|
||||||
|
@ -173,7 +173,7 @@ static void ReadMesh(RawModel &raw, FbxScene *pScene, FbxNode *pNode, const std:
|
||||||
for (int polygonIndex = 0; polygonIndex < pMesh->GetPolygonCount(); polygonIndex++) {
|
for (int polygonIndex = 0; polygonIndex < pMesh->GetPolygonCount(); polygonIndex++) {
|
||||||
FBX_ASSERT(pMesh->GetPolygonSize(polygonIndex) == 3);
|
FBX_ASSERT(pMesh->GetPolygonSize(polygonIndex) == 3);
|
||||||
const std::shared_ptr<FbxMaterialInfo> fbxMaterial = materials.GetMaterial(polygonIndex);
|
const std::shared_ptr<FbxMaterialInfo> fbxMaterial = materials.GetMaterial(polygonIndex);
|
||||||
const std::vector<std::string> userProperties = materials.GetUserProperties(polygonIndex);
|
const std::vector<std::string> userProperties = materials.GetUserProperties(polygonIndex);
|
||||||
|
|
||||||
int textures[RAW_TEXTURE_USAGE_MAX];
|
int textures[RAW_TEXTURE_USAGE_MAX];
|
||||||
std::fill_n(textures, (int) RAW_TEXTURE_USAGE_MAX, -1);
|
std::fill_n(textures, (int) RAW_TEXTURE_USAGE_MAX, -1);
|
||||||
|
|
|
@ -38,109 +38,109 @@ FbxMaterialsAccess::FbxMaterialsAccess(const FbxMesh *pMesh, const std::map<cons
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
FbxSurfaceMaterial* surfaceMaterial = mesh->GetNode()->GetSrcObject<FbxSurfaceMaterial>(materialNum);
|
FbxSurfaceMaterial* surfaceMaterial = mesh->GetNode()->GetSrcObject<FbxSurfaceMaterial>(materialNum);
|
||||||
|
|
||||||
if (materialNum >= summaries.size()) {
|
if (materialNum >= summaries.size()) {
|
||||||
summaries.resize(materialNum + 1);
|
summaries.resize(materialNum + 1);
|
||||||
}
|
}
|
||||||
auto summary = summaries[materialNum];
|
auto summary = summaries[materialNum];
|
||||||
if (summary == nullptr) {
|
if (summary == nullptr) {
|
||||||
summary = summaries[materialNum] = GetMaterialInfo(
|
summary = summaries[materialNum] = GetMaterialInfo(
|
||||||
surfaceMaterial,
|
surfaceMaterial,
|
||||||
textureLocations);
|
textureLocations);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (materialNum >= userProperties.size()) {
|
if (materialNum >= userProperties.size()) {
|
||||||
userProperties.resize(materialNum + 1);
|
userProperties.resize(materialNum + 1);
|
||||||
}
|
}
|
||||||
if (userProperties[materialNum].empty()) {
|
if (userProperties[materialNum].empty()) {
|
||||||
FbxProperty objectProperty = surfaceMaterial->GetFirstProperty();
|
FbxProperty objectProperty = surfaceMaterial->GetFirstProperty();
|
||||||
while (objectProperty.IsValid())
|
while (objectProperty.IsValid())
|
||||||
{
|
{
|
||||||
if (objectProperty.GetFlag(FbxPropertyFlags::eUserDefined)) {
|
if (objectProperty.GetFlag(FbxPropertyFlags::eUserDefined)) {
|
||||||
std::string ename;
|
std::string ename;
|
||||||
switch (objectProperty.GetPropertyDataType().GetType()) {
|
switch (objectProperty.GetPropertyDataType().GetType()) {
|
||||||
case eFbxBool: ename = "eFbxBool"; break;
|
case eFbxBool: ename = "eFbxBool"; break;
|
||||||
case eFbxChar: ename = "eFbxChar"; break;
|
case eFbxChar: ename = "eFbxChar"; break;
|
||||||
case eFbxUChar: ename = "eFbxUChar"; break;
|
case eFbxUChar: ename = "eFbxUChar"; break;
|
||||||
case eFbxShort: ename = "eFbxShort"; break;
|
case eFbxShort: ename = "eFbxShort"; break;
|
||||||
case eFbxUShort: ename = "eFbxUShort"; break;
|
case eFbxUShort: ename = "eFbxUShort"; break;
|
||||||
case eFbxInt: ename = "eFbxInt"; break;
|
case eFbxInt: ename = "eFbxInt"; break;
|
||||||
case eFbxUInt: ename = "eFbxUint"; break;
|
case eFbxUInt: ename = "eFbxUint"; break;
|
||||||
case eFbxLongLong: ename = "eFbxLongLong"; break;
|
case eFbxLongLong: ename = "eFbxLongLong"; break;
|
||||||
case eFbxULongLong: ename = "eFbxULongLong"; break;
|
case eFbxULongLong: ename = "eFbxULongLong"; break;
|
||||||
case eFbxFloat: ename = "eFbxFloat"; break;
|
case eFbxFloat: ename = "eFbxFloat"; break;
|
||||||
case eFbxHalfFloat: ename = "eFbxHalfFloat"; break;
|
case eFbxHalfFloat: ename = "eFbxHalfFloat"; break;
|
||||||
case eFbxDouble: ename = "eFbxDouble"; break;
|
case eFbxDouble: ename = "eFbxDouble"; break;
|
||||||
case eFbxDouble2: ename = "eFbxDouble2"; break;
|
case eFbxDouble2: ename = "eFbxDouble2"; break;
|
||||||
case eFbxDouble3: ename = "eFbxDouble3"; break;
|
case eFbxDouble3: ename = "eFbxDouble3"; break;
|
||||||
case eFbxDouble4: ename = "eFbxDouble4"; break;
|
case eFbxDouble4: ename = "eFbxDouble4"; break;
|
||||||
case eFbxString: ename = "eFbxString"; break;
|
case eFbxString: ename = "eFbxString"; break;
|
||||||
|
|
||||||
// Use this as fallback because it does not give very descriptive names
|
// Use this as fallback because it does not give very descriptive names
|
||||||
default: ename = objectProperty.GetPropertyDataType().GetName(); break;
|
default: ename = objectProperty.GetPropertyDataType().GetName(); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
json p;
|
json p;
|
||||||
p["type"] = ename;
|
p["type"] = ename;
|
||||||
|
|
||||||
// Convert property value
|
// Convert property value
|
||||||
switch (objectProperty.GetPropertyDataType().GetType()) {
|
switch (objectProperty.GetPropertyDataType().GetType()) {
|
||||||
case eFbxBool:
|
case eFbxBool:
|
||||||
case eFbxChar:
|
case eFbxChar:
|
||||||
case eFbxUChar:
|
case eFbxUChar:
|
||||||
case eFbxShort:
|
case eFbxShort:
|
||||||
case eFbxUShort:
|
case eFbxUShort:
|
||||||
case eFbxInt:
|
case eFbxInt:
|
||||||
case eFbxUInt:
|
case eFbxUInt:
|
||||||
case eFbxLongLong: {
|
case eFbxLongLong: {
|
||||||
p["value"] = objectProperty.EvaluateValue<long long>(FBXSDK_TIME_INFINITE);
|
p["value"] = objectProperty.EvaluateValue<long long>(FBXSDK_TIME_INFINITE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eFbxULongLong: {
|
case eFbxULongLong: {
|
||||||
p["value"] = objectProperty.EvaluateValue<unsigned long long>(FBXSDK_TIME_INFINITE);
|
p["value"] = objectProperty.EvaluateValue<unsigned long long>(FBXSDK_TIME_INFINITE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eFbxFloat:
|
case eFbxFloat:
|
||||||
case eFbxHalfFloat:
|
case eFbxHalfFloat:
|
||||||
case eFbxDouble: {
|
case eFbxDouble: {
|
||||||
p["value"] = objectProperty.EvaluateValue<double>(FBXSDK_TIME_INFINITE);
|
p["value"] = objectProperty.EvaluateValue<double>(FBXSDK_TIME_INFINITE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eFbxDouble2: {
|
case eFbxDouble2: {
|
||||||
auto v = objectProperty.EvaluateValue<FbxDouble2>(FBXSDK_TIME_INFINITE);
|
auto v = objectProperty.EvaluateValue<FbxDouble2>(FBXSDK_TIME_INFINITE);
|
||||||
p["value"] = { v[0], v[1] };
|
p["value"] = { v[0], v[1] };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eFbxDouble3: {
|
case eFbxDouble3: {
|
||||||
auto v = objectProperty.EvaluateValue<FbxDouble3>(FBXSDK_TIME_INFINITE);
|
auto v = objectProperty.EvaluateValue<FbxDouble3>(FBXSDK_TIME_INFINITE);
|
||||||
p["value"] = { v[0], v[1], v[2] };
|
p["value"] = { v[0], v[1], v[2] };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eFbxDouble4: {
|
case eFbxDouble4: {
|
||||||
auto v = objectProperty.EvaluateValue<FbxDouble4>(FBXSDK_TIME_INFINITE);
|
auto v = objectProperty.EvaluateValue<FbxDouble4>(FBXSDK_TIME_INFINITE);
|
||||||
p["value"] = { v[0], v[1], v[2], v[3] };
|
p["value"] = { v[0], v[1], v[2], v[3] };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eFbxString: {
|
case eFbxString: {
|
||||||
p["value"] = std::string{ objectProperty.Get<FbxString>() };
|
p["value"] = std::string{ objectProperty.Get<FbxString>() };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
p["value"] = "UNSUPPORTED_VALUE_TYPE";
|
p["value"] = "UNSUPPORTED_VALUE_TYPE";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
json n;
|
json n;
|
||||||
n[objectProperty.GetNameAsCStr()] = p;
|
n[objectProperty.GetNameAsCStr()] = p;
|
||||||
|
|
||||||
userProperties[materialNum].push_back(n.dump());
|
userProperties[materialNum].push_back(n.dump());
|
||||||
}
|
}
|
||||||
|
|
||||||
objectProperty = surfaceMaterial->GetNextProperty(objectProperty);
|
objectProperty = surfaceMaterial->GetNextProperty(objectProperty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,14 +158,14 @@ const std::shared_ptr<FbxMaterialInfo> FbxMaterialsAccess::GetMaterial(const int
|
||||||
|
|
||||||
const std::vector<std::string> FbxMaterialsAccess::GetUserProperties(const int polygonIndex) const
|
const std::vector<std::string> FbxMaterialsAccess::GetUserProperties(const int polygonIndex) const
|
||||||
{
|
{
|
||||||
if (mappingMode != FbxGeometryElement::eNone) {
|
if (mappingMode != FbxGeometryElement::eNone) {
|
||||||
const int materialNum = indices->GetAt((mappingMode == FbxGeometryElement::eByPolygon) ? polygonIndex : 0);
|
const int materialNum = indices->GetAt((mappingMode == FbxGeometryElement::eByPolygon) ? polygonIndex : 0);
|
||||||
if (materialNum < 0) {
|
if (materialNum < 0) {
|
||||||
return std::vector<std::string>();
|
return std::vector<std::string>();
|
||||||
}
|
}
|
||||||
return userProperties.at((unsigned long)materialNum);
|
return userProperties.at((unsigned long)materialNum);
|
||||||
}
|
}
|
||||||
return std::vector<std::string>();
|
return std::vector<std::string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<FbxMaterialInfo>
|
std::unique_ptr<FbxMaterialInfo>
|
||||||
|
|
|
@ -110,7 +110,7 @@ public:
|
||||||
accessor->count = attribArr.size();
|
accessor->count = attribArr.size();
|
||||||
} else {
|
} else {
|
||||||
auto bufferView = GetAlignedBufferView(buffer, BufferViewData::GL_ARRAY_BUFFER);
|
auto bufferView = GetAlignedBufferView(buffer, BufferViewData::GL_ARRAY_BUFFER);
|
||||||
accessor = AddAccessorWithView(*bufferView, attrDef.glType, attribArr, std::string(""));
|
accessor = AddAccessorWithView(*bufferView, attrDef.glType, attribArr, std::string(""));
|
||||||
}
|
}
|
||||||
primitive.AddAttrib(attrDef.gltfName, *accessor);
|
primitive.AddAttrib(attrDef.gltfName, *accessor);
|
||||||
return accessor;
|
return accessor;
|
||||||
|
|
|
@ -363,9 +363,9 @@ ModelData *Raw2Gltf(
|
||||||
emissiveFactor * emissiveIntensity, khrCmnUnlitMat, pbrMetRough));
|
emissiveFactor * emissiveIntensity, khrCmnUnlitMat, pbrMetRough));
|
||||||
materialsByName[materialHash(material)] = mData;
|
materialsByName[materialHash(material)] = mData;
|
||||||
|
|
||||||
if (options.enableUserProperties) {
|
if (options.enableUserProperties) {
|
||||||
mData->userProperties = material.userProperties;
|
mData->userProperties = material.userProperties;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &surfaceModel : materialModels) {
|
for (const auto &surfaceModel : materialModels) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ KHRCmnUnlitMaterial::KHRCmnUnlitMaterial()
|
||||||
|
|
||||||
void to_json(json &j, const KHRCmnUnlitMaterial &d)
|
void to_json(json &j, const KHRCmnUnlitMaterial &d)
|
||||||
{
|
{
|
||||||
j = json({});
|
j = json({});
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float clamp(float d, float bottom = 0, float top = 1) {
|
inline float clamp(float d, float bottom = 0, float top = 1) {
|
||||||
|
@ -129,16 +129,16 @@ json MaterialData::serialize() const
|
||||||
result["extensions"] = extensions;
|
result["extensions"] = extensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& i : userProperties)
|
for (const auto& i : userProperties)
|
||||||
{
|
{
|
||||||
auto& prop_map = result["extras"]["fromFBX"]["userProperties"];
|
auto& prop_map = result["extras"]["fromFBX"]["userProperties"];
|
||||||
|
|
||||||
json j = json::parse(i);
|
json j = json::parse(i);
|
||||||
for (const auto& k : json::iterator_wrapper(j))
|
for (const auto& k : json::iterator_wrapper(j))
|
||||||
{
|
{
|
||||||
prop_map[k.key()] = k.value();
|
prop_map[k.key()] = k.value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ struct MaterialData : Holdable
|
||||||
const std::shared_ptr<const KHRCmnUnlitMaterial> khrCmnConstantMaterial;
|
const std::shared_ptr<const KHRCmnUnlitMaterial> khrCmnConstantMaterial;
|
||||||
const std::shared_ptr<const PBRMetallicRoughness> pbrMetallicRoughness;
|
const std::shared_ptr<const PBRMetallicRoughness> pbrMetallicRoughness;
|
||||||
|
|
||||||
std::vector<std::string> userProperties;
|
std::vector<std::string> userProperties;
|
||||||
};
|
};
|
||||||
|
|
||||||
void to_json(json &j, const Tex &data);
|
void to_json(json &j, const Tex &data);
|
||||||
|
|
|
@ -121,7 +121,7 @@ int RawModel::AddMaterial(
|
||||||
const RawMaterialType materialType,
|
const RawMaterialType materialType,
|
||||||
const int textures[RAW_TEXTURE_USAGE_MAX],
|
const int textures[RAW_TEXTURE_USAGE_MAX],
|
||||||
std::shared_ptr<RawMatProps> materialInfo,
|
std::shared_ptr<RawMatProps> materialInfo,
|
||||||
const std::vector<std::string>& userProperties)
|
const std::vector<std::string>& userProperties)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < materials.size(); i++) {
|
for (size_t i = 0; i < materials.size(); i++) {
|
||||||
if (materials[i].name != name) {
|
if (materials[i].name != name) {
|
||||||
|
@ -137,14 +137,14 @@ int RawModel::AddMaterial(
|
||||||
for (int j = 0; match && j < RAW_TEXTURE_USAGE_MAX; j++) {
|
for (int j = 0; match && j < RAW_TEXTURE_USAGE_MAX; j++) {
|
||||||
match = match && (materials[i].textures[j] == textures[j]);
|
match = match && (materials[i].textures[j] == textures[j]);
|
||||||
}
|
}
|
||||||
if (materials[i].userProperties.size() != userProperties.size()) {
|
if (materials[i].userProperties.size() != userProperties.size()) {
|
||||||
match = false;
|
match = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (int j = 0; match && j < userProperties.size(); j++) {
|
for (int j = 0; match && j < userProperties.size(); j++) {
|
||||||
match = match && (materials[i].userProperties[j] == userProperties[j]);
|
match = match && (materials[i].userProperties[j] == userProperties[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (match) {
|
if (match) {
|
||||||
return (int) i;
|
return (int) i;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ int RawModel::AddMaterial(
|
||||||
material.name = name;
|
material.name = name;
|
||||||
material.type = materialType;
|
material.type = materialType;
|
||||||
material.info = materialInfo;
|
material.info = materialInfo;
|
||||||
material.userProperties = userProperties;
|
material.userProperties = userProperties;
|
||||||
|
|
||||||
for (int i = 0; i < RAW_TEXTURE_USAGE_MAX; i++) {
|
for (int i = 0; i < RAW_TEXTURE_USAGE_MAX; i++) {
|
||||||
material.textures[i] = textures[i];
|
material.textures[i] = textures[i];
|
||||||
|
@ -623,11 +623,11 @@ size_t RawModel::CalculateNormals(bool onlyBroken)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &triangle : triangles) {
|
for (auto &triangle : triangles) {
|
||||||
bool relevant = false;
|
bool relevant = false;
|
||||||
for (int vertIx : triangle.verts) {
|
for (int vertIx : triangle.verts) {
|
||||||
relevant |= (brokenVerts.count(vertIx) > 0);
|
relevant |= (brokenVerts.count(vertIx) > 0);
|
||||||
}
|
}
|
||||||
if (!relevant) {
|
if (!relevant) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -636,8 +636,8 @@ size_t RawModel::CalculateNormals(bool onlyBroken)
|
||||||
if (!onlyBroken || brokenVerts.count(vertIx) > 0) {
|
if (!onlyBroken || brokenVerts.count(vertIx) > 0) {
|
||||||
vertices[vertIx].normal += faceNormal;
|
vertices[vertIx].normal += faceNormal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int vertIx = 0; vertIx < vertices.size(); vertIx ++) {
|
for (int vertIx = 0; vertIx < vertices.size(); vertIx ++) {
|
||||||
if (onlyBroken && brokenVerts.count(vertIx) == 0) {
|
if (onlyBroken && brokenVerts.count(vertIx) == 0) {
|
||||||
|
@ -652,6 +652,6 @@ size_t RawModel::CalculateNormals(bool onlyBroken)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vertex.normal.Normalize();
|
vertex.normal.Normalize();
|
||||||
}
|
}
|
||||||
return onlyBroken ? brokenVerts.size() : vertices.size();
|
return onlyBroken ? brokenVerts.size() : vertices.size();
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,7 +267,7 @@ struct RawMaterial
|
||||||
RawMaterialType type;
|
RawMaterialType type;
|
||||||
std::shared_ptr<RawMatProps> info;
|
std::shared_ptr<RawMatProps> info;
|
||||||
int textures[RAW_TEXTURE_USAGE_MAX];
|
int textures[RAW_TEXTURE_USAGE_MAX];
|
||||||
std::vector<std::string> userProperties;
|
std::vector<std::string> userProperties;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RawBlendChannel
|
struct RawBlendChannel
|
||||||
|
|
Loading…
Reference in New Issue