diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 704338c9a69de70461a80f80655ed27201bc0518..e074d702b6c87ab9dae882cdd6a42e9eac12c669 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -32,6 +32,8 @@ Fixed * The :func:`.makeWriteable` function will always create a copy of an ``array`` if its base is a ``bytes`` object. * Fixed a bug in the :meth:`.GitfitMesh.loadVertices` method. +* Fixed a bug in the :meth:`.Mesh.addVertices` method where the wrong face + normals could be used for newly added vertex sets. 2.2.0 (Wednesday May 8th 2019) diff --git a/fsl/data/mesh.py b/fsl/data/mesh.py index e581c96037108376d1ba551b46f32d9b8720c0df..f3d1fb93bfdeaff3a0fb3afac2cd2dd9a0bb38cf 100644 --- a/fsl/data/mesh.py +++ b/fsl/data/mesh.py @@ -422,7 +422,7 @@ class Mesh(notifier.Notifier, meta.Meta): if fixWinding: indices = self.__indices - normals = self.normals + normals = calcFaceNormals(vertices, indices) needsFix = needsFixing(vertices, indices, normals, lo, hi) # See needsFixing documentation @@ -433,6 +433,8 @@ class Mesh(notifier.Notifier, meta.Meta): self.__vindices[ key] = self.__fixedIndices self.__faceNormals[key] = normals * -1 + else: + self.__faceNormals[key] = normals return vertices diff --git a/tests/test_idle.py b/tests/test_idle.py index 430e49fa06522681bae391320e898fb12180cbdb..b2eee726574eb484ddaadcff90fadc17e7fadb05 100644 --- a/tests/test_idle.py +++ b/tests/test_idle.py @@ -174,7 +174,11 @@ def _test_block(): idle.block(2) end = time.time() - assert (end - start) >= 2 + + # Be relaxed about precision - timing + # can sometimes be pretty sloppy when + # running in a docker container. + assert abs((end - start) < 2) < 0.05 if fslplatform.haveGui: assert called[0] diff --git a/tests/test_mesh.py b/tests/test_mesh.py index 20ff3cdb772878e1ece865f6fc98f7b813fa1824..243944b2e3feb1b476792a3fa319a595a8143ae7 100644 --- a/tests/test_mesh.py +++ b/tests/test_mesh.py @@ -433,6 +433,7 @@ def test_mesh_different_winding_orders(): mnofix.addVertices(verts2, key='v2', fixWinding=False) mfix .addVertices(verts1, key='v1', fixWinding=True) mfix .addVertices(verts2, key='v2', fixWinding=True) + mfix .addVertices(verts1, key='v3', fixWinding=True, select=False) mnofix.vertices = 'v1' assert np.all(mnofix.indices == tris) @@ -443,3 +444,5 @@ def test_mesh_different_winding_orders(): assert np.all(mfix.indices == tris) mfix.vertices = 'v2' assert np.all(mfix.indices == trisfixed) + mfix.vertices = 'v3' + assert np.all(mfix.indices == tris)