tinyobjloader 2.0.0__cp311-abi3-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
tinyobjloader/_ext.py ADDED
@@ -0,0 +1,333 @@
1
+ """Extension wrappers: tessellation, subdivision tags, skeletons, MaterialX."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import array as _array_module
6
+ from dataclasses import dataclass
7
+
8
+ from . import _core
9
+ from ._api import Array, Mesh, ObjScene, Shape, _array, _np, _precision_tag
10
+
11
+ __all__ = [
12
+ "MtlxColorSpace",
13
+ "MtlxConn",
14
+ "MtlxDoc",
15
+ "MtlxInput",
16
+ "MtlxMaterial",
17
+ "MtlxNode",
18
+ "SkelInfo",
19
+ "SkelJoint",
20
+ "SubdInfo",
21
+ "TessResult",
22
+ "mtlx_render",
23
+ "parse_mtlx",
24
+ "parse_skel",
25
+ "parse_subd",
26
+ "tessellate",
27
+ ]
28
+
29
+
30
+ # ---------------------------------------------------------------------------
31
+ # Tessellation
32
+ # ---------------------------------------------------------------------------
33
+
34
+
35
+ @dataclass(slots=True)
36
+ class TessResult:
37
+ """Result of triangulating one polygon ring.
38
+
39
+ ``indices`` is an ``(num_triangles, 3)`` array of ring-local corner
40
+ indices. ``status`` is one of ``"ok"``, ``"degenerate_besteffort"``,
41
+ ``"invalid"`` or ``"oom"``.
42
+ """
43
+
44
+ indices: Array
45
+ num_triangles: int
46
+ status: str
47
+
48
+ @property
49
+ def ok(self) -> bool:
50
+ return self.status in ("ok", "degenerate_besteffort")
51
+
52
+ def __repr__(self) -> str:
53
+ return f"TessResult(num_triangles={self.num_triangles}, status={self.status!r})"
54
+
55
+
56
+ def _coerce_points(points, precision):
57
+ if _np is not None:
58
+ array = _np.asarray(points)
59
+ if precision is None:
60
+ precision = 64 if array.dtype == _np.float64 else 32
61
+ dtype = _np.float64 if precision == 64 else _np.float32
62
+ if array.dtype != dtype or not array.flags["C_CONTIGUOUS"]:
63
+ array = _np.ascontiguousarray(array, dtype=dtype)
64
+ return array, precision
65
+ try:
66
+ view = memoryview(points)
67
+ except TypeError:
68
+ bits = 64 if precision == 64 else 32
69
+ values = []
70
+ for point in points:
71
+ if isinstance(point, (int, float)):
72
+ values.append(float(point))
73
+ else:
74
+ values.extend(float(value) for value in point)
75
+ flat = _array_module.array("d" if bits == 64 else "f", values)
76
+ return memoryview(flat), bits
77
+ inferred = 64 if view.itemsize == 8 else 32 if view.itemsize == 4 else None
78
+ if inferred is None:
79
+ raise TypeError("points must be a float32 or float64 buffer")
80
+ if precision is None:
81
+ precision = inferred
82
+ if precision != inferred:
83
+ # Match the numpy path, which converts to the requested precision.
84
+ values = view.tolist()
85
+ if values and isinstance(values[0], list):
86
+ values = [value for row in values for value in row]
87
+ converted = _array_module.array(
88
+ "d" if precision == 64 else "f", (float(value) for value in values)
89
+ )
90
+ return memoryview(converted), precision
91
+ return view, precision
92
+
93
+
94
+ def tessellate(
95
+ points,
96
+ *,
97
+ precision: int | str | None = None,
98
+ normal=None,
99
+ assume_convex: bool = False,
100
+ force_fan: bool = False,
101
+ ) -> TessResult:
102
+ """Triangulate one polygon ring given its ``(n, 3)`` corner positions."""
103
+ if precision is not None:
104
+ precision = _precision_tag(precision)
105
+ points, precision = _coerce_points(points, precision)
106
+ if normal is not None:
107
+ normal, _ = _coerce_points(normal, precision)
108
+ func = _core.tess_polygon_d if precision == 64 else _core.tess_polygon_f
109
+ raw = func(
110
+ points, normal=normal, assume_convex=assume_convex, force_fan=force_fan
111
+ )
112
+ return TessResult(
113
+ indices=_array(raw["indices"], "I", 3),
114
+ num_triangles=raw["num_triangles"],
115
+ status=raw["status_name"],
116
+ )
117
+
118
+
119
+ # ---------------------------------------------------------------------------
120
+ # Subdivision tags
121
+ # ---------------------------------------------------------------------------
122
+
123
+
124
+ @dataclass(slots=True)
125
+ class SubdInfo:
126
+ ok: bool
127
+ errors: list[str]
128
+ scheme: str | None
129
+ scheme_id: int
130
+ interpolate_boundary: int | None
131
+ fvar_interpolate_boundary: int | None
132
+ crease_method: str | None
133
+ smooth_triangles: str | None
134
+ creases: list[tuple[int, int, float]]
135
+ corners: list[tuple[int, float]]
136
+ holes: list[int]
137
+ unknown: list[str]
138
+ canonical: bytes
139
+
140
+ def __repr__(self) -> str:
141
+ return (
142
+ f"SubdInfo(ok={self.ok}, scheme={self.scheme!r}, "
143
+ f"creases={len(self.creases)}, corners={len(self.corners)}, "
144
+ f"holes={len(self.holes)})"
145
+ )
146
+
147
+
148
+ def parse_subd(shape_or_mesh: Shape | Mesh) -> SubdInfo:
149
+ """Parse and check a mesh's subdivision tags (``t`` lines).
150
+
151
+ The mesh must come from a load with ``triangulate=False``.
152
+ """
153
+ mesh = shape_or_mesh.mesh if isinstance(shape_or_mesh, Shape) else shape_or_mesh
154
+ raw = _core.subd_analyze(
155
+ mesh.tag_lines, mesh.num_face_vertices, mesh.indices
156
+ )
157
+ return SubdInfo(
158
+ ok=raw["ok"],
159
+ errors=raw["errors"],
160
+ scheme=raw["scheme"],
161
+ scheme_id=raw["scheme_id"],
162
+ interpolate_boundary=raw["interpolate_boundary"],
163
+ fvar_interpolate_boundary=raw["fvar_interpolate_boundary"],
164
+ crease_method=raw["crease_method"],
165
+ smooth_triangles=raw["smooth_triangles"],
166
+ creases=[(int(v0), int(v1), sharp) for v0, v1, sharp in raw["creases"]],
167
+ corners=[(int(v), sharp) for v, sharp in raw["corners"]],
168
+ holes=[int(v) for v in raw["holes"]],
169
+ unknown=raw["unknown"],
170
+ canonical=raw["canonical"],
171
+ )
172
+
173
+
174
+ # ---------------------------------------------------------------------------
175
+ # Skeletons / skinning
176
+ # ---------------------------------------------------------------------------
177
+
178
+
179
+ @dataclass(slots=True)
180
+ class SkelJoint:
181
+ name: str
182
+ parent: int
183
+ bind: list[float] | None
184
+ rest: list[float] | None
185
+
186
+
187
+ @dataclass(slots=True)
188
+ class SkelInfo:
189
+ ok: bool
190
+ ext: bool
191
+ errors: list[str]
192
+ joints: list[SkelJoint]
193
+ lib: str | None
194
+ lib_skeleton: str | None
195
+ anim: str | None
196
+ anim_name: str | None
197
+ canonical: bytes
198
+
199
+ def __repr__(self) -> str:
200
+ return (
201
+ f"SkelInfo(ok={self.ok}, joints={len(self.joints)}, "
202
+ f"lib={self.lib!r}, anim={self.anim!r})"
203
+ )
204
+
205
+
206
+ def parse_skel(scene: ObjScene) -> SkelInfo:
207
+ """Parse and check the scene's ``skel_*`` lines and ``vw`` joint ids."""
208
+ skin = scene.attrib.skin_weights
209
+ max_joint_id = skin.max_joint_id if skin is not None else -1
210
+ raw = _core.skel_analyze(scene.attrib.skel_lines, max_joint_id)
211
+ return SkelInfo(
212
+ ok=raw["ok"],
213
+ ext=raw["ext"],
214
+ errors=raw["errors"],
215
+ joints=[
216
+ SkelJoint(
217
+ name=joint["name"],
218
+ parent=joint["parent"],
219
+ bind=joint["bind"],
220
+ rest=joint["rest"],
221
+ )
222
+ for joint in raw["joints"]
223
+ ],
224
+ lib=raw["lib"],
225
+ lib_skeleton=raw["lib_skeleton"],
226
+ anim=raw["anim"],
227
+ anim_name=raw["anim_name"],
228
+ canonical=raw["canonical"],
229
+ )
230
+
231
+
232
+ # ---------------------------------------------------------------------------
233
+ # MaterialX-in-MTL
234
+ # ---------------------------------------------------------------------------
235
+
236
+
237
+ @dataclass(slots=True)
238
+ class MtlxNode:
239
+ name: str
240
+ category: str
241
+ type: str
242
+
243
+
244
+ @dataclass(slots=True)
245
+ class MtlxInput:
246
+ node: str
247
+ port: str
248
+ type: str
249
+ value: str
250
+
251
+
252
+ @dataclass(slots=True)
253
+ class MtlxConn:
254
+ src: str
255
+ src_out: str | None
256
+ dst: str
257
+ port: str
258
+ type: str
259
+
260
+
261
+ @dataclass(slots=True)
262
+ class MtlxColorSpace:
263
+ node: str
264
+ port: str
265
+ colorspace: str
266
+
267
+
268
+ @dataclass(slots=True)
269
+ class MtlxMaterial:
270
+ name: str
271
+ ext: bool
272
+ ok: bool
273
+ versions: list[str]
274
+ surface: list[tuple[str, str]]
275
+ nodes: list[MtlxNode]
276
+ inputs: list[MtlxInput]
277
+ conns: list[MtlxConn]
278
+ includes: list[str]
279
+ colorspaces: list[MtlxColorSpace]
280
+ errors: list[str]
281
+
282
+ def __repr__(self) -> str:
283
+ return (
284
+ f"MtlxMaterial(name={self.name!r}, ok={self.ok}, "
285
+ f"nodes={len(self.nodes)}, inputs={len(self.inputs)}, "
286
+ f"conns={len(self.conns)})"
287
+ )
288
+
289
+
290
+ @dataclass(slots=True)
291
+ class MtlxDoc:
292
+ materials: list[MtlxMaterial]
293
+
294
+ def __repr__(self) -> str:
295
+ return f"MtlxDoc(materials={len(self.materials)})"
296
+
297
+
298
+ def _mtlx_material(raw: dict) -> MtlxMaterial:
299
+ return MtlxMaterial(
300
+ name=raw["name"],
301
+ ext=raw["ext"],
302
+ ok=raw["ok"],
303
+ versions=list(raw["versions"]),
304
+ surface=[tuple(pair) for pair in raw["surface"]],
305
+ nodes=[MtlxNode(**node) for node in raw["nodes"]],
306
+ inputs=[MtlxInput(**value) for value in raw["inputs"]],
307
+ conns=[
308
+ MtlxConn(
309
+ src=value["src"],
310
+ src_out=value["src_out"] or None,
311
+ dst=value["dst"],
312
+ port=value["port"],
313
+ type=value["type"],
314
+ )
315
+ for value in raw["conns"]
316
+ ],
317
+ includes=list(raw["includes"]),
318
+ colorspaces=[MtlxColorSpace(**value) for value in raw["colorspaces"]],
319
+ errors=list(raw["errors"]),
320
+ )
321
+
322
+
323
+ def parse_mtlx(text: str | bytes) -> MtlxDoc:
324
+ """Parse MaterialX-in-MTL (``mtlx_*``) lines from a whole `.mtl` text."""
325
+ raw = _core.mtlx_parse(text)
326
+ return MtlxDoc(materials=[_mtlx_material(m) for m in raw["materials"]])
327
+
328
+
329
+ def mtlx_render(text: str | bytes, fmt: str = "xml") -> bytes:
330
+ """Parse MaterialX-in-MTL text and render it as ``xml``, ``mtl`` or ``dump``."""
331
+ if fmt not in ("xml", "mtl", "dump"):
332
+ raise ValueError("fmt must be 'xml', 'mtl' or 'dump'")
333
+ return _core.mtlx_render(text, fmt)
tinyobjloader/py.typed ADDED
File without changes
@@ -0,0 +1,278 @@
1
+ Metadata-Version: 2.4
2
+ Name: tinyobjloader
3
+ Version: 2.0.0
4
+ Summary: Tiny but powerful Wavefront OBJ loader (C11 core, numpy optional)
5
+ Author-email: Syoyo Fujita <syoyo@lighttransport.com>
6
+ License-Expression: MIT AND ISC
7
+ Project-URL: Homepage, https://github.com/tinyobjloader/tinyobjloader
8
+ Project-URL: Source, https://github.com/tinyobjloader/tinyobjloader
9
+ Keywords: obj,wavefront,3d,mesh,loader,tessellation,subdivision
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Topic :: Artistic Software
14
+ Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
15
+ Classifier: Topic :: Scientific/Engineering :: Visualization
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: C
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: Implementation :: CPython
21
+ Requires-Python: >=3.11
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Provides-Extra: numpy
25
+ Requires-Dist: numpy>=1.26; extra == "numpy"
26
+ Dynamic: license-file
27
+
28
+ # tinyobjloader (Python)
29
+
30
+ Lightweight Python bindings for [tinyobjloader](https://github.com/tinyobjloader/tinyobjloader),
31
+ built directly on the pure-C11 loader with the CPython C API.
32
+
33
+ * **Stable ABI**: one `cp311-abi3` wheel runs on CPython 3.11 and newer.
34
+ * **Free-threaded**: dedicated `cp314t` wheels run without the GIL
35
+ (the module declares `Py_MOD_GIL_NOT_USED`), and parsing releases the GIL.
36
+ * **NumPy optional**: the extension returns zero-copy, read-only `memoryview`
37
+ objects; if numpy is importable they are wrapped in `numpy.ndarray` views.
38
+ NumPy is never needed to build or to load a mesh.
39
+ * **float32 or float64**, selected per load.
40
+ * Tessellation, subdivision tags, skeletons/skinning, MaterialX-in-MTL and a
41
+ canonical `.obj` writer ship in the same module.
42
+
43
+ ```bash
44
+ python -m pip install tinyobjloader # add [numpy] to pull numpy in
45
+ ```
46
+
47
+ ## Quick start
48
+
49
+ ```python
50
+ import tinyobjloader as tobj
51
+
52
+ scene = tobj.load("model.obj") # float32 by default
53
+ print(scene.attrib.vertices.shape) # (num_vertices, 3)
54
+
55
+ mesh = scene.merged() # every shape's faces, one copy
56
+ print(mesh.triangles().shape) # (num_triangles, 3) vertex ids
57
+ print(mesh.shape_face_offsets) # faces of shape i: [o[i], o[i+1])
58
+
59
+ for shape in scene.shapes: # built lazily on first access
60
+ print(shape.name)
61
+ print(shape.mesh.indices.shape) # (num_corners, 3) int32
62
+ print(shape.mesh.num_face_vertices) # uint32 per face
63
+ print(shape.mesh.material_ids) # int32 per face, -1 = none
64
+
65
+ for material in scene.materials:
66
+ print(material.name, material.diffuse, material.diffuse_texname)
67
+ print(material.texopt["diffuse"].texture_resolution)
68
+
69
+ print(scene.warnings, scene.errors)
70
+ ```
71
+
72
+ Loading from memory, with `.mtl` sidecars supplied in memory:
73
+
74
+ ```python
75
+ with open("model.obj", "rb") as f:
76
+ obj = f.read()
77
+ mtl = {"model.mtl": open("model.mtl", "rb").read()}
78
+ scene = tobj.loads(obj, mtl=mtl) # bytes-like (no copy) or str
79
+
80
+ materials = tobj.parse_mtl("model.mtl") # a path-like object is accepted
81
+ ```
82
+
83
+ `mtl` accepts a single blob, a mapping of `name -> contents`, or a sequence of
84
+ `(name, contents)` pairs; contents may be bytes or `str` (encoded as UTF-8).
85
+ Names are matched case-insensitively against the `mtllib` line's basename.
86
+
87
+ ## Streaming very large files
88
+
89
+ `load` keeps the whole scene in memory (about 12 bytes per face corner plus
90
+ the attribute arrays). For files that do not fit, `iter_load` parses a window
91
+ at a time, so memory stays proportional to `chunk_bytes`:
92
+
93
+ ```python
94
+ import numpy as np
95
+
96
+ for chunk in tobj.iter_load("huge.obj", chunk_bytes=64 << 20):
97
+ chunk.vertices # (n, 3) vertices defined in this window
98
+ chunk.vertex_offset # global id of chunk.vertices[0]
99
+ chunk.triangles() # (F, 3) global, 0-based vertex ids
100
+ chunk.material_ids # index into chunk.material_names (-1 = none)
101
+ ```
102
+
103
+ The source may also be a binary file object such as `gzip.open(path, "rb")`.
104
+ Streaming covers `v`/`vn`/`vt`/`f`/`g`/`o`/`usemtl`; polygons are
105
+ fan-triangulated (the full loader's robust tessellator needs every vertex in
106
+ memory), and lines, points, materials, tags and skinning are only available
107
+ from `load`.
108
+
109
+ ## Migrating from the pybind11 binding (2.0.0rc13 and earlier)
110
+
111
+ Releases up to `2.0.0rc13` shipped a pybind11 binding modelled on the C++
112
+ `ObjReader`. That API is gone; there is no compatibility shim.
113
+
114
+ | pybind11 binding | this package |
115
+ | --- | --- |
116
+ | `reader = tinyobjloader.ObjReader()`; `reader.ParseFromFile(path, config)` | `scene = tobj.load(path, ...)` |
117
+ | `reader.ParseFromString(obj_text, mtl_text)` | `tobj.loads(obj_text, mtl=mtl_text)` |
118
+ | `ObjReaderConfig().triangulate` / `.vertex_color` | `triangulate=` / `vertex_colors=` keywords |
119
+ | `ObjReaderConfig().mtl_search_path` | not needed: `.mtl` files resolve next to the `.obj`; pass `mtl=` to `loads` for in-memory sidecars |
120
+ | `reader.Valid()`, `reader.Error()`, `reader.Warning()` | failures raise `tobj.LoadError`; warnings in `scene.warnings` |
121
+ | `reader.GetAttrib()`, `GetShapes()`, `GetMaterials()` | `scene.attrib`, `scene.shapes`, `scene.materials` |
122
+ | `attrib.numpy_vertices()` (flat) | `scene.attrib.vertices` (`(N, 3)`, already a numpy view) |
123
+ | `mesh.numpy_indices()` (flat `v, vn, vt` triples) | `mesh.indices` (`(N, 3)` columns `v, vn, vt`), or `mesh.vertex_indices` |
124
+ | `mesh.indices[i].vertex_index` (`index_t` objects) | `mesh.indices[i, 0]` |
125
+ | `material.GetCustomParameter(key)` | `material.unknown_params[key]` |
126
+
127
+ Note the column order of `mesh.indices`: vertex, **normal**, texcoord, the
128
+ same as the C `tobj_index` struct.
129
+
130
+ ## Numbers, arrays and lifetimes
131
+
132
+ `precision=32` (default) or `precision=64` picks the loader's float or double
133
+ family. Aliases (`"f4"`, `"f8"`, `"float64"`, ...) are accepted.
134
+
135
+ Every array is a **read-only zero-copy view** of the loaded scene:
136
+
137
+ * with numpy installed: a `numpy.ndarray` (`float32`/`float64`, `int32`,
138
+ `uint32`);
139
+ * without numpy: a one- or two-dimensional `memoryview` (empty arrays are
140
+ one-dimensional, since CPython cannot cast a zero-length view to a 2-D shape).
141
+
142
+ Views keep the loaded scene alive. `ObjScene.close()` only drops the scene's own
143
+ reference, so arrays you are still holding remain valid. Arrays are read-only by
144
+ design; copy them (e.g. `np.array(view)`) before mutating.
145
+
146
+ ## Loading options
147
+
148
+ `load` / `loads` take keyword-only options (a misspelled one is a `TypeError`):
149
+
150
+ | option | default | meaning |
151
+ | --- | --- | --- |
152
+ | `precision` | `32` | `32` (float32) or `64` (float64) |
153
+ | `triangulate` | `True` | triangulate n-gons during the load |
154
+ | `vertex_colors` | `True` | store per-vertex RGB when present |
155
+ | `vertex_color_fallback` | `True` | fill vertices without color as white |
156
+ | `freeform` | `False` | parse and retain `curv`/`surf`/... records |
157
+ | `num_threads` | `None` | `None` uses the default (see Performance); `0` is the single-threaded verified core, `-1` all cores, `N` N threads |
158
+ | `limits` | `None` | a `tobj.Limits(max_vertices=..., max_input_bytes=..., ...)`; `0` fields keep the loader default |
159
+
160
+ `load_obj` / `load_obj_from_memory` (names from the 2.0.0 release candidates) still
161
+ work, emit a `DeprecationWarning`, and accept the old option names.
162
+
163
+ Errors raise `tinyobjloader.LoadError` with the loader's message; file loads
164
+ include the path (`I/O error (while loading 'model.obj')`), and non-fatal issues
165
+ land in `scene.warnings`.
166
+
167
+ ## Extensions
168
+
169
+ ### Tessellation
170
+
171
+ `tobj.tessellate(points, normal=None, assume_convex=False, force_fan=False)`
172
+ triangulates one polygon ring (concave, collinear, non-planar and
173
+ self-intersecting input included). `points` is an `(n, 3)` float array or a
174
+ sequence of triples. The result is a `TessResult` with ring-local indices:
175
+
176
+ ```python
177
+ result = tobj.tessellate([(0,0,0), (1,0,0), (1,1,0), (0,1,0)])
178
+ result.indices # (num_triangles, 3) uint32
179
+ result.status # "ok" / "degenerate_besteffort" / "invalid" / "oom"
180
+ result.num_triangles
181
+ ```
182
+
183
+ ### Subdivision tags
184
+
185
+ ```python
186
+ scene = tobj.load("quad.obj", triangulate=False) # tags need raw faces
187
+ info = tobj.parse_subd(scene.shapes[0])
188
+ info.ok, info.errors, info.scheme, info.creases, info.corners, info.holes
189
+ info.canonical # bytes, canonical `t` lines
190
+ ```
191
+
192
+ ### Skeletons / skinning
193
+
194
+ ```python
195
+ info = tobj.parse_skel(scene)
196
+ info.joints[0].name, info.joints[0].parent, info.joints[0].bind
197
+ scene.attrib.skin_weights[0] # (vertex_id, {joint_id: weight})
198
+ scene.attrib.skin_weights.max_joint_id
199
+ scene.attrib.skel_lines
200
+ ```
201
+
202
+ ### MaterialX-in-MTL
203
+
204
+ ```python
205
+ doc = tobj.parse_mtlx(open("model.mtl").read())
206
+ doc.materials[0].nodes, doc.materials[0].inputs, doc.materials[0].conns
207
+ xml = tobj.mtlx_render(open("model.mtl").read(), fmt="xml") # or "mtl", "dump"
208
+ ```
209
+
210
+ ### Writing `.obj`
211
+
212
+ ```python
213
+ text = tobj.write_obj(scene) # bytes, canonical Wavefront .obj
214
+ tobj.write_obj(scene, "out.obj") # or straight to a file
215
+ ```
216
+
217
+ Only mesh topology is written (`v`, `vt`, `vn`, `g`, `usemtl`, `s`, `f`, plus
218
+ per-shape `t` lines); `.mtl` files, polylines and free-form geometry are not.
219
+
220
+ ## Performance
221
+
222
+ Wheels are built with the loader's file features enabled:
223
+
224
+ * **mmap** file loads map the `.obj` instead of copying it into the heap, which
225
+ lowers peak memory for large scenes (POSIX; Windows falls back to stdio);
226
+ * **SIMD** newline scanning (x86 SSE2/AVX2, AArch64 NEON, scalar elsewhere);
227
+ * the **threaded prepass** is compiled in and stays opt-in at run time.
228
+
229
+ Choosing a loading mode for large files (`bench_load.py`, quad grid with
230
+ `vt`/`vn`, float32, x86_64 with all cores busy with another workload, so an
231
+ idle machine will be faster):
232
+
233
+ | mode | 156 MB file | 1.07 GB file | 11.3 GB file (173M triangles) | peak RSS |
234
+ | --- | --- | --- | --- | --- |
235
+ | `load(num_threads=0)` (default) | 4.2 s | 29.1 s | does not fit | ~10x file |
236
+ | `load(num_threads=-1)` | 1.6 s | 11.2 s | does not fit | ~4x file |
237
+ | `iter_load(chunk_bytes=64 MB)` | 1.0 s | 7.2 s | 74.9 s | ~380 MB, flat |
238
+
239
+ * `num_threads=0` runs the formally verified core, which keeps one 112-byte
240
+ record per vertex and face corner while it builds the scene.
241
+ * `num_threads=-1` / `N` uses the threaded dispatcher. It is faster and leaner
242
+ but it ignores `vw` skin weights and accepts some malformed input that the
243
+ verified core rejects, so it is not the default.
244
+ * `iter_load` never holds more than about one window, whatever the file size.
245
+
246
+ ```bash
247
+ python tests/python/benchmarks/bench_load.py --size-mb 1000 --repeat 3
248
+ python tests/python/benchmarks/bench_load.py --size-mb 10000 --modes iter
249
+ ```
250
+
251
+ Fixtures are cached in `$TINYOBJ_BENCH_DIR` (default
252
+ `~/.cache/tinyobjloader-bench`); avoid a RAM-backed `/tmp` for multi-GB files.
253
+ Each mode runs in its own process so the reported peak RSS is its own.
254
+ `TINYOBJ_BENCH=1 pytest -q -s` runs a small load benchmark as a test.
255
+
256
+ ## Free-threaded Python
257
+
258
+ On `cp314t` the module opts out of the GIL, and the parse itself
259
+ releases it on regular builds too, so loading from several threads scales. All
260
+ state lives in the returned scene object; the module keeps no globals.
261
+
262
+ ## Building
263
+
264
+ Wheels are produced from the repository root:
265
+
266
+ ```bash
267
+ python -m build --wheel
268
+ # or: cibuildwheel --only cp311-manylinux_x86_64 .
269
+ cd tests/python && uv run --project . pytest -q
270
+ ```
271
+
272
+ The extension compiles `tiny_obj_c.c`, `tobj_tess.c`, `tobj_subd.c`,
273
+ `tobj_skel.c`, `tobj_mtlx.c` and `tobj_write.c`; there is no C++ or pybind11
274
+ dependency.
275
+
276
+ ## License
277
+
278
+ MIT (loader) and ISC (bundled tessellation-derived code). See `LICENSE`.
@@ -0,0 +1,10 @@
1
+ tinyobjloader/__init__.py,sha256=URZFSlrbkBAqvxoxcXmWmUOFinYCcWmHp0opGx6PRaU,1875
2
+ tinyobjloader/_api.py,sha256=upH4y7L0kaq3MX_uU1kHc6TA35Qxx5MOmF197AOkoxw,30354
3
+ tinyobjloader/_core.pyd,sha256=0kf5D82SdQJmexiSc29lwwQ8Dqft97WXP7VuwcnHMNM,325120
4
+ tinyobjloader/_ext.py,sha256=OwpFyESB-TYqjclr394cOioIiaOrww8RItUjA3Q7OeE,9962
5
+ tinyobjloader/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ tinyobjloader-2.0.0.dist-info/licenses/LICENSE,sha256=T5lkgX5OKwnZOY7-IiVYo6SlTiO9JHOytkxY88XG9oY,1948
7
+ tinyobjloader-2.0.0.dist-info/METADATA,sha256=DGS38-OePFCPEh9kIOdV9ih7z1P3dExssxbbPmOHsmE,12035
8
+ tinyobjloader-2.0.0.dist-info/WHEEL,sha256=DRIXvQxI5NAx1rGYKm9Q5pUeRLhtqrqDrAmS92IyJgU,100
9
+ tinyobjloader-2.0.0.dist-info/top_level.txt,sha256=M1pUAy-UzpedMzFXX9fMOXq8PDQ63Pzj88RKlK9YKcU,14
10
+ tinyobjloader-2.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: false
4
+ Tag: cp311-abi3-win_amd64
5
+
@@ -0,0 +1,42 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2012-Present, Syoyo Fujita and many contributors.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ ----------------------------------
24
+
25
+ mapbox/earcut.hpp
26
+
27
+ ISC License
28
+
29
+ Copyright (c) 2015, Mapbox
30
+
31
+ Permission to use, copy, modify, and/or distribute this software for any purpose
32
+ with or without fee is hereby granted, provided that the above copyright notice
33
+ and this permission notice appear in all copies.
34
+
35
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
36
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
37
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
38
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
39
+ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
40
+ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
41
+ THIS SOFTWARE.
42
+
@@ -0,0 +1 @@
1
+ tinyobjloader