diff options
author | Joseph Eagar <joeedh@gmail.com> | 2022-04-05 21:42:55 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2022-04-05 21:42:55 +0300 |
commit | eae36be372a6b16ee3e76eff0485a47da4f3c230 (patch) | |
tree | d1ca2dc30951e31f1b91eed6a4edfdfb0824bf1f /source/blender/blenloader/intern/versioning_300.c | |
parent | a3e122b9aec59fc303c2375a78183cfb8642c14f (diff) |
Refactor: Unify vertex and sculpt colors into new
color attribute system.
This commit removes sculpt colors from experimental
status and unifies it with vertex colors. It
introduces the concept of "color attributes", which
are any attributes that represents colors. Color
attributes can be represented with byte or floating-point
numbers and can be stored in either vertices or
face corners.
Color attributes share a common namespace
(so you can no longer have a floating-point
sculpt color attribute and a byte vertex color
attribute with the same name).
Note: this commit does not include vertex paint mode,
which is a separate patch, see:
https://developer.blender.org/D14179
Differential Revision: https://developer.blender.org/D12587
Ref D12587
Diffstat (limited to 'source/blender/blenloader/intern/versioning_300.c')
-rw-r--r-- | source/blender/blenloader/intern/versioning_300.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c index 3088dc4c7e8..5ba7dc74e3d 100644 --- a/source/blender/blenloader/intern/versioning_300.c +++ b/source/blender/blenloader/intern/versioning_300.c @@ -30,6 +30,7 @@ #include "DNA_lineart_types.h" #include "DNA_listBase.h" #include "DNA_material_types.h" +#include "DNA_mesh_types.h" #include "DNA_modifier_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" @@ -41,8 +42,10 @@ #include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_asset.h" +#include "BKE_attribute.h" #include "BKE_collection.h" #include "BKE_curve.h" +#include "BKE_data_transfer.h" #include "BKE_deform.h" #include "BKE_fcurve.h" #include "BKE_fcurve_driver.h" @@ -2566,6 +2569,74 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain) } } + if (!MAIN_VERSION_ATLEAST(bmain, 302, 10)) { + /* While vertex-colors were experimental the smear tool became corrupt due + * to bugs in the wm_toolsystem API (auto-creation of sculpt brushes + * was broken). Go through and reset all smear brushes. */ + LISTBASE_FOREACH (Brush *, br, &bmain->brushes) { + if (br->sculpt_tool == SCULPT_TOOL_SMEAR) { + br->alpha = 1.0f; + br->spacing = 5; + br->flag &= ~BRUSH_ALPHA_PRESSURE; + br->flag &= ~BRUSH_SPACE_ATTEN; + br->curve_preset = BRUSH_CURVE_SPHERE; + } + } + + /* Rebuild active/render color attribute references. */ + LISTBASE_FOREACH (Mesh *, me, &bmain->meshes) { + for (int step = 0; step < 2; step++) { + CustomDataLayer *actlayer = NULL; + + int vact1, vact2; + + if (step) { + vact1 = CustomData_get_render_layer_index(&me->vdata, CD_PROP_COLOR); + vact2 = CustomData_get_render_layer_index(&me->ldata, CD_MLOOPCOL); + } + else { + vact1 = CustomData_get_active_layer_index(&me->vdata, CD_PROP_COLOR); + vact2 = CustomData_get_active_layer_index(&me->ldata, CD_MLOOPCOL); + } + + if (vact1 != -1) { + actlayer = me->vdata.layers + vact1; + } + else if (vact2 != -1) { + actlayer = me->ldata.layers + vact2; + } + + if (actlayer) { + if (step) { + BKE_id_attributes_render_color_set(&me->id, actlayer); + } + else { + BKE_id_attributes_active_color_set(&me->id, actlayer); + } + } + } + } + + /* Update data transfer modifiers */ + LISTBASE_FOREACH (Object *, ob, &bmain->objects) { + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { + if (md->type == eModifierType_DataTransfer) { + DataTransferModifierData *dtmd = (DataTransferModifierData *)md; + + for (int i = 0; i < DT_MULTILAYER_INDEX_MAX; i++) { + if (dtmd->layers_select_src[i] == 0) { + dtmd->layers_select_src[i] = DT_LAYERS_ALL_SRC; + } + + if (dtmd->layers_select_dst[i] == 0) { + dtmd->layers_select_dst[i] = DT_LAYERS_NAME_DST; + } + } + } + } + } + } + /** * Versioning code until next subversion bump goes here. * |