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_types.h"
#include "RE_render_ext.h" /* externtex */
#include "RE_render_ext.h" /* RE_texture_evaluate */
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) {
/* Get strength by feeding the vertex
* location directly into a texture */
hasrgb = externtex(
mtex, point, &intensity, rgba, rgba + 1, rgba + 2, rgba + 3, thread, pool, false, false);
hasrgb = RE_texture_evaluate(mtex, point, thread, pool, false, false, &intensity, rgba);
}
else if (mtex->brush_map_mode == MTEX_MAP_MODE_STENCIL) {
float rotation = -mtex->rot;
@ -1583,8 +1582,7 @@ float BKE_brush_sample_tex_3d(const Scene *scene,
co[1] = y;
co[2] = 0.0f;
hasrgb = externtex(
mtex, co, &intensity, rgba, rgba + 1, rgba + 2, rgba + 3, thread, pool, false, false);
hasrgb = RE_texture_evaluate(mtex, co, thread, pool, false, false, &intensity, rgba);
}
else {
float rotation = -mtex->rot;
@ -1640,8 +1638,7 @@ float BKE_brush_sample_tex_3d(const Scene *scene,
co[1] = y;
co[2] = 0.0f;
hasrgb = externtex(
mtex, co, &intensity, rgba, rgba + 1, rgba + 2, rgba + 3, thread, pool, false, false);
hasrgb = RE_texture_evaluate(mtex, co, thread, pool, false, false, &intensity, rgba);
}
intensity += br->texture_sample_bias;
@ -1698,8 +1695,7 @@ float BKE_brush_sample_masktex(
co[1] = y;
co[2] = 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);
}
else {
float rotation = -mtex->rot;
@ -1755,8 +1751,7 @@ float BKE_brush_sample_masktex(
co[1] = y;
co[2] = 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);
}
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 */
/* 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 + 2] = ((

View File

@ -4004,7 +4004,7 @@ static void get_cpa_texture(Mesh *mesh,
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) {
ptex->rough1 = ptex->rough2 = ptex->roughe = texture_value_blend(
@ -4119,7 +4119,7 @@ void psys_get_texture(
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) {
/* 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 intensity, rgba[4];
float intensity;
float rgba_dummy[4];
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;
}
@ -184,11 +185,10 @@ void paint_get_tex_pixel_col(const MTex *mtex,
struct ColorSpace *colorspace)
{
float co[3] = {u, v, 0.0f};
int hasrgb;
float intensity;
hasrgb = externtex(
mtex, co, &intensity, rgba, rgba + 1, rgba + 2, rgba + 3, thread, pool, false, false);
const bool hasrgb = RE_texture_evaluate(mtex, co, thread, pool, false, false, &intensity, rgba);
if (!hasrgb) {
rgba[0] = intensity;
rgba[1] = intensity;

View File

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

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