rna api
obj.add_vertex_group() --> obj.vertex_groups.new() obj.add_vertex_to_group() --> obj.vertex_groups.assign() note: obj.vertex_groups.assign() will be very slow, need to have this take a list rather then 1 vertex at a time.
This commit is contained in:
@@ -821,11 +821,9 @@ def create_mesh(new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_loc, v
|
||||
# content of the vertex_groups. If the user selects to NOT have vertex groups saved then
|
||||
# the following test will never run
|
||||
for group_name, group_indicies in vertex_groups.items():
|
||||
group= ob.add_vertex_group(group_name)
|
||||
# me.addVertGroup(group_name)
|
||||
group= ob.vertex_groups.new(group_name)
|
||||
for vertex_index in group_indicies:
|
||||
ob.add_vertex_to_group(vertex_index, group, 1.0, 'REPLACE')
|
||||
# me.assignVertsToGroup(group_name, group_indicies, 1.00, Mesh.AssignModes.REPLACE)
|
||||
ob.vertex_groups.assign(vertex_index, group, 1.0, 'REPLACE')
|
||||
|
||||
|
||||
def create_nurbs(context_nurbs, vert_loc, new_objects):
|
||||
|
||||
@@ -83,7 +83,7 @@ bDeformGroup *ED_vgroup_add_name(Object *ob, char *name)
|
||||
{
|
||||
bDeformGroup *defgroup;
|
||||
|
||||
if(!ob)
|
||||
if(!ob || !ELEM(ob->type, OB_MESH, OB_LATTICE))
|
||||
return NULL;
|
||||
|
||||
defgroup = MEM_callocN(sizeof(bDeformGroup), "add deformGroup");
|
||||
|
||||
@@ -41,6 +41,9 @@
|
||||
#include "DNA_property_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "BLO_sys_types.h" /* needed for intptr_t used in ED_mesh.h */
|
||||
#include "ED_mesh.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
@@ -1055,6 +1058,12 @@ static void rna_Object_boundbox_get(PointerRNA *ptr, float *values)
|
||||
|
||||
}
|
||||
|
||||
static void rna_Object_add_vertex_to_group(Object *ob, int vertex_index, bDeformGroup *def, float weight, int assignmode)
|
||||
{
|
||||
/* creates dverts if needed */
|
||||
ED_vgroup_vert_add(ob, def, vertex_index, weight, assignmode);
|
||||
}
|
||||
|
||||
/* generic poll functions */
|
||||
int rna_Lattice_object_poll(PointerRNA *ptr, PointerRNA value)
|
||||
{
|
||||
@@ -1477,12 +1486,19 @@ static void rna_def_object_particle_systems(BlenderRNA *brna, PropertyRNA *cprop
|
||||
/* object.vertex_groups */
|
||||
static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
{
|
||||
static EnumPropertyItem assign_mode_items[] = {
|
||||
{WEIGHT_REPLACE, "REPLACE", 0, "Replace", "Replace"},
|
||||
{WEIGHT_ADD, "ADD", 0, "Add", "Add"},
|
||||
{WEIGHT_SUBTRACT, "SUBTRACT", 0, "Subtract", "Subtract"},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
StructRNA *srna;
|
||||
|
||||
PropertyRNA *prop;
|
||||
|
||||
// FunctionRNA *func;
|
||||
// PropertyRNA *parm;
|
||||
FunctionRNA *func;
|
||||
PropertyRNA *parm;
|
||||
|
||||
RNA_def_property_srna(cprop, "VertexGroups");
|
||||
srna= RNA_def_struct(brna, "VertexGroups", NULL);
|
||||
@@ -1500,6 +1516,25 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
RNA_def_property_int_funcs(prop, "rna_Object_active_vertex_group_index_get", "rna_Object_active_vertex_group_index_set", "rna_Object_active_vertex_group_index_range");
|
||||
RNA_def_property_ui_text(prop, "Active Vertex Group Index", "Active index in vertex group array");
|
||||
RNA_def_property_update(prop, NC_GEOM|ND_DATA, "rna_Object_internal_update_data");
|
||||
|
||||
/* vertex groups */ // add_vertex_group
|
||||
func= RNA_def_function(srna, "new", "ED_vgroup_add_name");
|
||||
RNA_def_function_ui_description(func, "Add vertex group to object.");
|
||||
parm= RNA_def_string(func, "name", "Group", 0, "", "Vertex group name."); /* optional */
|
||||
parm= RNA_def_pointer(func, "group", "VertexGroup", "", "New vertex group.");
|
||||
RNA_def_function_return(func, parm);
|
||||
|
||||
// XXX, this will be very slow, bad API design! :S
|
||||
func= RNA_def_function(srna, "assign", "rna_Object_add_vertex_to_group");
|
||||
RNA_def_function_ui_description(func, "Add vertex to a vertex group.");
|
||||
parm= RNA_def_int(func, "index", 0, 0, 0, "", "Vertex index.", 0, 0);
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
parm= RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to add vertex to.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
parm= RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight.", 0.0f, 1.0f);
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
parm= RNA_def_enum(func, "type", assign_mode_items, 0, "", "Vertex assign mode.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@
|
||||
|
||||
#include "DNA_object_types.h"
|
||||
|
||||
#include "BLO_sys_types.h" /* needed for intptr_t used in ED_mesh.h */
|
||||
// #include "BLO_sys_types.h" /* needed for intptr_t used in ED_mesh.h */
|
||||
|
||||
#include "ED_mesh.h"
|
||||
// #include "ED_mesh.h"
|
||||
|
||||
#ifdef RNA_RUNTIME
|
||||
|
||||
@@ -261,17 +261,6 @@ static void rna_Object_free_duplilist(Object *ob, ReportList *reports)
|
||||
}
|
||||
}
|
||||
|
||||
static bDeformGroup *rna_Object_add_vertex_group(Object *ob, char *group_name)
|
||||
{
|
||||
return ED_vgroup_add_name(ob, group_name);
|
||||
}
|
||||
|
||||
static void rna_Object_add_vertex_to_group(Object *ob, int vertex_index, bDeformGroup *def, float weight, int assignmode)
|
||||
{
|
||||
/* creates dverts if needed */
|
||||
ED_vgroup_vert_add(ob, def, vertex_index, weight, assignmode);
|
||||
}
|
||||
|
||||
/* copied from old API Object.makeDisplayList (Object.c)
|
||||
* use _ suffix because this exists for internal rna */
|
||||
static void rna_Object_update(Object *ob, Scene *sce, int object, int data, int time)
|
||||
@@ -433,13 +422,6 @@ void RNA_api_object(StructRNA *srna)
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static EnumPropertyItem assign_mode_items[] = {
|
||||
{WEIGHT_REPLACE, "REPLACE", 0, "Replace", "Replace"}, /* TODO: more meaningful descriptions */
|
||||
{WEIGHT_ADD, "ADD", 0, "Add", "Add"},
|
||||
{WEIGHT_SUBTRACT, "SUBTRACT", 0, "Subtract", "Subtract"},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
/* mesh */
|
||||
func= RNA_def_function(srna, "create_mesh", "rna_Object_create_mesh");
|
||||
RNA_def_function_ui_description(func, "Create a Mesh datablock with modifiers applied.");
|
||||
@@ -464,24 +446,6 @@ void RNA_api_object(StructRNA *srna)
|
||||
RNA_def_function_ui_description(func, "Free the list of dupli objects.");
|
||||
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
||||
|
||||
/* vertex groups */
|
||||
func= RNA_def_function(srna, "add_vertex_group", "rna_Object_add_vertex_group");
|
||||
RNA_def_function_ui_description(func, "Add vertex group to object.");
|
||||
parm= RNA_def_string(func, "name", "Group", 0, "", "Vertex group name."); /* optional */
|
||||
parm= RNA_def_pointer(func, "group", "VertexGroup", "", "New vertex group.");
|
||||
RNA_def_function_return(func, parm);
|
||||
|
||||
func= RNA_def_function(srna, "add_vertex_to_group", "rna_Object_add_vertex_to_group");
|
||||
RNA_def_function_ui_description(func, "Add vertex to a vertex group.");
|
||||
parm= RNA_def_int(func, "vertex_index", 0, 0, 0, "", "Vertex index.", 0, 0);
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
parm= RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to add vertex to.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
parm= RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight.", 0.0f, 1.0f);
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
parm= RNA_def_enum(func, "type", assign_mode_items, 0, "", "Vertex assign mode.");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
|
||||
/* Armature */
|
||||
func= RNA_def_function(srna, "find_armature", "rna_Object_find_armature");
|
||||
RNA_def_function_ui_description(func, "Find armature influencing this object as a parent or via a modifier.");
|
||||
|
||||
Reference in New Issue
Block a user