[Bf-blender-cvs] [f7d98d35829] master: Cleanup: rename externtex to RE_texture_evaluate

Campbell Barton noreply at git.blender.org
Fri May 1 06:05:57 CEST 2020


Commit: f7d98d358290c1a8c6ddbfc8e3d9be3673779ee8
Author: Campbell Barton
Date:   Fri May 1 14:03:12 2020 +1000
Branches: master
https://developer.blender.org/rBf7d98d358290c1a8c6ddbfc8e3d9be3673779ee8

Cleanup: rename externtex to RE_texture_evaluate

- Pass in return arguments last.
- Pass in RGBA as a vector.
- Use boolean return argument.

===================================================================

M	source/blender/blenkernel/intern/brush.c
M	source/blender/blenkernel/intern/particle.c
M	source/blender/editors/sculpt_paint/paint_utils.c
M	source/blender/render/extern/include/RE_render_ext.h
M	source/blender/render/intern/source/render_texture.c

===================================================================

diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 2cc1d869e4c..c734205e84c 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -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] = ((
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 48e0a493ee0..e5ebae02558 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -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 */
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 60b4a2f8e0c..c84a3b9cbfc 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -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;
diff --git a/source/blender/render/extern/include/RE_render_ext.h b/source/blender/render/extern/include/RE_render_ext.h
index bca3b749192..bdf81354b8d 100644
--- a/source/blender/render/extern/include/RE_render_ext.h
+++ b/source/blender/render/extern/include/RE_render_ext.h
@@ -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);
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index eabba94ef29..123d384bed6 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -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);
 }



More information about the Bf-blender-cvs mailing list