forked from bartvdbraak/blender
Added Object.find_armature() to find armature connected to object. Previously this was BPyObject.getObjectArmature()
This commit is contained in:
parent
3c3f8c3018
commit
8fa528cef8
@ -118,26 +118,6 @@ def copy_images(dest_dir, textures):
|
||||
|
||||
print('\tCopied %d images' % copyCount)
|
||||
|
||||
def BPyObject_getObjectArmature(ob):
|
||||
'''
|
||||
This returns the first armature the mesh uses.
|
||||
remember there can be more then 1 armature but most people dont do that.
|
||||
'''
|
||||
if ob.type != 'MESH':
|
||||
return None
|
||||
|
||||
arm = ob.parent
|
||||
if arm and arm.type == 'ARMATURE' and ob.parent_type == 'ARMATURE':
|
||||
return arm
|
||||
|
||||
for m in ob.modifiers:
|
||||
if m.type== 'ARMATURE':
|
||||
arm = m.object
|
||||
if arm:
|
||||
return arm
|
||||
|
||||
return None
|
||||
|
||||
# I guess FBX uses degrees instead of radians (Arystan).
|
||||
# Call this function just before writing to FBX.
|
||||
def eulerRadToDeg(eul):
|
||||
@ -298,30 +278,6 @@ def BPyMesh_meshWeight2List(ob):
|
||||
|
||||
return groupNames, vWeightList
|
||||
|
||||
|
||||
def BPyMesh_meshWeight2Dict(me, ob):
|
||||
''' Takes a mesh and return its group names and a list of dicts, one dict per vertex.
|
||||
using the group as a key and a float value for the weight.
|
||||
These 2 lists can be modified and then used with dict2MeshWeight to apply the changes.
|
||||
'''
|
||||
|
||||
vWeightDict= [dict() for i in range(len(me.verts))] # Sync with vertlist.
|
||||
|
||||
# Clear the vert group.
|
||||
groupNames= [g.name for g in ob.vertex_groups]
|
||||
# groupNames= me.getVertGroupNames()
|
||||
|
||||
for group in groupNames:
|
||||
for vert_index, weight in me.getVertsFromGroup(group, 1): # (i,w) tuples.
|
||||
vWeightDict[vert_index][group]= weight
|
||||
|
||||
# removed this because me may be copying teh vertex groups.
|
||||
#for group in groupNames:
|
||||
# me.removeVertGroup(group)
|
||||
|
||||
return groupNames, vWeightDict
|
||||
|
||||
|
||||
def meshNormalizedWeights(me):
|
||||
try: # account for old bad BPyMesh
|
||||
groupNames, vWeightList = BPyMesh_meshWeight2List(me)
|
||||
@ -2199,7 +2155,7 @@ def write(filename, batch_objects = None, \
|
||||
materials[None, None] = None
|
||||
|
||||
if EXP_ARMATURE:
|
||||
armob = BPyObject_getObjectArmature(ob)
|
||||
armob = ob.find_armature()
|
||||
blenParentBoneName = None
|
||||
|
||||
# parent bone - special case
|
||||
@ -3482,7 +3438,7 @@ bpy.ops.add(EXPORT_OT_fbx)
|
||||
# - Draw.PupMenu alternative in 2.5?, temporarily replaced PupMenu with print
|
||||
# - get rid of cleanName somehow
|
||||
# + fixed: isinstance(inst, bpy.types.*) doesn't work on RNA objects: line 565
|
||||
# - get rid of BPyObject_getObjectArmature, move it in RNA?
|
||||
# + get rid of BPyObject_getObjectArmature, move it in RNA?
|
||||
# - BATCH_ENABLE and BATCH_GROUP options: line 327
|
||||
# - implement all BPyMesh_* used here with RNA
|
||||
# - getDerivedObjects is not fully replicated with .dupli* funcs
|
||||
|
@ -154,6 +154,9 @@ void EM_reveal_mesh(struct EditMesh *em);
|
||||
void EM_select_by_material(struct EditMesh *em, int index);
|
||||
void EM_deselect_by_material(struct EditMesh *em, int index);
|
||||
|
||||
/* editmesh_tools.c */
|
||||
void convert_to_triface(struct EditMesh *em, int direction);
|
||||
|
||||
/* editface.c */
|
||||
struct MTFace *EM_get_active_mtface(struct EditMesh *em, struct EditFace **act_efa, struct MCol **mcol, int sloppy);
|
||||
|
||||
|
@ -63,6 +63,7 @@
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_curve_types.h"
|
||||
#include "DNA_modifier_types.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@ -309,6 +310,29 @@ static void rna_Object_make_display_list(Object *ob, bContext *C)
|
||||
DAG_object_flush_update(sce, ob, OB_RECALC_DATA);
|
||||
}
|
||||
|
||||
static Object *rna_Object_find_armature(Object *ob)
|
||||
{
|
||||
Object *ob_arm = NULL;
|
||||
|
||||
if (ob->type != OB_MESH) return NULL;
|
||||
|
||||
if (ob->parent && ob->partype == PARSKEL && ob->parent->type == OB_ARMATURE) {
|
||||
ob_arm = ob->parent;
|
||||
}
|
||||
else {
|
||||
ModifierData *mod = (ModifierData*)ob->modifiers.first;
|
||||
while (mod) {
|
||||
if (mod->type == eModifierType_Armature) {
|
||||
ob_arm = ((ArmatureModifierData*)mod)->object;
|
||||
}
|
||||
|
||||
mod = mod->next;
|
||||
}
|
||||
}
|
||||
|
||||
return ob_arm;
|
||||
}
|
||||
|
||||
/*
|
||||
static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int *indices, int totindex, float weight, int assignmode)
|
||||
{
|
||||
@ -409,6 +433,12 @@ void RNA_api_object(StructRNA *srna)
|
||||
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.");
|
||||
parm= RNA_def_pointer(func, "ob_arm", "Object", "", "Armature object influencing this object or NULL.");
|
||||
RNA_def_function_return(func, parm);
|
||||
|
||||
/* DAG */
|
||||
func= RNA_def_function(srna, "make_display_list", "rna_Object_make_display_list");
|
||||
RNA_def_function_ui_description(func, "Update object's display data."); /* XXX describe better */
|
||||
|
Loading…
Reference in New Issue
Block a user