[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52022] trunk/blender: code cleanup: move shrinkwrap's benchmark macro into PIL_time.h & some minor style edits .

Campbell Barton ideasman42 at gmail.com
Fri Nov 9 05:01:23 CET 2012


Revision: 52022
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52022
Author:   campbellbarton
Date:     2012-11-09 04:01:19 +0000 (Fri, 09 Nov 2012)
Log Message:
-----------
code cleanup: move shrinkwrap's benchmark macro into PIL_time.h & some minor style edits.

Modified Paths:
--------------
    trunk/blender/CMakeLists.txt
    trunk/blender/source/blender/blenkernel/intern/shrinkwrap.c
    trunk/blender/source/blender/blenlib/PIL_time.h
    trunk/blender/source/blender/bmesh/operators/bmo_bevel.c

Modified: trunk/blender/CMakeLists.txt
===================================================================
--- trunk/blender/CMakeLists.txt	2012-11-09 03:36:38 UTC (rev 52021)
+++ trunk/blender/CMakeLists.txt	2012-11-09 04:01:19 UTC (rev 52022)
@@ -313,8 +313,8 @@
 		string(SUBSTRING "${XCODE_VERS_BUILD_NR}" 6 3 XCODE_VERSION) # truncate away build-nr
 		unset(XCODE_VERS_BUILD_NR)
 		# force CMAKE_OSX_DEPLOYMENT_TARGET for makefiles, will not work else ( cmake bug ? )
-		set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}" )
-		set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}" )
+		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
+		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
 		add_definitions ("-DMACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}")
 	endif()
 	

Modified: trunk/blender/source/blender/blenkernel/intern/shrinkwrap.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/shrinkwrap.c	2012-11-09 03:36:38 UTC (rev 52021)
+++ trunk/blender/source/blender/blenkernel/intern/shrinkwrap.c	2012-11-09 04:01:19 UTC (rev 52022)
@@ -56,33 +56,16 @@
 #include "BKE_mesh.h"
 #include "BKE_tessmesh.h"
 
-/* Util macros */
-#define OUT_OF_MEMORY() ((void)printf("Shrinkwrap: Out of memory\n"))
-
-/* Benchmark macros */
-#if !defined(_WIN32) && 0
-
-#include <sys/time.h>
-
-#define BENCH(a)	\
-	do {			\
-		double _t1, _t2;				\
-		struct timeval _tstart, _tend;	\
-		clock_t _clock_init = clock();	\
-		gettimeofday ( &_tstart, NULL);	\
-		(a);							\
-		gettimeofday ( &_tend, NULL);	\
-		_t1 = ( double ) _tstart.tv_sec + ( double ) _tstart.tv_usec/ ( 1000*1000 );	\
-		_t2 = ( double )   _tend.tv_sec + ( double )   _tend.tv_usec/ ( 1000*1000 );	\
-		printf("%s: %fs (real) %fs (cpu)\n", #a, _t2-_t1, (float)(clock()-_clock_init)/CLOCKS_PER_SEC);\
-	} while (0)
-
+/* for timing... */
+#if 0
+#  include "PIL_time.h"
 #else
-
-#define BENCH(a)    (a)
-
+#  define TIMEIT_BENCH(expr, id) (expr)
 #endif
 
+/* Util macros */
+#define OUT_OF_MEMORY() ((void)printf("Shrinkwrap: Out of memory\n"))
+
 /* get derived mesh */
 /* TODO is anyfunction that does this? returning the derivedFinal without we caring if its in edit mode or not? */
 DerivedMesh *object_get_derived_final(Object *ob)
@@ -143,7 +126,7 @@
 	BVHTreeNearest nearest  = NULL_BVHTreeNearest;
 
 
-	BENCH(bvhtree_from_mesh_verts(&treeData, calc->target, 0.0, 2, 6));
+	TIMEIT_BENCH(bvhtree_from_mesh_verts(&treeData, calc->target, 0.0, 2, 6), bvhtree_verts);
 	if (treeData.tree == NULL) {
 		OUT_OF_MEMORY();
 		return;
@@ -437,7 +420,7 @@
 	BVHTreeNearest nearest  = NULL_BVHTreeNearest;
 
 	/* Create a bvh-tree of the given target */
-	BENCH(bvhtree_from_mesh_faces(&treeData, calc->target, 0.0, 2, 6));
+	TIMEIT_BENCH(bvhtree_from_mesh_faces(&treeData, calc->target, 0.0, 2, 6), bvhtree_faces);
 	if (treeData.tree == NULL) {
 		OUT_OF_MEMORY();
 		return;
@@ -584,15 +567,15 @@
 	if (calc.target) {
 		switch (smd->shrinkType) {
 			case MOD_SHRINKWRAP_NEAREST_SURFACE:
-				BENCH(shrinkwrap_calc_nearest_surface_point(&calc));
+				TIMEIT_BENCH(shrinkwrap_calc_nearest_surface_point(&calc), deform_surface);
 				break;
 
 			case MOD_SHRINKWRAP_PROJECT:
-				BENCH(shrinkwrap_calc_normal_projection(&calc));
+				TIMEIT_BENCH(shrinkwrap_calc_normal_projection(&calc), deform_project);
 				break;
 
 			case MOD_SHRINKWRAP_NEAREST_VERTEX:
-				BENCH(shrinkwrap_calc_nearest_vertex(&calc));
+				TIMEIT_BENCH(shrinkwrap_calc_nearest_vertex(&calc), deform_vertex);
 				break;
 		}
 	}

Modified: trunk/blender/source/blender/blenlib/PIL_time.h
===================================================================
--- trunk/blender/source/blender/blenlib/PIL_time.h	2012-11-09 03:36:38 UTC (rev 52021)
+++ trunk/blender/source/blender/blenlib/PIL_time.h	2012-11-09 04:01:19 UTC (rev 52022)
@@ -76,6 +76,14 @@
 	fflush(stdout);                                                           \
 } (void)0
 
+
+#define TIMEIT_BENCH(expr, id)                                                \
+	{                                                                         \
+		TIMEIT_START(id);                                                     \
+		(expr);                                                               \
+		TIMEIT_END(id);                                                       \
+	} (void)0
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/blender/source/blender/bmesh/operators/bmo_bevel.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_bevel.c	2012-11-09 03:36:38 UTC (rev 52021)
+++ trunk/blender/source/blender/bmesh/operators/bmo_bevel.c	2012-11-09 04:01:19 UTC (rev 52022)
@@ -510,7 +510,7 @@
 static void find_intersection_point_plane(float r[3], float p1[3], float p2[3], float p3[3],
                                           float a[3], float m[3])
 {
-	const double null = 1e-20;
+	const double isect_epsilon = 1e-20;
 	float P[3], N[3], A[3], M[3];
 	float vv1[3], vv2[3];
 	double t;
@@ -542,9 +542,9 @@
 	else {
 		C = N[0] * P[0] + N[1] * P[1] + N[2] * P[2];
 		D = N[0] * M[0] + N[1] * M[1] + N[2] * M[2];
-		E = (A[0] * N[0] + A[1] * N[1] + A[2] * N[2]);
+		E = A[0] * N[0] + A[1] * N[1] + A[2] * N[2];
 
-		if (fabs(E) < null)
+		if (fabs(E) < isect_epsilon)
 			t = 0;
 		else
 			t = (C - D) / E;




More information about the Bf-blender-cvs mailing list