Constraints: Code cleanup

* Removing duplicate api functions
* Shuffled around newly added api functions to make the ordering more consistent
* Fixes for a few bugs in the api functions as I checked over them
* Replaced most of the #defines for flags and modes with enums
This commit is contained in:
2009-11-16 12:33:42 +00:00
parent 567ee32f14
commit a12c2a8561
8 changed files with 331 additions and 277 deletions

View File

@@ -102,23 +102,12 @@ typedef struct bConstraintTypeInfo {
bConstraintTypeInfo *constraint_get_typeinfo(struct bConstraint *con);
bConstraintTypeInfo *get_constraint_typeinfo(int type);
struct bConstraint *add_ob_constraint(struct Object *ob, const char *name, short type);
struct bConstraint *add_pose_constraint(struct Object *ob, struct bPoseChannel *pchan, const char *name, short type);
struct bConstraint *find_active_constraint(ListBase *constraints);
void set_active_constraint(ListBase *constraints, struct bConstraint *con);
int remove_constraint(ListBase *constraints, struct bConstraint *con);
int remove_constraint_index(ListBase *constraints, int index);
/* ---------------------------------------------------------------------------- */
/* Useful macros for testing various common flag combinations */
/* Constraint Target Macros */
#define VALID_CONS_TARGET(ct) ((ct) && (ct->tar))
/* ---------------------------------------------------------------------------- */
/* Constraint function prototypes */
@@ -129,7 +118,15 @@ void copy_constraints(struct ListBase *dst, struct ListBase *src);
void relink_constraints(struct ListBase *list);
void free_constraint_data(struct bConstraint *con);
/* Constraint API function prototypes */
struct bConstraint *constraints_get_active(struct ListBase *list);
void constraints_set_active(ListBase *list, struct bConstraint *con);
struct bConstraint *add_ob_constraint(struct Object *ob, const char *name, short type);
struct bConstraint *add_pose_constraint(struct Object *ob, struct bPoseChannel *pchan, const char *name, short type);
int remove_constraint(ListBase *list, struct bConstraint *con);
int remove_constraint_index(ListBase *list, int index);
/* Constraints + Proxies function prototypes */
void extract_proxylocal_constraints(struct ListBase *dst, struct ListBase *src);

View File

@@ -3605,137 +3605,6 @@ bConstraintTypeInfo *constraint_get_typeinfo (bConstraint *con)
return NULL;
}
/* Creates a new constraint, initialises its data, and returns it */
static bConstraint *add_new_constraint_internal(const char *name, short type)
{
bConstraint *con;
bConstraintTypeInfo *cti;
con = MEM_callocN(sizeof(bConstraint), "Constraint");
/* Set up a generic constraint datablock */
con->type = type;
con->flag |= CONSTRAINT_EXPAND;
con->enforce = 1.0f;
/* Load the data for it */
cti = constraint_get_typeinfo(con);
if (cti) {
con->data = MEM_callocN(cti->size, cti->structName);
/* only constraints that change any settings need this */
if (cti->new_data)
cti->new_data(con->data);
/* set the name based on the type of constraint */
name= name ? name : cti->name;
}
else
name= name ? name : "Const";
strcpy(con->name, name);
return con;
}
/* if pchan is not NULL then assume we're adding a pose constraint */
static bConstraint *add_new_constraint(Object *ob, bPoseChannel *pchan, const char *name, short type)
{
bConstraint *con;
ListBase *list;
con= add_new_constraint_internal(name, type);
if(pchan) list= &pchan->constraints;
else list= &ob->constraints;
if (list) {
bConstraint *coniter;
/* add new constraint to end of list of constraints before ensuring that it has a unique name
* (otherwise unique-naming code will fail, since it assumes element exists in list)
*/
BLI_addtail(list, con);
unique_constraint_name(con, list);
/* if the target list is a list on some PoseChannel belonging to a proxy-protected
* Armature layer, we must tag newly added constraints with a flag which allows them
* to persist after proxy syncing has been done
*/
if (proxylocked_constraints_owner(ob, pchan))
con->flag |= CONSTRAINT_PROXY_LOCAL;
/* make this constraint the active one
* - since constraint was added at end of stack, we can just go
* through deactivating all previous ones
*/
con->flag |= CONSTRAINT_ACTIVE;
for (coniter= con->prev; coniter; coniter= coniter->prev)
coniter->flag &= ~CONSTRAINT_ACTIVE;
}
return con;
}
bConstraint *add_pose_constraint(Object *ob, bPoseChannel *pchan, const char *name, short type)
{
if(pchan==NULL)
return NULL;
return add_new_constraint(ob, pchan, name, type);
}
bConstraint *add_ob_constraint(Object *ob, const char *name, short type)
{
return add_new_constraint(ob, NULL, name, type);
}
struct bConstraint *find_active_constraint(ListBase *constraints)
{
bConstraint *con;
if (constraints==NULL)
return NULL;
for(con= constraints->first; con; con= con->next) {
if(con->flag & CONSTRAINT_ACTIVE)
return con;
}
return NULL;
}
void set_active_constraint(ListBase *constraints, struct bConstraint *con)
{
bConstraint *con_i;
for(con_i= constraints->first; con_i; con_i= con_i->next) {
if(con_i==con) con->flag |= CONSTRAINT_ACTIVE;
else con->flag &= ~CONSTRAINT_ACTIVE;
}
}
int remove_constraint(ListBase *constraints, struct bConstraint *con)
{
if(con) {
free_constraint_data(con);
BLI_freelinkN(constraints, con);
return 1;
}
else {
return 0;
}
}
int remove_constraint_index(ListBase *constraints, int index)
{
bConstraint *con= BLI_findlink(constraints, index);
if(con) {
return remove_constraint(constraints, con);
}
else {
return 0;
}
}
/* ************************* General Constraints API ************************** */
/* The functions here are called by various parts of Blender. Very few (should be none if possible)
* constraint-specific code should occur here.
@@ -3771,6 +3640,121 @@ void free_constraints (ListBase *list)
BLI_freelistN(list);
}
/* Remove the specified constraint from the given constraint stack */
int remove_constraint (ListBase *list, bConstraint *con)
{
if (con) {
free_constraint_data(con);
BLI_freelinkN(list, con);
return 1;
}
else
return 0;
}
/* Remove the nth constraint from the given constraint stack */
int remove_constraint_index (ListBase *list, int index)
{
bConstraint *con= BLI_findlink(list, index);
if (con)
return remove_constraint(list, con);
else
return 0;
}
/* ......... */
/* Creates a new constraint, initialises its data, and returns it */
static bConstraint *add_new_constraint_internal (const char *name, short type)
{
bConstraint *con= MEM_callocN(sizeof(bConstraint), "Constraint");
bConstraintTypeInfo *cti= get_constraint_typeinfo(type);
const char *newName;
/* Set up a generic constraint datablock */
con->type = type;
con->flag |= CONSTRAINT_EXPAND;
con->enforce = 1.0f;
/* Determine a basic name, and info */
if (cti) {
/* initialise constraint data */
con->data = MEM_callocN(cti->size, cti->structName);
/* only constraints that change any settings need this */
if (cti->new_data)
cti->new_data(con->data);
/* if no name is provided, use the type of the constraint as the name */
newName= (name && name[0]) ? name : cti->name;
}
else {
/* if no name is provided, use the generic "Const" name */
// NOTE: any constraint type that gets here really shouldn't get added...
newName= (name && name[0]) ? name : "Const";
}
/* copy the name */
BLI_strncpy(con->name, newName, sizeof(con->name));
/* return the new constraint */
return con;
}
/* if pchan is not NULL then assume we're adding a pose constraint */
static bConstraint *add_new_constraint (Object *ob, bPoseChannel *pchan, const char *name, short type)
{
bConstraint *con;
ListBase *list;
/* add the constraint */
con= add_new_constraint_internal(name, type);
/* find the constraint stack - bone or object? */
list = (pchan) ? (&pchan->constraints) : (&ob->constraints);
if (list) {
/* add new constraint to end of list of constraints before ensuring that it has a unique name
* (otherwise unique-naming code will fail, since it assumes element exists in list)
*/
BLI_addtail(list, con);
unique_constraint_name(con, list);
/* if the target list is a list on some PoseChannel belonging to a proxy-protected
* Armature layer, we must tag newly added constraints with a flag which allows them
* to persist after proxy syncing has been done
*/
if (proxylocked_constraints_owner(ob, pchan))
con->flag |= CONSTRAINT_PROXY_LOCAL;
/* make this constraint the active one */
constraints_set_active(list, con);
}
return con;
}
/* ......... */
/* Add new constraint for the given bone */
bConstraint *add_pose_constraint (Object *ob, bPoseChannel *pchan, const char *name, short type)
{
if (pchan == NULL)
return NULL;
return add_new_constraint(ob, pchan, name, type);
}
/* Add new constraint for the given object */
bConstraint *add_ob_constraint(Object *ob, const char *name, short type)
{
return add_new_constraint(ob, NULL, name, type);
}
/* ......... */
/* Reassign links that constraints have to other data (called during file loading?) */
void relink_constraints (ListBase *conlist)
{
@@ -3801,6 +3785,8 @@ void relink_constraints (ListBase *conlist)
}
}
/* ......... */
/* duplicate all of the constraints in a constraint stack */
void copy_constraints (ListBase *dst, ListBase *src)
{
@@ -3815,6 +3801,7 @@ void copy_constraints (ListBase *dst, ListBase *src)
/* make a new copy of the constraint's data */
con->data = MEM_dupallocN(con->data);
// NOTE: depreceated... old animation system
id_us_plus((ID *)con->ipo);
/* only do specific constraints if required */
@@ -3823,6 +3810,8 @@ void copy_constraints (ListBase *dst, ListBase *src)
}
}
/* ......... */
/* finds the 'active' constraint in a constraint stack */
bConstraint *constraints_get_active (ListBase *list)
{
@@ -3840,6 +3829,19 @@ bConstraint *constraints_get_active (ListBase *list)
return NULL;
}
/* Set the given constraint as the active one (clearing all the others) */
void constraints_set_active (ListBase *list, bConstraint *con)
{
bConstraint *c;
for (c= list->first; c; c= c->next) {
if (c == con)
c->flag |= CONSTRAINT_ACTIVE;
else
c->flag &= ~CONSTRAINT_ACTIVE;
}
}
/* -------- Constraints and Proxies ------- */
/* Rescue all constraints tagged as being CONSTRAINT_PROXY_LOCAL (i.e. added to bone that's proxy-synced in this file) */

