[Bf-blender-cvs] [5d0c79ec8af] soc-2021-adaptive-cloth: adaptive_cloth: tests: Mesh to MeshIO, include only valid normals and uvs
ishbosamiya
noreply at git.blender.org
Mon Jul 5 17:33:40 CEST 2021
Commit: 5d0c79ec8afc071d126de2c20fad6c3882dfbe50
Author: ishbosamiya
Date: Sat Jul 3 20:29:11 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rB5d0c79ec8afc071d126de2c20fad6c3882dfbe50
adaptive_cloth: tests: Mesh to MeshIO, include only valid normals and uvs
===================================================================
M source/blender/blenkernel/BKE_cloth_remesh.hh
M source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc
===================================================================
diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh
index 328fd41f019..03fb4704629 100644
--- a/source/blender/blenkernel/BKE_cloth_remesh.hh
+++ b/source/blender/blenkernel/BKE_cloth_remesh.hh
@@ -60,6 +60,7 @@ Mesh *BKE_cloth_remesh(struct Object *ob, struct ClothModifierData *clmd, struct
#ifdef __cplusplus
# include <bits/stdint-uintn.h>
+# include <cmath>
# include <filesystem>
# include <fstream>
# include <iostream>
@@ -1103,15 +1104,20 @@ template<typename END, typename EVD, typename EED, typename EFD> class Mesh {
for (const auto &node : this->nodes) {
auto pos = node.pos;
+ /* dont need unkown check for position, it should always be present */
positions.append(pos);
auto normal = node.normal;
- normals.append(normal);
+ if (float3_is_unknown(normal) == false) {
+ normals.append(normal);
+ }
}
for (const auto &vert : this->verts) {
auto uv = vert.uv;
- uvs.append(uv);
+ if (float2_is_unknown(uv) == false) {
+ uvs.append(uv);
+ }
}
for (const auto &face : this->faces) {
@@ -1202,6 +1208,16 @@ template<typename END, typename EVD, typename EED, typename EFD> class Mesh {
return float2(std::numeric_limits<float>::signaling_NaN());
}
+ static inline bool float3_is_unknown(const float3 &f3)
+ {
+ return std::isnan(f3[0]) && std::isnan(f3[1]) && std::isnan(f3[2]);
+ }
+
+ static inline bool float2_is_unknown(const float2 &f2)
+ {
+ return std::isnan(f2[0]) && std::isnan(f2[1]);
+ }
+
/* all private non-static methods */
Node<END> &add_empty_node(float3 pos, float3 normal)
{
diff --git a/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc b/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc
index e461a43069c..8bfd29a21bc 100644
--- a/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc
+++ b/source/blender/blenkernel/tests/BKE_cloth_remesh_test.cc
@@ -946,30 +946,10 @@ TEST(cloth_remesh, Mesh_Write_LooseEdges)
"vt 1 0\n"
"vt 1 1\n"
"vt 0 1\n"
- "vt nan nan\n"
- "vt nan nan\n"
- "vt nan nan\n"
- "vt nan nan\n"
- "vt nan nan\n"
- "vt nan nan\n"
- "vt nan nan\n"
- "vt nan nan\n"
- "vt nan nan\n"
- "vt nan nan\n"
"vn 0 1 0\n"
"vn 0 1 0\n"
"vn 0 1 0\n"
"vn 0 1 0\n"
- "vn nan nan nan\n"
- "vn nan nan nan\n"
- "vn nan nan nan\n"
- "vn nan nan nan\n"
- "vn nan nan nan\n"
- "vn nan nan nan\n"
- "vn nan nan nan\n"
- "vn nan nan nan\n"
- "vn nan nan nan\n"
- "vn nan nan nan\n"
"f 1/1/1 2/2/2 4/3/4 3/4/3 \n"
"l 6 5 \n"
"l 4 6 \n"
More information about the Bf-blender-cvs
mailing list