From 41a5e731a2e13a18110f3f1919c340425f32f452 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 29 Apr 2012 10:44:00 +0000 Subject: [PATCH 01/10] bmesh: new wireframe tool - makes wireframe from faces. - options similar to inset (even offset, relative scale) - copies face settings and loops (uvs, vcolors) - optionally replaces the existing geometry. --- release/scripts/startup/bl_ui/space_view3d.py | 1 + source/blender/blenlib/BLI_math_vector.h | 1 + source/blender/blenlib/intern/math_vector.c | 19 + source/blender/bmesh/CMakeLists.txt | 1 + source/blender/bmesh/intern/bmesh_opdefines.c | 20 + .../bmesh/intern/bmesh_operators_private.h | 1 + source/blender/bmesh/intern/bmesh_queries.c | 22 ++ source/blender/bmesh/intern/bmesh_queries.h | 1 + source/blender/bmesh/operators/bmo_inset.c | 19 +- .../blender/bmesh/operators/bmo_wireframe.c | 371 ++++++++++++++++++ source/blender/editors/mesh/editmesh_tools.c | 67 ++++ source/blender/editors/mesh/mesh_intern.h | 1 + source/blender/editors/mesh/mesh_ops.c | 1 + 13 files changed, 507 insertions(+), 18 deletions(-) create mode 100644 source/blender/bmesh/operators/bmo_wireframe.c diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 9cf52056875..ff9484e6baf 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -1767,6 +1767,7 @@ class VIEW3D_MT_edit_mesh_faces(Menu): layout.operator("mesh.inset") layout.operator("mesh.bevel") layout.operator("mesh.solidify") + layout.operator("mesh.wireframe") layout.operator("mesh.sort_faces") layout.separator() diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index af3df9c9ed2..df5199e19e7 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -186,6 +186,7 @@ float angle_normalized_v2v2(const float a[2], const float b[2]); float angle_v3v3(const float a[3], const float b[3]); float angle_v3v3v3(const float a[3], const float b[3], const float c[3]); float angle_normalized_v3v3(const float v1[3], const float v2[3]); +float angle_on_axis_v3v3v3_v3(const float v1[3], const float v2[3], const float v3[3], const float axis[3]); void angle_tri_v3(float angles[3], const float v1[3], const float v2[3], const float v3[3]); void angle_quad_v3(float angles[4], const float v1[3], const float v2[3], const float v3[3], const float v4[3]); void angle_poly_v3(float* angles, const float* verts[3], int len); diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index f734e01943f..90e6a4cb945 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -217,6 +217,25 @@ float angle_normalized_v2v2(const float v1[2], const float v2[2]) return 2.0f * (float)saasin(len_v2v2(v2, v1) / 2.0f); } +/** + * angle between 2 vectors defined by 3 coords, about an axis. */ +float angle_on_axis_v3v3v3_v3(const float v1[3], const float v2[3], const float v3[3], const float axis[3]) +{ + float v1_proj[3], v2_proj[3], tproj[3]; + + sub_v3_v3v3(v1_proj, v1, v2); + sub_v3_v3v3(v2_proj, v3, v2); + + /* project the vectors onto the axis */ + project_v3_v3v3(tproj, v1_proj, axis); + sub_v3_v3(v1_proj, tproj); + + project_v3_v3v3(tproj, v2_proj, axis); + sub_v3_v3(v2_proj, tproj); + + return angle_v3v3(v1_proj, v2_proj); +} + void angle_tri_v3(float angles[3], const float v1[3], const float v2[3], const float v3[3]) { float ed1[3], ed2[3], ed3[3]; diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt index 1cf2b9113b2..a23f1935ae0 100644 --- a/source/blender/bmesh/CMakeLists.txt +++ b/source/blender/bmesh/CMakeLists.txt @@ -51,6 +51,7 @@ set(SRC operators/bmo_subdivide.h operators/bmo_triangulate.c operators/bmo_utils.c + operators/bmo_wireframe.c intern/bmesh_construct.c intern/bmesh_construct.h diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 4b5c67c8671..8ffaf1875cf 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -1108,6 +1108,25 @@ static BMOpDefine bmo_inset_def = { 0 }; +/* + * Wire Frame + * + * Makes a wire copy of faces. + */ +static BMOpDefine bmo_wireframe_def = { + "wireframe", + {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ + {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */ + {BMO_OP_SLOT_BOOL, "use_boundary"}, + {BMO_OP_SLOT_BOOL, "use_even_offset"}, + {BMO_OP_SLOT_FLT, "thickness"}, + {BMO_OP_SLOT_BOOL, "use_relative_offset"}, + {BMO_OP_SLOT_FLT, "depth"}, + {0} /* null-terminating sentinel */}, + bmo_wireframe_exec, + 0 +}; + /* * Vertex Slide * @@ -1192,6 +1211,7 @@ BMOpDefine *opdefines[] = { &bmo_bridge_loops_def, &bmo_solidify_def, &bmo_inset_def, + &bmo_wireframe_def, &bmo_vertex_slide_def, }; diff --git a/source/blender/bmesh/intern/bmesh_operators_private.h b/source/blender/bmesh/intern/bmesh_operators_private.h index 423b30a503a..e222c3422c0 100644 --- a/source/blender/bmesh/intern/bmesh_operators_private.h +++ b/source/blender/bmesh/intern/bmesh_operators_private.h @@ -100,5 +100,6 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op); void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op); void bmo_solidify_face_region_exec(BMesh *bm, BMOperator *op); void bmo_inset_exec(BMesh *bm, BMOperator *op); +void bmo_wireframe_exec(BMesh *bm, BMOperator *op); #endif /* __BMESH_OPERATORS_PRIVATE_H__ */ diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index 3543fd952bb..e9a35ff70a2 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -927,6 +927,28 @@ float BM_vert_calc_shell_factor(BMVert *v) return accum_shell / accum_angle; } +/** + * \note quite an obscure function. + * used in bmesh operators that have a relative scale options, + */ +float BM_vert_calc_mean_tagged_edge_length(BMVert *v) +{ + BMIter iter; + BMEdge *e; + int tot; + float length = 0.0f; + + BM_ITER_ELEM_INDEX (e, &iter, v, BM_EDGES_OF_VERT, tot) { + BMVert *v_other = BM_edge_other_vert(e, v); + if (BM_elem_flag_test(v_other, BM_ELEM_TAG)) { + length += BM_edge_calc_length(e); + } + } + + return length / (float)tot; +} + + /** * Returns the edge existing between v1 and v2, or NULL if there isn't one. * diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h index aefeb80c4f3..08e15884b3f 100644 --- a/source/blender/bmesh/intern/bmesh_queries.h +++ b/source/blender/bmesh/intern/bmesh_queries.h @@ -65,6 +65,7 @@ void BM_edge_calc_face_tangent(BMEdge *e, BMLoop *e_loop, float r_tangent[3]) float BM_vert_calc_edge_angle(BMVert *v); float BM_vert_calc_shell_factor(BMVert *v); +float BM_vert_calc_mean_tagged_edge_length(BMVert *v); BMEdge *BM_edge_exists(BMVert *v1, BMVert *v2); diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c index 712f6b736d6..e08f08baacd 100644 --- a/source/blender/bmesh/operators/bmo_inset.c +++ b/source/blender/bmesh/operators/bmo_inset.c @@ -80,23 +80,6 @@ static BMLoop *bm_edge_is_mixed_face_tag(BMLoop *l) } } -float bm_vert_avg_tag_dist(BMVert *v) -{ - BMIter iter; - BMEdge *e; - int tot; - float length = 0.0f; - - BM_ITER_ELEM_INDEX (e, &iter, v, BM_EDGES_OF_VERT, tot) { - BMVert *v_other = BM_edge_other_vert(e, v); - if (BM_elem_flag_test(v_other, BM_ELEM_TAG)) { - length += BM_edge_calc_length(e); - } - } - - return length / (float)tot; -} - /** * implementation is as follows... * @@ -544,7 +527,7 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op) BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) { if (BM_elem_flag_test(v, BM_ELEM_TAG)) { const float fac = (depth * - (use_relative_offset ? bm_vert_avg_tag_dist(v) : 1.0f) * + (use_relative_offset ? BM_vert_calc_mean_tagged_edge_length(v) : 1.0f) * (use_even_boundry ? BM_vert_calc_shell_factor(v) : 1.0f)); madd_v3_v3v3fl(varr_co[i], v->co, v->no, fac); } diff --git a/source/blender/bmesh/operators/bmo_wireframe.c b/source/blender/bmesh/operators/bmo_wireframe.c new file mode 100644 index 00000000000..49aff164b7d --- /dev/null +++ b/source/blender/bmesh/operators/bmo_wireframe.c @@ -0,0 +1,371 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/bmesh/operators/bmo_wireframe.c + * \ingroup bmesh + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_math.h" + +#include "bmesh.h" + +#include "intern/bmesh_operators_private.h" /* own include */ + +BMLoop *bm_edge_tag_faceloop(BMEdge *e) +{ + BMLoop *l, *l_first; + + l = l_first = e->l; + do { + if (BM_elem_flag_test(l->f, BM_ELEM_TAG)) { + return l; + } + } while ((l = l->radial_next) != l_first); + + /* in the case this is used, we know this will never happen */ + return NULL; +} + +static void bm_vert_boundary_tangent(BMVert *v, float r_no[3], float r_no_face[3], + BMVert **r_va_other, BMVert **r_vb_other) +{ + BMIter iter; + BMEdge *e_iter; + + BMEdge *e_a = NULL, *e_b = NULL; + BMVert *v_a, *v_b; + + BMLoop *l_a, *l_b; + + float no_face[3], no_edge[3]; + float tvec_a[3], tvec_b[3]; + + /* get 2 boundary edges, there should only _be_ 2, + * in case there are more - results wont be valid of course */ + BM_ITER_ELEM (e_iter, &iter, v, BM_EDGES_OF_VERT) { + if (BM_elem_flag_test(e_iter, BM_ELEM_TAG)) { + if (e_a == NULL) { + e_a = e_iter; + } + else { + e_b = e_iter; + break; + } + } + } + + l_a = bm_edge_tag_faceloop(e_a); + l_b = bm_edge_tag_faceloop(e_b); + + /* average edge face normal */ + add_v3_v3v3(no_face, l_a->f->no, l_b->f->no); + + /* average edge direction */ + v_a = BM_edge_other_vert(e_a, v); + v_b = BM_edge_other_vert(e_b, v); + + sub_v3_v3v3(tvec_a, v->co, v_a->co); + sub_v3_v3v3(tvec_b, v_b->co, v->co); + normalize_v3(tvec_a); + normalize_v3(tvec_b); + add_v3_v3v3(no_edge, tvec_a, tvec_b); /* not unit length but this is ok */ + + + /* find the normal */ + cross_v3_v3v3(r_no, no_edge, no_face); + normalize_v3(r_no); + + /* check are we flipped the right way */ + BM_edge_calc_face_tangent(e_a, l_a, tvec_a); + BM_edge_calc_face_tangent(e_b, l_b, tvec_b); + add_v3_v3(tvec_a, tvec_b); + + if (dot_v3v3(r_no, tvec_a) > 0.0) { + negate_v3(r_no); + } + + copy_v3_v3(r_no_face, no_face); + *r_va_other = v_a; + *r_vb_other = v_b; +} + +/* check if we are the only tagged loop-face around this edge */ +static int bm_loop_is_radial_boundary(BMLoop *l_first) +{ + BMLoop *l = l_first->radial_next; + + if (l == l_first) { + return TRUE; /* a real boundary */ + } + else { + do { + if (BM_elem_flag_test(l->f, BM_ELEM_TAG)) { + return FALSE; + } + } while ((l = l->radial_next) != l_first); + } + return TRUE; +} + +extern float BM_vert_calc_mean_tagged_edge_length(BMVert *v); + +void bmo_wireframe_exec(BMesh *bm, BMOperator *op) +{ + const int use_boundary = BMO_slot_bool_get(op, "use_boundary"); + const int use_even_offset = BMO_slot_bool_get(op, "use_even_offset"); + const int use_relative_offset = BMO_slot_bool_get(op, "use_relative_offset"); + const float depth = BMO_slot_float_get(op, "thickness"); + const float inset = depth; + + const int totvert_orig = bm->totvert; + + BMOIter oiter; + BMIter iter; + BMIter itersub; + + /* filled only with boundary verts */ + BMVert **verts_src = MEM_mallocN(sizeof(BMVert **) * totvert_orig, __func__); + BMVert **verts_neg = MEM_mallocN(sizeof(BMVert **) * totvert_orig, __func__); + BMVert **verts_pos = MEM_mallocN(sizeof(BMVert **) * totvert_orig, __func__); + + /* will over-alloc, but makes for easy lookups by index to keep aligned */ + BMVert **verts_boundary = use_boundary ? + MEM_mallocN(sizeof(BMVert **) * totvert_orig, __func__) : NULL; + + float *verts_relfac = use_relative_offset ? + MEM_mallocN(sizeof(float) * totvert_orig, __func__) : NULL; + + /* may over-alloc if not all faces have wire */ + BMVert **verts_loop; + int verts_loop_tot = 0; + + BMVert *v_src; + + BMFace *f_src; + BMLoop *l; + + float tvec[3]; + float fac; + + int i; + + BM_mesh_elem_index_ensure(bm, BM_VERT); + + BM_ITER_MESH_INDEX (v_src, &iter, bm, BM_VERTS_OF_MESH, i) { + BM_elem_flag_disable(v_src, BM_ELEM_TAG); + verts_src[i] = v_src; + } + + /* setup tags, all faces and verts will be tagged which will be duplicated */ + BM_mesh_elem_hflag_disable_all(bm, BM_FACE, BM_ELEM_TAG, FALSE); + + BMO_ITER (f_src, &oiter, bm, op, "faces", BM_FACE) { + verts_loop_tot += f_src->len; + BM_elem_flag_enable(f_src, BM_ELEM_TAG); + BM_ITER_ELEM (l, &itersub, f_src, BM_LOOPS_OF_FACE) { + BM_elem_flag_enable(l->v, BM_ELEM_TAG); + + /* also tag boundary edges */ + BM_elem_flag_set(l->e, BM_ELEM_TAG, bm_loop_is_radial_boundary(l)); + } + } + + /* duplicate tagged verts */ + for (i = 0, v_src = verts_src[i]; i < totvert_orig; i++, v_src = verts_src[i]) { + if (BM_elem_flag_test(v_src, BM_ELEM_TAG)) { + fac = depth; + + if (use_relative_offset) { + verts_relfac[i] = BM_vert_calc_mean_tagged_edge_length(v_src); + fac *= verts_relfac[i]; + } + + madd_v3_v3v3fl(tvec, v_src->co, v_src->no, -fac); + verts_neg[i] = BM_vert_create(bm, tvec, v_src); + madd_v3_v3v3fl(tvec, v_src->co, v_src->no, fac); + verts_pos[i] = BM_vert_create(bm, tvec, v_src); + } + else { + /* could skip this */ + verts_src[i] = NULL; + verts_neg[i] = NULL; + verts_pos[i] = NULL; + } + + /* conflicts with BM_vert_calc_mean_tagged_edge_length */ + if (use_relative_offset == FALSE) { + BM_elem_flag_disable(v_src, BM_ELEM_TAG); + } + } + + if (use_relative_offset) { + BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, FALSE); + } + + verts_loop = MEM_mallocN(sizeof(BMVert **) * verts_loop_tot, __func__); + verts_loop_tot = 0; /* count up again */ + + BMO_ITER (f_src, &oiter, bm, op, "faces", BM_FACE) { + BM_ITER_ELEM (l, &itersub, f_src, BM_LOOPS_OF_FACE) { + BM_elem_index_set(l, verts_loop_tot); /* set_loop */ + + BM_loop_calc_face_tangent(l, tvec); + + /* create offset vert */ + fac = inset; + if (use_even_offset) { + fac *= shell_angle_to_dist((M_PI - BM_loop_calc_face_angle(l)) * 0.5f); + } + if (use_relative_offset) { + fac *= verts_relfac[BM_elem_index_get(l->v)]; + } + + madd_v3_v3v3fl(tvec, l->v->co, tvec, fac); + verts_loop[verts_loop_tot] = BM_vert_create(bm, tvec, l->v); + + + if (use_boundary) { + if (BM_elem_flag_test(l->e, BM_ELEM_TAG)) { /* is this a boundary? */ + + BMLoop *l_pair[2] = {l, l->next}; + + BM_elem_flag_enable(l->e, BM_ELEM_TAG); + for (i = 0; i < 2; i++) { + if (!BM_elem_flag_test(l_pair[i]->v, BM_ELEM_TAG)) { + float no_face[3]; + BMVert *va_other; + BMVert *vb_other; + + BM_elem_flag_enable(l_pair[i]->v, BM_ELEM_TAG); + + bm_vert_boundary_tangent(l_pair[i]->v, tvec, no_face, &va_other, &vb_other); + + /* create offset vert */ + /* similar to code above but different angle calc */ + fac = inset; + if (use_even_offset) { + fac *= shell_angle_to_dist((M_PI - angle_on_axis_v3v3v3_v3(va_other->co, + l_pair[i]->v->co, + vb_other->co, + no_face)) * 0.5f); + } + if (use_relative_offset) { + fac *= verts_relfac[BM_elem_index_get(l_pair[i]->v)]; + } + madd_v3_v3v3fl(tvec, l_pair[i]->v->co, tvec, fac); + verts_boundary[BM_elem_index_get(l_pair[i]->v)] = BM_vert_create(bm, tvec, l_pair[i]->v); + } + } + } + } + + verts_loop_tot++; + } + } + + BMO_ITER (f_src, &oiter, bm, op, "faces", BM_FACE) { + BM_elem_flag_disable(f_src, BM_ELEM_TAG); + BM_ITER_ELEM (l, &itersub, f_src, BM_LOOPS_OF_FACE) { + BMFace *f_new; + BMLoop *l_new; + BMLoop *l_next = l->next; + BMVert *v_l1 = verts_loop[BM_elem_index_get(l)]; + BMVert *v_l2 = verts_loop[BM_elem_index_get(l_next)]; + + BMVert *v_src_l1 = l->v; + BMVert *v_src_l2 = l_next->v; + + const int i_1 = BM_elem_index_get(v_src_l1); + const int i_2 = BM_elem_index_get(v_src_l2); + + BMVert *v_neg1 = verts_neg[i_1]; + BMVert *v_neg2 = verts_neg[i_2]; + + BMVert *v_pos1 = verts_pos[i_1]; + BMVert *v_pos2 = verts_pos[i_2]; + + f_new = BM_face_create_quad_tri(bm, v_l1, v_l2, v_neg2, v_neg1, f_src, FALSE); + BM_elem_flag_enable(f_new, BM_ELEM_TAG); + l_new = BM_FACE_FIRST_LOOP(f_new); + + BM_elem_attrs_copy(bm, bm, l, l_new); + BM_elem_attrs_copy(bm, bm, l, l_new->prev); + BM_elem_attrs_copy(bm, bm, l_next, l_new->next); + BM_elem_attrs_copy(bm, bm, l_next, l_new->next->next); + + f_new = BM_face_create_quad_tri(bm, v_l2, v_l1, v_pos1, v_pos2, f_src, FALSE); + BM_elem_flag_enable(f_new, BM_ELEM_TAG); + l_new = BM_FACE_FIRST_LOOP(f_new); + + BM_elem_attrs_copy(bm, bm, l_next, l_new); + BM_elem_attrs_copy(bm, bm, l_next, l_new->prev); + BM_elem_attrs_copy(bm, bm, l, l_new->next); + BM_elem_attrs_copy(bm, bm, l, l_new->next->next); + + + + if (use_boundary) { + if (BM_elem_flag_test(l->e, BM_ELEM_TAG)) { + /* we know its a boundary and this is the only face user (which is being wire'd) */ + /* we know we only touch this edge/face once */ + BMVert *v_b1 = verts_boundary[i_1]; + BMVert *v_b2 = verts_boundary[i_2]; + + f_new = BM_face_create_quad_tri(bm, v_b2, v_b1, v_neg1, v_neg2, f_src, FALSE); + BM_elem_flag_enable(f_new, BM_ELEM_TAG); + l_new = BM_FACE_FIRST_LOOP(f_new); + + BM_elem_attrs_copy(bm, bm, l_next, l_new); + BM_elem_attrs_copy(bm, bm, l_next, l_new->prev); + BM_elem_attrs_copy(bm, bm, l, l_new->next); + BM_elem_attrs_copy(bm, bm, l, l_new->next->next); + + f_new = BM_face_create_quad_tri(bm, v_b1, v_b2, v_pos2, v_pos1, f_src, FALSE); + BM_elem_flag_enable(f_new, BM_ELEM_TAG); + l_new = BM_FACE_FIRST_LOOP(f_new); + + BM_elem_attrs_copy(bm, bm, l, l_new); + BM_elem_attrs_copy(bm, bm, l, l_new->prev); + BM_elem_attrs_copy(bm, bm, l_next, l_new->next); + BM_elem_attrs_copy(bm, bm, l_next, l_new->next->next); + } + } + } + } + + if (use_boundary) { + MEM_freeN(verts_boundary); + } + + if (use_relative_offset) { + MEM_freeN(verts_relfac); + } + + MEM_freeN(verts_src); + MEM_freeN(verts_neg); + MEM_freeN(verts_pos); + MEM_freeN(verts_loop); + + BMO_slot_buffer_from_enabled_hflag(bm, op, "faceout", BM_FACE, BM_ELEM_TAG); +} diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 7eae8b4d67e..a5053978186 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4266,3 +4266,70 @@ void MESH_OT_inset(wmOperatorType *ot) RNA_def_boolean(ot->srna, "use_select_inset", TRUE, "Select Outer", "Select the new inset faces"); } +static int edbm_wireframe_exec(bContext *C, wmOperator *op) +{ + Object *obedit = CTX_data_edit_object(C); + BMEditMesh *em = BMEdit_FromObject(obedit); + BMOperator bmop; + const int use_boundary = RNA_boolean_get(op->ptr, "use_boundary"); + const int use_even_offset = RNA_boolean_get(op->ptr, "use_even_offset"); + const int use_replace = RNA_boolean_get(op->ptr, "use_replace"); + const int use_relative_offset = RNA_boolean_get(op->ptr, "use_relative_offset"); + const float thickness = RNA_float_get(op->ptr, "thickness"); + + EDBM_op_init(em, &bmop, op, + "wireframe faces=%hf use_boundary=%b use_even_offset=%b use_relative_offset=%b " + "thickness=%f", + BM_ELEM_SELECT, use_boundary, use_even_offset, use_relative_offset, + thickness); + + BMO_op_exec(em->bm, &bmop); + + if (use_replace) { + BM_mesh_elem_hflag_disable_all(em->bm, BM_FACE, BM_ELEM_TAG, FALSE); + BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faces", BM_FACE, BM_ELEM_TAG, FALSE); + + BMO_op_callf(em->bm, "del geom=%hvef context=%i", BM_ELEM_TAG, DEL_FACES); + } + + BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE); + BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faceout", BM_FACE, BM_ELEM_SELECT, TRUE); + + if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + return OPERATOR_CANCELLED; + } + else { + EDBM_update_generic(C, em, TRUE); + return OPERATOR_FINISHED; + } +} + +void MESH_OT_wireframe(wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* identifiers */ + ot->name = "Wire Frame"; + ot->idname = "MESH_OT_wireframe"; + ot->description = "Inset new faces into selected faces"; + + /* api callbacks */ + ot->exec = edbm_wireframe_exec; + ot->poll = ED_operator_editmesh; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + RNA_def_boolean(ot->srna, "use_boundary", TRUE, "Boundary", "Inset face boundaries"); + RNA_def_boolean(ot->srna, "use_even_offset", TRUE, "Offset Even", "Scale the offset to give more even thickness"); + RNA_def_boolean(ot->srna, "use_relative_offset", FALSE, "Offset Relative", "Scale the offset by surrounding geometry"); + + prop = RNA_def_float(ot->srna, "thickness", 0.01f, 0.0f, FLT_MAX, "Thickness", "", 0.0f, 10.0f); + /* use 1 rather then 10 for max else dragging the button moves too far */ + RNA_def_property_ui_range(prop, 0.0, 1.0, 0.01, 4); + + + RNA_def_boolean(ot->srna, "use_replace", TRUE, "Replace", "Remove original faces"); +} + diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index b6403f33bc9..ca989a25ccd 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -211,6 +211,7 @@ void MESH_OT_bevel(struct wmOperatorType *ot); void MESH_OT_bridge_edge_loops(struct wmOperatorType *ot); void MESH_OT_inset(struct wmOperatorType *ot); +void MESH_OT_wireframe(struct wmOperatorType *ot); void MESH_OT_vert_slide(struct wmOperatorType *ot); /* ******************* mesh_navmesh.c */ diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 4b4fef53275..0b2a6d2bd66 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -164,6 +164,7 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_bridge_edge_loops); WM_operatortype_append(MESH_OT_inset); + WM_operatortype_append(MESH_OT_wireframe); WM_operatortype_append(MESH_OT_edge_split); #ifdef WITH_GAMEENGINE From 16d4c49c464ba4c56d96120003456e92688432f1 Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Sun, 29 Apr 2012 12:20:06 +0000 Subject: [PATCH 02/10] Fix Cycles to compile again on AMD OpenCL devices. --- intern/cycles/util/util_math.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h index 33e351c74e9..53c1302b4a1 100644 --- a/intern/cycles/util/util_math.h +++ b/intern/cycles/util/util_math.h @@ -541,7 +541,7 @@ __device_inline bool is_zero(const float3 a) #endif } -__device_inline float reduce_add(const float3& a) +__device_inline float reduce_add(const float3 a) { #ifdef __KERNEL_SSE__ return (a.x + a.y + a.z); From c27c87dde4f627565df7cb000b7eba45c2604ce4 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 29 Apr 2012 12:32:26 +0000 Subject: [PATCH 03/10] Camera tracking: backport refactoring made in local branches with masking and dopesheet view into trunk Mostly related on changes in poll functions for tracking operators and some changes to how interface is initializing for different view types. --- release/scripts/startup/bl_ui/space_clip.py | 4 + source/blender/editors/include/ED_clip.h | 5 + .../blender/editors/space_clip/clip_buttons.c | 8 + .../blender/editors/space_clip/clip_editor.c | 57 +++++ .../editors/space_clip/clip_graph_draw.c | 58 +---- .../editors/space_clip/clip_graph_ops.c | 8 +- .../blender/editors/space_clip/clip_intern.h | 5 + .../blender/editors/space_clip/clip_toolbar.c | 8 +- .../blender/editors/space_clip/clip_utils.c | 60 +++++ .../blender/editors/space_clip/space_clip.c | 207 ++++++++++++++---- .../blender/editors/space_clip/tracking_ops.c | 99 +++------ source/blender/editors/transform/transform.c | 37 +++- .../editors/transform/transform_conversions.c | 21 +- .../editors/transform/transform_generics.c | 13 +- source/blender/makesdna/DNA_space_types.h | 1 + source/blender/makesrna/intern/rna_space.c | 6 + 16 files changed, 406 insertions(+), 191 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index ace208eb9b1..5c67b932d03 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -829,6 +829,10 @@ class CLIP_MT_view(Menu): def draw(self, context): layout = self.layout + sc = context.space_data + + layout.prop(sc, "show_seconds") + layout.separator() layout.operator("clip.properties", icon='MENU_PANEL') layout.operator("clip.tools", icon='MENU_PANEL') diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h index 5e8ef618a42..dfd0f258fc0 100644 --- a/source/blender/editors/include/ED_clip.h +++ b/source/blender/editors/include/ED_clip.h @@ -41,6 +41,9 @@ struct wmEvent; /* clip_editor.c */ int ED_space_clip_poll(struct bContext *C); +int ED_space_clip_tracking_poll(struct bContext *C); +int ED_space_clip_tracking_size_poll(struct bContext *C); +int ED_space_clip_tracking_frame_poll(struct bContext *C); void ED_space_clip_set(struct bContext *C, struct SpaceClip *sc, struct MovieClip *clip); struct MovieClip *ED_space_clip(struct SpaceClip *sc); @@ -58,6 +61,8 @@ void ED_clip_point_undistorted_pos(SpaceClip *sc, float co[2], float nco[2]); void ED_clip_point_stable_pos(struct bContext *C, float x, float y, float *xr, float *yr); void ED_clip_mouse_pos(struct bContext *C, struct wmEvent *event, float co[2]); +int ED_space_clip_show_trackedit(struct SpaceClip *sc); + /* clip_ops.c */ void ED_operatormacros_clip(void); diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index eabd64bdc4f..6bf7c4e3dc8 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -63,6 +63,13 @@ /* Panels */ +static int clip_grease_pencil_panel_poll(const bContext *C, PanelType *UNUSED(pt)) +{ + SpaceClip *sc = CTX_wm_space_clip(C); + + return TRUE; +} + void ED_clip_buttons_register(ARegionType *art) { PanelType *pt; @@ -72,6 +79,7 @@ void ED_clip_buttons_register(ARegionType *art) strcpy(pt->label, "Grease Pencil"); pt->draw = gpencil_panel_standard; pt->flag |= PNL_DEFAULT_CLOSED; + pt->poll = clip_grease_pencil_panel_poll; BLI_addtail(&art->paneltypes, pt); } diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 3946d4cc36d..885357a100d 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -35,6 +35,7 @@ #include "BKE_movieclip.h" #include "BKE_context.h" #include "BKE_tracking.h" + #include "DNA_object_types.h" /* SELECT */ #include "BLI_utildefines.h" @@ -55,6 +56,8 @@ #include "clip_intern.h" // own include +/* ******** operactor poll functions ******** */ + int ED_space_clip_poll(bContext *C) { SpaceClip *sc = CTX_wm_space_clip(C); @@ -65,6 +68,51 @@ int ED_space_clip_poll(bContext *C) return FALSE; } +int ED_space_clip_tracking_poll(bContext *C) +{ + SpaceClip *sc= CTX_wm_space_clip(C); + + if (sc && sc->clip) + return ED_space_clip_show_trackedit(sc); + + return FALSE; +} + +int ED_space_clip_tracking_size_poll(bContext *C) +{ + if (ED_space_clip_tracking_poll(C)) { + MovieClip *clip = CTX_data_edit_movieclip(C); + + if (clip) { + SpaceClip *sc = CTX_wm_space_clip(C); + int width, height; + + BKE_movieclip_get_size(clip, &sc->user, &width, &height); + + return width > 0 && height > 0; + } + } + + return FALSE; +} + +int ED_space_clip_tracking_frame_poll(bContext *C) +{ + if (ED_space_clip_tracking_poll(C)) { + MovieClip *clip = CTX_data_edit_movieclip(C); + + if (clip) { + SpaceClip *sc = CTX_wm_space_clip(C); + + return BKE_movieclip_has_frame(clip, &sc->user); + } + } + + return FALSE; +} + +/* ******** editing functions ******** */ + void ED_space_clip_set(bContext *C, SpaceClip *sc, MovieClip *clip) { sc->clip = clip; @@ -314,3 +362,12 @@ void ED_clip_mouse_pos(bContext *C, wmEvent *event, float co[2]) { ED_clip_point_stable_pos(C, event->mval[0], event->mval[1], &co[0], &co[1]); } + +int ED_space_clip_show_trackedit(SpaceClip *sc) +{ + if (sc) { + return ELEM3(sc->mode, SC_MODE_TRACKING, SC_MODE_RECONSTRUCTION, SC_MODE_DISTORTION); + } + + return FALSE; +} diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index df14491c9c9..4825403fb4a 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -87,60 +87,6 @@ static void draw_curve_knot(float x, float y, float xscale, float yscale, float glPopMatrix(); } -static void draw_graph_cfra(SpaceClip *sc, ARegion *ar, Scene *scene) -{ - View2D *v2d = &ar->v2d; - float xscale, yscale; - float vec[2]; - - /* Draw a light green line to indicate current frame */ - vec[0] = (float)(sc->user.framenr * scene->r.framelen); - - UI_ThemeColor(TH_CFRAME); - glLineWidth(2.0); - - glBegin(GL_LINE_STRIP); - vec[1] = v2d->cur.ymin; - glVertex2fv(vec); - - vec[1] = v2d->cur.ymax; - glVertex2fv(vec); - glEnd(); - - glLineWidth(1.0); - - UI_view2d_view_orthoSpecial(ar, v2d, 1); - - /* because the frame number text is subject to the same scaling as the contents of the view */ - UI_view2d_getscale(v2d, &xscale, &yscale); - glScalef(1.0f/xscale, 1.0f, 1.0f); - - clip_draw_curfra_label(sc, (float)sc->user.framenr * xscale, 18); - - /* restore view transform */ - glScalef(xscale, 1.0, 1.0); -} - -static void draw_graph_sfra_efra(Scene *scene, View2D *v2d) -{ - UI_view2d_view_ortho(v2d); - - /* currently clip editor supposes that editing clip length is equal to scene frame range */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - glColor4f(0.0f, 0.0f, 0.0f, 0.4f); - - glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax); - glRectf((float)EFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); - glDisable(GL_BLEND); - - UI_ThemeColorShade(TH_BACK, -60); - - /* thin lines where the actual frames are */ - fdrawline((float)SFRA, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax); - fdrawline((float)EFRA, v2d->cur.ymin, (float)EFRA, v2d->cur.ymax); -} - static void tracking_segment_point_cb(void *UNUSED(userdata), MovieTrackingTrack *UNUSED(track), MovieTrackingMarker *marker, int UNUSED(coord), float val) { @@ -280,8 +226,8 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene) } /* frame range */ - draw_graph_sfra_efra(scene, v2d); + clip_draw_sfra_efra(v2d, scene); /* current frame */ - draw_graph_cfra(sc, ar, scene); + clip_draw_cfra(sc, ar, scene); } diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index b569469d304..7916a96f98c 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -63,15 +63,13 @@ static int ED_space_clip_graph_poll(bContext *C) { - SpaceClip *sc = CTX_wm_space_clip(C); - - if (sc && sc->clip) { + if (ED_space_clip_tracking_poll(C)) { ARegion *ar = CTX_wm_region(C); return ar->regiontype == RGN_TYPE_PREVIEW; } - return 0; + return FALSE; } typedef struct { @@ -486,7 +484,7 @@ void CLIP_OT_graph_delete_curve(wmOperatorType *ot) /* api callbacks */ ot->invoke = WM_operator_confirm; ot->exec = delete_curve_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index 425a1da9ec5..0b63ae5b12f 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -38,6 +38,7 @@ struct MovieClip; struct MovieTrackingMarker; struct MovieTrackingTrack; struct Scene; +struct ScrArea; struct SpaceClip; struct wmOperatorType; @@ -81,6 +82,7 @@ void CLIP_OT_rebuild_proxy(struct wmOperatorType *ot); void CLIP_OT_mode_set(struct wmOperatorType *ot); /* clip_toolbar.c */ +struct ARegion *ED_clip_has_properties_region(struct ScrArea *sa); void CLIP_OT_tools(struct wmOperatorType *ot); void CLIP_OT_properties(struct wmOperatorType *ot); void ED_clip_tool_props_register(struct ARegionType *art); @@ -104,6 +106,9 @@ void clip_delete_marker(struct bContext *C, struct MovieClip *clip, struct ListB void clip_view_center_to_point(struct SpaceClip *sc, float x, float y); +void clip_draw_cfra(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene); +void clip_draw_sfra_efra(struct View2D *v2d, struct Scene *scene); + /* tracking_ops.c */ void CLIP_OT_select(struct wmOperatorType *ot); void CLIP_OT_select_all(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_clip/clip_toolbar.c b/source/blender/editors/space_clip/clip_toolbar.c index b80deb8260a..da8bf8fedd9 100644 --- a/source/blender/editors/space_clip/clip_toolbar.c +++ b/source/blender/editors/space_clip/clip_toolbar.c @@ -56,7 +56,7 @@ /************************** properties ******************************/ -static ARegion *clip_has_properties_region(ScrArea *sa) +ARegion *ED_clip_has_properties_region(ScrArea *sa) { ARegion *ar, *arnew; @@ -90,9 +90,9 @@ static int properties_poll(bContext *C) static int properties_exec(bContext *C, wmOperator *UNUSED(op)) { ScrArea *sa = CTX_wm_area(C); - ARegion *ar = clip_has_properties_region(sa); + ARegion *ar = ED_clip_has_properties_region(sa); - if (ar) + if (ar && ar->alignment != RGN_ALIGN_NONE) ED_region_toggle_hidden(C, ar); return OPERATOR_FINISHED; @@ -167,7 +167,7 @@ static int tools_exec(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa = CTX_wm_area(C); ARegion *ar = clip_has_tools_region(sa); - if (ar) + if (ar && ar->alignment != RGN_ALIGN_NONE) ED_region_toggle_hidden(C, ar); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index 443a1d0cdd3..c8ba8be7eae 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -29,6 +29,7 @@ * \ingroup spclip */ +#include "DNA_scene_types.h" #include "DNA_object_types.h" /* SELECT */ #include "MEM_guardedalloc.h" @@ -42,6 +43,9 @@ #include "BKE_tracking.h" #include "BKE_depsgraph.h" +#include "BIF_gl.h" +#include "BIF_glutil.h" + #include "WM_api.h" #include "WM_types.h" @@ -53,6 +57,8 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "UI_interface.h" +#include "UI_resources.h" #include "UI_view2d.h" #include "clip_intern.h" // own include @@ -220,3 +226,57 @@ void clip_view_center_to_point(SpaceClip *sc, float x, float y) sc->xof = (x - 0.5f) * width * aspx; sc->yof = (y - 0.5f) * height * aspy; } + +void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene) +{ + View2D *v2d = &ar->v2d; + float xscale, yscale; + float vec[2]; + + /* Draw a light green line to indicate current frame */ + vec[0] = (float)(sc->user.framenr * scene->r.framelen); + + UI_ThemeColor(TH_CFRAME); + glLineWidth(2.0); + + glBegin(GL_LINE_STRIP); + vec[1] = v2d->cur.ymin; + glVertex2fv(vec); + + vec[1] = v2d->cur.ymax; + glVertex2fv(vec); + glEnd(); + + glLineWidth(1.0); + + UI_view2d_view_orthoSpecial(ar, v2d, 1); + + /* because the frame number text is subject to the same scaling as the contents of the view */ + UI_view2d_getscale(v2d, &xscale, &yscale); + glScalef(1.0f/xscale, 1.0f, 1.0f); + + clip_draw_curfra_label(sc, (float)sc->user.framenr * xscale, 18); + + /* restore view transform */ + glScalef(xscale, 1.0, 1.0); +} + +void clip_draw_sfra_efra(View2D *v2d, Scene *scene) +{ + UI_view2d_view_ortho(v2d); + + /* currently clip editor supposes that editing clip length is equal to scene frame range */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glColor4f(0.0f, 0.0f, 0.0f, 0.4f); + + glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax); + glRectf((float)EFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); + glDisable(GL_BLEND); + + UI_ThemeColorShade(TH_BACK, -60); + + /* thin lines where the actual frames are */ + fdrawline((float)SFRA, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax); + fdrawline((float)EFRA, v2d->cur.ymin, (float)EFRA, v2d->cur.ymax); +} diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 4de790bc00c..58582df7a3f 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -96,7 +96,7 @@ static void init_preview_region(const bContext *C, ARegion *ar) ar->v2d.keeptot = 0; } -static ARegion *clip_has_preview_region(const bContext *C, ScrArea *sa) +static ARegion *ED_clip_has_preview_region(const bContext *C, ScrArea *sa) { ARegion *ar, *arnew; @@ -619,10 +619,13 @@ static int clip_context(const bContext *C, const char *member, bContextDataResul if (CTX_data_dir(member)) { CTX_data_dir_set(result, clip_context_dir); + return TRUE; } else if (CTX_data_equals(member, "edit_movieclip")) { - CTX_data_id_pointer_set(result, &sc->clip->id); + if (sc->clip) + CTX_data_id_pointer_set(result, &sc->clip->id); + return TRUE; } @@ -636,54 +639,163 @@ static void clip_refresh(const bContext *C, ScrArea *sa) Scene *scene = CTX_data_scene(C); SpaceClip *sc = (SpaceClip *)sa->spacedata.first; ARegion *ar_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - ARegion *ar_preview = clip_has_preview_region(C, sa); + ARegion *ar_tools = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS); + ARegion *ar_tool_props = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_PROPS); + ARegion *ar_preview = ED_clip_has_preview_region(C, sa); + ARegion *ar_properties = ED_clip_has_properties_region(sa); + int main_visible = FALSE, preview_visible = FALSE, tools_visible = FALSE; + int tool_props_visible = FALSE, properties_visible = FALSE; int view_changed = FALSE; switch (sc->view) { case SC_VIEW_CLIP: - if (ar_preview && !(ar_preview->flag & RGN_FLAG_HIDDEN)) { - ar_preview->flag |= RGN_FLAG_HIDDEN; - ar_preview->v2d.flag &= ~V2D_IS_INITIALISED; - WM_event_remove_handlers((bContext*)C, &ar_preview->handlers); - view_changed = TRUE; - } - if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) { - ar_main->alignment = RGN_ALIGN_NONE; - view_changed = TRUE; - } - if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) { - /* store graph region align */ - if (ar_preview->alignment == RGN_ALIGN_TOP) - sc->runtime_flag &= ~SC_GRAPH_BOTTOM; - else - sc->runtime_flag |= SC_GRAPH_BOTTOM; - - ar_preview->alignment = RGN_ALIGN_NONE; - view_changed = TRUE; - } + main_visible = TRUE; + preview_visible = FALSE; + tools_visible = TRUE; + tool_props_visible = TRUE; + properties_visible = TRUE; break; case SC_VIEW_GRAPH: - if (ar_preview && (ar_preview->flag & RGN_FLAG_HIDDEN)) { - ar_preview->flag &= ~RGN_FLAG_HIDDEN; - ar_preview->v2d.flag &= ~V2D_IS_INITIALISED; - ar_preview->v2d.cur = ar_preview->v2d.tot; - view_changed = TRUE; - } - if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) { - ar_main->alignment = RGN_ALIGN_NONE; - view_changed = TRUE; - } - if (ar_preview && !ELEM(ar_preview->alignment, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) { - if (sc->runtime_flag & SC_GRAPH_BOTTOM) - ar_preview->alignment = RGN_ALIGN_BOTTOM; - else - ar_preview->alignment = RGN_ALIGN_TOP; - - view_changed = TRUE; - } + main_visible = TRUE; + preview_visible = TRUE; + tools_visible = TRUE; + tool_props_visible = TRUE; + properties_visible = TRUE; break; } + if (main_visible) { + if (ar_main && (ar_main->flag & RGN_FLAG_HIDDEN)) { + ar_main->flag &= ~RGN_FLAG_HIDDEN; + ar_main->v2d.flag &= ~V2D_IS_INITIALISED; + view_changed = TRUE; + } + + if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) { + ar_main->alignment = RGN_ALIGN_NONE; + view_changed = TRUE; + } + } + else { + if (ar_main && !(ar_main->flag & RGN_FLAG_HIDDEN)) { + ar_main->flag |= RGN_FLAG_HIDDEN; + ar_main->v2d.flag &= ~V2D_IS_INITIALISED; + WM_event_remove_handlers((bContext *)C, &ar_main->handlers); + view_changed = TRUE; + } + if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) { + ar_main->alignment = RGN_ALIGN_NONE; + view_changed = TRUE; + } + } + + if (properties_visible) { + if (ar_properties && (ar_properties->flag & RGN_FLAG_HIDDEN)) { + ar_properties->flag &= ~RGN_FLAG_HIDDEN; + ar_properties->v2d.flag &= ~V2D_IS_INITIALISED; + view_changed = TRUE; + } + if (ar_properties && ar_properties->alignment != RGN_ALIGN_RIGHT) { + ar_properties->alignment = RGN_ALIGN_RIGHT; + view_changed = TRUE; + } + } + else { + if (ar_properties && !(ar_properties->flag & RGN_FLAG_HIDDEN)) { + ar_properties->flag |= RGN_FLAG_HIDDEN; + ar_properties->v2d.flag &= ~V2D_IS_INITIALISED; + WM_event_remove_handlers((bContext *)C, &ar_properties->handlers); + view_changed = TRUE; + } + if (ar_properties && ar_properties->alignment != RGN_ALIGN_NONE) { + ar_properties->alignment = RGN_ALIGN_NONE; + view_changed = TRUE; + } + } + + if (tools_visible) { + if (ar_tools && (ar_tools->flag & RGN_FLAG_HIDDEN)) { + ar_tools->flag &= ~RGN_FLAG_HIDDEN; + ar_tools->v2d.flag &= ~V2D_IS_INITIALISED; + view_changed = TRUE; + } + if (ar_tools && ar_tools->alignment != RGN_ALIGN_LEFT) { + ar_tools->alignment = RGN_ALIGN_LEFT; + view_changed = TRUE; + } + } + else { + if (ar_tools && !(ar_tools->flag & RGN_FLAG_HIDDEN)) { + ar_tools->flag |= RGN_FLAG_HIDDEN; + ar_tools->v2d.flag &= ~V2D_IS_INITIALISED; + WM_event_remove_handlers((bContext *)C, &ar_tools->handlers); + view_changed = TRUE; + } + if (ar_tools && ar_tools->alignment != RGN_ALIGN_NONE) { + ar_tools->alignment = RGN_ALIGN_NONE; + view_changed = TRUE; + } + } + + if (tool_props_visible) { + if (ar_tool_props && (ar_tool_props->flag & RGN_FLAG_HIDDEN)) { + ar_tool_props->flag &= ~RGN_FLAG_HIDDEN; + ar_tool_props->v2d.flag &= ~V2D_IS_INITIALISED; + view_changed = TRUE; + } + if (ar_tool_props && (ar_tool_props->alignment != (RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV))) { + ar_tool_props->alignment = RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; + view_changed = TRUE; + } + } + else { + if (ar_tool_props && !(ar_tool_props->flag & RGN_FLAG_HIDDEN)) { + ar_tool_props->flag |= RGN_FLAG_HIDDEN; + ar_tool_props->v2d.flag &= ~V2D_IS_INITIALISED; + WM_event_remove_handlers((bContext *)C, &ar_tool_props->handlers); + view_changed = TRUE; + } + if (ar_tool_props && ar_tool_props->alignment != RGN_ALIGN_NONE) { + ar_tool_props->alignment = RGN_ALIGN_NONE; + view_changed = TRUE; + } + } + + if (preview_visible) { + if (ar_preview && (ar_preview->flag & RGN_FLAG_HIDDEN)) { + ar_preview->flag &= ~RGN_FLAG_HIDDEN; + ar_preview->v2d.flag &= ~V2D_IS_INITIALISED; + ar_preview->v2d.cur = ar_preview->v2d.tot; + view_changed = TRUE; + } + if (ar_preview && !ELEM(ar_preview->alignment, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) { + if (sc->runtime_flag & SC_GRAPH_BOTTOM) + ar_preview->alignment = RGN_ALIGN_BOTTOM; + else + ar_preview->alignment = RGN_ALIGN_TOP; + + view_changed = TRUE; + } + } + else { + /* store graph region align */ + if (ar_preview->alignment == RGN_ALIGN_TOP) + sc->runtime_flag &= ~SC_GRAPH_BOTTOM; + else if (ar_preview->alignment == RGN_ALIGN_BOTTOM) + sc->runtime_flag |= SC_GRAPH_BOTTOM; + + if (ar_preview && !(ar_preview->flag & RGN_FLAG_HIDDEN)) { + ar_preview->flag |= RGN_FLAG_HIDDEN; + ar_preview->v2d.flag &= ~V2D_IS_INITIALISED; + WM_event_remove_handlers((bContext *)C, &ar_preview->handlers); + view_changed = TRUE; + } + if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) { + ar_preview->alignment = RGN_ALIGN_NONE; + view_changed = TRUE; + } + } + if (view_changed) { ED_area_initialize(wm, window, sa); ED_area_tag_redraw(sa); @@ -832,13 +944,13 @@ static void clip_preview_area_init(wmWindowManager *wm, ARegion *ar) WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } -static void clip_preview_area_draw(const bContext *C, ARegion *ar) +static void graph_area_draw(const bContext *C, ARegion *ar) { View2D *v2d = &ar->v2d; View2DScrollers *scrollers; SpaceClip *sc = CTX_wm_space_clip(C); Scene *scene = CTX_data_scene(C); - short unitx = V2D_UNIT_FRAMESCALE, unity = V2D_UNIT_VALUES; + short unitx, unity; if (sc->flag & SC_LOCK_TIMECURSOR) ED_clip_graph_center_current_frame(scene, ar); @@ -856,11 +968,20 @@ static void clip_preview_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ + unitx = (sc->flag & SC_SHOW_SECONDS)? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES; + unity = V2D_UNIT_VALUES; scrollers = UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } +static void clip_preview_area_draw(const bContext *C, ARegion *ar) +{ + SpaceClip *sc = CTX_wm_space_clip(C); + + graph_area_draw(C, ar); +} + static void clip_preview_area_listener(ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn)) { } diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index f4454394ca3..b3bb7464761 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -78,39 +78,6 @@ #include "clip_intern.h" // own include -static int space_clip_frame_poll(bContext *C) -{ - SpaceClip *sc = CTX_wm_space_clip(C); - - if (sc) { - MovieClip *clip = ED_space_clip(sc); - - if (clip) - return BKE_movieclip_has_frame(clip, &sc->user); - } - - return FALSE; -} - -static int space_clip_size_poll(bContext *C) -{ - SpaceClip *sc = CTX_wm_space_clip(C); - - if (sc) { - MovieClip *clip = ED_space_clip(sc); - - if (clip) { - int width, height; - - BKE_movieclip_get_size(clip, &sc->user, &width, &height); - - return width > 0 && height > 0; - } - } - - return FALSE; -} - /********************** add marker operator *********************/ static void add_marker(SpaceClip *sc, float x, float y) @@ -175,7 +142,7 @@ void CLIP_OT_add_marker(wmOperatorType *ot) /* api callbacks */ ot->invoke = add_marker_invoke; ot->exec = add_marker_exec; - ot->poll = space_clip_size_poll; + ot->poll = ED_space_clip_tracking_size_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -220,7 +187,7 @@ void CLIP_OT_delete_track(wmOperatorType *ot) /* api callbacks */ ot->invoke = WM_operator_confirm; ot->exec = delete_track_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -271,7 +238,7 @@ void CLIP_OT_delete_marker(wmOperatorType *ot) /* api callbacks */ ot->invoke = WM_operator_confirm; ot->exec = delete_marker_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -662,7 +629,7 @@ void CLIP_OT_slide_marker(wmOperatorType *ot) ot->idname = "CLIP_OT_slide_marker"; /* api callbacks */ - ot->poll = space_clip_size_poll; + ot->poll = ED_space_clip_tracking_size_poll; ot->invoke = slide_marker_invoke; ot->modal = slide_marker_modal; @@ -876,7 +843,7 @@ void CLIP_OT_select(wmOperatorType *ot) /* api callbacks */ ot->exec = select_exec; ot->invoke = select_invoke; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_UNDO; @@ -953,7 +920,7 @@ void CLIP_OT_select_border(wmOperatorType *ot) ot->invoke = WM_border_select_invoke; ot->exec = border_select_exec; ot->modal = WM_border_select_modal; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_UNDO; @@ -1037,7 +1004,7 @@ void CLIP_OT_select_circle(wmOperatorType *ot) ot->invoke = WM_gesture_circle_invoke; ot->modal = WM_gesture_circle_modal; ot->exec = circle_select_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1128,7 +1095,7 @@ void CLIP_OT_select_all(wmOperatorType *ot) /* api callbacks */ ot->exec = select_all_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1219,7 +1186,7 @@ void CLIP_OT_select_grouped(wmOperatorType *ot) /* api callbacks */ ot->exec = select_groped_exec; - ot->poll = space_clip_size_poll; + ot->poll = ED_space_clip_tracking_size_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1596,7 +1563,7 @@ void CLIP_OT_track_markers(wmOperatorType *ot) /* api callbacks */ ot->exec = track_markers_exec; ot->invoke = track_markers_invoke; - ot->poll = space_clip_frame_poll; + ot->poll = ED_space_clip_tracking_frame_poll; ot->modal = track_markers_modal; /* flags */ @@ -1819,7 +1786,7 @@ void CLIP_OT_solve_camera(wmOperatorType *ot) ot->exec = solve_camera_exec; ot->invoke = solve_camera_invoke; ot->modal = solve_camera_modal; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1867,7 +1834,7 @@ void CLIP_OT_clear_solution(wmOperatorType *ot) /* api callbacks */ ot->exec = clear_solution_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1919,7 +1886,7 @@ void CLIP_OT_clear_track_path(wmOperatorType *ot) /* api callbacks */ ot->exec = clear_track_path_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1977,7 +1944,7 @@ void CLIP_OT_disable_markers(wmOperatorType *ot) /* api callbacks */ ot->exec = disable_markers_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2035,7 +2002,7 @@ static Object *get_orientation_object(bContext *C) static int set_orientation_poll(bContext *C) { - if (space_clip_size_poll(C)) { + if (ED_space_clip_tracking_size_poll(C)) { Scene *scene = CTX_data_scene(C); SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip(sc); @@ -2645,7 +2612,7 @@ void CLIP_OT_set_scale(wmOperatorType *ot) static int set_solution_scale_poll(bContext *C) { - if (space_clip_size_poll(C)) { + if (ED_space_clip_tracking_size_poll(C)) { SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip(sc); MovieTracking *tracking = &clip->tracking; @@ -2723,7 +2690,7 @@ void CLIP_OT_set_center_principal(wmOperatorType *ot) /* api callbacks */ ot->exec = set_center_principal_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2777,7 +2744,7 @@ void CLIP_OT_hide_tracks(wmOperatorType *ot) /* api callbacks */ ot->exec = hide_tracks_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2816,7 +2783,7 @@ void CLIP_OT_hide_tracks_clear(wmOperatorType *ot) /* api callbacks */ ot->exec = hide_tracks_clear_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2898,7 +2865,7 @@ void CLIP_OT_detect_features(wmOperatorType *ot) /* api callbacks */ ot->exec = detect_features_exec; - ot->poll = space_clip_frame_poll; + ot->poll = ED_space_clip_tracking_frame_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2993,7 +2960,7 @@ void CLIP_OT_frame_jump(wmOperatorType *ot) /* api callbacks */ ot->exec = frame_jump_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -3050,7 +3017,7 @@ void CLIP_OT_join_tracks(wmOperatorType *ot) /* api callbacks */ ot->exec = join_tracks_exec; - ot->poll = space_clip_size_poll; + ot->poll = ED_space_clip_tracking_size_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -3100,7 +3067,7 @@ void CLIP_OT_lock_tracks(wmOperatorType *ot) /* api callbacks */ ot->exec = lock_tracks_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -3150,7 +3117,7 @@ void CLIP_OT_track_copy_color(wmOperatorType *ot) /* api callbacks */ ot->exec = track_copy_color_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -3199,7 +3166,7 @@ void CLIP_OT_stabilize_2d_add(wmOperatorType *ot) /* api callbacks */ ot->exec = stabilize_2d_add_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -3259,7 +3226,7 @@ void CLIP_OT_stabilize_2d_remove(wmOperatorType *ot) /* api callbacks */ ot->exec = stabilize_2d_remove_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -3302,7 +3269,7 @@ void CLIP_OT_stabilize_2d_select(wmOperatorType *ot) /* api callbacks */ ot->exec = stabilize_2d_select_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -3339,7 +3306,7 @@ void CLIP_OT_stabilize_2d_set_rotation(wmOperatorType *ot) /* api callbacks */ ot->exec = stabilize_2d_set_rotation_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -3530,7 +3497,7 @@ void CLIP_OT_clean_tracks(wmOperatorType *ot) /* api callbacks */ ot->exec = clean_tracks_exec; ot->invoke = clean_tracks_invoke; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -3567,7 +3534,7 @@ void CLIP_OT_tracking_object_new(wmOperatorType *ot) /* api callbacks */ ot->exec = tracking_object_new_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -3605,7 +3572,7 @@ void CLIP_OT_tracking_object_remove(wmOperatorType *ot) /* api callbacks */ ot->exec = tracking_object_remove_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; @@ -3636,7 +3603,7 @@ void CLIP_OT_copy_tracks(wmOperatorType *ot) /* api callbacks */ ot->exec = copy_tracks_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_tracking_poll; /* flags */ ot->flag = OPTYPE_REGISTER; @@ -3646,7 +3613,7 @@ void CLIP_OT_copy_tracks(wmOperatorType *ot) static int paste_tracks_poll(bContext *C) { - if (ED_space_clip_poll(C)) { + if (ED_space_clip_tracking_poll(C)) { return BKE_tracking_clipboard_has_tracks(); } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 233719033c7..82bb30d660f 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -225,7 +225,11 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2]) adr[1]= out[1]; } else if (t->spacetype==SPACE_CLIP) { - UI_view2d_to_region_no_clip(t->view, vec[0], vec[1], adr, adr+1); + float v[2]; + + copy_v2_v2(v, vec); + + UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr+1); } } @@ -274,6 +278,19 @@ void applyAspectRatio(TransInfo *t, float *vec) vec[0] /= aspx; vec[1] /= aspy; } + else if ((t->spacetype==SPACE_CLIP) && (t->mode==TFM_TRANSLATION)) { + if (t->options & CTX_MOVIECLIP) { + SpaceClip *sc = t->sa->spacedata.first; + float aspx, aspy; + int width, height; + + ED_space_clip_size(sc, &width, &height); + ED_space_clip_aspect(sc, &aspx, &aspy); + + vec[0] *= width / aspx; + vec[1] *= height / aspy; + } + } } void removeAspectRatio(TransInfo *t, float *vec) @@ -294,6 +311,19 @@ void removeAspectRatio(TransInfo *t, float *vec) vec[0] *= aspx; vec[1] *= aspy; } + else if ((t->spacetype==SPACE_CLIP) && (t->mode==TFM_TRANSLATION)) { + if (t->options & CTX_MOVIECLIP) { + SpaceClip *sc = t->sa->spacedata.first; + float aspx, aspy; + int width, height; + + ED_space_clip_size(sc, &width, &height); + ED_space_clip_aspect(sc, &aspx, &aspy); + + vec[0] *= aspx / width; + vec[1] *= aspy / height; + } + } } static void viewRedrawForce(const bContext *C, TransInfo *t) @@ -624,10 +654,10 @@ int transformEvent(TransInfo *t, wmEvent *event) t->redraw |= TREDRAW_HARD; } else if (t->mode == TFM_TRANSLATION) { - if (t->options&CTX_MOVIECLIP) { + if(t->options & CTX_MOVIECLIP) { restoreTransObjects(t); - t->flag^= T_ALT_TRANSFORM; + t->flag ^= T_ALT_TRANSFORM; t->redraw |= TREDRAW_HARD; } } @@ -1561,6 +1591,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t); } else if (t->spacetype == SPACE_CLIP) { + SpaceClip *sc = CTX_wm_space_clip(C); unit_m3(t->spacemtx); t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW); t->options |= CTX_MOVIECLIP; diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 00c8e0a1d34..859ae1e1b1b 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -4924,14 +4924,16 @@ void special_aftertrans_update(bContext *C, TransInfo *t) ED_node_link_intersect_test(t->sa, 0); } else if (t->spacetype == SPACE_CLIP) { - SpaceClip *sc = t->sa->spacedata.first; - MovieClip *clip = ED_space_clip(sc); + if (t->options & CTX_MOVIECLIP) { + SpaceClip *sc = t->sa->spacedata.first; + MovieClip *clip = ED_space_clip(sc); - if (t->scene->nodetree) { - /* tracks can be used for stabilization nodes, - * flush update for such nodes */ - nodeUpdateID(t->scene->nodetree, &clip->id); - WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL); + if (t->scene->nodetree) { + /* tracks can be used for stabilization nodes, + * flush update for such nodes */ + nodeUpdateID(t->scene->nodetree, &clip->id); + WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL); + } } } else if (t->spacetype == SPACE_ACTION) { @@ -5402,6 +5404,8 @@ static void createTransNodeData(bContext *C, TransInfo *t) /* *** CLIP EDITOR *** */ +/* * motion tracking * */ + enum { transDataTracking_ModeTracks = 0, transDataTracking_ModeCurves = 1, @@ -5923,7 +5927,8 @@ void createTransData(bContext *C, TransInfo *t) } else if (t->spacetype == SPACE_CLIP) { t->flag |= T_POINTS|T_2D_EDIT; - createTransTrackingData(C, t); + if (t->options & CTX_MOVIECLIP) + createTransTrackingData(C, t); } else if (t->obedit) { t->ext = NULL; diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 217e0d36fce..c1b995e8a53 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -633,15 +633,16 @@ static void recalcData_image(TransInfo *t) } /* helper for recalcData() - for Movie Clip transforms */ -static void recalcData_clip(TransInfo *t) +static void recalcData_spaceclip(TransInfo *t) { SpaceClip *sc = t->sa->spacedata.first; + MovieClip *clip = ED_space_clip(sc); ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); MovieTrackingTrack *track; - + flushTransTracking(t); - + track = tracksbase->first; while (track) { if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) { @@ -658,10 +659,10 @@ static void recalcData_clip(TransInfo *t) BKE_tracking_clamp_track(track, CLAMP_SEARCH_DIM); } } - + track = track->next; } - + DAG_id_tag_update(&clip->id, 0); } @@ -900,7 +901,7 @@ void recalcData(TransInfo *t) recalcData_view3d(t); } else if (t->spacetype == SPACE_CLIP) { - recalcData_clip(t); + recalcData_spaceclip(t); } } diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 1938c63d474..2356c1945b9 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -904,6 +904,7 @@ enum { #define SC_SHOW_GRAPH_TRACKS (1<<15) /*#define SC_SHOW_PYRAMID_LEVELS (1<<16) */ /* UNUSED */ #define SC_LOCK_TIMECURSOR (1<<17) +#define SC_SHOW_SECONDS (1<<18) /* SpaceClip->mode */ #define SC_MODE_TRACKING 0 diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 8d4b5a32969..15f296b504b 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -3104,6 +3104,12 @@ static void rna_def_space_clip(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "postproc_flag", MOVIECLIP_PREVIEW_GRAYSCALE); RNA_def_property_ui_text(prop, "Grayscale", "Display frame in grayscale mode"); RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL); + + /* timeline */ + prop = RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_SECONDS); + RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames"); + RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL); } From 04d8ef3c476bf75d7790741b559cb4b6e075917b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 29 Apr 2012 12:33:56 +0000 Subject: [PATCH 04/10] wireframe option to crase edges at the hub, much nicer subsurf --- source/blender/bmesh/intern/bmesh_opdefines.c | 1 + .../blender/bmesh/operators/bmo_wireframe.c | 43 ++++++++++++++++--- source/blender/editors/mesh/editmesh_tools.c | 14 +++--- .../windowmanager/intern/wm_event_system.c | 2 +- 4 files changed, 48 insertions(+), 12 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 8ffaf1875cf..af083fc30a6 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -1119,6 +1119,7 @@ static BMOpDefine bmo_wireframe_def = { {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */ {BMO_OP_SLOT_BOOL, "use_boundary"}, {BMO_OP_SLOT_BOOL, "use_even_offset"}, + {BMO_OP_SLOT_BOOL, "use_crease"}, {BMO_OP_SLOT_FLT, "thickness"}, {BMO_OP_SLOT_BOOL, "use_relative_offset"}, {BMO_OP_SLOT_FLT, "depth"}, diff --git a/source/blender/bmesh/operators/bmo_wireframe.c b/source/blender/bmesh/operators/bmo_wireframe.c index 49aff164b7d..7cb8ac0b66d 100644 --- a/source/blender/bmesh/operators/bmo_wireframe.c +++ b/source/blender/bmesh/operators/bmo_wireframe.c @@ -28,6 +28,8 @@ #include "BLI_math.h" +#include "BKE_customdata.h" + #include "bmesh.h" #include "intern/bmesh_operators_private.h" /* own include */ @@ -132,9 +134,11 @@ extern float BM_vert_calc_mean_tagged_edge_length(BMVert *v); void bmo_wireframe_exec(BMesh *bm, BMOperator *op) { - const int use_boundary = BMO_slot_bool_get(op, "use_boundary"); - const int use_even_offset = BMO_slot_bool_get(op, "use_even_offset"); - const int use_relative_offset = BMO_slot_bool_get(op, "use_relative_offset"); + const int use_boundary = BMO_slot_bool_get(op, "use_boundary"); + const int use_even_offset = BMO_slot_bool_get(op, "use_even_offset"); + const int use_relative_offset = BMO_slot_bool_get(op, "use_relative_offset"); + const int use_crease = (BMO_slot_bool_get(op, "use_crease") && + CustomData_has_layer(&bm->edata, CD_CREASE)); const float depth = BMO_slot_float_get(op, "thickness"); const float inset = depth; @@ -323,8 +327,6 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op) BM_elem_attrs_copy(bm, bm, l, l_new->next); BM_elem_attrs_copy(bm, bm, l, l_new->next->next); - - if (use_boundary) { if (BM_elem_flag_test(l->e, BM_ELEM_TAG)) { /* we know its a boundary and this is the only face user (which is being wire'd) */ @@ -349,8 +351,39 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op) BM_elem_attrs_copy(bm, bm, l, l_new->prev); BM_elem_attrs_copy(bm, bm, l_next, l_new->next); BM_elem_attrs_copy(bm, bm, l_next, l_new->next->next); + + if (use_crease) { + BMEdge *e_new; + e_new = BM_edge_exists(v_pos1, v_b1); + BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f); + + e_new = BM_edge_exists(v_pos2, v_b2); + BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f); + + e_new = BM_edge_exists(v_neg1, v_b1); + BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f); + + e_new = BM_edge_exists(v_neg2, v_b2); + BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f); + } } } + + if (use_crease) { + BMEdge *e_new; + e_new = BM_edge_exists(v_pos1, v_l1); + BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f); + + e_new = BM_edge_exists(v_pos2, v_l2); + BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f); + + e_new = BM_edge_exists(v_neg1, v_l1); + BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f); + + e_new = BM_edge_exists(v_neg2, v_l2); + BM_elem_float_data_set(&bm->edata, e_new, CD_CREASE, 1.0f); + } + } } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index a5053978186..b650a361369 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4271,16 +4271,17 @@ static int edbm_wireframe_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); BMOperator bmop; - const int use_boundary = RNA_boolean_get(op->ptr, "use_boundary"); - const int use_even_offset = RNA_boolean_get(op->ptr, "use_even_offset"); + const int use_boundary = RNA_boolean_get(op->ptr, "use_boundary"); + const int use_even_offset = RNA_boolean_get(op->ptr, "use_even_offset"); const int use_replace = RNA_boolean_get(op->ptr, "use_replace"); - const int use_relative_offset = RNA_boolean_get(op->ptr, "use_relative_offset"); - const float thickness = RNA_float_get(op->ptr, "thickness"); + const int use_relative_offset = RNA_boolean_get(op->ptr, "use_relative_offset"); + const int use_crease = RNA_boolean_get(op->ptr, "use_crease"); + const float thickness = RNA_float_get(op->ptr, "thickness"); EDBM_op_init(em, &bmop, op, - "wireframe faces=%hf use_boundary=%b use_even_offset=%b use_relative_offset=%b " + "wireframe faces=%hf use_boundary=%b use_even_offset=%b use_relative_offset=%b use_crease=%b " "thickness=%f", - BM_ELEM_SELECT, use_boundary, use_even_offset, use_relative_offset, + BM_ELEM_SELECT, use_boundary, use_even_offset, use_relative_offset, use_crease, thickness); BMO_op_exec(em->bm, &bmop); @@ -4324,6 +4325,7 @@ void MESH_OT_wireframe(wmOperatorType *ot) RNA_def_boolean(ot->srna, "use_boundary", TRUE, "Boundary", "Inset face boundaries"); RNA_def_boolean(ot->srna, "use_even_offset", TRUE, "Offset Even", "Scale the offset to give more even thickness"); RNA_def_boolean(ot->srna, "use_relative_offset", FALSE, "Offset Relative", "Scale the offset by surrounding geometry"); + RNA_def_boolean(ot->srna, "use_crease", FALSE, "Crease", "Crease hub edges for improved subsurf"); prop = RNA_def_float(ot->srna, "thickness", 0.01f, 0.0f, FLT_MAX, "Thickness", "", 0.0f, 10.0f); /* use 1 rather then 10 for max else dragging the button moves too far */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 78ad364b8e8..9ff71c72e7e 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -746,7 +746,7 @@ static void wm_region_mouse_co(bContext *C, wmEvent *event) } } -#if 0 /* disabling for 2.63 release, since we keep getting reports some menu items are leaving props undefined */ +#if 1 /* disabling for 2.63 release, since we keep getting reports some menu items are leaving props undefined */ int WM_operator_last_properties_init(wmOperator *op) { int change = FALSE; From b7a59f52b8918ffd40aeaecdc93224a8a7863d2f Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 29 Apr 2012 13:00:00 +0000 Subject: [PATCH 05/10] mingw32 compiles again "__force_inline" keyword used in Cycles header is not defined --- intern/cycles/util/util_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h index cf167707e47..0451d877c45 100644 --- a/intern/cycles/util/util_types.h +++ b/intern/cycles/util/util_types.h @@ -36,7 +36,7 @@ #define __shared #define __constant -#ifdef _WIN32 +#if defined(_WIN32) && !defined(FREE_WINDOWS) #define __device_inline static __forceinline #define __align(...) __declspec(align(__VA_ARGS__)) #else From d47528b2f49d092120fbb32e3d1695aa6ecae391 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 29 Apr 2012 13:18:59 +0000 Subject: [PATCH 06/10] Pose armature cleanup: remove old commented code replaced by use of new generic pchan_to_pose_mat(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After two months, think we can get rid of it, it’s in svn anyway if we ever need it! --- source/blender/blenkernel/intern/armature.c | 65 +------------- .../editors/transform/transform_conversions.c | 87 ------------------- 2 files changed, 1 insertion(+), 151 deletions(-) diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index d1d6833e903..0827cb5cb14 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1208,9 +1208,8 @@ void pchan_to_pose_mat(bPoseChannel *pchan, float rotscale_mat[][4], float loc_m else mult_m4_m4m4(rotscale_mat, parchan->pose_mat, offs_bone); -# if 1 /* Compose the loc matrix for this bone. */ - /* NOTE: That version deos not modify bone's loc when HINGE/NO_SCALE options are set. */ + /* NOTE: That version does not modify bone's loc when HINGE/NO_SCALE options are set. */ /* In this case, use the object's space *orientation*. */ if (bone->flag & BONE_NO_LOCAL_LOCATION) { @@ -1236,58 +1235,6 @@ void pchan_to_pose_mat(bPoseChannel *pchan, float rotscale_mat[][4], float loc_m /* Else (i.e. default, usual case), just use the same matrix for rotation/scaling, and location. */ else copy_m4_m4(loc_mat, rotscale_mat); -# endif -# if 0 - /* Compose the loc matrix for this bone. */ - /* NOTE: That version modifies bone's loc when HINGE/NO_SCALE options are set. */ - - /* In these cases we need to compute location separately */ - if (bone->flag & (BONE_HINGE|BONE_NO_SCALE|BONE_NO_LOCAL_LOCATION)) { - float bone_loc[4][4], bone_rotscale[3][3], tmat4[4][4], tmat3[3][3]; - unit_m4(bone_loc); - unit_m4(loc_mat); - unit_m4(tmat4); - - mul_v3_m4v3(bone_loc[3], parchan->pose_mat, offs_bone[3]); - - /* "No local location" is not transformed by bone matrix. */ - /* This only affects orientations (rotations), as scale is always 1.0 here. */ - if (bone->flag & BONE_NO_LOCAL_LOCATION) - unit_m3(bone_rotscale); - else - /* We could also use bone->bone_mat directly, here... */ - copy_m3_m4(bone_rotscale, offs_bone); - - if (bone->flag & BONE_HINGE) { - copy_m3_m4(tmat3, parbone->arm_mat); - /* for hinge-only, we use armature *rotation*, but pose mat *scale*! */ - if (!(bone->flag & BONE_NO_SCALE)) { - float size[3], tsmat[3][3]; - mat4_to_size(size, parchan->pose_mat); - size_to_mat3(tsmat, size); - mul_m3_m3m3(tmat3, tsmat, tmat3); - } - mul_m3_m3m3(bone_rotscale, tmat3, bone_rotscale); - } - else if (bone->flag & BONE_NO_SCALE) { - /* For no-scale only, normalized parent pose mat is enough! */ - copy_m3_m4(tmat3, parchan->pose_mat); - normalize_m3(tmat3); - mul_m3_m3m3(bone_rotscale, tmat3, bone_rotscale); - } - /* NO_LOCAL_LOCATION only. */ - else { - copy_m3_m4(tmat3, parchan->pose_mat); - mul_m3_m3m3(bone_rotscale, tmat3, bone_rotscale); - } - - copy_m4_m3(tmat4, bone_rotscale); - mult_m4_m4m4(loc_mat, bone_loc, tmat4); - } - /* Else, just use the same matrix for rotation/scaling, and location. */ - else - copy_m4_m4(loc_mat, rotscale_mat); -# endif } /* Root bones. */ else { @@ -2438,16 +2385,6 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti /* Construct the posemat based on PoseChannels, that we do before applying constraints. */ /* pose_mat(b) = pose_mat(b-1) * yoffs(b-1) * d_root(b) * bone_mat(b) * chan_mat(b) */ armature_mat_bone_to_pose(pchan, pchan->chan_mat, pchan->pose_mat); -#if 0 /* XXX Old code, will remove this later. */ - { - float rotscale_mat[4][4], loc_mat[4][4]; - pchan_to_pose_mat(pchan, rotscale_mat, loc_mat); - /* Rotation and scale. */ - mult_m4_m4m4(pchan->pose_mat, rotscale_mat, pchan->chan_mat); - /* Location. */ - mul_v3_m4v3(pchan->pose_mat[3], loc_mat, pchan->chan_mat[3]); - } -#endif /* Only rootbones get the cyclic offset (unless user doesn't want that). */ /* XXX That could be a problem for snapping and other "reverse transform" features... */ diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 859ae1e1b1b..c4edeefa598 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -424,51 +424,6 @@ static short apply_targetless_ik(Object *ob) bone= parchan->bone; bone->flag |= BONE_TRANSFORM; /* ensures it gets an auto key inserted */ - /* XXX Old code. Will remove it later. */ -#if 0 - if (parchan->parent) { - Bone *parbone= parchan->parent->bone; - float offs_bone[4][4]; - - /* offs_bone = yoffs(b-1) + root(b) + bonemat(b) */ - copy_m4_m3(offs_bone, bone->bone_mat); - - /* The bone's root offset (is in the parent's coordinate system) */ - copy_v3_v3(offs_bone[3], bone->head); - - /* Get the length translation of parent (length along y axis) */ - offs_bone[3][1]+= parbone->length; - - /* pose_mat(b-1) * offs_bone */ - if (parchan->bone->flag & BONE_HINGE) { - /* the rotation of the parent restposition */ - copy_m4_m4(rmat, parbone->arm_mat); /* rmat used as temp */ - - /* the location of actual parent transform */ - copy_v3_v3(rmat[3], offs_bone[3]); - offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f; - mul_m4_v3(parchan->parent->pose_mat, rmat[3]); - - mult_m4_m4m4(tmat, rmat, offs_bone); - } - else if (parchan->bone->flag & BONE_NO_SCALE) { - mult_m4_m4m4(tmat, parchan->parent->pose_mat, offs_bone); - normalize_m4(tmat); - } - else - mult_m4_m4m4(tmat, parchan->parent->pose_mat, offs_bone); - - invert_m4_m4(imat, tmat); - } - else { - copy_m4_m3(tmat, bone->bone_mat); - - copy_v3_v3(tmat[3], bone->head); - invert_m4_m4(imat, tmat); - } - /* result matrix */ - mult_m4_m4m4(rmat, imat, parchan->pose_mat); -#endif armature_mat_pose_to_bone(parchan, parchan->pose_mat, rmat); /* apply and decompose, doesn't work for constraints or non-uniform scale well */ @@ -599,48 +554,6 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr mul_serie_m3(td->mtx, pmat, omat, NULL, NULL,NULL,NULL,NULL,NULL); } - /* XXX Old code. Will remove it later. */ -#if 0 - if (ELEM(t->mode, TFM_TRANSLATION, TFM_RESIZE) && (pchan->bone->flag & BONE_NO_LOCAL_LOCATION)) - unit_m3(bmat); - else - copy_m3_m3(bmat, pchan->bone->bone_mat); - - if (pchan->parent) { - if (pchan->bone->flag & BONE_HINGE) { - copy_m3_m4(pmat, pchan->parent->bone->arm_mat); - if (!(pchan->bone->flag & BONE_NO_SCALE)) { - float tsize[3], tsmat[3][3]; - mat4_to_size(tsize, pchan->parent->pose_mat); - size_to_mat3(tsmat, tsize); - mul_m3_m3m3(pmat, tsmat, pmat); - } - } - else { - copy_m3_m4(pmat, pchan->parent->pose_mat); - if (pchan->bone->flag & BONE_NO_SCALE) - normalize_m3(pmat); - } - - if (constraints_list_needinv(t, &pchan->constraints)) { - copy_m3_m4(tmat, pchan->constinv); - invert_m3_m3(cmat, tmat); - mul_serie_m3(td->mtx, bmat, pmat, omat, cmat, NULL,NULL,NULL,NULL); - } - else - mul_serie_m3(td->mtx, bmat, pmat, omat, NULL,NULL,NULL,NULL,NULL); - } - else { - if (constraints_list_needinv(t, &pchan->constraints)) { - copy_m3_m4(tmat, pchan->constinv); - invert_m3_m3(cmat, tmat); - mul_serie_m3(td->mtx, bmat, omat, cmat, NULL,NULL,NULL,NULL,NULL); - } - else - mul_m3_m3m3(td->mtx, omat, bmat); - } -# endif - invert_m3_m3(td->smtx, td->mtx); /* exceptional case: rotate the pose bone which also applies transformation From 40489e378d33517997cd8b5502102c42c9c6d905 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 29 Apr 2012 13:19:22 +0000 Subject: [PATCH 07/10] quiet unused warnings --- source/blender/editors/space_clip/clip_buttons.c | 4 ++-- source/blender/editors/space_clip/space_clip.c | 2 +- source/blender/editors/transform/transform.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index 6bf7c4e3dc8..ba77cd726d3 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -63,9 +63,9 @@ /* Panels */ -static int clip_grease_pencil_panel_poll(const bContext *C, PanelType *UNUSED(pt)) +static int clip_grease_pencil_panel_poll(const bContext *UNUSED(C), PanelType *UNUSED(pt)) { - SpaceClip *sc = CTX_wm_space_clip(C); + /* SpaceClip *sc = CTX_wm_space_clip(C); */ /* UNUSED */ return TRUE; } diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 58582df7a3f..d3d4cbebc97 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -977,7 +977,7 @@ static void graph_area_draw(const bContext *C, ARegion *ar) static void clip_preview_area_draw(const bContext *C, ARegion *ar) { - SpaceClip *sc = CTX_wm_space_clip(C); + /* SpaceClip *sc = CTX_wm_space_clip(C); */ /* UNUSED */ graph_area_draw(C, ar); } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 82bb30d660f..f972375a413 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1591,7 +1591,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t); } else if (t->spacetype == SPACE_CLIP) { - SpaceClip *sc = CTX_wm_space_clip(C); + /* SpaceClip *sc = CTX_wm_space_clip(C); */ /* UNUSED */ unit_m3(t->spacemtx); t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW); t->options |= CTX_MOVIECLIP; From d3d93ee4a2bd1a111afc010a73d6f5b7c04b4d04 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 29 Apr 2012 13:20:28 +0000 Subject: [PATCH 08/10] Code cleanups - whitespace --- .../blender/editors/space_graph/space_graph.c | 90 +++++++++---------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 6214201a87d..447003804ce 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -551,21 +551,21 @@ static void graph_refresh(const bContext *C, ScrArea *sa) * TODO: find a way to module the hue so that not all curves have same color... */ float *col= fcu->color; - + switch (fcu->array_index) { - case 0: - col[0]= 1.0f; col[1]= 0.0f; col[2]= 0.0f; - break; - case 1: - col[0]= 0.0f; col[1]= 1.0f; col[2]= 0.0f; - break; - case 2: - col[0]= 0.0f; col[1]= 0.0f; col[2]= 1.0f; - break; - default: - /* 'unknown' color - bluish so as to not conflict with handles */ - col[0]= 0.3f; col[1]= 0.8f; col[2]= 1.0f; - break; + case 0: + col[0] = 1.0f; col[1] = 0.0f; col[2] = 0.0f; + break; + case 1: + col[0] = 0.0f; col[1] = 1.0f; col[2] = 0.0f; + break; + case 2: + col[0] = 0.0f; col[1] = 0.0f; col[2] = 1.0f; + break; + default: + /* 'unknown' color - bluish so as to not conflict with handles */ + col[0] = 0.3f; col[1] = 0.8f; col[2] = 1.0f; + break; } } break; @@ -596,55 +596,55 @@ void ED_spacetype_ipo(void) st->spaceid= SPACE_IPO; strncpy(st->name, "Graph", BKE_ST_MAXNAME); - st->new= graph_new; - st->free= graph_free; - st->init= graph_init; - st->duplicate= graph_duplicate; - st->operatortypes= graphedit_operatortypes; - st->keymap= graphedit_keymap; - st->listener= graph_listener; - st->refresh= graph_refresh; + st->new = graph_new; + st->free = graph_free; + st->init = graph_init; + st->duplicate = graph_duplicate; + st->operatortypes = graphedit_operatortypes; + st->keymap = graphedit_keymap; + st->listener = graph_listener; + st->refresh = graph_refresh; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"); art->regionid = RGN_TYPE_WINDOW; - art->init= graph_main_area_init; - art->draw= graph_main_area_draw; - art->listener= graph_region_listener; - art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES; + art->init = graph_main_area_init; + art->draw = graph_main_area_draw; + art->listener = graph_region_listener; + art->keymapflag = ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES; BLI_addhead(&st->regiontypes, art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; - art->listener= graph_region_listener; - art->init= graph_header_area_init; - art->draw= graph_header_area_draw; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; + art->listener = graph_region_listener; + art->init = graph_header_area_init; + art->draw = graph_header_area_draw; BLI_addhead(&st->regiontypes, art); /* regions: channels */ - art= MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"); art->regionid = RGN_TYPE_CHANNELS; - art->prefsizex= 200+V2D_SCROLL_WIDTH; /* 200 is the 'standard', but due to scrollers, we want a bit more to fit the lock icons in */ - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES; - art->listener= graph_region_listener; - art->init= graph_channel_area_init; - art->draw= graph_channel_area_draw; + art->prefsizex = 200 + V2D_SCROLL_WIDTH; /* 200 is the 'standard', but due to scrollers, we want a bit more to fit the lock icons in */ + art->keymapflag = ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES; + art->listener = graph_region_listener; + art->init = graph_channel_area_init; + art->draw = graph_channel_area_draw; BLI_addhead(&st->regiontypes, art); /* regions: UI buttons */ - art= MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"); art->regionid = RGN_TYPE_UI; - art->prefsizex= 200; - art->keymapflag= ED_KEYMAP_UI; - art->listener= graph_region_listener; - art->init= graph_buttons_area_init; - art->draw= graph_buttons_area_draw; + art->prefsizex = 200; + art->keymapflag = ED_KEYMAP_UI; + art->listener = graph_region_listener; + art->init = graph_buttons_area_init; + art->draw = graph_buttons_area_draw; BLI_addhead(&st->regiontypes, art); From 38c2d34d47c1fe8784b024258c543b487dc98229 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 29 Apr 2012 13:24:10 +0000 Subject: [PATCH 09/10] Bugfix [#31029] Select all in view3D don't update the graph editor immediately One-liner fix. The code was assuming that editor.refresh() would do a editor.redraw() too (like for Dopesheet), but that wasn't the case. --- source/blender/editors/space_graph/space_graph.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 447003804ce..1b60a0a39ac 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -516,6 +516,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa) if (sipo->flag & SIPO_TEMP_NEEDCHANSYNC) { ANIM_sync_animchannels_to_data(C); sipo->flag &= ~SIPO_TEMP_NEEDCHANSYNC; + ED_area_tag_redraw(sa); } /* init/adjust F-Curve colors */ From d30ee954f8ba46893b9f2ba9ba314cdb1ef34c80 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 29 Apr 2012 13:45:31 +0000 Subject: [PATCH 10/10] Remove variables tagged as unused. Easier to synchronize with current patches and makes patches easier to read when variables are creating or e-using, but not un-commenting. --- source/blender/editors/space_clip/clip_buttons.c | 2 -- source/blender/editors/space_clip/space_clip.c | 2 -- source/blender/editors/transform/transform.c | 1 - 3 files changed, 5 deletions(-) diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index ba77cd726d3..82178e47ae5 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -65,8 +65,6 @@ static int clip_grease_pencil_panel_poll(const bContext *UNUSED(C), PanelType *UNUSED(pt)) { - /* SpaceClip *sc = CTX_wm_space_clip(C); */ /* UNUSED */ - return TRUE; } diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index d3d4cbebc97..4044568b70d 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -977,8 +977,6 @@ static void graph_area_draw(const bContext *C, ARegion *ar) static void clip_preview_area_draw(const bContext *C, ARegion *ar) { - /* SpaceClip *sc = CTX_wm_space_clip(C); */ /* UNUSED */ - graph_area_draw(C, ar); } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index f972375a413..fd21bd1922f 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1591,7 +1591,6 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t); } else if (t->spacetype == SPACE_CLIP) { - /* SpaceClip *sc = CTX_wm_space_clip(C); */ /* UNUSED */ unit_m3(t->spacemtx); t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW); t->options |= CTX_MOVIECLIP;