Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gltf: Vertex attribute は UnsignedInt に対応していない #351

Merged
merged 7 commits into from
Feb 27, 2024

Conversation

nokonoko1203
Copy link
Collaborator

@nokonoko1203 nokonoko1203 commented Feb 27, 2024

Summary by CodeRabbit

  • 機能変更
    • gltf_writer.rsの変更により、feature_idu32からf32に変換しました。これは、MeshPrimitiveUnsignedIntをサポートしていないために行われました。この変更により、バイナリコンテンツの書き込みとアクセサコンポーネントのタイプに影響があります。

Copy link

coderabbitai bot commented Feb 27, 2024

Walkthrough

この変更の概要は、MeshPrimitiveUnsignedIntをサポートしていないため、feature_idu32からf32に変換することに関連しています。これは、バイナリコンテンツの書き込みとアクセサコンポーネントタイプに影響を与えます。

Changes

ファイル 変更概要
.../gltf/gltf_writer.rs feature_idu32からf32に変換する変更。MeshPrimitiveUnsignedIntをサポートしていないため。

🐇
ぴょんぴょん変更を祝って、
コードの海を跳ねる
新しい型で、流れを変え、
エラーを遠くに追いやる
🌟ぴかぴかの未来へ🌟


Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@nokonoko1203 nokonoko1203 requested review from a team and ciscorn February 27, 2024 06:52
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c70a1e4 and 1a7207d.
Files ignored due to path filters (1)
  • demo/cesium/examples/ext_structural_metadata/tileset.json is excluded by: !**/*.json
Files selected for processing (1)
  • nusamai/src/sink/gltf/gltf_writer.rs (2 hunks)

Comment on lines 134 to 143
let feature_ids_offset = bin_content.len();
let mut feature_ids_count = 0;
for vertex in buffer.vertices.clone() {
bin_content
.write_all(&vertex.feature_id.to_le_bytes())
.unwrap();
// MeshPrimitive does not support UnsignedInt
// https://github.com/CesiumGS/glTF/blob/proposal-EXT_mesh_features/extensions/2.0/Vendor/EXT_mesh_features/README.md#feature-id-by-vertex
let vertex = vertex.feature_id as f32;
bin_content.write_all(&vertex.to_le_bytes()).unwrap();
feature_ids_count += 1;
}
let feature_ids_len = bin_content.len() - feature_ids_offset;
Copy link

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [137-158]

feature_id のデータ型を u32 から f32 に変換する変更について、GLTFのEXT_mesh_features拡張機能に準拠するための適切な対応です。ただし、f32 への変換により精度が低下する可能性があるため、この変更がアプリケーションの要件に適合しているか検討する必要があります。また、feature_id の最小値と最大値を計算する際に、as f64 でキャストしている点に注意してください。f32 から f64 へのキャストは精度を向上させるものではなく、元の u32 の値の範囲を正確に反映しているか確認が必要です。

Copy link

codecov bot commented Feb 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Additional details and impacted files
Components Coverage Δ
GUI ∅ <ø> (∅)
Backend 89.06% <100.00%> (+<0.01%) ⬆️
Libraries 92.00% <ø> (ø)

📢 Thoughts on this report? Let us know!

@ciscorn ciscorn changed the title MeshPrimitiveはUnsignedIntに対応していないので、対応 gltf: Vertex attribute は UnsignedInt に対応していないので修正 Feb 27, 2024
Copy link
Member

@ciscorn ciscorn left a comment

Choose a reason for hiding this comment

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

LGTM

@nokonoko1203 nokonoko1203 enabled auto-merge (squash) February 27, 2024 09:05
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1a7207d and a0b0d03.
Files selected for processing (1)
  • nusamai/src/sink/gltf/gltf_writer.rs (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • nusamai/src/sink/gltf/gltf_writer.rs

@nokonoko1203 nokonoko1203 merged commit 8acf35d into main Feb 27, 2024
2 checks passed
@nokonoko1203 nokonoko1203 deleted the modify-content-type branch February 27, 2024 09:12
@ciscorn ciscorn changed the title gltf: Vertex attribute は UnsignedInt に対応していないので修正 Fix gltf: Vertex attribute は UnsignedInt に対応していない Feb 28, 2024
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.

2 participants