From 0a5e9e2f56f5d738b1128b46ecadd9713bd42dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Sat, 10 Jun 2017 00:36:33 +0200 Subject: Probe: Small UI improvments -Better falloff default. -Add clip distance visualisation. -Reformat UI and add a display panel. --- source/blender/blenkernel/intern/probe.c | 2 +- source/blender/draw/modes/object_mode.c | 41 ++++++++++++++++++++++++------ source/blender/makesdna/DNA_probe_types.h | 2 ++ source/blender/makesrna/intern/rna_probe.c | 9 +++++-- 4 files changed, 43 insertions(+), 11 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/probe.c b/source/blender/blenkernel/intern/probe.c index c6449275aa9..143ecb23875 100644 --- a/source/blender/blenkernel/intern/probe.c +++ b/source/blender/blenkernel/intern/probe.c @@ -46,7 +46,7 @@ void BKE_probe_init(Probe *probe) probe->distinf = 5.0f; probe->distpar = 5.0f; - probe->falloff = 0.75f; + probe->falloff = 0.2f; probe->clipsta = 1.0f; probe->clipend = 40.0f; } diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 0f91ae27903..e1bcb3bf147 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -1430,21 +1430,46 @@ static void DRW_shgroup_probe(OBJECT_StorageList *stl, Object *ob, SceneLayer *s } if ((prb->flag & PRB_SHOW_PARALLAX) != 0) { - if ((prb->flag & PRB_CUSTOM_PARALLAX) != 0) { - float (*obmat)[4]; + float (*obmat)[4], *dist; + + if ((prb->flag & PRB_CUSTOM_PARALLAX) != 0) { + dist = &prb->distpar; /* TODO object parallax */ obmat = ob->obmat; + } + else { + dist = &prb->distinf; + obmat = ob->obmat; + } - if (prb->parallax_type == PROBE_BOX) { - DRW_shgroup_call_dynamic_add(stl->g_data->cube, color, &prb->distpar, obmat); - } - else { - DRW_shgroup_call_dynamic_add(stl->g_data->sphere, color, &prb->distpar, obmat); - } + if (prb->parallax_type == PROBE_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 & PRB_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}}, + }; + + for (int i = 0; i < 6; ++i) { + normalize_m4_m4(prb->clipmat[i], ob->obmat); + // invert_m4(prb->clipmat[i]); + mul_m4_m4m4(prb->clipmat[i], prb->clipmat[i], cubefacemat[i]); + + DRW_shgroup_call_dynamic_add(stl->g_data->lamp_buflimit, color, &prb->clipsta, &prb->clipend, prb->clipmat[i]); + DRW_shgroup_call_dynamic_add(stl->g_data->lamp_buflimit_points, color, &prb->clipsta, &prb->clipend, prb->clipmat[i]); + } + } DRW_shgroup_call_dynamic_add(stl->g_data->lamp_center_group, ob->obmat[3]); /* Line and point going to the ground */ diff --git a/source/blender/makesdna/DNA_probe_types.h b/source/blender/makesdna/DNA_probe_types.h index ce97a898ede..88a1ba9078f 100644 --- a/source/blender/makesdna/DNA_probe_types.h +++ b/source/blender/makesdna/DNA_probe_types.h @@ -59,6 +59,7 @@ typedef struct Probe { /* Runtime display data */ float distfalloff, pad; + float clipmat[6][4][4]; } Probe; /* Probe->type */ @@ -73,6 +74,7 @@ enum { PRB_CUSTOM_PARALLAX = (1 << 0), PRB_SHOW_INFLUENCE = (1 << 1), PRB_SHOW_PARALLAX = (1 << 2), + PRB_SHOW_CLIP_DIST = (1 << 3), }; /* Probe->display */ diff --git a/source/blender/makesrna/intern/rna_probe.c b/source/blender/makesrna/intern/rna_probe.c index c9c20282195..dae84a51494 100644 --- a/source/blender/makesrna/intern/rna_probe.c +++ b/source/blender/makesrna/intern/rna_probe.c @@ -97,6 +97,11 @@ static void rna_def_probe(BlenderRNA *brna) "Probe clip end, beyond which objects will not appear in reflections"); RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_Probe_recalc"); + prop = RNA_def_property(srna, "show_clip", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PRB_SHOW_CLIP_DIST); + RNA_def_property_ui_text(prop, "Clipping", "Show the clipping distances in the 3D view"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); + prop = RNA_def_property(srna, "influence_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "attenuation_type"); RNA_def_property_enum_items(prop, parallax_type_items); @@ -105,7 +110,7 @@ static void rna_def_probe(BlenderRNA *brna) prop = RNA_def_property(srna, "show_influence", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PRB_SHOW_INFLUENCE); - RNA_def_property_ui_text(prop, "Show Influence Volume", "Show the influence volume in the 3D view"); + RNA_def_property_ui_text(prop, "Influence", "Show the influence volume in the 3D view"); RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); prop = RNA_def_property(srna, "influence_distance", PROP_FLOAT, PROP_DISTANCE); @@ -126,7 +131,7 @@ static void rna_def_probe(BlenderRNA *brna) prop = RNA_def_property(srna, "show_parallax", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PRB_SHOW_PARALLAX); - RNA_def_property_ui_text(prop, "Show Parallax Volume", "Show the parallax correction volume in the 3D view"); + RNA_def_property_ui_text(prop, "Parallax", "Show the parallax correction volume in the 3D view"); RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL); prop = RNA_def_property(srna, "parallax_type", PROP_ENUM, PROP_NONE); -- cgit v1.2.3