Remove old object nodes

master
Jeremy HU 2022-11-13 18:02:53 +11:00
parent 5b6861be44
commit 34cc69f003
6 changed files with 43 additions and 37 deletions

View File

@ -22,7 +22,7 @@ dust3d::Object* MeshResultPostProcessor::takePostProcessedObject()
void MeshResultPostProcessor::poseProcess() void MeshResultPostProcessor::poseProcess()
{ {
if (!m_object->nodes.empty()) { //if (!m_object->nodes.empty()) {
/* /*
{ {
std::vector<std::vector<dust3d::Vector2>> triangleVertexUvs; std::vector<std::vector<dust3d::Vector2>> triangleVertexUvs;
@ -39,7 +39,7 @@ void MeshResultPostProcessor::poseProcess()
m_object->setTriangleTangents(triangleTangents); m_object->setTriangleTangents(triangleTangents);
} }
*/ */
} //}
} }
void MeshResultPostProcessor::process() void MeshResultPostProcessor::process()

View File

@ -130,11 +130,11 @@ ModelMesh::ModelMesh(dust3d::Object& object)
m_vertices = object.vertices; m_vertices = object.vertices;
m_faces = object.triangleAndQuads; m_faces = object.triangleAndQuads;
std::map<std::pair<dust3d::Uuid, dust3d::Uuid>, const dust3d::ObjectNode*> nodeMap; //std::map<std::pair<dust3d::Uuid, dust3d::Uuid>, const dust3d::ObjectNode*> nodeMap;
for (size_t i = 0; i < object.nodes.size(); ++i) { //for (size_t i = 0; i < object.nodes.size(); ++i) {
const auto& node = object.nodes[i]; // const auto& node = object.nodes[i];
nodeMap.insert({ { node.partId, node.nodeId }, &node }); // nodeMap.insert({ { node.partId, node.nodeId }, &node });
} //}
m_triangleVertexCount = (int)object.triangles.size() * 3; m_triangleVertexCount = (int)object.triangles.size() * 3;
m_triangleVertices = new ModelOpenGLVertex[m_triangleVertexCount]; m_triangleVertices = new ModelOpenGLVertex[m_triangleVertexCount];
@ -172,14 +172,14 @@ ModelMesh::ModelMesh(dust3d::Object& object)
dest->normX = srcNormal->x(); dest->normX = srcNormal->x();
dest->normY = srcNormal->y(); dest->normY = srcNormal->y();
dest->normZ = srcNormal->z(); dest->normZ = srcNormal->z();
auto findNode = nodeMap.find(object.vertexSourceNodes[vertexIndex]); //auto findNode = nodeMap.find(object.vertexSourceNodes[vertexIndex]);
if (findNode != nodeMap.end()) { //if (findNode != nodeMap.end()) {
dest->metalness = findNode->second->metalness; // dest->metalness = findNode->second->metalness;
dest->roughness = findNode->second->roughness; // dest->roughness = findNode->second->roughness;
} else { //} else {
dest->metalness = m_defaultMetalness; dest->metalness = m_defaultMetalness;
dest->roughness = m_defaultRoughness; dest->roughness = m_defaultRoughness;
} //}
dest->tangentX = srcTangent->x(); dest->tangentX = srcTangent->x();
dest->tangentY = srcTangent->y(); dest->tangentY = srcTangent->y();
dest->tangentZ = srcTangent->z(); dest->tangentZ = srcTangent->z();

View File

