Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-04-16 15:04:17 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-04-16 15:07:28 +0400
commitb3972aeea05bc6c60d7b7da4e6b59a64b822448a (patch)
treeee959d88f8be160e01f8633b9c163ba7dc105d0c /source/blender/bmesh
parent233dac149478624a74831ff24454e5956124622c (diff)
Math Lib: optimize axis_dominant_v3_to_m3, approx 6x speedup
build the matrix directly rather then calculating with axis/angle also remove unused function calc_poly_plane
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r--source/blender/bmesh/intern/bmesh_interp.c7
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.c55
-rw-r--r--source/blender/bmesh/intern/bmesh_private.h3
3 files changed, 11 insertions, 54 deletions
diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c
index e5921bb49d7..5bd1a72b5a2 100644
--- a/source/blender/bmesh/intern/bmesh_interp.c
+++ b/source/blender/bmesh/intern/bmesh_interp.c
@@ -317,12 +317,7 @@ static int quad_co(float *x, float *y, float v1[3], float v2[3], float v3[3], fl
/* rotate */
poly_rotate_plane(n, projverts, 5);
-
- /* flatten */
- for (i = 0; i < 5; i++) {
- projverts[i][2] = 0.0f;
- }
-
+
/* subtract origin */
for (i = 0; i < 4; i++) {
sub_v3_v3(projverts[i], projverts[4]);
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c
index 17996176555..a2cfdc41281 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -362,46 +362,6 @@ void BM_face_calc_center_mean_weighted(BMFace *f, float r_cent[3])
}
/**
- * COMPUTE POLY PLANE
- *
- * Projects a set polygon's vertices to
- * a plane defined by the average
- * of its edges cross products
- */
-void calc_poly_plane(float (*verts)[3], const int nverts)
-{
-
- float avgc[3], norm[3], mag, avgn[3];
- float *v1, *v2, *v3;
- int i;
-
- if (nverts < 3)
- return;
-
- zero_v3(avgn);
- zero_v3(avgc);
-
- for (i = 0; i < nverts; i++) {
- v1 = verts[i];
- v2 = verts[(i + 1) % nverts];
- v3 = verts[(i + 2) % nverts];
- normal_tri_v3(norm, v1, v2, v3);
-
- add_v3_v3(avgn, norm);
- }
-
- if (UNLIKELY(normalize_v3(avgn) == 0.0f)) {
- avgn[2] = 1.0f;
- }
-
- for (i = 0; i < nverts; i++) {
- v1 = verts[i];
- mag = dot_v3v3(v1, avgn);
- madd_v3_v3fl(v1, avgn, -mag);
- }
-}
-
-/**
* \brief BM LEGAL EDGES
*
* takes in a face and a list of edges, and sets to NULL any edge in
@@ -430,15 +390,18 @@ static void scale_edge_v2f(float v1[2], float v2[2], const float fac)
* Rotates a polygon so that it's
* normal is pointing towards the mesh Z axis
*/
-void poly_rotate_plane(const float normal[3], float (*verts)[3], const int nverts)
+void poly_rotate_plane(const float normal[3], float (*verts)[3], const unsigned int nverts)
{
float mat[3][3];
+ float co[3];
+ unsigned int i;
- if (axis_dominant_v3_to_m3(mat, normal)) {
- int i;
- for (i = 0; i < nverts; i++) {
- mul_m3_v3(mat, verts[i]);
- }
+ co[2] = 0.0f;
+
+ axis_dominant_v3_to_m3(mat, normal);
+ for (i = 0; i < nverts; i++) {
+ mul_v2_m3v3(co, mat, verts[i]);
+ copy_v3_v3(verts[i], co);
}
}
diff --git a/source/blender/bmesh/intern/bmesh_private.h b/source/blender/bmesh/intern/bmesh_private.h
index 7ec418b2253..cac4713c8b2 100644
--- a/source/blender/bmesh/intern/bmesh_private.h
+++ b/source/blender/bmesh/intern/bmesh_private.h
@@ -72,8 +72,7 @@ enum {
#define BM_ELEM_API_FLAG_TEST(element, f) ((element)->head.api_flag & (f))
#define BM_ELEM_API_FLAG_CLEAR(element) ((element)->head.api_flag = 0)
-void calc_poly_plane(float (*verts)[3], const int nverts);
-void poly_rotate_plane(const float normal[3], float (*verts)[3], const int nverts);
+void poly_rotate_plane(const float normal[3], float (*verts)[3], unsigned const int nverts);
/* include the rest of our private declarations */
#include "bmesh_structure.h"