Blender V4.3
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 bConstraintTypeInfoBKE_constraint_typeinfo_get (struct bConstraint *con)
 
const bConstraintTypeInfoBKE_constraint_typeinfo_from_type (int type)
 
void BKE_constraint_unique_name (struct bConstraint *con, struct ListBase *list)
 
struct bConstraintBKE_constraint_duplicate_ex (struct bConstraint *src, int flag, bool do_extern)
 
struct bConstraintBKE_constraint_copy_for_pose (struct Object *ob, struct bPoseChannel *pchan, struct bConstraint *src)
 
struct bConstraintBKE_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, const int flag, 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 bConstraintBKE_constraints_active_get (struct ListBase *list)
 
void BKE_constraints_active_set (ListBase *list, struct bConstraint *con)
 
struct bConstraintBKE_constraints_find_name (struct ListBase *list, const char *name)
 
struct bConstraintBKE_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 bConstraintBKE_constraint_add_for_object (struct Object *ob, const char *name, short type)
 
struct bConstraintBKE_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 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 bConstraintObBKE_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 ID *id_owner, struct ListBase *lb)
 

Typedef Documentation

◆ bConstraintOb

typedef struct bConstraintOb bConstraintOb

◆ bConstraintTypeInfo

typedef struct bConstraintTypeInfo 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()

◆ 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 5992 of file constraint.cc.

References add_new_constraint().

Referenced by add_temporary_ik_constraint(), and blender::ed::object::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()

◆ BKE_constraint_apply_for_pose()

◆ BKE_constraint_blend_read_data()

◆ BKE_constraint_blend_write()

◆ BKE_constraint_copy_for_object()

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

◆ BKE_constraint_copy_for_pose()

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

◆ BKE_constraint_custom_object_space_init()

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

◆ 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 6084 of file constraint.cc.

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

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 6192 of file constraint.cc.

References bPose::chanbase, constraint_list_find_from_target(), Object::constraints, LISTBASE_FOREACH, 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 5684 of file constraint.cc.

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

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 blender::ed::object::edit_constraint_poll_generic().

◆ BKE_constraint_mat_convertspace()

◆ BKE_constraint_panel_expand()

void BKE_constraint_panel_expand ( struct bConstraint * con)

◆ BKE_constraint_remove()

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

Remove the specified constraint from the given constraint stack.

Definition at line 5727 of file constraint.cc.

References BKE_constraint_free_data(), and BLI_freelinkN().

Referenced by BKE_constraint_remove_ex(), blender::ed::object::object_track_clear_exec(), and blender::ed::object::pose_ik_clear_exec().

◆ BKE_constraint_remove_ex()

◆ 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 6354 of file constraint.cc.

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(), bConstraintOb::ob, bConstraintOb::pchan, bPoseChannel::pose_mat, bConstraintOb::scene, scene, bConstraintOb::startmat, bConstraintOb::type, and unit_m4().

Referenced by base_callback(), execute_posetree(), blender::ed::object::parent_set(), and target_callback().

◆ BKE_constraint_target_uses_bbone()

◆ BKE_constraint_targets_flush()

◆ 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()

◆ 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 5617 of file constraint.cc.

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

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()

◆ 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 120 of file constraint.cc.

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

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 6141 of file constraint.cc.

References CONSTRAINT_ACTIVE, and LISTBASE_FOREACH.

Referenced by blender::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 6157 of file constraint.cc.

References CONSTRAINT_ACTIVE, bConstraint::flag, and LISTBASE_FOREACH.

Referenced by add_new_constraint_to_list(), blender::ed::object::constraint_active_set(), and blender::ed::outliner::constraint_fn().

◆ BKE_constraints_clear_evalob()

◆ BKE_constraints_copy()

◆ 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()

◆ 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 5711 of file constraint.cc.

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,
const int flag,
void * userdata )

Run the given callback on all ID-blocks in list of constraints.

Parameters
flagthe IDWALK_ flags controlling the behavior of the foreach_id code, see BKE_lib_query.hh

Definition at line 6011 of file constraint.cc.

References BKE_constraint_typeinfo_get(), con_invoke_id_looper(), flag, and LISTBASE_FOREACH.

Referenced by blender::deg::DepsgraphNodeBuilder::build_object(), blender::deg::DepsgraphRelationBuilder::build_object(), blender::deg::DepsgraphNodeBuilder::build_pose_constraints(), blender::deg::DepsgraphRelationBuilder::build_rig(), and object_foreach_id().

◆ BKE_constraints_make_evalob()

◆ BKE_constraints_solve()

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