From 5e4bc5a4f8d1fd5fa6e10afe4091fed77a39768e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 28 Dec 2012 11:24:07 +0000 Subject: patch [#33687] select similar lamp by Saurabh Wankhade (sauraedron), with some edits. --- source/blender/editors/object/object_select.c | 28 ++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/object/object_select.c') diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 2aa737d204d..07eca749a74 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -42,6 +42,7 @@ #include "DNA_property_types.h" #include "DNA_scene_types.h" #include "DNA_armature_types.h" +#include "DNA_lamp_types.h" #include "BLI_math.h" #include "BLI_listbase.h" @@ -525,6 +526,7 @@ static EnumPropertyItem prop_select_grouped_types[] = { {10, "COLOR", 0, "Color", "Object Color"}, {11, "PROPERTIES", 0, "Properties", "Game Properties"}, {12, "KEYINGSET", 0, "Keying Set", "Objects included in active Keying Set"}, + {13, "LAMP_TYPE", 0, "Lamp Type", "Matching lamp types"}, {0, NULL, 0, NULL, NULL} }; @@ -656,7 +658,25 @@ static short select_grouped_siblings(bContext *C, Object *ob) CTX_DATA_END; return changed; } +static short select_similar_lamps(bContext *C, Object *ob) +{ + Lamp *la = ob->data; + + short changed = 0; + CTX_DATA_BEGIN (C, Base *, base, selectable_bases) + { + if (base->object->type == OB_LAMP) { + Lamp *la_test = base->object->data; + if ((la->type == la_test->type) && !(base->flag & SELECT)) { + ED_base_object_select(base, BA_SELECT); + changed = 1; + } + } + } + CTX_DATA_END; + return changed; +} static short select_grouped_type(bContext *C, Object *ob) { short changed = 0; @@ -803,7 +823,12 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No active object"); return OPERATOR_CANCELLED; } - + + if (nr == 13 && ob->type != OB_LAMP) { + BKE_report(op->reports, RPT_ERROR, "Active object must be a lamp"); + return OPERATOR_CANCELLED; + } + if (nr == 1) changed |= select_grouped_children(C, ob, 1); else if (nr == 2) changed |= select_grouped_children(C, ob, 0); else if (nr == 3) changed |= select_grouped_parent(C); @@ -816,6 +841,7 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op) else if (nr == 10) changed |= select_grouped_color(C, ob); else if (nr == 11) changed |= select_grouped_gameprops(C, ob); else if (nr == 12) changed |= select_grouped_keyingset(C, ob); + else if (nr == 13) changed |= select_similar_lamps(C, ob); if (changed) { WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); -- cgit v1.2.3