View File

@@ -1013,22 +1013,20 @@ int remove_fmodifier (ListBase *modifiers, FModifier *fcm)
if (modifiers) {
BLI_freelinkN(modifiers, fcm);
return 1;
} else {
}
else {
// XXX this case can probably be removed some day, as it shouldn't happen...
printf("remove_fmodifier() - no modifier stack given \n");
MEM_freeN(fcm);
return 0;
}
}
/* Remove and free the nth F-Modifier from the given stack */
int remove_fmodifier_index (ListBase *modifiers, int index)
{
FModifier *fcm= BLI_findlink(modifiers, index);
if(fcm) {
return remove_fmodifier(modifiers, fcm);
}
else {
return 0;
}
return remove_fmodifier(modifiers, fcm);
}
/* Remove all of a given F-Curve's modifiers */

View File

@@ -101,7 +101,7 @@ ListBase *get_active_constraints (Object *ob)
/* single constraint */
bConstraint *get_active_constraint (Object *ob)
{
return find_active_constraint(get_active_constraints(ob));
return constraints_get_active(get_active_constraints(ob));
}
/* -------------- Constraint Management (Add New, Remove, Rename) -------------------- */
/* ------------- PyConstraints ------------------ */
@@ -646,10 +646,11 @@ void ED_object_constraint_rename(Object *ob, bConstraint *con, char *oldname)
void ED_object_constraint_set_active(Object *ob, bConstraint *con)
{
/* lets be nice and escape if its active already */
if(con && (con->flag & CONSTRAINT_ACTIVE))
// NOTE: this assumes that the stack doesn't have other active ones set...
if (con && (con->flag & CONSTRAINT_ACTIVE))
return ;
set_active_constraint(get_active_constraints(ob), con);
constraints_set_active(get_active_constraints(ob), con);
}
void ED_object_constraint_update(Object *ob)

View File

@@ -377,7 +377,7 @@ typedef struct bShrinkwrapConstraint {
* - Do not ever change the order of these, or else files could get
* broken as their correct value cannot be resolved
*/
typedef enum B_CONSTAINT_TYPES {
typedef enum eBConstraint_Types {
CONSTRAINT_TYPE_NULL = 0, /* Invalid/legacy constraint */
CONSTRAINT_TYPE_CHILDOF, /* Unimplemented non longer :) - during constraints recode, Aligorith */
CONSTRAINT_TYPE_TRACKTO,
@@ -404,12 +404,12 @@ typedef enum B_CONSTAINT_TYPES {
/* NOTE: no constraints are allowed to be added after this */
NUM_CONSTRAINT_TYPES
} B_CONSTRAINT_TYPES;
} eBConstraint_Types;
/* bConstraint->flag */
/* flags 0x2 (1<<1) and 0x8 (1<<3) were used in past */
/* flag 0x20 (1<<5) was used to indicate that a constraint was evaluated using a 'local' hack for posebones only */
typedef enum B_CONSTRAINT_FLAG {
typedef enum eBConstraint_Flags {
/* expand for UI */
CONSTRAINT_EXPAND = (1<<0),
/* pre-check for illegal object name or bone name */
@@ -424,10 +424,10 @@ typedef enum B_CONSTRAINT_FLAG {
CONSTRAINT_PROXY_LOCAL = (1<<8),
/* indicates that constraint is temporarily disabled (only used in GE) */
CONSTRAINT_OFF = (1<<9)
} B_CONSTRAINT_FLAG;
} eBConstraint_Flags;
/* bConstraint->ownspace/tarspace */
typedef enum B_CONSTRAINT_SPACETYPES {
typedef enum eBConstraint_SpaceTypes {
/* default for all - worldspace */
CONSTRAINT_SPACE_WORLD = 0,
/* for objects (relative to parent/without parent influence),
@@ -440,13 +440,14 @@ typedef enum B_CONSTRAINT_SPACETYPES {
CONSTRAINT_SPACE_PARLOCAL, /* = 3 */
/* for files from between 2.43-2.46 (should have been parlocal) */
CONSTRAINT_SPACE_INVALID, /* = 4. do not exchange for anything! */
} B_CONSTRAINT_SPACETYPES;
} eBConstraint_SpaceTypes;
/* bConstraintChannel.flag */
typedef enum B_CONSTRAINTCHANNEL_FLAG {
// XXX depreceated... old AnimSys
typedef enum eConstraintChannel_Flags {
CONSTRAINT_CHANNEL_SELECT = (1<<0),
CONSTRAINT_CHANNEL_PROTECTED = (1<<1)
} B_CONSTRAINTCHANNEL_FLAG;
} eConstraintChannel_Flags;
/* -------------------------------------- */
@@ -456,167 +457,219 @@ typedef enum B_CONSTRAINTCHANNEL_FLAG {
*/
/* bRotateLikeConstraint.flag */
#define ROTLIKE_X 0x01
#define ROTLIKE_Y 0x02
#define ROTLIKE_Z 0x04
#define ROTLIKE_X_INVERT 0x10
#define ROTLIKE_Y_INVERT 0x20
#define ROTLIKE_Z_INVERT 0x40
#define ROTLIKE_OFFSET 0x80
typedef enum eCopyRotation_Flags {
ROTLIKE_X = (1<<0),
ROTLIKE_Y = (1<<1),
ROTLIKE_Z = (1<<2),
ROTLIKE_X_INVERT = (1<<4),
ROTLIKE_Y_INVERT = (1<<5),
ROTLIKE_Z_INVERT = (1<<6),
ROTLIKE_OFFSET = (1<<7),
} eCopyRotation_Flags;
/* bLocateLikeConstraint.flag */
#define LOCLIKE_X 0x01
#define LOCLIKE_Y 0x02
#define LOCLIKE_Z 0x04
/* LOCLIKE_TIP is a depreceated option... use headtail=1.0f instead */
#define LOCLIKE_TIP 0x08
#define LOCLIKE_X_INVERT 0x10
#define LOCLIKE_Y_INVERT 0x20
#define LOCLIKE_Z_INVERT 0x40
#define LOCLIKE_OFFSET 0x80
typedef enum eCopyLocation_Flags {
LOCLIKE_X = (1<<0),
LOCLIKE_Y = (1<<1),
LOCLIKE_Z = (1<<2),
/* LOCLIKE_TIP is a depreceated option... use headtail=1.0f instead */
LOCLIKE_TIP = (1<<3),
LOCLIKE_X_INVERT = (1<<4),
LOCLIKE_Y_INVERT = (1<<5),
LOCLIKE_Z_INVERT = (1<<6),
LOCLIKE_OFFSET = (1<<7),
} eCopyLocation_Flags;
/* bSizeLikeConstraint.flag */
#define SIZELIKE_X 0x01
#define SIZELIKE_Y 0x02
#define SIZELIKE_Z 0x04
#define SIZELIKE_OFFSET 0x80
typedef enum eCopyScale_Flags {
SIZELIKE_X = (1<<0),
SIZELIKE_Y = (1<<1),
SIZELIKE_Z = (1<<2),
SIZELIKE_OFFSET = (1<<3),
} eCopyScale_Flags;
/* Axis flags */
#define LOCK_X 0x00
#define LOCK_Y 0x01
#define LOCK_Z 0x02
/* Locked-Axis Values (Locked Track) */
typedef enum eLockAxis_Modes {
LOCK_X = 0,
LOCK_Y,
LOCK_Z,
} eLockAxis_Modes;
#define UP_X 0x00
#define UP_Y 0x01
#define UP_Z 0x02
/* Up-Axis Values (TrackTo and Locked Track) */
typedef enum eUpAxis_Modes {
UP_X = 0,
UP_Y,
UP_Z,
} eUpAxis_Modes;
#define TRACK_X 0x00
#define TRACK_Y 0x01
#define TRACK_Z 0x02
#define TRACK_nX 0x03
#define TRACK_nY 0x04
#define TRACK_nZ 0x05
/* Tracking axis (TrackTo, Locked Track, Damped Track) */
typedef enum eTrackToAxis_Modes {
TRACK_X = 0,
TRACK_Y,
TRACK_Z,
TRACK_nX,
TRACK_nY,
TRACK_nZ,
} eTrackToAxis_Modes;
/* FollowPath flags */
#define FOLLOWPATH_FOLLOW 0x01
#define FOLLOWPATH_STATIC 0x02
#define FOLLOWPATH_RADIUS 0x04
typedef enum eFollowPath_Flags {
FOLLOWPATH_FOLLOW = (1<<0),
FOLLOWPATH_STATIC = (1<<1),
FOLLOWPATH_RADIUS = (1<<2),
} eFollowPath_Flags;
/* bTrackToConstraint->flags */
#define TARGET_Z_UP 0x01
typedef enum eTrackTo_Flags {
TARGET_Z_UP = (1<<0),
} eTrackTo_Flags;
#define VOLUME_XZ 0x00
#define VOLUME_X 0x01
#define VOLUME_Z 0x02
#define NO_VOLUME 0x03
/* Strech To Constraint -> volmode */
typedef enum eStretchTo_VolMode {
VOLUME_XZ = 0,
VOLUME_X,
VOLUME_Z,
NO_VOLUME,
} eStretchTo_VolMode;
#define PLANE_X 0x00
#define PLANE_Y 0x01
#define PLANE_Z 0x02
/* Stretch To Constraint -> plane mode */
typedef enum eStretchTo_PlaneMode {
PLANE_X = 0,
PLANE_Y,
PLANE_Z,
} eStretchTo_PlaneMode;
/* Clamp-To Constraint ->flag */
#define CLAMPTO_AUTO 0
#define CLAMPTO_X 1
#define CLAMPTO_Y 2
#define CLAMPTO_Z 3
typedef enum eClampTo_Modes {
CLAMPTO_AUTO = 0,
CLAMPTO_X,
CLAMPTO_Y,
CLAMPTO_Z,
} eClampTo_Modes;
/* ClampTo Constraint ->flag2 */
#define CLAMPTO_CYCLIC 1
typedef enum eClampTo_Flags {
CLAMPTO_CYCLIC = (1<<0),
} eClampTo_Flags;
/* bKinematicConstraint->flag */
#define CONSTRAINT_IK_TIP 1
#define CONSTRAINT_IK_ROT 2
typedef enum eKinematic_Flags {
CONSTRAINT_IK_TIP = (1<<0),
CONSTRAINT_IK_ROT = (1<<1),
/* targetless */
#define CONSTRAINT_IK_AUTO 4
CONSTRAINT_IK_AUTO = (1<<2),
/* autoik */
#define CONSTRAINT_IK_TEMP 8
#define CONSTRAINT_IK_STRETCH 16
#define CONSTRAINT_IK_POS 32
#define CONSTRAINT_IK_SETANGLE 64
#define CONSTRAINT_IK_GETANGLE 128
CONSTRAINT_IK_TEMP = (1<<3),
CONSTRAINT_IK_STRETCH = (1<<4),
CONSTRAINT_IK_POS = (1<<5),
CONSTRAINT_IK_SETANGLE = (1<<6),
CONSTRAINT_IK_GETANGLE = (1<<7),
/* limit axis */
#define CONSTRAINT_IK_NO_POS_X 256
#define CONSTRAINT_IK_NO_POS_Y 512
#define CONSTRAINT_IK_NO_POS_Z 1024
#define CONSTRAINT_IK_NO_ROT_X 2048
#define CONSTRAINT_IK_NO_ROT_Y 4096
#define CONSTRAINT_IK_NO_ROT_Z 8192
CONSTRAINT_IK_NO_POS_X = (1<<8),
CONSTRAINT_IK_NO_POS_Y = (1<<9),
CONSTRAINT_IK_NO_POS_Z = (1<<10),
CONSTRAINT_IK_NO_ROT_X = (1<<11),
CONSTRAINT_IK_NO_ROT_Y = (1<<12),
CONSTRAINT_IK_NO_ROT_Z = (1<<13),
/* axis relative to target */
#define CONSTRAINT_IK_TARGETAXIS 16384
CONSTRAINT_IK_TARGETAXIS = (1<<14),
} eKinematic_Flags;
/* bSplineIKConstraint->flag */
typedef enum eSplineIK_Flags {
/* chain has been attached to spline */
#define CONSTRAINT_SPLINEIK_BOUND (1<<0)
CONSTRAINT_SPLINEIK_BOUND = (1<<0),
/* root of chain is not influenced by the constraint */
#define CONSTRAINT_SPLINEIK_NO_ROOT (1<<1)
CONSTRAINT_SPLINEIK_NO_ROOT = (1<<1),
/* bones in the chain should not scale to fit the curve */
#define CONSTRAINT_SPLINEIK_SCALE_LIMITED (1<<2)
CONSTRAINT_SPLINEIK_SCALE_LIMITED = (1<<2),
/* evenly distribute the bones along the path regardless of length */
#define CONSTRAINT_SPLINEIK_EVENSPLITS (1<<3)
CONSTRAINT_SPLINEIK_EVENSPLITS = (1<<3),
} eSplineIK_Flags;
/* bSplineIKConstraint->xzScaleMode */
typedef enum eSplineIK_XZScaleModes {
/* no x/z scaling */
#define CONSTRAINT_SPLINEIK_XZS_NONE 0
CONSTRAINT_SPLINEIK_XZS_NONE = 0,
/* bones in the chain should take their x/z scales from the curve radius */
#define CONSTRAINT_SPLINEIK_XZS_RADIUS 1
CONSTRAINT_SPLINEIK_XZS_RADIUS,
/* bones in the chain should take their x/z scales from the original scaling */
#define CONSTRAINT_SPLINEIK_XZS_ORIGINAL 2
CONSTRAINT_SPLINEIK_XZS_ORIGINAL,
} eSplineIK_XZScaleModes;
/* MinMax (floor) flags */
#define MINMAX_STICKY 0x01
#define MINMAX_STUCK 0x02
#define MINMAX_USEROT 0x04
/* transform limiting constraints -> flag */
#define LIMIT_XMIN 0x01
#define LIMIT_XMAX 0x02
#define LIMIT_YMIN 0x04
#define LIMIT_YMAX 0x08
#define LIMIT_ZMIN 0x10
#define LIMIT_ZMAX 0x20
#define LIMIT_XROT 0x01
#define LIMIT_YROT 0x02
#define LIMIT_ZROT 0x04
typedef enum eFloor_Flags {
MINMAX_STICKY = (1<<0),
MINMAX_STUCK = (1<<1),
MINMAX_USEROT = (1<<2),
} eFloor_Flags;
/* transform limiting constraints -> flag2 */
typedef enum eTransformLimits_Flags2 {
/* not used anymore - for older Limit Location constraints only */
#define LIMIT_NOPARENT 0x01
LIMIT_NOPARENT = (1<<0),
/* for all Limit constraints - allow to be used during transform? */
#define LIMIT_TRANSFORM 0x02
LIMIT_TRANSFORM = (1<<1),
} eTransformLimits_Flags2;
/* transform limiting constraints -> flag (own flags) */
typedef enum eTransformLimits_Flags {
LIMIT_XMIN = (1<<0),
LIMIT_XMAX = (1<<1),
LIMIT_YMIN = (1<<2),
LIMIT_YMAX = (1<<3),
LIMIT_ZMIN = (1<<4),
LIMIT_ZMAX = (1<<5),
} eTransformLimits_Flags;
/* limit rotation constraint -> flag (own flags) */
typedef enum eRotLimit_Flags {
LIMIT_XROT = (1<<0),
LIMIT_YROT = (1<<1),
LIMIT_ZROT = (1<<2),
} eRotLimit_Flags;
/* distance limit constraint */
/* bDistLimitConstraint->flag */
#define LIMITDIST_USESOFT (1<<0)
typedef enum eDistLimit_Flag {
LIMITDIST_USESOFT = (1<<0),
} eDistLimit_Flag;
/* bDistLimitConstraint->mode */
#define LIMITDIST_INSIDE 0
#define LIMITDIST_OUTSIDE 1
#define LIMITDIST_ONSURFACE 2
typedef enum eDistLimit_Modes {
LIMITDIST_INSIDE = 0,
LIMITDIST_OUTSIDE,
LIMITDIST_ONSURFACE,
} eDistLimit_Modes;
/* python constraint -> flag */
#define PYCON_USETARGETS 0x01
#define PYCON_SCRIPTERROR 0x02
typedef enum ePyConstraint_Flags {
PYCON_USETARGETS = (1<<0),
PYCON_SCRIPTERROR = (1<<1),
} ePyConstraint_Flags;
/* ChildOf Constraint -> flag */
#define CHILDOF_LOCX 0x001
#define CHILDOF_LOCY 0x002
#define CHILDOF_LOCZ 0x004
#define CHILDOF_ROTX 0x008
#define CHILDOF_ROTY 0x010
#define CHILDOF_ROTZ 0x020
#define CHILDOF_SIZEX 0x040
#define CHILDOF_SIZEY 0x080
#define CHILDOF_SIZEZ 0x100
typedef enum eChildOf_Flags {
CHILDOF_LOCX = (1<<0),
CHILDOF_LOCY = (1<<1),
CHILDOF_LOCZ = (1<<2),
CHILDOF_ROTX = (1<<3),
CHILDOF_ROTY = (1<<4),
CHILDOF_ROTZ = (1<<5),
CHILDOF_SIZEX = (1<<6),
CHILDOF_SIZEY = (1<<7),
CHILDOF_SIZEZ = (1<<8),
} eChildOf_Flags;
/* Rigid-Body Constraint */
#define CONSTRAINT_DRAW_PIVOT 0x40
#define CONSTRAINT_DISABLE_LINKED_COLLISION 0x80
#define CONSTRAINT_DISABLE_LINKED_COLLISION 0x80
/* important: these defines need to match up with PHY_DynamicTypes headerfile */
#define CONSTRAINT_RB_BALL 1
#define CONSTRAINT_RB_HINGE 2
#define CONSTRAINT_RB_CONETWIST 4
#define CONSTRAINT_RB_VEHICLE 11
#define CONSTRAINT_RB_GENERIC6DOF 12
#define CONSTRAINT_RB_BALL 1
#define CONSTRAINT_RB_HINGE 2
#define CONSTRAINT_RB_CONETWIST 4
#define CONSTRAINT_RB_VEHICLE 11
#define CONSTRAINT_RB_GENERIC6DOF 12
#endif

View File

@@ -287,7 +287,6 @@ static void rna_ActionConstraint_minmax_range(PointerRNA *ptr, float *min, float
}
}
#else
EnumPropertyItem constraint_distance_items[] = {
@@ -1681,9 +1680,9 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna)
PropertyRNA *prop;
static EnumPropertyItem splineik_xz_scale_mode[] = {
{CONSTRAINT_SPLINEIK_XZS_NONE, "NONE", 0, "None", "Don't scale the x and z axes, giving a volume preservation effect. (Default)"},
{CONSTRAINT_SPLINEIK_XZS_NONE, "NONE", 0, "Volume Preserve", "Don't scale the x and z axes, giving a volume preservation effect. (Default)"},
{CONSTRAINT_SPLINEIK_XZS_RADIUS, "CURVE_RADIUS", 0, "Curve Radius", "Use the radius of the curve."},
{CONSTRAINT_SPLINEIK_XZS_ORIGINAL, "ORIGINAL", 0, "Original", "Use the original scaling of the bones."},
{CONSTRAINT_SPLINEIK_XZS_ORIGINAL, "BONE_ORIGINAL", 0, "Bone Original", "Use the original scaling of the bones."},
{0, NULL, 0, NULL, NULL}};
srna= RNA_def_struct(brna, "SplineIKConstraint", "Constraint");
@@ -1703,7 +1702,11 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Chain Length", "How many bones are included in the chain");
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update");
// TODO: add access to the positions array to allow more flexible aligning?
/* direct access to bindings */
// NOTE: only to be used by experienced users
//prop= RNA_def_property(srna, "joint_bindings", PROP_FLOAT, PROP_FACTOR);
//RNA_def_property_collection_sdna(prop, NULL, "points", "numpoints");
//RNA_def_property_ui_text(prop, "Joint Bindings", "(EXPERIENCED USERS ONLY) The relative positions of the joints along the chain as percentages.");
/* settings */
prop= RNA_def_property(srna, "chain_offset", PROP_BOOLEAN, PROP_NONE);

View File

@@ -865,14 +865,14 @@ static PointerRNA rna_Object_collision_get(PointerRNA *ptr)
static PointerRNA rna_Object_active_constraint_get(PointerRNA *ptr)
{
Object *ob= (Object*)ptr->id.data;
bConstraint *con= find_active_constraint(&ob->constraints);
bConstraint *con= constraints_get_active(&ob->constraints);
return rna_pointer_inherit_refine(ptr, &RNA_Constraint, con);
}
static void rna_Object_active_constraint_set(PointerRNA *ptr, PointerRNA value)
{
Object *ob= (Object*)ptr->id.data;
set_active_constraint(&ob->constraints, (bConstraint *)value.data);
constraints_set_active(&ob->constraints, (bConstraint *)value.data);
}
static bConstraint *rna_Object_constraints_new(Object *object, bContext *C, int type)

View File

@@ -419,14 +419,14 @@ static void rna_pose_pgroup_name_set(PointerRNA *ptr, const char *value, char *r
static PointerRNA rna_PoseChannel_active_constraint_get(PointerRNA *ptr)
{
bPoseChannel *pchan= (bPoseChannel*)ptr->data;
bConstraint *con= find_active_constraint(&pchan->constraints);
bConstraint *con= constraints_get_active(&pchan->constraints);
return rna_pointer_inherit_refine(ptr, &RNA_Constraint, con);
}
static void rna_PoseChannel_active_constraint_set(PointerRNA *ptr, PointerRNA value)
{
bPoseChannel *pchan= (bPoseChannel*)ptr->data;
set_active_constraint(&pchan->constraints, (bConstraint *)value.data);
constraints_set_active(&pchan->constraints, (bConstraint *)value.data);
}
static bConstraint *rna_PoseChannel_constraints_new(bPoseChannel *pchan, bContext *C, int type)