Cleanup: rename externtex to RE_texture_evaluate

- Pass in return arguments last.
- Pass in RGBA as a vector.
- Use boolean return argument.
This commit is contained in:
Campbell Barton
2020-05-01 14:03:12 +10:00
parent 635754a876
commit f7d98d3582
5 changed files with 43 additions and 47 deletions

View File

@@ -49,7 +49,7 @@
#include "IMB_imbuf.h" #include "IMB_imbuf.h"
#include "IMB_imbuf_types.h" #include "IMB_imbuf_types.h"
#include "RE_render_ext.h" /* externtex */ #include "RE_render_ext.h" /* RE_texture_evaluate */
static void brush_init_data(ID *id) static void brush_init_data(ID *id)
{ {
@@ -1552,8 +1552,7 @@ float BKE_brush_sample_tex_3d(const Scene *scene,
else if (mtex->brush_map_mode == MTEX_MAP_MODE_3D) { else if (mtex->brush_map_mode == MTEX_MAP_MODE_3D) {
/* Get strength by feeding the vertex /* Get strength by feeding the vertex
* location directly into a texture */ * location directly into a texture */
hasrgb = externtex( hasrgb = RE_texture_evaluate(mtex, point, thread, pool, false, false, &intensity, rgba);
mtex, point, &intensity, rgba, rgba + 1, rgba + 2, rgba + 3, thread, pool, false, false);
} }
else if (mtex->brush_map_mode == MTEX_MAP_MODE_STENCIL) { else if (mtex->brush_map_mode == MTEX_MAP_MODE_STENCIL) {
float rotation = -mtex->rot; float rotation = -mtex->rot;
@@ -1583,8 +1582,7 @@ float BKE_brush_sample_tex_3d(const Scene *scene,
co[1] = y; co[1] = y;
co[2] = 0.0f; co[2] = 0.0f;
hasrgb = externtex( hasrgb = RE_texture_evaluate(mtex, co, thread, pool, false, false, &intensity, rgba);
mtex, co, &intensity, rgba, rgba + 1, rgba + 2, rgba + 3, thread, pool, false, false);
} }
else { else {
float rotation = -mtex->rot; float rotation = -mtex->rot;
@@ -1640,8 +1638,7 @@ float BKE_brush_sample_tex_3d(const Scene *scene,
co[1] = y; co[1] = y;
co[2] = 0.0f; co[2] = 0.0f;
hasrgb = externtex( hasrgb = RE_texture_evaluate(mtex, co, thread, pool, false, false, &intensity, rgba);
mtex, co, &intensity, rgba, rgba + 1, rgba + 2, rgba + 3, thread, pool, false, false);
} }
intensity += br->texture_sample_bias; intensity += br->texture_sample_bias;
@@ -1698,8 +1695,7 @@ float BKE_brush_sample_masktex(
co[1] = y; co[1] = y;
co[2] = 0.0f; co[2] = 0.0f;
externtex( RE_texture_evaluate(mtex, co, thread, pool, false, false, &intensity, rgba);
mtex, co, &intensity, rgba, rgba + 1, rgba + 2, rgba + 3, thread, pool, false, false);
} }
else { else {
float rotation = -mtex->rot; float rotation = -mtex->rot;
@@ -1755,8 +1751,7 @@ float BKE_brush_sample_masktex(
co[1] = y; co[1] = y;
co[2] = 0.0f; co[2] = 0.0f;
externtex( RE_texture_evaluate(mtex, co, thread, pool, false, false, &intensity, rgba);
mtex, co, &intensity, rgba, rgba + 1, rgba + 2, rgba + 3, thread, pool, false, false);
} }
CLAMP(intensity, 0.0f, 1.0f); CLAMP(intensity, 0.0f, 1.0f);
@@ -2078,7 +2073,7 @@ unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side, bool use_sec
/* This is copied from displace modifier code */ /* This is copied from displace modifier code */
/* TODO(sergey): brush are always caching with CM enabled for now. */ /* TODO(sergey): brush are always caching with CM enabled for now. */
externtex(mtex, co, &intensity, rgba, rgba + 1, rgba + 2, rgba + 3, 0, NULL, false, false); RE_texture_evaluate(mtex, co, 0, NULL, false, false, &intensity, rgba);
((char *)texcache)[(iy * side + ix) * 4] = ((char *)texcache)[(iy * side + ix) * 4 + 1] = ((char *)texcache)[(iy * side + ix) * 4] = ((char *)texcache)[(iy * side + ix) * 4 + 1] =
((char *)texcache)[(iy * side + ix) * 4 + 2] = (( ((char *)texcache)[(iy * side + ix) * 4 + 2] = ((

View File

@@ -4004,7 +4004,7 @@ static void get_cpa_texture(Mesh *mesh,
break; break;
} }
externtex(mtex, texvec, &value, rgba, rgba + 1, rgba + 2, rgba + 3, 0, NULL, false, false); RE_texture_evaluate(mtex, texvec, 0, NULL, false, false, &value, rgba);
if ((event & mtex->mapto) & PAMAP_ROUGH) { if ((event & mtex->mapto) & PAMAP_ROUGH) {
ptex->rough1 = ptex->rough2 = ptex->roughe = texture_value_blend( ptex->rough1 = ptex->rough2 = ptex->roughe = texture_value_blend(
@@ -4119,7 +4119,7 @@ void psys_get_texture(
break; break;
} }
externtex(mtex, texvec, &value, rgba, rgba + 1, rgba + 2, rgba + 3, 0, NULL, false, false); RE_texture_evaluate(mtex, texvec, 0, NULL, false, false, &value, rgba);
if ((event & mtex->mapto) & PAMAP_TIME) { if ((event & mtex->mapto) & PAMAP_TIME) {
/* the first time has to set the base value for time regardless of blend mode */ /* the first time has to set the base value for time regardless of blend mode */

View File

@@ -166,10 +166,11 @@ float paint_calc_object_space_radius(ViewContext *vc, const float center[3], flo
float paint_get_tex_pixel(const MTex *mtex, float u, float v, struct ImagePool *pool, int thread) float paint_get_tex_pixel(const MTex *mtex, float u, float v, struct ImagePool *pool, int thread)
{ {
float intensity, rgba[4]; float intensity;
float rgba_dummy[4];
float co[3] = {u, v, 0.0f}; float co[3] = {u, v, 0.0f};
externtex(mtex, co, &intensity, rgba, rgba + 1, rgba + 2, rgba + 3, thread, pool, false, false); RE_texture_evaluate(mtex, co, thread, pool, false, false, &intensity, rgba_dummy);
return intensity; return intensity;
} }
@@ -184,11 +185,10 @@ void paint_get_tex_pixel_col(const MTex *mtex,
struct ColorSpace *colorspace) struct ColorSpace *colorspace)
{ {
float co[3] = {u, v, 0.0f}; float co[3] = {u, v, 0.0f};
int hasrgb;
float intensity; float intensity;
hasrgb = externtex( const bool hasrgb = RE_texture_evaluate(mtex, co, thread, pool, false, false, &intensity, rgba);
mtex, co, &intensity, rgba, rgba + 1, rgba + 2, rgba + 3, thread, pool, false, false);
if (!hasrgb) { if (!hasrgb) {
rgba[0] = intensity; rgba[0] = intensity;
rgba[1] = intensity; rgba[1] = intensity;

View File

@@ -33,18 +33,16 @@ struct ImagePool;
struct MTex; struct MTex;
/* render_texture.c */ /* render_texture.c */
/* used by particle.c, effect.c, editmesh_modes.c and brush.c, returns 1 if rgb, 0 otherwise */ bool RE_texture_evaluate(const struct MTex *mtex,
int externtex(const struct MTex *mtex, const float vec[3],
const float vec[3], const int thread,
float *tin, struct ImagePool *pool,
float *tr, const bool skip_load_image,
float *tg, const bool texnode_preview,
float *tb, /* Return arguments. */
float *ta, float *r_intensity,
const int thread, float r_rgba[4]) ATTR_NONNULL(1, 2, 7, 8);
struct ImagePool *pool,
const bool skip_load_image,
const bool texnode_preview);
void texture_rgb_blend( void texture_rgb_blend(
float in[3], const float tex[3], const float out[3], float fact, float facg, int blendtype); float in[3], const float tex[3], const float out[3], float fact, float facg, int blendtype);
float texture_value_blend(float tex, float out, float fact, float facg, int blendtype); float texture_value_blend(float tex, float out, float fact, float facg, int blendtype);

View File

@@ -1724,17 +1724,20 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
int externtex(const MTex *mtex, /**
const float vec[3], * \param pool: Thread pool, may be NULL.
float *tin, *
float *tr, * \return True if the texture has color, otherwise false.
float *tg, */
float *tb, bool RE_texture_evaluate(const MTex *mtex,
float *ta, const float vec[3],
const int thread, const int thread,
struct ImagePool *pool, struct ImagePool *pool,
const bool skip_load_image, const bool skip_load_image,
const bool texnode_preview) const bool texnode_preview,
/* Return arguments. */
float *r_intensity,
float r_rgba[4])
{ {
Tex *tex; Tex *tex;
TexResult texr; TexResult texr;
@@ -1796,11 +1799,11 @@ int externtex(const MTex *mtex,
texr.tb = mtex->b; texr.tb = mtex->b;
} }
*tin = texr.tin; *r_intensity = texr.tin;
*tr = texr.tr; r_rgba[0] = texr.tr;
*tg = texr.tg; r_rgba[1] = texr.tg;
*tb = texr.tb; r_rgba[2] = texr.tb;
*ta = texr.ta; r_rgba[3] = texr.ta;
return (rgb != 0); return (rgb != 0);
} }