=== BPY ===
authorMartin Poirier <theeth@yahoo.com>
Fri, 6 Apr 2007 19:42:46 +0000 (19:42 +0000)
committerMartin Poirier <theeth@yahoo.com>
Fri, 6 Apr 2007 19:42:46 +0000 (19:42 +0000)
Adding Python counterparts to the Invert params for Copy Rot and Copy Loc.

I had to align the constants being used, so if you had files using those options (introduced after 2.43), you'll have to modify the INVERT settings for ROTLIKE constraints (didn't feel like making a minor version bump for this, if people thing otherwise, please say so).

Based on a patch by Juho Vepsäläinen (bebraw)

source/blender/makesdna/DNA_constraint_types.h
source/blender/python/api2_2x/Constraint.c
source/blender/python/api2_2x/doc/Constraint.py

index 14506f1b1aac8ab09c5b96a3b6fb75f1a512cdc4..6cf1403b803e4e72e286ae73cff8f233ad771908 100644 (file)
@@ -252,14 +252,19 @@ typedef struct bRigidBodyJointConstraint{
 #define CONSTRAINT_CHANNEL_SELECT              0x01
 #define CONSTRAINT_CHANNEL_PROTECTED   0x02
 
 #define CONSTRAINT_CHANNEL_SELECT              0x01
 #define CONSTRAINT_CHANNEL_PROTECTED   0x02
 
+/**
+ * The flags for ROTLIKE, LOCLIKE and SIZELIKE should be kept identical
+ * (that is, same effect, different name). It simplifies the Python API access a lot.
+ */
+
 /* bRotateLikeConstraint.flag */
 #define ROTLIKE_X              0x01
 #define ROTLIKE_Y              0x02
 #define ROTLIKE_Z              0x04
 /* bRotateLikeConstraint.flag */
 #define ROTLIKE_X              0x01
 #define ROTLIKE_Y              0x02
 #define ROTLIKE_Z              0x04
-#define ROTLIKE_X_INVERT       0x08
-#define ROTLIKE_Y_INVERT       0x10
-#define ROTLIKE_Z_INVERT       0x20
-#define ROTLIKE_OFFSET 0x40
+#define ROTLIKE_X_INVERT       0x10
+#define ROTLIKE_Y_INVERT       0x20
+#define ROTLIKE_Z_INVERT       0x40
+#define ROTLIKE_OFFSET 0x80
 
 /* bLocateLikeConstraint.flag */
 #define LOCLIKE_X                      0x01
 
 /* bLocateLikeConstraint.flag */
 #define LOCLIKE_X                      0x01
@@ -275,7 +280,7 @@ typedef struct bRigidBodyJointConstraint{
 #define SIZELIKE_X             0x01
 #define SIZELIKE_Y             0x02
 #define SIZELIKE_Z             0x04
 #define SIZELIKE_X             0x01
 #define SIZELIKE_Y             0x02
 #define SIZELIKE_Z             0x04
-#define SIZELIKE_OFFSET 0x08
+#define SIZELIKE_OFFSET 0x80
 
 /* Axis flags */
 #define LOCK_X         0x00
 
 /* Axis flags */
 #define LOCK_X         0x00
index 1fb202be6afc58216003a45bfab3c1cfa5214478..602ef7a396bf85598696cdb9cc14cab6d3cfcc5e 100644 (file)
@@ -876,7 +876,7 @@ static int locatelike_setter( BPy_Constraint *self, int type, PyObject *value )
                }
        case EXPP_CONSTR_COPY:
                return EXPP_setIValueRange( value, &con->flag,
                }
        case EXPP_CONSTR_COPY:
                return EXPP_setIValueRange( value, &con->flag,
-                               0, LOCLIKE_X | LOCLIKE_Y | LOCLIKE_Z, 'i' );
+                               0, LOCLIKE_X | LOCLIKE_Y | LOCLIKE_Z | LOCLIKE_X_INVERT | LOCLIKE_Y_INVERT | LOCLIKE_Z_INVERT, 'i' );
        case EXPP_CONSTR_LOCAL:
                if( !get_armature( con->tar ) )
                        return EXPP_ReturnIntError( PyExc_RuntimeError,
        case EXPP_CONSTR_LOCAL:
                if( !get_armature( con->tar ) )
                        return EXPP_ReturnIntError( PyExc_RuntimeError,
@@ -934,7 +934,7 @@ static int rotatelike_setter( BPy_Constraint *self, int type, PyObject *value )
                }
        case EXPP_CONSTR_COPY:
                return EXPP_setIValueRange( value, &con->flag,
                }
        case EXPP_CONSTR_COPY:
                return EXPP_setIValueRange( value, &con->flag,
-                               0, LOCLIKE_X | LOCLIKE_Y | LOCLIKE_Z, 'i' );
+                               0, LOCLIKE_X | LOCLIKE_Y | LOCLIKE_Z | LOCLIKE_X_INVERT | LOCLIKE_Y_INVERT | LOCLIKE_Z_INVERT, 'i' );
        case EXPP_CONSTR_LOCAL:
                if( !get_armature( con->tar ) )
                        return EXPP_ReturnIntError( PyExc_RuntimeError,
        case EXPP_CONSTR_LOCAL:
                if( !get_armature( con->tar ) )
                        return EXPP_ReturnIntError( PyExc_RuntimeError,
@@ -994,7 +994,7 @@ static int sizelike_setter( BPy_Constraint *self, int type, PyObject *value )
                }
        case EXPP_CONSTR_COPY:
                return EXPP_setIValueRange( value, &con->flag,
                }
        case EXPP_CONSTR_COPY:
                return EXPP_setIValueRange( value, &con->flag,
-                               0, LOCLIKE_X | LOCLIKE_Y | LOCLIKE_Z, 'i' );
+                               0, LOCLIKE_X | LOCLIKE_Y | LOCLIKE_Z | LOCLIKE_X_INVERT | LOCLIKE_Y_INVERT | LOCLIKE_Z_INVERT, 'i' );
 #if 0
        case EXPP_CONSTR_LOCAL:
                if( !get_armature( con->tar ) )
 #if 0
        case EXPP_CONSTR_LOCAL:
                if( !get_armature( con->tar ) )
@@ -1957,6 +1957,12 @@ static PyObject *M_Constraint_SettingsDict( void )
                                PyInt_FromLong( LOCLIKE_Y ) );
                PyConstant_Insert( d, "COPYZ",
                                PyInt_FromLong( LOCLIKE_Z ) );
                                PyInt_FromLong( LOCLIKE_Y ) );
                PyConstant_Insert( d, "COPYZ",
                                PyInt_FromLong( LOCLIKE_Z ) );
+               PyConstant_Insert( d, "COPYXINVERT",
+                               PyInt_FromLong( LOCLIKE_X_INVERT ) );
+               PyConstant_Insert( d, "COPYYINVERT",
+                               PyInt_FromLong( LOCLIKE_Y_INVERT ) );
+               PyConstant_Insert( d, "COPYZINVERT",
+                               PyInt_FromLong( LOCLIKE_Z_INVERT ) );
 
                PyConstant_Insert( d, "TARGET",
                                PyInt_FromLong( EXPP_CONSTR_TARGET ) );
 
                PyConstant_Insert( d, "TARGET",
                                PyInt_FromLong( EXPP_CONSTR_TARGET ) );
index da69fb23c065187d5c6345766da9871feb2181e2..627db9050e3c09eae4ca380dfb0b642a2db75ef5 100644 (file)
@@ -82,7 +82,7 @@ Or to print all the constraints attached to each bone in a pose::
                - OFFSET (float): clamped to [-100.0,100.0]
                - STICKY (bool)
        - Used by Copy Location (COPYLOC) and Copy Rotation (COPYROT)
                - OFFSET (float): clamped to [-100.0,100.0]
                - STICKY (bool)
        - Used by Copy Location (COPYLOC) and Copy Rotation (COPYROT)
-               - COPY (bitfield): any combination of COPYX, COPYY and COPYZ
+               - COPY (bitfield): any combination of COPYX, COPYY and COPYZ with possible addition of COPYXINVERT, COPYYINVERT and COPYZINVERT to invert that particular input (if on).
                - LOCAL (bool): Only for constraints which Armature targets.
        - Used by Copy Size (COPYSIZE) constraint:
                - COPY (bitfield): any combination of COPYX, COPYY and COPYZ
                - LOCAL (bool): Only for constraints which Armature targets.
        - Used by Copy Size (COPYSIZE) constraint:
                - COPY (bitfield): any combination of COPYX, COPYY and COPYZ