Skip to content

Commit

Permalink
Merge pull request #1887 from mikedh/release/op
Browse files Browse the repository at this point in the history
Release: OBJ Parsing
  • Loading branch information
mikedh authored Apr 4, 2023
2 parents 18d1748 + a51d513 commit 820878a
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 15 deletions.
9 changes: 9 additions & 0 deletions models/face_in_group_name_mid_file.obj
Original file line number Diff line number Diff line change
@@ -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
17 changes: 6 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions tests/test_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion trimesh/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion trimesh/exchange/obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion trimesh/version.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion trimesh/viewer/trackball.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 820878a

Please sign in to comment.