move api functions from r57909 into BKE.

This commit is contained in:
2013-07-01 20:27:03 +00:00
parent 11145c7c22
commit 3d845b4a17
5 changed files with 33 additions and 37 deletions

View File

@@ -79,6 +79,8 @@ void BKE_object_copy_proxy_drivers(struct Object *ob, struct Object *target);
void BKE_object_unlink(struct Object *ob);
bool BKE_object_exists_check(struct Object *obtest);
bool BKE_object_is_in_editmode(struct Object *ob);
bool BKE_object_is_in_editmode_vgroup(struct Object *ob);
bool BKE_object_is_in_wpaint_select_vert(struct Object *ob);
struct Object *BKE_object_add_only_object(struct Main *bmain, int type, const char *name);
struct Object *BKE_object_add(struct Main *bmain, struct Scene *scene, int type);

View File

@@ -764,6 +764,24 @@ bool BKE_object_is_in_editmode(Object *ob)
return false;
}
bool BKE_object_is_in_editmode_vgroup(Object *ob)
{
return (OB_TYPE_SUPPORT_VGROUP(ob->type) &&
BKE_object_is_in_editmode(ob));
}
bool BKE_object_is_in_wpaint_select_vert(Object *ob)
{
if (ob->type == OB_MESH) {
Mesh *me = ob->data;
return ( (ob->mode & OB_MODE_WEIGHT_PAINT) &&
(me->edit_btmesh == NULL) &&
(ME_EDIT_PAINT_SEL_MODE(me) == SCE_SELECT_VERTEX) );
}
return false;
}
bool BKE_object_exists_check(Object *obtest)
{
Object *ob;

View File

@@ -214,9 +214,6 @@ struct EnumPropertyItem *ED_object_vgroup_selection_itemf_helper(
int *free,
const unsigned int selection_mask);
bool ED_vgroup_object_in_edit_mode(struct Object *ob);
bool ED_vgroup_object_in_wpaint_vert_select(struct Object *ob);
#ifdef __cplusplus
}
#endif

View File

@@ -2775,35 +2775,13 @@ static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *dg)
}
}
bool ED_vgroup_object_in_edit_mode(Object *ob)
{
if (ob->type == OB_MESH)
return (BKE_editmesh_from_object(ob) != NULL);
else if (ob->type == OB_LATTICE)
return (((Lattice *)ob->data)->editlatt != NULL);
return false;
}
bool ED_vgroup_object_in_wpaint_vert_select(Object *ob)
{
if (ob->type == OB_MESH) {
Mesh *me = ob->data;
return ( (ob->mode & OB_MODE_WEIGHT_PAINT) &&
(me->edit_btmesh == NULL) &&
(ME_EDIT_PAINT_SEL_MODE(me) == SCE_SELECT_VERTEX) );
}
return false;
}
static void vgroup_delete(Object *ob)
{
bDeformGroup *dg = BLI_findlink(&ob->defbase, ob->actdef - 1);
if (!dg)
return;
if (ED_vgroup_object_in_edit_mode(ob))
if (BKE_object_is_in_editmode_vgroup(ob))
vgroup_delete_edit_mode(ob, dg);
else
vgroup_delete_object_mode(ob, dg);
@@ -2956,7 +2934,7 @@ static int UNUSED_FUNCTION(vertex_group_poll_edit) (bContext *C)
if (!(ob && !ob->id.lib && data && !data->lib))
return 0;
return ED_vgroup_object_in_edit_mode(ob);
return BKE_object_is_in_editmode_vgroup(ob);
}
/* editmode _or_ weight paint vertex sel */
@@ -2968,8 +2946,8 @@ static int vertex_group_vert_select_poll(bContext *C)
if (!(ob && !ob->id.lib && data && !data->lib))
return 0;
return (ED_vgroup_object_in_edit_mode(ob) ||
ED_vgroup_object_in_wpaint_vert_select(ob));
return (BKE_object_is_in_editmode_vgroup(ob) ||
BKE_object_is_in_wpaint_select_vert(ob));
}
/* editmode _or_ weight paint vertex sel and active group unlocked */
@@ -2981,8 +2959,8 @@ static int vertex_group_vert_select_unlocked_poll(bContext *C)
if (!(ob && !ob->id.lib && data && !data->lib))
return 0;
if (!(ED_vgroup_object_in_edit_mode(ob) ||
ED_vgroup_object_in_wpaint_vert_select(ob)))
if (!(BKE_object_is_in_editmode_vgroup(ob) ||
BKE_object_is_in_wpaint_select_vert(ob)))
{
return 0;
}
@@ -3008,8 +2986,8 @@ static int vertex_group_vert_select_mesh_poll(bContext *C)
if (ob->type != OB_MESH)
return 0;
return (ED_vgroup_object_in_edit_mode(ob) ||
ED_vgroup_object_in_wpaint_vert_select(ob));
return (BKE_object_is_in_editmode_vgroup(ob) ||
BKE_object_is_in_wpaint_select_vert(ob));
}
static int vertex_group_add_exec(bContext *C, wmOperator *UNUSED(op))
@@ -3076,7 +3054,7 @@ void OBJECT_OT_vertex_group_remove(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "all", 0, "All", "Remove all vertex groups");
}
static int vertex_group_assign_exec(bContext *C, wmOperator *op)
static int vertex_group_assign_exec(bContext *C, wmOperator *UNUSED(op))
{
ToolSettings *ts = CTX_data_tool_settings(C);
Object *ob = ED_object_context(C);
@@ -3513,7 +3491,7 @@ static int vertex_group_blend_poll(bContext *C)
if (!(ob && !ob->id.lib && data && !data->lib))
return false;
if (ED_vgroup_object_in_edit_mode(ob)) {
if (BKE_object_is_in_editmode_vgroup(ob)) {
return true;
}
else if ((ob->type == OB_MESH) && (ob->mode & OB_MODE_WEIGHT_PAINT)) {

View File

@@ -798,8 +798,9 @@ static int view3d_panel_vgroup_poll(const bContext *C, PanelType *UNUSED(pt))
{
Scene *scene = CTX_data_scene(C);
Object *ob = OBACT;
if (ob && (ED_vgroup_object_in_edit_mode(ob) ||
ED_vgroup_object_in_wpaint_vert_select(ob))) {
if (ob && (BKE_object_is_in_editmode_vgroup(ob) ||
BKE_object_is_in_wpaint_select_vert(ob)))
{
MDeformVert *dvert_act = ED_mesh_active_dvert_get_only(ob);
if (dvert_act) {
return (dvert_act->totweight != 0);