Blender V2.61 - r43446
Classes | Defines | Typedefs | Enumerations | Functions | Variables

editarmature_retarget.c File Reference

#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include "MEM_guardedalloc.h"
#include "PIL_time.h"
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_editVert.h"
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
#include "BLI_graph.h"
#include "BLI_rand.h"
#include "BLI_threads.h"
#include "BKE_constraint.h"
#include "BKE_armature.h"
#include "BKE_context.h"
#include "ED_armature.h"
#include "ED_util.h"
#include "BIF_retarget.h"
#include "reeb.h"
#include "armature_intern.h"

Go to the source code of this file.

Classes

struct  MemoNode
struct  RetargetParam

Defines

#define SHAPE_LEVELS   (SHAPE_RADIX * SHAPE_RADIX)
#define MAX_COST   FLT_MAX

Typedefs

typedef struct MemoNode MemoNode
typedef struct RetargetParam RetargetParam

Enumerations

enum  RetargetMode { RETARGET_LENGTH, RETARGET_AGGRESSIVE }
enum  RetargetMethod { METHOD_BRUTE_FORCE = 0, METHOD_MEMOIZE = 1 }
enum  ArcUsageFlags { ARC_FREE = 0, ARC_TAKEN = 1, ARC_USED = 2 }

Functions

