Remove old object nodes
parent
5b6861be44
commit
34cc69f003
|
@ -22,7 +22,7 @@ dust3d::Object* MeshResultPostProcessor::takePostProcessedObject()
|
|||
|
||||
void MeshResultPostProcessor::poseProcess()
|
||||
{
|
||||
if (!m_object->nodes.empty()) {
|
||||
//if (!m_object->nodes.empty()) {
|
||||
/*
|
||||
{
|
||||
std::vector<std::vector<dust3d::Vector2>> triangleVertexUvs;
|
||||
|
@ -39,7 +39,7 @@ void MeshResultPostProcessor::poseProcess()
|
|||
m_object->setTriangleTangents(triangleTangents);
|
||||
}
|
||||
*/
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
void MeshResultPostProcessor::process()
|
||||
|
|
|
@ -130,11 +130,11 @@ ModelMesh::ModelMesh(dust3d::Object& object)
|
|||
m_vertices = object.vertices;
|
||||
m_faces = object.triangleAndQuads;
|
||||
|
||||
std::map<std::pair<dust3d::Uuid, dust3d::Uuid>, const dust3d::ObjectNode*> nodeMap;
|
||||
for (size_t i = 0; i < object.nodes.size(); ++i) {
|
||||
const auto& node = object.nodes[i];
|
||||
nodeMap.insert({ { node.partId, node.nodeId }, &node });
|
||||
}
|
||||
//std::map<std::pair<dust3d::Uuid, dust3d::Uuid>, const dust3d::ObjectNode*> nodeMap;
|
||||
//for (size_t i = 0; i < object.nodes.size(); ++i) {
|
||||
// const auto& node = object.nodes[i];
|
||||
// nodeMap.insert({ { node.partId, node.nodeId }, &node });
|
||||
//}
|
||||
|
||||
m_triangleVertexCount = (int)object.triangles.size() * 3;
|
||||
m_triangleVertices = new ModelOpenGLVertex[m_triangleVertexCount];
|
||||
|
@ -172,14 +172,14 @@ ModelMesh::ModelMesh(dust3d::Object& object)
|
|||
dest->normX = srcNormal->x();
|
||||
dest->normY = srcNormal->y();
|
||||
dest->normZ = srcNormal->z();
|
||||
auto findNode = nodeMap.find(object.vertexSourceNodes[vertexIndex]);
|
||||
if (findNode != nodeMap.end()) {
|
||||
dest->metalness = findNode->second->metalness;
|
||||
dest->roughness = findNode->second->roughness;
|
||||
} else {
|
||||
//auto findNode = nodeMap.find(object.vertexSourceNodes[vertexIndex]);
|
||||
//if (findNode != nodeMap.end()) {
|
||||
// dest->metalness = findNode->second->metalness;
|
||||
// dest->roughness = findNode->second->roughness;
|
||||
//} else {
|
||||
dest->metalness = m_defaultMetalness;
|
||||
dest->roughness = m_defaultRoughness;
|
||||
}
|
||||
//}
|
||||
dest->tangentX = srcTangent->x();
|
||||
dest->tangentY = srcTangent->y();
|
||||
dest->tangentZ = srcTangent->z();
|
||||
|
|
|
@ -56,8 +56,8 @@ struct ObjectNode {
|
|||
|
||||
class Object {
|
||||
public:
|
||||
std::vector<ObjectNode> nodes;
|
||||
std::vector<std::pair<std::pair<Uuid, Uuid>, std::pair<Uuid, Uuid>>> edges;
|
||||
//std::vector<ObjectNode> nodes;
|
||||
//std::vector<std::pair<std::pair<Uuid, Uuid>, std::pair<Uuid, Uuid>>> edges;
|
||||
std::vector<Vector3> vertices;
|
||||
std::vector<std::pair<Uuid, Uuid>> vertexSourceNodes;
|
||||
std::vector<std::vector<size_t>> triangleAndQuads;
|
||||
|
|
|
@ -1055,22 +1055,22 @@ void MeshGenerator::postprocessObject(Object* object)
|
|||
|
||||
object->triangleNormals = combinedFacesNormals;
|
||||
|
||||
std::vector<std::pair<Uuid, Uuid>> sourceNodes;
|
||||
resolveTriangleSourceNode(*object, m_nodeVertices, sourceNodes, &object->vertexSourceNodes);
|
||||
object->setTriangleSourceNodes(sourceNodes);
|
||||
//std::vector<std::pair<Uuid, Uuid>> sourceNodes;
|
||||
//resolveTriangleSourceNode(*object, m_nodeVertices, sourceNodes, &object->vertexSourceNodes);
|
||||
//object->setTriangleSourceNodes(sourceNodes);
|
||||
|
||||
std::map<std::pair<Uuid, Uuid>, Color> sourceNodeToColorMap;
|
||||
for (const auto& node : object->nodes)
|
||||
sourceNodeToColorMap.insert({ { node.partId, node.nodeId }, node.color });
|
||||
//std::map<std::pair<Uuid, Uuid>, Color> sourceNodeToColorMap;
|
||||
//for (const auto& node : object->nodes)
|
||||
// sourceNodeToColorMap.insert({ { node.partId, node.nodeId }, node.color });
|
||||
|
||||
object->triangleColors.resize(object->triangles.size(), Color::createWhite());
|
||||
const std::vector<std::pair<Uuid, Uuid>>* triangleSourceNodes = object->triangleSourceNodes();
|
||||
if (nullptr != triangleSourceNodes) {
|
||||
for (size_t triangleIndex = 0; triangleIndex < object->triangles.size(); triangleIndex++) {
|
||||
const auto& source = (*triangleSourceNodes)[triangleIndex];
|
||||
object->triangleColors[triangleIndex] = sourceNodeToColorMap[source];
|
||||
}
|
||||
}
|
||||
//const std::vector<std::pair<Uuid, Uuid>>* triangleSourceNodes = object->triangleSourceNodes();
|
||||
//if (nullptr != triangleSourceNodes) {
|
||||
//for (size_t triangleIndex = 0; triangleIndex < object->triangles.size(); triangleIndex++) {
|
||||
//const auto& source = (*triangleSourceNodes)[triangleIndex];
|
||||
//object->triangleColors[triangleIndex] = sourceNodeToColorMap[source];
|
||||
//}
|
||||
//}
|
||||
|
||||
std::vector<std::vector<Vector3>> triangleVertexNormals;
|
||||
smoothNormal(object->vertices,
|
||||
|
@ -1117,8 +1117,8 @@ void MeshGenerator::collectUncombinedComponent(const std::string& componentIdStr
|
|||
return;
|
||||
}
|
||||
|
||||
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->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_nodeVertices.insert(m_nodeVertices.end(), componentCache.objectNodeVertices.begin(), componentCache.objectNodeVertices.end());
|
||||
|
||||
collectIncombinableMesh(componentCache.mesh.get(), componentCache);
|
||||
|
@ -1293,8 +1293,8 @@ void MeshGenerator::generate()
|
|||
|
||||
const auto& componentCache = m_cacheContext->components[to_string(Uuid())];
|
||||
|
||||
m_object->nodes = componentCache.objectNodes;
|
||||
m_object->edges = componentCache.objectEdges;
|
||||
//m_object->nodes = componentCache.objectNodes;
|
||||
//m_object->edges = componentCache.objectEdges;
|
||||
m_object->partTriangleUvs = componentCache.partTriangleUvs;
|
||||
m_nodeVertices = componentCache.objectNodeVertices;
|
||||
|
||||
|
|
|
@ -45,6 +45,11 @@ const std::vector<Vector3>& TubeMeshBuilder::generatedVertices()
|
|||
return m_generatedVertices;
|
||||
}
|
||||
|
||||
const std::vector<Uuid>& TubeMeshBuilder::generatedVertexSources()
|
||||
{
|
||||
return m_generatedVertexSources;
|
||||
}
|
||||
|
||||
const std::vector<std::vector<size_t>>& TubeMeshBuilder::generatedFaces()
|
||||
{
|
||||
return m_generatedFaces;
|
||||
|
@ -113,8 +118,6 @@ void TubeMeshBuilder::preprocessNodes()
|
|||
{
|
||||
applyInterpolation();
|
||||
applyRoundEnd();
|
||||
|
||||
// TODO: Interpolate...
|
||||
}
|
||||
|
||||
void TubeMeshBuilder::buildNodePositionAndDirections()
|
||||
|
@ -260,6 +263,7 @@ void TubeMeshBuilder::build()
|
|||
for (size_t k = 0; k < cutFaceVertices.size(); ++k) {
|
||||
cutFaceIndices[i][k] = m_generatedVertices.size();
|
||||
m_generatedVertices.emplace_back(cutFaceVertices[k]);
|
||||
m_generatedVertexSources.emplace_back(m_nodes[i].sourceId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ public:
|
|||
void build();
|
||||
const Vector3& generatedBaseNormal();
|
||||
const std::vector<Vector3>& generatedVertices();
|
||||
const std::vector<Uuid>& generatedVertexSources();
|
||||
const std::vector<std::vector<size_t>>& generatedFaces();
|
||||
const std::vector<std::vector<Vector2>>& generatedFaceUvs();
|
||||
|
||||
|
@ -56,6 +57,7 @@ private:
|
|||
std::vector<Vector3> m_nodePositions;
|
||||
std::vector<Vector3> m_nodeForwardDirections;
|
||||
std::vector<double> m_nodeForwardDistances;
|
||||
std::vector<Uuid> m_generatedVertexSources;
|
||||
std::vector<Vector3> m_generatedVertices;
|
||||
std::vector<std::vector<size_t>> m_generatedFaces;
|
||||
std::vector<std::vector<Vector2>> m_generatedFaceUvs;
|
||||
|
|
Loading…
Reference in New Issue