From 226d111f9cb1a751894f57b0a3c82c4c26a3e9e3 Mon Sep 17 00:00:00 2001 From: maxcorsini Date: Tue, 20 Jan 2009 11:06:12 +0000 Subject: [PATCH] modify generatePoissonDisk taking into account spatial hash properties --- vcg/complex/trimesh/point_sampling.h | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/vcg/complex/trimesh/point_sampling.h b/vcg/complex/trimesh/point_sampling.h index 49fef47b..4438464a 100644 --- a/vcg/complex/trimesh/point_sampling.h +++ b/vcg/complex/trimesh/point_sampling.h @@ -666,16 +666,13 @@ static CoordType RandomBox(vcg::Box3 box) } // generate Poisson-disk sample using a set of pre-generated samples (with the Montecarlo algorithm) -static bool generatePoissonDiskSample(Point3i *cell, MontecarloSHT & samplepool, vcg::Point3 & p) +// It always return a point. +static vcg::Point3 generatePoissonDiskSample(Point3i *cell, MontecarloSHT & samplepool) { MontecarloSHTIterator cellBegin; MontecarloSHTIterator cellEnd; samplepool.Grid(*cell, cellBegin, cellEnd); - - assert(cellBegin != cellEnd); - - p = (*cellBegin)->P(); - return true; + return (*cellBegin)->P(); } // check the radius constrain @@ -795,8 +792,6 @@ static void Poissondisk(MetroMesh &origMesh, VertexSampler &ps, MetroMesh &monte vcg::Box3 currentBox; vcg::Point3 s; // current sample int level = 0; - bool validsample; - bool acceptedsample; do { @@ -833,20 +828,10 @@ static void Poissondisk(MetroMesh &origMesh, VertexSampler &ps, MetroMesh &monte currentCell = activeCells[i]; // generate a sample chosen from the pre-generated one - validsample = generatePoissonDiskSample(currentCell, montecarloSHT, s); + s = generatePoissonDiskSample(currentCell, montecarloSHT); samplesgenerated[level]++; - if (validsample) - { - // sample is valid - acceptedsample = checkPoissonDisk(*ps.m, checkSHT, s, r); - } - else - { - acceptedsample = false; - } - - if (acceptedsample) + if (checkPoissonDisk(*ps.m, checkSHT, s, r)) { // add sample tri::Allocator::AddVertices(supportMesh,1);