[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11437] branches/pyapi_devel/source/ blender/python/api2_2x: update to MTex type

Campbell Barton cbarton at metavr.com
Mon Jul 30 22:04:23 CEST 2007


Revision: 11437
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11437
Author:   campbellbarton
Date:     2007-07-30 22:04:23 +0200 (Mon, 30 Jul 2007)

Log Message:
-----------
update to MTex type
* general update and code cleanup
* use new constants
* dont use a pointer directly to data (very bad! since these are allocated and deallocated frequently), point to the ID instead.
* color now wraps MTex color

Modified Paths:
--------------
    branches/pyapi_devel/source/blender/python/api2_2x/BGL.c
    branches/pyapi_devel/source/blender/python/api2_2x/Effect.c
    branches/pyapi_devel/source/blender/python/api2_2x/Font.c
    branches/pyapi_devel/source/blender/python/api2_2x/Group.c
    branches/pyapi_devel/source/blender/python/api2_2x/Library.c
    branches/pyapi_devel/source/blender/python/api2_2x/MTex.c
    branches/pyapi_devel/source/blender/python/api2_2x/MTex.h
    branches/pyapi_devel/source/blender/python/api2_2x/NLA.c
    branches/pyapi_devel/source/blender/python/api2_2x/Texture.c
    branches/pyapi_devel/source/blender/python/api2_2x/charRGBA.c
    branches/pyapi_devel/source/blender/python/api2_2x/color.c
    branches/pyapi_devel/source/blender/python/api2_2x/gen_library.c
    branches/pyapi_devel/source/blender/python/api2_2x/gen_utils.c
    branches/pyapi_devel/source/blender/python/api2_2x/gen_utils.h
    branches/pyapi_devel/source/blender/python/api2_2x/sceneSequence.c

Modified: branches/pyapi_devel/source/blender/python/api2_2x/BGL.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/BGL.c	2007-07-30 19:40:23 UTC (rev 11436)
+++ branches/pyapi_devel/source/blender/python/api2_2x/BGL.c	2007-07-30 20:04:23 UTC (rev 11437)
@@ -215,7 +215,7 @@
 	
 	buffer= make_buffer(type, ndimensions, dimensions);
 	if (template && ndimensions) {
-		if (GLBuffer_ass_slice((PyObject *) buffer, 0, dimensions[0], template)) {
+		if (GLBuffer_ass_slice(buffer, 0, dimensions[0], template)) {
 			Py_DECREF(buffer);
 			return NULL;
 		}
@@ -301,7 +301,7 @@
 	}
 	
 	if (self->ndimensions!=1) {
-		PyObject *row= GLBuffer_item(self, i);
+		BPyGLBufferObject *row= GLBuffer_item(self, i);
 		int ret;
 
 		if (!row) return -1;

Modified: branches/pyapi_devel/source/blender/python/api2_2x/Effect.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Effect.c	2007-07-30 19:40:23 UTC (rev 11436)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Effect.c	2007-07-30 20:04:23 UTC (rev 11437)
@@ -1186,4 +1186,4 @@
 		PyType_Ready( &BPyEffect_Type ) ;
 	}
 	return (PyObject *) &BPyEffect_Type ;
-}
\ No newline at end of file
+}

Modified: branches/pyapi_devel/source/blender/python/api2_2x/Font.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Font.c	2007-07-30 19:40:23 UTC (rev 11436)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Font.c	2007-07-30 20:04:23 UTC (rev 11437)
@@ -293,4 +293,4 @@
 {
 	PyType_Ready( &BPyFont_Type ) ;
 	return (PyObject *) &BPyFont_Type ;
-}
\ No newline at end of file
+}

Modified: branches/pyapi_devel/source/blender/python/api2_2x/Group.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Group.c	2007-07-30 19:40:23 UTC (rev 11436)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Group.c	2007-07-30 20:04:23 UTC (rev 11437)
@@ -728,4 +728,4 @@
 {
 	PyType_Ready( &BPyGroupObSeq_Type );
 	return (PyObject *) &BPyGroupObSeq_Type;
-}
\ No newline at end of file
+}

Modified: branches/pyapi_devel/source/blender/python/api2_2x/Library.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Library.c	2007-07-30 19:40:23 UTC (rev 11436)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Library.c	2007-07-30 20:04:23 UTC (rev 11437)
@@ -78,9 +78,6 @@
 /**
  * Module doc strings.
  */
-static char M_Library_doc[] = "The Blender.Library submodule:\n\n\
-This module gives access to .blend files, using them as libraries of\n\
-data that can be loaded into the current scene in Blender.";
 
 static char Library_Open_doc[] =
 	"(filename) - Open the given .blend file for access to its objects.\n\

