Cleanup: Move colorband handling from DM to mesh_runtime universe.

This commit is contained in:
Bastien Montagne 2018-06-25 13:03:56 +02:00
parent e10eb5bcb8
commit 5b3ff9f7d8
6 changed files with 32 additions and 29 deletions

View File

@ -515,9 +515,6 @@ void DM_interp_poly_data(
int *src_indices,
float *weights, int count, int dest_index);
/* Temporary? A function to give a colorband to derivedmesh for vertexcolor ranges */
void vDM_ColorBand_store(const struct ColorBand *coba, const char alert_color[4]);
/* UNUSED */
#if 0
/** Simple function to get me->totvert amount of vertices/normals,

View File

@ -35,6 +35,7 @@
#include "BKE_customdata.h" /* for CustomDataMask */
struct ColorBand;
struct CustomData;
struct Depsgraph;
struct KeyBlock;
@ -86,6 +87,10 @@ struct Mesh *mesh_get_eval_deform(
void BKE_mesh_runtime_eval_to_meshkey(struct Mesh *me_deformed, struct Mesh *me, struct KeyBlock *kb);
/* Temporary? A function to give a colorband to derivedmesh for vertexcolor ranges */
void BKE_mesh_runtime_color_band_store(const struct ColorBand *coba, const char alert_color[4]);
#ifndef NDEBUG
char *BKE_mesh_runtime_debug_info(struct Mesh *me_eval);
void BKE_mesh_runtime_debug_print(struct Mesh *me_eval);

View File

@ -1438,10 +1438,10 @@ enum {
CALC_WP_MIRROR_X = (1 << 5),
};
typedef struct DMWeightColorInfo {
typedef struct MERuntimeWeightColorInfo {
const ColorBand *coba;
const char *alert_color;
} DMWeightColorInfo;
} MERuntimeWeightColorInfo;
static int dm_drawflag_calc(const ToolSettings *ts, const Mesh *me)
@ -1453,7 +1453,7 @@ static int dm_drawflag_calc(const ToolSettings *ts, const Mesh *me)
((me->editflag & ME_EDIT_MIRROR_X) ? CALC_WP_MIRROR_X : 0));
}
static void weightpaint_color(unsigned char r_col[4], DMWeightColorInfo *dm_wcinfo, const float input)
static void weightpaint_color(unsigned char r_col[4], MERuntimeWeightColorInfo *dm_wcinfo, const float input)
{
float colf[4];
@ -1476,7 +1476,7 @@ static void weightpaint_color(unsigned char r_col[4], DMWeightColorInfo *dm_wcin
static void calc_weightpaint_vert_color(
unsigned char r_col[4],
const MDeformVert *dv,
DMWeightColorInfo *dm_wcinfo,
MERuntimeWeightColorInfo *dm_wcinfo,
const int defbase_tot, const int defbase_act,
const bool *defbase_sel, const int defbase_sel_tot,
const int draw_flag)
@ -1521,12 +1521,12 @@ static void calc_weightpaint_vert_color(
}
}
static DMWeightColorInfo G_dm_wcinfo;
static MERuntimeWeightColorInfo G_me_runtime_wcinfo;
void vDM_ColorBand_store(const ColorBand *coba, const char alert_color[4])
void BKE_mesh_runtime_color_band_store(const ColorBand *coba, const char alert_color[4])
{
G_dm_wcinfo.coba = coba;
G_dm_wcinfo.alert_color = alert_color;
G_me_runtime_wcinfo.coba = coba;
G_me_runtime_wcinfo.alert_color = alert_color;
}
/**
@ -1537,7 +1537,7 @@ void vDM_ColorBand_store(const ColorBand *coba, const char alert_color[4])
* so leave this as is - campbell
*/
static void calc_weightpaint_vert_array(
Object *ob, DerivedMesh *dm, int const draw_flag, DMWeightColorInfo *dm_wcinfo,
Object *ob, DerivedMesh *dm, int const draw_flag, MERuntimeWeightColorInfo *dm_wcinfo,
unsigned char (*r_wtcol_v)[4])
{
BMEditMesh *em = (dm->type == DM_TYPE_EDITBMESH) ? BKE_editmesh_from_object(ob) : NULL;
@ -1612,7 +1612,7 @@ static void calc_weightpaint_vert_array(
}
static void calc_weightpaint_vert_array_mesh(
Object *ob, Mesh *mesh, int const draw_flag, DMWeightColorInfo *dm_wcinfo,
Object *ob, Mesh *mesh, int const draw_flag, MERuntimeWeightColorInfo *dm_wcinfo,
unsigned char (*r_wtcol_v)[4])
{
BMEditMesh *em = BKE_editmesh_from_object(ob);
@ -1741,7 +1741,7 @@ void DM_update_weight_mcol(
}
else {
/* No weights given, take them from active vgroup(s). */
calc_weightpaint_vert_array(ob, dm, draw_flag, &G_dm_wcinfo, wtcol_v);
calc_weightpaint_vert_array(ob, dm, draw_flag, &G_me_runtime_wcinfo, wtcol_v);
}
if (dm->type == DM_TYPE_EDITBMESH) {
@ -1815,7 +1815,7 @@ static void mesh_update_weight_mcol(
}
else {
/* No weights given, take them from active vgroup(s). */
calc_weightpaint_vert_array_mesh(ob, mesh, draw_flag, &G_dm_wcinfo, wtcol_v);
calc_weightpaint_vert_array_mesh(ob, mesh, draw_flag, &G_me_runtime_wcinfo, wtcol_v);
}
if (em) {

View File

@ -48,9 +48,9 @@
#include "BKE_addon.h"
#include "BKE_appdir.h"
#include "BKE_colorband.h"
#include "BKE_DerivedMesh.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_mesh_runtime.h"
#include "BIF_gl.h"
@ -1856,9 +1856,9 @@ void init_userdef_do_versions(Main *bmain)
U.fcu_inactive_alpha = 0.25f;
}
/* signal for derivedmesh to use colorband */
/* signal for evaluated mesh to use colorband */
/* run in case this was on and is now off in the user prefs [#28096] */
vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL, UI_GetTheme()->tv3d.vertex_unreferenced);
BKE_mesh_runtime_color_band_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL, UI_GetTheme()->tv3d.vertex_unreferenced);
if (!USER_VERSION_ATLEAST(192, 0)) {
strcpy(U.sounddir, "/");

View File

@ -34,6 +34,7 @@
#include "DNA_curve_types.h"
#include "DNA_group_types.h"
#include "DNA_lattice_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
#include "DNA_scene_types.h"
@ -48,7 +49,6 @@
#include "BKE_blender_version.h"
#include "BKE_curve.h"
#include "BKE_displist.h"
#include "BKE_DerivedMesh.h"
#include "BKE_key.h"
#include "BKE_layer.h"
#include "BKE_paint.h"
@ -92,15 +92,15 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats)
switch (ob->type) {
case OB_MESH:
{
/* we assume derivedmesh is already built, this strictly does stats now. */
DerivedMesh *dm = ob->derivedFinal;
/* we assume evaluated mesh is already built, this strictly does stats now. */
Mesh *me_eval = ob->runtime.mesh_eval;
int totvert, totedge, totface, totloop;
if (dm) {
totvert = dm->getNumVerts(dm);
totedge = dm->getNumEdges(dm);
totface = dm->getNumPolys(dm);
totloop = dm->getNumLoops(dm);
if (me_eval) {
totvert = me_eval->totvert;
totedge = me_eval->totedge;
totface = me_eval->totpoly;
totloop = me_eval->totloop;
stats->totvert += totvert * totob;
stats->totedge += totedge * totob;

View File

@ -39,7 +39,6 @@
#include "BLI_math_vector.h"
#include "BKE_appdir.h"
#include "BKE_DerivedMesh.h"
#include "BKE_sound.h"
#include "BKE_addon.h"
#include "BKE_studiolight.h"
@ -101,9 +100,11 @@ static const EnumPropertyItem rna_enum_studio_light_orientation_items[] = {
#include "DNA_screen_types.h"
#include "BKE_blender.h"
#include "BKE_DerivedMesh.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_idprop.h"
#include "BKE_main.h"
#include "BKE_mesh_runtime.h"
#include "BKE_pbvh.h"
#include "BKE_paint.h"
@ -365,7 +366,7 @@ static void rna_UserDef_weight_color_update(Main *bmain, Scene *scene, PointerRN
Object *ob;
bTheme *btheme = UI_GetTheme();
vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL, btheme->tv3d.vertex_unreferenced);
BKE_mesh_runtime_color_band_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL, btheme->tv3d.vertex_unreferenced);
for (ob = bmain->object.first; ob; ob = ob->id.next) {
if (ob->mode & OB_MODE_WEIGHT_PAINT)