Recommended Posts

aha,hello to all the smarter and warm-hearted helper! let's get to the point/

I'm study the Tutorials about "How to use Facet data",and there is a description about mesh partitioning,and the Official PG is

and here is mine:

so,if i call "updateFacetData()" method,then there will be 10*10*10(default) blocks here,,right?

i wanna know：

1. if there is a way/method to check if a specific block contains/intersect some facet(the whole facet or part of it).

thanks for u time.

Share on other sites

yep

say x is the index of the block on the mesh X local axis, y is the index of the block on the mesh Y local axis, and z the index on the Z local axis.

So if you want to know what is inside the (x-th, y-th, z-th) block when it's partitioned by 10x10x10, just compute

i = x + 10 * y + 10 * 10 * z

and call mesh.getFacetLocalPartioning() what returns an array of arrays of facet indexes : https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.abstractMesh.ts#L1821

var i = x + 10 * y + 10 * 10 * z;
var blocks = mesh.getFacetLocalPartioning();

blocks[i] // contains all the facets intersecting the block indexes

Share on other sites

o,thx,so if it's 10*10*10,there should be 1000 blocks.

console.log(blocks.length) 

the result is >1000,why is that?

console.log(blocks)



the result is:

does this means :

block[23] contain(include intersect) the 349th、350th、351th、396th、397th、398th facet

block[24] only contain(include intersect) the 349th facet?

Share on other sites

Nope, this is a flat array, for performance access reasons, with a max size of 10 + 10 * 10 + 10 * 10 * 10

But not all the elements are populated, only the one containing / intersecting a facet. This is why the actual size can be lower than this maximum.

Example : block[6] = [12, 23] means the facet 12 and 23 intersects the 6-th block on the X axis

yes, for your second question : the facets 349, 350, 351, etc, up to 398 have a least one vertex or their own center (barycenter) in the block[23]

Share on other sites

oh,haha ,got it.Thank u

Share on other sites

hi,jerome:

when i use sphere to test "getFacetLocalPartitioning()" function.it works perfectly.

mesh = BABYLON.Mesh.CreateSphere("sphere", 32.0, 10.0, scene);

so if i change the mesh to a cube,i think it should be a cube made up with many little cubes.right?

mesh = BABYLON.Mesh.CreateBox("box", 10.0, scene);

but it seems that they didn't work well,the PG is :

so

if block != undifined

as you said :the block will have a least one vertex or their own center (barycenter) ...

can i check if a block contain part of the facet(Neither vertex nor center ，just part of it)?

Share on other sites

In order to work well, the facets must be in general far smaller than the blocks (if the facets are as big as the blocks, the results may be weird) and it's mostly intended to manage meshes with many tiny facets (several dozens, hundreds, thousands, etc) rather than meshes with few big facets. The box is, by definition, a mesh with few big facets, so the block partitioning is probably not the best tool here.

You could try by reducing the block number for the box to 4 or 3 though.

There's no provided method to check if just a part of a facet is in a given block : only the 3 vertices and the facet center are tested so far (this means 4 tests per facet, what can lead to high computation when dealing with 10K facets ex : the skull)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.