cemyuksel / cyCodeBase

An open source programming resource intended for graphics programmers.
MIT License
271 stars 60 forks source link

Is it possible to keep the index of input points in the output points for cySampleElimination? #8

Closed marlinilram closed 4 years ago

marlinilram commented 5 years ago

Hi, thanks for the poisson disk sampling method, is it possible to keep the index of input points in the output points for cySampleElimination?

cemyuksel commented 5 years ago

It should be possible by using a custom class for PointType that also stores the point index, but I haven't tested this.

alecjacobson commented 4 years ago

Here's what I used (might be a better way):

namespace cy
{
  struct Point3f_id : public cy::Point3f
  {
    int i;
    Point3f_id( float v): cy::Point3f(v),i(-1){}
    Point3f_id(){}
    Point3f_id(const Point3f_id & that): cy::Point3f(that), i(that.i) {}
    Point3f_id(const Point3f & that): cy::Point3f(that), i(-1) {}
    Point3f_id operator-(Point3f_id const &that) const 
    {
      return cy::Point3f::operator-(that);
    };
  };
}

(sampler only seems to need the operator- and these constructors because the bounds are stored as the given type)