[Bf-blender-cvs] [1cb5939] master: Cleanup: use const, avoid float -> double in matrix invert

Campbell Barton noreply at git.blender.org
Sat Nov 29 17:50:59 CET 2014


Commit: 1cb59394ae69148904de34a32d09319f02c86a09
Author: Campbell Barton
Date:   Sat Nov 29 17:49:38 2014 +0100
Branches: master
https://developer.blender.org/rB1cb59394ae69148904de34a32d09319f02c86a09

Cleanup: use const, avoid float -> double in matrix invert

===================================================================

M	source/blender/blenkernel/intern/smoke.c
M	source/blender/blenlib/intern/math_matrix.c
M	source/blender/editors/mesh/editmesh_knife.c
M	source/blender/editors/uvedit/uvedit_parametrizer.c
M	source/blender/gpu/intern/gpu_buffers.c
M	source/blender/modifiers/intern/MOD_build.c

===================================================================

diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index fb6f99b..3b60098 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -1425,7 +1425,7 @@ static void emit_from_particles(Object *flow_ob, SmokeDomainSettings *sds, Smoke
 
 static void sample_derivedmesh(
         SmokeFlowSettings *sfs, MVert *mvert, MTFace *tface, MFace *mface,
-        float *influence_map, float *velocity_map, int index, int base_res[3], float flow_center[3],
+        float *influence_map, float *velocity_map, int index, const int base_res[3], float flow_center[3],
         BVHTreeFromMesh *treeData, const float ray_start[3], const float *vert_vel,
         bool has_velocity, int defgrp_index, MDeformVert *dvert, float x, float y, float z)
 {
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 2da1f22..8f9fcbc 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -848,9 +848,10 @@ bool invert_m4_m4(float inverse[4][4], float mat[4][4])
 			}
 		}
 
-		temp = tempmat[i][i];
-		if (temp == 0)
-			return 0;  /* No non-zero pivot */
+		if (UNLIKELY(tempmat[i][i] == 0.0f)) {
+			return false;  /* No non-zero pivot */
+		}
+		temp = (double)tempmat[i][i];
 		for (k = 0; k < 4; k++) {
 			tempmat[i][k] = (float)((double)tempmat[i][k] / temp);
 			inverse[i][k] = (float)((double)inverse[i][k] / temp);
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index b08f7ef..5d60fcc 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -1410,8 +1410,9 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
 	{
 		/* Scale the epsilon by the zoom level
 		 * to compensate for projection imprecision, see T41164 */
-		float zoom_xy[2] = {kcd->vc.rv3d->winmat[0][0],
-		                    kcd->vc.rv3d->winmat[1][1]};
+		const float zoom_xy[2] = {
+		        kcd->vc.rv3d->winmat[0][0],
+		        kcd->vc.rv3d->winmat[1][1]};
 		eps_scale = len_v2(zoom_xy);
 	}
 
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 39ddb19..d054ccc 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -4193,7 +4193,7 @@ void param_delete(ParamHandle *handle)
 
 static void p_add_ngon(ParamHandle *handle, ParamKey key, int nverts,
                        ParamKey *vkeys, float **co, float **uv,
-                       ParamBool *pin, ParamBool *select, float normal[3])
+                       ParamBool *pin, ParamBool *select, const float normal[3])
 {
 	int *boundary = BLI_array_alloca(boundary, nverts);
 	int i;
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 985e04b..9a67e6d 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -2740,7 +2740,7 @@ void GPU_free_pbvh_buffers(GPU_PBVH_Buffers *buffers)
 /* debug function, draws the pbvh BB */
 void GPU_draw_pbvh_BB(float min[3], float max[3], bool leaf)
 {
-	float quads[4][4][3] = {
+	const float quads[4][4][3] = {
 	    {
 	        {min[0], min[1], min[2]},
 	        {max[0], min[1], min[2]},
diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c
index b9f5be4..f30529b 100644
--- a/source/blender/modifiers/intern/MOD_build.c
+++ b/source/blender/modifiers/intern/MOD_build.c
@@ -43,11 +43,14 @@
 #include "DNA_meshdata_types.h"
 
 #include "BKE_cdderivedmesh.h"
-#include "BKE_mesh.h"
 #include "BKE_modifier.h"
 #include "BKE_particle.h"
 #include "BKE_scene.h"
 
+#ifdef _OPENMP
+#  include "BKE_mesh.h"  /* BKE_MESH_OMP_LIMIT */
+#endif
+
 static void initData(ModifierData *md)
 {
 	BuildModifierData *bmd = (BuildModifierData *) md;




More information about the Bf-blender-cvs mailing list