[Bf-blender-cvs] [0993af54842] blender2.8: Planar Probe: Add UI, 3d view Display and change defaults.
Clément Foucault
noreply at git.blender.org
Mon Jun 19 10:48:14 CEST 2017
Commit: 0993af54842ad9ad43a45fded7e397c6eaafb9a0
Author: Clément Foucault
Date: Sat Jun 17 01:55:49 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB0993af54842ad9ad43a45fded7e397c6eaafb9a0
Planar Probe: Add UI, 3d view Display and change defaults.
===================================================================
M release/scripts/startup/bl_ui/properties_data_lightprobe.py
M source/blender/draw/modes/object_mode.c
M source/blender/editors/object/object_add.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_data_lightprobe.py b/release/scripts/startup/bl_ui/properties_data_lightprobe.py
index 603e7b4741b..af6a1affd69 100644
--- a/release/scripts/startup/bl_ui/properties_data_lightprobe.py
+++ b/release/scripts/startup/bl_ui/properties_data_lightprobe.py
@@ -76,6 +76,11 @@ class DATA_PT_lightprobe(DataButtonsPanel, Panel):
col.label("Influence:")
col.prop(probe, "influence_distance", "Distance")
col.prop(probe, "falloff")
+ elif probe.type == "PLANAR":
+ col = split.column(align=True)
+ col.label("Influence:")
+ col.prop(probe, "influence_distance", "Distance")
+ col.prop(probe, "falloff")
else:
col = split.column(align=True)
col.label("Influence:")
@@ -91,7 +96,8 @@ class DATA_PT_lightprobe(DataButtonsPanel, Panel):
col = split.column(align=True)
col.label("Clipping:")
col.prop(probe, "clip_start", text="Start")
- col.prop(probe, "clip_end", text="End")
+ if probe.type != "PLANAR":
+ col.prop(probe, "clip_end", text="End")
class DATA_PT_lightprobe_parallax(DataButtonsPanel, Panel):
@@ -132,6 +138,7 @@ class DATA_PT_lightprobe_display(DataButtonsPanel, Panel):
ob = context.object
probe = context.lightprobe
+ is_planar = (probe.type is "PLANAR")
split = layout.split()
@@ -139,14 +146,19 @@ class DATA_PT_lightprobe_display(DataButtonsPanel, Panel):
col.prop(probe, "show_influence")
col = split.column()
+ col.active = is_planar
col.prop(probe, "show_parallax")
col = split.column()
+ col.active = is_planar
col.prop(probe, "show_clip")
row = layout.row()
row.prop(probe, "show_data")
- row.prop(probe, "data_draw_size")
+ if probe.type != "PLANAR":
+ row.prop(probe, "data_draw_size")
+ else:
+ row.prop(ob, "empty_draw_size", text="Arrow Size")
classes = (
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index c7d3bedb712..3262e863106 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -1411,12 +1411,34 @@ static void DRW_shgroup_speaker(OBJECT_StorageList *stl, Object *ob, SceneLayer
static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, Object *ob, SceneLayer *sl)
{
float *color;
+ static float one = 1.0f;
LightProbe *prb = (LightProbe *)ob->data;
DRW_object_wire_theme_get(ob, sl, &color);
-
DRW_shgroup_call_dynamic_add(stl->g_data->probe, ob->obmat[3], color);
+ float **prb_mats = (float **)DRW_object_engine_data_get(ob, &draw_engine_object_type, NULL);
+ if (*prb_mats == NULL) {
+ /* we need 6 matrices */
+ *prb_mats = MEM_mallocN(sizeof(float) * 16 * 6, "Probe Clip distances Matrices");
+ }
+
+ if (prb->type == LIGHTPROBE_TYPE_PLANAR) {
+ float (*mat)[4];
+ mat = (float (*)[4])(*prb_mats);
+ copy_m4_m4(mat, ob->obmat);
+ normalize_m4(mat);
+
+ DRW_shgroup_call_dynamic_add(stl->g_data->single_arrow, color, &ob->empty_drawsize, mat);
+ DRW_shgroup_call_dynamic_add(stl->g_data->single_arrow_line, color, &ob->empty_drawsize, mat);
+
+ mat = (float (*)[4])(*prb_mats + 16);
+ copy_m4_m4(mat, ob->obmat);
+ zero_v3(mat[2]);
+
+ DRW_shgroup_call_dynamic_add(stl->g_data->cube, color, &one, mat);
+ }
+
if ((prb->flag & LIGHTPROBE_FLAG_SHOW_INFLUENCE) != 0) {
prb->distfalloff = (1.0f - prb->falloff) * prb->distinf;
@@ -1433,6 +1455,22 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, Object *ob, SceneLay
DRW_shgroup_call_dynamic_add(stl->g_data->cube, color, &prb->distgridinf, ob->obmat);
DRW_shgroup_call_dynamic_add(stl->g_data->cube, color, &prb->distfalloff, ob->obmat);
}
+ else if (prb->type == LIGHTPROBE_TYPE_PLANAR) {
+ float (*rangemat)[4];
+ rangemat = (float (*)[4])(*prb_mats + 32);
+ copy_m4_m4(rangemat, ob->obmat);
+ normalize_v3(rangemat[2]);
+ mul_v3_fl(rangemat[2], prb->distinf);
+
+ DRW_shgroup_call_dynamic_add(stl->g_data->cube, color, &one, rangemat);
+
+ rangemat = (float (*)[4])(*prb_mats + 64);
+ copy_m4_m4(rangemat, ob->obmat);
+ normalize_v3(rangemat[2]);
+ mul_v3_fl(rangemat[2], prb->distfalloff);
+
+ DRW_shgroup_call_dynamic_add(stl->g_data->cube, color, &one, rangemat);
+ }
else {
DRW_shgroup_call_dynamic_add(stl->g_data->sphere, color, &prb->distgridinf, ob->obmat);
DRW_shgroup_call_dynamic_add(stl->g_data->sphere, color, &prb->distfalloff, ob->obmat);
@@ -1440,59 +1478,58 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, Object *ob, SceneLay
}
if ((prb->flag & LIGHTPROBE_FLAG_SHOW_PARALLAX) != 0) {
- float (*obmat)[4], *dist;
+ if (prb->type != LIGHTPROBE_TYPE_PLANAR) {
+ float (*obmat)[4], *dist;
- if ((prb->flag & LIGHTPROBE_FLAG_CUSTOM_PARALLAX) != 0) {
- dist = &prb->distpar;
- /* TODO object parallax */
- obmat = ob->obmat;
- }
- else {
- dist = &prb->distinf;
- obmat = ob->obmat;
- }
+ if ((prb->flag & LIGHTPROBE_FLAG_CUSTOM_PARALLAX) != 0) {
+ dist = &prb->distpar;
+ /* TODO object parallax */
+ obmat = ob->obmat;
+ }
+ else {
+ dist = &prb->distinf;
+ obmat = ob->obmat;
+ }
- if (prb->parallax_type == LIGHTPROBE_SHAPE_BOX) {
- DRW_shgroup_call_dynamic_add(stl->g_data->cube, color, &dist, obmat);
- }
- else {
- DRW_shgroup_call_dynamic_add(stl->g_data->sphere, color, &dist, obmat);
+ if (prb->parallax_type == LIGHTPROBE_SHAPE_BOX) {
+ DRW_shgroup_call_dynamic_add(stl->g_data->cube, color, &dist, obmat);
+ }
+ else {
+ DRW_shgroup_call_dynamic_add(stl->g_data->sphere, color, &dist, obmat);
+ }
}
}
if ((prb->flag & LIGHTPROBE_FLAG_SHOW_CLIP_DIST) != 0) {
- static const float cubefacemat[6][4][4] = {
- {{0.0, 0.0, -1.0, 0.0}, {0.0, -1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 1.0}},
- {{0.0, 0.0, 1.0, 0.0}, {0.0, -1.0, 0.0, 0.0}, {1.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 1.0}},
- {{1.0, 0.0, 0.0, 0.0}, {0.0, 0.0, -1.0, 0.0}, {0.0, 1.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 1.0}},
- {{1.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 1.0, 0.0}, {0.0, -1.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 1.0}},
- {{1.0, 0.0, 0.0, 0.0}, {0.0, -1.0, 0.0, 0.0}, {0.0, 0.0, -1.0, 0.0}, {0.0, 0.0, 0.0, 1.0}},
- {{-1.0, 0.0, 0.0, 0.0}, {0.0, -1.0, 0.0, 0.0}, {0.0, 0.0, 1.0, 0.0}, {0.0, 0.0, 0.0, 1.0}},
- };
-
- float **prb_mats = (float **)DRW_object_engine_data_get(ob, &draw_engine_object_type, NULL);
- if (*prb_mats == NULL) {
- /* we need 2 matrices */
- *prb_mats = MEM_mallocN(sizeof(float) * 16 * 6, "Probe Clip distances Matrices");
- }
+ if (prb->type != LIGHTPROBE_TYPE_PLANAR) {
+ static const float cubefacemat[6][4][4] = {
+ {{0.0, 0.0, -1.0, 0.0}, {0.0, -1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 1.0}},
+ {{0.0, 0.0, 1.0, 0.0}, {0.0, -1.0, 0.0, 0.0}, {1.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 1.0}},
+ {{1.0, 0.0, 0.0, 0.0}, {0.0, 0.0, -1.0, 0.0}, {0.0, 1.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 1.0}},
+ {{1.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 1.0, 0.0}, {0.0, -1.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 1.0}},
+ {{1.0, 0.0, 0.0, 0.0}, {0.0, -1.0, 0.0, 0.0}, {0.0, 0.0, -1.0, 0.0}, {0.0, 0.0, 0.0, 1.0}},
+ {{-1.0, 0.0, 0.0, 0.0}, {0.0, -1.0, 0.0, 0.0}, {0.0, 0.0, 1.0, 0.0}, {0.0, 0.0, 0.0, 1.0}},
+ };
- for (int i = 0; i < 6; ++i) {
- float (*clipmat)[4];
- clipmat = (float (*)[4])(*prb_mats + 16 * i);
+ for (int i = 0; i < 6; ++i) {
+ float (*clipmat)[4];
+ clipmat = (float (*)[4])(*prb_mats + 16 * i);
- normalize_m4_m4(clipmat, ob->obmat);
- // invert_m4(clipmat);
- mul_m4_m4m4(clipmat, clipmat, cubefacemat[i]);
+ normalize_m4_m4(clipmat, ob->obmat);
+ mul_m4_m4m4(clipmat, clipmat, cubefacemat[i]);
- DRW_shgroup_call_dynamic_add(stl->g_data->lamp_buflimit, color, &prb->clipsta, &prb->clipend, clipmat);
- DRW_shgroup_call_dynamic_add(stl->g_data->lamp_buflimit_points, color, &prb->clipsta, &prb->clipend, clipmat);
+ DRW_shgroup_call_dynamic_add(stl->g_data->lamp_buflimit, color, &prb->clipsta, &prb->clipend, clipmat);
+ DRW_shgroup_call_dynamic_add(stl->g_data->lamp_buflimit_points, color, &prb->clipsta, &prb->clipend, clipmat);
+ }
}
}
DRW_shgroup_call_dynamic_add(stl->g_data->lamp_center_group, ob->obmat[3]);
/* Line and point going to the ground */
- DRW_shgroup_call_dynamic_add(stl->g_data->lamp_groundline, ob->obmat[3]);
- DRW_shgroup_call_dynamic_add(stl->g_data->lamp_groundpoint, ob->obmat[3]);
+ if (prb->type == LIGHTPROBE_TYPE_CUBE) {
+ DRW_shgroup_call_dynamic_add(stl->g_data->lamp_groundline, ob->obmat[3]);
+ DRW_shgroup_call_dynamic_add(stl->g_data->lamp_groundpoint, ob->obmat[3]);
+ }
}
static void DRW_shgroup_relationship_lines(OBJECT_StorageList *stl, Object *ob)
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 49bcdd3d5ae..0dc91f6d615 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -543,8 +543,10 @@ static int lightprobe_add_exec(bContext *C, wmOperator *op)
}
else if (type == 2) {
probe->type = LIGHTPROBE_TYPE_PLANAR;
- probe->distinf = 0.3f;
- probe->falloff = 0.6f;
+ probe->distinf = 0.1f;
+ probe->falloff = 0.5f;
+ probe->clipsta = 0.001f;
+ ob->empty_drawsize = 0.5f;
}
else {
probe->type = LIGHTPROBE_TYPE_CUBE;
More information about the Bf-blender-cvs
mailing list