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:
-rw-r--r--source/blender/blenkernel/intern/fcurve.c3
-rw-r--r--source/blender/blenlib/BLI_math_base.h2
-rw-r--r--source/blender/blenlib/BLI_math_geom.h4
-rw-r--r--source/blender/blenlib/intern/math_base_inline.c12
-rw-r--r--source/blender/blenlib/intern/math_geom_inline.c34
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.c4
-rw-r--r--source/blender/bmesh/operators/bmo_extrude.c2
-rw-r--r--source/blender/bmesh/operators/bmo_inset.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c17
-rw-r--r--source/blender/modifiers/intern/MOD_solidify.c4
10 files changed, 53 insertions, 31 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index fc74ae5fe60..d4fa9de1043 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1928,6 +1928,7 @@ static void berekenx(float *f, float *o, int b)
/* Calculate F-Curve value for 'evaltime' using BezTriple keyframes */
static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime)
{
+ const float eps = 1.e-8f;
BezTriple *bezt, *prevbezt, *lastbezt;
float v1[2], v2[2], v3[2], v4[2], opl[32], dx, fac;
unsigned int a;
@@ -2073,7 +2074,7 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime
if (exact) {
cvalue = prevbezt->vec[1][1];
}
- else if (fabsf(bezt->vec[1][0] - evaltime) < SMALL_NUMBER) {
+ else if (fabsf(bezt->vec[1][0] - evaltime) < eps) {
cvalue = bezt->vec[1][1];
}
/* evaltime occurs within the interval defined by these two keyframes */
diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h
index 68ffb4b4893..5bd8490db6e 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -241,8 +241,6 @@ MINLINE int mod_i(int i, int n);
MINLINE unsigned int highest_order_bit_i(unsigned int n);
MINLINE unsigned short highest_order_bit_s(unsigned short n);
-MINLINE float shell_angle_to_dist(const float angle);
-
#if defined(_MSC_VER) && (_MSC_VER < 1800)
extern double copysign(double x, double y);
extern double round(double x);
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 6ba8910db14..5067cee7352 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -314,6 +314,10 @@ MINLINE int min_axis_v3(const float vec[3]);
MINLINE int poly_to_tri_count(const int poly_count, const int corner_count);
+MINLINE float shell_angle_to_dist(const float angle);
+MINLINE float shell_v3v3_normalized_to_dist(const float a[3], const float b[3]);
+MINLINE float shell_v2v2_normalized_to_dist(const float a[2], const float b[2]);
+
/**************************** Inline Definitions ******************************/
#if BLI_MATH_DO_INLINE
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index 82c6e68ccc2..e6217329145 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -44,9 +44,6 @@
# define UNLIKELY(x) (x)
#endif
-/* A few small defines. Keep'em local! */
-#define SMALL_NUMBER 1.e-8f
-
MINLINE float sqrt3f(float f)
{
if (UNLIKELY(f == 0.0f)) return 0.0f;
@@ -111,15 +108,6 @@ MINLINE float interpf(float target, float origin, float fac)
return (fac * target) + (1.0f - fac) * origin;
}
-/* useful to calculate an even width shell, by taking the angle between 2 planes.
- * The return value is a scale on the offset.
- * no angle between planes is 1.0, as the angle between the 2 planes approaches 180d
- * the distance gets very high, 180d would be inf, but this case isn't valid */
-MINLINE float shell_angle_to_dist(const float angle)
-{
- return (UNLIKELY(angle < SMALL_NUMBER)) ? 1.0f : fabsf(1.0f / cosf(angle));
-}
-
/* used for zoom values*/
MINLINE float power_of_2(float val)
{
diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c
index 0e243c5e198..1e54dd11a76 100644
--- a/source/blender/blenlib/intern/math_geom_inline.c
+++ b/source/blender/blenlib/intern/math_geom_inline.c
@@ -34,6 +34,9 @@
#include <string.h>
+/* A few small defines. Keep'em local! */
+#define SMALL_NUMBER 1.e-8f
+
/********************************** Polygons *********************************/
MINLINE float cross_tri_v2(const float v1[2], const float v2[2], const float v3[2])
@@ -227,4 +230,35 @@ MINLINE float plane_point_side_v3(const float plane[4], const float co[3])
return dot_v3v3(co, plane) + plane[3];
}
+/* useful to calculate an even width shell, by taking the angle between 2 planes.
+ * The return value is a scale on the offset.
+ * no angle between planes is 1.0, as the angle between the 2 planes approaches 180d
+ * the distance gets very high, 180d would be inf, but this case isn't valid */
+MINLINE float shell_angle_to_dist(const float angle)
+{
+ return (UNLIKELY(angle < SMALL_NUMBER)) ? 1.0f : fabsf(1.0f / cosf(angle));
+}
+/**
+ * equivalent to ``shell_angle_to_dist(angle_normalized_v3v3(a, b))``
+ */
+MINLINE float shell_v3v3_normalized_to_dist(const float a[3], const float b[3])
+{
+ const float angle_cos = fabsf(dot_v3v3(a, b));
+ BLI_ASSERT_UNIT_V3(a);
+ BLI_ASSERT_UNIT_V3(b);
+ return (UNLIKELY(angle_cos < SMALL_NUMBER)) ? 1.0f : (1.0f / angle_cos);
+}
+/**
+ * equivalent to ``shell_angle_to_dist(angle_normalized_v2v2(a, b))``
+ */
+MINLINE float shell_v2v2_normalized_to_dist(const float a[2], const float b[2])
+{
+ const float angle_cos = fabsf(dot_v2v2(a, b));
+ BLI_ASSERT_UNIT_V2(a);
+ BLI_ASSERT_UNIT_V2(b);
+ return (UNLIKELY(angle_cos < SMALL_NUMBER)) ? 1.0f : (1.0f / angle_cos);
+}
+
+#undef SMALL_NUMBER
+
#endif /* __MATH_GEOM_INLINE_C__ */
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c
index f240a10efc8..67f333215d9 100644
--- a/source/blender/bmesh/intern/bmesh_queries.c
+++ b/source/blender/bmesh/intern/bmesh_queries.c
@@ -1236,7 +1236,7 @@ float BM_vert_calc_shell_factor(BMVert *v)
BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
const float face_angle = BM_loop_calc_face_angle(l);
- accum_shell += shell_angle_to_dist(angle_normalized_v3v3(v->no, l->f->no)) * face_angle;
+ accum_shell += shell_v3v3_normalized_to_dist(v->no, l->f->no) * face_angle;
accum_angle += face_angle;
}
@@ -1260,7 +1260,7 @@ float BM_vert_calc_shell_factor_ex(BMVert *v, const char hflag)
BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
if (BM_elem_flag_test(l->f, hflag)) { /* <-- main difference to BM_vert_calc_shell_factor! */
const float face_angle = BM_loop_calc_face_angle(l);
- accum_shell += shell_angle_to_dist(angle_normalized_v3v3(v->no, l->f->no)) * face_angle;
+ accum_shell += shell_v3v3_normalized_to_dist(v->no, l->f->no) * face_angle;
accum_angle += face_angle;
tot_sel++;
}
diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c
index 90c514bfd02..f924d478f1a 100644
--- a/source/blender/bmesh/operators/bmo_extrude.c
+++ b/source/blender/bmesh/operators/bmo_extrude.c
@@ -602,7 +602,7 @@ static void solidify_add_thickness(BMesh *bm, const float dist)
v = l->v;
index = BM_elem_index_get(v);
vert_accum[index] += face_angles[i];
- vert_angles[index] += shell_angle_to_dist(angle_normalized_v3v3(v->no, f->no)) * face_angles[i];
+ vert_angles[index] += shell_v3v3_normalized_to_dist(v->no, f->no) * face_angles[i];
i++;
}
}
diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c
index 29522b62707..e0285dc960a 100644
--- a/source/blender/bmesh/operators/bmo_inset.c
+++ b/source/blender/bmesh/operators/bmo_inset.c
@@ -758,7 +758,7 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
normalize_v3(tvec);
if (use_even_offset) {
- mul_v3_fl(tvec, shell_angle_to_dist(angle_normalized_v3v3(e_no_a, tvec)));
+ mul_v3_fl(tvec, shell_v3v3_normalized_to_dist(e_no_a, tvec));
}
}
else {
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index c6de5749274..ac48bee404e 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -983,19 +983,16 @@ static void uv_image_outset(float (*orig_uv)[2], float (*outset_uv)[2], const fl
normalize_v2(dir3);
}
- /* TODO - angle_normalized_v2v2(...) * (M_PI/180.0f)
- * This is incorrect. Its already given radians but without it wont work.
- * need to look into a fix - campbell */
if (is_quad) {
- a1 = shell_angle_to_dist(angle_normalized_v2v2(dir4, dir1) * ((float)M_PI / 180.0f));
- a2 = shell_angle_to_dist(angle_normalized_v2v2(dir1, dir2) * ((float)M_PI / 180.0f));
- a3 = shell_angle_to_dist(angle_normalized_v2v2(dir2, dir3) * ((float)M_PI / 180.0f));
- a4 = shell_angle_to_dist(angle_normalized_v2v2(dir3, dir4) * ((float)M_PI / 180.0f));
+ a1 = shell_v2v2_normalized_to_dist(dir4, dir1);
+ a2 = shell_v2v2_normalized_to_dist(dir1, dir2);
+ a3 = shell_v2v2_normalized_to_dist(dir2, dir3);
+ a4 = shell_v2v2_normalized_to_dist(dir3, dir4);
}
else {
- a1 = shell_angle_to_dist(angle_normalized_v2v2(dir3, dir1) * ((float)M_PI / 180.0f));
- a2 = shell_angle_to_dist(angle_normalized_v2v2(dir1, dir2) * ((float)M_PI / 180.0f));
- a3 = shell_angle_to_dist(angle_normalized_v2v2(dir2, dir3) * ((float)M_PI / 180.0f));
+ a1 = shell_v2v2_normalized_to_dist(dir3, dir1);
+ a2 = shell_v2v2_normalized_to_dist(dir1, dir2);
+ a3 = shell_v2v2_normalized_to_dist(dir2, dir3);
}
if (is_quad) {
diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c
index 721a77df29c..90a5d56f451 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -538,13 +538,13 @@ static DerivedMesh *applyModifier(
LIKELY(((orig_medge[ml[i_curr].e].flag & ME_EDGE_TMP_TAG) == 0) &&
((orig_medge[ml[i_next].e].flag & ME_EDGE_TMP_TAG) == 0)))
{
- vert_angles[vidx] += shell_angle_to_dist(angle_normalized_v3v3(vert_nors[vidx], face_nors[i])) * angle;
+ vert_angles[vidx] += shell_v3v3_normalized_to_dist(vert_nors[vidx], face_nors[i]) * angle;
}
else {
vert_angles[vidx] += angle;
}
#else
- vert_angles[vidx] += shell_angle_to_dist(angle_normalized_v3v3(vert_nors[vidx], face_nors[i])) * angle;
+ vert_angles[vidx] += shell_v3v3_normalized_to_dist(vert_nors[vidx], face_nors[i]) * angle;
#endif
/* --- end non-angle-calc section --- */