two-parameter radius in pull_spot()

This commit is contained in:
David Rose 2013-06-06 21:14:12 +00:00
parent c277d802a0
commit ac3f5e924c
2 changed files with 13 additions and 11 deletions

View File

@ -1533,23 +1533,25 @@ clear_to_texcoords(int x_size, int y_size) {
// Function: PfmFile::pull_spot
// Access: Published
// Description: Applies delta * t to the point values within radius
// distance of (xc, yc). The t value is scaled from 1.0
// at the center to 0.0 at radius, and this scale
// follows the specified exponent. Returns the number
// of points affected.
// (xr, yr) distance of (xc, yc). The t value is scaled
// from 1.0 at the center to 0.0 at radius (xr, yr), and
// this scale follows the specified exponent. Returns
// the number of points affected.
////////////////////////////////////////////////////////////////////
int PfmFile::
pull_spot(const LPoint4f &delta, double xc, double yc,
double radius, double exponent) {
int minx = max((int)cceil(xc - radius), 0);
int maxx = min((int)cfloor(xc + radius), _x_size - 1);
int miny = max((int)cceil(yc - radius), 0);
int maxy = min((int)cfloor(yc + radius), _y_size - 1);
double xr, double yr, double exponent) {
int minx = max((int)cceil(xc - xr), 0);
int maxx = min((int)cfloor(xc + xr), _x_size - 1);
int miny = max((int)cceil(yc - yr), 0);
int maxy = min((int)cfloor(yc + yr), _y_size - 1);
int count = 0;
for (int yi = miny; yi <= maxy; ++yi) {
for (int xi = minx; xi <= maxx; ++xi) {
double r2 = (xi - xc) * (xi - xc) + (yi - yc) * (yi - yc);
double xd = ((double)xi - xc) / xr;
double yd = ((double)yi - yc) / yr;
double r2 = xd * xd + yd * yd;
if (r2 >= 1.0) {
continue;
}

View File

@ -125,7 +125,7 @@ PUBLISHED:
BLOCKING void clear_to_texcoords(int x_size, int y_size);
BLOCKING int pull_spot(const LPoint4f &delta, double xc, double yc,
double radius, double exponent);
double xr, double yr, double exponent);
bool calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point) const;
BLOCKING PT(BoundingHexahedron) compute_planar_bounds(const LPoint2f &center, PN_float32 point_dist, PN_float32 sample_radius, bool points_only) const;