Vertex Paint: projection options
[blender-staging.git] / source / blender / blenloader / intern / versioning_270.c
index 810e6507c910701bf9bd9e3637c25188d85c7a90..b374e49fc836c1f4ebca6b3f51a87ce12cb6b940 100644 (file)
@@ -60,6 +60,7 @@
 #include "DNA_genfile.h"
 
 #include "BKE_animsys.h"
+#include "BKE_brush.h"
 #include "BKE_colortools.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
@@ -249,6 +250,41 @@ static void do_version_hue_sat_node(bNodeTree *ntree, bNode *node)
        node->storage = NULL;
 }
 
+static void do_versions_compositor_render_passes_storage(bNode *node)
+{
+       int pass_index = 0;
+       const char *sockname;
+       for (bNodeSocket *sock = node->outputs.first; sock && pass_index < 31; sock = sock->next, pass_index++) {
+               if (sock->storage == NULL) {
+                       NodeImageLayer *sockdata = MEM_callocN(sizeof(NodeImageLayer), "node image layer");
+                       sock->storage = sockdata;
+                       BLI_strncpy(sockdata->pass_name, node_cmp_rlayers_sock_to_pass(pass_index), sizeof(sockdata->pass_name));
+
+                       if (pass_index == 0) sockname = "Image";
+                       else if (pass_index == 1) sockname = "Alpha";
+                       else sockname = node_cmp_rlayers_sock_to_pass(pass_index);
+                       BLI_strncpy(sock->name, sockname, sizeof(sock->name));
+               }
+       }
+}
+
+static void do_versions_compositor_render_passes(bNodeTree *ntree)
+{
+       for (bNode *node = ntree->nodes.first; node; node = node->next) {
+               if (node->type == CMP_NODE_R_LAYERS) {
+                       /* First we make sure existing sockets have proper names.
+                        * This is important because otherwise verification will
+                        * drop links from sockets which were renamed.
+                        */
+                       do_versions_compositor_render_passes_storage(node);
+                       /* Make sure new sockets are properly created. */
+                       node_verify_socket_templates(ntree, node);
+                       /* Make sure all possibly created sockets have proper storage. */
+                       do_versions_compositor_render_passes_storage(node);
+               }
+       }
+}
+
 void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 {
        if (!MAIN_VERSION_ATLEAST(main, 270, 0)) {
@@ -1201,12 +1237,19 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 
                        SEQ_BEGIN (scene->ed, seq)
                        {
-                               if (seq->type == SEQ_TYPE_TEXT) {
-                                       TextVars *data = seq->effectdata;
-                                       if (data->color[3] == 0.0f) {
-                                               copy_v4_fl(data->color, 1.0f);
-                                               data->shadow_color[3] = 1.0f;
-                                       }
+                               if (seq->type != SEQ_TYPE_TEXT) {
+                                       continue;
+                               }
+
+                               if (seq->effectdata == NULL) {
+                                       struct SeqEffectHandle effect_handle = BKE_sequence_get_effect(seq);
+                                       effect_handle.init(seq);
+                               }
+
+                               TextVars *data = seq->effectdata;
+                               if (data->color[3] == 0.0f) {
+                                       copy_v4_fl(data->color, 1.0f);
+                                       data->shadow_color[3] = 1.0f;
                                }
                        }
                        SEQ_END
@@ -1610,46 +1653,73 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
                        }
                }
 
+               {
+                       Brush *br;
+                       br = (Brush *)BKE_libblock_find_name_ex(main, ID_BR, "Average");
+                       if (!br) {
+                               br = BKE_brush_add(main, "Average", OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT);
+                               br->vertexpaint_tool = PAINT_BLEND_AVERAGE;
+                               br->ob_mode = OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT;
+                       }
+
+                       br = (Brush *)BKE_libblock_find_name_ex(main, ID_BR, "Smear");
+                       if (!br) {
+                               br = BKE_brush_add(main, "Smear", OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT);
+                               br->vertexpaint_tool = PAINT_BLEND_SMEAR;
+                               br->ob_mode = OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT;
+                       }
+               }
+
                FOREACH_NODETREE(main, ntree, id) {
                        if (ntree->type == NTREE_COMPOSIT) {
-                               bNode *node;
-                               for (node = ntree->nodes.first; node; node = node->next) {
-                                       if (node->type == CMP_NODE_R_LAYERS) {
-                                               /* Make sure new sockets are properly created. */
-                                               node_verify_socket_templates(ntree, node);
-                                               int pass_index = 0;
-                                               const char *sockname;
-                                               for (bNodeSocket *sock = node->outputs.first; sock && pass_index < 31; sock = sock->next, pass_index++) {
-                                                       if (sock->storage == NULL) {
-                                                               NodeImageLayer *sockdata = MEM_callocN(sizeof(NodeImageLayer), "node image layer");
-                                                               sock->storage = sockdata;
-                                                               BLI_strncpy(sockdata->pass_name, node_cmp_rlayers_sock_to_pass(pass_index), sizeof(sockdata->pass_name));
-
-                                                               if (pass_index == 0) sockname = "Image";
-                                                               else if (pass_index == 1) sockname = "Alpha";
-                                                               else sockname = node_cmp_rlayers_sock_to_pass(pass_index);
-                                                               BLI_strncpy(sock->name, sockname, sizeof(sock->name));
-                                                       }
-                                               }
-                                       }
-                               }
+                               do_versions_compositor_render_passes(ntree);
                        }
                } FOREACH_NODETREE_END
        }
 
-       {
+       if (!MAIN_VERSION_ATLEAST(main, 279, 0)) {
                for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
                        if (scene->r.im_format.exr_codec == R_IMF_EXR_CODEC_DWAB) {
                                scene->r.im_format.exr_codec = R_IMF_EXR_CODEC_DWAA;
                        }
                }
+
+               /* Fix related to VGroup modifiers creating named defgroup CD layers! See T51520. */
+               for (Mesh *me = main->mesh.first; me; me = me->id.next) {
+                       CustomData_set_layer_name(&me->vdata, CD_MDEFORMVERT, 0, "");
+               }
+       }
+
+       {
+               /* Fix for invalid state of screen due to bug in older versions. */
+               for (bScreen *sc = main->screen.first; sc; sc = sc->id.next) {
+                       for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
+                               if(sa->full && sc->state == SCREENNORMAL) {
+                                       sa->full = NULL;
+                               }
+                       }
+               }
+
+               if (!DNA_struct_elem_find(fd->filesdna, "VPaint", "char", "falloff_shape")) {
+                       for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+                               ToolSettings *ts = scene->toolsettings;
+                               for (int i = 0; i < 2; i++) {
+                                       VPaint *vp = i ? ts->vpaint : ts->wpaint;
+                                       if (vp != NULL) {
+                                               /* remove all other flags */
+                                               vp->flag &= (VP_FLAG_SPRAY | VP_FLAG_VGROUP_RESTRICT);
+                                               vp->normal_angle = 80;
+                                       }
+                               }
+                       }
+               }
        }
 }
 
 void do_versions_after_linking_270(Main *main)
 {
        /* To be added to next subversion bump! */
-       {
+       if (!MAIN_VERSION_ATLEAST(main, 279, 0)) {
                FOREACH_NODETREE(main, ntree, id) {
                        if (ntree->type == NTREE_COMPOSIT) {
                                ntreeSetTypes(NULL, ntree);