diff --git a/source/blender/python/api2_2x/Modifier.c b/source/blender/python/api2_2x/Modifier.c index b43c810b435..49220bcd05e 100644 --- a/source/blender/python/api2_2x/Modifier.c +++ b/source/blender/python/api2_2x/Modifier.c @@ -64,17 +64,19 @@ enum mod_constants { EXPP_MOD_ONCAGE, /*GENERIC*/ - EXPP_MOD_OBJECT, /*ARMATURE, LATTICE, CURVE, BOOLEAN, ARRAY*/ - EXPP_MOD_VERTGROUP, /*ARMATURE, LATTICE, CURVE, SMOOTH, CAST*/ + EXPP_MOD_OBJECT, /*ARMATURE, LATTICE, CURVE, BOOLEAN, ARRAY, + SHRINKWRAP, SIMPLEDEFORM*/ + EXPP_MOD_VERTGROUP, /*ARMATURE, LATTICE, CURVE, SMOOTH, CAST, + SHRINKWRAP, SIMPLEDEFORM */ EXPP_MOD_LIMIT, /*ARRAY, MIRROR*/ EXPP_MOD_FLAG, /*MIRROR, WAVE*/ EXPP_MOD_COUNT, /*DECIMATOR, ARRAY*/ EXPP_MOD_LENGTH, /*BUILD, ARRAY*/ - EXPP_MOD_FACTOR, /*SMOOTH, CAST*/ + EXPP_MOD_FACTOR, /*SMOOTH, CAST, SIMPLEDEFORM*/ EXPP_MOD_ENABLE_X, /*SMOOTH, CAST*/ EXPP_MOD_ENABLE_Y, /*SMOOTH, CAST*/ EXPP_MOD_ENABLE_Z, /*SMOOTH, CAST*/ - EXPP_MOD_TYPES, /*SUBSURF, CAST*/ + EXPP_MOD_TYPES, /*SUBSURF, CAST, SHRINKWRAP, SIMPLEDEFORM*/ /*SUBSURF SPECIFIC*/ EXPP_MOD_LEVELS, @@ -144,8 +146,29 @@ enum mod_constants { EXPP_MOD_RADIUS, EXPP_MOD_SIZE, EXPP_MOD_USE_OB_TRANSFORM, - EXPP_MOD_SIZE_FROM_RADIUS - + EXPP_MOD_SIZE_FROM_RADIUS, + + /* SHRINKWRAP*/ + EXPP_MOD_OBJECT_AUX, + EXPP_MOD_KEEPDIST, + EXPP_MOD_PROJECT_OVER_X_AXIS, + EXPP_MOD_PROJECT_OVER_Y_AXIS, + EXPP_MOD_PROJECT_OVER_Z_AXIS, + EXPP_MOD_PROJECT_OVER_NORMAL, + EXPP_MOD_SUBSURFLEVELS, + EXPP_MOD_ALLOW_POS_DIR, + EXPP_MOD_ALLOW_NEG_DIR, + EXPP_MOD_CULL_TARGET_FRONTFACE, + EXPP_MOD_CULL_TARGET_BACKFACE, + EXPP_MOD_KEEP_ABOVE_SURFACE, + + /* SIMPLEDEFORM*/ + EXPP_MOD_RELATIVE, + EXPP_MOD_LOWER_LIMIT, + EXPP_MOD_UPPER_LIMIT, + EXPP_MOD_LOCK_AXIS_X, + EXPP_MOD_LOCK_AXIS_Y + /* yet to be implemented */ /* EXPP_MOD_HOOK_,*/ /* , */ @@ -989,6 +1012,43 @@ static PyObject *shrinkwrap_getter( BPy_Modifier * self, int type ) switch( type ) { case EXPP_MOD_OBJECT: return Object_CreatePyObject( md->target ); + case EXPP_MOD_OBJECT_AUX: + return Object_CreatePyObject( md->auxTarget ); + case EXPP_MOD_VERTGROUP: + return PyString_FromString( md->vgroup_name ) ; + case EXPP_MOD_TYPES: + return PyInt_FromLong( (long)md->shrinkType ); + case EXPP_MOD_ALLOW_POS_DIR: + return PyBool_FromLong( ( long ) + ( md->shrinkOpts & MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR) ) ; + case EXPP_MOD_ALLOW_NEG_DIR: + return PyBool_FromLong( ( long ) + ( md->shrinkOpts & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR) ) ; + case EXPP_MOD_CULL_TARGET_FRONTFACE: + return PyBool_FromLong( ( long ) + ( md->shrinkOpts & MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE) ) ; + case EXPP_MOD_CULL_TARGET_BACKFACE: + return PyBool_FromLong( ( long ) + ( md->shrinkOpts & MOD_SHRINKWRAP_CULL_TARGET_BACKFACE) ) ; + case EXPP_MOD_KEEP_ABOVE_SURFACE: + return PyBool_FromLong( ( long ) + ( md->shrinkOpts & MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE) ) ; + case EXPP_MOD_KEEPDIST: + return PyFloat_FromDouble( (double)md->keepDist ); + case EXPP_MOD_PROJECT_OVER_X_AXIS: + return PyBool_FromLong( ( long ) + ( md->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS) ) ; + case EXPP_MOD_PROJECT_OVER_Y_AXIS: + return PyBool_FromLong( ( long ) + ( md->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS) ) ; + case EXPP_MOD_PROJECT_OVER_Z_AXIS: + return PyBool_FromLong( ( long ) + ( md->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS) ) ; + case EXPP_MOD_PROJECT_OVER_NORMAL: + return PyBool_FromLong( ( long ) + ( md->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) ) ; + case EXPP_MOD_SUBSURFLEVELS: + return PyInt_FromLong( ( long )md->subsurfLevels ); default: return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" ); } @@ -1012,11 +1072,144 @@ static int shrinkwrap_setter( BPy_Modifier *self, int type, PyObject *value ) } return 0; } + case EXPP_MOD_OBJECT_AUX: { + Object *ob_new=NULL; + if (value == Py_None) { + md->auxTarget = NULL; + } else if (BPy_Object_Check( value )) { + ob_new = ((( BPy_Object * )value)->object); + md->auxTarget = ob_new; + } else { + return EXPP_ReturnIntError( PyExc_TypeError, + "Expected an Object or None value" ); + } + return 0; + } + case EXPP_MOD_VERTGROUP:{ + char *defgrp_name = PyString_AsString( value ); + if( !defgrp_name ) + return EXPP_ReturnIntError( PyExc_TypeError, + "expected string arg" ); + BLI_strncpy( md->vgroup_name, defgrp_name, sizeof( md->vgroup_name ) ); + return 0; + } + case EXPP_MOD_TYPES: + return EXPP_setIValueRange( value, &md->shrinkType, 0, + MOD_SHRINKWRAP_NEAREST_VERTEX, 'h' ); + case EXPP_MOD_KEEPDIST: + return EXPP_setFloatClamped( value, &md->keepDist, -1000.0, +1000.0 ); + case EXPP_MOD_PROJECT_OVER_X_AXIS: + return EXPP_setBitfield( value, &md->projAxis, + MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS, 'h' ); + case EXPP_MOD_PROJECT_OVER_Y_AXIS: + return EXPP_setBitfield( value, &md->projAxis, + MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS, 'h' ); + case EXPP_MOD_PROJECT_OVER_Z_AXIS: + return EXPP_setBitfield( value, &md->projAxis, + MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS, 'h' ); + case EXPP_MOD_PROJECT_OVER_NORMAL: + return EXPP_setBitfield( value, &md->projAxis, + MOD_SHRINKWRAP_PROJECT_OVER_NORMAL, 'h' ); + + case EXPP_MOD_ALLOW_POS_DIR: + return EXPP_setBitfield( value, &md->shrinkOpts, + MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR, 'h' ); + case EXPP_MOD_ALLOW_NEG_DIR: + return EXPP_setBitfield( value, &md->shrinkOpts, + MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR, 'h' ); + case EXPP_MOD_CULL_TARGET_FRONTFACE: + return EXPP_setBitfield( value, &md->shrinkOpts, + MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE, 'h' ); + case EXPP_MOD_CULL_TARGET_BACKFACE: + return EXPP_setBitfield( value, &md->shrinkOpts, + MOD_SHRINKWRAP_CULL_TARGET_BACKFACE, 'h' ); + case EXPP_MOD_KEEP_ABOVE_SURFACE: + return EXPP_setBitfield( value, &md->shrinkOpts, + MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE, 'h' ); + case EXPP_MOD_SUBSURFLEVELS: + return EXPP_setIValueClamped( value, &md->subsurfLevels, 1, 6, 'h' ); + default: return EXPP_ReturnIntError( PyExc_KeyError, "key not found" ); } } +static PyObject *simpledeform_getter( BPy_Modifier * self, int type ) +{ + SimpleDeformModifierData *md = (SimpleDeformModifierData *)(self->md); + + switch( type ) { + case EXPP_MOD_OBJECT: + return Object_CreatePyObject( md->origin ); + case EXPP_MOD_TYPES: + return PyInt_FromLong( (long)md->mode ); + case EXPP_MOD_FACTOR: + return PyFloat_FromDouble( (double)md->factor ); + case EXPP_MOD_UPPER_LIMIT: + return PyFloat_FromDouble( (double)md->limit[1] ); + case EXPP_MOD_LOWER_LIMIT: + return PyFloat_FromDouble( (double)md->limit[0] ); + case EXPP_MOD_VERTGROUP: + return PyString_FromString( md->vgroup_name ) ; + case EXPP_MOD_RELATIVE: + return PyBool_FromLong( (long) md->originOpts ) ; + case EXPP_MOD_LOCK_AXIS_X: + return PyBool_FromLong( (long) + ( md->axis & MOD_SIMPLEDEFORM_LOCK_AXIS_X) ) ; + case EXPP_MOD_LOCK_AXIS_Y: + return PyBool_FromLong( (long) + ( md->axis & MOD_SIMPLEDEFORM_LOCK_AXIS_Y) ) ; + default: + return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" ); + } +} + +static int simpledeform_setter( BPy_Modifier *self, int type, PyObject *value ) +{ + SimpleDeformModifierData *md = (SimpleDeformModifierData *)(self->md); + + switch( type ) { + case EXPP_MOD_OBJECT: { /* Only object for now */ + Object *ob_new=NULL; + if (value == Py_None) { + md->origin = NULL; + } else if (BPy_Object_Check( value )) { + ob_new = ((( BPy_Object * )value)->object); + md->origin = ob_new; + } else { + return EXPP_ReturnIntError( PyExc_TypeError, + "Expected an Object or None value" ); + } + return 0; + } + case EXPP_MOD_TYPES: + return EXPP_setIValueRange( value, &md->mode, 1, MOD_SIMPLEDEFORM_MODE_STRETCH, 'h' ); + case EXPP_MOD_FACTOR: + return EXPP_setFloatClamped( value, &md->factor, -10.0, 10.0 ); + case EXPP_MOD_LOWER_LIMIT: + return EXPP_setFloatClamped( value, &md->limit[0], 0.0, md->limit[1] ); + case EXPP_MOD_UPPER_LIMIT: + return EXPP_setFloatClamped( value, &md->limit[1], md->limit[0], 1.0 ); + case EXPP_MOD_VERTGROUP:{ + char *defgrp_name = PyString_AsString( value ); + if( !defgrp_name ) + return EXPP_ReturnIntError( PyExc_TypeError, + "expected string arg" ); + BLI_strncpy( md->vgroup_name, defgrp_name, sizeof( md->vgroup_name ) ); + return 0; + } + case EXPP_MOD_RELATIVE: + return EXPP_setBitfield( value, &md->originOpts, 1, 'h' ); + case EXPP_MOD_LOCK_AXIS_X: + return EXPP_setBitfield( value, &md->axis, + MOD_SIMPLEDEFORM_LOCK_AXIS_X, 'h' ); + case EXPP_MOD_LOCK_AXIS_Y: + return EXPP_setBitfield( value, &md->axis, + MOD_SIMPLEDEFORM_LOCK_AXIS_Y, 'h' ); + default: + return EXPP_ReturnIntError( PyExc_KeyError, "key not found" ); + } +} /* static PyObject *uvproject_getter( BPy_Modifier * self, int type ) { @@ -1100,7 +1293,9 @@ static PyObject *Modifier_getData( BPy_Modifier * self, PyObject * key ) case eModifierType_Shrinkwrap: return shrinkwrap_getter( self, setting ); /*case eModifierType_UVProject: - return uvproject_getter( self, setting );*/ + return uvproject_getter( self, setting );*/ + case eModifierType_SimpleDeform: + return simpledeform_getter( self, setting ); case eModifierType_Hook: case eModifierType_Softbody: case eModifierType_None: @@ -1171,6 +1366,8 @@ static int Modifier_setData( BPy_Modifier * self, PyObject * key, return displace_setter( self, key_int, arg ); case eModifierType_Shrinkwrap: return shrinkwrap_setter( self, key_int, arg ); + case eModifierType_SimpleDeform: + return simpledeform_setter( self, key_int, arg ); /*case eModifierType_UVProject: return uvproject_setter( self, key_int, arg );*/ case eModifierType_Hook: @@ -1603,8 +1800,8 @@ static PyObject *M_Modifier_TypeDict( void ) PyInt_FromLong( eModifierType_Bevel ) ); PyConstant_Insert( d, "SHRINKWRAP", PyInt_FromLong( eModifierType_Shrinkwrap ) ); - PyConstant_Insert( d, "SHRINKWRAP", - PyInt_FromLong( eModifierType_Shrinkwrap ) ); + PyConstant_Insert( d, "SIMPLEDEFORM", + PyInt_FromLong( eModifierType_SimpleDeform ) ); } return S; } @@ -1768,6 +1965,39 @@ for var in st.replace(',','').split('\n'): PyConstant_Insert( d, "SIZE_FROM_RADIUS", PyInt_FromLong( EXPP_MOD_SIZE_FROM_RADIUS ) ); /*End Auto generated code*/ + PyConstant_Insert( d, "RELATIVE", + PyInt_FromLong( EXPP_MOD_RELATIVE ) ); + PyConstant_Insert( d, "UPPER_LIMIT", + PyInt_FromLong( EXPP_MOD_UPPER_LIMIT ) ); + PyConstant_Insert( d, "LOWER_LIMIT", + PyInt_FromLong( EXPP_MOD_LOWER_LIMIT ) ); + PyConstant_Insert( d, "LOCK_AXIS_X", + PyInt_FromLong( EXPP_MOD_LOCK_AXIS_X ) ); + PyConstant_Insert( d, "LOCK_AXIS_Y", + PyInt_FromLong( EXPP_MOD_LOCK_AXIS_Y ) ); + + PyConstant_Insert( d, "OBJECT_AUX", + PyInt_FromLong( EXPP_MOD_OBJECT_AUX ) ); + PyConstant_Insert( d, "KEEPDIST", + PyInt_FromLong( EXPP_MOD_KEEPDIST ) ); + PyConstant_Insert( d, "PROJECT_OVER_X_AXIS", + PyInt_FromLong( EXPP_MOD_PROJECT_OVER_X_AXIS ) ); + PyConstant_Insert( d, "PROJECT_OVER_Y_AXIS", + PyInt_FromLong( EXPP_MOD_PROJECT_OVER_Y_AXIS ) ); + PyConstant_Insert( d, "PROJECT_OVER_Z_AXIS", + PyInt_FromLong( EXPP_MOD_PROJECT_OVER_Z_AXIS ) ); + PyConstant_Insert( d, "SUBSURFLEVELS", + PyInt_FromLong( EXPP_MOD_SUBSURFLEVELS ) ); + PyConstant_Insert( d, "ALLOW_POS_DIR", + PyInt_FromLong( EXPP_MOD_ALLOW_POS_DIR ) ); + PyConstant_Insert( d, "ALLOW_NEG_DIR", + PyInt_FromLong( EXPP_MOD_ALLOW_NEG_DIR ) ); + PyConstant_Insert( d, "CULL_TARGET_FRONTFACE", + PyInt_FromLong( EXPP_MOD_CULL_TARGET_FRONTFACE ) ); + PyConstant_Insert( d, "CULL_TARGET_BACKFACE", + PyInt_FromLong( EXPP_MOD_CULL_TARGET_BACKFACE ) ); + PyConstant_Insert( d, "KEEP_ABOVE_SURFACE", + PyInt_FromLong( EXPP_MOD_KEEP_ABOVE_SURFACE ) ); } return S; } diff --git a/source/blender/python/api2_2x/doc/Modifier.py b/source/blender/python/api2_2x/doc/Modifier.py index 03b868d3605..8b62a7270f0 100644 --- a/source/blender/python/api2_2x/doc/Modifier.py +++ b/source/blender/python/api2_2x/doc/Modifier.py @@ -50,18 +50,23 @@ Example:: modifier sequence and comparing with L{Modifier.type}: - ARMATURE - type value for Armature modifiers - ARRAY - type value for Array modifiers - - BOOLEAN - type value for Boolean modifiers + - BEVEL - type value for Bevel modifiers + - BOOLEAN - type value for Boolean modifiers - BUILD - type value for Build modifiers - - CURVE - type value for Curve modifiers - - MIRROR - type value for Mirror modifiers - - DECIMATE - type value for Decimate modifiers - - LATTICE - type value for Lattice modifiers - - SUBSURF - type value for Subsurf modifiers - - WAVE - type value for Wave modifiers - - EDGESPLIT - type value for Edge Split modifiers - - DISPLACE - type value for Displace modifiers - - SMOOTH - type value for Smooth modifiers - CAST - type value for Cast modifiers + - CURVE - type value for Curve modifiers + - DECIMATE - type value for Decimate modifiers + - DISPLACE - type value for Displace modifiers + - EDGESPLIT - type value for Edge Split modifiers + - LATTICE - type value for Lattice modifiers + - MESHDEFORM - type value for MeshDeform modifiers + - MASK - type value for Mask modifiers + - MIRROR - type value for Mirror modifiers + - SHRINKWRAP - type value for Shrinkwrap modifiers + - SIMPLEDEFORM - type value for SimpleDeform modifiers + - SMOOTH - type value for Smooth modifiers + - SUBSURF - type value for Subsurf modifiers + - WAVE - type value for Wave modifiers @type Settings: readonly dictionary @var Settings: Constant Modifier dict used for changing modifier settings. @@ -70,17 +75,17 @@ Example:: - EDITMODE - Used for all modifiers (bool) If both REALTIME and EDITMODE are true, the modifier is enabled for interactive display while the object is in edit mode. - ONCAGE - Used for all modifiers (bool) If true, the modifier is enabled for the editing cage during edit mode. - - OBJECT - Used for Armature, Lattice, Curve, Boolean and Array (Object) - - VERTGROUP - Used for Armature, Lattice, Curve, Smooth and Cast (String) - - LIMIT - Array and Mirror (float [0.0 - 1.0]) + - OBJECT - Used for Armature, Lattice, Curve, Boolean, Array, Shrinkwrap and SimpleDeform (Object) + - VERTGROUP - Used for Armature, Lattice, Curve, Smooth, Cast, Shrinkwrap and SimpleDeform (String) + - LIMIT - Array, Mirror (float [0.0 - 1.0]) - FLAG - Mirror and Wave (int) - COUNT - Decimator Polycount (readonly) and Array (int) - LENGTH - Build [1.0-300000.0] and Array [0.0 - 10000.0] (float) - - FACTOR - Smooth [-10.0, 10.0] and Cast [-10.0, 10.0] (float) + - FACTOR - Smooth [-10.0, 10.0], Cast [-10.0, 10.0] and SimpleDeform [-10.0, 10.0] (float) - ENABLE_X = Smooth and Cast (bool, default: True) - ENABLE_Y = Smooth and Cast (bool, default: True) - ENABLE_Z = Smooth and Cast (bool, default: True) - - TYPES - Subsurf and Cast. For Subsurf it determines the subdivision algorithm - (int): 0 = Catmull-Clark; 1 = simple subdivision. For Cast it determines the shape to deform to = (int): 0 = Sphere; 1 = Cylinder; 2 = Cuboid + - TYPES - Subsurf, Cast, Shrinkwrap and SimpleDeform. For Subsurf it determines the subdivision algorithm - (int): 0 = Catmull-Clark; 1 = simple subdivision. For Cast it determines the shape to deform to = (int): 0 = Sphere; 1 = Cylinder; 2 = Cuboid. For Shrinkwrap it determines where it has to project = (int): 0 = Nearest surface; 1 = Project; 2 = Nearest vertex. For DeformMesh it determines the function to apply = (int): 1 = Twist; 2 = Bend; 3 = Taper; 4 = Stretch. - LEVELS - Used for Subsurf only (int [0 - 6]). The number of subdivision levels used for interactive display. - RENDLEVELS - Used for Subsurf only (int [0 - 6]). The number of subdivision levels used for rendering. @@ -139,6 +144,26 @@ Example:: - SIZE - Used for Cast only (float [0.0, 100.0], default: 0.0) - SIZE_FROM_RADIUS - Used for Cast only (bool, default: True) - USE_OB_TRANSFORM - Used for Cast only (bool, default: False) + + - OBJECT_AUX - Used for Shrinkwrap only, (Object) + - KEEPDIST - Used for Shrinkwrap only (float [-1000.0, 1000.0, default: 0.0) + - PROJECT_OVER_X_AXIS - Used for Shrinkwrap only, should the modifier not project over normal (bool) + - PROJECT_OVER_Y_AXIS - Used for Shrinkwrap only, should the modifier not project over normal (bool) + - PROJECT_OVER_Z_AXIS - Used for Shrinkwrap only, should the modifier not project over normal (bool) + - PROJECT_OVER_NORMAL - Used for Shrinkwrap only (bool) + - ALLOW_POS_DIR - Used for Shrinkwrap only, should the modifier use Project TYPES (bool) + - ALLOW_NEG_DIR - Used for Shrinkwrap only, should the modifier use Project TYPES (bool) + - CULL_TARGET_FRONTFACE - Used for Shrinkwrap only, should the modifier use Project TYPES (bool) + - CULL_TARGET_BACKFACE - Used for Shrinkwrap only, should the modifier use Project TYPES (bool) + - KEEP_ABOVE_SURFACE - Used for Shrinkwrap only , should the modifier use Nearest Surface TYPES(bool) + - SUBSURFLEVELS - Used for Shrinkwrap only (int [0 - 6]). The number of subdivision levels used. + + - RELATIVE - Used for Simpledeform only (bool, default: False) + - LOWER_LIMIT - Used for Simpledeform only (float [0.0, UPPER_LIMIT], default: 0.0)) + - UPPER_LIMIT - Used for Simpledeform only (float [LOWER_LIMIT,1.0], default: 1.0)) + - LOCK_AXIS_X - Used for Simpledeform only (bool, default: False) + - LOCK_AXIS_Y - Used for Simpledeform only (bool, default: False) + """ class ModSeq: