diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2010-06-17 11:33:57 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2010-06-17 11:33:57 +0400 |
commit | 3d562ddaa9d7f07b505a0a25516f06dde6fadcec (patch) | |
tree | eef4e9a07a84bce34b6a5ba2c147ee359ead5bdf /source/blender/editors/space_logic | |
parent | 3173232bfa1e6878088cdbb0134fe709a1f757bd (diff) |
logic ops: accepting no object as argument into "remove s/c/a" operators (uses the active object in those cases)
Diffstat (limited to 'source/blender/editors/space_logic')
-rw-r--r-- | source/blender/editors/space_logic/logic_ops.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/source/blender/editors/space_logic/logic_ops.c b/source/blender/editors/space_logic/logic_ops.c index 1f5eddaa77f..5a7a6ba839d 100644 --- a/source/blender/editors/space_logic/logic_ops.c +++ b/source/blender/editors/space_logic/logic_ops.c @@ -110,8 +110,14 @@ static bSensor *edit_sensor_property_get(bContext *C, wmOperator *op, Object **o RNA_string_get(op->ptr, "sensor", sensor_name); RNA_string_get(op->ptr, "object", ob_name); - - *ob = BLI_findstring(&(CTX_data_main(C)->object), ob_name, offsetof(ID, name) + 2); + + /* if ob_name is valid try to find the object with this name + otherwise gets the active object */ + if (ob_name[0] != '\0' ) + *ob = BLI_findstring(&(CTX_data_main(C)->object), ob_name, offsetof(ID, name) + 2); + else + *ob= ED_object_active_context(C); + if (!*ob) return NULL; @@ -152,8 +158,14 @@ static bController *edit_controller_property_get(bContext *C, wmOperator *op, Ob RNA_string_get(op->ptr, "controller", controller_name); RNA_string_get(op->ptr, "object", ob_name); - - *ob = BLI_findstring(&(CTX_data_main(C)->object), ob_name, offsetof(ID, name) + 2); + + /* if ob_name is valid try to find the object with this name + otherwise gets the active object */ + if (ob_name[0] != '\0' ) + *ob = BLI_findstring(&(CTX_data_main(C)->object), ob_name, offsetof(ID, name) + 2); + else + *ob= ED_object_active_context(C); + if (!*ob) return NULL; @@ -194,8 +206,14 @@ static bController *edit_actuator_property_get(bContext *C, wmOperator *op, Obje RNA_string_get(op->ptr, "actuator", actuator_name); RNA_string_get(op->ptr, "object", ob_name); - - *ob = BLI_findstring(&(CTX_data_main(C)->object), ob_name, offsetof(ID, name) + 2); + + /* if ob_name is valid try to find the object with this name + otherwise gets the active object */ + if (ob_name[0] != '\0' ) + *ob = BLI_findstring(&(CTX_data_main(C)->object), ob_name, offsetof(ID, name) + 2); + else + *ob= ED_object_active_context(C); + if (!*ob) return NULL; |