Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-11-30 15:58:27 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-11-30 17:40:57 +0300
commit909fa08a7654e411b3fba90178a7003646ca7e54 (patch)
tree1e7a8cb02edac7e4c96a0cd08eb265b696247127
parent856b858f88052371f231c69c182e6169101f9b39 (diff)
StudioLight: Add a 4th light to adjust lighting
There was a bug due to non-aligned struct in the DNA that prevented us to increase the size of the userdef light array. Since the studio lights are now presets and stored in external files, there is no need to keep backward compatibility with theses lights. Remove the old array and create a new one. Add blue tint light for specular.
-rw-r--r--release/scripts/startup/bl_ui/space_userpref.py4
-rw-r--r--source/blender/blenkernel/intern/blender.c2
-rw-r--r--source/blender/blenkernel/intern/studiolight.c10
-rw-r--r--source/blender/blenloader/intern/versioning_userdef.c37
-rw-r--r--source/blender/draw/engines/workbench/workbench_studiolight.c7
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h4
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c10
7 files changed, 45 insertions, 29 deletions
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 041ac14602a..557948504d7 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -1602,6 +1602,10 @@ class USERPREF_PT_studiolight_lights_editor(Panel):
self.opengl_light_buttons(colsplit, light)
light = system.solid_lights[2]
+ colsplit = column.split(factor=0.85)
+ self.opengl_light_buttons(colsplit, light)
+
+ light = system.solid_lights[3]
self.opengl_light_buttons(column, light)
layout.separator()
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index f1b1aa548d2..0ba19d5b4da 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -307,8 +307,6 @@ void BKE_blender_userdef_app_template_data_swap(UserDef *userdef_a, UserDef *use
LIST_SWAP(addons);
LIST_SWAP(user_keymaps);
- DATA_SWAP(light);
-
DATA_SWAP(font_path_ui);
DATA_SWAP(font_path_ui_mono);
DATA_SWAP(keyconfigstr);
diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c
index 3a98d5ea90a..5196ae50bab 100644
--- a/source/blender/blenkernel/intern/studiolight.c
+++ b/source/blender/blenkernel/intern/studiolight.c
@@ -1210,6 +1210,12 @@ void BKE_studiolight_init(void)
sl->light[2].flag = 1;
sl->light[2].smooth = 0.5;
+ copy_v4_fl4(sl->light[3].vec, 0.021053, -0.989474, 0.143173, 0.0);
+ copy_v4_fl4(sl->light[3].col, 0.0, 0.0, 0.0, 1.0);
+ copy_v4_fl4(sl->light[3].spec, 0.072234, 0.082253, 0.162642, 1.000000);
+ sl->light[3].flag = 1;
+ sl->light[3].smooth = 0.7;
+
BLI_addtail(&studiolights, sl);
/* go over the preset folder and add a studiolight for every image with its path */
@@ -1360,7 +1366,7 @@ StudioLight *BKE_studiolight_create(const char *path, const SolidLight light[4],
BLI_snprintf(sl->path, FILE_MAXFILE, "%s%s", path, ".sl");
BLI_snprintf(sl->name, FILE_MAXFILE, "%s%s", filename, ".sl");
- memcpy(sl->light, light, sizeof(*light) * 3);
+ memcpy(sl->light, light, sizeof(*light) * 4);
memcpy(sl->light_ambient, light_ambient, sizeof(*light_ambient) * 3);
studiolight_write_solid_light(sl);
@@ -1375,7 +1381,7 @@ StudioLight *BKE_studiolight_studio_edit_get(void)
static StudioLight sl = {0};
sl.flag = STUDIOLIGHT_TYPE_STUDIO;
- memcpy(sl.light, U.light, sizeof(*sl.light) * 3);
+ memcpy(sl.light, U.light_param, sizeof(*sl.light) * 4);
memcpy(sl.light_ambient, U.light_ambient, sizeof(*sl.light_ambient) * 3);
return &sl;
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index 55c875e3412..47e3cef2062 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -421,20 +421,29 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
*/
{
/* (keep this block even if it becomes empty). */
- copy_v4_fl4(userdef->light[0].vec, -0.580952, 0.228571, 0.781185, 0.0);
- copy_v4_fl4(userdef->light[0].col, 0.900000, 0.900000, 0.900000, 1.000000);
- copy_v4_fl4(userdef->light[0].spec, 0.318547, 0.318547, 0.318547, 1.000000);
- userdef->light[0].smooth = 0.1;
-
- copy_v4_fl4(userdef->light[1].vec, 0.788218, 0.593482, -0.162765, 0.0);
- copy_v4_fl4(userdef->light[1].col, 0.267115, 0.269928, 0.358840, 1.000000);
- copy_v4_fl4(userdef->light[1].spec, 0.090838, 0.090838, 0.090838, 1.000000);
- userdef->light[1].smooth = 0.25;
-
- copy_v4_fl4(userdef->light[2].vec, 0.696472, -0.696472, -0.172785, 0.0);
- copy_v4_fl4(userdef->light[2].col, 0.293216, 0.304662, 0.401968, 1.000000);
- copy_v4_fl4(userdef->light[2].spec, 0.069399, 0.020331, 0.020331, 1.000000);
- userdef->light[2].smooth = 0.5;
+ copy_v4_fl4(userdef->light_param[0].vec, -0.580952, 0.228571, 0.781185, 0.0);
+ copy_v4_fl4(userdef->light_param[0].col, 0.900000, 0.900000, 0.900000, 1.000000);
+ copy_v4_fl4(userdef->light_param[0].spec, 0.318547, 0.318547, 0.318547, 1.000000);
+ userdef->light_param[0].flag = 1;
+ userdef->light_param[0].smooth = 0.1;
+
+ copy_v4_fl4(userdef->light_param[1].vec, 0.788218, 0.593482, -0.162765, 0.0);
+ copy_v4_fl4(userdef->light_param[1].col, 0.267115, 0.269928, 0.358840, 1.000000);
+ copy_v4_fl4(userdef->light_param[1].spec, 0.090838, 0.090838, 0.090838, 1.000000);
+ userdef->light_param[1].flag = 1;
+ userdef->light_param[1].smooth = 0.25;
+
+ copy_v4_fl4(userdef->light_param[2].vec, 0.696472, -0.696472, -0.172785, 0.0);
+ copy_v4_fl4(userdef->light_param[2].col, 0.293216, 0.304662, 0.401968, 1.000000);
+ copy_v4_fl4(userdef->light_param[2].spec, 0.069399, 0.020331, 0.020331, 1.000000);
+ userdef->light_param[2].flag = 1;
+ userdef->light_param[2].smooth = 0.4;
+
+ copy_v4_fl4(userdef->light_param[3].vec, 0.021053, -0.989474, 0.143173, 0.0);
+ copy_v4_fl4(userdef->light_param[3].col, 0.0, 0.0, 0.0, 1.0);
+ copy_v4_fl4(userdef->light_param[3].spec, 0.072234, 0.082253, 0.162642, 1.000000);
+ userdef->light_param[3].flag = 1;
+ userdef->light_param[3].smooth = 0.7;
copy_v4_fl4(userdef->light_ambient, 0.025000, 0.025000, 0.025000, 1.000000);
}
diff --git a/source/blender/draw/engines/workbench/workbench_studiolight.c b/source/blender/draw/engines/workbench/workbench_studiolight.c
index 7b348cfd8ec..63fc096ab0f 100644
--- a/source/blender/draw/engines/workbench/workbench_studiolight.c
+++ b/source/blender/draw/engines/workbench/workbench_studiolight.c
@@ -54,13 +54,6 @@ void studiolight_update_world(WORKBENCH_PrivateData *wpd, StudioLight *studiolig
/* Studio Lights. */
for (int i = 0; i < 4; i++) {
WORKBENCH_UBO_Light *light = &wd->lights[i];
- /* TODO use 4 lights in studiolights prefs. */
- if (i > 2) {
- copy_v3_fl3(light->light_direction, 1.0f, 0.0f, 0.0f);
- copy_v3_fl(light->specular_color, 0.0f);
- copy_v3_fl(light->diffuse_color, 0.0f);
- continue;
- }
SolidLight *sl = &studiolight->light[i];
if (sl->flag) {
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index e0bed7216e2..8fc7c0ed326 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -494,6 +494,7 @@ enum {
typedef struct SolidLight {
int flag;
float smooth;
+ float pad[2];
float col[4], spec[4], vec[4];
} SolidLight;
@@ -586,7 +587,8 @@ typedef struct UserDef {
short gp_manhattendist, gp_euclideandist, gp_eraser;
short gp_settings; /* eGP_UserdefSettings */
short tb_leftmouse, tb_rightmouse;
- struct SolidLight light[3];
+ /* struct SolidLight light[3] DNA_DEPRECATED; */ /* Was using non-aligned struct! */
+ struct SolidLight light_param[4];
float light_ambient[3], pad7;
short gizmo_flag, gizmo_size;
short edit_solid_light;
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index af6150704e0..416689f403f 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -329,7 +329,11 @@ static void rna_UserDef_viewport_lights_update(Main *bmain, Scene *scene, Pointe
{
/* if all lights are off gpu_draw resets them all, [#27627]
* so disallow them all to be disabled */
- if (U.light[0].flag == 0 && U.light[1].flag == 0 && U.light[2].flag == 0) {
+ if (U.light_param[0].flag == 0 &&
+ U.light_param[1].flag == 0 &&
+ U.light_param[2].flag == 0 &&
+ U.light_param[3].flag == 0)
+ {
SolidLight *light = ptr->data;
light->flag |= 1;
}
@@ -636,7 +640,7 @@ static StudioLight *rna_StudioLights_load(UserDef *UNUSED(userdef), const char *
/* TODO: Make it accept arguments. */
static StudioLight *rna_StudioLights_new(UserDef *userdef, const char *name)
{
- return BKE_studiolight_create(name, userdef->light, userdef->light_ambient);
+ return BKE_studiolight_create(name, userdef->light_param, userdef->light_ambient);
}
/* StudioLight.name */
@@ -4300,7 +4304,7 @@ static void rna_def_userdef_system(BlenderRNA *brna)
/* System & OpenGL */
prop = RNA_def_property(srna, "solid_lights", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_collection_sdna(prop, NULL, "light", "");
+ RNA_def_property_collection_sdna(prop, NULL, "light_param", "");
RNA_def_property_struct_type(prop, "UserSolidLight");
RNA_def_property_ui_text(prop, "Solid Lights", "Lights user to display objects in solid draw mode");