mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
clip to bounds in make_displacement()
This commit is contained in:
parent
b16e829044
commit
6f248198e7
@ -421,7 +421,10 @@ make_displacement(PNMImage &result, double max_u, double max_v) const {
|
|||||||
|
|
||||||
// We use the blue channel to mark holes, so we can fill them in
|
// We use the blue channel to mark holes, so we can fill them in
|
||||||
// later.
|
// later.
|
||||||
result.set_xel_val(xi, yi, u_val, v_val, 0);
|
result.set_xel_val(xi, yi,
|
||||||
|
min(max(u_val, 0), PNM_MAXMAXVAL),
|
||||||
|
min(max(v_val, 0), PNM_MAXMAXVAL),
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,7 +486,10 @@ r_fill_displacement(PNMImage &result, int xi, int yi,
|
|||||||
double y_shift = (nyi - (double)yi);
|
double y_shift = (nyi - (double)yi);
|
||||||
int u_val = midval + (int)cfloor(x_shift * u_scale + 0.5);
|
int u_val = midval + (int)cfloor(x_shift * u_scale + 0.5);
|
||||||
int v_val = midval + (int)cfloor(y_shift * v_scale + 0.5);
|
int v_val = midval + (int)cfloor(y_shift * v_scale + 0.5);
|
||||||
result.set_xel_val(xi, yi, u_val, v_val, distance);
|
result.set_xel_val(xi, yi,
|
||||||
|
min(max(u_val, 0), PNM_MAXMAXVAL),
|
||||||
|
min(max(v_val, 0), PNM_MAXMAXVAL),
|
||||||
|
min(distance, PNM_MAXMAXVAL));
|
||||||
|
|
||||||
r_fill_displacement(result, xi - 1, yi, nxi, nyi, u_scale, v_scale, distance + 1);
|
r_fill_displacement(result, xi - 1, yi, nxi, nyi, u_scale, v_scale, distance + 1);
|
||||||
r_fill_displacement(result, xi + 1, yi, nxi, nyi, u_scale, v_scale, distance + 1);
|
r_fill_displacement(result, xi + 1, yi, nxi, nyi, u_scale, v_scale, distance + 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user