[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33358] trunk/blender: minor changes to the python api.

Campbell Barton ideasman42 at gmail.com
Sun Nov 28 07:03:45 CET 2010


Revision: 33358
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33358
Author:   campbellbarton
Date:     2010-11-28 07:03:30 +0100 (Sun, 28 Nov 2010)

Log Message:
-----------
minor changes to the python api.
- pep8 script was giving an error on non utf8 scons source files.
- use PyList_SET_ITEM macro when list type is ensured.
- all mathutils types use subtypes to create new types when available.
- use defines MAT3_UNITY, MAT4_UNITY to initialize unit matrices.

Modified Paths:
--------------
    trunk/blender/release/test/pep8.py
    trunk/blender/source/blender/blenkernel/intern/armature.c
    trunk/blender/source/blender/blenkernel/intern/constraint.c
    trunk/blender/source/blender/blenkernel/intern/particle.c
    trunk/blender/source/blender/blenlib/intern/math_geom.c
    trunk/blender/source/blender/editors/armature/editarmature.c
    trunk/blender/source/blender/editors/curve/editcurve.c
    trunk/blender/source/blender/editors/interface/interface_draw.c
    trunk/blender/source/blender/editors/physics/particle_edit.c
    trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
    trunk/blender/source/blender/editors/transform/transform.c
    trunk/blender/source/blender/editors/transform/transform_constraints.c
    trunk/blender/source/blender/editors/transform/transform_manipulator.c
    trunk/blender/source/blender/modifiers/intern/MOD_screw.c
    trunk/blender/source/blender/python/generic/bgl.c
    trunk/blender/source/blender/python/generic/mathutils_color.c
    trunk/blender/source/blender/python/generic/mathutils_euler.c
    trunk/blender/source/blender/python/generic/mathutils_geometry.c
    trunk/blender/source/blender/python/generic/mathutils_matrix.c
    trunk/blender/source/blender/python/generic/mathutils_quat.c
    trunk/blender/source/blender/python/generic/mathutils_vector.c
    trunk/blender/source/blender/python/intern/bpy_rna.c
    trunk/blender/source/blender/render/intern/source/zbuf.c

Modified: trunk/blender/release/test/pep8.py
===================================================================
--- trunk/blender/release/test/pep8.py	2010-11-28 02:48:37 UTC (rev 33357)
+++ trunk/blender/release/test/pep8.py	2010-11-28 06:03:30 UTC (rev 33358)
@@ -47,6 +47,7 @@
 
 
 def is_pep8(path):
+    print(path)
     f = open(path, 'r')
     for i in range(PEP8_SEEK_COMMENT):
         line = f.readline()
@@ -63,14 +64,16 @@
     files = []
     files_skip = []
     for f in file_list_py("."):
+        if [None for prefix in SKIP_PREFIX if f.startswith(prefix)]:
+            continue
+
         pep8_type = is_pep8(f)
 
         if pep8_type:
             # so we can batch them for each tool.
             files.append((os.path.abspath(f), pep8_type))
         else:
-            if not [None for prefix in SKIP_PREFIX if f.startswith(prefix)]:
-                files_skip.append(f)
+            files_skip.append(f)
 
     print("\nSkipping...")
     for f in files_skip:

Modified: trunk/blender/source/blender/blenkernel/intern/armature.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/armature.c	2010-11-28 02:48:37 UTC (rev 33357)
+++ trunk/blender/source/blender/blenkernel/intern/armature.c	2010-11-28 06:03:30 UTC (rev 33358)
@@ -590,7 +590,7 @@
 	Mat4 *b_bone_rest= b_bone_spline_setup(pchan, 1);
 	Mat4 *b_bone_mats;
 	DualQuat *b_bone_dual_quats= NULL;
-	float tmat[4][4];
+	float tmat[4][4]= MAT4_UNITY;
 	int a;
 	
 	/* allocate b_bone matrices and dual quats */
@@ -611,7 +611,6 @@
 		- translate over the curve to the bbone mat space
 		- transform with b_bone matrix
 		- transform back into global space */
