[Bf-blender-cvs] [255edfa5e15] soc-2021-adaptive-cloth: adaptive_cloth: fix: mesh_reader: obj: 'vt' considered under 'v'

ishbosamiya noreply at git.blender.org
Mon Jun 28 08:28:22 CEST 2021


Commit: 255edfa5e1554abdf5f55d454488f2e1d69271b7
Author: ishbosamiya
Date:   Tue Jun 22 23:32:25 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rB255edfa5e1554abdf5f55d454488f2e1d69271b7

adaptive_cloth: fix: mesh_reader: obj: 'vt' considered under 'v'

Consider
v 1.0 1.0 1.0
vt 1.0 1.0

Here, both lines start with "v" hence, if the check is, line starts with "v", it satisfies both, which is not correct.

The correct check should be, line starts with "v ".

===================================================================

M	source/blender/blenkernel/BKE_cloth_remesh.hh

===================================================================

diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh
index f17cc7ff863..05fe29404ec 100644
--- a/source/blender/blenkernel/BKE_cloth_remesh.hh
+++ b/source/blender/blenkernel/BKE_cloth_remesh.hh
@@ -369,7 +369,7 @@ class MeshReader {
         continue;
       }
 
-      if (line.rfind('v', 0) == 0) {
+      if (line.rfind("v ", 0) == 0) {
         std::istringstream li(line);
         float x, y, z;
         std::string temp;
@@ -380,7 +380,7 @@ class MeshReader {
         BLI_assert(temp == "v");
         this->positions.append(float3(x, y, z));
       }
-      else if (line.rfind("vt", 0) == 0) {
+      else if (line.rfind("vt ", 0) == 0) {
         std::istringstream li(line);
         float u, v;
         std::string temp;
@@ -402,9 +402,11 @@ class MeshReader {
         BLI_assert(temp == "vn");
         this->normals.append(float3(x, y, z));
       }
-      else if (line.rfind("f", 0) == 0) {
+      else if (line.rfind("f ", 0) == 0) {
         const auto line_toks = this->tokenize(line, ' ');
 
+        BLI_assert(line_toks.size() != 0);
+
         blender::Vector<FaceData> face;
 
         for (const auto *indices_group_iter = line_toks.begin() + 1;
@@ -448,9 +450,10 @@ class MeshReader {
           }
         }
 
+        BLI_assert(line_toks[0] == "f");
         this->face_indices.append(face);
       }
-      else if (line.rfind("l", 0) == 0) {
+      else if (line.rfind("l ", 0) == 0) {
         std::istringstream li(line);
         std::string temp;
         li >> temp;
@@ -461,6 +464,8 @@ class MeshReader {
           indices.append(index - 1); /* obj starts from 1, we want to
                                       * start from 0 */
         }
+
+        BLI_assert(temp == "l");
         this->line_indices.append(indices);
       }
       else {



More information about the Bf-blender-cvs mailing list