Jump to content

questions about facet data-->Mesh partitioning


BangTao
 Share

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 

http://www.babylonjs-playground.com/#UZGNA

and here is mine:

http://www.babylonjs-playground.com/#1YTZAC#5

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.

Link to comment
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

 

Link to comment
Share on other sites

@jerome

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

console.log(blocks.length) 

http://www.babylonjs-playground.com/#1YTZAC#6

the result is >1000,why is that?

console.log(blocks)

the result is:

58b6624e0e45c_DJX3S6K6T(@XB81EVF.png.bd18bfc18b5b8d85208ac9efb88ece4c.png

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?

Link to comment
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]

Link to comment
Share on other sites

@jerome

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 :

http://www.babylonjs-playground.com/#TQPS2

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)?

 

Link to comment
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)

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...