Merge branch 'blender2.8' into tmp-static-override-insertion
authorBastien Montagne <montagne29@wanadoo.fr>
Thu, 3 May 2018 14:02:11 +0000 (16:02 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Thu, 3 May 2018 14:02:11 +0000 (16:02 +0200)
24 files changed:
release/scripts/startup/bl_ui/space_view3d.py
source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
source/blender/draw/CMakeLists.txt
source/blender/draw/DRW_engine.h
source/blender/draw/engines/workbench/workbench_engine.c
source/blender/draw/engines/workbench/workbench_materials.c
source/blender/draw/engines/workbench/workbench_private.h
source/blender/draw/engines/workbench/workbench_studiolight.c [new file with mode: 0644]
source/blender/draw/intern/draw_armature.c
source/blender/draw/intern/draw_common.c
source/blender/draw/modes/shaders/object_mball_handles_vert.glsl [moved from source/blender/gpu/shaders/gpu_shader_instance_mball_handles_vert.glsl with 95% similarity]
source/blender/editors/armature/armature_select.c
source/blender/editors/armature/pose_select.c
source/blender/editors/include/UI_icons.h
source/blender/editors/interface/CMakeLists.txt
source/blender/editors/interface/interface_icons.c
source/blender/editors/render/render_preview.c
source/blender/gpu/CMakeLists.txt
source/blender/gpu/GPU_shader.h
source/blender/gpu/intern/gpu_shader.c
source/blender/makesdna/DNA_view3d_types.h
source/blender/makesrna/intern/rna_constraint.c
source/blender/makesrna/intern/rna_space.c
source/blender/modifiers/intern/MOD_solidify.c

index 077af19da8cf16b408b2be0833756e57ed964143..5b06f512abeae2092c2ab4e25931182483d105a1 100644 (file)
@@ -3545,38 +3545,17 @@ class VIEW3D_PT_shading(Panel):
         col.prop(shading, "type", expand=True)
 
         if shading.type == 'SOLID':
+            col.separator()
+            col.row().prop(shading, "single_color_mode", expand=True)
+
             col.separator()
             col.row().prop(shading, "light", expand=True)
+            if shading.light == 'STUDIO':
+                col.row().template_icon_view(shading, "studiolight")
 
             col.separator()
-            col.row().prop(shading, "single_color_mode", expand=True)
             col.prop(shading, "show_object_overlap")
 
-            if shading.light == 'STUDIO':
-                # TODO: don't store these settings in the scene
-                scene = context.scene
-                props = scene.layer_properties['BLENDER_WORKBENCH']
-
-                col.separator()
-
-                sub = col.column()
-                sub.label(text="Left/Right:")
-                row = sub.row(align=True)
-                row.prop(props, "diffuse_light_x_neg", text="")
-                row.prop(props, "diffuse_light_x_pos", text="")
-
-                sub = col.column()
-                sub.label(text="Up/Down:")
-                row = sub.row(align=True)
-                row.prop(props, "diffuse_light_y_neg", text="")
-                row.prop(props, "diffuse_light_y_pos", text="")
-
-                sub = col.column()
-                sub.label(text="Front/Back:")
-                row = sub.row(align=True)
-                row.prop(props, "diffuse_light_z_neg", text="")
-                row.prop(props, "diffuse_light_z_pos", text="")
-
 
 class VIEW3D_PT_overlay(Panel):
     bl_space_type = 'VIEW_3D'
index 2c6186a4fe51be0d59dfa349b5202e9a5c83f436..99c24506a7b1488dff8940f9860cff5b55f2c9d2 100644 (file)
@@ -547,7 +547,7 @@ ID *deg_expand_copy_on_write_datablock(const Depsgraph *depsgraph,
         */
        deg_tag_copy_on_write_id(id_cow, id_orig);
        /* Perform remapping of the nodes. */
-       RemapCallbackUserData user_data;
+       RemapCallbackUserData user_data = {NULL};
        user_data.depsgraph = depsgraph;
        user_data.node_builder = node_builder;
        user_data.create_placeholders = create_placeholders;
@@ -586,6 +586,13 @@ static void deg_update_copy_on_write_animation(const Depsgraph *depsgraph,
                             id_node->id_orig->name,
                             id_node->id_cow);
        BKE_animdata_copy_id(NULL, id_node->id_cow, id_node->id_orig, false, false);
+       RemapCallbackUserData user_data = {NULL};
+       user_data.depsgraph = depsgraph;
+       BKE_library_foreach_ID_link(NULL,
+                                   id_node->id_cow,
+                                   foreach_libblock_remap_callback,
+                                   (void *)&user_data,
+                                   IDWALK_NOP);
 }
 
 ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
index 0db397433e5fb592e5d7d492f21ad8d74c3ef27d..e3b6e6fb1f9777122192f67632c5d72f7224df31 100644 (file)
@@ -107,6 +107,7 @@ set(SRC
        engines/eevee/eevee_volumes.c
        engines/workbench/workbench_engine.c
        engines/workbench/workbench_materials.c
+       engines/workbench/workbench_studiolight.c
        engines/workbench/solid_mode.c
        engines/external/external_engine.c
 
@@ -257,6 +258,7 @@ data_to_c_simple(modes/shaders/object_outline_prepass_frag.glsl SRC)
 data_to_c_simple(modes/shaders/object_grid_frag.glsl SRC)
 data_to_c_simple(modes/shaders/object_grid_vert.glsl SRC)
 data_to_c_simple(modes/shaders/object_lightprobe_grid_vert.glsl SRC)
+data_to_c_simple(modes/shaders/object_mball_handles_vert.glsl SRC)
 data_to_c_simple(modes/shaders/object_particle_prim_vert.glsl SRC)
 data_to_c_simple(modes/shaders/object_particle_dot_vert.glsl SRC)
 data_to_c_simple(modes/shaders/object_particle_dot_frag.glsl SRC)
index e300bcad8bf8723db0718e53a556d97c78295e29..22dc116d4a67c3ac60cc3accb73b1a1d94004e0e 100644 (file)
@@ -142,4 +142,5 @@ void DRW_opengl_context_disable(void);
 
 void DRW_deferred_shader_remove(struct GPUMaterial *mat);
 
+unsigned int *WORKBENCH_generate_studiolight_preview(int studiolight_id, int icon_size);
 #endif /* __DRW_ENGINE_H__ */
index d4d14125116aff657817fa4ba221662bbc49eb42..f758918d577081345d7f61ba70a11e8756f06dac 100644 (file)
@@ -58,20 +58,7 @@ static void workbench_view_layer_settings_create(RenderEngine *UNUSED(engine), I
        BLI_assert(props &&
                   props->type == IDP_GROUP &&
                   props->subtype == IDP_GROUP_SUB_ENGINE_RENDER);
-
-       const float diffuse_x_pos[3] = {1.0,  0.8,   0.6};
-       const float diffuse_x_neg[3] = {1.0,  0.6,   0.6};
-       const float diffuse_y_pos[3] = {0.9,  0.9,   1.0};
-       const float diffuse_y_neg[3] = {0.05, 0.025, 0.025};
-       const float diffuse_z_pos[3] = {0.8,  0.8,   0.75};
-       const float diffuse_z_neg[3] = {1.0,  0.95,  0.8};
-
-       BKE_collection_engine_property_add_float_array(props, "diffuse_light_x_pos", diffuse_x_pos, 3);
-       BKE_collection_engine_property_add_float_array(props, "diffuse_light_x_neg", diffuse_x_neg, 3);
-       BKE_collection_engine_property_add_float_array(props, "diffuse_light_y_pos", diffuse_y_pos, 3);
-       BKE_collection_engine_property_add_float_array(props, "diffuse_light_y_neg", diffuse_y_neg, 3);
-       BKE_collection_engine_property_add_float_array(props, "diffuse_light_z_pos", diffuse_z_pos, 3);
-       BKE_collection_engine_property_add_float_array(props, "diffuse_light_z_neg", diffuse_z_neg, 3);
+       UNUSED_VARS_NDEBUG(props);
 }
 
 /* Note: currently unused, we may want to register so we can see this when debugging the view. */
index b095890f8733457925c409f711eae35bec961fa8..69d983b96c7f8c80a630647e349e35e083d1d8c9 100644 (file)
@@ -257,10 +257,6 @@ void workbench_materials_cache_init(WORKBENCH_Data *vedata)
        WORKBENCH_PrivateData *wpd = stl->g_data;
        DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
        DRWShadingGroup *grp;
-       const DRWContextState *draw_ctx = DRW_context_state_get();
-       ViewLayer *view_layer = draw_ctx->view_layer;
-       IDProperty *props = BKE_view_layer_engine_evaluated_get(view_layer, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_WORKBENCH);
-
        const DRWContextState *DCS = DRW_context_state_get();
 
        wpd->material_hash = BLI_ghash_ptr_new(__func__);
@@ -269,10 +265,12 @@ void workbench_materials_cache_init(WORKBENCH_Data *vedata)
        if (v3d) {
                wpd->drawtype_lighting = v3d->drawtype_lighting;
                wpd->drawtype_options = v3d->drawtype_options;
+               wpd->drawtype_studiolight = v3d->drawtype_studiolight;
        }
        else {
                wpd->drawtype_lighting = V3D_LIGHTING_STUDIO;
                wpd->drawtype_options = 0;
+               wpd->drawtype_studiolight = 0;
        }
 
        select_deferred_shaders(wpd);
@@ -281,12 +279,7 @@ void workbench_materials_cache_init(WORKBENCH_Data *vedata)
                WORKBENCH_UBO_World *wd = &wpd->world_data;
                UI_GetThemeColor3fv(UI_GetThemeValue(TH_SHOW_BACK_GRAD) ? TH_LOW_GRAD:TH_HIGH_GRAD, wd->background_color_low);
                UI_GetThemeColor3fv(TH_HIGH_GRAD, wd->background_color_high);
-               copy_v3_v3(wd->diffuse_light_x_pos, BKE_collection_engine_property_value_get_float_array(props, "diffuse_light_x_pos"));
-               copy_v3_v3(wd->diffuse_light_x_neg, BKE_collection_engine_property_value_get_float_array(props, "diffuse_light_x_neg"));
-               copy_v3_v3(wd->diffuse_light_y_pos, BKE_collection_engine_property_value_get_float_array(props, "diffuse_light_y_pos"));
-               copy_v3_v3(wd->diffuse_light_y_neg, BKE_collection_engine_property_value_get_float_array(props, "diffuse_light_y_neg"));
-               copy_v3_v3(wd->diffuse_light_z_pos, BKE_collection_engine_property_value_get_float_array(props, "diffuse_light_z_pos"));
-               copy_v3_v3(wd->diffuse_light_z_neg, BKE_collection_engine_property_value_get_float_array(props, "diffuse_light_z_neg"));
+               studiolight_update_world(wpd->drawtype_studiolight, wd);
 
                psl->composite_pass = DRW_pass_create("Composite", DRW_STATE_WRITE_COLOR);
                grp = DRW_shgroup_create(wpd->composite_sh, psl->composite_pass);
index d94cce6e88043519ab20f52c9daf181b92098037..1f66fb31095547e7417cb62656c51ad3d6257501 100644 (file)
@@ -73,6 +73,7 @@ typedef struct WORKBENCH_PrivateData {
        struct GPUShader *composite_sh;
        short drawtype_lighting;
        short drawtype_options;
+       short drawtype_studiolight;
        struct GPUUniformBuffer *world_ubo;
        WORKBENCH_UBO_World world_data;
 } WORKBENCH_PrivateData; /* Transient data */
@@ -113,4 +114,7 @@ void workbench_materials_cache_init(WORKBENCH_Data *vedata);
 void workbench_materials_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob);
 void workbench_materials_cache_finish(WORKBENCH_Data *vedata);
 
+/* workbench_studiolight.c */
+void studiolight_update_world(int studio_light, WORKBENCH_UBO_World* wd);
+
 #endif
diff --git a/source/blender/draw/engines/workbench/workbench_studiolight.c b/source/blender/draw/engines/workbench/workbench_studiolight.c
new file mode 100644 (file)
index 0000000..f93a734
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2016, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Blender Institute
+ *
+ */
+
+/** \file workbench_studiolight.h
+ *  \ingroup draw_engine
+ */
+ #include "DRW_engine.h"
+#include "workbench_private.h"
+
+#include "BLI_math.h"
+
+
+#define STUDIOLIGHT_X_POS 0
+#define STUDIOLIGHT_X_NEG 1
+#define STUDIOLIGHT_Y_POS 2
+#define STUDIOLIGHT_Y_NEG 3
+#define STUDIOLIGHT_Z_POS 4
+#define STUDIOLIGHT_Z_NEG 5
+
+const float studiolights[][6][3] = {
+       {
+               {1.0,  0.8,   0.6}, 
+               {1.0,  0.6,   0.6},
+               {0.9,  0.9,   1.0},
+               {0.05, 0.025, 0.025},
+               {0.8,  0.8,   0.75},
+               {1.0,  0.95,  0.8},
+       },
+       {
+               {0.0, 0.0, 0.0}, 
+               {0.0, 0.0, 0.0}, 
+               {0.0, 0.0, 0.0}, 
+               {0.0, 0.0, 0.0}, 
+               {0.8, 0.8, 1.0}, 
+               {0.0, 0.0, 0.0}, 
+       },
+       {
+               {0.4, 0.3, 0.8}, 
+               {0.4, 0.3, 0.8}, 
+               {0.8, 0.8, 0.2}, 
+               {0.0, 0.0, 0.0}, 
+               {0.4, 0.4, 0.8}, 
+               {0.0, 0.0, 0.0}, 
+       },
+       {
+               {0.2, 0.2, 0.0}, 
+               {0.8, 0.2, 0.0}, 
+               {0.8, 0.2, 0.0}, 
+               {0.2, 0.2, 0.0}, 
+               {0.8, 0.6, 0.4}, 
+               {0.0, 0.0, 0.0}, 
+       },
+       {
+               {0.8, 0.2, 0.0}, 
+               {0.8, 0.2, 0.0}, 
+               {0.8, 0.6, 0.0}, 
+               {0.2, 0.2, 0.0}, 
+               {1.0, 0.5, 0.0}, 
+               {0.0, 0.0, 0.0}, 
+       },
+};
+
+void studiolight_update_world(int studio_light, WORKBENCH_UBO_World* wd) {
+       copy_v3_v3(wd->diffuse_light_x_pos, studiolights[studio_light][STUDIOLIGHT_X_POS]);
+       copy_v3_v3(wd->diffuse_light_x_neg, studiolights[studio_light][STUDIOLIGHT_X_NEG]);
+       copy_v3_v3(wd->diffuse_light_y_pos, studiolights[studio_light][STUDIOLIGHT_Y_POS]);
+       copy_v3_v3(wd->diffuse_light_y_neg, studiolights[studio_light][STUDIOLIGHT_Y_NEG]);
+       copy_v3_v3(wd->diffuse_light_z_pos, studiolights[studio_light][STUDIOLIGHT_Z_POS]);
+       copy_v3_v3(wd->diffuse_light_z_neg, studiolights[studio_light][STUDIOLIGHT_Z_NEG]);
+}
+
+unsigned int *WORKBENCH_generate_studiolight_preview(int studiolight_id, int icon_size) {
+       unsigned int* rect = MEM_mallocN(icon_size * icon_size * sizeof(unsigned int), __func__);
+       int icon_center = icon_size / 2;
+       float sphere_radius = icon_center * 0.9;
+       
+       int offset = 0;
+       for (int y = 0 ; y < icon_size ; y ++) {
+               float dy = y - icon_center;
+               for (int x = 0 ; x < icon_size ; x ++) {
+                       float dx = x - icon_center;
+                       /* calculate aliasing */
+                       float alias = 0;
+                       const float alias_step = 0.2;
+                       for (float ay = dy - 0.5; ay < dy + 0.5 ; ay += alias_step) {
+                               for (float ax = dx - 0.5; ax < dx + 0.5 ; ax += alias_step) {
+                                       if (sqrt(ay*ay + ax*ax) < sphere_radius) {
+                                               alias += alias_step*alias_step;
+                                       }
+                               }
+                       }
+                       unsigned int pixelresult = 0x0;
+                       unsigned int alias_i = clamp_i(alias * 256, 0, 255);
+                       if (alias_i != 0) {
+                               /* calculate normal */
+                               unsigned int alias_mask = alias_i << 24;
+                               float normal[3];
+                               normal[0] = dx / sphere_radius;
+                               normal[1] = dy / sphere_radius;
+                               normal[2] = sqrt(-(normal[0]*normal[0])-(normal[1]*normal[1]) + 1);
+                               normalize_v3(normal);
+
+                               float color[3];
+                               mul_v3_v3fl(color, studiolights[studiolight_id][STUDIOLIGHT_X_POS], clamp_f(normal[0], 0.0, 1.0));
+                               interp_v3_v3v3(color, color, studiolights[studiolight_id][STUDIOLIGHT_X_NEG], clamp_f(-normal[0], 0.0, 1.0));
+                               interp_v3_v3v3(color, color, studiolights[studiolight_id][STUDIOLIGHT_Y_POS], clamp_f(normal[1], 0.0, 1.0));
+                               interp_v3_v3v3(color, color, studiolights[studiolight_id][STUDIOLIGHT_Y_NEG], clamp_f(-normal[1], 0.0, 1.0));
+                               interp_v3_v3v3(color, color, studiolights[studiolight_id][STUDIOLIGHT_Z_POS], clamp_f(normal[2], 0.0, 1.0));
+
+                               pixelresult = rgb_to_cpack(
+                                       linearrgb_to_srgb(color[0]),
+                                       linearrgb_to_srgb(color[1]),
+                                       linearrgb_to_srgb(color[2])
+                               ) | alias_mask;
+                       }
+                       rect[offset++] = pixelresult;
+               }
+       }
+       return rect;
+}
\ No newline at end of file
index 3b61d21849ea7f771e7e6eb68d2e2b51f02b7c71..7b29b213beca073c7efb52f078d657eb49d49ba6 100644 (file)
@@ -1195,7 +1195,8 @@ static void draw_bone_envelope(
                rad_head = (pchan->parent && (boneflag & BONE_CONNECTED)) ? &pchan->parent->bone->rad_tail : &pchan->bone->rad_head;
        }
 
-       if ((boneflag & BONE_NO_DEFORM) == 0 &&
+       if ((select_id == -1) &&
+           (boneflag & BONE_NO_DEFORM) == 0 &&
            ((boneflag & BONE_SELECTED) || (eBone && (boneflag & (BONE_ROOTSEL | BONE_TIPSEL)))))
        {
                drw_shgroup_bone_envelope_distance(BONE_VAR(eBone, pchan, disp_mat), col_white, rad_head, rad_tail, distance);
index eaccd1b68b6fbf3785e209f41a569a8602c110dd..3acc851cd0124b793564e5ca576850f322c0bfb4 100644 (file)
@@ -166,6 +166,8 @@ extern char datatoc_armature_shape_outline_vert_glsl[];
 extern char datatoc_armature_shape_outline_geom_glsl[];
 extern char datatoc_gpu_shader_flat_color_frag_glsl[];
 
+extern char datatoc_object_mball_handles_vert_glsl[];
+
 static struct {
        struct GPUShader *shape_outline;
        struct GPUShader *bone_envelope;
@@ -173,7 +175,9 @@ static struct {
        struct GPUShader *bone_envelope_outline;
        struct GPUShader *bone_sphere;
        struct GPUShader *bone_sphere_outline;
-} g_armature_shaders = {NULL};
+
+       struct GPUShader *mball_handles;
+} g_shaders = {NULL};
 
 static struct {
        struct Gwn_VertFormat *instance_screenspace;
@@ -197,8 +201,8 @@ void DRW_globals_free(void)
                MEM_SAFE_FREE(*format);
        }
 
-       struct GPUShader **shader = &g_armature_shaders.shape_outline;
-       for (int i = 0; i < sizeof(g_armature_shaders) / sizeof(void *); ++i, ++shader) {
+       struct GPUShader **shader = &g_shaders.shape_outline;
+       for (int i = 0; i < sizeof(g_shaders) / sizeof(void *); ++i, ++shader) {
                DRW_SHADER_FREE_SAFE(*shader);
        }
 }
@@ -428,8 +432,8 @@ DRWShadingGroup *shgroup_spot_instance(DRWPass *pass, struct Gwn_Batch *geom)
 
 DRWShadingGroup *shgroup_instance_bone_envelope_outline(DRWPass *pass)
 {
-       if (g_armature_shaders.bone_envelope_outline == NULL) {
-               g_armature_shaders.bone_envelope_outline = DRW_shader_create(
+       if (g_shaders.bone_envelope_outline == NULL) {
+               g_shaders.bone_envelope_outline = DRW_shader_create(
                            datatoc_armature_envelope_outline_vert_glsl, NULL,
                            datatoc_gpu_shader_flat_color_frag_glsl, NULL);
        }
@@ -441,7 +445,7 @@ DRWShadingGroup *shgroup_instance_bone_envelope_outline(DRWPass *pass)
                {"xAxis"               , DRW_ATTRIB_FLOAT, 3}
        });
 
-       DRWShadingGroup *grp = DRW_shgroup_instance_create(g_armature_shaders.bone_envelope_outline,
+       DRWShadingGroup *grp = DRW_shgroup_instance_create(g_shaders.bone_envelope_outline,
                                                           pass, DRW_cache_bone_envelope_outline_get(),
                                                           g_formats.instance_bone_envelope);
        DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
@@ -451,8 +455,8 @@ DRWShadingGroup *shgroup_instance_bone_envelope_outline(DRWPass *pass)
 
 DRWShadingGroup *shgroup_instance_bone_envelope_distance(DRWPass *pass)
 {
-       if (g_armature_shaders.bone_envelope_distance == NULL) {
-               g_armature_shaders.bone_envelope_distance = DRW_shader_create(
+       if (g_shaders.bone_envelope_distance == NULL) {
+               g_shaders.bone_envelope_distance = DRW_shader_create(
                            datatoc_armature_envelope_vert_glsl, NULL,
                            datatoc_armature_envelope_frag_glsl, NULL);
        }
@@ -464,7 +468,7 @@ DRWShadingGroup *shgroup_instance_bone_envelope_distance(DRWPass *pass)
                {"xAxis"               , DRW_ATTRIB_FLOAT, 3}
        });
 
-       DRWShadingGroup *grp = DRW_shgroup_instance_create(g_armature_shaders.bone_envelope_distance,
+       DRWShadingGroup *grp = DRW_shgroup_instance_create(g_shaders.bone_envelope_distance,
                                                           pass, DRW_cache_bone_envelope_solid_get(),
                                                           g_formats.instance_bone_envelope);
 
@@ -473,8 +477,8 @@ DRWShadingGroup *shgroup_instance_bone_envelope_distance(DRWPass *pass)
 
 DRWShadingGroup *shgroup_instance_bone_envelope_solid(DRWPass *pass)
 {
-       if (g_armature_shaders.bone_envelope == NULL) {
-               g_armature_shaders.bone_envelope = DRW_shader_create(
+       if (g_shaders.bone_envelope == NULL) {
+               g_shaders.bone_envelope = DRW_shader_create(
                            datatoc_armature_envelope_vert_glsl, NULL,
                            datatoc_armature_envelope_frag_glsl, "#define SMOOTH_ENVELOPE\n");
        }
@@ -486,7 +490,7 @@ DRWShadingGroup *shgroup_instance_bone_envelope_solid(DRWPass *pass)
                {"xAxis"               , DRW_ATTRIB_FLOAT, 3}
        });
 
-       DRWShadingGroup *grp = DRW_shgroup_instance_create(g_armature_shaders.bone_envelope,
+       DRWShadingGroup *grp = DRW_shgroup_instance_create(g_shaders.bone_envelope,
                                                           pass, DRW_cache_bone_envelope_solid_get(),
                                                           g_formats.instance_bone_envelope);
 
@@ -495,7 +499,11 @@ DRWShadingGroup *shgroup_instance_bone_envelope_solid(DRWPass *pass)
 
 DRWShadingGroup *shgroup_instance_mball_handles(DRWPass *pass)
 {
-       GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_MBALL_HANDLES);
+       if (g_shaders.mball_handles == NULL) {
+               g_shaders.mball_handles = DRW_shader_create(
+                           datatoc_object_mball_handles_vert_glsl, NULL,
+                           datatoc_gpu_shader_flat_color_frag_glsl, NULL);
+       }
 
        DRW_shgroup_instance_format(g_formats.instance_mball_handles, {
                {"ScaleTranslationMatrix" , DRW_ATTRIB_FLOAT, 12},
@@ -503,7 +511,8 @@ DRWShadingGroup *shgroup_instance_mball_handles(DRWPass *pass)
                {"color"                  , DRW_ATTRIB_FLOAT, 3}
        });
 
-       DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, DRW_cache_screenspace_circle_get(),
+       DRWShadingGroup *grp = DRW_shgroup_instance_create(g_shaders.mball_handles, pass,
+                                                          DRW_cache_screenspace_circle_get(),
                                                           g_formats.instance_mball_handles);
        DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2);
 
@@ -513,8 +522,8 @@ DRWShadingGroup *shgroup_instance_mball_handles(DRWPass *pass)
 /* Only works with batches with adjacency infos. */
 DRWShadingGroup *shgroup_instance_bone_shape_outline(DRWPass *pass, struct Gwn_Batch *geom)
 {
-       if (g_armature_shaders.shape_outline == NULL) {
-               g_armature_shaders.shape_outline = DRW_shader_create(
+       if (g_shaders.shape_outline == NULL) {
+               g_shaders.shape_outline = DRW_shader_create(
                            datatoc_armature_shape_outline_vert_glsl,
                            datatoc_armature_shape_outline_geom_glsl,
                            datatoc_gpu_shader_flat_color_frag_glsl,
@@ -527,7 +536,7 @@ DRWShadingGroup *shgroup_instance_bone_shape_outline(DRWPass *pass, struct Gwn_B
                {"color"              , DRW_ATTRIB_FLOAT, 4}
        });
 
-       DRWShadingGroup *grp = DRW_shgroup_instance_create(g_armature_shaders.shape_outline,
+       DRWShadingGroup *grp = DRW_shgroup_instance_create(g_shaders.shape_outline,
                                                           pass, geom, g_formats.instance_color);
        DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
 
@@ -536,8 +545,8 @@ DRWShadingGroup *shgroup_instance_bone_shape_outline(DRWPass *pass, struct Gwn_B
 
 DRWShadingGroup *shgroup_instance_bone_sphere(DRWPass *pass)
 {
-       if (g_armature_shaders.bone_sphere == NULL) {
-               g_armature_shaders.bone_sphere = DRW_shader_create(
+       if (g_shaders.bone_sphere == NULL) {
+               g_shaders.bone_sphere = DRW_shader_create(
                            datatoc_armature_sphere_vert_glsl, NULL,
                            datatoc_armature_sphere_frag_glsl, NULL);
        }
@@ -548,7 +557,7 @@ DRWShadingGroup *shgroup_instance_bone_sphere(DRWPass *pass)
                {"color"              , DRW_ATTRIB_FLOAT, 4}
        });
 
-       DRWShadingGroup *grp = DRW_shgroup_instance_create(g_armature_shaders.bone_sphere,
+       DRWShadingGroup *grp = DRW_shgroup_instance_create(g_shaders.bone_sphere,
                                                           pass, DRW_cache_bone_point_get(), g_formats.instance_color);
 
        return grp;
@@ -556,8 +565,8 @@ DRWShadingGroup *shgroup_instance_bone_sphere(DRWPass *pass)
 
 DRWShadingGroup *shgroup_instance_bone_sphere_outline(DRWPass *pass)
 {
-       if (g_armature_shaders.bone_sphere_outline == NULL) {
-               g_armature_shaders.bone_sphere_outline = DRW_shader_create(
+       if (g_shaders.bone_sphere_outline == NULL) {
+               g_shaders.bone_sphere_outline = DRW_shader_create(
                            datatoc_armature_sphere_outline_vert_glsl, NULL,
                            datatoc_gpu_shader_flat_color_frag_glsl, NULL);
        }
@@ -568,7 +577,7 @@ DRWShadingGroup *shgroup_instance_bone_sphere_outline(DRWPass *pass)
                {"color"              , DRW_ATTRIB_FLOAT, 4}
        });
 
-       DRWShadingGroup *grp = DRW_shgroup_instance_create(g_armature_shaders.bone_sphere_outline,
+       DRWShadingGroup *grp = DRW_shgroup_instance_create(g_shaders.bone_sphere_outline,
                                                           pass, DRW_cache_bone_point_wire_outline_get(),
                                                           g_formats.instance_color);
        DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
similarity index 95%
rename from source/blender/gpu/shaders/gpu_shader_instance_mball_handles_vert.glsl
rename to source/blender/draw/modes/shaders/object_mball_handles_vert.glsl
index 819199c26c772cbe7e0d9a35f1b52e02836b496f..baa3ecb804c0d1d5e4e8aea303e67c2bef2c4b9f 100644 (file)
@@ -4,8 +4,6 @@
  * Note that if the stiffness is zero, it assumes the scale is directly multiplied by the radius */
 
 
- #define M_PI_2     1.570796f   // pi/2
-
 uniform mat4 ViewProjectionMatrix;
 uniform vec3 screen_vecs[2];
 
index af0483cf1dc9e0273eb879f461c714062f1c9a32..65f845ce34c5e8814639ed1c622c4f239c4ae421 100644 (file)
@@ -493,6 +493,8 @@ cache_end:
                                        Base *base = NULL;
                                        EditBone *ebone;
                                        base = ED_armature_base_and_ebone_from_select_buffer(bases, bases_len, hitresult, &ebone);
+                                       /* If this fails, selection code is setting the selection ID's incorrectly. */
+                                       BLI_assert(base && ebone);
 
                                        int dep;
                                        /* clicks on bone points get advantage */
index c1c5afaca548f5cd658088d68d739013d6170388..9087a8879d6ed9e1e5c162560e0bce7ebaed549c 100644 (file)
@@ -129,6 +129,9 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select)
                
                /* send necessary notifiers */
                WM_main_add_notifier(NC_GEOM | ND_DATA, ob);
+               
+               /* tag armature for copy-on-write update (since act_bone is in armature not object) */
+               DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
        }
 }
 
@@ -220,6 +223,9 @@ bool ED_armature_pose_select_pick_with_buffer(
                                 */
                                DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
                        }
+                       
+                       /* tag armature for copy-on-write update (since act_bone is in armature not object) */
+                       DEG_id_tag_update(&arm->id, DEG_TAG_COPY_ON_WRITE);
                }
        }
        
index 923038a749056c875154d24608ec8d4d2a91688a..a87f23c42a85f825dba79dfdf4e5dc858791cdaf 100644 (file)
@@ -1032,3 +1032,9 @@ DEF_VICO(COLORSET_18_VEC)
 DEF_VICO(COLORSET_19_VEC)
 DEF_VICO(COLORSET_20_VEC)
 
+       /* Studio lighting presets */
+DEF_ICON(STUDIOLIGHT_01)
+DEF_ICON(STUDIOLIGHT_02)
+DEF_ICON(STUDIOLIGHT_03)
+DEF_ICON(STUDIOLIGHT_04)
+DEF_ICON(STUDIOLIGHT_05)
index cc5c580ad386f8f3463ee2e9f669278eeef2acda..49fe6bfb2dc2d75d701d07e0cba626a256f9755b 100644 (file)
@@ -25,6 +25,7 @@ set(INC
        ../../blenlib
        ../../blentranslation
        ../../depsgraph
+       ../../draw
        ../../gpu
        ../../imbuf
        ../../makesdna
index 9815d58764c1b4a7acd64bab1e36d6e679801f5e..12b549e8f8b34b960825e0f1651dee3c61347870 100644 (file)
@@ -67,6 +67,8 @@
 
 #include "DEG_depsgraph.h"
 
+#include "DRW_engine.h"
+
 #include "ED_datafiles.h"
 #include "ED_keyframes_draw.h"
 #include "ED_render.h"
@@ -491,6 +493,23 @@ static void init_matcap_icons(void)
 
 }
 
+static void init_studio_light_icons(void)
+{
+       /* dynamic allocation now, tucking datatoc pointers in DrawInfo */
+#define INIT_STUDIOLIGHT_ICON(icon_id, studiolight_id)                                         \
+       {                                                                                          \
+               DrawInfo *di;                                                                          \
+               di = def_internal_icon(NULL, icon_id, 0, 0, 96, ICON_TYPE_BUFFER);                     \
+               di->data.buffer.image->rect = WORKBENCH_generate_studiolight_preview(studiolight_id, 96); \
+       } (void)0
+
+       INIT_STUDIOLIGHT_ICON(ICON_STUDIOLIGHT_01, 0);
+       INIT_STUDIOLIGHT_ICON(ICON_STUDIOLIGHT_02, 1);
+       INIT_STUDIOLIGHT_ICON(ICON_STUDIOLIGHT_03, 2);
+       INIT_STUDIOLIGHT_ICON(ICON_STUDIOLIGHT_04, 3);
+       INIT_STUDIOLIGHT_ICON(ICON_STUDIOLIGHT_05, 4);
+
+}
 static void init_internal_icons(void)
 {
 //     bTheme *btheme = UI_GetTheme();
@@ -837,6 +856,7 @@ void UI_icons_init(int first_dyn_id)
        init_internal_icons();
        init_brush_icons();
        init_matcap_icons();
+       init_studio_light_icons();
 #endif
 }
 
index 4afcc5f661e65d18ff444be8e8405f1ae0905fa7..d03909851813a49f69417d700c37521ee3de551a 100644 (file)
@@ -80,6 +80,7 @@
 #include "BKE_world.h"
 
 #include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
 #include "DEG_depsgraph_build.h"
 
 #include "IMB_imbuf.h"
@@ -155,6 +156,7 @@ typedef struct ShaderPreview {
        short *stop, *do_update;
        
        Scene *scene;
+       Depsgraph *depsgraph;
        ID *id;
        ID *parent;
        MTex *slot;
@@ -184,6 +186,7 @@ typedef struct IconPreviewSize {
 typedef struct IconPreview {
        Main *bmain;
        Scene *scene;
+       Depsgraph *depsgraph;
        void *owner;
        ID *id;
        ListBase sizes;
@@ -679,6 +682,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
        char name[32];
        int sizex;
        Main *pr_main = sp->pr_main;
+       ID *id_eval = DEG_get_evaluated_id(sp->depsgraph, id);
        
        /* in case of split preview, use border render */
        if (split) {
@@ -698,7 +702,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
        }
        
        /* get the stuff from the builtin preview dbase */
-       sce = preview_prepare_scene(sp->bmain, sp->scene, id, idtype, sp);
+       sce = preview_prepare_scene(sp->bmain, sp->scene, id_eval, idtype, sp);
        if (sce == NULL) return;
        
        if (!split || first) sprintf(name, "Preview %p", sp->owner);
@@ -1060,6 +1064,7 @@ static void icon_preview_startjob_all_sizes(void *customdata, short *stop, short
 
                /* construct shader preview from image size and previewcustomdata */
                sp->scene = ip->scene;
+               sp->depsgraph = ip->depsgraph;
                sp->owner = ip->owner;
                sp->sizex = cur_size->sizex;
                sp->sizey = cur_size->sizey;
@@ -1172,6 +1177,7 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r
        /* customdata for preview thread */
        ip->bmain = CTX_data_main(C);
        ip->scene = CTX_data_scene(C);
+       ip->depsgraph = CTX_data_depsgraph(C);
        ip->owner = owner;
        ip->id = id;
 
@@ -1216,6 +1222,7 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M
 
        /* customdata for preview thread */
        sp->scene = scene;
+       sp->depsgraph = CTX_data_depsgraph(C);
        sp->owner = owner;
        sp->sizex = sizex;
        sp->sizey = sizey;
index 7634bd74978114aa08c1977b8cff4ef4dd332a6a..481133ba98424977cf7a5753e36f4b2575a25783 100644 (file)
@@ -181,7 +181,6 @@ data_to_c_simple(shaders/gpu_shader_instance_camera_vert.glsl SRC)
 data_to_c_simple(shaders/gpu_shader_instance_distance_line_vert.glsl SRC)
 data_to_c_simple(shaders/gpu_shader_instance_edges_variying_color_geom.glsl SRC)
 data_to_c_simple(shaders/gpu_shader_instance_edges_variying_color_vert.glsl SRC)
-data_to_c_simple(shaders/gpu_shader_instance_mball_handles_vert.glsl SRC)
 
 data_to_c_simple(shaders/gpu_shader_3D_groundline_geom.glsl SRC)
 data_to_c_simple(shaders/gpu_shader_3D_groundpoint_vert.glsl SRC)
index b395b320580386a4aa1b264bce250d74f918ff97..2a672873d865915a1fb01dc610eca4151527cd4d 100644 (file)
@@ -185,8 +185,6 @@ typedef enum GPUBuiltinShader {
        GPU_SHADER_2D_NODELINK,
        GPU_SHADER_2D_NODELINK_INST,
 
-       GPU_SHADER_3D_INSTANCE_MBALL_HANDLES,
-
        GPU_NUM_BUILTIN_SHADERS /* (not an actual shader) */
 } GPUBuiltinShader;
 
index 34b710b649e8592772672ea9bca038e4c523c0c4..02baa2e58cb9e10c81d623ca19083256febcd1fe 100644 (file)
@@ -819,9 +819,6 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
                                             datatoc_gpu_shader_2D_nodelink_frag_glsl },
                [GPU_SHADER_2D_NODELINK_INST] = { datatoc_gpu_shader_2D_nodelink_vert_glsl,
                                                  datatoc_gpu_shader_2D_nodelink_frag_glsl },
-
-               [GPU_SHADER_3D_INSTANCE_MBALL_HANDLES] = { datatoc_gpu_shader_instance_mball_handles_vert_glsl,
-                                                          datatoc_gpu_shader_flat_color_frag_glsl },
        };
 
        if (builtin_shaders[shader] == NULL) {
index 545acf667b6edff954714712c72045da93b98eb0..dd2933b04ee498a9e533bd737dbf5eb106809078 100644 (file)
@@ -258,7 +258,7 @@ typedef struct View3D {
        /* drawtype options (lighting, random) used for drawtype == OB_SOLID */
        short drawtype_lighting;
        short drawtype_options;
-       short pad5;
+       short drawtype_studiolight;
 
        int overlays;
        int pad6;
index 80f06cc52f3b7fd8ad507b4cd5efb89a8782f5c7..f964550e30d5f69f37bca306115ed1fbee2b4a32 100644 (file)
@@ -520,25 +520,31 @@ static void rna_def_constraint_headtail_common(StructRNA *srna)
        RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
 }
 
-static void rna_def_constrainttarget(BlenderRNA *brna)
+static void rna_def_constraint_target_common(StructRNA *srna)
 {
-       StructRNA *srna;
        PropertyRNA *prop;
 
-       srna = RNA_def_struct(brna, "ConstraintTarget", NULL);
-       RNA_def_struct_ui_text(srna, "Constraint Target", "Target object for multi-target constraints");
-       RNA_def_struct_sdna(srna, "bConstraintTarget");
-
        prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
        RNA_def_property_pointer_sdna(prop, NULL, "tar");
-       RNA_def_property_ui_text(prop, "Target", "Target Object");
+       RNA_def_property_ui_text(prop, "Target", "Target object");
        RNA_def_property_flag(prop, PROP_EDITABLE);
        RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
 
        prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
        RNA_def_property_string_sdna(prop, NULL, "subtarget");
-       RNA_def_property_ui_text(prop, "Sub-Target", "");
+       RNA_def_property_ui_text(prop, "Sub-Target", "Armature bone, mesh or lattice vertex group, ...");
        RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
+}
+
+static void rna_def_constrainttarget(BlenderRNA *brna)
+{
+       StructRNA *srna;
+
+       srna = RNA_def_struct(brna, "ConstraintTarget", NULL);
+       RNA_def_struct_ui_text(srna, "Constraint Target", "Target object for multi-target constraints");
+       RNA_def_struct_sdna(srna, "bConstraintTarget");
+
+       rna_def_constraint_target_common(srna);
 
        /* space, flag and type still to do  */
 }
@@ -552,16 +558,7 @@ static void rna_def_constraint_childof(BlenderRNA *brna)
        RNA_def_struct_ui_text(srna, "Child Of Constraint", "Create constraint-based parent-child relationship");
        RNA_def_struct_sdna_from(srna, "bChildOfConstraint", "data");
 
-       prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
-       RNA_def_property_pointer_sdna(prop, NULL, "tar");
-       RNA_def_property_ui_text(prop, "Target", "Target Object");
-       RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
-       prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
-       RNA_def_property_string_sdna(prop, NULL, "subtarget");
-       RNA_def_property_ui_text(prop, "Sub-Target", "");
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
+       rna_def_constraint_target_common(srna);
 
        prop = RNA_def_property(srna, "use_location_x", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_LOCX);
@@ -672,16 +669,7 @@ static void rna_def_constraint_kinematic(BlenderRNA *brna)
        RNA_def_struct_ui_text(srna, "Kinematic Constraint", "Inverse Kinematics");
        RNA_def_struct_sdna_from(srna, "bKinematicConstraint", "data");
 
-       prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
-       RNA_def_property_pointer_sdna(prop, NULL, "tar");
-       RNA_def_property_ui_text(prop, "Target", "Target Object");
-       RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
-       prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
-       RNA_def_property_string_sdna(prop, NULL, "subtarget");
-       RNA_def_property_ui_text(prop, "Sub-Target", "");
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
+       rna_def_constraint_target_common(srna);
 
        prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE);
        RNA_def_property_range(prop, 0, 10000);
@@ -828,16 +816,7 @@ static void rna_def_constraint_track_to(BlenderRNA *brna)
 
        RNA_def_struct_sdna_from(srna, "bTrackToConstraint", "data");
 
-       prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
-       RNA_def_property_pointer_sdna(prop, NULL, "tar");
-       RNA_def_property_ui_text(prop, "Target", "Target Object");
-       RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
-       prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
-       RNA_def_property_string_sdna(prop, NULL, "subtarget");
-       RNA_def_property_ui_text(prop, "Sub-Target", "");
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
+       rna_def_constraint_target_common(srna);
 
        prop = RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "reserved1");
@@ -869,17 +848,7 @@ static void rna_def_constraint_locate_like(BlenderRNA *brna)
 
        RNA_def_struct_sdna_from(srna, "bLocateLikeConstraint", "data");
 
-       prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
-       RNA_def_property_pointer_sdna(prop, NULL, "tar");
-       RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_ui_text(prop, "Target", "Target Object");
-       RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
-       prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
-       RNA_def_property_string_sdna(prop, NULL, "subtarget");
-       RNA_def_property_ui_text(prop, "Sub-Target", "");
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
+       rna_def_constraint_target_common(srna);
 
        prop = RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_X);
@@ -926,16 +895,7 @@ static void rna_def_constraint_rotate_like(BlenderRNA *brna)
        RNA_def_struct_ui_text(srna, "Copy Rotation Constraint", "Copy the rotation of the target");
        RNA_def_struct_sdna_from(srna, "bRotateLikeConstraint", "data");
 
-       prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
-       RNA_def_property_pointer_sdna(prop, NULL, "tar");
-       RNA_def_property_ui_text(prop, "Target", "Target Object");
-       RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
-       prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
-       RNA_def_property_string_sdna(prop, NULL, "subtarget");
-       RNA_def_property_ui_text(prop, "Sub-Target", "");
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
+       rna_def_constraint_target_common(srna);
 
        prop = RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", ROTLIKE_X);
@@ -982,17 +942,7 @@ static void rna_def_constraint_size_like(BlenderRNA *brna)
        RNA_def_struct_ui_text(srna, "Copy Scale Constraint", "Copy the scale of the target");
        RNA_def_struct_sdna_from(srna, "bSizeLikeConstraint", "data");
 
-       prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
-       RNA_def_property_pointer_sdna(prop, NULL, "tar");
-       RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_ui_text(prop, "Target", "Target Object");
-       RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
-       prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
-       RNA_def_property_string_sdna(prop, NULL, "subtarget");
-       RNA_def_property_ui_text(prop, "Sub-Target", "");
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
+       rna_def_constraint_target_common(srna);
 
        prop = RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", SIZELIKE_X);
@@ -1048,7 +998,6 @@ static void rna_def_constraint_same_volume(BlenderRNA *brna)
 static void rna_def_constraint_transform_like(BlenderRNA *brna)
 {
        StructRNA *srna;
-       PropertyRNA *prop;
 
        srna = RNA_def_struct(brna, "CopyTransformsConstraint", "Constraint");
        RNA_def_struct_ui_text(srna, "Copy Transforms Constraint", "Copy all the transforms of the target");
@@ -1057,16 +1006,7 @@ static void rna_def_constraint_transform_like(BlenderRNA *brna)
 
        RNA_def_struct_sdna_from(srna, "bTransLikeConstraint", "data");
 
-       prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
-       RNA_def_property_pointer_sdna(prop, NULL, "tar");
-       RNA_def_property_ui_text(prop, "Target", "Target Object");
-       RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
-       prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
-       RNA_def_property_string_sdna(prop, NULL, "subtarget");
-       RNA_def_property_ui_text(prop, "Sub-Target", "");
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
+       rna_def_constraint_target_common(srna);
 }
 
 static void rna_def_constraint_minmax(BlenderRNA *brna)
@@ -1088,16 +1028,7 @@ static void rna_def_constraint_minmax(BlenderRNA *brna)
        RNA_def_struct_ui_text(srna, "Floor Constraint", "Use the target object for location limitation");
        RNA_def_struct_sdna_from(srna, "bMinMaxConstraint", "data");
 
-       prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
-       RNA_def_property_pointer_sdna(prop, NULL, "tar");
-       RNA_def_property_ui_text(prop, "Target", "Target Object");
-       RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
-       prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
-       RNA_def_property_string_sdna(prop, NULL, "subtarget");
-       RNA_def_property_ui_text(prop, "Sub-Target", "");
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
+       rna_def_constraint_target_common(srna);
 
        prop = RNA_def_property(srna, "floor_location", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "minmaxflag");
@@ -1143,16 +1074,7 @@ static void rna_def_constraint_action(BlenderRNA *brna)
        RNA_def_struct_ui_text(srna, "Action Constraint", "Map an action to the transform axes of a bone");
        RNA_def_struct_sdna_from(srna, "bActionConstraint", "data");
 
-       prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
-       RNA_def_property_pointer_sdna(prop, NULL, "tar");
-       RNA_def_property_ui_text(prop, "Target", "Target Object");
-       RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
-       prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
-       RNA_def_property_string_sdna(prop, NULL, "subtarget");
-       RNA_def_property_ui_text(prop, "Sub-Target", "");
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
+       rna_def_constraint_target_common(srna);
 
        prop = RNA_def_property(srna, "transform_channel", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "type");
@@ -1232,16 +1154,7 @@ static void rna_def_constraint_locked_track(BlenderRNA *brna)
        
        RNA_def_struct_sdna_from(srna, "bLockTrackConstraint", "data");
 
-       prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
-       RNA_def_property_pointer_sdna(prop, NULL, "tar");
-       RNA_def_property_ui_text(prop, "Target", "Target Object");
-       RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
-       prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
-       RNA_def_property_string_sdna(prop, NULL, "subtarget");
-       RNA_def_property_ui_text(prop, "Sub-Target", "");
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
+       rna_def_constraint_target_common(srna);
 
        prop = RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "trackflag");
@@ -1285,7 +1198,7 @@ static void rna_def_constraint_follow_path(BlenderRNA *brna)
        prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
        RNA_def_property_pointer_sdna(prop, NULL, "tar");
        RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Curve_object_poll");
-       RNA_def_property_ui_text(prop, "Target", "Target Object");
+       RNA_def_property_ui_text(prop, "Target", "Target Curve object");
        RNA_def_property_flag(prop, PROP_EDITABLE);
        RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
 
@@ -1356,16 +1269,7 @@ static void rna_def_constraint_stretch_to(BlenderRNA *brna)
 
        RNA_def_struct_sdna_from(srna, "bStretchToConstraint", "data");
 
-       prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
-       RNA_def_property_pointer_sdna(prop, NULL, "tar");
-       RNA_def_property_ui_text(prop, "Target", "Target Object");
-       RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-       
-       prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
-       RNA_def_property_string_sdna(prop, NULL, "subtarget");
-       RNA_def_property_ui_text(prop, "Sub-Target", "");
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
+       rna_def_constraint_target_common(srna);
 
        prop = RNA_def_property(srna, "volume", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "volmode");
@@ -1470,16 +1374,7 @@ static void rna_def_constraint_transform(BlenderRNA *brna)
        RNA_def_struct_ui_text(srna, "Transformation Constraint", "Map transformations of the target to the object");
        RNA_def_struct_sdna_from(srna, "bTransformConstraint", "data");
 
-       prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
-       RNA_def_property_pointer_sdna(prop, NULL, "tar");
-       RNA_def_property_ui_text(prop, "Target", "Target Object");
-       RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
-       prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
-       RNA_def_property_string_sdna(prop, NULL, "subtarget");
-       RNA_def_property_ui_text(prop, "Sub-Target", "");
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
+       rna_def_constraint_target_common(srna);
 
        prop = RNA_def_property(srna, "map_from", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "from");
@@ -1976,16 +1871,7 @@ static void rna_def_constraint_distance_limit(BlenderRNA *brna)
        
        RNA_def_struct_sdna_from(srna, "bDistLimitConstraint", "data");
 
-       prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
-       RNA_def_property_pointer_sdna(prop, NULL, "tar");
-       RNA_def_property_ui_text(prop, "Target", "Target Object");
-       RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
-       prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
-       RNA_def_property_string_sdna(prop, NULL, "subtarget");
-       RNA_def_property_ui_text(prop, "Sub-Target", "");
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
+       rna_def_constraint_target_common(srna);
 
        prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE);
        RNA_def_property_float_sdna(prop, NULL, "dist");
@@ -2027,7 +1913,7 @@ static void rna_def_constraint_shrinkwrap(BlenderRNA *brna)
        prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
        RNA_def_property_pointer_sdna(prop, NULL, "target"); /* TODO, mesh type */
        RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Mesh_object_poll");
-       RNA_def_property_ui_text(prop, "Target", "Target Object");
+       RNA_def_property_ui_text(prop, "Target", "Target Mesh object");
        RNA_def_property_flag(prop, PROP_EDITABLE);
        RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
        
@@ -2087,16 +1973,7 @@ rna_def_constraint_headtail_common(srna);
        
        RNA_def_struct_sdna_from(srna, "bDampTrackConstraint", "data");
 
-       prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
-       RNA_def_property_pointer_sdna(prop, NULL, "tar");
-       RNA_def_property_ui_text(prop, "Target", "Target Object");
-       RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
-
-       prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
-       RNA_def_property_string_sdna(prop, NULL, "subtarget");
-       RNA_def_property_ui_text(prop, "Sub-Target", "");
-       RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
+       rna_def_constraint_target_common(srna);
 
        prop = RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "trackflag");
index 8cef700e93419c2f01350a1b049f07f7f3f6eab8..6feec3558089d0c2cafd85e944c208163db2eba5 100644 (file)
@@ -2201,6 +2201,14 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
                {V3D_DRAWOPTION_RANDOMIZE,      "RANDOM",   0, "Random",   "Show random object color"},
                {0, NULL, 0, NULL, NULL}
        };
+       static const EnumPropertyItem studio_lighting_items[] = {
+               {0, "01", ICON_STUDIOLIGHT_01, "", ""},
+               {1, "02", ICON_STUDIOLIGHT_02, "", ""},
+               {2, "03", ICON_STUDIOLIGHT_03, "", ""},
+               {3, "04", ICON_STUDIOLIGHT_04, "", ""},
+               {4, "05", ICON_STUDIOLIGHT_05, "", ""},
+               {0, NULL, 0, NULL, NULL}
+       };
 
        srna = RNA_def_struct(brna, "View3DShading", NULL);
        RNA_def_struct_sdna(srna, "View3D");
@@ -2228,6 +2236,12 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Object Overlap", "Show Object Overlap");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_3DViewShading_type_update");
 
+       prop = RNA_def_property(srna, "studiolight", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "drawtype_studiolight");
+       RNA_def_property_enum_items(prop, studio_lighting_items);
+       RNA_def_property_ui_text(prop, "Studiolight", "Studio lighting setup");
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_3DViewShading_type_update");
+
        prop = RNA_def_property(srna, "single_color_mode", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_items(prop, single_color_mode_items);
        RNA_def_property_enum_funcs(prop, "rna_View3DShading_single_color_mode_get",
index cac08bd6d3a5457e0876bf58355473dbc9b6feee..43fceaae22acac08d0b8692613f97382bb15917c 100644 (file)
@@ -68,6 +68,106 @@ BLI_INLINE bool edgeref_is_init(const EdgeFaceRef *edge_ref)
        return !((edge_ref->f1 == 0) && (edge_ref->f2 == 0));
 }
 
+/**
+ * \param dm  Mesh to calculate normals for.
+ * \param face_nors  Precalculated face normals.
+ * \param r_vert_nors  Return vert normals.
+ */
+static void mesh_calc_hq_normal(Mesh *mesh, float (*face_nors)[3], float (*r_vert_nors)[3])
+{
+       int i, numVerts, numEdges, numFaces;
+       MPoly *mpoly, *mp;
+       MLoop *mloop, *ml;
+       MEdge *medge, *ed;
+       MVert *mvert, *mv;
+
+       numVerts = mesh->totvert;
+       numEdges = mesh->totedge;
+       numFaces = mesh->totface;
+       mpoly = mesh->mpoly;
+       medge = mesh->medge;
+       mvert = mesh->mvert;
+       mloop = mesh->mloop;
+
+       /* we don't want to overwrite any referenced layers */
+
+       /* Doesn't work here! */
+#if 0
+       mv = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, numVerts);
+       cddm->mvert = mv;
+#endif
+
+       mv = mvert;
+       mp = mpoly;
+
+       {
+               EdgeFaceRef *edge_ref_array = MEM_calloc_arrayN((size_t)numEdges, sizeof(EdgeFaceRef), "Edge Connectivity");
+               EdgeFaceRef *edge_ref;
+               float edge_normal[3];
+
+               /* This loop adds an edge hash if its not there, and adds the face index */
+               for (i = 0; i < numFaces; i++, mp++) {
+                       int j;
+
+                       ml = mloop + mp->loopstart;
+
+                       for (j = 0; j < mp->totloop; j++, ml++) {
+                               /* --- add edge ref to face --- */
+                               edge_ref = &edge_ref_array[ml->e];
+                               if (!edgeref_is_init(edge_ref)) {
+                                       edge_ref->f1 =  i;
+                                       edge_ref->f2 = -1;
+                               }
+                               else if ((edge_ref->f1 != -1) && (edge_ref->f2 == -1)) {
+                                       edge_ref->f2 = i;
+                               }
+                               else {
+                                       /* 3+ faces using an edge, we can't handle this usefully */
+                                       edge_ref->f1 = edge_ref->f2 = -1;
+#ifdef USE_NONMANIFOLD_WORKAROUND
+                                       medge[ml->e].flag |= ME_EDGE_TMP_TAG;
+#endif
+                               }
+                               /* --- done --- */
+                       }
+               }
+
+               for (i = 0, ed = medge, edge_ref = edge_ref_array; i < numEdges; i++, ed++, edge_ref++) {
+                       /* Get the edge vert indices, and edge value (the face indices that use it) */
+
+                       if (edgeref_is_init(edge_ref) && (edge_ref->f1 != -1)) {
+                               if (edge_ref->f2 != -1) {
+                                       /* We have 2 faces using this edge, calculate the edges normal
+                                                                               * using the angle between the 2 faces as a weighting */
+#if 0
+                                       add_v3_v3v3(edge_normal, face_nors[edge_ref->f1], face_nors[edge_ref->f2]);
+                                       normalize_v3_length(
+                                                   edge_normal,
+                                                   angle_normalized_v3v3(face_nors[edge_ref->f1], face_nors[edge_ref->f2]));
+#else
+                                       mid_v3_v3v3_angle_weighted(edge_normal, face_nors[edge_ref->f1], face_nors[edge_ref->f2]);
+#endif
+                               }
+                               else {
+                                       /* only one face attached to that edge */
+                                       /* an edge without another attached- the weight on this is undefined */
+                                       copy_v3_v3(edge_normal, face_nors[edge_ref->f1]);
+                               }
+                               add_v3_v3(r_vert_nors[ed->v1], edge_normal);
+                               add_v3_v3(r_vert_nors[ed->v2], edge_normal);
+                       }
+               }
+               MEM_freeN(edge_ref_array);
+       }
+
+       /* normalize vertex normals and assign */
+       for (i = 0; i < numVerts; i++, mv++) {
+               if (normalize_v3(r_vert_nors[i]) == 0.0f) {
+                       normal_short_to_float_v3(r_vert_nors[i], mv->no);
+               }
+       }
+}
+
 static void initData(ModifierData *md)
 {
        SolidifyModifierData *smd = (SolidifyModifierData *) md;
@@ -266,9 +366,7 @@ static Mesh *applyModifier(
 
        if (smd->flag & MOD_SOLIDIFY_NORMAL_CALC) {
                vert_nors = MEM_calloc_arrayN(numVerts, 3 * sizeof(float), "mod_solid_vno_hq");
-               BKE_mesh_calc_normals_poly(mesh->mvert, vert_nors, mesh->totvert,
-                                          mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
-                                          NULL, false);
+               mesh_calc_hq_normal(mesh, face_nors, vert_nors);
        }
 
        result = BKE_mesh_from_template(mesh,