Blender  V3.3
Classes | Typedefs | Functions
BKE_constraint.h File Reference

Go to the source code of this file.

Classes

struct  bConstraintOb
 
struct  bConstraintTypeInfo
 

Typedefs

typedef struct bConstraintOb bConstraintOb
 
typedef void(* ConstraintIDFunc) (struct bConstraint *con, struct ID **idpoin, bool is_reference, void *userdata)
 
typedef struct bConstraintTypeInfo bConstraintTypeInfo
 

Functions

const bConstraintTypeInfo * BKE_constraint_typeinfo_get (struct bConstraint *con)
 
const bConstraintTypeInfo * BKE_constraint_typeinfo_from_type (int type)
 
void BKE_constraint_unique_name (struct bConstraint *con, struct ListBase *list)
 
struct bConstraint * BKE_constraint_duplicate_ex (struct bConstraint *src, int flag, bool do_extern)
 
struct bConstraint * BKE_constraint_copy_for_pose (struct Object *ob, struct bPoseChannel *pchan, struct bConstraint *src)
 
struct bConstraint * BKE_constraint_copy_for_object (struct Object *ob, struct bConstraint *src)
 
void BKE_constraints_free (struct ListBase *list)
 
void BKE_constraints_free_ex (struct ListBase *list, bool do_id_user)
 
void BKE_constraints_copy (struct ListBase *dst, const struct ListBase *src, bool do_extern)
 
void BKE_constraints_copy_ex (struct ListBase *dst, const struct ListBase *src, int flag, bool do_extern)
 
void BKE_constraints_id_loop (struct ListBase *list, ConstraintIDFunc func, void *userdata)
 
void BKE_constraint_free_data (struct bConstraint *con)
 
void BKE_constraint_free_data_ex (struct bConstraint *con, bool do_id_user)
 
bool BKE_constraint_target_uses_bbone (struct bConstraint *con, struct bConstraintTarget *ct)
 
struct bConstraint * BKE_constraints_active_get (struct ListBase *list)
 
void BKE_constraints_active_set (ListBase *list, struct bConstraint *con)
 
struct bConstraint * BKE_constraints_find_name (struct ListBase *list, const char *name)
 
struct bConstraint * BKE_constraint_find_from_target (struct Object *ob, struct bConstraintTarget *tgt, struct bPoseChannel **r_pchan)
 
bool BKE_constraint_is_nonlocal_in_liboverride (const struct Object *ob, const struct bConstraint *con)
 
struct bConstraint * BKE_constraint_add_for_object (struct Object *ob, const char *name, short type)
 
struct bConstraint * BKE_constraint_add_for_pose (struct Object *ob, struct bPoseChannel *pchan, const char *name, short type)
 
bool BKE_constraint_remove_ex (ListBase *list, struct Object *ob, struct bConstraint *con, bool clear_dep)
 
bool BKE_constraint_remove (ListBase *list, struct bConstraint *con)
 
bool BKE_constraint_apply_for_object (struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct bConstraint *con)
 
bool BKE_constraint_apply_and_remove_for_object (struct Depsgraph *depsgraph, struct Scene *scene, ListBase *constraints, struct Object *ob, struct bConstraint *con)
 
bool BKE_constraint_apply_for_pose (struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, struct bConstraint *con)
 
bool BKE_constraint_apply_and_remove_for_pose (struct Depsgraph *depsgraph, struct Scene *scene, ListBase *constraints, struct Object *ob, struct bConstraint *con, struct bPoseChannel *pchan)
 
void BKE_constraint_panel_expand (struct bConstraint *con)
 
struct bConstraintOb * BKE_constraints_make_evalob (struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, void *subdata, short datatype)
 
void BKE_constraints_clear_evalob (struct bConstraintOb *cob)
 
void BKE_constraint_mat_convertspace (struct Object *ob, struct bPoseChannel *pchan, struct bConstraintOb *cob, float mat[4][4], short from, short to, bool keep_scale)
 
