Skip to content

Zeros in place of correct values in numpy_num_face_vertices() #400

@paulmelnikow

Description

@paulmelnikow

Describe the issue
Using the built-in Python bindings, certain quad and mixed-arity meshes produce zeros in place of correct values in numpy_num_face_vertices(), while the values in num_face_vertices are correct.

To Reproduce
Run the following Python code:

from tinyobjloader import ObjReader, ObjReaderConfig

reader = ObjReader()
config = ObjReaderConfig()
config.triangulate = False
reader.ParseFromString(mesh_string, "", config)
shapes = reader.GetShapes()
print(shapes[0].mesh.numpy_num_face_vertices())

Load either of the following meshes:

v 0 0 0
v 0 0 0
v 0 0 0
v 0 0 0
f 1 2 3 4
v 46.367584 82.676086 8.867414
v 46.524185 82.81955 8.825487
v 46.59864 83.086678 8.88121
v 46.461926 82.834091 8.953863
f 5 6 7 8
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
The code above produces array([4, 0], dtype=uint8) for both meshes. For the first mesh the expected result is array([4, 4], dtype=uint8) and for the second mesh the expected result is array([4, 3], dtype=uint8).

With config.triangulate = True, the first mesh produces array([3, 0, 0, 0], dtype=uint8) whereas the expected result is array([3, 3, 3, 3], dtype=uint8). The second mesh the produces array([3, 0, 0], dtype=uint8) whereas the expected result is array([3, 3, 3], dtype=uint8).

In all cases the values of shapes[0].mesh.num_face_vertices are correct.

Environment

  • TinyObjLoader 2.0.0rc12 and 2.0.0rc11
  • OS: Linux and Mac
  • Compiler Using official wheels published to pypi
  • Other environment Python 3.9, 3.10; NumPy 1.21.1

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