問題タブ [bounding-volume]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票する
0 に答える
793 参照

algorithm - Optimizing BVH Traversal with GPU

I created a bounding volume hierarchy that is generated every frame. Due to it's use, each node must have two children, no more, no less.

Traversal is the single most expensive computation for my program right now and it prevents large scenes (>2k triangles) from running at acceptable frame rates. I am at a loss as to how it can be performed faster. A simple square with 16 triangles introduces a noticeable frame drop when many rays pass through it at once.

To traverse it I used the concepts provided by the paper at this link, where each thread traverses the following code.

What can be done to make it increase it's speed?

At the moment, this function is used in a much larger kernal. Will isolating it within its own dispatch call help at the cost of using more memory to store its output?

I tried to minimize the memory accesses within the context of the algorithm, however the divergence, which I assume to be the problem, seems an impossible hurdle to overcome.

0 投票する
1 に答える
782 参照

javascript - boundingSphere による衝突検出

各メッシュ ( ) に対して、Three.js は非常にTHREE.Object3D便利なプロパティを提供boundingSphereboundingSphereます。intersectsSphereisIntersectionBox

これで、単純な衝突検出に使用できると思いましたが、試してみると、boundingSphereboundingSphere.center が常に入っているため、常に衝突が発生しているように見え(0, 0, 0);ます。 object - オブジェクトのクローンを作成boundingSphereし、ワールド座標を取得してから使用しますintersectsSphere

このようなもの:

これはどのように使用されると思われますか、それとも何かが足りないので、boundingBox/boundingSphere に基づいて衝突検出を行うより便利な方法がありますか?

0 投票する
2 に答える
359 参照

c++ - メモリ割り当てを減らす C++

次の問題のメモリ割り当てを減らすための適切な戦略を考え出すのに苦労しています:

ツリーを作成中です。std::vector最初は、いくつかのデータ (インデックスのリスト ())を含むルートしかありません。インデックスの一部が左の子に、残りの部分が右の子に移動する 2 つの部分に分割します。左/右にいくつ行くかわかりません。ルートの処理が完了すると、ルートのインデックスを保存する必要がなくなります。実際、私は葉のものだけに興味があります。さらに、分割ごとにデータを追加可能!したがって、ルートに 20 個の要素がある場合、分割後、左の要素は 12 個、右の要素は 10 個になる可能性があります。

各ノードで、std::vectorこれらのインデックスを含む を保持します。要素を追加するとき、push_back()多くのメモリ割り当てにつながる要素です。

インデックスを維持するための良い戦略は何ですか?

この質問は、SBVH データ構造の生成に関連しています。

コード:

0 投票する
0 に答える
94 参照

matlab - オブジェクトに位置合わせされたバウンディング ボリュームの作成

MATLAB を使用して、(レイ トレーシングの前に) バウンディング ボリューム アルゴリズムの背後にある数学をテストしようとしています。

これまでのところ、軸に沿った比較的単純なバウンディング ボリュームの作成に成功し、バウンディング 球体の作成に成功したと思います。

次に、オブジェクトに位置合わせされた境界ボリュームを作成しようとしましたが、ボックスが適切な形状であるように見えるため、主軸が正しいと思いますが、形状に正しく「上に」変換できませんでした。

基本的に私の質問は、アルゴリズムで間違っていることと、バウンディングボリュームを形状に変換する方法です。

私が使用している 2 つのソースは、Maths for 3D Gamesと、翻訳を行うためのヒントを提供しているブログですが、うまく機能していないようです。

ソース コードを以下に示します。どうもありがとうございました。

0 投票する
1 に答える
2962 参照

python - Computing the Bounding Sphere for a 3D Mesh in Python

As part of writing a 3D game library, I am trying to implement frustum culling in order to avoid rendering objects that are outside of the camera perspective frustum. To do this, I first need to calculate a bounding sphere for each mesh and see if it collides with any of the six sides of the viewing frustum. Here is my currently (very) naive implementation of computing the bounding sphere for each model as written in model.py in my code:

I am just taking pairwise points from my mesh and using the largest distance I find as my diameter. Calling this on 100 simple cube test models every frame is extremely slow, driving my frame rate from 120 fps to 1 fps! This is not surprising since I assume the time complexity for this pairwise code is O(n^2).

My question is what algorithm is fast and reasonably simple to implement that computes (at least) an approximate bounding sphere given a set of 3D points from a mesh? I looked at this Wikipedia page and saw there was an algorithm called "Ritter's bounding sphere." However, this requires me to choose some random point x in the mesh and hope that it is the approximate center so that I get a reasonably tight bounding sphere. Is there a fast method for choosing a good starting point x? Any help or advice would be greatly appreciated!

UPDATE:

Following @Aaron3468's answer, here is the code in my library that would calculate the bounding box and the corresponding bounding sphere:

0 投票する
0 に答える
217 参照

c++ - バウンディング ボリュームの計算から空の QEntity を除外する方法

私の会社では Qt3D を使用して CAD モデルを表示しています。Wee は、この関数を使用してQCamera::viewEntity(Qt3DCore::QEntity *entity)、特定のエンティティの境界球を計算し、エンティティを画面に合わせようとしました。

QEntityここで、空のノードの場合に解決できない問題に出くわしました。結局、ノードに頂点/ポイントが含まれていない場合、ノードを空と呼びます。この場合、バウンディング ボリュームの計算では無視する必要があると予想しました。代わりに、中心 (0.,0.,0.) と半径 0 の境界球があるため、処理されるようです。

次のコードは、この問題を示しています。

main.cpp

半径 0.5 で互いに距離 20 の 2 つの青い球体があります。中心 (20,0,0) と半径 (10.5) の境界球を期待しています。

代わりに、プログラムは次のように出力します。

値 2.14455 は本当にどこからともなく来ているようで、私の追加バウンディング ボリューム球体はいくぶん予測不可能です。

予期しないバウンディング ボリューム球

QVector3D(20, 10, 0)翻訳を結果に置き換えると、QVector3D(0,10,0)期待どおりになります。

バウンディング ボリューム球を修正する

バウンディング ボリュームの計算からルート エンティティを除外するにはどうすればよいですか?