Modified: branches/pyapi_devel/source/blender/python/api2_2x/MTex.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/MTex.c	2007-07-30 19:40:23 UTC (rev 11436)
+++ branches/pyapi_devel/source/blender/python/api2_2x/MTex.c	2007-07-30 20:04:23 UTC (rev 11437)
@@ -35,720 +35,481 @@
 #include "BLI_blenlib.h"
 #include "Texture.h"
 #include "Object.h"
+#include "color.h"
+#include "Const.h"
 #include "gen_utils.h"
 #include "gen_library.h"
 
 #include <DNA_material_types.h>
+#include <DNA_lamp_types.h>
+#include <DNA_world_types.h>
 
-/*****************************************************************************/
-/* Python BPyMTexObject methods declarations:                                     */
-/*****************************************************************************/
-static PyObject *MTex_setTexMethod( BPyMTexObject * self, PyObject * args );
+enum mtex_float_consts {
+	EXPP_TEX_ATTR_NOISESIZE = 0,
+};
 
-/*****************************************************************************/
-/* Python BPyMTexObject methods table:                                            */
-/*****************************************************************************/
-static PyMethodDef BPyMTex_methods[] = {
-	/* name, method, flags, doc */
-	{"setTex", ( PyCFunction ) MTex_setTexMethod, METH_VARARGS,
-	 "(i) - Set MTex Texture"},
-	{NULL, NULL, 0, NULL}
+enum tex_float_consts {
+	EXPP_MTEX_ATTR_DEF_VAR = 0,
+	EXPP_MTEX_ATTR_COLFAC,
+	EXPP_MTEX_ATTR_NORFAC,
+	EXPP_MTEX_ATTR_VARFAC,
+	EXPP_MTEX_ATTR_DISPFAC,
+	EXPP_MTEX_ATTR_WARPFAC,
+	EXPP_MTEX_ATTR_XOFS,
+	EXPP_MTEX_ATTR_YOFS,
+	EXPP_MTEX_ATTR_ZOFS,
+	EXPP_MTEX_ATTR_XSCA,
+	EXPP_MTEX_ATTR_YSCA,
+	EXPP_MTEX_ATTR_ZSCA,
 };
 
-/*****************************************************************************/
-/* Python BPyMTex_Type callback function prototypes:                            */
-/*****************************************************************************/
-static int MTex_compare( BPyMTexObject * a, BPyMTexObject * b );
-static PyObject *MTex_repr( BPyMTexObject * self );
+enum tex_const_consts {
+	EXPP_MTEX_ATTR_COORD = 0,
+	EXPP_MTEX_ATTR_MAPPING,
+	EXPP_MTEX_ATTR_BLEND,
+};
 
-#define MTEXGET(x) \
-	static PyObject *MTex_get##x( BPyMTexObject *self, void *closure );
-#define MTEXSET(x) \
-	static int MTex_set##x( BPyMTexObject *self, PyObject *value, void *closure);
-#define MTEXGETSET(x) \
-	MTEXGET(x) \
-	MTEXSET(x)
+/* 
+ * structure of "tuples" of constant's string name and int value
+ *
+ * For example, these two structures will define the constant category
+ * "bpy.types.Object.DrawTypes" the constant 
+ * "bpy.types.Object.DrawTypes.BOUNDBOX" and others.
+ */
 
-MTEXGETSET(Tex)
-MTEXGETSET(TexCo)
-MTEXGETSET(Object)
-MTEXGETSET(UVLayer)
-MTEXGETSET(MapTo)
-MTEXGETSET(Col)
-MTEXGETSET(DVar)
-MTEXGETSET(BlendMode)
-MTEXGETSET(ColFac)
-MTEXGETSET(NorFac)
-MTEXGETSET(VarFac)
-MTEXGETSET(DispFac)
-MTEXGETSET(WarpFac)
-MTEXGETSET(Ofs)
-MTEXGETSET(Size)
-MTEXGETSET(Mapping)
-MTEXGETSET(Flag)
-MTEXGETSET(ProjX)
-MTEXGETSET(ProjY)
-MTEXGETSET(ProjZ)
-MTEXGETSET(MapToFlag)
+static constIdents coordTypesIdents[] = {
+	{"ORCO",			{(int)TEXCO_ORCO}},
+	{"REFLECT",			{(int)TEXCO_REFL}},
+	{"NORMAL",			{(int)TEXCO_NORM}},
+	{"GLOBAL",			{(int)TEXCO_GLOB}},
+	{"UV",				{(int)TEXCO_UV}},
+	{"OBJECT",			{(int)TEXCO_OBJECT}},
+	/*{"LAVECTOR",		{(int)TEXCO_LAVECTOR}}, - not used? */
+	{"VIEW",			{(int)TEXCO_VIEW}},
+	{"STICKY",			{(int)TEXCO_STICKY}},
+	/*{"OSA",			{(int)TEXCO_OSA}}, - internal use only */
+	{"WINDOW",			{(int)TEXCO_WINDOW}},
+	/*{"UV",			{(int)NEED_UV}}, - internal use only */
+	{"TANGENT",			{(int)TEXCO_TANGENT}},
+	{"STRESS",			{(int)TEXCO_STRESS}},
+};
 
-/*****************************************************************************/
-/* Python get/set methods table                                              */
-/*****************************************************************************/
+static constDefinition coordTypes = {
+	EXPP_CONST_INT, "MappingCoords",
+		sizeof(coordTypesIdents)/sizeof(constIdents), coordTypesIdents
+};
 
-static PyGetSetDef MTex_getset[] = {
-	{ "tex", (getter) MTex_getTex, (setter) MTex_setTex,
-		"Texture whose mapping this MTex describes", NULL },
-	{ "texco", (getter) MTex_getTexCo, (setter) MTex_setTexCo,
-		"Texture coordinate space (UV, Global, etc.)", NULL },
-	{ "object", (getter) MTex_getObject, (setter) MTex_setObject,
-		"Object whose space to use when texco is Object", NULL },
-	{ "uvlayer", (getter) MTex_getUVLayer, (setter) MTex_setUVLayer,
-		"Name of the UV layer to use", NULL },
-	{ "mapto", (getter) MTex_getMapTo, (setter) MTex_setMapTo,
-		"What values the texture affects", NULL },
-	{ "col", (getter) MTex_getCol, (setter) MTex_setCol,
-		"Color that the texture blends with", NULL },
-	{ "dvar", (getter) MTex_getDVar, (setter) MTex_setDVar,
-		"Value that the texture blends with when not blending colors", NULL },
-	{ "blendmode", (getter) MTex_getBlendMode, (setter) MTex_setBlendMode,
-		"Texture blending mode", NULL },
-	{ "colfac", (getter) MTex_getColFac, (setter) MTex_setColFac,
-		"Factor by which texture affects color", NULL },
-	{ "norfac", (getter) MTex_getNorFac, (setter) MTex_setNorFac,
-		"Factor by which texture affects normal", NULL },
-	{ "varfac", (getter) MTex_getVarFac, (setter) MTex_setVarFac,
-		"Factor by which texture affects most variables", NULL },
-	{ "dispfac", (getter) MTex_getDispFac, (setter) MTex_setDispFac,
-		"Factor by which texture affects displacement", NULL },
-	{ "warpfac", (getter) MTex_getWarpFac, (setter) MTex_setWarpFac,
-		"Factor by which texture affects warp", NULL },
-	{ "ofs", (getter) MTex_getOfs, (setter) MTex_setOfs,
-		"Offset to adjust texture space", NULL },
-	{ "size", (getter) MTex_getSize, (setter) MTex_setSize,
-		"Size to scale texture space", NULL },
-	{ "mapping", (getter) MTex_getMapping, (setter) MTex_setMapping,
-		"Mapping of texture coordinates (flat, cube, etc.)", NULL },
-	{ "stencil", (getter) MTex_getFlag, (setter) MTex_setFlag,
-		"Stencil mode", (void*) MTEX_STENCIL },
-	{ "neg", (getter) MTex_getFlag, (setter) MTex_setFlag,
-		"Negate texture values mode", (void*) MTEX_NEGATIVE },
-	{ "noRGB", (getter) MTex_getFlag, (setter) MTex_setFlag,
-		"Convert texture RGB values to intensity values",
-		(void*) MTEX_RGBTOINT },
-	{ "correctNor", (getter) MTex_getFlag, (setter) MTex_setFlag,
-		"Correct normal mapping for Texture space and Object space",
-		(void*) MTEX_VIEWSPACE },
-	{ "xproj", (getter) MTex_getProjX, (setter) MTex_setProjX,
-		"Projection of X axis to Texture space", NULL },
-	{ "yproj", (getter) MTex_getProjY, (setter) MTex_setProjY,
-		"Projection of Y axis to Texture space", NULL },
-	{ "zproj", (getter) MTex_getProjZ, (setter) MTex_setProjZ,
-		"Projection of Z axis to Texture space", NULL },
-	{ "mtCol", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
-		"How texture maps to color", (void*) MAP_COL },
-	{ "mtNor", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
-		"How texture maps to normals", (void*) MAP_NORM },
-	{ "mtCsp", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
-		"How texture maps to specularity color", (void*) MAP_COLSPEC },
-	{ "mtCmir", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
-		"How texture maps to mirror color", (void*) MAP_COLMIR },
-	{ "mtRef", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
-		"How texture maps to reflectivity", (void*) MAP_REF },

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list