void * exec_retargetArctoArc (void *param)
static void RIG_calculateEdgeAngles (RigEdge *edge_first, RigEdge *edge_second)
float rollBoneByQuat (EditBone *bone, float old_up_axis[3], float qrot[4])
static int countEditBoneChildren (ListBase *list, EditBone *parent)
static EditBonenextEditBoneChild (ListBase *list, EditBone *parent, int n)
static void getEditBoneRollUpAxis (EditBone *bone, float roll, float up_axis[3])
static float rollBoneByQuatAligned (EditBone *bone, float old_up_axis[3], float qrot[4], float qroll[4], float aligned_axis[3])
static float rollBoneByQuatJoint (RigEdge *edge, RigEdge *previous, float qrot[4], float qroll[4], float up_axis[3])
static void RIG_freeRigArc (BArc *arc)
void RIG_freeRigGraph (BGraph *rg)
static RigGraphnewRigGraph (void)
static RigArcnewRigArc (RigGraph *rg)
static RigControlnewRigControl (RigGraph *rg)
static RigNodenewRigNodeHead (RigGraph *rg, RigArc *arc, float p[3])
static void addRigNodeHead (RigGraph *UNUSED(rg), RigArc *arc, RigNode *node)
static RigNodenewRigNode (RigGraph *rg, float p[3])
static RigNodenewRigNodeTail (RigGraph *rg, RigArc *arc, float p[3])
static void RIG_appendEdgeToArc (RigArc *arc, RigEdge *edge)
static void RIG_addEdgeToArc (RigArc *arc, float tail[3], EditBone *bone)
static void renameTemplateBone (char *name, char *template_name, ListBase *editbones, char *side_string, char *num_string)
static RigControlcloneControl (RigGraph *rg, RigGraph *src_rg, RigControl *src_ctrl, GHash *ptr_hash, char *side_string, char *num_string)
static RigArccloneArc (RigGraph *rg, RigGraph *src_rg, RigArc *src_arc, GHash *ptr_hash, char *side_string, char *num_string)
static RigGraphcloneRigGraph (RigGraph *src, ListBase *editbones, Object *ob, char *side_string, char *num_string)
static void RIG_addControlBone (RigGraph *rg, EditBone *bone)
static int RIG_parentControl (RigControl *ctrl, EditBone *link)
static void RIG_reconnectControlBones (RigGraph *rg)
static void RIG_joinArcs (RigGraph *rg, RigNode *node, RigArc *joined_arc1, RigArc *joined_arc2)
static void RIG_removeNormalNodes (RigGraph *rg)
static void RIG_removeUneededOffsets (RigGraph *rg)
static void RIG_arcFromBoneChain (RigGraph *rg, ListBase *list, EditBone *root_bone, RigNode *starting_node, int selected)
static void RIG_findHead (RigGraph *rg)
static void RIG_printNode (RigNode *node, const char name[])
void RIG_printArcBones (RigArc *arc)
static void RIG_printCtrl (RigControl *ctrl, char *indent)
static void RIG_printLinkedCtrl (RigGraph *rg, EditBone *bone, int tabs)
void RIG_printArc (RigGraph *rg, RigArc *arc)
void RIG_printGraph (RigGraph *rg)
RigGraphRIG_graphFromArmature (const bContext *C, Object *ob, bArmature *arm)
static RigGrapharmatureSelectedToGraph (bContext *C, Object *ob, bArmature *arm)
static void repositionControl (RigGraph *rigg, RigControl *ctrl, float head[3], float tail[3], float qrot[4], float resize)
static void repositionTailControl (RigGraph *rigg, RigControl *ctrl)
static void finalizeControl (RigGraph *rigg, RigControl *ctrl, float resize)
static void repositionControl (RigGraph *rigg, RigControl *ctrl, float head[3], float UNUSED(tail[3]), float qrot[4], float resize)
static void repositionBone (bContext *C, RigGraph *rigg, RigEdge *edge, float vec0[3], float vec1[3], float up_axis[3])
static RetargetMode detectArcRetargetMode (RigArc *arc)
static void retargetArctoArcLength (bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start)
static float costDistance (BArcIterator *iter, float *vec0, float *vec1, int i0, int i1, float distance_weight)
static float costAngle (float original_angle, float vec_first[3], float vec_second[3], float angle_weight)
static float costLength (float original_length, float current_length, float length_weight)
static float calcCostAngleLengthDistance (BArcIterator *iter, float **UNUSED(vec_cache), RigEdge *edge, float *vec0, float *vec1, float *vec2, int i1, int i2, float angle_weight, float length_weight, float distance_weight)
static int indexMemoNode (int nb_positions, int previous, int current, int joints_left)
static void copyMemoPositions (int *positions, MemoNode *table, int nb_positions, int joints_left)
static MemoNodesolveJoints (MemoNode *table, BArcIterator *iter, float **vec_cache, int nb_joints, int nb_positions, int previous, int current, RigEdge *edge, int joints_left, float angle_weight, float length_weight, float distance_weight)
static int testFlipArc (RigArc *iarc, RigNode *inode_start)
static void retargetArctoArcAggresive (bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start)
static void retargetArctoArc (bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start)
static void matchMultiResolutionNode (RigGraph *rigg, RigNode *inode, ReebNode *top_node)
static void markMultiResolutionChildArc (ReebNode *end_enode, ReebNode *enode)
static void markMultiResolutionArc (ReebArc *start_earc)
static void matchMultiResolutionArc (RigGraph *rigg, RigNode *start_node, RigArc *next_iarc, ReebArc *next_earc)
static void matchMultiResolutionStartingNode (RigGraph *rigg, ReebGraph *reebg, RigNode *inode)
static void findCorrespondingArc (RigGraph *rigg, RigArc *start_arc, RigNode *start_node, RigArc *next_iarc, int root)
static void retargetSubgraph (bContext *C, RigGraph *rigg, RigArc *start_arc, RigNode *start_node)
static void finishRetarget (RigGraph *rigg)
static void adjustGraphs (bContext *C, RigGraph *rigg)
static void retargetGraphs (bContext *C, RigGraph *rigg)
const char * RIG_nameBone (RigGraph *rg, int arc_index, int bone_index)
int RIG_nbJoints (RigGraph *rg)
static void BIF_freeRetarget (void)
void BIF_retargetArmature (bContext *C)
void BIF_retargetArc (bContext *C, ReebArc *earc, RigGraph *template_rigg)
void BIF_adjustRetarget (bContext *C)

Variables

static RigGraphGLOBAL_RIGG = NULL

Detailed Description

Definition in file editarmature_retarget.c.


Define Documentation

#define MAX_COST   FLT_MAX

