[Bf-blender-cvs] [2ba081f59bc] master: Curves: disable Empty Hair operator when there is no active mesh

Jacques Lucke noreply at git.blender.org
Fri May 6 15:17:57 CEST 2022


Commit: 2ba081f59bc62f1fc7f59a6391c001c5a9281c53
Author: Jacques Lucke
Date:   Fri May 6 15:17:44 2022 +0200
Branches: master
https://developer.blender.org/rB2ba081f59bc62f1fc7f59a6391c001c5a9281c53

Curves: disable Empty Hair operator when there is no active mesh

===================================================================

M	source/blender/editors/object/object_add.cc

===================================================================

diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc
index 4b838297b7b..820f500d172 100644
--- a/source/blender/editors/object/object_add.cc
+++ b/source/blender/editors/object/object_add.cc
@@ -2116,6 +2116,21 @@ static int object_curves_empty_hair_add_exec(bContext *C, wmOperator *op)
   return OPERATOR_FINISHED;
 }
 
+static bool object_curves_empty_hair_add_poll(bContext *C)
+{
+  if (!U.experimental.use_new_curves_type) {
+    return false;
+  }
+  if (!ED_operator_objectmode(C)) {
+    return false;
+  }
+  Object *ob = CTX_data_active_object(C);
+  if (ob == nullptr || ob->type != OB_MESH) {
+    return false;
+  }
+  return true;
+}
+
 void OBJECT_OT_curves_empty_hair_add(wmOperatorType *ot)
 {
   ot->name = "Add Empty Curves";
@@ -2123,7 +2138,7 @@ void OBJECT_OT_curves_empty_hair_add(wmOperatorType *ot)
   ot->idname = "OBJECT_OT_curves_empty_hair_add";
 
   ot->exec = object_curves_empty_hair_add_exec;
-  ot->poll = object_curves_add_poll;
+  ot->poll = object_curves_empty_hair_add_poll;
 
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;



More information about the Bf-blender-cvs mailing list