@ -56,8 +56,8 @@ struct ObjectNode {
class Object { class Object {
public: public:
std::vector<ObjectNode> nodes; //std::vector<ObjectNode> nodes;
std::vector<std::pair<std::pair<Uuid, Uuid>, std::pair<Uuid, Uuid>>> edges; //std::vector<std::pair<std::pair<Uuid, Uuid>, std::pair<Uuid, Uuid>>> edges;
std::vector<Vector3> vertices; std::vector<Vector3> vertices;
std::vector<std::pair<Uuid, Uuid>> vertexSourceNodes; std::vector<std::pair<Uuid, Uuid>> vertexSourceNodes;
std::vector<std::vector<size_t>> triangleAndQuads; std::vector<std::vector<size_t>> triangleAndQuads;

View File

@ -1055,22 +1055,22 @@ void MeshGenerator::postprocessObject(Object* object)
object->triangleNormals = combinedFacesNormals; object->triangleNormals = combinedFacesNormals;
std::vector<std::pair<Uuid, Uuid>> sourceNodes; //std::vector<std::pair<Uuid, Uuid>> sourceNodes;
resolveTriangleSourceNode(*object, m_nodeVertices, sourceNodes, &object->vertexSourceNodes); //resolveTriangleSourceNode(*object, m_nodeVertices, sourceNodes, &object->vertexSourceNodes);
object->setTriangleSourceNodes(sourceNodes); //object->setTriangleSourceNodes(sourceNodes);
std::map<std::pair<Uuid, Uuid>, Color> sourceNodeToColorMap; //std::map<std::pair<Uuid, Uuid>, Color> sourceNodeToColorMap;
for (const auto& node : object->nodes) //for (const auto& node : object->nodes)
sourceNodeToColorMap.insert({ { node.partId, node.nodeId }, node.color }); // sourceNodeToColorMap.insert({ { node.partId, node.nodeId }, node.color });
object->triangleColors.resize(object->triangles.size(), Color::createWhite()); object->triangleColors.resize(object->triangles.size(), Color::createWhite());
const std::vector<std::pair<Uuid, Uuid>>* triangleSourceNodes = object->triangleSourceNodes(); //const std::vector<std::pair<Uuid, Uuid>>* triangleSourceNodes = object->triangleSourceNodes();
if (nullptr != triangleSourceNodes) { //if (nullptr != triangleSourceNodes) {
for (size_t triangleIndex = 0; triangleIndex < object->triangles.size(); triangleIndex++) { //for (size_t triangleIndex = 0; triangleIndex < object->triangles.size(); triangleIndex++) {
const auto& source = (*triangleSourceNodes)[triangleIndex]; //const auto& source = (*triangleSourceNodes)[triangleIndex];
object->triangleColors[triangleIndex] = sourceNodeToColorMap[source]; //object->triangleColors[triangleIndex] = sourceNodeToColorMap[source];
} //}
} //}
std::vector<std::vector<Vector3>> triangleVertexNormals; std::vector<std::vector<Vector3>> triangleVertexNormals;
smoothNormal(object->vertices, smoothNormal(object->vertices,
@ -1117,8 +1117,8 @@ void MeshGenerator::collectUncombinedComponent(const std::string& componentIdStr
return; return;
} }
m_object->nodes.insert(m_object->nodes.end(), componentCache.objectNodes.begin(), componentCache.objectNodes.end()); //m_object->nodes.insert(m_object->nodes.end(), componentCache.objectNodes.begin(), componentCache.objectNodes.end());
m_object->edges.insert(m_object->edges.end(), componentCache.objectEdges.begin(), componentCache.objectEdges.end()); //m_object->edges.insert(m_object->edges.end(), componentCache.objectEdges.begin(), componentCache.objectEdges.end());
m_nodeVertices.insert(m_nodeVertices.end(), componentCache.objectNodeVertices.begin(), componentCache.objectNodeVertices.end()); m_nodeVertices.insert(m_nodeVertices.end(), componentCache.objectNodeVertices.begin(), componentCache.objectNodeVertices.end());
collectIncombinableMesh(componentCache.mesh.get(), componentCache); collectIncombinableMesh(componentCache.mesh.get(), componentCache);
@ -1293,8 +1293,8 @@ void MeshGenerator::generate()
const auto& componentCache = m_cacheContext->components[to_string(Uuid())]; const auto& componentCache = m_cacheContext->components[to_string(Uuid())];
m_object->nodes = componentCache.objectNodes; //m_object->nodes = componentCache.objectNodes;
m_object->edges = componentCache.objectEdges; //m_object->edges = componentCache.objectEdges;
m_object->partTriangleUvs = componentCache.partTriangleUvs; m_object->partTriangleUvs = componentCache.partTriangleUvs;
m_nodeVertices = componentCache.objectNodeVertices; m_nodeVertices = componentCache.objectNodeVertices;

View File

@ -45,6 +45,11 @@ const std::vector<Vector3>& TubeMeshBuilder::generatedVertices()
return m_generatedVertices; return m_generatedVertices;
} }
const std::vector<Uuid>& TubeMeshBuilder::generatedVertexSources()
{
return m_generatedVertexSources;
}
const std::vector<std::vector<size_t>>& TubeMeshBuilder::generatedFaces() const std::vector<std::vector<size_t>>& TubeMeshBuilder::generatedFaces()
{ {
return m_generatedFaces; return m_generatedFaces;
@ -113,8 +118,6 @@ void TubeMeshBuilder::preprocessNodes()
{ {
applyInterpolation(); applyInterpolation();
applyRoundEnd(); applyRoundEnd();
// TODO: Interpolate...
} }
void TubeMeshBuilder::buildNodePositionAndDirections() void TubeMeshBuilder::buildNodePositionAndDirections()
@ -260,6 +263,7 @@ void TubeMeshBuilder::build()
for (size_t k = 0; k < cutFaceVertices.size(); ++k) { for (size_t k = 0; k < cutFaceVertices.size(); ++k) {
cutFaceIndices[i][k] = m_generatedVertices.size(); cutFaceIndices[i][k] = m_generatedVertices.size();
m_generatedVertices.emplace_back(cutFaceVertices[k]); m_generatedVertices.emplace_back(cutFaceVertices[k]);
m_generatedVertexSources.emplace_back(m_nodes[i].sourceId);
} }
} }

View File

@ -47,6 +47,7 @@ public:
void build(); void build();
const Vector3& generatedBaseNormal(); const Vector3& generatedBaseNormal();
const std::vector<Vector3>& generatedVertices(); const std::vector<Vector3>& generatedVertices();
const std::vector<Uuid>& generatedVertexSources();
const std::vector<std::vector<size_t>>& generatedFaces(); const std::vector<std::vector<size_t>>& generatedFaces();
const std::vector<std::vector<Vector2>>& generatedFaceUvs(); const std::vector<std::vector<Vector2>>& generatedFaceUvs();
@ -56,6 +57,7 @@ private:
std::vector<Vector3> m_nodePositions; std::vector<Vector3> m_nodePositions;
std::vector<Vector3> m_nodeForwardDirections; std::vector<Vector3> m_nodeForwardDirections;
std::vector<double> m_nodeForwardDistances; std::vector<double> m_nodeForwardDistances;
std::vector<Uuid> m_generatedVertexSources;
std::vector<Vector3> m_generatedVertices; std::vector<Vector3> m_generatedVertices;
std::vector<std::vector<size_t>> m_generatedFaces; std::vector<std::vector<size_t>> m_generatedFaces;
std::vector<std::vector<Vector2>> m_generatedFaceUvs; std::vector<std::vector<Vector2>> m_generatedFaceUvs;