-	unit_m4(tmat);
 
 	for(a=0; a<bone->segments; a++) {
 		invert_m4_m4(tmat, b_bone_rest[a].mat);
@@ -1104,11 +1103,10 @@
  */
 void armature_loc_world_to_pose(Object *ob, float *inloc, float *outloc) 
 {
-	float xLocMat[4][4];
+	float xLocMat[4][4]= MAT4_UNITY;
 	float nLocMat[4][4];
 	
 	/* build matrix for location */
-	unit_m4(xLocMat);
 	VECCOPY(xLocMat[3], inloc);
 
 	/* get bone-space cursor matrix and extract location */
@@ -1184,11 +1182,10 @@
  */
 void armature_loc_pose_to_bone(bPoseChannel *pchan, float *inloc, float *outloc) 
 {
-	float xLocMat[4][4];
+	float xLocMat[4][4]= MAT4_UNITY;
 	float nLocMat[4][4];
 	
 	/* build matrix for location */
-	unit_m4(xLocMat);
 	VECCOPY(xLocMat[3], inloc);
 
 	/* get bone-space cursor matrix and extract location */

Modified: trunk/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/constraint.c	2010-11-28 02:48:37 UTC (rev 33357)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c	2010-11-28 06:03:30 UTC (rev 33358)
@@ -1202,12 +1202,11 @@
 	if (VALID_CONS_TARGET(ct)) {
 		Curve *cu= ct->tar->data;
 		float vec[4], dir[3], radius;
-		float totmat[4][4];
+		float totmat[4][4]= MAT4_UNITY;
 		float curvetime;
-		
-		unit_m4(totmat);
+
 		unit_m4(ct->matrix);
-		
+
 		/* note: when creating constraints that follow path, the curve gets the CU_PATH set now,
 		 *		currently for paths to work it needs to go through the bevlist/displist system (ton) 
 		 */
@@ -3106,11 +3105,11 @@
 	/* only evaluate if there is a target and it is a curve */
 	if (VALID_CONS_TARGET(ct) && (ct->tar->type == OB_CURVE)) {
 		Curve *cu= data->tar->data;
-		float obmat[4][4], targetMatrix[4][4], ownLoc[3];
+		float obmat[4][4], ownLoc[3];
 		float curveMin[3], curveMax[3];
+		float targetMatrix[4][4]= MAT4_UNITY;
 		
 		copy_m4_m4(obmat, cob->matrix);
-		unit_m4(targetMatrix);
 		copy_v3_v3(ownLoc, obmat[3]);
 		
 		INIT_MINMAX(curveMin, curveMax)

Modified: trunk/blender/source/blender/blenkernel/intern/particle.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/particle.c	2010-11-28 02:48:37 UTC (rev 33357)
+++ trunk/blender/source/blender/blenkernel/intern/particle.c	2010-11-28 06:03:30 UTC (rev 33358)
@@ -4359,7 +4359,7 @@
 		normalize_v3(side);
 		cross_v3_v3v3(nor, vec, side);
 
-		 unit_m4(mat);
+		unit_m4(mat);
 		VECCOPY(mat[0], vec);
 		VECCOPY(mat[1], side);
 		VECCOPY(mat[2], nor);

Modified: trunk/blender/source/blender/blenlib/intern/math_geom.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_geom.c	2010-11-28 02:48:37 UTC (rev 33357)
+++ trunk/blender/source/blender/blenlib/intern/math_geom.c	2010-11-28 06:03:30 UTC (rev 33358)
@@ -1704,10 +1704,9 @@
 void lookat_m4(float mat[][4],float vx, float vy, float vz, float px, float py, float pz, float twist)
 {
 	float sine, cosine, hyp, hyp1, dx, dy, dz;
-	float mat1[4][4];
+	float mat1[4][4]= MAT4_UNITY;
 	
 	unit_m4(mat);
-	unit_m4(mat1);
 
 	rotate_m4(mat, 'Z', -twist);
 

Modified: trunk/blender/source/blender/editors/armature/editarmature.c
===================================================================
--- trunk/blender/source/blender/editors/armature/editarmature.c	2010-11-28 02:48:37 UTC (rev 33357)
+++ trunk/blender/source/blender/editors/armature/editarmature.c	2010-11-28 06:03:30 UTC (rev 33358)
@@ -5779,13 +5779,8 @@
 
 	if (scene->toolsettings->skgen_options & SKGEN_CUT_CORRELATION)
 	{
-		float invmat[4][4] = {	{1, 0, 0, 0},
-								{0, 1, 0, 0},
-								{0, 0, 1, 0},
-								{0, 0, 0, 1}};
-		float tmat[3][3] = {	{1, 0, 0},
-								{0, 1, 0},
-								{0, 0, 1}};
+		float invmat[4][4]= MAT4_UNITY;
+		float tmat[3][3]= MAT3_UNITY;
 		ReebArcIterator arc_iter;
 		BArcIterator *iter = (BArcIterator*)&arc_iter;
 		bArmature *arm= obedit->data;
@@ -5831,13 +5826,8 @@
 	if ((scene->toolsettings->skgen_options & SKGEN_CUT_LENGTH) &&
 		arcLengthRatio(arc) >= G.scene->toolsettings->skgen_length_ratio)
 	{
-		float invmat[4][4] = {	{1, 0, 0, 0},
-								{0, 1, 0, 0},
-								{0, 0, 1, 0},
-								{0, 0, 0, 1}};
-		float tmat[3][3] = {	{1, 0, 0},
-								{0, 1, 0},
-								{0, 0, 1}};
+		float invmat[4][4]= MAT4_UNITY;
+		float tmat[3][3]= MAT3_UNITY;
 		ReebArcIterator arc_iter;
 		BArcIterator *iter = (BArcIterator*)&arc_iter;
 		bArmature *arm= obedit->data;

Modified: trunk/blender/source/blender/editors/curve/editcurve.c
===================================================================
--- trunk/blender/source/blender/editors/curve/editcurve.c	2010-11-28 02:48:37 UTC (rev 33357)
+++ trunk/blender/source/blender/editors/curve/editcurve.c	2010-11-28 06:03:30 UTC (rev 33358)
@@ -5754,8 +5754,7 @@
 	int a, b, cutype, stype;
 	int force_3d = ((Curve *)obedit->data)->flag & CU_3D; /* could be adding to an existing 3D curve */
 
-	float umat[4][4];
-	unit_m4(umat);
+	float umat[4][4]= MAT4_UNITY;
 
 	cutype= type & CU_TYPE;	// poly, bezier, nurbs, etc
 	stype= type & CU_PRIMITIVE;

Modified: trunk/blender/source/blender/editors/interface/interface_draw.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_draw.c	2010-11-28 02:48:37 UTC (rev 33357)
+++ trunk/blender/source/blender/editors/interface/interface_draw.c	2010-11-28 06:03:30 UTC (rev 33358)
@@ -808,7 +808,7 @@
 	int i, c;
 	float w, w3, h, alpha, yofs;
 	GLint scissor[4];
-	float colors[3][3] = {{1,0,0},{0,1,0},{0,0,1}};
+	float colors[3][3]= MAT3_UNITY;
 	float colorsycc[3][3] = {{1,0,1},{1,1,0},{0,1,1}};
 	float colors_alpha[3][3], colorsycc_alpha[3][3]; /* colors  pre multiplied by alpha for speed up */
 	float min, max;

Modified: trunk/blender/source/blender/editors/physics/particle_edit.c
===================================================================
--- trunk/blender/source/blender/editors/physics/particle_edit.c	2010-11-28 02:48:37 UTC (rev 33357)
+++ trunk/blender/source/blender/editors/physics/particle_edit.c	2010-11-28 06:03:30 UTC (rev 33358)
@@ -593,7 +593,7 @@
 	ParticleSystemModifierData *psmd = NULL;
 	ParticleEditSettings *pset= PE_settings(data->scene);
 	POINT_P; KEY_K;
-	float mat[4][4], imat[4][4];
+	float mat[4][4]= MAT4_UNITY, imat[4][4]= MAT4_UNITY;
 
 	if(edit->psys)
 		psmd= psys_get_modifier(data->ob, edit->psys);
@@ -602,9 +602,6 @@
 	if(pset->selectmode==SCE_SELECT_PATH)
 		selected= 0;
 
-	unit_m4(imat);
-	unit_m4(mat);
-
 	LOOP_VISIBLE_POINTS {
 		if(pset->selectmode==SCE_SELECT_END) {
 			/* only do end keys */
@@ -1605,7 +1602,7 @@
 	ParticleSystem *psys = edit->psys;
 	ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
 	POINT_P; KEY_K;
-	float co[3], mat[4][4];
+	float co[3], mat[4][4]= MAT4_UNITY;
 	short vertco[2];
 
 	PEData data;
@@ -1619,8 +1616,6 @@
 	/* only for depths */
 	PE_set_view3d_data(C, &data);
 
-	unit_m4(mat);
-
 	LOOP_VISIBLE_POINTS {
 		if(edit->psys && !(psys->flag & PSYS_GLOBAL_HAIR))
 			psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles + p, mat);

Modified: trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2010-11-28 02:48:37 UTC (rev 33357)
+++ trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2010-11-28 06:03:30 UTC (rev 33358)
@@ -516,8 +516,7 @@
 	flip_coord(mirror, cache->true_location, symm);
 
 	if(axis != 0) {
-		float mat[4][4];
-		unit_m4(mat);
+		float mat[4][4]= MAT4_UNITY;
 		rotate_m4(mat, axis, angle);
 		mul_m4_v3(mat, mirror);
 	}

Modified: trunk/blender/source/blender/editors/transform/transform.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.c	2010-11-28 02:48:37 UTC (rev 33357)
+++ trunk/blender/source/blender/editors/transform/transform.c	2010-11-28 06:03:30 UTC (rev 33358)
@@ -560,7 +560,7 @@
 
 int transformEvent(TransInfo *t, wmEvent *event)
 {
-	float mati[3][3] = {{1.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, {0.0f, 0.0f, 1.0f}};
+	float mati[3][3]= MAT3_UNITY;
 	char cmode = constraintModeToChar(t);
 	int handled = 1;
 

Modified: trunk/blender/source/blender/editors/transform/transform_constraints.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_constraints.c	2010-11-28 02:48:37 UTC (rev 33357)
+++ trunk/blender/source/blender/editors/transform/transform_constraints.c	2010-11-28 06:03:30 UTC (rev 33358)
@@ -560,9 +560,8 @@
 	switch(orientation) {
 	case V3D_MANIP_GLOBAL:
 		{
-			float mtx[3][3];

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list