Merged
Conversation
…ptions for quantization
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, |
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close #0
What I did
GLB出力に
EXT_meshopt_compressionによる頂点バッファ圧縮を追加した。主な変更:
--meshoptCLIオプションの追加。--quantizeとの併用も可能cesiumtiles-gltf-jsonにEXT_meshopt_compression関連の型定義を追加(ExtMeshoptCompression,MeshoptCompressionMode,MeshoptCompressionFilter等)
pcd-exporter/gltf.rsをリファクタリングflate2に変更Notes