Cleanup: remove another bunch of DM usages, includes etc.

This commit is contained in:
Bastien Montagne 2018-06-29 14:56:38 +02:00
parent a59df21ad8
commit 5ba87cf22e
18 changed files with 75 additions and 70 deletions

View File

@ -566,7 +566,6 @@ void makeDerivedMesh(
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct BMEditMesh *em,
CustomDataMask dataMask, const bool build_shapekey_layers);
void weight_to_rgb(float r_rgb[3], const float weight);
/** Update the weight MCOL preview layer.
* If weights are NULL, use object's active vgroup(s).
* Else, weights must be an array of weight float values.

View File

@ -116,4 +116,6 @@ void BKE_defvert_extract_vgroup_to_polyweights(
struct MDeformVert *dvert, const int defgroup, const int num_verts, struct MLoop *loops, const int num_loops,
struct MPoly *polys, const int num_polys, float *r_weights, const bool invert_vgroup);
void BKE_defvert_weight_to_rgb(float r_rgb[3], const float weight);
#endif /* __BKE_DEFORM_H__ */

View File

@ -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

View File

@ -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;
}
}
/** \} */

View File

@ -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 {

View File

@ -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);
}

View File

@ -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;

View File

@ -550,7 +550,7 @@ BLI_INLINE void bmesh_quick_edgedraw_flag(MEdge *med, BMEdge *e)
/**
*
* \param bmain May be NULL in case \a calc_object_remap parameter option is set.
* \param bmain May be NULL in case \a calc_object_remap parameter option is not set.
*/
void BM_mesh_bm_to_me(
Main *bmain, BMesh *bm, Mesh *me,

View File

@ -48,7 +48,7 @@
#include "BLT_translation.h"
#include "BKE_DerivedMesh.h"
#include "BKE_bvhutils.h"
#include "BKE_context.h"
#include "BKE_editmesh.h"
#include "BKE_editmesh_bvh.h"

View File

@ -27,6 +27,7 @@
#include "CLG_log.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_key_types.h"
#include "DNA_layer_types.h"
@ -35,7 +36,6 @@
#include "BLI_array_utils.h"
#include "BLI_alloca.h"
#include "BKE_DerivedMesh.h"
#include "BKE_context.h"
#include "BKE_key.h"
#include "BKE_layer.h"

View File

@ -49,7 +49,6 @@
#include "BLI_utildefines.h"
#include "BKE_context.h"
#include "BKE_DerivedMesh.h"
#include "BKE_icons.h"
#include "BKE_layer.h"
#include "BKE_main.h"

View File

@ -57,7 +57,6 @@
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_DerivedMesh.h"
#include "BKE_icons.h"
#include "BKE_image.h"
#include "BKE_global.h"

View File

@ -40,8 +40,8 @@
#include "BLI_utildefines.h"
#include "BLI_math.h"
#include "BKE_DerivedMesh.h"
#include "BKE_colorband.h"
#include "BKE_deform.h"
#include "BKE_particle.h"
#include "smoke_API.h"
@ -685,7 +685,7 @@ static void add_needle(float (*verts)[3], float (*colors)[3], float center[3],
float len = len_v3(dir);
float rgb[3];
weight_to_rgb(rgb, len);
BKE_defvert_weight_to_rgb(rgb, len);
if (len != 0.0f) {
mul_v3_fl(dir, 1.0f / len);
@ -725,7 +725,7 @@ static void add_streamline(float (*verts)[3], float(*colors)[3], float center[3]
const float len = len_v3(dir);
float rgb[3];
weight_to_rgb(rgb, len);
BKE_defvert_weight_to_rgb(rgb, len);
copy_v3_v3(colors[(*offset)], rgb);
copy_v3_v3(verts[(*offset)++], center);

View File

@ -57,7 +57,6 @@
#include "BKE_camera.h"
#include "BKE_context.h"
#include "BKE_customdata.h"
#include "BKE_DerivedMesh.h"
#include "BKE_image.h"
#include "BKE_key.h"
#include "BKE_layer.h"

View File

@ -41,7 +41,6 @@ struct Base;
struct BoundBox;
struct Gwn_Batch;
struct Depsgraph;
struct DerivedMesh;
struct Object;
struct SmokeDomainSettings;
struct bAnimVizSettings;

View File

@ -61,7 +61,6 @@
#include "BLI_bitmap.h"
#include "BLI_rect.h"
#include "BKE_DerivedMesh.h"
#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_constraint.h"

View File

@ -48,7 +48,7 @@
#include "BLI_buffer.h"
#include "BLI_bitmap.h"
#include "BKE_DerivedMesh.h"
#include "BKE_deform.h"
#include "BKE_editmesh.h"
#include "BKE_material.h"
#include "BKE_layer.h"
@ -277,7 +277,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME
else
areadiff = 1.0f - (area / uvarea);
weight_to_rgb(col, areadiff);
BKE_defvert_weight_to_rgb(col, areadiff);
immUniformColor3fv(col);
/* TODO: use editmesh tessface */
@ -357,7 +357,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME
BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
a = fabsf(uvang[i] - ang[i]) / (float)M_PI;
weight_to_rgb(col, 1.0f - pow2f(1.0f - a));
BKE_defvert_weight_to_rgb(col, 1.0f - pow2f(1.0f - a));
immAttrib3fv(color, col);
immVertex2fv(pos, luv->uv);
}

View File

@ -41,7 +41,6 @@
#include "BLI_utildefines.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_editmesh.h"
#include "BKE_mesh.h"
#include "BKE_library.h"
@ -218,20 +217,24 @@ static void deformVerts(
}
}
/* disabled particles in editmode for now, until support for proper derivedmesh
/* disabled particles in editmode for now, until support for proper evaluated mesh
* updates is coded */
#if 0
static void deformVertsEM(
ModifierData *md, Object *ob, EditMesh *editData,
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
ModifierData *md, Object *ob, BMEditMesh *editData,
Mesh *mesh, float (*vertexCos)[3], int numVerts)
{
DerivedMesh *dm = derivedData;
const bool do_temp_mesh = (mesh == NULL);
if (do_temp_mesh) {
mesh = BKE_id_new_nomain(ID_ME, ((ID *)ob->data)->name);
BM_mesh_bm_to_me(NULL, editData->bm, mesh, &((BMeshToMeshParams){0}));
}
if (!derivedData) dm = CDDM_from_editmesh(editData, ob->data);
deformVerts(md, ob, mesh, vertexCos, numVerts);
deformVerts(md, ob, dm, vertexCos, numVerts);
if (!derivedData) dm->release(dm);
if (derivedData) {
BKE_id_free(NULL, mesh);
}
}
#endif