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:
authorJeroen Bakker <j.bakker@atmind.nl>2018-06-20 10:29:40 +0300
committerJeroen Bakker <j.bakker@atmind.nl>2018-06-20 10:29:40 +0300
commite3052ecb0d246381558c75219962915140bbe4ca (patch)
treea05e59c7c0b94b18bb45fe884bee6af920e241c2 /source/blender/blenkernel/intern/studiolight.c
parent91c0f17a475793de7bc6016598ef13221392dbf5 (diff)
Studiolight: removed raise condition
Happened when deleting many studiolights at the same time when the previews were still beging calculated in the background. Added a free function callback that is filled when the preview is being generated. This free function will then kill the preview job This patch also removes icons that are not valid anymore so the user cannot accidentally render an icon where the studiolight is invalid. In the end we should use a add/remove function in the studiolight as currently icons are recalculated too much.
Diffstat (limited to 'source/blender/blenkernel/intern/studiolight.c')
-rw-r--r--source/blender/blenkernel/intern/studiolight.c49
1 files changed, 43 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c
index 42a6b96653f..da370971715 100644
--- a/source/blender/blenkernel/intern/studiolight.c
+++ b/source/blender/blenkernel/intern/studiolight.c
@@ -81,6 +81,21 @@ if (p) { \
static void studiolight_free(struct StudioLight *sl)
{
+#define STUDIOLIGHT_DELETE_ICON(s) { \
+ if (s != 0) { \
+ BKE_icon_delete(s); \
+ s = 0; \
+ } \
+}
+ if (sl->free_function) {
+ sl->free_function(sl, sl->free_function_data);
+ }
+ STUDIOLIGHT_DELETE_ICON(sl->icon_id_radiance);
+ STUDIOLIGHT_DELETE_ICON(sl->icon_id_irradiance);
+ STUDIOLIGHT_DELETE_ICON(sl->icon_id_matcap);
+ STUDIOLIGHT_DELETE_ICON(sl->icon_id_matcap_flipped);
+#undef STUDIOLIGHT_DELETE_ICON
+
for (int index = 0 ; index < 6 ; index ++) {
IMB_SAFE_FREE(sl->radiance_cubemap_buffers[index]);
}
@@ -101,6 +116,7 @@ static struct StudioLight *studiolight_create(int flag)
sl->name[0] = 0x00;
sl->path_irr_cache = NULL;
sl->path_sh2_cache = NULL;
+ sl->free_function = NULL;
sl->flag = flag;
sl->index = BLI_listbase_count(&studiolights);
if (flag & STUDIOLIGHT_ORIENTATION_VIEWNORMAL) {
@@ -892,7 +908,7 @@ void BKE_studiolight_free(void)
struct StudioLight *BKE_studiolight_find_first(int flag)
{
LISTBASE_FOREACH(StudioLight *, sl, &studiolights) {
- if ((sl->flag & flag) && (sl->flag & STUDIOLIGHT_DISABLED) == 0) {
+ if ((sl->flag & flag)) {
return sl;
}
}
@@ -903,7 +919,7 @@ struct StudioLight *BKE_studiolight_find(const char *name, int flag)
{
LISTBASE_FOREACH(StudioLight *, sl, &studiolights) {
if (STREQLEN(sl->name, name, FILE_MAXFILE)) {
- if ((sl->flag & flag) && (sl->flag & STUDIOLIGHT_DISABLED) == 0) {
+ if ((sl->flag & flag)) {
return sl;
}
else {
@@ -919,7 +935,7 @@ struct StudioLight *BKE_studiolight_find(const char *name, int flag)
struct StudioLight *BKE_studiolight_findindex(int index, int flag)
{
LISTBASE_FOREACH(StudioLight *, sl, &studiolights) {
- if (sl->index == index && (sl->flag & STUDIOLIGHT_DISABLED) == 0) {
+ if (sl->index == index) {
return sl;
}
}
@@ -995,8 +1011,29 @@ void BKE_studiolight_ensure_flag(StudioLight *sl, int flag)
void BKE_studiolight_refresh(void)
{
- LISTBASE_FOREACH(StudioLight *, sl, &studiolights) {
- sl->flag |= STUDIOLIGHT_DISABLED;
- }
+ BKE_studiolight_free();
BKE_studiolight_init();
}
+
+void BKE_studiolight_set_free_function(StudioLight *sl, StudioLightFreeFunction *free_function, void *data)
+{
+ sl->free_function = free_function;
+ sl->free_function_data = data;
+}
+
+void BKE_studiolight_unset_icon_id(StudioLight *sl, int icon_id)
+{
+ BLI_assert(sl != NULL);
+ if (sl->icon_id_radiance == icon_id) {
+ sl->icon_id_radiance = 0;
+ }
+ if (sl->icon_id_irradiance == icon_id) {
+ sl->icon_id_irradiance = 0;
+ }
+ if (sl->icon_id_matcap == icon_id) {
+ sl->icon_id_matcap = 0;
+ }
+ if (sl->icon_id_matcap_flipped == icon_id) {
+ sl->icon_id_matcap_flipped = 0;
+ }
+} \ No newline at end of file