Skip to content

Comments

meshoptによる圧縮の有効化#73

Merged
nokonoko1203 merged 7 commits intomainfrom
feature/meshopt
Feb 1, 2026
Merged

meshoptによる圧縮の有効化#73
nokonoko1203 merged 7 commits intomainfrom
feature/meshopt

Conversation

@nokonoko1203
Copy link
Collaborator

Close #0

What I did

GLB出力に EXT_meshopt_compression による頂点バッファ圧縮を追加した。

主な変更:

  • --meshopt CLIオプションの追加。--quantize との併用も可能
  • cesiumtiles-gltf-jsonEXT_meshopt_compression 関連の型定義を追加(ExtMeshoptCompression, MeshoptCompressionMode, MeshoptCompressionFilter
    等)
  • pcd-exporter/gltf.rs をリファクタリング
  • VoxelDecimator にMortonコードによる空間ソートを追加し、meshoptの圧縮効率を向上
  • gzip圧縮を flate2 に変更

Notes

@nokonoko1203 nokonoko1203 merged commit c1f4f84 into main Feb 1, 2026
5 checks passed
@nokonoko1203 nokonoko1203 deleted the feature/meshopt branch February 1, 2026 15:36
Comment on lines 273 to -280
..Default::default()
}],
nodes: vec![Node {
mesh: Some(0),
translation: offset,
scale: [
common_scale as f64,
common_scale as f64,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: For an empty point cloud without meshopt, an invalid GLTF is created where a BufferView references a non-existent buffer, because the buffers array is empty.
Severity: HIGH

Suggested Fix

Conditionally create the buffer_views array only when the buffers array is not empty. For example, wrap the buffer_views creation in an if uncompressed_len > 0 block, similar to how the buffers array is created. This will ensure that no BufferView is created when there are no buffers, resulting in a valid GLTF for empty point clouds.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: pcd-exporter/src/gltf.rs#L273-L280

Potential issue: When generating a GLB file for an empty point cloud without meshopt
compression, the code produces an invalid GLTF structure. If the `uncompressed_len` is
0, an empty `buffers` array is created. However, a `BufferView` is still generated, and
its `buffer` field defaults to `0`, causing it to reference a buffer that does not exist
in the empty array. This can occur when the decimation process results in an empty point
cloud, which is a possible production scenario. The resulting invalid GLB file violates
the glTF specification and can cause loading failures or crashes in client applications.

Did we get this right? 👍 / 👎 to inform future reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant