Python API
authorKen Hughes <khughes@pacific.edu>
Fri, 21 Sep 2007 20:46:17 +0000 (20:46 +0000)
committerKen Hughes <khughes@pacific.edu>
Fri, 21 Sep 2007 20:46:17 +0000 (20:46 +0000)
----------

Bgfix #7386: added support for texture flags TEX_PRV_ALPHA, TEX_REPEAT_XMIR and
TEX_REPEAT_YMIR to tex.flags attribute.

source/blender/makesdna/DNA_texture_types.h
source/blender/python/api2_2x/Texture.c
source/blender/python/api2_2x/doc/Texture.py

index 064cfe39d45bedfdd9e15b9f4922d9214572943b..794d818d8fe3e5d3c7ce60d9dd6c67f6ffe327fc 100644 (file)
@@ -265,6 +265,7 @@ typedef struct TexMapping {
 #define TEX_PRV_NOR                    64
 #define TEX_REPEAT_XMIR                128
 #define TEX_REPEAT_YMIR                256
+#define TEX_FLAG_MASK          ( TEX_COLORBAND | TEX_FLIPBLEND | TEX_NEGALPHA | TEX_CHECKER_ODD | TEX_CHECKER_EVEN | TEX_PRV_ALPHA | TEX_PRV_NOR | TEX_REPEAT_XMIR | TEX_REPEAT_YMIR ) 
 
 /* extend (starts with 1 because of backward comp.) */
 #define TEX_EXTEND             1
index 2f2443eef8883ca3d148462d7df0db65cbe3d42d..34906757ebd5f1ade4d9a3232fe420667f48b210 100644 (file)
@@ -203,11 +203,14 @@ static const EXPP_map_pair tex_type_map[] = {
 
 static const EXPP_map_pair tex_flag_map[] = {
 /* NOTE "CheckerOdd" and "CheckerEven" are new */
-    {"ColorBand",  TEX_COLORBAND },
+       {"ColorBand",  TEX_COLORBAND },
        {"FlipBlend", TEX_FLIPBLEND},
        {"NegAlpha", TEX_NEGALPHA},
        {"CheckerOdd",TEX_CHECKER_ODD},
        {"CheckerEven",TEX_CHECKER_EVEN},
+       {"PreviewAlpha",TEX_PRV_ALPHA},
+       {"RepeatXMirror",TEX_REPEAT_XMIR},
+       {"RepeatYMirror",TEX_REPEAT_YMIR}, 
        {NULL, 0}
 };
 
@@ -1162,6 +1165,9 @@ static PyObject *M_Texture_FlagsDict( void )
                PyConstant_Insert(d, "NEGALPHA", PyInt_FromLong(TEX_NEGALPHA));
                PyConstant_Insert(d, "CHECKER_ODD", PyInt_FromLong(TEX_CHECKER_ODD)); 
                PyConstant_Insert(d, "CHECKER_EVEN", PyInt_FromLong(TEX_CHECKER_EVEN));
+               PyConstant_Insert(d, "PREVIEW_ALPHA", PyInt_FromLong(TEX_PRV_ALPHA));
+               PyConstant_Insert(d, "REPEAT_XMIR", PyInt_FromLong(TEX_REPEAT_XMIR));
+               PyConstant_Insert(d, "REPEAT_YMIR", PyInt_FromLong(TEX_REPEAT_YMIR));
        }
        return Flags;
 }
@@ -1528,20 +1534,15 @@ static int Texture_setFilterSize( BPy_Texture * self, PyObject * value )
 static int Texture_setFlags( BPy_Texture * self, PyObject * value )
 {
        int param;
-       int bitmask = TEX_FLIPBLEND
-                                       | TEX_COLORBAND
-                                       | TEX_NEGALPHA
-                                       | TEX_CHECKER_ODD
-                                       | TEX_CHECKER_EVEN;
 
        if( !PyInt_Check( value ) ) {
                char errstr[128];
-               sprintf ( errstr , "expected int bitmask of 0x%08x", bitmask );
+               sprintf ( errstr , "expected int bitmask of 0x%08x", TEX_FLAG_MASK );
                return EXPP_ReturnIntError( PyExc_TypeError, errstr );
        }
        param = PyInt_AS_LONG ( value );
 
-       if ( ( param & bitmask ) != param )
+       if ( ( param & TEX_FLAG_MASK ) != param )
                return EXPP_ReturnIntError( PyExc_ValueError,
                                                "invalid bit(s) set in mask" );
 
index 684897c8635e8fba5d7291e765ff816b0f0a94db..004cd2df274ba27f4677eb4c8a18b6b835fe7f79 100644 (file)
@@ -60,6 +60,9 @@ Example::
                - CHECKER_ODD - Fill the "odd" checkerboard tiles
                - CHECKER_EVEN - Fill the "even" checkerboard tiles
                - COLORBAND - Enable colorband for this texture
+        - PREVIEW_ALPHA - Show alpha in preview
+        - REPEAT_XMIR - Mirrors X direction repeat
+        - REPEAT_YMIR - Mirrors Y direction repeat
 
 @type ImageFlags: readonly dictionary
 @var ImageFlags: The available image flags for Texture.imageFlags: