Style tweaks.
This commit is contained in:
parent
fada9e45ee
commit
e2e0d741a2
|
@ -612,14 +612,12 @@ static void ReadMesh(RawModel &raw, FbxScene *pScene, FbxNode *pNode, const std:
|
||||||
|
|
||||||
// Associate the node to this surface
|
// Associate the node to this surface
|
||||||
int nodeId = raw.GetNodeByName(pNode->GetName());
|
int nodeId = raw.GetNodeByName(pNode->GetName());
|
||||||
if (nodeId >= 0)
|
if (nodeId >= 0) {
|
||||||
{
|
RawNode &node = raw.GetNode(nodeId);
|
||||||
RawNode& node = raw.GetNode(nodeId);
|
|
||||||
node.surfaceId = surfaceId;
|
node.surfaceId = surfaceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (raw.GetSurfaceById(surfaceId) >= 0)
|
if (raw.GetSurfaceById(surfaceId) >= 0) {
|
||||||
{
|
|
||||||
// This surface is already loaded
|
// This surface is already loaded
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,7 +293,7 @@ ModelData *Raw2Gltf(
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<NodeData>> nodesByName;
|
std::map<std::string, std::shared_ptr<NodeData>> nodesByName;
|
||||||
std::map<std::string, std::shared_ptr<MaterialData>> materialsByName;
|
std::map<std::string, std::shared_ptr<MaterialData>> materialsByName;
|
||||||
std::map<long, std::shared_ptr<MeshData>> meshBySurfaceId;
|
std::map<long, std::shared_ptr<MeshData>> meshBySurfaceId;
|
||||||
|
|
||||||
// for now, we only have one buffer; data->binary points to the same vector as that BufferData does.
|
// for now, we only have one buffer; data->binary points to the same vector as that BufferData does.
|
||||||
BufferData &buffer = *gltf->buffers.hold(
|
BufferData &buffer = *gltf->buffers.hold(
|
||||||
|
@ -475,20 +475,18 @@ ModelData *Raw2Gltf(
|
||||||
|
|
||||||
assert(surfaceModel.GetSurfaceCount() == 1);
|
assert(surfaceModel.GetSurfaceCount() == 1);
|
||||||
const RawSurface &rawSurface = surfaceModel.GetSurface(0);
|
const RawSurface &rawSurface = surfaceModel.GetSurface(0);
|
||||||
|
const int surfaceId = rawSurface.id;
|
||||||
|
|
||||||
const RawMaterial &rawMaterial = surfaceModel.GetMaterial(surfaceModel.GetTriangle(0).materialIndex);
|
const RawMaterial &rawMaterial = surfaceModel.GetMaterial(surfaceModel.GetTriangle(0).materialIndex);
|
||||||
const MaterialData &mData = require(materialsByName, materialHash(rawMaterial));
|
const MaterialData &mData = require(materialsByName, materialHash(rawMaterial));
|
||||||
|
|
||||||
int surfaceId = rawSurface.id;
|
|
||||||
//NodeData &meshNode = require(nodesByName, nodeName);
|
|
||||||
|
|
||||||
MeshData *mesh = nullptr;
|
MeshData *mesh = nullptr;
|
||||||
auto meshIter = meshBySurfaceId.find(surfaceId);
|
auto meshIter = meshBySurfaceId.find(surfaceId);
|
||||||
if (meshIter != meshBySurfaceId.end()) {
|
if (meshIter != meshBySurfaceId.end()) {
|
||||||
mesh = meshIter->second.get();
|
mesh = meshIter->second.get();
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
std::vector<float> defaultDeforms;
|
std::vector<float> defaultDeforms;
|
||||||
for (const auto &channel : rawSurface.blendChannels) {
|
for (const auto &channel : rawSurface.blendChannels) {
|
||||||
defaultDeforms.push_back(channel.defaultDeform);
|
defaultDeforms.push_back(channel.defaultDeform);
|
||||||
|
@ -517,8 +515,7 @@ ModelData *Raw2Gltf(
|
||||||
AccessorData &indexes = *gltf->accessors.hold(new AccessorData(GLT_USHORT));
|
AccessorData &indexes = *gltf->accessors.hold(new AccessorData(GLT_USHORT));
|
||||||
indexes.count = 3 * triangleCount;
|
indexes.count = 3 * triangleCount;
|
||||||
primitive.reset(new PrimitiveData(indexes, mData, dracoMesh));
|
primitive.reset(new PrimitiveData(indexes, mData, dracoMesh));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
const AccessorData &indexes = *gltf->AddAccessorWithView(
|
const AccessorData &indexes = *gltf->AddAccessorWithView(
|
||||||
*gltf->GetAlignedBufferView(buffer, BufferViewData::GL_ELEMENT_ARRAY_BUFFER),
|
*gltf->GetAlignedBufferView(buffer, BufferViewData::GL_ELEMENT_ARRAY_BUFFER),
|
||||||
GLT_USHORT, getIndexArray(surfaceModel));
|
GLT_USHORT, getIndexArray(surfaceModel));
|
||||||
|
@ -650,7 +647,7 @@ ModelData *Raw2Gltf(
|
||||||
|
|
||||||
//
|
//
|
||||||
// Assign mesh to node
|
// Assign mesh to node
|
||||||
//
|
//
|
||||||
if (node.surfaceId > 0)
|
if (node.surfaceId > 0)
|
||||||
{
|
{
|
||||||
int surfaceIndex = raw.GetSurfaceById(node.surfaceId);
|
int surfaceIndex = raw.GetSurfaceById(node.surfaceId);
|
||||||
|
|
|
@ -549,4 +549,3 @@ int RawModel::GetSurfaceById(const long surfaceId) const
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue