2009-01-07 19:23:22 +00:00
|
|
|
/**
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
|
|
|
|
* ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "DNA_cloth_types.h"
|
|
|
|
|
#include "DNA_curve_types.h"
|
|
|
|
|
#include "DNA_lattice_types.h"
|
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
|
#include "DNA_meshdata_types.h"
|
|
|
|
|
#include "DNA_modifier_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
#include "DNA_object_force.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
#include "DNA_particle_types.h"
|
2009-02-14 21:31:34 +00:00
|
|
|
#include "DNA_windowmanager_types.h"
|
2009-01-07 19:23:22 +00:00
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
#include "BLI_editVert.h"
|
|
|
|
|
|
2009-07-01 22:25:49 +00:00
|
|
|
#include "BKE_context.h"
|
2009-01-07 19:23:22 +00:00
|
|
|
#include "BKE_customdata.h"
|
|
|
|
|
#include "BKE_deform.h"
|
2009-07-01 22:25:49 +00:00
|
|
|
#include "BKE_depsgraph.h"
|
|
|
|
|
#include "BKE_DerivedMesh.h"
|
2009-01-07 19:23:22 +00:00
|
|
|
#include "BKE_displist.h"
|
|
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_lattice.h"
|
|
|
|
|
#include "BKE_mesh.h"
|
2009-08-17 02:49:31 +00:00
|
|
|
#include "BKE_paint.h"
|
2009-01-07 19:23:22 +00:00
|
|
|
#include "BKE_utildefines.h"
|
|
|
|
|
|
2009-07-01 22:25:49 +00:00
|
|
|
#include "RNA_access.h"
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
#include "RNA_define.h"
|
2009-07-01 22:25:49 +00:00
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
2009-01-07 19:23:22 +00:00
|
|
|
#include "ED_mesh.h"
|
|
|
|
|
#include "ED_view3d.h"
|
2009-07-01 22:25:49 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
#include "UI_interface.h"
|
|
|
|
|
|
2009-07-01 22:25:49 +00:00
|
|
|
#include "object_intern.h"
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/************************ Exported Functions **********************/
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
static Lattice *vgroup_edit_lattice(Object *ob)
|
2009-01-13 15:18:41 +00:00
|
|
|
{
|
|
|
|
|
if(ob->type==OB_LATTICE) {
|
|
|
|
|
Lattice *lt= ob->data;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
return (lt->editlatt)? lt->editlatt: lt;
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
return NULL;
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* check if deform vertex has defgroup index */
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
MDeformWeight *ED_vgroup_weight_get(MDeformVert *dv, int defgroup)
|
2009-01-07 19:23:22 +00:00
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(!dv || defgroup<0)
|
2009-01-07 19:23:22 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
for(i=0; i<dv->totweight; i++)
|
|
|
|
|
if(dv->dw[i].def_nr == defgroup)
|
2009-01-07 19:23:22 +00:00
|
|
|
return dv->dw+i;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2009-01-07 19:23:22 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* Ensures that mv has a deform weight entry for the specified defweight group */
|
2009-01-07 19:23:22 +00:00
|
|
|
/* Note this function is mirrored in editmesh_tools.c, for use for editvertices */
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
MDeformWeight *ED_vgroup_weight_verify(MDeformVert *dv, int defgroup)
|
2009-01-07 19:23:22 +00:00
|
|
|
{
|
|
|
|
|
MDeformWeight *newdw;
|
|
|
|
|
|
|
|
|
|
/* do this check always, this function is used to check for it */
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(!dv || defgroup<0)
|
2009-01-07 19:23:22 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
newdw = ED_vgroup_weight_get(dv, defgroup);
|
|
|
|
|
if(newdw)
|
2009-01-07 19:23:22 +00:00
|
|
|
return newdw;
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
newdw = MEM_callocN(sizeof(MDeformWeight)*(dv->totweight+1), "deformWeight");
|
|
|
|
|
if(dv->dw) {
|
|
|
|
|
memcpy(newdw, dv->dw, sizeof(MDeformWeight)*dv->totweight);
|
|
|
|
|
MEM_freeN(dv->dw);
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
dv->dw=newdw;
|
|
|
|
|
|
|
|
|
|
dv->dw[dv->totweight].weight=0.0f;
|
|
|
|
|
dv->dw[dv->totweight].def_nr=defgroup;
|
|
|
|
|
/* Group index */
|
|
|
|
|
|
|
|
|
|
dv->totweight++;
|
|
|
|
|
|
|
|
|
|
return dv->dw+(dv->totweight-1);
|
|
|
|
|
}
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
bDeformGroup *ED_vgroup_add_name(Object *ob, char *name)
|
2009-01-07 19:23:22 +00:00
|
|
|
{
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
bDeformGroup *defgroup;
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(!ob)
|
2009-01-07 19:23:22 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
defgroup = MEM_callocN(sizeof(bDeformGroup), "add deformGroup");
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
BLI_strncpy(defgroup->name, name, 32);
|
2009-01-07 19:23:22 +00:00
|
|
|
|
|
|
|
|
BLI_addtail(&ob->defbase, defgroup);
|
|
|
|
|
unique_vertexgroup_name(defgroup, ob);
|
|
|
|
|
|
|
|
|
|
ob->actdef = BLI_countlist(&ob->defbase);
|
|
|
|
|
|
|
|
|
|
return defgroup;
|
|
|
|
|
}
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
bDeformGroup *ED_vgroup_add(Object *ob)
|
2009-01-07 19:23:22 +00:00
|
|
|
{
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
return ED_vgroup_add_name(ob, "Group");
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
void ED_vgroup_data_create(ID *id)
|
2009-01-07 19:23:22 +00:00
|
|
|
{
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* create deform verts */
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(GS(id->name)==ID_ME) {
|
|
|
|
|
Mesh *me= (Mesh *)id;
|
|
|
|
|
me->dvert= CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, me->totvert);
|
2009-06-08 20:08:19 +00:00
|
|
|
}
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
else if(GS(id->name)==ID_LT) {
|
|
|
|
|
Lattice *lt= (Lattice *)id;
|
|
|
|
|
lt->dvert= MEM_callocN(sizeof(MDeformVert)*lt->pntsu*lt->pntsv*lt->pntsw, "lattice deformVert");
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* for mesh in object mode
|
|
|
|
|
lattice can be in editmode */
|
|
|
|
|
void ED_vgroup_nr_vert_remove(Object *ob, int def_nr, int vertnum)
|
2009-01-07 19:23:22 +00:00
|
|
|
{
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* This routine removes the vertex from the deform
|
|
|
|
|
* group with number def_nr.
|
|
|
|
|
*
|
|
|
|
|
* This routine is meant to be fast, so it is the
|
|
|
|
|
* responsibility of the calling routine to:
|
|
|
|
|
* a) test whether ob is non-NULL
|
|
|
|
|
* b) test whether ob is a mesh
|
|
|
|
|
* c) calculate def_nr
|
|
|
|
|
*/
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
MDeformWeight *newdw;
|
|
|
|
|
MDeformVert *dvert= NULL;
|
|
|
|
|
int i;
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* get the deform vertices corresponding to the
|
|
|
|
|
* vertnum
|
|
|
|
|
*/
|
|
|
|
|
if(ob->type==OB_MESH) {
|
|
|
|
|
if(((Mesh*)ob->data)->dvert)
|
|
|
|
|
dvert = ((Mesh*)ob->data)->dvert + vertnum;
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
else if(ob->type==OB_LATTICE) {
|
|
|
|
|
Lattice *lt= vgroup_edit_lattice(ob);
|
|
|
|
|
|
|
|
|
|
if(lt->dvert)
|
|
|
|
|
dvert = lt->dvert + vertnum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(dvert==NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* for all of the deform weights in the
|
|
|
|
|
* deform vert
|
|
|
|
|
*/
|
|
|
|
|
for(i=dvert->totweight - 1 ; i>=0 ; i--){
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* if the def_nr is the same as the one
|
|
|
|
|
* for our weight group then remove it
|
|
|
|
|
* from this deform vert.
|
|
|
|
|
*/
|
|
|
|
|
if(dvert->dw[i].def_nr == def_nr) {
|
|
|
|
|
dvert->totweight--;
|
|
|
|
|
|
|
|
|
|
/* if there are still other deform weights
|
|
|
|
|
* attached to this vert then remove this
|
|
|
|
|
* deform weight, and reshuffle the others
|
|
|
|
|
*/
|
|
|
|
|
if(dvert->totweight) {
|
|
|
|
|
newdw = MEM_mallocN(sizeof(MDeformWeight)*(dvert->totweight),
|
|
|
|
|
"deformWeight");
|
|
|
|
|
if(dvert->dw){
|
|
|
|
|
memcpy(newdw, dvert->dw, sizeof(MDeformWeight)*i);
|
|
|
|
|
memcpy(newdw+i, dvert->dw+i+1,
|
|
|
|
|
sizeof(MDeformWeight)*(dvert->totweight-i));
|
|
|
|
|
MEM_freeN(dvert->dw);
|
|
|
|
|
}
|
|
|
|
|
dvert->dw=newdw;
|
|
|
|
|
}
|
|
|
|
|
/* if there are no other deform weights
|
|
|
|
|
* left then just remove the deform weight
|
|
|
|
|
*/
|
|
|
|
|
else {
|
|
|
|
|
MEM_freeN(dvert->dw);
|
|
|
|
|
dvert->dw = NULL;
|
|
|
|
|
break;
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* for Mesh in Object mode */
|
|
|
|
|
/* allows editmode for Lattice */
|
|
|
|
|
void ED_vgroup_nr_vert_add(Object *ob, int def_nr, int vertnum, float weight, int assignmode)
|
2009-01-07 19:23:22 +00:00
|
|
|
{
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* add the vert to the deform group with the
|
|
|
|
|
* specified number
|
|
|
|
|
*/
|
|
|
|
|
MDeformVert *dv= NULL;
|
|
|
|
|
MDeformWeight *newdw;
|
|
|
|
|
int i;
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* get the vert */
|
|
|
|
|
if(ob->type==OB_MESH) {
|
|
|
|
|
if(((Mesh*)ob->data)->dvert)
|
|
|
|
|
dv = ((Mesh*)ob->data)->dvert + vertnum;
|
2009-06-08 20:08:19 +00:00
|
|
|
}
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
else if(ob->type==OB_LATTICE) {
|
|
|
|
|
Lattice *lt= vgroup_edit_lattice(ob);
|
|
|
|
|
|
|
|
|
|
if(lt->dvert)
|
|
|
|
|
dv = lt->dvert + vertnum;
|
2009-06-08 20:08:19 +00:00
|
|
|
}
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(dv==NULL)
|
2009-01-07 19:23:22 +00:00
|
|
|
return;
|
2009-06-08 20:08:19 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* Lets first check to see if this vert is
|
|
|
|
|
* already in the weight group -- if so
|
|
|
|
|
* lets update it
|
|
|
|
|
*/
|
|
|
|
|
for(i=0; i<dv->totweight; i++){
|
|
|
|
|
|
|
|
|
|
/* if this weight cooresponds to the
|
|
|
|
|
* deform group, then add it using
|
|
|
|
|
* the assign mode provided
|
|
|
|
|
*/
|
|
|
|
|
if(dv->dw[i].def_nr == def_nr){
|
|
|
|
|
|
|
|
|
|
switch(assignmode) {
|
|
|
|
|
case WEIGHT_REPLACE:
|
|
|
|
|
dv->dw[i].weight=weight;
|
|
|
|
|
break;
|
|
|
|
|
case WEIGHT_ADD:
|
|
|
|
|
dv->dw[i].weight+=weight;
|
|
|
|
|
if(dv->dw[i].weight >= 1.0)
|
|
|
|
|
dv->dw[i].weight = 1.0;
|
|
|
|
|
break;
|
|
|
|
|
case WEIGHT_SUBTRACT:
|
|
|
|
|
dv->dw[i].weight-=weight;
|
|
|
|
|
/* if the weight is zero or less then
|
|
|
|
|
* remove the vert from the deform group
|
|
|
|
|
*/
|
|
|
|
|
if(dv->dw[i].weight <= 0.0)
|
|
|
|
|
ED_vgroup_nr_vert_remove(ob, def_nr, vertnum);
|
|
|
|
|
break;
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
return;
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* if the vert wasn't in the deform group then
|
|
|
|
|
* we must take a different form of action ...
|
|
|
|
|
*/
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
switch(assignmode) {
|
2009-01-07 19:23:22 +00:00
|
|
|
case WEIGHT_SUBTRACT:
|
|
|
|
|
/* if we are subtracting then we don't
|
|
|
|
|
* need to do anything
|
|
|
|
|
*/
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case WEIGHT_REPLACE:
|
|
|
|
|
case WEIGHT_ADD:
|
|
|
|
|
/* if we are doing an additive assignment, then
|
|
|
|
|
* we need to create the deform weight
|
|
|
|
|
*/
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
newdw = MEM_callocN(sizeof(MDeformWeight)*(dv->totweight+1),
|
2009-01-07 19:23:22 +00:00
|
|
|
"deformWeight");
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(dv->dw){
|
|
|
|
|
memcpy(newdw, dv->dw, sizeof(MDeformWeight)*dv->totweight);
|
|
|
|
|
MEM_freeN(dv->dw);
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
dv->dw=newdw;
|
|
|
|
|
|
|
|
|
|
dv->dw[dv->totweight].weight=weight;
|
|
|
|
|
dv->dw[dv->totweight].def_nr=def_nr;
|
|
|
|
|
|
|
|
|
|
dv->totweight++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* called while not in editmode */
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
void ED_vgroup_vert_add(Object *ob, bDeformGroup *dg, int vertnum, float weight, int assignmode)
|
2009-01-07 19:23:22 +00:00
|
|
|
{
|
|
|
|
|
/* add the vert to the deform group with the
|
|
|
|
|
* specified assign mode
|
|
|
|
|
*/
|
|
|
|
|
int def_nr;
|
|
|
|
|
|
|
|
|
|
/* get the deform group number, exit if
|
|
|
|
|
* it can't be found
|
|
|
|
|
*/
|
|
|
|
|
def_nr = get_defgroup_num(ob, dg);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(def_nr < 0) return;
|
2009-01-07 19:23:22 +00:00
|
|
|
|
|
|
|
|
/* if there's no deform verts then
|
|
|
|
|
* create some
|
|
|
|
|
*/
|
|
|
|
|
if(ob->type==OB_MESH) {
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(!((Mesh*)ob->data)->dvert)
|
|
|
|
|
ED_vgroup_data_create(ob->data);
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
else if(ob->type==OB_LATTICE) {
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(!((Lattice*)ob->data)->dvert)
|
|
|
|
|
ED_vgroup_data_create(ob->data);
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* call another function to do the work
|
|
|
|
|
*/
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
ED_vgroup_nr_vert_add(ob, def_nr, vertnum, weight, assignmode);
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* mesh object mode, lattice can be in editmode */
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
void ED_vgroup_vert_remove(Object *ob, bDeformGroup *dg, int vertnum)
|
2009-01-07 19:23:22 +00:00
|
|
|
{
|
|
|
|
|
/* This routine removes the vertex from the specified
|
|
|
|
|
* deform group.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
int def_nr;
|
|
|
|
|
|
|
|
|
|
/* if the object is NULL abort
|
|
|
|
|
*/
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(!ob)
|
2009-01-07 19:23:22 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* get the deform number that cooresponds
|
|
|
|
|
* to this deform group, and abort if it
|
|
|
|
|
* can not be found.
|
|
|
|
|
*/
|
|
|
|
|
def_nr = get_defgroup_num(ob, dg);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(def_nr < 0) return;
|
2009-01-07 19:23:22 +00:00
|
|
|
|
|
|
|
|
/* call another routine to do the work
|
|
|
|
|
*/
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
ED_vgroup_nr_vert_remove(ob, def_nr, vertnum);
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
static float get_vert_def_nr(Object *ob, int def_nr, int vertnum)
|
2009-01-07 19:23:22 +00:00
|
|
|
{
|
|
|
|
|
MDeformVert *dvert= NULL;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
EditVert *eve;
|
|
|
|
|
Mesh *me;
|
2009-01-07 19:23:22 +00:00
|
|
|
int i;
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* get the deform vertices corresponding to the vertnum */
|
2009-01-07 19:23:22 +00:00
|
|
|
if(ob->type==OB_MESH) {
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
me= ob->data;
|
|
|
|
|
|
|
|
|
|
if(me->edit_mesh) {
|
|
|
|
|
eve= BLI_findlink(&me->edit_mesh->verts, vertnum);
|
|
|
|
|
if(!eve) return 0.0f;
|
|
|
|
|
dvert= CustomData_em_get(&me->edit_mesh->vdata, eve->data, CD_MDEFORMVERT);
|
2009-10-12 17:16:44 +00:00
|
|
|
vertnum= 0;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
|
else
|
2009-10-12 17:16:44 +00:00
|
|
|
dvert = me->dvert;
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
else if(ob->type==OB_LATTICE) {
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
Lattice *lt= vgroup_edit_lattice(ob);
|
2009-01-07 19:23:22 +00:00
|
|
|
|
|
|
|
|
if(lt->dvert)
|
2009-10-12 17:16:44 +00:00
|
|
|
dvert = lt->dvert;
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(dvert==NULL)
|
|
|
|
|
return 0.0f;
|
|
|
|
|
|
2009-10-12 17:16:44 +00:00
|
|
|
dvert += vertnum;
|
|
|
|
|
|
2009-01-07 19:23:22 +00:00
|
|
|
for(i=dvert->totweight-1 ; i>=0 ; i--)
|
|
|
|
|
if(dvert->dw[i].def_nr == def_nr)
|
|
|
|
|
return dvert->dw[i].weight;
|
|
|
|
|
|
|
|
|
|
return 0.0f;
|
|
|
|
|
}
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
float ED_vgroup_vert_weight(Object *ob, bDeformGroup *dg, int vertnum)
|
2009-01-07 19:23:22 +00:00
|
|
|
{
|
|
|
|
|
int def_nr;
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(!ob) return 0.0f;
|
2009-01-07 19:23:22 +00:00
|
|
|
|
|
|
|
|
def_nr = get_defgroup_num(ob, dg);
|
|
|
|
|
if(def_nr < 0) return 0.0f;
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
return get_vert_def_nr(ob, def_nr, vertnum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ED_vgroup_select_by_name(Object *ob, char *name)
|
|
|
|
|
{
|
|
|
|
|
bDeformGroup *curdef;
|
|
|
|
|
int actdef= 1;
|
|
|
|
|
|
|
|
|
|
for(curdef = ob->defbase.first; curdef; curdef=curdef->next, actdef++){
|
|
|
|
|
if(!strcmp(curdef->name, name)) {
|
|
|
|
|
ob->actdef= actdef;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ob->actdef=0; // this signals on painting to create a new one, if a bone in posemode is selected */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/********************** Operator Implementations *********************/
|
|
|
|
|
|
|
|
|
|
/* only in editmode */
|
|
|
|
|
static void vgroup_select_verts(Object *ob, int select)
|
|
|
|
|
{
|
|
|
|
|
EditVert *eve;
|
|
|
|
|
MDeformVert *dvert;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if(ob->type == OB_MESH) {
|
|
|
|
|
Mesh *me= ob->data;
|
|
|
|
|
EditMesh *em = BKE_mesh_get_editmesh(me);
|
|
|
|
|
|
|
|
|
|
for(eve=em->verts.first; eve; eve=eve->next){
|
|
|
|
|
dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
|
|
|
|
|
|
|
|
|
|
if(dvert && dvert->totweight){
|
|
|
|
|
for(i=0; i<dvert->totweight; i++){
|
|
|
|
|
if(dvert->dw[i].def_nr == (ob->actdef-1)){
|
|
|
|
|
if(select) eve->f |= SELECT;
|
|
|
|
|
else eve->f &= ~SELECT;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* this has to be called, because this function operates on vertices only */
|
|
|
|
|
if(select) EM_select_flush(em); // vertices to edges/faces
|
|
|
|
|
else EM_deselect_flush(em);
|
|
|
|
|
|
|
|
|
|
BKE_mesh_end_editmesh(me, em);
|
|
|
|
|
}
|
|
|
|
|
else if(ob->type == OB_LATTICE) {
|
|
|
|
|
Lattice *lt= vgroup_edit_lattice(ob);
|
|
|
|
|
|
|
|
|
|
if(lt->dvert) {
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
int a, tot;
|
|
|
|
|
|
|
|
|
|
dvert= lt->dvert;
|
|
|
|
|
|
|
|
|
|
tot= lt->pntsu*lt->pntsv*lt->pntsw;
|
|
|
|
|
for(a=0, bp= lt->def; a<tot; a++, bp++, dvert++) {
|
|
|
|
|
for(i=0; i<dvert->totweight; i++){
|
|
|
|
|
if(dvert->dw[i].def_nr == (ob->actdef-1)) {
|
|
|
|
|
if(select) bp->f1 |= SELECT;
|
|
|
|
|
else bp->f1 &= ~SELECT;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void vgroup_duplicate(Object *ob)
|
|
|
|
|
{
|
|
|
|
|
bDeformGroup *dg, *cdg;
|
|
|
|
|
char name[32], s[32];
|
|
|
|
|
MDeformWeight *org, *cpy;
|
|
|
|
|
MDeformVert *dvert, *dvert_array=NULL;
|
|
|
|
|
int i, idg, icdg, dvert_tot=0;
|
|
|
|
|
|
|
|
|
|
dg = BLI_findlink(&ob->defbase, (ob->actdef-1));
|
|
|
|
|
if(!dg)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(strstr(dg->name, "_copy")) {
|
|
|
|
|
BLI_strncpy(name, dg->name, 32); /* will be renamed _copy.001... etc */
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_snprintf(name, 32, "%s_copy", dg->name);
|
|
|
|
|
while(get_named_vertexgroup(ob, name)) {
|
|
|
|
|
if((strlen(name) + 6) > 32) {
|
|
|
|
|
printf("Internal error: the name for the new vertex group is > 32 characters");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
strcpy(s, name);
|
|
|
|
|
BLI_snprintf(name, 32, "%s_copy", s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cdg = copy_defgroup(dg);
|
|
|
|
|
strcpy(cdg->name, name);
|
|
|
|
|
unique_vertexgroup_name(cdg, ob);
|
|
|
|
|
|
|
|
|
|
BLI_addtail(&ob->defbase, cdg);
|
|
|
|
|
|
|
|
|
|
idg = (ob->actdef-1);
|
|
|
|
|
ob->actdef = BLI_countlist(&ob->defbase);
|
|
|
|
|
icdg = (ob->actdef-1);
|
|
|
|
|
|
|
|
|
|
if(ob->type == OB_MESH) {
|
|
|
|
|
Mesh *me = get_mesh(ob);
|
|
|
|
|
dvert_array= me->dvert;
|
|
|
|
|
dvert_tot= me->totvert;
|
|
|
|
|
}
|
|
|
|
|
else if(ob->type == OB_LATTICE) {
|
|
|
|
|
Lattice *lt= (Lattice *)ob->data;
|
|
|
|
|
dvert_array= lt->dvert;
|
|
|
|
|
dvert_tot= lt->pntsu*lt->pntsv*lt->pntsw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!dvert_array)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < dvert_tot; i++) {
|
|
|
|
|
dvert = dvert_array+i;
|
|
|
|
|
org = ED_vgroup_weight_get(dvert, idg);
|
|
|
|
|
if(org) {
|
|
|
|
|
float weight = org->weight;
|
|
|
|
|
/* ED_vgroup_weight_verify re-allocs org so need to store the weight first */
|
|
|
|
|
cpy = ED_vgroup_weight_verify(dvert, icdg);
|
|
|
|
|
cpy->weight = weight;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void vgroup_delete_update_users(Object *ob, int id)
|
|
|
|
|
{
|
|
|
|
|
ExplodeModifierData *emd;
|
|
|
|
|
ModifierData *md;
|
|
|
|
|
ParticleSystem *psys;
|
|
|
|
|
ClothModifierData *clmd;
|
|
|
|
|
ClothSimSettings *clsim;
|
|
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
/* these cases don't use names to refer to vertex groups, so when
|
|
|
|
|
* they get deleted the numbers get out of sync, this corrects that */
|
|
|
|
|
|
|
|
|
|
if(ob->soft) {
|
|
|
|
|
if(ob->soft->vertgroup == id)
|
|
|
|
|
ob->soft->vertgroup= 0;
|
|
|
|
|
else if(ob->soft->vertgroup > id)
|
|
|
|
|
ob->soft->vertgroup--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(md=ob->modifiers.first; md; md=md->next) {
|
|
|
|
|
if(md->type == eModifierType_Explode) {
|
|
|
|
|
emd= (ExplodeModifierData*)md;
|
|
|
|
|
|
|
|
|
|
if(emd->vgroup == id)
|
|
|
|
|
emd->vgroup= 0;
|
|
|
|
|
else if(emd->vgroup > id)
|
|
|
|
|
emd->vgroup--;
|
|
|
|
|
}
|
|
|
|
|
else if(md->type == eModifierType_Cloth) {
|
|
|
|
|
clmd= (ClothModifierData*)md;
|
|
|
|
|
clsim= clmd->sim_parms;
|
|
|
|
|
|
|
|
|
|
if(clsim) {
|
|
|
|
|
if(clsim->vgroup_mass == id)
|
|
|
|
|
clsim->vgroup_mass= 0;
|
|
|
|
|
else if(clsim->vgroup_mass > id)
|
|
|
|
|
clsim->vgroup_mass--;
|
|
|
|
|
|
|
|
|
|
if(clsim->vgroup_bend == id)
|
|
|
|
|
clsim->vgroup_bend= 0;
|
|
|
|
|
else if(clsim->vgroup_bend > id)
|
|
|
|
|
clsim->vgroup_bend--;
|
|
|
|
|
|
|
|
|
|
if(clsim->vgroup_struct == id)
|
|
|
|
|
clsim->vgroup_struct= 0;
|
|
|
|
|
else if(clsim->vgroup_struct > id)
|
|
|
|
|
clsim->vgroup_struct--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(psys=ob->particlesystem.first; psys; psys=psys->next) {
|
|
|
|
|
for(a=0; a<PSYS_TOT_VG; a++)
|
|
|
|
|
if(psys->vgroup[a] == id)
|
|
|
|
|
psys->vgroup[a]= 0;
|
|
|
|
|
else if(psys->vgroup[a] > id)
|
|
|
|
|
psys->vgroup[a]--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void vgroup_delete_object_mode(Object *ob)
|
|
|
|
|
{
|
|
|
|
|
bDeformGroup *dg;
|
|
|
|
|
MDeformVert *dvert, *dvert_array=NULL;
|
|
|
|
|
int i, e, dvert_tot=0;
|
|
|
|
|
|
|
|
|
|
if(ob->type == OB_MESH) {
|
|
|
|
|
Mesh *me = get_mesh(ob);
|
|
|
|
|
dvert_array= me->dvert;
|
|
|
|
|
dvert_tot= me->totvert;
|
|
|
|
|
}
|
|
|
|
|
else if(ob->type == OB_LATTICE) {
|
|
|
|
|
Lattice *lt= (Lattice *)ob->data;
|
|
|
|
|
dvert_array= lt->dvert;
|
|
|
|
|
dvert_tot= lt->pntsu*lt->pntsv*lt->pntsw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dg = BLI_findlink(&ob->defbase, (ob->actdef-1));
|
|
|
|
|
if(!dg)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(dvert_array) {
|
|
|
|
|
for(i = 0; i < dvert_tot; i++) {
|
|
|
|
|
dvert = dvert_array + i;
|
|
|
|
|
if(dvert) {
|
|
|
|
|
if(ED_vgroup_weight_get(dvert, (ob->actdef-1)))
|
|
|
|
|
ED_vgroup_vert_remove(ob, dg, i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < dvert_tot; i++) {
|
|
|
|
|
dvert = dvert_array+i;
|
|
|
|
|
if(dvert) {
|
|
|
|
|
for(e = 0; e < dvert->totweight; e++) {
|
|
|
|
|
if(dvert->dw[e].def_nr > (ob->actdef-1))
|
|
|
|
|
dvert->dw[e].def_nr--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vgroup_delete_update_users(ob, ob->actdef);
|
|
|
|
|
|
|
|
|
|
/* Update the active deform index if necessary */
|
|
|
|
|
if(ob->actdef == BLI_countlist(&ob->defbase))
|
|
|
|
|
ob->actdef--;
|
|
|
|
|
|
|
|
|
|
/* Remove the group */
|
|
|
|
|
BLI_freelinkN(&ob->defbase, dg);
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* only in editmode */
|
2009-01-07 19:23:22 +00:00
|
|
|
/* removes from active defgroup, if allverts==0 only selected vertices */
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
static void vgroup_active_remove_verts(Object *ob, int allverts)
|
2009-01-07 19:23:22 +00:00
|
|
|
{
|
|
|
|
|
EditVert *eve;
|
|
|
|
|
MDeformVert *dvert;
|
|
|
|
|
MDeformWeight *newdw;
|
|
|
|
|
bDeformGroup *dg, *eg;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
dg=BLI_findlink(&ob->defbase, ob->actdef-1);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(!dg)
|
2009-01-07 19:23:22 +00:00
|
|
|
return;
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(ob->type == OB_MESH) {
|
2009-01-07 19:23:22 +00:00
|
|
|
Mesh *me= ob->data;
|
2009-04-11 08:26:51 +00:00
|
|
|
EditMesh *em = BKE_mesh_get_editmesh(me);
|
2009-03-30 07:28:37 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
for(eve=em->verts.first; eve; eve=eve->next){
|
2009-03-30 07:28:37 +00:00
|
|
|
dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(dvert && dvert->dw && ((eve->f & 1) || allverts)){
|
|
|
|
|
for(i=0; i<dvert->totweight; i++){
|
2009-01-07 19:23:22 +00:00
|
|
|
/* Find group */
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
eg = BLI_findlink(&ob->defbase, dvert->dw[i].def_nr);
|
|
|
|
|
if(eg == dg){
|
2009-01-07 19:23:22 +00:00
|
|
|
dvert->totweight--;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(dvert->totweight){
|
|
|
|
|
newdw = MEM_mallocN(sizeof(MDeformWeight)*(dvert->totweight), "deformWeight");
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(dvert->dw){
|
|
|
|
|
memcpy(newdw, dvert->dw, sizeof(MDeformWeight)*i);
|
|
|
|
|
memcpy(newdw+i, dvert->dw+i+1, sizeof(MDeformWeight)*(dvert->totweight-i));
|
|
|
|
|
MEM_freeN(dvert->dw);
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
dvert->dw=newdw;
|
|
|
|
|
}
|
|
|
|
|
else{
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
MEM_freeN(dvert->dw);
|
2009-01-07 19:23:22 +00:00
|
|
|
dvert->dw=NULL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-04-11 08:26:51 +00:00
|
|
|
BKE_mesh_end_editmesh(me, em);
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
else if(ob->type == OB_LATTICE) {
|
|
|
|
|
Lattice *lt= vgroup_edit_lattice(ob);
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2009-01-13 15:18:41 +00:00
|
|
|
if(lt->dvert) {
|
2009-01-07 19:23:22 +00:00
|
|
|
BPoint *bp;
|
2009-01-13 15:18:41 +00:00
|
|
|
int a, tot= lt->pntsu*lt->pntsv*lt->pntsw;
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2009-01-13 15:18:41 +00:00
|
|
|
for(a=0, bp= lt->def; a<tot; a++, bp++) {
|
2009-01-07 19:23:22 +00:00
|
|
|
if(allverts || (bp->f1 & SELECT))
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
ED_vgroup_vert_remove(ob, dg, a);
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-01-13 15:18:41 +00:00
|
|
|
}
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
static void vgroup_delete_edit_mode(Object *ob)
|
2009-01-07 19:23:22 +00:00
|
|
|
{
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
bDeformGroup *defgroup;
|
|
|
|
|
int i;
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(!ob->actdef)
|
2009-01-07 19:23:22 +00:00
|
|
|
return;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
|
defgroup = BLI_findlink(&ob->defbase, ob->actdef-1);
|
|
|
|
|
if(!defgroup)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Make sure that no verts are using this group */
|
|
|
|
|
vgroup_active_remove_verts(ob, 1);
|
|
|
|
|
|
|
|
|
|
/* Make sure that any verts with higher indices are adjusted accordingly */
|
|
|
|
|
if(ob->type==OB_MESH) {
|
|
|
|
|
Mesh *me= ob->data;
|
|
|
|
|
EditMesh *em = BKE_mesh_get_editmesh(me);
|
|
|
|
|
EditVert *eve;
|
|
|
|
|
MDeformVert *dvert;
|
|
|
|
|
|
|
|
|
|
for(eve=em->verts.first; eve; eve=eve->next){
|
|
|
|
|
dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
|
|
|
|
|
|
|
|
|
|
if(dvert)
|
|
|
|
|
for(i=0; i<dvert->totweight; i++)
|
|
|
|
|
if(dvert->dw[i].def_nr > (ob->actdef-1))
|
|
|
|
|
dvert->dw[i].def_nr--;
|
|
|
|
|
}
|
|
|
|
|
BKE_mesh_end_editmesh(me, em);
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
else if(ob->type==OB_LATTICE) {
|
|
|
|
|
Lattice *lt= vgroup_edit_lattice(ob);
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
MDeformVert *dvert= lt->dvert;
|
|
|
|
|
int a, tot;
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(dvert) {
|
|
|
|
|
tot= lt->pntsu*lt->pntsv*lt->pntsw;
|
|
|
|
|
for(a=0, bp= lt->def; a<tot; a++, bp++, dvert++) {
|
|
|
|
|
for(i=0; i<dvert->totweight; i++){
|
|
|
|
|
if(dvert->dw[i].def_nr > (ob->actdef-1))
|
|
|
|
|
dvert->dw[i].def_nr--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
vgroup_delete_update_users(ob, ob->actdef);
|
|
|
|
|
|
|
|
|
|
/* Update the active deform index if necessary */
|
|
|
|
|
if(ob->actdef==BLI_countlist(&ob->defbase))
|
|
|
|
|
ob->actdef--;
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* Remove the group */
|
|
|
|
|
BLI_freelinkN (&ob->defbase, defgroup);
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* remove all dverts */
|
|
|
|
|
if(ob->actdef==0) {
|
|
|
|
|
if(ob->type==OB_MESH) {
|
|
|
|
|
Mesh *me= ob->data;
|
|
|
|
|
CustomData_free_layer_active(&me->vdata, CD_MDEFORMVERT, me->totvert);
|
|
|
|
|
me->dvert= NULL;
|
|
|
|
|
}
|
|
|
|
|
else if(ob->type==OB_LATTICE) {
|
|
|
|
|
Lattice *lt= vgroup_edit_lattice(ob);
|
|
|
|
|
if(lt->dvert) {
|
|
|
|
|
MEM_freeN(lt->dvert);
|
|
|
|
|
lt->dvert= NULL;
|
|
|
|
|
}
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
static int vgroup_object_in_edit_mode(Object *ob)
|
2009-01-07 19:23:22 +00:00
|
|
|
{
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(ob->type == OB_MESH)
|
|
|
|
|
return (((Mesh*)ob->data)->edit_mesh != NULL);
|
|
|
|
|
else if(ob->type == OB_LATTICE)
|
|
|
|
|
return (((Lattice*)ob->data)->editlatt != NULL);
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void vgroup_delete(Object *ob)
|
|
|
|
|
{
|
|
|
|
|
if(vgroup_object_in_edit_mode(ob))
|
|
|
|
|
vgroup_delete_edit_mode(ob);
|
|
|
|
|
else
|
|
|
|
|
vgroup_delete_object_mode(ob);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void vgroup_delete_all(Object *ob)
|
|
|
|
|
{
|
|
|
|
|
/* Remove all DVerts */
|
|
|
|
|
if(ob->type==OB_MESH) {
|
|
|
|
|
Mesh *me= ob->data;
|
|
|
|
|
CustomData_free_layer_active(&me->vdata, CD_MDEFORMVERT, me->totvert);
|
|
|
|
|
me->dvert= NULL;
|
|
|
|
|
}
|
|
|
|
|
else if(ob->type==OB_LATTICE) {
|
|
|
|
|
Lattice *lt= vgroup_edit_lattice(ob);
|
|
|
|
|
if(lt->dvert) {
|
|
|
|
|
MEM_freeN(lt->dvert);
|
|
|
|
|
lt->dvert= NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* Remove all DefGroups */
|
|
|
|
|
BLI_freelistN(&ob->defbase);
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* Fix counters/indices */
|
|
|
|
|
ob->actdef= 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* only in editmode */
|
|
|
|
|
static void vgroup_assign_verts(Object *ob, float weight)
|
|
|
|
|
{
|
|
|
|
|
EditVert *eve;
|
|
|
|
|
bDeformGroup *dg, *eg;
|
|
|
|
|
MDeformWeight *newdw;
|
|
|
|
|
MDeformVert *dvert;
|
|
|
|
|
int i, done;
|
|
|
|
|
|
|
|
|
|
dg=BLI_findlink(&ob->defbase, ob->actdef-1);
|
|
|
|
|
|
|
|
|
|
if(ob->type == OB_MESH) {
|
|
|
|
|
Mesh *me= ob->data;
|
|
|
|
|
EditMesh *em = BKE_mesh_get_editmesh(me);
|
|
|
|
|
|
|
|
|
|
if(!CustomData_has_layer(&em->vdata, CD_MDEFORMVERT))
|
|
|
|
|
EM_add_data_layer(em, &em->vdata, CD_MDEFORMVERT);
|
|
|
|
|
|
|
|
|
|
/* Go through the list of editverts and assign them */
|
|
|
|
|
for(eve=em->verts.first; eve; eve=eve->next){
|
|
|
|
|
dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
|
|
|
|
|
|
|
|
|
|
if(dvert && (eve->f & 1)){
|
|
|
|
|
done=0;
|
|
|
|
|
/* See if this vert already has a reference to this group */
|
|
|
|
|
/* If so: Change its weight */
|
|
|
|
|
done=0;
|
|
|
|
|
for(i=0; i<dvert->totweight; i++){
|
|
|
|
|
eg = BLI_findlink(&ob->defbase, dvert->dw[i].def_nr);
|
|
|
|
|
/* Find the actual group */
|
|
|
|
|
if(eg==dg){
|
|
|
|
|
dvert->dw[i].weight= weight;
|
|
|
|
|
done=1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* If not: Add the group and set its weight */
|
|
|
|
|
if(!done){
|
|
|
|
|
newdw = MEM_callocN(sizeof(MDeformWeight)*(dvert->totweight+1), "deformWeight");
|
|
|
|
|
if(dvert->dw){
|
|
|
|
|
memcpy(newdw, dvert->dw, sizeof(MDeformWeight)*dvert->totweight);
|
|
|
|
|
MEM_freeN(dvert->dw);
|
|
|
|
|
}
|
|
|
|
|
dvert->dw=newdw;
|
|
|
|
|
|
|
|
|
|
dvert->dw[dvert->totweight].weight= weight;
|
|
|
|
|
dvert->dw[dvert->totweight].def_nr= ob->actdef-1;
|
|
|
|
|
|
|
|
|
|
dvert->totweight++;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BKE_mesh_end_editmesh(me, em);
|
|
|
|
|
}
|
|
|
|
|
else if(ob->type == OB_LATTICE) {
|
|
|
|
|
Lattice *lt= vgroup_edit_lattice(ob);
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
int a, tot;
|
|
|
|
|
|
|
|
|
|
if(lt->dvert==NULL)
|
|
|
|
|
ED_vgroup_data_create(<->id);
|
|
|
|
|
|
|
|
|
|
tot= lt->pntsu*lt->pntsv*lt->pntsw;
|
|
|
|
|
for(a=0, bp= lt->def; a<tot; a++, bp++) {
|
|
|
|
|
if(bp->f1 & SELECT)
|
|
|
|
|
ED_vgroup_nr_vert_add(ob, ob->actdef-1, a, weight, WEIGHT_REPLACE);
|
|
|
|
|
}
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* only in editmode */
|
|
|
|
|
/* removes from all defgroup, if allverts==0 only selected vertices */
|
|
|
|
|
static void vgroup_remove_verts(Object *ob, int allverts)
|
2009-01-07 19:23:22 +00:00
|
|
|
{
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
int actdef, defCount;
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
actdef= ob->actdef;
|
2009-01-07 19:23:22 +00:00
|
|
|
defCount= BLI_countlist(&ob->defbase);
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(defCount == 0)
|
|
|
|
|
return;
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
/* To prevent code redundancy, we just use vgroup_active_remove_verts, but that
|
|
|
|
|
* only operates on the active vgroup. So we iterate through all groups, by changing
|
|
|
|
|
* active group index
|
|
|
|
|
*/
|
|
|
|
|
for(ob->actdef= 1; ob->actdef <= defCount; ob->actdef++)
|
|
|
|
|
vgroup_active_remove_verts(ob, allverts);
|
|
|
|
|
|
|
|
|
|
ob->actdef= actdef;
|
2009-01-07 19:23:22 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-01 22:25:49 +00:00
|
|
|
/********************** vertex group operators *********************/
|
|
|
|
|
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
static int vertex_group_poll(bContext *C)
|
2009-07-01 22:25:49 +00:00
|
|
|
{
|
|
|
|
|
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
ID *data= (ob)? ob->data: NULL;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
return (ob && !ob->id.lib && ELEM(ob->type, OB_MESH, OB_LATTICE) && data && !data->lib);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int vertex_group_poll_edit(bContext *C)
|
|
|
|
|
{
|
|
|
|
|
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
|
|
|
|
ID *data= (ob)? ob->data: NULL;
|
|
|
|
|
|
|
|
|
|
if(!(ob && !ob->id.lib && data && !data->lib))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return vgroup_object_in_edit_mode(ob);
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
}
|
2009-07-01 22:25:49 +00:00
|
|
|
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
static int vertex_group_add_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
2009-07-01 22:25:49 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
ED_vgroup_add(ob);
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
|
|
|
|
|
WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data);
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
2009-07-01 22:25:49 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_vertex_group_add(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Add Vertex Group";
|
|
|
|
|
ot->idname= "OBJECT_OT_vertex_group_add";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
ot->poll= vertex_group_poll;
|
2009-07-01 22:25:49 +00:00
|
|
|
ot->exec= vertex_group_add_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int vertex_group_remove_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(RNA_boolean_get(op->ptr, "all"))
|
|
|
|
|
vgroup_delete_all(ob);
|
|
|
|
|
else
|
|
|
|
|
vgroup_delete(ob);
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data);
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
2009-07-01 22:25:49 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_vertex_group_remove(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Remove Vertex Group";
|
|
|
|
|
ot->idname= "OBJECT_OT_vertex_group_remove";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
ot->poll= vertex_group_poll;
|
2009-07-01 22:25:49 +00:00
|
|
|
ot->exec= vertex_group_remove_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
RNA_def_boolean(ot->srna, "all", 0, "All", "Remove from all vertex groups.");
|
2009-07-01 22:25:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int vertex_group_assign_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
ToolSettings *ts= CTX_data_tool_settings(C);
|
|
|
|
|
Object *ob= CTX_data_edit_object(C);
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
if(RNA_boolean_get(op->ptr, "new"))
|
|
|
|
|
ED_vgroup_add(ob);
|
|
|
|
|
|
|
|
|
|
vgroup_assign_verts(ob, ts->vgroup_weight);
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
|
|
|
|
|
WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data);
|
2009-07-01 22:25:49 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_vertex_group_assign(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Assign Vertex Group";
|
|
|
|
|
ot->idname= "OBJECT_OT_vertex_group_assign";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
ot->poll= vertex_group_poll_edit;
|
2009-07-01 22:25:49 +00:00
|
|
|
ot->exec= vertex_group_assign_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
RNA_def_boolean(ot->srna, "new", 0, "New", "Assign vertex to new vertex group.");
|
2009-07-01 22:25:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int vertex_group_remove_from_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Object *ob= CTX_data_edit_object(C);
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
vgroup_remove_verts(ob, 0);
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
|
|
|
|
|
WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2009-07-01 22:25:49 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_vertex_group_remove_from(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Remove from Vertex Group";
|
|
|
|
|
ot->idname= "OBJECT_OT_vertex_group_remove_from";
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2009-07-01 22:25:49 +00:00
|
|
|
/* api callbacks */
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
ot->poll= vertex_group_poll_edit;
|
2009-07-01 22:25:49 +00:00
|
|
|
ot->exec= vertex_group_remove_from_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
RNA_def_boolean(ot->srna, "all", 0, "All", "Remove from all vertex groups.");
|
2009-07-01 22:25:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int vertex_group_select_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Object *ob= CTX_data_edit_object(C);
|
|
|
|
|
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
if(!ob || ob->id.lib)
|
2009-07-01 22:25:49 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
vgroup_select_verts(ob, 1);
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, ob->data);
|
2009-07-01 22:25:49 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_vertex_group_select(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Select Vertex Group";
|
|
|
|
|
ot->idname= "OBJECT_OT_vertex_group_select";
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2009-07-01 22:25:49 +00:00
|
|
|
/* api callbacks */
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
ot->poll= vertex_group_poll_edit;
|
2009-07-01 22:25:49 +00:00
|
|
|
ot->exec= vertex_group_select_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int vertex_group_deselect_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Object *ob= CTX_data_edit_object(C);
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
vgroup_select_verts(ob, 0);
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, ob->data);
|
2009-07-01 22:25:49 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_vertex_group_deselect(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Deselect Vertex Group";
|
|
|
|
|
ot->idname= "OBJECT_OT_vertex_group_deselect";
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2009-07-01 22:25:49 +00:00
|
|
|
/* api callbacks */
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
ot->poll= vertex_group_poll_edit;
|
2009-07-01 22:25:49 +00:00
|
|
|
ot->exec= vertex_group_deselect_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int vertex_group_copy_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
vgroup_duplicate(ob);
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
|
|
|
|
WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2009-07-01 22:25:49 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_vertex_group_copy(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Copy Vertex Group";
|
|
|
|
|
ot->idname= "OBJECT_OT_vertex_group_copy";
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2009-07-01 22:25:49 +00:00
|
|
|
/* api callbacks */
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
ot->poll= vertex_group_poll;
|
2009-07-01 22:25:49 +00:00
|
|
|
ot->exec= vertex_group_copy_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int vertex_group_copy_to_linked_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
Base *base;
|
2009-07-01 22:25:49 +00:00
|
|
|
int retval= OPERATOR_CANCELLED;
|
|
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
for(base=scene->base.first; base; base= base->next) {
|
|
|
|
|
if(base->object->type==ob->type) {
|
|
|
|
|
if(base->object!=ob && base->object->data==ob->data) {
|
|
|
|
|
BLI_freelistN(&base->object->defbase);
|
|
|
|
|
BLI_duplicatelist(&base->object->defbase, &ob->defbase);
|
|
|
|
|
base->object->actdef= ob->actdef;
|
2009-07-01 22:25:49 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
DAG_id_flush_update(&base->object->id, OB_RECALC_DATA);
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, base->object);
|
|
|
|
|
WM_event_add_notifier(C, NC_GEOM|ND_DATA, base->object->data);
|
2009-07-01 22:25:49 +00:00
|
|
|
|
|
|
|
|
retval = OPERATOR_FINISHED;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-01 22:25:49 +00:00
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_vertex_group_copy_to_linked(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Copy Vertex Group to Linked";
|
|
|
|
|
ot->idname= "OBJECT_OT_vertex_group_copy_to_linked";
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
|
2009-07-01 22:25:49 +00:00
|
|
|
/* api callbacks */
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
ot->poll= vertex_group_poll;
|
2009-07-01 22:25:49 +00:00
|
|
|
ot->exec= vertex_group_copy_to_linked_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
2009-01-07 19:23:22 +00:00
|
|
|
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
static EnumPropertyItem vgroup_items[]= {
|
|
|
|
|
{0, NULL, 0, NULL, NULL}};
|
|
|
|
|
|
|
|
|
|
static int set_active_group_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
|
|
|
|
int nr= RNA_enum_get(op->ptr, "group");
|
|
|
|
|
|
|
|
|
|
ob->actdef= nr+1;
|
|
|
|
|
|
|
|
|
|
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static EnumPropertyItem *vgroup_itemf(bContext *C, PointerRNA *ptr, int *free)
|
|
|
|
|
{
|
2009-09-09 23:11:43 +00:00
|
|
|
Object *ob;
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
EnumPropertyItem tmp = {0, "", 0, "", ""};
|
|
|
|
|
EnumPropertyItem *item= NULL;
|
|
|
|
|
bDeformGroup *def;
|
|
|
|
|
int a, totitem= 0;
|
|
|
|
|
|
2009-09-09 23:11:43 +00:00
|
|
|
if(!C || !(ob = CTX_data_pointer_get_type(C, "object", &RNA_Object).data)) /* needed for docs */
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
return vgroup_items;
|
|
|
|
|
|
|
|
|
|
for(a=0, def=ob->defbase.first; def; def=def->next, a++) {
|
|
|
|
|
tmp.value= a;
|
|
|
|
|
tmp.identifier= def->name;
|
|
|
|
|
tmp.name= def->name;
|
|
|
|
|
RNA_enum_item_add(&item, &totitem, &tmp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RNA_enum_item_end(&item, &totitem);
|
|
|
|
|
|
|
|
|
|
*free= 1;
|
|
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_vertex_group_set_active(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Set Active Vertex Group";
|
|
|
|
|
ot->idname= "OBJECT_OT_vertex_group_set_active";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->poll= vertex_group_poll;
|
|
|
|
|
ot->exec= set_active_group_exec;
|
|
|
|
|
ot->invoke= WM_menu_invoke;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
prop= RNA_def_enum(ot->srna, "group", vgroup_items, 0, "Group", "Vertex group to set as active.");
|
|
|
|
|
RNA_def_enum_funcs(prop, vgroup_itemf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int vertex_group_menu_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
|
|
|
|
uiPopupMenu *pup;
|
|
|
|
|
uiLayout *layout;
|
|
|
|
|
|
|
|
|
|
pup= uiPupMenuBegin(C, "Vertex Groups", 0);
|
|
|
|
|
layout= uiPupMenuLayout(pup);
|
|
|
|
|
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN);
|
|
|
|
|
|
|
|
|
|
if(vgroup_object_in_edit_mode(ob)) {
|
|
|
|
|
uiItemBooleanO(layout, "Assign to New Group", 0, "OBJECT_OT_vertex_group_assign", "new", 1);
|
|
|
|
|
|
|
|
|
|
if(BLI_countlist(&ob->defbase) && ob->actdef) {
|
|
|
|
|
uiItemO(layout, "Assign to Group", 0, "OBJECT_OT_vertex_group_assign");
|
|
|
|
|
uiItemO(layout, "Remove from Group", 0, "OBJECT_OT_vertex_group_remove_from");
|
|
|
|
|
uiItemBooleanO(layout, "Remove from All", 0, "OBJECT_OT_vertex_group_remove_from", "all", 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(BLI_countlist(&ob->defbase) && ob->actdef) {
|
|
|
|
|
if(vgroup_object_in_edit_mode(ob))
|
|
|
|
|
uiItemS(layout);
|
|
|
|
|
|
|
|
|
|
uiItemO(layout, "Set Active Group", 0, "OBJECT_OT_vertex_group_set_active");
|
|
|
|
|
uiItemO(layout, "Remove Group", 0, "OBJECT_OT_vertex_group_remove");
|
|
|
|
|
uiItemBooleanO(layout, "Remove All Groups", 0, "OBJECT_OT_vertex_group_remove", "all", 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uiPupMenuEnd(C, pup);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_vertex_group_menu(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Vertex Group Menu";
|
|
|
|
|
ot->idname= "OBJECT_OT_vertex_group_menu";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->poll= vertex_group_poll;
|
|
|
|
|
ot->exec= vertex_group_menu_exec;
|
|
|
|
|
}
|
|
|
|
|
|