diff --git a/models/face_in_group_name_mid_file.obj b/models/face_in_group_name_mid_file.obj new file mode 100644 index 000000000..7d049c6ef --- /dev/null +++ b/models/face_in_group_name_mid_file.obj @@ -0,0 +1,9 @@ +v 10 20 30 +v 15 5 25 +v 1 5 10 +v 5 15 20 +f 1//1 2//2 4//4 + +g An f Three Other Things +v 5 15 21 +f 1 3 5 \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index d99146593..7818fa9c6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,19 +6,14 @@ requires = ["setuptools >= 40.8", "wheel"] select = ["E", "F", # the default rules "T201", # disallow print statements "B"] # pass bugbear - #"I001", # isort - #"D"] # pydocstyle ignore = ["B905", # `zip()` without an explicit `strict=` "B904", # `raise ... from err` seems a bit silly "B018"] # useless expression ideally ignore only on `tests` line-length = 90 -[tool.ruff.pydocstyle] -convention = "numpy" - -[tool.trimesh-setup.fetch.gltfvalidator] -url = 'https://github.com/KhronosGroup/glTF-Validator/releases/download/2.0.0-dev.3.8/gltf_validator-2.0.0-dev.3.8-linux64.tar.xz' -sha256 = '374c7807e28fe481b5075f3bb271f580ddfc0af3e930a0449be94ec2c1f6f49a' -target = "$PATH" -chmod = 755 -extract_only = "gltf_validator" +[tool.autopep8] +max_line_length = 90 +in-place = true +recursive = true +aggressive = 3 +verbose = true \ No newline at end of file diff --git a/tests/test_obj.py b/tests/test_obj.py index f9213e330..51c4ac57f 100644 --- a/tests/test_obj.py +++ b/tests/test_obj.py @@ -430,6 +430,14 @@ def test_face_parsing_in_group_names(self): m = g.get_mesh('face_in_group_name.obj') assert len(m.vertices) == 1 + def test_face_parsing_in_group_names_with_object_tag(self): + # Checks that an obj with a g tag in the middle of a file, + # containinig a face like name (an 'f ' followed by three + # space separated text chunks, ex: f 1 2 3), does load properly + m = g.get_mesh('face_in_group_name_mid_file.obj') + assert len(m.vertices) == 5 + assert len(m.faces) == 2 + def simple_load(text): # we're going to load faces in a basic text way diff --git a/trimesh/base.py b/trimesh/base.py index 7e26d0e4e..7f04620d8 100644 --- a/trimesh/base.py +++ b/trimesh/base.py @@ -2410,7 +2410,6 @@ def apply_transform(self, matrix): # exit early if we've been passed an identity matrix # np.allclose is surprisingly slow so do this test elif util.allclose(matrix, np.eye(4), 1e-8): - log.debug('apply_transform passed identity matrix') return self # new vertex positions diff --git a/trimesh/exchange/obj.py b/trimesh/exchange/obj.py index b4e522d51..abfbd6803 100644 --- a/trimesh/exchange/obj.py +++ b/trimesh/exchange/obj.py @@ -132,7 +132,7 @@ def load_obj(file_obj, # after it finds the first newline # passed as arg as it's not a kwarg in python2 face_lines = [i.split('\n', 1)[0].strip() - for i in chunk.split('f ')[1:]] + for i in re.split('^f', chunk, flags=re.MULTILINE)[1:]] # check every face for mixed tri-quad-ngon columns = len(face_lines[0].replace('/', ' ').split()) diff --git a/trimesh/version.py b/trimesh/version.py index 88a361e4d..0e47affe4 100644 --- a/trimesh/version.py +++ b/trimesh/version.py @@ -1,4 +1,4 @@ -__version__ = '3.21.3' +__version__ = '3.21.4' if __name__ == '__main__': # print version if run directly i.e. in a CI script diff --git a/trimesh/viewer/trackball.py b/trimesh/viewer/trackball.py index be871a3bb..cc2de2e8a 100644 --- a/trimesh/viewer/trackball.py +++ b/trimesh/viewer/trackball.py @@ -125,7 +125,9 @@ def drag(self, point): motion between this point and the one marked by down(). """ point = np.array(point, dtype=np.float32) - dx, dy = point - self._pdown + # get the "down" point defaulting to current point making + # this a no-op if the "down" event didn't trigger for some reason + dx, dy = point - getattr(self, '_pdown', point) mindim = 0.3 * np.min(self._size) target = self._target