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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-11-15 17:24:14 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-11-15 17:24:14 +0400
commit987f6a7d4f8637441cadf1bfe162070b965dbf96 (patch)
tree292bbbc7470f46d9952111f7498eb0e0074b7937 /source
parent9eccf40daa7edccc6ca9613611c12270cddbd773 (diff)
code cleanup: move local math functions into math_geom.c, math_vector.c, no functional changes.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenlib/BLI_math_geom.h4
-rw-r--r--source/blender/blenlib/BLI_math_vector.h1
-rw-r--r--source/blender/blenlib/intern/math_geom.c27
-rw-r--r--source/blender/blenlib/intern/math_vector.c7
-rw-r--r--source/blender/bmesh/operators/bmo_bevel.c21
-rw-r--r--source/blender/editors/object/object_bake.c32
-rw-r--r--source/blender/makesdna/DNA_text_types.h1
7 files changed, 50 insertions, 43 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 80169e952bf..509927e589c 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -187,6 +187,10 @@ int barycentric_inside_triangle_v2(const float w[3]);
void resolve_tri_uv(float r_uv[2], const float st[2], const float st0[2], const float st1[2], const float st2[2]);
void resolve_quad_uv(float uv[2], const float st[2], const float st0[2], const float st1[2], const float st2[2], const float st3[2]);
+/* use to find the point of a UV on a face */
+void interp_bilinear_quad_v3(float data[4][3], float u, float v, float res[3]);
+void interp_barycentric_tri_v3(float data[3][3], float u, float v, float res[3]);
+
/***************************** View & Projection *****************************/
void lookat_m4(float mat[4][4], float vx, float vy,
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 77c0ec0a88f..5f80d1e52d7 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -169,6 +169,7 @@ void interp_v4_v4v4v4v4(float p[4], const float v1[4], const float v2[4], const
void mid_v3_v3v3(float r[3], const float a[3], const float b[3]);
void mid_v2_v2v2(float r[2], const float a[2], const float b[2]);
+void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3]);
/********************************* Comparison ********************************/
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index e10229f11da..cd726179f56 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -2399,6 +2399,33 @@ void resolve_quad_uv(float r_uv[2], const float st[2], const float st0[2], const
#undef IS_ZERO
+/* reverse of the functions above */
+void interp_bilinear_quad_v3(float data[4][3], float u, float v, float res[3])
+{
+ float vec[3];
+
+ copy_v3_v3(res, data[0]);
+ mul_v3_fl(res, (1 - u) * (1 - v));
+ copy_v3_v3(vec, data[1]);
+ mul_v3_fl(vec, u * (1 - v)); add_v3_v3(res, vec);
+ copy_v3_v3(vec, data[2]);
+ mul_v3_fl(vec, u * v); add_v3_v3(res, vec);
+ copy_v3_v3(vec, data[3]);
+ mul_v3_fl(vec, (1 - u) * v); add_v3_v3(res, vec);
+}
+
+void interp_barycentric_tri_v3(float data[3][3], float u, float v, float res[3])
+{
+ float vec[3];
+
+ copy_v3_v3(res, data[0]);
+ mul_v3_fl(res, u);
+ copy_v3_v3(vec, data[1]);
+ mul_v3_fl(vec, v); add_v3_v3(res, vec);
+ copy_v3_v3(vec, data[2]);
+ mul_v3_fl(vec, 1.0f - u - v); add_v3_v3(res, vec);
+}
+
/***************************** View & Projection *****************************/
void orthographic_m4(float matrix[][4], const float left, const float right, const float bottom, const float top,
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index 976895fe6fc..7f578fe305d 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -115,6 +115,13 @@ void mid_v2_v2v2(float v[2], const float v1[2], const float v2[2])
v[1] = 0.5f * (v1[1] + v2[1]);
}
+void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3])
+{
+ v[0] = (v1[0] + v2[0] + v3[0]) / 3.0f;
+ v[1] = (v1[1] + v2[1] + v3[1]) / 3.0f;
+ v[2] = (v1[2] + v2[2] + v3[2]) / 3.0f;
+}
+
/********************************** Angles ***********************************/
/* Return the angle in radians between vecs 1-2 and 2-3 in radians
diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c
index 2209c60b280..4b1ea5298a3 100644
--- a/source/blender/bmesh/operators/bmo_bevel.c
+++ b/source/blender/bmesh/operators/bmo_bevel.c
@@ -115,7 +115,7 @@ typedef struct BevelParams {
/* Make a new BoundVert of the given kind, insert it at the end of the circular linked
* list with entry point bv->boundstart, and return it. */
-static BoundVert *add_new_bound_vert(MemArena *mem_arena, VMesh *vm, float co[3])
+static BoundVert *add_new_bound_vert(MemArena *mem_arena, VMesh *vm, const float co[3])
{
BoundVert *ans = (BoundVert *)BLI_memarena_alloc(mem_arena, sizeof(BoundVert));
@@ -383,7 +383,8 @@ static void offset_in_two_planes(EdgeHalf *e1, EdgeHalf *e2, BMVert *v,
if (fabs(angle_v3v3(dir1, dir2)) < BEVEL_EPSILON) {
/* lines are parallel; off1a is a good meet point */
copy_v3_v3(meetco, off1a);
- } else if (!isect_line_line_v3(off1a, off1b, off2a, off2b, meetco, isect2)) {
+ }
+ else if (!isect_line_line_v3(off1a, off1b, off2a, off2b, meetco, isect2)) {
/* another test says they are parallel */
copy_v3_v3(meetco, off1a);
}
@@ -392,7 +393,7 @@ static void offset_in_two_planes(EdgeHalf *e1, EdgeHalf *e2, BMVert *v,
/* Offset by e->offset in plane with normal plane_no, on left if left==TRUE,
* else on right. If no is NULL, choose an arbitrary plane different
* from eh's direction. */
-static void offset_in_plane(EdgeHalf *e, float plane_no[3], int left, float r[3])
+static void offset_in_plane(EdgeHalf *e, const float plane_no[3], int left, float r[3])
{
float dir[3], no[3];
BMVert *v;
@@ -434,7 +435,7 @@ static void slide_dist(EdgeHalf *e, BMVert *v, float d, float slideco[3])
}
/* Calculate the point on e where line (co_a, co_b) comes closest to and return it in projco */
-static void project_to_edge(BMEdge *e, float co_a[3], float co_b[3], float projco[3])
+static void project_to_edge(BMEdge *e, const float co_a[3], const float co_b[3], float projco[3])
{
float otherco[3];
@@ -471,7 +472,7 @@ static int bev_ccw_test(BMEdge *a, BMEdge *b, BMFace *f)
* of that segment in r.
*/
static void get_point_on_round_profile(float r[3], float offset, int i, int count,
- float va[3], float v[3], float vb[3])
+ const float va[3], const float v[3], const float vb[3])
{
float vva[3], vvb[3], angle, center[3], rv[3], axis[3], co[3];
@@ -514,7 +515,8 @@ static void get_point_on_round_profile(float r[3], float offset, int i, int coun
* If va, vmid, and vb are all on the same plane, just interpolate between va and vb.
*/
static void get_point_on_round_edge(EdgeHalf *e, int i,
- float va[3], float vmid[3], float vb[3], float profileco[3])
+ const float va[3], const float vmid[3], const float vb[3],
+ float profileco[3])
{
float vva[3], vvb[3], point[3], dir[3], vaadj[3], vbadj[3], p2[3], pn[3];
int n = e->seg;
@@ -547,13 +549,6 @@ static void get_point_on_round_edge(EdgeHalf *e, int i,
}
}
-static void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3])
-{
- v[0] = (v1[0] + v2[0] + v3[0]) / 3.0f;
- v[1] = (v1[1] + v2[1] + v3[1]) / 3.0f;
- v[2] = (v1[2] + v2[2] + v3[2]) / 3.0f;
-}
-
/* Make a circular list of BoundVerts for bv, each of which has the coordinates
* of a vertex on the the boundary of the beveled vertex bv->v.
* Also decide on the mesh pattern that will be used inside the boundary.
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index ee3c66b6eac..032314d06f3 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -451,32 +451,6 @@ static void do_multires_bake(MultiresBakeRender *bkr, Image *ima, MPassKnownData
}
}
-static void interp_bilinear_quad_data(float data[4][3], float u, float v, float res[3])
-{
- float vec[3];
-
- copy_v3_v3(res, data[0]);
- mul_v3_fl(res, (1 - u) * (1 - v));
- copy_v3_v3(vec, data[1]);
- mul_v3_fl(vec, u * (1 - v)); add_v3_v3(res, vec);
- copy_v3_v3(vec, data[2]);
- mul_v3_fl(vec, u * v); add_v3_v3(res, vec);
- copy_v3_v3(vec, data[3]);
- mul_v3_fl(vec, (1 - u) * v); add_v3_v3(res, vec);
-}
-
-static void interp_barycentric_tri_data(float data[3][3], float u, float v, float res[3])
-{
- float vec[3];
-
- copy_v3_v3(res, data[0]);
- mul_v3_fl(res, u);
- copy_v3_v3(vec, data[1]);
- mul_v3_fl(vec, v); add_v3_v3(res, vec);
- copy_v3_v3(vec, data[2]);
- mul_v3_fl(vec, 1.0f - u - v); add_v3_v3(res, vec);
-}
-
/* mode = 0: interpolate normals,
* mode = 1: interpolate coord */
static void interp_bilinear_grid(CCGKey *key, CCGElem *grid, float crn_x, float crn_y, int mode, float res[3])
@@ -507,7 +481,7 @@ static void interp_bilinear_grid(CCGKey *key, CCGElem *grid, float crn_x, float
copy_v3_v3(data[3], CCG_grid_elem_co(key, grid, x0, y1));
}
- interp_bilinear_quad_data(data, u, v, res);
+ interp_bilinear_quad_v3(data, u, v, res);
}
static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm,
@@ -579,7 +553,7 @@ static void interp_bilinear_mface(DerivedMesh *dm, MFace *mface, const float u,
dm->getVertCo(dm, mface->v4, data[3]);
}
- interp_bilinear_quad_data(data, u, v, res);
+ interp_bilinear_quad_v3(data, u, v, res);
}
/* mode = 0: interpolate normals,
@@ -599,7 +573,7 @@ static void interp_barycentric_mface(DerivedMesh *dm, MFace *mface, const float
dm->getVertCo(dm, mface->v3, data[2]);
}
- interp_barycentric_tri_data(data, u, v, res);
+ interp_barycentric_tri_v3(data, u, v, res);
}
static void *init_heights_data(MultiresBakeRender *bkr, Image *ima)
diff --git a/source/blender/makesdna/DNA_text_types.h b/source/blender/makesdna/DNA_text_types.h
index cf26dae402d..810628ac29b 100644
--- a/source/blender/makesdna/DNA_text_types.h
+++ b/source/blender/makesdna/DNA_text_types.h
@@ -78,7 +78,6 @@ typedef struct Text {
/* text flags */
#define TXT_ISDIRTY 0x0001
-#define TXT_DEPRECATED 0x0004 /* deprecated ISTMP flag */
#define TXT_ISMEM 0x0004
#define TXT_ISEXT 0x0008
#define TXT_ISSCRIPT 0x0010 /* used by space handler scriptlinks */