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

テクスチャ付き最大LODを出力するオプションを追加 #647

Merged
merged 48 commits into from
Sep 25, 2024

Conversation

satoshi7190
Copy link
Contributor

@satoshi7190 satoshi7190 commented Sep 19, 2024

#643 (最適化が必要なのでクローズしません)
Close #644
Close #645

※不要なコミットが多いため Squash and mergeを推奨

What I did(変更内容)

  • テクスチャ付き最大LODを出力するオプションを追加(-t use_lod=textured_max_lod
  • 単体のテクスチャありなしオプションを削除(-t use_texture=true
  • すべてのLODを抽出するオプションを追加(通常は機能しないため、開発時にコメントアウトを解除する)
  • UI画面の初期ウィンドウサイズと各UIの間隔を修正(変換ボタンが見える様に)

image

Notes(連絡事項)

動作確認

# テクスチャ付き最大LODを出力
cargo run -- <input_path> --sink gltf -t use_lod=textured_max_lod  -o --output <output_path>
# 全てのLODを出力 `nusamai/src/transformer/setting.rs`の`get_lod_selection_options()`内のコメントアウトを解除して実行
cargo run -- <input_path> --sink gltf -t use_lod=all_lod  -o --output <output_path>

Copy link

coderabbitai bot commented Sep 19, 2024

Walkthrough

このプルリクエストでは、複数のファイルにおいて構造体やメソッドの変更が行われています。主な変更点は、Entity構造体にCloneトレイトを追加し、テクスチャ設定の削除を含むトランスフォーマーオプションの簡素化です。また、LOD選択機能の拡張や新しいLODフィルターモードの追加が行われています。これにより、テクスチャの有無に基づく詳細レベルの選択が可能になります。

Changes

ファイル 変更概要
nusamai-plateau/src/entity.rs Entity構造体にCloneトレイトを追加。
nusamai/src/sink/cesiumtiles/mod.rs DataSinkProvidertransformer_optionsメソッドからuse_texture_configを削除。
nusamai/src/sink/gltf/mod.rs GltfSinkProvidertransformer_optionsメソッドからuse_texture_configを削除。
nusamai/src/sink/obj/mod.rs ObjSinkProvidertransformer_optionsメソッドからuse_texture_configを削除。
nusamai/src/transformer/setting.rs LodSelection構造体の選択肢を拡張し、TransformerRegistrytextured_max_lodの処理を追加。
nusamai/src/transformer/transform/lods.rs LodFilterModeTexturedHighestAllを追加し、LodMask構造体にDebugトレイトを追加。

Assessment against linked issues

Objective Addressed Explanation
全てのLODを抽出できるTransformerの設定を追加する (#645)

Possibly related issues

うさぎの詩:

変更が舞い込む、嬉しい知らせ、
エンティティがクローン、さあ、みんなで遊ぼう!
テクスチャの設定、さようなら、
新しいLOD、もっと楽しくなる!
うさぎたちの夢、広がる空、
みんなで描く、素敵なアート! 🐇✨


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f7b3a84 and 8ed6320.

Files selected for processing (1)
  • nusamai/src/transformer/setting.rs (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • nusamai/src/transformer/setting.rs

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>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 testing code 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 39.53488% with 52 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
nusamai/src/transformer/transform/lods.rs 17.07% 34 Missing ⚠️
nusamai/src/transformer/setting.rs 50.00% 16 Missing ⚠️
nusamai-plateau/src/entity.rs 0.00% 1 Missing ⚠️
nusamai/src/sink/obj/mod.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
Components Coverage Δ
GUI 0.00% <ø> (ø)
Backend 73.81% <40.00%> (-0.37%) ⬇️
Libraries 89.71% <0.00%> (+0.02%) ⬆️

📢 Thoughts on this report? Let us know!

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.

Actionable comments posted: 3

Outside diff range and nitpick comments (2)
nusamai/src/transformer/setting.rs (2)

142-143: テストケースの追加が必要です。

追加された行がテストでカバーされていないようです。Boolean パラメータタイプの処理ロジックを実装する際は、適切なテストケースを追加してください。

テストコードの生成やGitHub issueの作成をお手伝いしましょうか?

Tools
GitHub Check: codecov/patch

[warning] 142-143: nusamai/src/transformer/setting.rs#L142-L143
Added lines #L142 - L143 were not covered by tests


163-169: 変更内容に問題ありません。テストケースの追加をお願いします。

新しい "textured_max_lod" オプションの処理が正しく実装されています。LODフィルターモードを TexturedHighest に設定し、appearanceをtrueに設定することで、期待される動作が実現できています。

ただし、追加された行がテストでカバーされていないようです。動作を確認するためのテストケースを追加してください。

テストコードの生成やGitHub issueの作成をお手伝いしましょうか?

Tools
GitHub Check: codecov/patch

[warning] 163-169: nusamai/src/transformer/setting.rs#L163-L169
Added lines #L163 - L169 were not covered by tests

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 58eb3e2 and f3c5812.

Files selected for processing (7)
  • nusamai-plateau/src/entity.rs (1 hunks)
  • nusamai/src/sink/cesiumtiles/mod.rs (1 hunks)
  • nusamai/src/sink/gltf/mod.rs (1 hunks)
  • nusamai/src/sink/obj/mod.rs (1 hunks)
  • nusamai/src/sink/obj/obj_writer.rs (1 hunks)
  • nusamai/src/transformer/setting.rs (3 hunks)
  • nusamai/src/transformer/transform/lods.rs (3 hunks)
Files skipped from review due to trivial changes (1)
  • nusamai/src/sink/obj/obj_writer.rs
Additional context used
GitHub Check: codecov/patch
nusamai-plateau/src/entity.rs

[warning] 8-8: nusamai-plateau/src/entity.rs#L8
Added line #L8 was not covered by tests

nusamai/src/transformer/setting.rs

[warning] 142-143: nusamai/src/transformer/setting.rs#L142-L143
Added lines #L142 - L143 were not covered by tests


[warning] 163-169: nusamai/src/transformer/setting.rs#L163-L169
Added lines #L163 - L169 were not covered by tests

nusamai/src/transformer/transform/lods.rs

[warning] 35-37: nusamai/src/transformer/transform/lods.rs#L35-L37
Added lines #L35 - L37 were not covered by tests


[warning] 39-40: nusamai/src/transformer/transform/lods.rs#L39-L40
Added lines #L39 - L40 were not covered by tests


[warning] 42-42: nusamai/src/transformer/transform/lods.rs#L42
Added line #L42 was not covered by tests


[warning] 44-54: nusamai/src/transformer/transform/lods.rs#L44-L54
Added lines #L44 - L54 were not covered by tests


[warning] 57-59: nusamai/src/transformer/transform/lods.rs#L57-L59
Added lines #L57 - L59 were not covered by tests


[warning] 61-61: nusamai/src/transformer/transform/lods.rs#L61
Added line #L61 was not covered by tests


[warning] 64-64: nusamai/src/transformer/transform/lods.rs#L64
Added line #L64 was not covered by tests


[warning] 69-71: nusamai/src/transformer/transform/lods.rs#L69-L71
Added lines #L69 - L71 were not covered by tests


[warning] 83-84: nusamai/src/transformer/transform/lods.rs#L83-L84
Added lines #L83 - L84 were not covered by tests


[warning] 86-89: nusamai/src/transformer/transform/lods.rs#L86-L89
Added lines #L86 - L89 were not covered by tests


[warning] 91-91: nusamai/src/transformer/transform/lods.rs#L91
Added line #L91 was not covered by tests

Additional comments not posted (7)
nusamai-plateau/src/entity.rs (1)

8-8: LGTM!

Clone トレイトを Entity 構造体の derive マクロに追加することは、構造体のインスタンスをクローンできるようにするための適切な変更です。クローンは、データ構造を複製する必要がある場合によく使用されます。

この変更は、コードの既存のロジックやコントロールフローを変更するものではありません。

追加された行がテストでカバーされていないことについては、Clone トレイトは標準的な Rust の機能であり、その動作は明確に定義されているため、重大な問題ではありません。ただし、将来的にはテストケースを追加することを検討してください。

Tools
GitHub Check: codecov/patch

[warning] 8-8: nusamai-plateau/src/entity.rs#L8
Added line #L8 was not covered by tests

nusamai/src/transformer/setting.rs (2)

71-75: LGTM!

新しいオプション "テクスチャ付き最大LOD" が正しく追加されています。ラベルと値のフォーマットが既存のオプションと一致しており、問題ありません。


163-169: 新しいオプションが期待通りに動作することを確認してください。

以下のスクリプトを実行して、"textured_max_lod" オプションが正しく動作することを確認してください。

Verification successful

新しい "textured_max_lod" オプションが正しく実装されていることを確認しました。

コードベースの分析結果から、以下のことが確認できました:

  • "textured_max_lod" オプションが nusamai/src/transformer/setting.rs ファイルに正しく実装されています。
  • このオプションが選択された場合、LodFilterMode::TexturedHighest が設定されます。
  • 同時に set_appearance(true) が呼び出され、appearanceが正しく設定されます。
  • LodFilterMode::TexturedHighestnusamai/src/transformer/transform/lods.rs ファイルでも参照されており、適切に統合されていることが示唆されます。

これらの結果から、新しいオプションが期待通りに実装され、動作することが確認できました。

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 説明: "textured_max_lod" オプションが正しく動作することを確認します。

# テスト: "textured_max_lod" オプションを選択した場合の動作を確認します。
# 期待される結果: 
# - LODフィルターモードが `TexturedHighest` に設定されること。
# - appearanceがtrueに設定されること。

# TransformerRegistryのbuildメソッドをモック化してテストを実行
cat <<EOF | cargo test
use crate::transformer::setting::{LodSelection, ParameterType, Selection, TransformerConfig, TransformerRegistry};
use crate::sink::DataRequirements;
use crate::transformer::{LodFilterMode, LodFilterSpec};

#[test]
fn test_textured_max_lod_option() {
    let mut registry = TransformerRegistry::new();
    let lod_selection = Selection::new(LodSelection::get_lod_selection_options(), "textured_max_lod");
    let config = TransformerConfig {
        key: "use_lod".to_string(),
        label: "".to_string(), 
        parameter: ParameterType::Selection(lod_selection),
    };
    registry.insert(config);

    let requirements = registry.build(DataRequirements::default());

    assert_eq!(requirements.lod_filter.mode, LodFilterMode::TexturedHighest);
    assert_eq!(requirements.appearance, true);
}
EOF

Length of output: 92


Script:

#!/bin/bash

# Search for the "textured_max_lod" option implementation
ast-grep --lang rust --pattern 'match $_ {
  $$$
  "textured_max_lod" => {
    $$$
  }
  $$$
}'

# Search for references to LodFilterMode::TexturedHighest
rg "LodFilterMode::TexturedHighest" -n

# Search for set_appearance(true) calls
rg "set_appearance\(true\)" -n

Length of output: 499

Tools
GitHub Check: codecov/patch

[warning] 163-169: nusamai/src/transformer/setting.rs#L163-L169
Added lines #L163 - L169 were not covered by tests

nusamai/src/sink/gltf/mod.rs (1)

32-32: テクスチャ設定の削除は適切です。

テクスチャ設定 use_texture_config(false) の削除により、トランスフォーマーオプションが簡素化されています。この変更は、GLTFデータシンクにおけるテクスチャの処理や利用方法に影響を与える可能性があります。

nusamai/src/sink/cesiumtiles/mod.rs (1)

41-41: テクスチャ設定オプションの削除は適切です。

use_texture_config(false) の削除により、Cesium タイルのデータ処理パイプラインが簡素化され、テクスチャ付きの最大LODを出力するオプションの導入に合致しています。この変更は、テクスチャ設定がこのコンテキストで不要になったことを示唆しています。

nusamai/src/sink/obj/mod.rs (1)

39-39: LGTM!

use_lod_config 関数のインポートは適切です。この関数は、おそらく ObjSinkProvider 構造体の transformer_options メソッドで使用されます。

nusamai/src/transformer/transform/lods.rs (1)

15-15: TexturedHighestモードの追加

LodFilterModeに新しいバリアントTexturedHighestを追加することで、テクスチャ付きの最高LODを選択できるようになっており、機能拡張として適切です。

nusamai/src/transformer/transform/lods.rs Show resolved Hide resolved
nusamai/src/transformer/transform/lods.rs Show resolved Hide resolved
nusamai/src/transformer/transform/lods.rs Outdated Show resolved Hide resolved
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.

Actionable comments posted: 1

Outside diff range and nitpick comments (3)
nusamai/src/transformer/setting.rs (1)

143-144: TODOコメントに対処することを忘れないでください。

このTODOコメントは、ブール型パラメータの処理ロジックがまだ実装されていないことを示しています。実装を完了させるか、適切なチケットを作成して追跡してください。

このタスクのチケットを作成しましょうか?

nusamai/src/transformer/transform/lods.rs (2)

36-36: TODO: 処理の最適化

TODOコメントにあるように、処理の最適化の余地があります。パフォーマンスが重要な場合は、別のPRで最適化に取り組むことをお勧めします。


91-91: match文での網羅性の向上

match self.modeにおいて、デフォルトの_ => {}パターンがありますが、LodFilterModeの全てのバリアントを明示的にマッチさせることで、将来新しいバリアントが追加された際にコンパイラが未処理のケースを警告します。_ => {}を削除することをお勧めします。

修正案:

                 }
-                _ => {}
             }
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d66377d and d3b2c6b.

Files selected for processing (2)
  • nusamai/src/transformer/setting.rs (3 hunks)
  • nusamai/src/transformer/transform/lods.rs (3 hunks)
Additional comments not posted (7)
nusamai/src/transformer/setting.rs (2)

71-76: LGTM!

テクスチャ付き最大LODオプションの追加は良いと思います。将来の3Dタイルシンクでの全LODオプションのサポートについてのコメントも適切です。


164-170: LGTM!

テクスチャ付き最大LODパラメータ値の処理ケースの追加は適切です。LODフィルターモードをTexturedHighestに設定し、appearanceをtrueに設定することは、テクスチャ付き最大LODを処理するのに適しています。

nusamai/src/transformer/transform/lods.rs (5)

15-16: LGTM!

LodFilterMode列挙型に新しいバリアントTexturedHighestAllを追加することで、機能が拡張されています。命名規則に従っており、既存のコードを壊すこともありません。


35-73: テクスチャの有無に基づいてLODを選択する新しいロジックを追加

TexturedHighestモードでは、テクスチャ付きのLODがある場合はそのLODのエンティティを、テクスチャがない場合は最高のLODのエンティティを選択するロジックが実装されています。コードの可読性も高く、LODの選択処理が適切に行われています。


93-95: Allモードの実装

Allモードでは、フィルタリングを行わずに元のエンティティをそのまま出力しています。シンプルで分かりやすい実装になっています。


149-149: LodMaskDebugトレイトを追加

LodMask構造体がDebugトレイトを導出するようになりました。これにより、LodMaskのインスタンスをデバッグしやすくなります。既存の機能に悪影響はありません。


49-52: unwrap()の使用によるパニックの可能性を回避する

appearance_store.read().unwrap()を使用していますが、ロックがポイズンされている場合にパニックを引き起こす可能性があります。エラーハンドリングを追加して、ロック取得に失敗した場合に適切に対処することをお勧めします。

修正案:

- let appearance = entity_copy.appearance_store.read().unwrap();
+ let appearance = match entity_copy.appearance_store.read() {
+     Ok(appearance) => appearance,
+     Err(e) => {
+         // ロック取得に失敗した場合の処理(例: エラーを記録してスキップ)
+         eprintln!("Failed to acquire read lock: {}", e);
+         return; // または適切なエラー処理
+     }
+ };

Likely invalid or redundant comment.

nusamai/src/transformer/setting.rs Show resolved Hide resolved
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.

Actionable comments posted: 2

Outside diff range and nitpick comments (2)
nusamai/src/option.rs (1)

10-12: 関数名の変更を検討してください

use_lod_config関数は現在、テクスチャなしのLOD選択に特化しています。関数名をより明確にするために、use_non_textured_lod_configなどに変更することを検討してください。

それ以外の変更は適切で、PRの目的に沿っています。テクスチャ付きとテクスチャなしのLOD選択を分離することで、コードの明確性が向上しています。

nusamai/src/transformer/setting.rs (1)

83-89: テクスチャなしLOD選択の実装が適切です。最適化の提案があります。

lod_selection_without_texture関数は、"textured_max_lod"オプションを適切にフィルタリングしています。イテレータメソッドの使用も効率的です。

パフォーマンスを少し向上させるために、以下の最適化を検討してください:

-        let options = Self::get_lod_selection_options()
-            .into_iter()
+        let options = Self::get_lod_selection_options()
             .into_iter()
             .filter(|&(_, value)| value != "textured_max_lod")
-            .collect::<Vec<_>>();
-        Selection::new(options, default_value)
+        Selection::new(options.collect(), default_value)

この変更により、中間のベクターの作成を避けることができます。

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d3b2c6b and c905271.

Files ignored due to path filters (1)
  • app/src-tauri/tauri.conf.json is excluded by !**/*.json
Files selected for processing (5)
  • nusamai/src/option.rs (1 hunks)
  • nusamai/src/sink/cesiumtiles/mod.rs (2 hunks)
  • nusamai/src/sink/gltf/mod.rs (2 hunks)
  • nusamai/src/sink/obj/mod.rs (2 hunks)
  • nusamai/src/transformer/setting.rs (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • nusamai/src/sink/obj/mod.rs
Additional comments not posted (6)
nusamai/src/option.rs (1)

Line range hint 1-24: 全体的な評価:良好な変更

このファイルの変更は、PRの目的であるテクスチャ付き最大LODを出力するオプションの追加に適切に対応しています。テクスチャ付きとテクスチャなしのLOD選択を分離することで、コードの明確性と柔軟性が向上しています。

提案した小さな改善点(関数名の変更と一意のキーの使用)を検討し、実装することで、コードの品質がさらに向上するでしょう。

全体として、これらの変更は有益であり、プロジェクトの機能を拡張するという目標を達成しています。

nusamai/src/transformer/setting.rs (2)

79-82: テクスチャ付きLOD選択の実装が適切です。

lod_selection_with_texture関数は、テクスチャ付きのLODオプションを含むすべてのLOD選択肢を提供しており、要件を正しく満たしています。


71-76: LODオプションの追加が適切に実装されています。

"テクスチャ付き最大LOD"オプションの追加はPRの目的に合致しており、適切に実装されています。

コメントアウトされている"すべてのLOD"オプションについて、以下の確認をお願いします:

この実装は3dtilesシンクに関連しているようですが、現在の開発状況や今後の計画について教えていただけますか?

Verification successful

コメントアウトされた「すべてのLOD」オプションと関連するTODOについて確認しました。

"すべてのLOD"オプションは現在コメントアウトされており、3dtiles sinkに関連するTODOが存在します。今後の実装予定に従って処理されることを確認しました。

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: 3dtilesシンクの実装状況を確認
rg --type rust "3dtiles.*sink" -C 5

Length of output: 2482


Script:

#!/bin/bash
# Description: Check if 'lod_all' option is implemented or if TODOs related to 3dtiles sink are addressed
rg --type rust "lod_all|TODO.*3dtiles sink" -C 5

Length of output: 1990

nusamai/src/sink/gltf/mod.rs (3)

32-32: 新しい設定オプションのインポートが追加されました。

use_textured_lod_configのインポートは、PRの目的であるテクスチャ付き最大LODを出力するオプションの追加と一致しています。この変更は適切であり、新しい機能の実装を支援します。


61-61: LODとテクスチャの設定が統合されました。

use_textured_lod_config("max_lod")の使用は、PRの目的に沿ってテクスチャ付き最大LODを設定するための良い方法です。この変更はコードを簡素化し、可読性を向上させています。

ただし、以下の点を確認してください:

  1. この変更が、LODとテクスチャの設定を別々に行う必要があるケースに影響を与えていないか。
  2. "max_lod"以外の引数でこの関数を呼び出す必要がある場合の挙動。

以下のスクリプトを実行して、use_textured_lod_configの使用箇所と引数を確認してください:


Line range hint 1-1000: テクスチャ関連の機能の総合的なテストを推奨します。

新しいuse_textured_lod_config関数の導入に伴い、既存のテクスチャ処理ロジックとの互換性を確認することが重要です。特に以下の点に注意してテストを行ってください:

  1. テクスチャのパッキングプロセス(特にTexturePackerの使用箇所)
  2. UV座標の更新処理
  3. アトラステクスチャの生成と使用

これらのテストにより、新しい設定オプションが既存の機能を損なうことなく、期待通りに動作することを確認できます。

テクスチャ関連の主要な処理を特定するために、以下のスクリプトを実行してください:

Verification successful

テクスチャ関連の機能が正しく統合されています。特にuse_textured_lod_config関数は既存のテクスチャ処理ロジックと互換性があります。

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Identify key texture-related processing in the file
rg --type rust -e 'TexturePacker' -e 'uv_coords' -e 'atlas' nusamai/src/sink/gltf/mod.rs

Length of output: 1176


Script:

#!/bin/bash
# Description: Search for all usages of `use_textured_lod_config` in the codebase
rg --type rust 'use_textured_lod_config' nusamai/src/sink/gltf/mod.rs

Length of output: 167


Script:

#!/bin/bash
# Description: Find the definition and implementation of `use_textured_lod_config` in the codebase
rg --type rust 'fn use_textured_lod_config' nusamai

Length of output: 150


Script:

#!/bin/bash
# Description: Extract the complete definition of `use_textured_lod_config` from option.rs
rg --type rust -A 20 'fn use_textured_lod_config' nusamai/src/option.rs

Length of output: 393

nusamai/src/option.rs Show resolved Hide resolved
nusamai/src/sink/cesiumtiles/mod.rs Show resolved Hide resolved
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.

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
nusamai/src/transformer/setting.rs (1)

151-152: 未実装のBoolean型パラメータ処理があります

ParameterType::Booleanの処理が未実装です。必要であれば、実装をお手伝いできます。

実装のコードを提供しましょうか?それとも、GitHub Issueを作成してこのタスクを追跡しますか?

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 78b291f and 1506f6d.

Files selected for processing (1)
  • nusamai/src/transformer/setting.rs (3 hunks)
Additional comments not posted (4)
nusamai/src/transformer/setting.rs (4)

71-76: 新しいLODオプションの追加が適切です

「テクスチャ付き最大LOD」オプションが正しく追加されています。


79-82: lod_selection_with_texture関数の実装が正しいです

新しいLODオプションを含めた選択肢が正しく作成されています。


83-89: lod_selection_without_texture関数の実装が正しいです

「テクスチャ付き最大LOD」オプションを除外するフィルタリングが正しく行われています。


172-178: "textured_max_lod"オプションの処理が適切です

data_requirementsに対してLodFilterMode::TexturedHighestを設定し、set_appearance(true)が正しく呼び出されています。

@satoshi7190 satoshi7190 marked this pull request as ready for review September 24, 2024 06:32
Copy link
Collaborator

@nokonoko1203 nokonoko1203 left a comment

Choose a reason for hiding this comment

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

@satoshi7190 要求は満たしているためapproveですが、質問への回答と整理・整頓が必須かなと思いました…!
マージはちょっと保留…
いや、マージはします!問題を切り分けてちゃんと対処した方が良いと思ったので!

@@ -5,7 +5,7 @@ use nusamai_citygml::{geometry::GeometryStore, object::Value};
use crate::appearance::AppearanceStore;

/// City objects, features, objects or data
#[derive(Debug, serde::Deserialize, serde::Serialize)]
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

q) 結局ここのCloneは除去できなかった感じですかね…

Copy link
Collaborator

Choose a reason for hiding this comment

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

僕が提案したコードを適用すると、除去できる気はしています!

@@ -92,7 +146,7 @@ fn find_lods(value: &Value) -> LodMask {
mask
}

#[derive(Default, Clone, Copy)]
#[derive(Default, Clone, Copy, Debug)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

nits) Debugは消しときましょうか!

out.push(entity);
match self.mode {
LodFilterMode::TexturedHighest => {
// TODO: Processing needs to be optimised
Copy link
Collaborator

Choose a reason for hiding this comment

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

nits) Processing needs to be optimized.
nits) 「最適化」とは具体的に何をするのか、記載しておいた方が良いかと!

edit_tree(&mut entity.root, target_lod);
out.push(entity);
match self.mode {
LodFilterMode::TexturedHighest => {
Copy link
Collaborator

@nokonoko1203 nokonoko1203 Sep 25, 2024

Choose a reason for hiding this comment

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

imo) テクスチャが付いた最大のLODを抽出する。テクスチャがない場合は最大のLODを抽出する。
くらいのコメントはあった方が良いと思いました!

match self.mode {
LodFilterMode::TexturedHighest => {
// TODO: Processing needs to be optimised
let original_lods = find_lods(&entity.root) & self.mask;
Copy link
Collaborator

@nokonoko1203 nokonoko1203 Sep 25, 2024

Choose a reason for hiding this comment

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

fyi) シンプルに、こんな感じではいかがでしょう。
一応、自分で動かしてみたところ、動作はしているように見えました。

let available_lods = find_lods(&entity.root) & self.mask;
let mut highest_textured_lod = None;

// 「最大のLOD」は初めから決まっている。テクスチャが存在しなければ、即座に最大LODを返却できる
let highest_available_lod = available_lods.highest_lod().unwrap_or(0);

// revで逆順イテレータを作成
for lod in (0..=highest_available_lod).rev() {
	if available_lods.0 & (1 << lod) != 0 {
		edit_tree(&mut entity.root, lod);

		let has_textures = {
			let appearance = entity.appearance_store.read().unwrap();
			!appearance.textures.is_empty()
		};

		// テクスチャが存在するLODが見つかれば、それを保存して終了
		if has_textures {
			highest_textured_lod = Some(lod);
			break;
		}
	}
}

// highest_textured_lodがNoneではないならhighest_textured_lodを利用
// Noneならhighest_available_lodを利用
if let Some(lod) = highest_textured_lod.or(Some(highest_available_lod)) {
	edit_tree(&mut entity.root, lod);
	out.push(entity);
}
Suggested change
let original_lods = find_lods(&entity.root) & self.mask;
let original_lods = find_lods(&entity.root) & self.mask;

}
}

pub fn use_texture_config(default_value: bool) -> TransformerConfig {
pub fn use_textured_lod_config(default_value: &str) -> TransformerConfig {
Copy link
Collaborator

Choose a reason for hiding this comment

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

q) use_lod_configuse_textured_lod_configで、use_lodという同名キーが利用されているのが全く理解できず…
オプションは分ける必要がある感じでしょうか?

@@ -7,16 +7,18 @@ pub fn use_lod_config(default_value: &str) -> TransformerConfig {
TransformerConfig {
Copy link
Collaborator

Choose a reason for hiding this comment

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

q) 前提がよく理解できていなかったんですが、option.rsはSinkのオプションで、transformer/setting.rsはトランスフォーマーのオプションを列挙している感じでしょうか?

Copy link
Collaborator

Choose a reason for hiding this comment

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

option.rsが transformerフォルダに属していないのが気になりました。

Copy link
Collaborator

Choose a reason for hiding this comment

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

imo) optionなのか、configなのか、settingなのか…表記が揺れていて、かつどれも異なる意味を持っていそうで、理解に時間がかかっちゃいそうです…!
整理が必要かと…

@nokonoko1203 nokonoko1203 merged commit 734ad3d into main Sep 25, 2024
9 of 10 checks passed
@nokonoko1203 nokonoko1203 deleted the feature/lod-texture-option branch September 25, 2024 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

transformer: 全てのLODを抽出する設定を追加 ui: 初期画面サイズを大きくする
2 participants