Definition at line 1960 of file editarmature_retarget.c.

Referenced by costDistance(), costLength(), and solveJoints().

#define SHAPE_LEVELS   (SHAPE_RADIX * SHAPE_RADIX)

Typedef Documentation

typedef struct MemoNode MemoNode
typedef struct RetargetParam RetargetParam

Enumeration Type Documentation

Enumerator:
ARC_FREE 
ARC_TAKEN 
ARC_USED 

Definition at line 97 of file editarmature_retarget.c.

Enumerator:
METHOD_BRUTE_FORCE 
METHOD_MEMOIZE 

Definition at line 91 of file editarmature_retarget.c.

Enumerator:
RETARGET_LENGTH 
RETARGET_AGGRESSIVE 

Definition at line 85 of file editarmature_retarget.c.


Function Documentation

static void addRigNodeHead ( RigGraph UNUSEDrg,
RigArc arc,
RigNode node 
) [static]

Definition at line 379 of file editarmature_retarget.c.

References RigNode::degree, and RigArc::head.

Referenced by RIG_arcFromBoneChain().

static void adjustGraphs ( bContext C,
RigGraph rigg 
) [static]
static RigGraph* armatureSelectedToGraph ( bContext C,
Object ob,
bArmature arm 
) [static]
void BIF_adjustRetarget ( bContext C)

Definition at line 2948 of file editarmature_retarget.c.

References adjustGraphs().

static void BIF_freeRetarget ( void  ) [static]

Definition at line 2806 of file editarmature_retarget.c.

References NULL, and RIG_freeRigGraph().

Referenced by BIF_retargetArmature().

void BIF_retargetArc ( bContext C,
ReebArc earc,
RigGraph template_rigg 
)
void BIF_retargetArmature ( bContext C)
static float calcCostAngleLengthDistance ( BArcIterator iter,
float **  UNUSEDvec_cache,
RigEdge edge,
float *  vec0,
float *  vec1,
float *  vec2,
int  i1,
int  i2,
float  angle_weight,
float  length_weight,
float  distance_weight 
) [static]
static RigArc* cloneArc ( RigGraph rg,
RigGraph src_rg,
RigArc src_arc,
GHash ptr_hash,
char *  side_string,
char *  num_string 
) [static]
static RigControl* cloneControl ( RigGraph rg,
RigGraph src_rg,
RigControl src_ctrl,
GHash ptr_hash,
char *  side_string,
char *  num_string 
) [static]
static RigGraph* cloneRigGraph ( RigGraph src,
ListBase editbones,
Object ob,
char *  side_string,
char *  num_string 
) [static]
static void copyMemoPositions ( int *  positions,
MemoNode table,
int  nb_positions,
int  joints_left 
) [static]

Definition at line 2088 of file editarmature_retarget.c.

References i, indexMemoNode(), and MemoNode::next.

Referenced by retargetArctoArcAggresive().

static float costAngle ( float  original_angle,
float  vec_first[3],
float  vec_second[3],
float  angle_weight 
) [static]

Definition at line 2006 of file editarmature_retarget.c.

References dot_v3v3(), fabsf, is_zero_v3(), M_PI, and saacos().

Referenced by calcCostAngleLengthDistance().

static float costDistance ( BArcIterator iter,
float *  vec0,
float *  vec1,
int  i0,
int  i1,
float  distance_weight 
) [static]
static float costLength ( float  original_length,
float  current_length,
float  length_weight 
) [static]

Definition at line 2029 of file editarmature_retarget.c.

References fabs(), and MAX_COST.

Referenced by calcCostAngleLengthDistance().

static int countEditBoneChildren ( ListBase list,
EditBone parent 
) [static]

Definition at line 118 of file editarmature_retarget.c.

References ListBase::first, EditBone::next, and EditBone::parent.

Referenced by RIG_arcFromBoneChain().

static RetargetMode detectArcRetargetMode ( RigArc arc) [static]
void * exec_retargetArctoArc ( void *  param)
static void finalizeControl ( RigGraph rigg,
RigControl ctrl,
float  resize 
) [static]
static void findCorrespondingArc ( RigGraph rigg,
RigArc start_arc,
RigNode start_node,
RigArc next_iarc,
int  root 
) [static]
static void finishRetarget ( RigGraph rigg) [static]

Definition at line 2707 of file editarmature_retarget.c.

References BLI_end_worker(), and RigGraph::worker.

Referenced by adjustGraphs(), BIF_retargetArc(), and retargetGraphs().

static void getEditBoneRollUpAxis ( EditBone bone,
float  roll,
float  up_axis[3] 
) [static]
static int indexMemoNode ( int  nb_positions,
int  previous,
int  current,
int  joints_left 
) [static]

Definition at line 2083 of file editarmature_retarget.c.

Referenced by copyMemoPositions(), and solveJoints().

static void markMultiResolutionArc ( ReebArc start_earc) [static]
static void markMultiResolutionChildArc ( ReebNode end_enode,
ReebNode enode 
) [static]
static void matchMultiResolutionArc ( RigGraph rigg,
RigNode start_node,
RigArc next_iarc,
ReebArc next_earc 
) [static]
static void matchMultiResolutionNode ( RigGraph rigg,
RigNode inode,
ReebNode top_node 
) [static]
static void matchMultiResolutionStartingNode ( RigGraph rigg,
ReebGraph reebg,
RigNode inode 
) [static]
static RigArc* newRigArc ( RigGraph rg) [static]

Definition at line 342 of file editarmature_retarget.c.

References RigGraph::arcs, BLI_addtail(), RigArc::count, and MEM_callocN().

Referenced by cloneArc(), and RIG_arcFromBoneChain().

static RigControl* newRigControl ( RigGraph rg) [static]

Definition at line 353 of file editarmature_retarget.c.

References BLI_addtail(), RigGraph::controls, and MEM_callocN().

Referenced by cloneControl(), and RIG_addControlBone().

static RigGraph* newRigGraph ( void  ) [static]
static RigNode* newRigNode ( RigGraph rg,
float  p[3] 
) [static]
static RigNode* newRigNodeHead ( RigGraph rg,
RigArc arc,
float  p[3] 
) [static]
static RigNode* newRigNodeTail ( RigGraph rg,
RigArc arc,
float  p[3] 
) [static]

Definition at line 399 of file editarmature_retarget.c.

References RigNode::degree, newRigNode(), and RigArc::tail.

Referenced by RIG_arcFromBoneChain().

static EditBone* nextEditBoneChild ( ListBase list,
EditBone parent,
int  n 
) [static]

Definition at line 134 of file editarmature_retarget.c.

References ListBase::first, EditBone::next, NULL, and EditBone::parent.

Referenced by RIG_arcFromBoneChain().

static void renameTemplateBone ( char *  name,
char *  template_name,
ListBase editbones,
char *  side_string,
char *  num_string 
) [static]

Definition at line 449 of file editarmature_retarget.c.

References i, MAXBONENAME, NULL, and unique_editbone_name().

Referenced by cloneArc(), and cloneControl().

static void repositionBone ( bContext C,
RigGraph rigg,
RigEdge edge,
float  vec0[3],
float  vec1[3],
float  up_axis[3] 
) [static]
static void repositionControl ( RigGraph rigg,
RigControl ctrl,
float  head[3],
float  tail[3],
float  qrot[4],
float  resize 
) [static]

Referenced by finalizeControl(), and repositionBone().

static void repositionControl ( RigGraph rigg,
RigControl ctrl,
float  head[3],
float   UNUSEDtail[3],
float  qrot[4],
float  resize 
) [static]
static void repositionTailControl ( RigGraph rigg,
RigControl ctrl 
) [static]

Definition at line 1783 of file editarmature_retarget.c.

References finalizeControl(), RigControl::flag, and RIG_CTRL_TAIL_DONE.

Referenced by finalizeControl(), and repositionBone().

