modify generatePoissonDisk taking into account spatial hash properties
This commit is contained in:
parent
f1ef838535
commit
226d111f9c
|
@ -666,16 +666,13 @@ static CoordType RandomBox(vcg::Box3<ScalarType> box)
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate Poisson-disk sample using a set of pre-generated samples (with the Montecarlo algorithm)
|
// generate Poisson-disk sample using a set of pre-generated samples (with the Montecarlo algorithm)
|
||||||
static bool generatePoissonDiskSample(Point3i *cell, MontecarloSHT & samplepool, vcg::Point3<ScalarType> & p)
|
// It always return a point.
|
||||||
|
static vcg::Point3<ScalarType> generatePoissonDiskSample(Point3i *cell, MontecarloSHT & samplepool)
|
||||||
{
|
{
|
||||||
MontecarloSHTIterator cellBegin;
|
MontecarloSHTIterator cellBegin;
|
||||||
MontecarloSHTIterator cellEnd;
|
MontecarloSHTIterator cellEnd;
|
||||||
samplepool.Grid(*cell, cellBegin, cellEnd);
|
samplepool.Grid(*cell, cellBegin, cellEnd);
|
||||||
|
return (*cellBegin)->P();
|
||||||
assert(cellBegin != cellEnd);
|
|
||||||
|
|
||||||
p = (*cellBegin)->P();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check the radius constrain
|
// check the radius constrain
|
||||||
|
@ -795,8 +792,6 @@ static void Poissondisk(MetroMesh &origMesh, VertexSampler &ps, MetroMesh &monte
|
||||||
vcg::Box3<ScalarType> currentBox;
|
vcg::Box3<ScalarType> currentBox;
|
||||||
vcg::Point3<ScalarType > s; // current sample
|
vcg::Point3<ScalarType > s; // current sample
|
||||||
int level = 0;
|
int level = 0;
|
||||||
bool validsample;
|
|
||||||
bool acceptedsample;
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -833,20 +828,10 @@ static void Poissondisk(MetroMesh &origMesh, VertexSampler &ps, MetroMesh &monte
|
||||||
currentCell = activeCells[i];
|
currentCell = activeCells[i];
|
||||||
|
|
||||||
// generate a sample chosen from the pre-generated one
|
// generate a sample chosen from the pre-generated one
|
||||||
validsample = generatePoissonDiskSample(currentCell, montecarloSHT, s);
|
s = generatePoissonDiskSample(currentCell, montecarloSHT);
|
||||||
samplesgenerated[level]++;
|
samplesgenerated[level]++;
|
||||||
|
|
||||||
if (validsample)
|
if (checkPoissonDisk(*ps.m, checkSHT, s, r))
|
||||||
{
|
|
||||||
// sample is valid
|
|
||||||
acceptedsample = checkPoissonDisk(*ps.m, checkSHT, s, r);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
acceptedsample = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (acceptedsample)
|
|
||||||
{
|
{
|
||||||
// add sample
|
// add sample
|
||||||
tri::Allocator<MetroMesh>::AddVertices(supportMesh,1);
|
tri::Allocator<MetroMesh>::AddVertices(supportMesh,1);
|
||||||
|
|
Loading…
Reference in New Issue