void BKE_constraint_target_matrix_get (struct Depsgraph *depsgraph, struct Scene *scene, struct bConstraint *con, int index, short ownertype, void *ownerdata, float mat[4][4], float ctime)
 
int BKE_constraint_targets_get (struct bConstraint *con, struct ListBase *r_targets)
 
void BKE_constraint_targets_flush (struct bConstraint *con, struct ListBase *targets, bool no_copy)
 
void BKE_constraint_targets_for_solving_get (struct Depsgraph *depsgraph, struct bConstraint *con, struct bConstraintOb *ob, struct ListBase *targets, float ctime)
 
void BKE_constraint_custom_object_space_init (struct bConstraintOb *cob, struct bConstraint *con)
 
void BKE_constraints_solve (struct Depsgraph *depsgraph, struct ListBase *conlist, struct bConstraintOb *cob, float ctime)
 
void BKE_constraint_blend_write (struct BlendWriter *writer, struct ListBase *conlist)
 
void BKE_constraint_blend_read_data (struct BlendDataReader *reader, struct ListBase *lb)
 
void BKE_constraint_blend_read_lib (struct BlendLibReader *reader, struct ID *id, struct ListBase *conlist)
 
void BKE_constraint_blend_read_expand (struct BlendExpander *expander, struct ListBase *lb)
 

Typedef Documentation

◆ bConstraintOb

typedef struct bConstraintOb bConstraintOb

◆ bConstraintTypeInfo

Constraint Type-Info (shorthand in code = cti): This struct provides function pointers for runtime, so that functions can be written more generally (with fewer/no special exceptions for various constraints).

Callers of these functions must check that they actually point to something useful, as some constraints don't define some of these.

WARNING: it is not too advisable to reorder order of members of this struct, as you'll have to edit quite a few NUM_CONSTRAINT_TYPES of these structs.

◆ ConstraintIDFunc

typedef void(* ConstraintIDFunc) (struct bConstraint *con, struct ID **idpoin, bool is_reference, void *userdata)

Definition at line 55 of file BKE_constraint.h.

Function Documentation

◆ BKE_constraint_add_for_object()

struct bConstraint* BKE_constraint_add_for_object ( struct Object *  ob,
const char *  name,
short  type 
)

◆ BKE_constraint_add_for_pose()

struct bConstraint* BKE_constraint_add_for_pose ( struct Object *  ob,
struct bPoseChannel *  pchan,
const char *  name,
short  type 
)

Add new constraint for the given bone.

Definition at line 5858 of file constraint.c.

References add_new_constraint(), NULL, and type.

Referenced by add_temporary_ik_constraint(), and constraint_add_exec().

◆ BKE_constraint_apply_and_remove_for_object()

bool BKE_constraint_apply_and_remove_for_object ( struct Depsgraph *  depsgraph,
struct Scene *  scene,
ListBase *  constraints,
struct Object *  ob,
struct bConstraint *  con 
)

◆ BKE_constraint_apply_and_remove_for_pose()

bool BKE_constraint_apply_and_remove_for_pose ( struct Depsgraph *  depsgraph,
struct Scene *  scene,
ListBase *  constraints,
struct Object *  ob,
struct bConstraint *  con,
struct bPoseChannel *  pchan 
)

◆ BKE_constraint_apply_for_object()

bool BKE_constraint_apply_for_object ( struct Depsgraph *  depsgraph,
struct Scene *  scene,
struct Object *  ob,
struct bConstraint *  con 
)

◆ BKE_constraint_apply_for_pose()

bool BKE_constraint_apply_for_pose ( struct Depsgraph *  depsgraph,
struct Scene *  scene,
struct Object *  ob,
struct bPoseChannel *  pchan,
struct bConstraint *  con 
)

◆ BKE_constraint_blend_read_data()

void BKE_constraint_blend_read_data ( struct BlendDataReader *  reader,
struct ListBase *  lb 
)

◆ BKE_constraint_blend_read_expand()

void BKE_constraint_blend_read_expand ( struct BlendExpander *  expander,
struct ListBase *  lb 
)

◆ BKE_constraint_blend_read_lib()

void BKE_constraint_blend_read_lib ( struct BlendLibReader *  reader,
struct ID *  id,
struct ListBase *  conlist 
)

◆ BKE_constraint_blend_write()

void BKE_constraint_blend_write ( struct BlendWriter *  writer,
struct ListBase *  conlist 
)

◆ BKE_constraint_copy_for_object()

struct bConstraint* BKE_constraint_copy_for_object ( struct Object *  ob,
struct bConstraint *  src 
)

Add a copy of the given constraint for the given object.

Definition at line 5966 of file constraint.c.

References add_new_constraint_to_list(), BKE_constraint_duplicate_ex(), ID_IS_LINKED, NULL, and src.

Referenced by constraint_copy_exec(), constraint_copy_to_selected_exec(), and ED_object_constraint_copy_for_object().

◆ BKE_constraint_copy_for_pose()

struct bConstraint* BKE_constraint_copy_for_pose ( struct Object *  ob,
struct bPoseChannel *  pchan,
struct bConstraint *  src 
)

Add a copy of the given constraint for the given bone.

Definition at line 5955 of file constraint.c.

References add_new_constraint_to_list(), BKE_constraint_duplicate_ex(), ID_IS_LINKED, NULL, and src.

Referenced by constraint_copy_exec(), constraint_copy_to_selected_exec(), and ED_object_constraint_copy_for_pose().

◆ BKE_constraint_custom_object_space_init()

void BKE_constraint_custom_object_space_init ( struct bConstraintOb *  cob,
struct bConstraint *  con 
)

Initialize the Custom Space matrix inside cob (if required by the constraint).

Parameters
cobConstraint evaluation context (contains the matrix to be initialized).
conConstraint that is about to be evaluated.

Definition at line 6331 of file constraint.c.

References CONSTRAINT_SPACE_WORLD, constraint_target_to_mat4(), is_custom_space_needed(), NULL, bConstraintOb::space_obj_world_matrix, bConstraint::space_object, bConstraint::space_subtarget, and unit_m4().

Referenced by BKE_constraint_target_matrix_get(), BKE_constraints_solve(), constraintTransLim(), OVERLAY_relationship_lines(), updateDuplicateActionConstraintSettings(), and updateDuplicateLocRotConstraintSettings().

◆ BKE_constraint_duplicate_ex()

struct bConstraint* BKE_constraint_duplicate_ex ( struct bConstraint *  src,
int  flag,
bool  do_extern 
)

Allocate and duplicate a single constraint, outside of any object/pose context.

Definition at line 5947 of file constraint.c.

References constraint_copy_data_ex(), MEM_dupallocN, bConstraint::next, NULL, bConstraint::prev, and src.

Referenced by BKE_constraint_apply_for_object(), BKE_constraint_apply_for_pose(), BKE_constraint_copy_for_object(), and BKE_constraint_copy_for_pose().

◆ BKE_constraint_find_from_target()

struct bConstraint* BKE_constraint_find_from_target ( struct Object *  ob,
struct bConstraintTarget *  tgt,
struct bPoseChannel **  r_pchan 
)

Finds the constraint that owns the given target within the object.

Definition at line 6052 of file constraint.c.

References bPose::chanbase, constraint_list_find_from_target(), Object::constraints, LISTBASE_FOREACH, NULL, Object::pose, and result.

Referenced by blender::deg::RNANodeQuery::construct_node_identifier().

◆ BKE_constraint_free_data()

void BKE_constraint_free_data ( struct bConstraint *  con)

◆ BKE_constraint_free_data_ex()

void BKE_constraint_free_data_ex ( struct bConstraint *  con,
bool  do_id_user 
)

Free data of a specific constraint if it has any info. Be sure to run BIK_clear_data() when freeing an IK constraint, unless #DAG_relations_tag_update is called.

Definition at line 5549 of file constraint.c.

References BKE_constraint_typeinfo_get(), con_invoke_id_looper(), con_unlink_refs_cb(), bConstraint::data, bConstraintTypeInfo::free_data, MEM_freeN, and NULL.

Referenced by BKE_constraint_free_data(), and BKE_constraints_free_ex().

◆ BKE_constraint_is_nonlocal_in_liboverride()

bool BKE_constraint_is_nonlocal_in_liboverride ( const struct Object *  ob,
const struct bConstraint *  con 
)

Check whether given constraint is not local (i.e. from linked data) when the object is a library override.

Parameters
conMay be NULL, in which case we consider it as a non-local constraint case.

Referenced by edit_constraint_poll_generic().

◆ BKE_constraint_mat_convertspace()

void BKE_constraint_mat_convertspace ( struct Object *  ob,
struct bPoseChannel *  pchan,
struct bConstraintOb *  cob,
float  mat[4][4],
short  from,
short  to,
bool  keep_scale 
)

◆ BKE_constraint_panel_expand()

void BKE_constraint_panel_expand ( struct bConstraint *  con)

Definition at line 5734 of file constraint.c.

References bConstraint::ui_expand_flag, and UI_PANEL_DATA_EXPAND_ROOT.

Referenced by outliner_set_properties_tab().

◆ BKE_constraint_remove()

bool BKE_constraint_remove ( ListBase *  list,
struct bConstraint *  con 
)

Remove the specified constraint from the given constraint stack.

Definition at line 5592 of file constraint.c.

References BKE_constraint_free_data(), and BLI_freelinkN().

Referenced by BKE_constraint_remove_ex(), object_track_clear_exec(), and pose_ik_clear_exec().

◆ BKE_constraint_remove_ex()

bool BKE_constraint_remove_ex ( ListBase *  list,
struct Object *  ob,
struct bConstraint *  con,
bool  clear_dep 
)

◆ BKE_constraint_target_matrix_get()

void BKE_constraint_target_matrix_get ( struct Depsgraph *  depsgraph,
struct Scene *  scene,
struct bConstraint *  con,
int  index,
short  ownertype,
void *  ownerdata,
float  mat[4][4],
float  ctime 
)

This function is a relic from the prior implementations of the constraints system, when all constraints either had one or no targets. It used to be called during the main constraint solving loop, but is now only used for the remaining cases for a few constraints.

None of the actual calculations of the matrices should be done here! Also, this function is not to be used by any new constraints, particularly any that have multiple targets.

Definition at line 6214 of file constraint.c.

References BKE_constraint_custom_object_space_init(), BKE_constraint_typeinfo_get(), BLI_findlink(), CONSTRAINT_OBTYPE_BONE, CONSTRAINT_OBTYPE_OBJECT, copy_m4_m4(), bConstraintOb::depsgraph, depsgraph, bConstraintTypeInfo::flush_constraint_targets, bConstraintTypeInfo::get_constraint_targets, bConstraintTypeInfo::get_target_matrix, bConstraintOb::matrix, bConstraintTarget::matrix, MEM_callocN, MEM_freeN, NULL, bConstraintOb::ob, Object::obmat, bConstraintOb::pchan, bPoseChannel::pose_mat, bConstraintOb::scene, scene, bConstraintOb::startmat, bConstraintOb::type, and unit_m4().

Referenced by base_callback(), ED_object_parent_set(), execute_posetree(), and target_callback().

◆ BKE_constraint_target_uses_bbone()

bool BKE_constraint_target_uses_bbone ( struct bConstraint *  con,
struct bConstraintTarget *  ct 
)

◆ BKE_constraint_targets_flush()

void BKE_constraint_targets_flush ( struct bConstraint *  con,
struct ListBase *  targets,
bool  no_copy 
)

◆ BKE_constraint_targets_for_solving_get()

void BKE_constraint_targets_for_solving_get ( struct Depsgraph *  depsgraph,
struct bConstraint *  con,
struct bConstraintOb *  ob,
struct ListBase *  targets,
float  ctime 
)

◆ BKE_constraint_targets_get()

