diff options
author | Julian Eisel <julian@blender.org> | 2020-07-01 18:13:57 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-07-01 18:13:57 +0300 |
commit | 0829cebeb024095c268f190c34daa8ae9a5a224c (patch) | |
tree | 12ee5a4a1c2a32e12eff47c8eb9bb0ed217791c1 /source/blender/blenlib/intern | |
parent | cfde6ebf450594faa57c4bfeaecff10fe512c91b (diff) | |
parent | 42be3964eb201180f6b0fa1ff6ce43b8c3845bc2 (diff) |
Merge branch 'master' into asset-uuid--archivedasset-uuid--archived
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/BLI_kdopbvh.c | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/delaunay_2d.c | 37 | ||||
-rw-r--r-- | source/blender/blenlib/intern/dot_export.cc | 6 | ||||
-rw-r--r-- | source/blender/blenlib/intern/edgehash.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_bits_inline.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 26 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_matrix.c | 16 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_rotation.c | 6 | ||||
-rw-r--r-- | source/blender/blenlib/intern/storage.c | 2 |
9 files changed, 64 insertions, 37 deletions
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index da67baf0ead..9d1981b3392 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -769,7 +769,7 @@ static void non_recursive_bvh_div_nodes_task_cb(void *__restrict userdata, * This functions builds an optimal implicit tree from the given leafs. * Where optimal stands for: * - The resulting tree will have the smallest number of branches; - * - At most only one branch will have NULL childs; + * - At most only one branch will have NULL children; * - All leafs will be stored at level N or N+1. * * This function creates an implicit tree on branches_array, @@ -777,7 +777,7 @@ static void non_recursive_bvh_div_nodes_task_cb(void *__restrict userdata, * * The tree is built per depth levels. First branches at depth 1.. then branches at depth 2.. etc.. * The reason is that we can build level N+1 from level N without any data dependencies.. - * thus it allows to use multithread building. + * thus it allows to use multi-thread building. * * To archive this is necessary to find how much leafs are accessible from a certain branch, * #BVHBuildHelper, #implicit_needed_branches and #implicit_leafs_index diff --git a/source/blender/blenlib/intern/delaunay_2d.c b/source/blender/blenlib/intern/delaunay_2d.c index 4e0cd3a78dc..08ccff695c1 100644 --- a/source/blender/blenlib/intern/delaunay_2d.c +++ b/source/blender/blenlib/intern/delaunay_2d.c @@ -405,7 +405,8 @@ static CDTEdge *add_vert_to_symedge_edge(CDT_state *cdt, CDTVert *v, SymEdge *se return e; } -/* Connect the verts of se1 and se2, assuming that currently those two SymEdges are on +/** + * Connect the verts of se1 and se2, assuming that currently those two #SymEdges are on * the outer boundary (have face == outer_face) of two components that are isolated from * each other. */ @@ -479,7 +480,7 @@ static CDTEdge *split_edge(CDT_state *cdt, SymEdge *se, double lambda) * the deleted edge will be the one that was e's face. * There will be now an unused face, marked by setting its deleted flag, * and an unused #CDTEdge, marked by setting the next and rot pointers of - * its SymEdges to NULL. + * its #SymEdge(s) to NULL. * <pre> * . v2 . * / \ / \ @@ -1017,7 +1018,9 @@ static void initial_triangulation(CDT_state *cdt) MEM_freeN(sites); } -/** Use LinkNode linked list as stack of SymEdges, allocating from cdt->listpool. */ +/** + * Use #LinkNode linked list as stack of #SymEdges, allocating from `cdt->listpool` . + */ typedef LinkNode *Stack; BLI_INLINE void push(Stack *stack, SymEdge *se, CDT_state *cdt) @@ -1153,22 +1156,22 @@ static double tri_orient(const SymEdge *t) * in the path we will take to insert an edge constraint. * Each such point will either be * (a) a vertex or - * (b) a fraction lambda (0 < lambda < 1) along some SymEdge.] + * (b) a fraction lambda (0 < lambda < 1) along some #SymEdge.] * * In general, lambda=0 indicates case a and lambda != 0 indicates case be. * The 'in' edge gives the destination attachment point of a diagonal from the previous crossing, * and the 'out' edge gives the origin attachment point of a diagonal to the next crossing. * But in some cases, 'in' and 'out' are undefined or not needed, and will be NULL. * - * For case (a), 'vert' will be the vertex, and lambda will be 0, and 'in' will be the SymEdge from - * 'vert' that has as face the one that you go through to get to this vertex. If you go exactly - * along an edge then we set 'in' to NULL, since it won't be needed. The first crossing will have - * 'in' = NULL. We set 'out' to the SymEdge that has the face we go though to get to the next - * crossing, or, if the next crossing is a case (a), then it is the edge that goes to that next - * vertex. 'out' wlll be NULL for the last one. + * For case (a), 'vert' will be the vertex, and lambda will be 0, and 'in' will be the #SymEdge + * from 'vert' that has as face the one that you go through to get to this vertex. If you go + * exactly along an edge then we set 'in' to NULL, since it won't be needed. The first crossing + * will have 'in' = NULL. We set 'out' to the #SymEdge that has the face we go though to get to the + * next crossing, or, if the next crossing is a case (a), then it is the edge that goes to that + * next vertex. 'out' wlll be NULL for the last one. * * For case (b), vert will be NULL at first, and later filled in with the created split vertex, - * and 'in' will be the SymEdge that we go through, and lambda will be between 0 and 1, + * and 'in' will be the #SymEdge that we go through, and lambda will be between 0 and 1, * the fraction from in's vert to in->next's vert to put the split vertex. * 'out' is not needed in this case, since the attachment point will be the sym of the first * half of the split edge. @@ -1231,8 +1234,8 @@ static void fill_crossdata_for_through_vert(CDTVert *v, /** * As part of finding crossings, we found a case where orient tests say that the next crossing - * is on the SymEdge t, while intersecting with the ray from curco to v2. - * Find the intersection point and fill in the CrossData for that point. + * is on the #SymEdge t, while intersecting with the ray from \a curco to \a v2. + * Find the intersection point and fill in the #CrossData for that point. * It may turn out that when doing the intersection, we get an answer that says that * this case is better handled as through-vertex case instead, so we may do that. * In the latter case, we want to avoid a situation where the current crossing is on an edge @@ -1442,12 +1445,12 @@ static bool get_next_crossing_from_vert(CDT_state *cdt, } /** - * As part of finding the crossings of a ray to v2, find the next crossing after 'cd', assuming + * As part of finding the crossings of a ray to 'v2', find the next crossing after 'cd', assuming * 'cd' represents a crossing that goes through a an edge, not at either end of that edge. * - * We have the triangle vb-va-vc, where va and vb are the split edge and vc is the third vertex on - * that new side of the edge (should be closer to v2). The next crossing should be through vc or - * intersecting vb-vc or va-vc. + * We have the triangle 'vb-va-vc', where va and vb are the split edge and 'vc' is the third vertex + * on that new side of the edge (should be closer to v2). The next crossing should be through 'vc' + * or intersecting 'vb-vc' or 'va-vc'. */ static void get_next_crossing_from_edge(CDT_state *cdt, CrossData *cd, diff --git a/source/blender/blenlib/intern/dot_export.cc b/source/blender/blenlib/intern/dot_export.cc index a2cf843c473..ff39265d681 100644 --- a/source/blender/blenlib/intern/dot_export.cc +++ b/source/blender/blenlib/intern/dot_export.cc @@ -19,7 +19,7 @@ #include "BLI_dot_export.hh" namespace blender { -namespace DotExport { +namespace dot { /* Graph Building ************************************************/ @@ -237,7 +237,7 @@ void NodePort::to_dot_string(std::stringstream &ss) const { m_node->export__as_id(ss); if (m_port_name.has_value()) { - ss << ":" << m_port_name.value(); + ss << ":" << *m_port_name; } } @@ -301,5 +301,5 @@ NodeWithSocketsRef::NodeWithSocketsRef(Node &node, m_node->set_shape(Attr_shape::Rectangle); } -} // namespace DotExport +} // namespace dot } // namespace blender diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c index 556c0a65fc5..56529581dd3 100644 --- a/source/blender/blenlib/intern/edgehash.c +++ b/source/blender/blenlib/intern/edgehash.c @@ -376,7 +376,7 @@ bool BLI_edgehash_ensure_p(EdgeHash *eh, uint v0, uint v1, void ***r_value) * Remove \a key (v0, v1) from \a eh, or return false if the key wasn't found. * * \param v0, v1: The key to remove. - * \param valfreefp: Optional callback to free the value. + * \param free_value: Optional callback to free the value. * \return true if \a key was removed from \a eh. */ bool BLI_edgehash_remove(EdgeHash *eh, uint v0, uint v1, EdgeHashFreeFP free_value) diff --git a/source/blender/blenlib/intern/math_bits_inline.c b/source/blender/blenlib/intern/math_bits_inline.c index 8f8f257f1e7..e7a7b17e1e4 100644 --- a/source/blender/blenlib/intern/math_bits_inline.c +++ b/source/blender/blenlib/intern/math_bits_inline.c @@ -63,7 +63,7 @@ MINLINE unsigned int bitscan_reverse_uint(unsigned int a) #ifdef _MSC_VER unsigned long clz; _BitScanReverse(&clz, a); - return clz; + return 31 - clz; #else return (unsigned int)__builtin_clz(a); #endif diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index e7c1fc8c2d9..d3dc4729617 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -3248,19 +3248,27 @@ bool isect_ray_aabb_v3_simple(const float orig[3], } } -/* find closest point to p on line through (l1, l2) and return lambda, - * where (0 <= lambda <= 1) when cp is in the line segment (l1, l2) +float closest_to_ray_v3(float r_close[3], + const float p[3], + const float ray_orig[3], + const float ray_dir[3]) +{ + float h[3], lambda; + sub_v3_v3v3(h, p, ray_orig); + lambda = dot_v3v3(ray_dir, h) / dot_v3v3(ray_dir, ray_dir); + madd_v3_v3v3fl(r_close, ray_orig, ray_dir, lambda); + return lambda; +} + +/** + * Find closest point to p on line through (l1, l2) and return lambda, + * where (0 <= lambda <= 1) when cp is in the line segment (l1, l2). */ float closest_to_line_v3(float r_close[3], const float p[3], const float l1[3], const float l2[3]) { - float h[3], u[3], lambda; + float u[3]; sub_v3_v3v3(u, l2, l1); - sub_v3_v3v3(h, p, l1); - lambda = dot_v3v3(u, h) / dot_v3v3(u, u); - r_close[0] = l1[0] + u[0] * lambda; - r_close[1] = l1[1] + u[1] * lambda; - r_close[2] = l1[2] + u[2] * lambda; - return lambda; + return closest_to_ray_v3(r_close, p, l1, u); } float closest_to_line_v2(float r_close[2], const float p[2], const float l1[2], const float l2[2]) diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 9e398239bc7..92cfd09f191 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -2388,6 +2388,22 @@ void interp_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3], con mat3_polar_decompose(A, U_A, P_A); mat3_polar_decompose(B, U_B, P_B); + /* Quaternions cannot represent an axis flip. If such a singularity is detected, choose a + * different decomposition of the matrix that still satisfies A = U_A * P_A but which has a + * positive determinant and thus no axis flips. This resolves T77154. + * + * Note that a flip of two axes is just a rotation of 180 degrees around the third axis, and + * three flipped axes are just an 180 degree rotation + a single axis flip. It is thus sufficient + * to solve this problem for single axis flips. */ + if (determinant_m3_array(U_A) < 0) { + mul_m3_fl(U_A, -1.0f); + mul_m3_fl(P_A, -1.0f); + } + if (determinant_m3_array(U_B) < 0) { + mul_m3_fl(U_B, -1.0f); + mul_m3_fl(P_B, -1.0f); + } + mat3_to_quat(quat_A, U_A); mat3_to_quat(quat_B, U_B); interp_qt_qtqt(quat, quat_A, quat_B, t); diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index a91cdabe3ab..a2f7cc24dd3 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -543,8 +543,8 @@ void rotation_between_quats_to_quat(float q[4], const float q1[4], const float q * * \param q: input quaternion. * \param axis: twist axis in [0,1,2] - * \param r_swing[out]: if not NULL, receives the swing quaternion. - * \param r_twist[out]: if not NULL, receives the twist quaternion. + * \param r_swing: if not NULL, receives the swing quaternion. + * \param r_twist: if not NULL, receives the twist quaternion. * \returns twist angle. */ float quat_split_swing_and_twist(const float q[4], int axis, float r_swing[4], float r_twist[4]) @@ -2127,7 +2127,7 @@ void mul_v3m3_dq(float co[3], float mat[3][3], DualQuat *dq) co[1] = (co[1] + t[1]) * len2; co[2] = (co[2] + t[2]) * len2; - /* compute crazyspace correction mat */ + /* Compute crazy-space correction matrix. */ if (mat) { if (dq->scale_weight) { copy_m3_m4(scalemat, dq->scale); diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index fbfb258693b..f2217b1cd1a 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -529,7 +529,7 @@ void *BLI_file_read_binary_as_mem(const char *filepath, size_t pad_bytes, size_t * Return the text file data with: * - Newlines replaced with '\0'. - * - Optionally trim whitespace, replacing trailing ' ' & '\t' with '\0'. + * - Optionally trim white-space, replacing trailing <space> & <tab> with '\0'. * * This is an alternative to using #BLI_file_read_as_lines, * allowing us to loop over lines without converting it into a linked list |