mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
pull_spot()
This commit is contained in:
parent
a3027ceb23
commit
c277d802a0
@ -1529,6 +1529,43 @@ 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.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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);
|
||||
|
||||
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);
|
||||
if (r2 >= 1.0) {
|
||||
continue;
|
||||
}
|
||||
PN_float32 t = (PN_float32)pow(1.0 - sqrt(r2), exponent);
|
||||
|
||||
PN_float32 *f = &_table[(yi * _x_size + xi) * _num_channels];
|
||||
for (int ci = 0; ci < _num_channels; ++ci) {
|
||||
f[ci] += delta[ci] * t;
|
||||
}
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PfmFile::calc_tight_bounds
|
||||
// Access: Published
|
||||
|
@ -124,6 +124,9 @@ PUBLISHED:
|
||||
BLOCKING void apply_crop(int x_begin, int x_end, int y_begin, int y_end);
|
||||
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);
|
||||
|
||||
bool calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point) const;
|
||||
BLOCKING PT(BoundingHexahedron) compute_planar_bounds(const LPoint2f ¢er, PN_float32 point_dist, PN_float32 sample_radius, bool points_only) const;
|
||||
INLINE BLOCKING PT(BoundingHexahedron) compute_planar_bounds(const LPoint2d ¢er, PN_float32 point_dist, PN_float32 sample_radius, bool points_only) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user