int BKE_constraint_targets_get ( struct bConstraint *  con,
struct ListBase *  r_targets 
)

◆ BKE_constraint_typeinfo_from_type()

const bConstraintTypeInfo* BKE_constraint_typeinfo_from_type ( int  type)

This function should be used for getting the appropriate type-info when only a constraint type is known.

Definition at line 5487 of file constraint.c.

References CLOG_WARN, CONSTRAINT_TYPE_NULL, constraints_init_typeinfo(), constraintsTypeInfo, CTI_INIT, LOG, NULL, NUM_CONSTRAINT_TYPES, and type.

Referenced by add_new_constraint_internal(), BKE_constraint_typeinfo_get(), bone_constraint_panel_id(), constraintRotLim(), constraintSizeLim(), constraintTransLim(), and object_constraint_panel_id().

◆ BKE_constraint_typeinfo_get()

const bConstraintTypeInfo* BKE_constraint_typeinfo_get ( struct bConstraint *  con)

◆ BKE_constraint_unique_name()

void BKE_constraint_unique_name ( struct bConstraint *  con,
struct ListBase *  list 
)

Find the first available, non-duplicate name for a given constraint.

Definition at line 112 of file constraint.c.

References BLI_uniquename(), DATA_, and bConstraint::name.

Referenced by add_new_constraint_to_list().

◆ BKE_constraints_active_get()

struct bConstraint* BKE_constraints_active_get ( struct ListBase *  list)

Finds the 'active' constraint in a constraint stack.

Definition at line 6001 of file constraint.c.

References CONSTRAINT_ACTIVE, bConstraint::flag, LISTBASE_FOREACH, and NULL.

Referenced by ED_object_constraint_active_get().

◆ BKE_constraints_active_set()

void BKE_constraints_active_set ( ListBase *  list,
struct bConstraint *  con 
)

Set the given constraint as the active one (clearing all the others).

Definition at line 6017 of file constraint.c.

References CONSTRAINT_ACTIVE, and LISTBASE_FOREACH.

Referenced by add_new_constraint_to_list(), constraint_fn(), and ED_object_constraint_active_set().

◆ BKE_constraints_clear_evalob()

void BKE_constraints_clear_evalob ( struct bConstraintOb *  cob)

◆ BKE_constraints_copy()

void BKE_constraints_copy ( struct ListBase *  dst,
const struct ListBase *  src,
bool  do_extern 
)

◆ BKE_constraints_copy_ex()

void BKE_constraints_copy_ex ( struct ListBase *  dst,
const struct ListBase *  src,
int  flag,
bool  do_extern 
)

Duplicate all of the constraints in a constraint stack.

Referenced by BKE_pose_copy_data_ex(), and object_copy_data().

◆ BKE_constraints_find_name()

struct bConstraint* BKE_constraints_find_name ( struct ListBase *  list,
const char *  name 
)

◆ BKE_constraints_free()

void BKE_constraints_free ( struct ListBase *  list)

◆ BKE_constraints_free_ex()

void BKE_constraints_free_ex ( struct ListBase *  list,
bool  do_id_user 
)

Free all constraints from a constraint-stack.

Definition at line 5576 of file constraint.c.

References BKE_constraint_free_data_ex(), BLI_freelistN(), and LISTBASE_FOREACH.

Referenced by BKE_constraints_free(), BKE_pose_channel_free_ex(), and object_free_data().

◆ BKE_constraints_id_loop()

void BKE_constraints_id_loop ( struct ListBase *  list,
ConstraintIDFunc  func,
void *  userdata 
)

◆ BKE_constraints_make_evalob()

struct bConstraintOb* BKE_constraints_make_evalob ( struct Depsgraph *  depsgraph,
struct Scene *  scene,
struct Object *  ob,
void *  subdata,
short  datatype 
)

◆ BKE_constraints_solve()

void BKE_constraints_solve ( struct Depsgraph *  depsgraph,
struct ListBase *  conlist,
struct bConstraintOb *  cob,
float  ctime 
)