From 92a167d830b166adf55591cb6dd7e4e7a0cf4073 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Wed, 15 Jan 2025 11:16:11 -0500 Subject: [PATCH 1/2] Reduce default vector resolutions. --- glue_ar/common/scatter_gltf.py | 4 ++-- glue_ar/common/scatter_usd.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/glue_ar/common/scatter_gltf.py b/glue_ar/common/scatter_gltf.py index f6190cb..a336106 100644 --- a/glue_ar/common/scatter_gltf.py +++ b/glue_ar/common/scatter_gltf.py @@ -38,8 +38,8 @@ def add_vectors_gltf(builder: GLTFBuilder, tip_height: float, shaft_radius: float, tip_radius: float, - tip_resolution: int = 10, - shaft_resolution: int = 10, + tip_resolution: int = 6, + shaft_resolution: int = 6, materials: Optional[dict[int, int]] = None, mask: Optional[ndarray] = None): diff --git a/glue_ar/common/scatter_usd.py b/glue_ar/common/scatter_usd.py index d0d7077..05af79f 100644 --- a/glue_ar/common/scatter_usd.py +++ b/glue_ar/common/scatter_usd.py @@ -35,8 +35,8 @@ def add_vectors_usd(builder: USDBuilder, tip_height: float, shaft_radius: float, tip_radius: float, - tip_resolution: int = 10, - shaft_resolution: int = 10, + tip_resolution: int = 6, + shaft_resolution: int = 6, colors: Optional[List[Tuple[int, int, int]]] = None, mask: Optional[ndarray] = None): From 1609a4e624d653d37fa85a21a89fd5bdc3cf6452 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Wed, 15 Jan 2025 11:18:41 -0500 Subject: [PATCH 2/2] Use short packing for vector triangle indices when appropriate. --- glue_ar/common/scatter_gltf.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/glue_ar/common/scatter_gltf.py b/glue_ar/common/scatter_gltf.py index a336106..65bfaa7 100644 --- a/glue_ar/common/scatter_gltf.py +++ b/glue_ar/common/scatter_gltf.py @@ -54,9 +54,10 @@ def add_vectors_gltf(builder: GLTFBuilder, max_index = max(idx for tri in triangles for idx in tri) add_triangles_to_bytearray(barr, triangles) + use_short = max_index <= SHORT_MAX if layer_state.vector_arrowhead: tip_triangles = cone_triangles(theta_resolution=tip_resolution, start_index=max_index + 1) - add_triangles_to_bytearray(barr, tip_triangles) + add_triangles_to_bytearray(barr, tip_triangles, short=use_short) max_index = max(idx for tri in tip_triangles for idx in tri) triangle_count += len(tip_triangles) @@ -69,9 +70,10 @@ def add_vectors_gltf(builder: GLTFBuilder, byte_offset=0, target=BufferTarget.ELEMENT_ARRAY_BUFFER, ) + component_type = ComponentType.UNSIGNED_SHORT if use_short else ComponentType.UNSIGNED_INT builder.add_accessor( buffer_view=builder.buffer_view_count-1, - component_type=ComponentType.UNSIGNED_INT, + component_type=component_type, count=triangle_count*3, type=AccessorType.SCALAR, mins=[0],