Skip to content

In NumPy 2, numpy_num_face_vertices() are wrong on some mixed-arity meshes #402

@paulmelnikow

Description

@paulmelnikow

Describe the issue
In NumPy 2, numpy_num_face_vertices() are wrong on some mixed-arity meshes.

It's not clear whether this is related to #401 which describes a different problem with different arrays with NumPy 2, or to #400 which describes a different problem with this array in NumPy 1.21.1.

To Reproduce

from tinyobjloader import ObjReader, ObjReaderConfig

reader = ObjReader()
config = ObjReaderConfig()
config.triangulate = False
reader.ParseFromString(mesh_string, "", config)

Load the following mesh:

v 0 1 1
v 0 2 2
v 0 3 3
v 0 4 4
v 0 5 5
f 1 2 3 4
f 1 4 5

Expected behavior

Observed:

(Pdb) reader.GetShapes()[0].mesh.num_face_vertices
[4, 3]
(Pdb) reader.GetShapes()[0].mesh.numpy_num_face_vertices()
array([4, 4], dtype=uint8)

Expected:

(Pdb) reader.GetShapes()[0].mesh.numpy_num_face_vertices()
array([4, 3], dtype=uint8)

Environment

  • TinyObjLoader version 2.0.0rc12
  • OS: Linux and Mac
  • Compiler Wheels from PyPI
  • Other environment Python 3.11 or 3.12, NumPy 2.4.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions