[Bf-blender-cvs] [c1009af596a] blender2.8: Probe: Add panel and "Add-menu" items.
Clément Foucault
noreply at git.blender.org
Fri Jun 9 01:27:19 CEST 2017
Commit: c1009af596a17e6be37d5c64746ae3b2c6b6dc7d
Author: Clément Foucault
Date: Wed Jun 7 18:32:27 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBc1009af596a17e6be37d5c64746ae3b2c6b6dc7d
Probe: Add panel and "Add-menu" items.
Also revisits defaults.
===================================================================
M release/scripts/startup/bl_ui/__init__.py
A release/scripts/startup/bl_ui/properties_data_probe.py
M release/scripts/startup/bl_ui/space_view3d.py
M source/blender/blenkernel/intern/probe.c
M source/blender/editors/object/object_add.c
M source/blender/editors/object/object_intern.h
M source/blender/editors/object/object_ops.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py
index c5772101df8..d1984649624 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -40,6 +40,7 @@ _modules = [
"properties_data_mesh",
"properties_data_metaball",
"properties_data_modifier",
+ "properties_data_probe",
"properties_data_speaker",
"properties_game",
"properties_mask_common",
diff --git a/release/scripts/startup/bl_ui/properties_data_probe.py b/release/scripts/startup/bl_ui/properties_data_probe.py
new file mode 100644
index 00000000000..e800c1ab9fa
--- /dev/null
+++ b/release/scripts/startup/bl_ui/properties_data_probe.py
@@ -0,0 +1,77 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# 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.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+import bpy
+from bpy.types import Panel
+
+
+class DataButtonsPanel:
+ bl_space_type = 'PROPERTIES'
+ bl_region_type = 'WINDOW'
+ bl_context = "data"
+
+ @classmethod
+ def poll(cls, context):
+ engine = context.scene.render.engine
+ return context.probe and (engine in cls.COMPAT_ENGINES)
+
+
+class DATA_PT_context_probe(DataButtonsPanel, Panel):
+ bl_label = ""
+ bl_options = {'HIDE_HEADER'}
+ COMPAT_ENGINES = {'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ def draw(self, context):
+ layout = self.layout
+
+ ob = context.object
+ probe = context.probe
+ space = context.space_data
+
+ if ob:
+ layout.template_ID(ob, "data")
+ elif probe:
+ layout.template_ID(space, "pin_id")
+
+
+class DATA_PT_probe(DataButtonsPanel, Panel):
+ bl_label = "Probe"
+ COMPAT_ENGINES = {'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ def draw(self, context):
+ layout = self.layout
+
+ ob = context.object
+ probe = context.probe
+
+ layout.prop(probe, "type", expand=True)
+
+ layout.prop(probe, "distance")
+ layout.prop(probe, "falloff")
+
+
+classes = (
+ DATA_PT_context_probe,
+ DATA_PT_probe,
+)
+
+if __name__ == "__main__": # only for live edit.
+ from bpy.utils import register_class
+ for cls in classes:
+ register_class(cls)
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 317d621778a..080b92bdccc 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -1205,6 +1205,17 @@ class INFO_MT_lamp_add(Menu):
layout.operator_enum("object.lamp_add", "type")
+class INFO_MT_probe_add(Menu):
+ bl_idname = "INFO_MT_probe_add"
+ bl_label = "Probe"
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.operator_context = 'INVOKE_REGION_WIN'
+ layout.operator_enum("object.probe_add", "type")
+
+
class INFO_MT_camera_add(Menu):
bl_idname = "INFO_MT_camera_add"
bl_label = "Camera"
@@ -1252,6 +1263,7 @@ class INFO_MT_add(Menu):
INFO_MT_camera_add.draw(self, context)
layout.menu("INFO_MT_lamp_add", icon='OUTLINER_OB_LAMP')
+ layout.menu("INFO_MT_probe_add")
layout.separator()
layout.operator_menu_enum("object.effector_add", "type", text="Force Field", icon='OUTLINER_OB_EMPTY')
@@ -3775,6 +3787,7 @@ classes = (
INFO_MT_edit_armature_add,
INFO_MT_armature_add,
INFO_MT_lamp_add,
+ INFO_MT_probe_add,
INFO_MT_camera_add,
INFO_MT_add,
VIEW3D_MT_object,
diff --git a/source/blender/blenkernel/intern/probe.c b/source/blender/blenkernel/intern/probe.c
index 8f26ae9d8f7..5c7ecedddd7 100644
--- a/source/blender/blenkernel/intern/probe.c
+++ b/source/blender/blenkernel/intern/probe.c
@@ -44,7 +44,8 @@ void BKE_probe_init(Probe *probe)
{
BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(probe, id));
- probe->dist = 1.5f;
+ probe->dist = 5.0f;
+ probe->falloff = 0.25f;
}
void *BKE_probe_add(Main *bmain, const char *name)
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 3c64117a2d8..f8f27f8785e 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -45,6 +45,7 @@
#include "DNA_object_fluidsim.h"
#include "DNA_object_force.h"
#include "DNA_object_types.h"
+#include "DNA_probe_types.h"
#include "DNA_scene_types.h"
#include "DNA_vfont_types.h"
#include "DNA_actuator_types.h"
@@ -151,6 +152,14 @@ static EnumPropertyItem field_type_items[] = {
{0, NULL, 0, NULL, NULL}
};
+/* copy from rna_probe.c */
+static EnumPropertyItem probe_type_items[] = {
+ {PROBE_CAPTURE, "CAPTURE", ICON_FORCE_FORCE, "Capture", ""},
+ {PROBE_PLANAR, "PLANAR", ICON_FORCE_FORCE, "Planar", ""},
+ {PROBE_CUSTOM, "CUSTOM", ICON_FORCE_FORCE, "Custom", ""},
+ {0, NULL, 0, NULL, NULL}
+};
+
/************************** Exported *****************************/
void ED_object_location_from_view(bContext *C, float loc[3])
@@ -500,6 +509,59 @@ void OBJECT_OT_add(wmOperatorType *ot)
ED_object_add_generic_props(ot, true);
}
+/********************** Add Probe Operator **********************/
+
+/* for object add operator */
+static int probe_add_exec(bContext *C, wmOperator *op)
+{
+ Object *ob;
+ Probe *probe;
+ int type;
+ bool enter_editmode;
+ unsigned int layer;
+ float loc[3], rot[3];
+ float dia;
+
+ WM_operator_view3d_unit_defaults(C, op);
+ if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &layer, NULL))
+ return OPERATOR_CANCELLED;
+
+ type = RNA_enum_get(op->ptr, "type");
+ dia = RNA_float_get(op->ptr, "radius");
+
+ const char *name = CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Probe");
+ ob = ED_object_add_type(C, OB_PROBE, name, loc, rot, false, layer);
+ BKE_object_obdata_size_init(ob, dia);
+
+ probe = (Probe *)ob->data;
+ probe->type = type;
+
+ DAG_relations_tag_update(CTX_data_main(C));
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_probe_add(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Add Probe";
+ ot->description = "Add a probe object";
+ ot->idname = "OBJECT_OT_probe_add";
+
+ /* api callbacks */
+ ot->exec = probe_add_exec;
+ ot->poll = ED_operator_objectmode;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ ot->prop = RNA_def_enum(ot->srna, "type", probe_type_items, 0, "Type", "");
+
+ ED_object_add_unit_props(ot);
+ ED_object_add_generic_props(ot, true);
+}
+
/********************* Add Effector Operator ********************/
/* for object add operator */
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index ed64f1c8ec1..a03bb17dc2a 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -112,6 +112,7 @@ void OBJECT_OT_metaball_add(struct wmOperatorType *ot);
void OBJECT_OT_text_add(struct wmOperatorType *ot);
void OBJECT_OT_armature_add(struct wmOperatorType *ot);
void OBJECT_OT_empty_add(struct wmOperatorType *ot);
+void OBJECT_OT_probe_add(struct wmOperatorType *ot);
void OBJECT_OT_drop_named_image(struct wmOperatorType *ot);
void OBJECT_OT_lamp_add(struct wmOperatorType *ot);
void OBJECT_OT_effector_add(struct wmOperatorType *ot);
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index 5641f62ec7a..8e50db725e3 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -107,6 +107,7 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_text_add);
WM_operatortype_append(OBJECT_OT_armature_add);
WM_operatortype_append(OBJECT_OT_empty_add);
+ WM_operatortype_append(OBJECT_OT_probe_add);
WM_operatortype_append(OBJECT_OT_drop_named_image);
WM_operatortype_append(OBJECT_OT_lamp_add);
WM_operatortype_append(OBJECT_OT_camera_add);
More information about the Bf-blender-cvs
mailing list