Fix document reset

master
Jeremy HU 2022-12-05 23:07:31 +11:00
parent ce128bff1e
commit 8b8579d02e
4 changed files with 14 additions and 1 deletions

View File

@ -67,9 +67,18 @@ void BoneGenerator::process()
previewTriangleNormals, previewTriangleNormals,
0, 0,
&previewTriangleVertexNormals); &previewTriangleVertexNormals);
std::vector<std::tuple<dust3d::Color, float /*metalness*/, float /*roughness*/>> vertexProperties(it.second.vertexColors.size());
for (size_t i = 0; i < vertexProperties.size(); ++i) {
vertexProperties[i] = std::make_tuple(it.second.vertexColors[i],
(float)0.0, (float)1.0);
}
(*m_bonePreviewMeshes)[it.first] = std::make_unique<ModelMesh>(it.second.vertices, (*m_bonePreviewMeshes)[it.first] = std::make_unique<ModelMesh>(it.second.vertices,
it.second.triangles, it.second.triangles,
previewTriangleVertexNormals); previewTriangleVertexNormals,
dust3d::Color::createWhite(),
(float)0.0,
(float)1.0,
&vertexProperties);
} }
qDebug() << "The bone generation took" << countTimeConsumed.elapsed() << "milliseconds"; qDebug() << "The bone generation took" << countTimeConsumed.elapsed() << "milliseconds";

View File

@ -2058,6 +2058,8 @@ void Document::silentReset()
partMap.clear(); partMap.clear();
componentMap.clear(); componentMap.clear();
rootComponent = Document::Component(); rootComponent = Document::Component();
boneMap.clear();
boneIdList.clear();
} }
void Document::reset() void Document::reset()

View File

@ -171,6 +171,7 @@ void BoneGenerator::addBonePreviewTriangle(BonePreview& bonePreview,
oldToNewVertexMap.insert(std::make_pair(triangle[i], bonePreview.vertices.size())); oldToNewVertexMap.insert(std::make_pair(triangle[i], bonePreview.vertices.size()));
newTriangle[i] = bonePreview.vertices.size(); newTriangle[i] = bonePreview.vertices.size();
bonePreview.vertices.push_back(m_vertices[triangle[i]]); bonePreview.vertices.push_back(m_vertices[triangle[i]]);
bonePreview.vertexColors.push_back(Color(1.0, 1.0, 1.0));
} else { } else {
newTriangle[i] = findVertex->second; newTriangle[i] = findVertex->second;
} }

View File

@ -62,6 +62,7 @@ public:
struct BonePreview { struct BonePreview {
std::vector<Vector3> vertices; std::vector<Vector3> vertices;
std::vector<std::vector<size_t>> triangles; std::vector<std::vector<size_t>> triangles;
std::vector<Color> vertexColors;
}; };
BoneGenerator(); BoneGenerator();