diff options
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 35 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/deform.c | 40 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/editderivedmesh.c | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 4 |
5 files changed, 52 insertions, 46 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index a77e6ec12c7..4aee616580e 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1394,39 +1394,6 @@ static void add_orco_mesh( * happens on enter/exit wpaint. */ -void weight_to_rgb(float r_rgb[3], const float weight) -{ - const float blend = ((weight / 2.0f) + 0.5f); - - if (weight <= 0.25f) { /* blue->cyan */ - r_rgb[0] = 0.0f; - r_rgb[1] = blend * weight * 4.0f; - r_rgb[2] = blend; - } - else if (weight <= 0.50f) { /* cyan->green */ - r_rgb[0] = 0.0f; - r_rgb[1] = blend; - r_rgb[2] = blend * (1.0f - ((weight - 0.25f) * 4.0f)); - } - else if (weight <= 0.75f) { /* green->yellow */ - r_rgb[0] = blend * ((weight - 0.50f) * 4.0f); - r_rgb[1] = blend; - r_rgb[2] = 0.0f; - } - else if (weight <= 1.0f) { /* yellow->red */ - r_rgb[0] = blend; - r_rgb[1] = blend * (1.0f - ((weight - 0.75f) * 4.0f)); - r_rgb[2] = 0.0f; - } - else { - /* exceptional value, unclamped or nan, - * avoid uninitialized memory use */ - r_rgb[0] = 1.0f; - r_rgb[1] = 0.0f; - r_rgb[2] = 1.0f; - } -} - /* draw_flag's for calc_weightpaint_vert_color */ enum { /* only one of these should be set, keep first (for easy bit-shifting) */ @@ -1461,7 +1428,7 @@ static void weightpaint_color(unsigned char r_col[4], MERuntimeWeightColorInfo * BKE_colorband_evaluate(dm_wcinfo->coba, input, colf); } else { - weight_to_rgb(colf, input); + BKE_defvert_weight_to_rgb(colf, input); } /* don't use rgb_float_to_uchar() here because diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 2da157d5b88..d08e3643ca7 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -1293,3 +1293,43 @@ bool data_transfer_layersmapping_vgroups( } /** \} */ + +/* -------------------------------------------------------------------- */ + +/** \name Various utils & helpers. + * \{ */ + +void BKE_defvert_weight_to_rgb(float r_rgb[3], const float weight) +{ + const float blend = ((weight / 2.0f) + 0.5f); + + if (weight <= 0.25f) { /* blue->cyan */ + r_rgb[0] = 0.0f; + r_rgb[1] = blend * weight * 4.0f; + r_rgb[2] = blend; + } + else if (weight <= 0.50f) { /* cyan->green */ + r_rgb[0] = 0.0f; + r_rgb[1] = blend; + r_rgb[2] = blend * (1.0f - ((weight - 0.25f) * 4.0f)); + } + else if (weight <= 0.75f) { /* green->yellow */ + r_rgb[0] = blend * ((weight - 0.50f) * 4.0f); + r_rgb[1] = blend; + r_rgb[2] = 0.0f; + } + else if (weight <= 1.0f) { /* yellow->red */ + r_rgb[0] = blend; + r_rgb[1] = blend * (1.0f - ((weight - 0.75f) * 4.0f)); + r_rgb[2] = 0.0f; + } + else { + /* exceptional value, unclamped or nan, + * avoid uninitialized memory use */ + r_rgb[0] = 1.0f; + r_rgb[1] = 0.0f; + r_rgb[2] = 1.0f; + } +} + +/** \} */ diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index f5e5a37c7d7..4c2f513007a 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -49,6 +49,7 @@ #include "BLI_task.h" #include "BKE_cdderivedmesh.h" +#include "BKE_deform.h" #include "BKE_mesh.h" #include "BKE_editmesh.h" #include "BKE_editmesh_bvh.h" @@ -1082,7 +1083,7 @@ static void statvis_calc_overhang( /* fallback max */ { float fcol[3]; - weight_to_rgb(fcol, 1.0f); + BKE_defvert_weight_to_rgb(fcol, 1.0f); rgb_float_to_uchar(col_fallback_max, fcol); } @@ -1096,7 +1097,7 @@ static void statvis_calc_overhang( fac = (fac - min) * minmax_irange; fac = 1.0f - fac; CLAMP(fac, 0.0f, 1.0f); - weight_to_rgb(fcol, fac); + BKE_defvert_weight_to_rgb(fcol, fac); rgb_float_to_uchar(r_face_colors[index], fcol); } else { @@ -1231,7 +1232,7 @@ static void statvis_calc_thickness( fac = (fac - min) * minmax_irange; fac = 1.0f - fac; CLAMP(fac, 0.0f, 1.0f); - weight_to_rgb(fcol, fac); + BKE_defvert_weight_to_rgb(fcol, fac); rgb_float_to_uchar(r_face_colors[i], fcol); } else { @@ -1270,7 +1271,7 @@ static void statvis_calc_intersect( overlap = BKE_bmbvh_overlap(bmtree, bmtree, &overlap_len); /* same for all faces */ - weight_to_rgb(fcol, 1.0f); + BKE_defvert_weight_to_rgb(fcol, 1.0f); rgb_float_to_uchar(col, fcol); if (overlap) { @@ -1357,7 +1358,7 @@ static void statvis_calc_distort( float fcol[3]; fac = (fac - min) * minmax_irange; CLAMP(fac, 0.0f, 1.0f); - weight_to_rgb(fcol, fac); + BKE_defvert_weight_to_rgb(fcol, fac); rgb_float_to_uchar(r_face_colors[index], fcol); } else { @@ -1407,7 +1408,7 @@ static void statvis_calc_sharp( float fcol[3]; fac = (fac - min) * minmax_irange; CLAMP(fac, 0.0f, 1.0f); - weight_to_rgb(fcol, fac); + BKE_defvert_weight_to_rgb(fcol, fac); rgb_float_to_uchar(r_vert_colors[i], fcol); } else { diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index aec4d8b735a..82514f0c92d 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2767,7 +2767,7 @@ static void psys_cache_edit_paths_iter( /* selection coloring in edit mode */ if (use_weight) { if (k == 0) { - weight_to_rgb(ca->col, pind.hkey[1]->weight); + BKE_defvert_weight_to_rgb(ca->col, pind.hkey[1]->weight); } else { /* warning: copied from 'do_particle_interpolation' (without 'mvert' array stepping) */ @@ -2789,8 +2789,8 @@ static void psys_cache_edit_paths_iter( float w1[3], w2[3]; keytime = (t - (*pind.ekey[0]->time)) / ((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); - weight_to_rgb(w1, pind.hkey[0]->weight); - weight_to_rgb(w2, pind.hkey[1]->weight); + BKE_defvert_weight_to_rgb(w1, pind.hkey[0]->weight); + BKE_defvert_weight_to_rgb(w2, pind.hkey[1]->weight); interp_v3_v3v3(ca->col, w1, w2, keytime); } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 8f94c7b3c8d..35c8761f671 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -70,7 +70,6 @@ #include "BKE_animsys.h" #include "BKE_boids.h" -#include "BKE_cdderivedmesh.h" #include "BKE_collision.h" #include "BKE_colortools.h" #include "BKE_effect.h" @@ -81,7 +80,6 @@ #include "BKE_particle.h" #include "BKE_collection.h" -#include "BKE_DerivedMesh.h" #include "BKE_object.h" #include "BKE_material.h" #include "BKE_cloth.h" @@ -328,7 +326,7 @@ void psys_calc_dmcache(Object *ob, Mesh *mesh_final, Mesh *mesh_original, Partic /* CACHE LOCATIONS */ if (!mesh_final->runtime.deformed_only) { - /* Will use later to speed up subsurf/derivedmesh */ + /* Will use later to speed up subsurf/evaluated mesh. */ LinkNode *node, *nodedmelem, **nodearray; int totdmelem, totelem, i, *origindex, *origindex_poly = NULL; |