From 149955b3e2dd557057d7507f26594964f4ff5cc0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 6 Jan 2011 13:49:09 +0000 Subject: [PATCH] print_m3/m4 didnt use const char *, which gave an errror with passing strings & pedantic warnings. also minor rename in bvh export --- release/scripts/op/io_anim_bvh/export_bvh.py | 52 ++++++++++---------- source/blender/blenlib/BLI_math_matrix.h | 4 +- source/blender/blenlib/intern/math_matrix.c | 4 +- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/release/scripts/op/io_anim_bvh/export_bvh.py b/release/scripts/op/io_anim_bvh/export_bvh.py index 73f878c4951..334f47ca14a 100644 --- a/release/scripts/op/io_anim_bvh/export_bvh.py +++ b/release/scripts/op/io_anim_bvh/export_bvh.py @@ -24,7 +24,7 @@ import bpy -def _read(context, filepath, frame_start, frame_end, global_scale=1.0): +def write_armature(context, filepath, frame_start, frame_end, global_scale=1.0): from mathutils import Matrix, Vector, Euler from math import degrees @@ -34,40 +34,40 @@ def _read(context, filepath, frame_start, frame_end, global_scale=1.0): obj = context.object arm = obj.data - # Build a dictionary of bone children. - # None is for parentless bones - bone_children = {None: []} + # Build a dictionary of children. + # None for parentless + children = {None: []} # initialize with blank lists for bone in arm.bones: - bone_children[bone.name] = [] + children[bone.name] = [] for bone in arm.bones: - bone_children[getattr(bone.parent, "name", None)].append(bone.name) + children[getattr(bone.parent, "name", None)].append(bone.name) # sort the children - for children_list in bone_children.values(): + for children_list in children.values(): children_list.sort() # bone name list in the order that the bones are written - bones_serialized_names = [] + serialized_names = [] - bone_locs = {} + node_locations = {} file.write("HIERARCHY\n") - def write_bones_recursive(bone_name, indent): - my_bone_children = bone_children[bone_name] + def write_recursive_nodes(bone_name, indent): + my_children = children[bone_name] indent_str = "\t" * indent bone = arm.bones[bone_name] loc = bone.head_local - bone_locs[bone_name] = loc + node_locations[bone_name] = loc # make relative if we can if bone.parent: - loc = loc - bone_locs[bone.parent.name] + loc = loc - node_locations[bone.parent.name] if indent: file.write("%sJOINT %s\n" % (indent_str, bone_name)) @@ -78,31 +78,31 @@ def _read(context, filepath, frame_start, frame_end, global_scale=1.0): file.write("%s\tOFFSET %.6f %.6f %.6f\n" % (indent_str, loc.x * global_scale, loc.y * global_scale, loc.z * global_scale)) file.write("%s\tCHANNELS 6 Xposition Yposition Zposition Xrotation Yrotation Zrotation\n" % indent_str) - if my_bone_children: + if my_children: # store the location for the children # to het their relative offset # Write children - for child_bone in my_bone_children: - bones_serialized_names.append(child_bone) - write_bones_recursive(child_bone, indent + 1) + for child_bone in my_children: + serialized_names.append(child_bone) + write_recursive_nodes(child_bone, indent + 1) else: # Write the bone end. file.write("%s\tEnd Site\n" % indent_str) file.write("%s\t{\n" % indent_str) - loc = bone.tail_local - bone_locs[bone_name] + loc = bone.tail_local - node_locations[bone_name] file.write("%s\t\tOFFSET %.6f %.6f %.6f\n" % (indent_str, loc.x * global_scale, loc.y * global_scale, loc.z * global_scale)) file.write("%s\t}\n" % indent_str) file.write("%s}\n" % indent_str) - if len(bone_children[None]) == 1: - key = bone_children[None][0] - bones_serialized_names.append(key) + if len(children[None]) == 1: + key = children[None][0] + serialized_names.append(key) indent = 0 - write_bones_recursive(key, indent) + write_recursive_nodes(key, indent) else: # Write a dummy parent node @@ -113,11 +113,11 @@ def _read(context, filepath, frame_start, frame_end, global_scale=1.0): key = None indent = 1 - write_bones_recursive(key, indent) + write_recursive_nodes(key, indent) file.write("}\n") - # redefine bones as sorted by bones_serialized_names + # redefine bones as sorted by serialized_names # so we can write motion class decorated_bone(object): @@ -164,7 +164,7 @@ def _read(context, filepath, frame_start, frame_end, global_scale=1.0): else: return "[\"%s\" root bone]\n" % (self.name) - bones_decorated = [decorated_bone(bone_name) for bone_name in bones_serialized_names] + bones_decorated = [decorated_bone(bone_name) for bone_name in serialized_names] # Assign parents bones_decorated_dict = {} @@ -224,7 +224,7 @@ def save(operator, context, filepath="", global_scale=1.0, ): - _read(context, filepath, + write_armature(context, filepath, frame_start=frame_start, frame_end=frame_end, global_scale=global_scale, diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 7b21c5f6df7..8fbd0205b41 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -165,8 +165,8 @@ int is_negative_m4(float mat[4][4]); /*********************************** Other ***********************************/ -void print_m3(char *str, float M[3][3]); -void print_m4(char *str, float M[3][4]); +void print_m3(const char *str, float M[3][3]); +void print_m4(const char *str, float M[3][4]); #ifdef __cplusplus } diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 154eb746e5c..456c752c302 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -1224,7 +1224,7 @@ void loc_axisangle_size_to_mat4(float mat[4][4], const float loc[3], const float /*********************************** Other ***********************************/ -void print_m3(char *str, float m[][3]) +void print_m3(const char *str, float m[][3]) { printf("%s\n", str); printf("%f %f %f\n",m[0][0],m[1][0],m[2][0]); @@ -1233,7 +1233,7 @@ void print_m3(char *str, float m[][3]) printf("\n"); } -void print_m4(char *str, float m[][4]) +void print_m4(const char *str, float m[][4]) { printf("%s\n", str); printf("%f %f %f %f\n",m[0][0],m[1][0],m[2][0],m[3][0]);