static void retargetArctoArc ( bContext C,
RigGraph rigg,
RigArc iarc,
RigNode inode_start 
) [static]
static void retargetArctoArcAggresive ( bContext C,
RigGraph rigg,
RigArc iarc,
RigNode inode_start 
) [static]
static void retargetArctoArcLength ( bContext C,
RigGraph rigg,
RigArc iarc,
RigNode inode_start 
) [static]
static void retargetGraphs ( bContext C,
RigGraph rigg 
) [static]
static void retargetSubgraph ( bContext C,
RigGraph rigg,
RigArc start_arc,
RigNode start_node 
) [static]
static void RIG_addControlBone ( RigGraph rg,
EditBone bone 
) [static]
static void RIG_addEdgeToArc ( RigArc arc,
float  tail[3],
EditBone bone 
) [static]
static void RIG_appendEdgeToArc ( RigArc arc,
RigEdge edge 
) [static]
static void RIG_arcFromBoneChain ( RigGraph rg,
ListBase list,
EditBone root_bone,
RigNode starting_node,
int  selected 
) [static]
static void RIG_calculateEdgeAngles ( RigEdge edge_first,
RigEdge edge_second 
) [static]
static void RIG_findHead ( RigGraph rg) [static]
static void RIG_freeRigArc ( BArc arc) [static]

Definition at line 263 of file editarmature_retarget.c.

References BLI_freelistN().

Referenced by newRigGraph(), and RIG_freeRigGraph().

void RIG_freeRigGraph ( BGraph rg)
RigGraph* RIG_graphFromArmature ( const bContext C,
Object ob,
bArmature arm 
)
static void RIG_joinArcs ( RigGraph rg,
RigNode node,
RigArc joined_arc1,
RigArc joined_arc2 
) [static]
const char* RIG_nameBone ( RigGraph rg,
int  arc_index,
int  bone_index 
)
int RIG_nbJoints ( RigGraph rg)
static int RIG_parentControl ( RigControl ctrl,
EditBone link 
) [static]
void RIG_printArc ( RigGraph rg,
RigArc arc 
)
void RIG_printArcBones ( RigArc arc)
static void RIG_printCtrl ( RigControl ctrl,
char *  indent 
) [static]
void RIG_printGraph ( RigGraph rg)
static void RIG_printLinkedCtrl ( RigGraph rg,
EditBone bone,
int  tabs 
) [static]
static void RIG_printNode ( RigNode node,
const char  name[] 
) [static]

Definition at line 1420 of file editarmature_retarget.c.

References RigNode::degree, print_v3(), SYM_AXIAL, SYM_RADIAL, and SYM_TOPOLOGICAL.

Referenced by RIG_printArc(), and RIG_printGraph().

static void RIG_reconnectControlBones ( RigGraph rg) [static]
static void RIG_removeNormalNodes ( RigGraph rg) [static]
static void RIG_removeUneededOffsets ( RigGraph rg) [static]
float rollBoneByQuat ( EditBone bone,
float  old_up_axis[3],
float  qrot[4] 
)

Definition at line 251 of file editarmature_retarget.c.

References copy_v3_v3(), ED_rollBoneToVector(), FALSE, and mul_qt_v3().

Referenced by finalizeControl(), and repositionBone().

static float rollBoneByQuatAligned ( EditBone bone,
float  old_up_axis[3],
float  qrot[4],
float  qroll[4],
float  aligned_axis[3] 
) [static]
static float rollBoneByQuatJoint ( RigEdge edge,
RigEdge previous,
float  qrot[4],
float  qroll[4],
float  up_axis[3] 
) [static]
static MemoNode* solveJoints ( MemoNode table,
BArcIterator iter,
float **  vec_cache,
int  nb_joints,
int  nb_positions,
int  previous,
int  current,
RigEdge edge,
int  joints_left,
float  angle_weight,
float  length_weight,
float  distance_weight 
) [static]
static int testFlipArc ( RigArc iarc,
RigNode inode_start 
) [static]

Variable Documentation

RigGraph* GLOBAL_RIGG = NULL [static]

Definition at line 104 of file editarmature_retarget.c.