Cleanup: remove unused sculpt texture cache generation
This has not been used since 5505697ac
in 2010.
This commit is contained in:
parent
b6a76243cd
commit
5c0d18f682
Notes:
blender-bot
2023-02-14 05:04:52 +01:00
Referenced by issue #100350, Regression: Sculpt mode strength Falloff Overlay not visible
|
@ -119,10 +119,6 @@ float BKE_brush_sample_masktex(const struct Scene *scene,
|
|||
int thread,
|
||||
struct ImagePool *pool);
|
||||
|
||||
/* Texture. */
|
||||
|
||||
unsigned int *BKE_brush_gen_texture_cache(struct Brush *br, int half_side, bool use_secondary);
|
||||
|
||||
/**
|
||||
* Radial control.
|
||||
*/
|
||||
|
|
|
@ -552,8 +552,7 @@ typedef struct SculptSession {
|
|||
float (*deform_cos)[3]; /* Coords of deformed mesh but without stroke displacement. */
|
||||
float (*deform_imats)[3][3]; /* Crazy-space deformation matrices. */
|
||||
|
||||
/* Used to cache the render of the active texture */
|
||||
unsigned int texcache_side, *texcache, texcache_actual;
|
||||
/* Pool for texture evaluations. */
|
||||
struct ImagePool *tex_pool;
|
||||
|
||||
struct StrokeCache *cache;
|
||||
|
|
|
@ -2469,71 +2469,55 @@ float BKE_brush_curve_strength_clamped(const Brush *br, float p, const float len
|
|||
}
|
||||
|
||||
/* TODO: should probably be unified with BrushPainter stuff? */
|
||||
unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side, bool use_secondary)
|
||||
static bool brush_gen_texture(const Brush *br,
|
||||
const int side,
|
||||
const bool use_secondary,
|
||||
float *rect)
|
||||
{
|
||||
unsigned int *texcache = NULL;
|
||||
MTex *mtex = (use_secondary) ? &br->mask_mtex : &br->mtex;
|
||||
float intensity;
|
||||
float rgba_dummy[4];
|
||||
const MTex *mtex = (use_secondary) ? &br->mask_mtex : &br->mtex;
|
||||
if (mtex->tex == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const float step = 2.0 / side;
|
||||
int ix, iy;
|
||||
int side = half_side * 2;
|
||||
float x, y;
|
||||
|
||||
if (mtex->tex) {
|
||||
float x, y, step = 2.0 / side, co[3];
|
||||
/* Do normalized canonical view coords for texture. */
|
||||
for (y = -1.0, iy = 0; iy < side; iy++, y += step) {
|
||||
for (x = -1.0, ix = 0; ix < side; ix++, x += step) {
|
||||
const float co[3] = {x, y, 0.0f};
|
||||
|
||||
texcache = MEM_callocN(sizeof(int) * side * side, "Brush texture cache");
|
||||
float intensity;
|
||||
float rgba_dummy[4];
|
||||
RE_texture_evaluate(mtex, co, 0, NULL, false, false, &intensity, rgba_dummy);
|
||||
|
||||
/* do normalized canonical view coords for texture */
|
||||
for (y = -1.0, iy = 0; iy < side; iy++, y += step) {
|
||||
for (x = -1.0, ix = 0; ix < side; ix++, x += step) {
|
||||
co[0] = x;
|
||||
co[1] = y;
|
||||
co[2] = 0.0f;
|
||||
|
||||
/* This is copied from displace modifier code */
|
||||
/* TODO(sergey): brush are always caching with CM enabled for now. */
|
||||
RE_texture_evaluate(mtex, co, 0, NULL, false, false, &intensity, rgba_dummy);
|
||||
copy_v4_uchar((uchar *)&texcache[iy * side + ix], (char)(intensity * 255.0f));
|
||||
}
|
||||
rect[iy * side + ix] = intensity;
|
||||
}
|
||||
}
|
||||
|
||||
return texcache;
|
||||
return true;
|
||||
}
|
||||
|
||||
struct ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br, bool secondary, bool display_gradient)
|
||||
{
|
||||
ImBuf *im = MEM_callocN(sizeof(ImBuf), "radial control texture");
|
||||
unsigned int *texcache;
|
||||
int side = 512;
|
||||
int half = side / 2;
|
||||
int i, j;
|
||||
|
||||
BKE_curvemapping_init(br->curve);
|
||||
texcache = BKE_brush_gen_texture_cache(br, half, secondary);
|
||||
im->rect_float = MEM_callocN(sizeof(float) * side * side, "radial control rect");
|
||||
im->x = im->y = side;
|
||||
|
||||
if (display_gradient || texcache) {
|
||||
for (i = 0; i < side; i++) {
|
||||
for (j = 0; j < side; j++) {
|
||||
float magn = sqrtf(pow2f(i - half) + pow2f(j - half));
|
||||
im->rect_float[i * side + j] = BKE_brush_curve_strength_clamped(br, magn, half);
|
||||
}
|
||||
}
|
||||
}
|
||||
const bool have_texture = brush_gen_texture(br, side, secondary, im->rect_float);
|
||||
|
||||
if (texcache) {
|
||||
/* Modulate curve with texture */
|
||||
for (i = 0; i < side; i++) {
|
||||
for (j = 0; j < side; j++) {
|
||||
const int col = texcache[i * side + j];
|
||||
im->rect_float[i * side + j] *= (((char *)&col)[0] + ((char *)&col)[1] +
|
||||
((char *)&col)[2]) /
|
||||
3.0f / 255.0f;
|
||||
if (display_gradient || have_texture) {
|
||||
for (int i = 0; i < side; i++) {
|
||||
for (int j = 0; j < side; j++) {
|
||||
float magn = sqrtf(pow2f(i - half) + pow2f(j - half));
|
||||
im->rect_float[i * side + j] *= BKE_brush_curve_strength_clamped(br, magn, half);
|
||||
}
|
||||
}
|
||||
MEM_freeN(texcache);
|
||||
}
|
||||
|
||||
return im;
|
||||
|
|
|
@ -1485,8 +1485,6 @@ void BKE_sculptsession_free(Object *ob)
|
|||
BM_log_free(ss->bm_log);
|
||||
}
|
||||
|
||||
MEM_SAFE_FREE(ss->texcache);
|
||||
|
||||
if (ss->tex_pool) {
|
||||
BKE_image_pool_free(ss->tex_pool);
|
||||
}
|
||||
|
|
|
@ -2381,7 +2381,7 @@ float SCULPT_brush_strength_factor(SculptSession *ss,
|
|||
/* Get strength by feeding the vertex location directly into a texture. */
|
||||
avg = BKE_brush_sample_tex_3d(scene, br, point, rgba, 0, ss->tex_pool);
|
||||
}
|
||||
else if (ss->texcache) {
|
||||
else {
|
||||
float symm_point[3], point_2d[2];
|
||||
/* Quite warnings. */
|
||||
float x = 0.0f, y = 0.0f;
|
||||
|
@ -3937,27 +3937,6 @@ static void do_symmetrical_brush_actions(Sculpt *sd,
|
|||
}
|
||||
}
|
||||
|
||||
static void sculpt_update_tex(const Scene *scene, Sculpt *sd, SculptSession *ss)
|
||||
{
|
||||
Brush *brush = BKE_paint_brush(&sd->paint);
|
||||
const int radius = BKE_brush_size_get(scene, brush);
|
||||
|
||||
MEM_SAFE_FREE(ss->texcache);
|
||||
|
||||
if (ss->tex_pool) {
|
||||
BKE_image_pool_free(ss->tex_pool);
|
||||
ss->tex_pool = NULL;
|
||||
}
|
||||
|
||||
/* Need to allocate a bigger buffer for bigger brush size. */
|
||||
ss->texcache_side = 2 * radius;
|
||||
if (!ss->texcache || ss->texcache_side > ss->texcache_actual) {
|
||||
ss->texcache = BKE_brush_gen_texture_cache(brush, radius, false);
|
||||
ss->texcache_actual = ss->texcache_side;
|
||||
ss->tex_pool = BKE_image_pool_new();
|
||||
}
|
||||
}
|
||||
|
||||
bool SCULPT_mode_poll(bContext *C)
|
||||
{
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
|
@ -5040,7 +5019,7 @@ bool SCULPT_stroke_get_location(bContext *C, float out[3], const float mval[2])
|
|||
return hit;
|
||||
}
|
||||
|
||||
static void sculpt_brush_init_tex(const Scene *scene, Sculpt *sd, SculptSession *ss)
|
||||
static void sculpt_brush_init_tex(Sculpt *sd, SculptSession *ss)
|
||||
{
|
||||
Brush *brush = BKE_paint_brush(&sd->paint);
|
||||
MTex *mtex = &brush->mtex;
|
||||
|
@ -5051,14 +5030,13 @@ static void sculpt_brush_init_tex(const Scene *scene, Sculpt *sd, SculptSession
|
|||
ntreeTexBeginExecTree(mtex->tex->nodetree);
|
||||
}
|
||||
|
||||
/* TODO: Shouldn't really have to do this at the start of every stroke, but sculpt would need
|
||||
* some sort of notification when changes are made to the texture. */
|
||||
sculpt_update_tex(scene, sd, ss);
|
||||
if (ss->tex_pool == NULL) {
|
||||
ss->tex_pool = BKE_image_pool_new();
|
||||
}
|
||||
}
|
||||
|
||||
static void sculpt_brush_stroke_init(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
|
||||
SculptSession *ss = CTX_data_active_object(C)->sculpt;
|
||||
|
@ -5077,7 +5055,7 @@ static void sculpt_brush_stroke_init(bContext *C, wmOperator *op)
|
|||
}
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
sculpt_brush_init_tex(scene, sd, ss);
|
||||
sculpt_brush_init_tex(sd, ss);
|
||||
|
||||
need_pmap = sculpt_needs_connectivity_info(sd, brush, ss, mode);
|
||||
needs_colors = SCULPT_TOOL_NEEDS_COLOR(brush->sculpt_tool);
|
||||
|
|
Loading…
Reference in New Issue