diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-12-11 03:34:41 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-12-11 03:34:41 +0400 |
commit | c9dc80111b63fc1b28cae27d6f7ed02ee3bd53db (patch) | |
tree | 4e5a52579c7e0451f04b8f18bb25ef989a798939 /source | |
parent | 5083e0737f6413c63ab49b82735333534181d9b4 (diff) | |
parent | 245345fba5f44b5c8562c826ca0053fa5bbd2ff3 (diff) |
Merged changes in the trunk up to revision 52858.
Congratulations to all trunk devs on the Blender 2.65 release!
Diffstat (limited to 'source')
24 files changed, 245 insertions, 196 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 3c210877de7..b624d0f9c3a 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -41,8 +41,8 @@ extern "C" { /* these lines are grep'd, watch out for our not-so-awesome regex * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ -#define BLENDER_VERSION 264 -#define BLENDER_SUBVERSION 9 +#define BLENDER_VERSION 265 +#define BLENDER_SUBVERSION 0 /* 262 was the last editmesh release but it has compatibility code for bmesh data */ #define BLENDER_MINVERSION 262 @@ -50,9 +50,9 @@ extern "C" { /* used by packaging tools */ /* can be left blank, otherwise a,b,c... etc with no quotes */ -#define BLENDER_VERSION_CHAR a +#define BLENDER_VERSION_CHAR /* alpha/beta/rc/release, docs use this */ -#define BLENDER_VERSION_CYCLE alpha +#define BLENDER_VERSION_CYCLE release extern char versionstr[]; /* from blender.c */ diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index f5c0660371b..9a2462e9724 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1257,6 +1257,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p float (*obmat)[4], (*oldobmat)[4]; int a, b, hair = 0; int totpart, totchild, totgroup = 0 /*, pa_num */; + int dupli_type_hack = !BKE_scene_use_new_shading_nodes(scene); int no_draw_flag = PARS_UNEXIST; @@ -1474,6 +1475,13 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p } } else { + int dupli_type = OB_DUPLIPARTS; + + /* blender internal needs this to be set to dupligroup to render + * groups correctly, but we don't want this hack for cycles */ + if(dupli_type_hack && GS(id->name) == ID_GR) + dupli_type = OB_DUPLIGROUP; + /* to give ipos in object correct offset */ BKE_object_where_is_calc_time(scene, ob, ctime - pa_time); @@ -1527,7 +1535,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p if (part->draw & PART_DRAW_GLOBAL_OB) add_v3_v3v3(mat[3], mat[3], vec); - dob = new_dupli_object(lb, ob, mat, ob->lay, persistent_id, level, a, GS(id->name) == ID_GR ? OB_DUPLIGROUP : OB_DUPLIPARTS, (flag & DUPLILIST_ANIMATED)); + dob = new_dupli_object(lb, ob, mat, ob->lay, persistent_id, level, a, dupli_type, (flag & DUPLILIST_ANIMATED)); dob->particle_system = psys; copy_m4_m4(dob->omat, oldobmat); if (flag & DUPLILIST_FOR_RENDER) diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index cd726179f56..74abd7e8c7e 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -1453,9 +1453,16 @@ float line_point_factor_v3(const float p[3], const float l1[3], const float l2[3 float line_point_factor_v2(const float p[2], const float l1[2], const float l2[2]) { float h[2], u[2]; + float dot; sub_v2_v2v2(u, l2, l1); sub_v2_v2v2(h, p, l1); +#if 0 return (dot_v2v2(u, h) / dot_v2v2(u, u)); +#else + /* better check for zero */ + dot = dot_v2v2(u, u); + return (dot != 0.0f) ? (dot_v2v2(u, h) / dot) : 0.0f; +#endif } /* ensure the distance between these points is no greater then 'dist' diff --git a/source/blender/blenlib/intern/string_cursor_utf8.c b/source/blender/blenlib/intern/string_cursor_utf8.c index bab144266a4..65763f21b0f 100644 --- a/source/blender/blenlib/intern/string_cursor_utf8.c +++ b/source/blender/blenlib/intern/string_cursor_utf8.c @@ -38,7 +38,7 @@ typedef enum strCursorDelimType { STRCUR_DELIM_NONE, - STRCUR_DELIM_ALPHA, + STRCUR_DELIM_ALPHANUMERIC, STRCUR_DELIM_PUNCT, STRCUR_DELIM_BRACE, STRCUR_DELIM_OPERATOR, @@ -47,21 +47,12 @@ typedef enum strCursorDelimType { STRCUR_DELIM_OTHER } strCursorDelimType; -/* return 1 if char ch is special character, otherwise return 0 */ -static strCursorDelimType test_special_char(const char *ch_utf8) +static strCursorDelimType cursor_delim_type(const char *ch_utf8) { /* for full unicode support we really need to have large lookup tables to figure * out whats what in every possible char set - and python, glib both have these. */ unsigned int uch = BLI_str_utf8_as_unicode(ch_utf8); - if ((uch >= 'a' && uch <= 'z') || - (uch >= 'A' && uch <= 'Z') || - (uch == '_') /* not quite correct but allow for python, could become configurable */ - ) - { - return STRCUR_DELIM_ALPHA; - } - switch (uch) { case ',': case '.': @@ -86,10 +77,11 @@ static strCursorDelimType test_special_char(const char *ch_utf8) case '^': case '*': case '&': + case '|': return STRCUR_DELIM_OPERATOR; case '\'': - case '\"': // " - an extra closing one for Aligorith's text editor + case '\"': return STRCUR_DELIM_QUOTE; case ' ': @@ -97,20 +89,22 @@ static strCursorDelimType test_special_char(const char *ch_utf8) return STRCUR_DELIM_WHITESPACE; case '\\': - case '!': case '@': case '#': case '$': case ':': case ';': case '?': + case '!': + case 0xA3: /* pound */ + case 0x80: /* euro */ /* case '_': *//* special case, for python */ return STRCUR_DELIM_OTHER; default: break; } - return STRCUR_DELIM_NONE; + return STRCUR_DELIM_ALPHANUMERIC; /* Not quite true, but ok for now */ } int BLI_str_cursor_step_next_utf8(const char *str, size_t maxlen, int *pos) @@ -153,14 +147,14 @@ void BLI_str_cursor_step_utf8(const char *str, size_t maxlen, BLI_str_cursor_step_next_utf8(str, maxlen, pos); if (jump != STRCUR_JUMP_NONE) { - const strCursorDelimType is_special = (*pos) < maxlen ? test_special_char(&str[*pos]) : STRCUR_DELIM_NONE; + const strCursorDelimType delim_type = (*pos) < maxlen ? cursor_delim_type(&str[*pos]) : STRCUR_DELIM_NONE; /* jump between special characters (/,\,_,-, etc.), - * look at function test_special_char() for complete + * look at function cursor_delim_type() for complete * list of special character, ctr -> */ while ((*pos) < maxlen) { if (BLI_str_cursor_step_next_utf8(str, maxlen, pos)) { - if ((jump != STRCUR_JUMP_ALL) && (is_special != test_special_char(&str[*pos]))) - break; + if ((jump != STRCUR_JUMP_ALL) && (delim_type != cursor_delim_type(&str[*pos]))) + break; } else { break; /* unlikely but just in case */ @@ -172,13 +166,13 @@ void BLI_str_cursor_step_utf8(const char *str, size_t maxlen, BLI_str_cursor_step_prev_utf8(str, maxlen, pos); if (jump != STRCUR_JUMP_NONE) { - const strCursorDelimType is_special = (*pos) > 1 ? test_special_char(&str[(*pos) - 1]) : STRCUR_DELIM_NONE; + const strCursorDelimType delim_type = (*pos) > 1 ? cursor_delim_type(&str[(*pos) - 1]) : STRCUR_DELIM_NONE; /* jump between special characters (/,\,_,-, etc.), - * look at function test_special_char() for complete + * look at function cursor_delim_type() for complete * list of special character, ctr -> */ while ((*pos) > 0) { if (BLI_str_cursor_step_prev_utf8(str, maxlen, pos)) { - if ((jump != STRCUR_JUMP_ALL) && (is_special != test_special_char(&str[*pos]))) + if ((jump != STRCUR_JUMP_ALL) && (delim_type != cursor_delim_type(&str[*pos]))) break; } else { diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index bad884b9025..79a246e20f0 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8560,7 +8560,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } - { + if (main->versionfile < 265) { Object *ob; for (ob = main->object.first; ob; ob = ob->id.next) { if (ob->step_height == 0.0f) { diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index baec0b7745d..5e51f5a5ada 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -1225,7 +1225,7 @@ static void bmo_flag_layer_free(BMesh *bm) /* de-increment the totflags first.. */ bm->totflags--; /* allocate new flag poo */ - bm->toolflagpool = newpool = BLI_mempool_create(new_totflags_size, 512, 512, BLI_MEMPOOL_SYSMALLOC); + bm->toolflagpool = newpool = BLI_mempool_create(new_totflags_size, 512, 512, 0); /* now go through and memcpy all the flag */ BM_ITER_MESH_INDEX (ele, &iter, bm, BM_VERTS_OF_MESH, i) { diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 62ffdc7fd3a..1b980790fdc 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -1409,6 +1409,11 @@ static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static int ed_marker_make_links_scene_invoke_wrapper(bContext *C, wmOperator *op, wmEvent *evt) +{ + return ed_markers_opwrap_invoke_custom(C, op, evt, WM_menu_invoke); +} + static void MARKER_OT_make_links_scene(wmOperatorType *ot) { PropertyRNA *prop; @@ -1420,7 +1425,7 @@ static void MARKER_OT_make_links_scene(wmOperatorType *ot) /* api callbacks */ ot->exec = ed_marker_make_links_scene_exec; - ot->invoke = ed_markers_opwrap_invoke; + ot->invoke = ed_marker_make_links_scene_invoke_wrapper; ot->poll = ed_markers_poll_selected_markers; /* flags */ diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index d5c9b9ef01a..f15f2418707 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -193,7 +193,8 @@ void ED_view3d_global_to_vector(struct RegionView3D *rv3d, const float coord[3], void ED_view3d_win_to_3d(struct ARegion *ar, const float depth_pt[3], const float mval[2], float out[3]); void ED_view3d_win_to_delta(struct ARegion *ar, const float mval[2], float out[3]); void ED_view3d_win_to_vector(struct ARegion *ar, const float mval[2], float out[3]); -void ED_view3d_win_to_segment_clip(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]); +void ED_view3d_win_to_segment(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]); +int ED_view3d_win_to_segment_clip(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]); void ED_view3d_ob_project_mat_get(struct RegionView3D *v3d, struct Object *ob, float pmat[4][4]); void ED_view3d_unproject(struct bglMats *mats, float out[3], const float x, const float y, const float z); @@ -295,6 +296,8 @@ void ED_view3D_background_image_clear(struct View3D *v3d); #define VIEW3D_MARGIN 1.4f float ED_view3d_offset_distance(float mat[4][4], float ofs[3]); + +float ED_scene_grid_scale(struct Scene *scene, const char **grid_unit); float ED_view3d_grid_scale(struct Scene *scene, struct View3D *v3d, const char **grid_unit); /* view matrix properties utilities */ diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 527f383c837..c4b80f0a42f 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -651,8 +651,8 @@ static void widget_verts_to_quad_strip_open(uiWidgetBase *wtb, const int totvert for (a = 0; a < totvert; a++) { quad_strip[a * 2][0] = wtb->outer_v[a][0]; quad_strip[a * 2][1] = wtb->outer_v[a][1]; - quad_strip[a * 2 + 1][0] = wtb->outer_v[a][0]; - quad_strip[a * 2 + 1][1] = wtb->outer_v[a][1] - 1.0f; + quad_strip[a * 2 + 1][0] = wtb->inner_v[a][0]; + quad_strip[a * 2 + 1][1] = wtb->inner_v[a][1]; } } diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index eed72935b3c..4a425c83d86 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -204,7 +204,7 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op) if (!EDBM_op_call_and_selectf(em, op, "verts.out", "create_circle segments=%i diameter=%f cap_ends=%b cap_tris=%b matrix=%m4", - RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius") * dia, + RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius"), cap_end, cap_tri, mat)) { return OPERATOR_CANCELLED; @@ -225,6 +225,7 @@ void MESH_OT_primitive_circle_add(wmOperatorType *ot) ot->idname = "MESH_OT_primitive_circle_add"; /* api callbacks */ + ot->invoke = WM_operator_view3d_distance_invoke; ot->exec = add_primitive_circle_exec; ot->poll = ED_operator_scene_editable; @@ -260,10 +261,10 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op) em, op, "verts.out", "create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b cap_tris=%b depth=%f matrix=%m4", RNA_int_get(op->ptr, "vertices"), - RNA_float_get(op->ptr, "radius") * dia, - RNA_float_get(op->ptr, "radius") * dia, + RNA_float_get(op->ptr, "radius"), + RNA_float_get(op->ptr, "radius"), cap_end, cap_tri, - RNA_float_get(op->ptr, "depth") * dia, mat)) + RNA_float_get(op->ptr, "depth"), mat)) { return OPERATOR_CANCELLED; } @@ -283,6 +284,7 @@ void MESH_OT_primitive_cylinder_add(wmOperatorType *ot) ot->idname = "MESH_OT_primitive_cylinder_add"; /* api callbacks */ + ot->invoke = WM_operator_view3d_distance_invoke; ot->exec = add_primitive_cylinder_exec; ot->poll = ED_operator_scene_editable; @@ -319,8 +321,8 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op) if (!EDBM_op_call_and_selectf( em, op, "verts.out", "create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b cap_tris=%b depth=%f matrix=%m4", - RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius1") * dia, - RNA_float_get(op->ptr, "radius2") * dia, cap_end, cap_tri, RNA_float_get(op->ptr, "depth") * dia, mat)) + RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius1"), + RNA_float_get(op->ptr, "radius2"), cap_end, cap_tri, RNA_float_get(op->ptr, "depth"), mat)) { return OPERATOR_CANCELLED; } @@ -340,6 +342,7 @@ void MESH_OT_primitive_cone_add(wmOperatorType *ot) ot->idname = "MESH_OT_primitive_cone_add"; /* api callbacks */ + ot->invoke = WM_operator_view3d_distance_invoke; ot->exec = add_primitive_cone_exec; ot->poll = ED_operator_scene_editable; @@ -376,7 +379,7 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op) "create_grid x_segments=%i y_segments=%i size=%f matrix=%m4", RNA_int_get(op->ptr, "x_subdivisions"), RNA_int_get(op->ptr, "y_subdivisions"), - RNA_float_get(op->ptr, "size") * dia, mat)) + RNA_float_get(op->ptr, "size"), mat)) { return OPERATOR_CANCELLED; } @@ -396,6 +399,7 @@ void MESH_OT_primitive_grid_add(wmOperatorType *ot) ot->idname = "MESH_OT_primitive_grid_add"; /* api callbacks */ + ot->invoke = WM_operator_view3d_distance_invoke; ot->exec = add_primitive_grid_exec; ot->poll = ED_operator_scene_editable; @@ -473,7 +477,7 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op) if (!EDBM_op_call_and_selectf(em, op, "verts.out", "create_uvsphere u_segments=%i v_segments=%i diameter=%f matrix=%m4", RNA_int_get(op->ptr, "segments"), RNA_int_get(op->ptr, "ring_count"), - RNA_float_get(op->ptr, "size") * dia, mat)) + RNA_float_get(op->ptr, "size"), mat)) { return OPERATOR_CANCELLED; } @@ -493,6 +497,7 @@ void MESH_OT_primitive_uv_sphere_add(wmOperatorType *ot) ot->idname = "MESH_OT_primitive_uv_sphere_add"; /* api callbacks */ + ot->invoke = WM_operator_view3d_distance_invoke; ot->exec = add_primitive_uvsphere_exec; ot->poll = ED_operator_scene_editable; @@ -525,7 +530,7 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op) em, op, "verts.out", "create_icosphere subdivisions=%i diameter=%f matrix=%m4", RNA_int_get(op->ptr, "subdivisions"), - RNA_float_get(op->ptr, "size") * dia, mat)) + RNA_float_get(op->ptr, "size"), mat)) { return OPERATOR_CANCELLED; } @@ -545,6 +550,7 @@ void MESH_OT_primitive_ico_sphere_add(wmOperatorType *ot) ot->idname = "MESH_OT_primitive_ico_sphere_add"; /* api callbacks */ + ot->invoke = WM_operator_view3d_distance_invoke; ot->exec = add_primitive_icosphere_exec; ot->poll = ED_operator_scene_editable; diff --git a/source/blender/editors/mesh/editmesh_bvh.c b/source/blender/editors/mesh/editmesh_bvh.c index 4324e50f914..8e397797dd9 100644 --- a/source/blender/editors/mesh/editmesh_bvh.c +++ b/source/blender/editors/mesh/editmesh_bvh.c @@ -399,7 +399,7 @@ int BMBVH_EdgeVisible(BMBVHTree *tree, BMEdge *e, ARegion *ar, View3D *v3d, Obje const float mval_f[2] = {ar->winx / 2.0f, ar->winy / 2.0f}; - ED_view3d_win_to_segment_clip(ar, v3d, mval_f, origin, end); + ED_view3d_win_to_segment(ar, v3d, mval_f, origin, end); invert_m4_m4(invmat, obedit->obmat); mul_m4_v3(invmat, origin); diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index d5cf174b1a1..a59c491fe13 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1181,7 +1181,6 @@ static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree, result = results = BLI_bvhtree_overlap(tree, tree2, &tot); for (i = 0; i < tot; i++, result++) { - float p[3]; BMLoop *l1; BMFace *hitf; ListBase *lst; @@ -1200,7 +1199,7 @@ static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree, } if (isect_line_tri_v3(kfe->v1->cageco, kfe->v2->cageco, v1, v2, v3, &lambda, NULL)) { - float no[3], view[3], sp[3]; + float p[3], no[3], view[3], sp[3]; interp_v3_v3v3(p, kfe->v1->cageco, kfe->v2->cageco, lambda); @@ -1215,6 +1214,11 @@ static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree, { continue; } + if ((kcd->vc.rv3d->rflag & RV3D_CLIPPING) && + ED_view3d_clipping_test(kcd->vc.rv3d, p, TRUE)) + { + continue; + } knife_project_v3(kcd, p, sp); ED_view3d_unproject(mats, view, sp[0], sp[1], 0.0f); @@ -1523,12 +1527,7 @@ static int knife_sample_screen_density(KnifeTool_OpData *kcd, float radius) dis = len_v2v2(kfv->sco, sco); if (dis < radius) { if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) { - float vec[3]; - - copy_v3_v3(vec, kfv->cageco); - mul_m4_v3(kcd->vc.obedit->obmat, vec); - - if (ED_view3d_clipping_test(kcd->vc.rv3d, vec, TRUE) == 0) { + if (ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, TRUE) == 0) { c++; } } @@ -1595,13 +1594,10 @@ static KnifeEdge *knife_find_closest_edge(KnifeTool_OpData *kcd, float p[3], flo dis = dist_to_line_segment_v2(sco, kfe->v1->sco, kfe->v2->sco); if (dis < curdis && dis < maxdist) { if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) { - float labda = labda_PdistVL2Dfl(sco, kfe->v1->sco, kfe->v2->sco); + float labda = line_point_factor_v2(sco, kfe->v1->sco, kfe->v2->sco); float vec[3]; - vec[0] = kfe->v1->cageco[0] + labda * (kfe->v2->cageco[0] - kfe->v1->cageco[0]); - vec[1] = kfe->v1->cageco[1] + labda * (kfe->v2->cageco[1] - kfe->v1->cageco[1]); - vec[2] = kfe->v1->cageco[2] + labda * (kfe->v2->cageco[2] - kfe->v1->cageco[2]); - mul_m4_v3(kcd->vc.obedit->obmat, vec); + interp_v3_v3v3(vec, kfe->v1->cageco, kfe->v2->cageco, labda); if (ED_view3d_clipping_test(kcd->vc.rv3d, vec, TRUE) == 0) { cure = kfe; @@ -1693,12 +1689,7 @@ static KnifeVert *knife_find_closest_vert(KnifeTool_OpData *kcd, float p[3], flo dis = len_v2v2(kfv->sco, sco); if (dis < curdis && dis < maxdist) { if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) { - float vec[3]; - - copy_v3_v3(vec, kfv->cageco); - mul_m4_v3(kcd->vc.obedit->obmat, vec); - - if (ED_view3d_clipping_test(kcd->vc.rv3d, vec, TRUE) == 0) { + if (ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, TRUE) == 0) { curv = kfv; curdis = dis; } @@ -3114,6 +3105,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, wmEvent *event) { Object *obedit = CTX_data_edit_object(C); KnifeTool_OpData *kcd = op->customdata; + int do_refresh = FALSE; if (!obedit || obedit->type != OB_MESH || BMEdit_FromObject(obedit) != kcd->em) { knifetool_exit(C, op); @@ -3122,6 +3114,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, wmEvent *event) } view3d_operator_needs_opengl(C); + ED_view3d_init_mats_rv3d(obedit, kcd->vc.rv3d); /* needed to initialize clipping */ if (kcd->mode == MODE_PANNING) kcd->mode = kcd->prevmode; @@ -3153,6 +3146,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, wmEvent *event) knife_update_active(kcd); knife_update_header(C, kcd); ED_region_tag_redraw(kcd->ar); + do_refresh = TRUE; break; case KNF_MODAL_MIDPOINT_OFF: kcd->snap_midpoints = 0; @@ -3161,25 +3155,29 @@ static int knifetool_modal(bContext *C, wmOperator *op, wmEvent *event) knife_update_active(kcd); knife_update_header(C, kcd); ED_region_tag_redraw(kcd->ar); + do_refresh = TRUE; break; case KNF_MODEL_IGNORE_SNAP_ON: ED_region_tag_redraw(kcd->ar); kcd->ignore_vert_snapping = kcd->ignore_edge_snapping = 1; knife_update_header(C, kcd); + do_refresh = TRUE; break; case KNF_MODEL_IGNORE_SNAP_OFF: ED_region_tag_redraw(kcd->ar); kcd->ignore_vert_snapping = kcd->ignore_edge_snapping = 0; knife_update_header(C, kcd); + do_refresh = TRUE; break; case KNF_MODAL_ANGLE_SNAP_TOGGLE: kcd->angle_snapping = !kcd->angle_snapping; knife_update_header(C, kcd); + do_refresh = TRUE; break; case KNF_MODAL_CUT_THROUGH_TOGGLE: kcd->cut_through = !kcd->cut_through; - knifetool_update_mval(kcd, event->mval); /* refresh knife path */ knife_update_header(C, kcd); + do_refresh = TRUE; break; case KNF_MODAL_NEW_CUT: ED_region_tag_redraw(kcd->ar); @@ -3232,6 +3230,12 @@ static int knifetool_modal(bContext *C, wmOperator *op, wmEvent *event) } } + if (do_refresh) { + /* we don't really need to update mval, + * but this happens to be the best way to refresh at the moment */ + knifetool_update_mval(kcd, event->mval); + } + /* keep going until the user confirms */ return OPERATOR_RUNNING_MODAL; } diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index cb1b4ebba72..68dfbf66ec3 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -450,20 +450,6 @@ BMVert *EDBM_vert_find_nearest(ViewContext *vc, float *r_dist, const short sel, } } -/* returns labda for closest distance v1 to line-piece v2 - v3 */ -float labda_PdistVL2Dfl(const float v1[2], const float v2[2], const float v3[2]) -{ - float rc[2], len; - - rc[0] = v3[0] - v2[0]; - rc[1] = v3[1] - v2[1]; - len = rc[0] * rc[0] + rc[1] * rc[1]; - if (len == 0.0f) - return 0.0f; - - return (rc[0] * (v1[0] - v2[0]) + rc[1] * (v1[1] - v2[1])) / len; -} - /* note; uses v3d, so needs active 3d window */ static void findnearestedge__doClosest(void *userData, BMEdge *eed, const float screen_co_a[2], const float screen_co_b[2], int UNUSED(index)) { @@ -478,7 +464,7 @@ static void findnearestedge__doClosest(void *userData, BMEdge *eed, const float if (distance < data->dist) { if (data->vc.rv3d->rflag & RV3D_CLIPPING) { - float labda = labda_PdistVL2Dfl(data->mval_fl, screen_co_a, screen_co_b); + float labda = line_point_factor_v2(data->mval_fl, screen_co_a, screen_co_b); float vec[3]; vec[0] = eed->v1->co[0] + labda * (eed->v2->co[0] - eed->v1->co[0]); diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index 58f05df83f1..043679b9d8a 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -80,9 +80,6 @@ int EDBM_op_finish(struct BMEditMesh *em, struct BMOperator *bmop, void EDBM_flag_disable_all(struct BMEditMesh *em, const char hflag); void EDBM_stats_update(struct BMEditMesh *em); -/* TODO, move to math_geometry.c */ -float labda_PdistVL2Dfl(const float v1[3], const float v2[3], const float v3[3]); - /* ******************** editface.c */ void MESH_OT_separate(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index ad1e2816c10..7c4a547debc 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -210,8 +210,8 @@ float ED_object_new_primitive_matrix(bContext *C, Object *obedit, invert_m3_m3(imat, mat); mul_m3_v3(imat, primmat[3]); - if (v3d) { - float dia = ED_view3d_grid_scale(scene, v3d, NULL); + { + const float dia = v3d ? ED_view3d_grid_scale(scene, v3d, NULL) : ED_scene_grid_scale(scene, NULL); if (apply_diameter) { primmat[0][0] *= dia; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 25ea08a4bb1..e2ed7776b7e 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3764,6 +3764,7 @@ int sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2]) mval[0] = mouse[0] - vc.ar->winrct.xmin; mval[1] = mouse[1] - vc.ar->winrct.ymin; + /* TODO: what if the segment is totally clipped? (return == 0) */ ED_view3d_win_to_segment_clip(vc.ar, vc.v3d, mval, ray_start, ray_end); invert_m4_m4(obimat, ob->obmat); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 6c23635da90..51261f4c341 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -451,10 +451,9 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** } #undef GRID_MIN_PX -float ED_view3d_grid_scale(Scene *scene, View3D *v3d, const char **grid_unit) +/** could move this elsewhere, but tied into #ED_view3d_grid_scale */ +float ED_scene_grid_scale(Scene *scene, const char **grid_unit) { - float grid_scale = v3d->grid; - /* apply units */ if (scene->unit.system) { void *usys; @@ -466,11 +465,16 @@ float ED_view3d_grid_scale(Scene *scene, View3D *v3d, const char **grid_unit) int i = bUnit_GetBaseUnit(usys); if (grid_unit) *grid_unit = bUnit_GetNameDisplay(usys, i); - grid_scale = (grid_scale * (float)bUnit_GetScaler(usys, i)) / scene->unit.scale_length; + return (float)bUnit_GetScaler(usys, i) / scene->unit.scale_length; } } - return grid_scale; + return 1.0f; +} + +float ED_view3d_grid_scale(Scene *scene, View3D *v3d, const char **grid_unit) +{ + return v3d->grid * ED_scene_grid_scale(scene, grid_unit); } static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c index 6ba05abae9a..34b983f83df 100644 --- a/source/blender/editors/space_view3d/view3d_project.c +++ b/source/blender/editors/space_view3d/view3d_project.c @@ -296,7 +296,7 @@ void ED_view3d_win_to_ray(ARegion *ar, View3D *v3d, const float mval[2], float r { float ray_end[3]; - ED_view3d_win_to_segment_clip(ar, v3d, mval, ray_start, ray_end); + ED_view3d_win_to_segment(ar, v3d, mval, ray_start, ray_end); sub_v3_v3v3(ray_normal, ray_end, ray_start); normalize_v3(ray_normal); } @@ -419,19 +419,7 @@ void ED_view3d_win_to_vector(ARegion *ar, const float mval[2], float out[3]) normalize_v3(out); } -/** - * Calculate a 3d segment from 2d window coordinates. - * This ray_start is located at the viewpoint, ray_end is a far point. - * ray_start and ray_end are clipped by the view near and far limits - * so points along this line are always in view. - * In orthographic view all resulting segments will be parallel. - * \param ar The region (used for the window width and height). - * \param v3d The 3d viewport (used for near and far clipping range). - * \param mval The area relative 2d location (such as event->mval, converted into float[2]). - * \param ray_start The world-space starting point of the segment. - * \param ray_end The world-space end point of the segment. - */ -void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]) +void ED_view3d_win_to_segment(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]) { RegionView3D *rv3d = ar->regiondata; @@ -455,14 +443,46 @@ void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2] madd_v3_v3v3fl(ray_start, vec, rv3d->viewinv[2], 1000.0f); madd_v3_v3v3fl(ray_end, vec, rv3d->viewinv[2], -1000.0f); } +} + +/** + * Calculate a 3d segment from 2d window coordinates. + * This ray_start is located at the viewpoint, ray_end is a far point. + * ray_start and ray_end are clipped by the view near and far limits + * so points along this line are always in view. + * In orthographic view all resulting segments will be parallel. + * \param ar The region (used for the window width and height). + * \param v3d The 3d viewport (used for near and far clipping range). + * \param mval The area relative 2d location (such as event->mval, converted into float[2]). + * \param ray_start The world-space starting point of the segment. + * \param ray_end The world-space end point of the segment. + * \return success, FALSE if the segment is totally clipped. + */ +int ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]) +{ + RegionView3D *rv3d = ar->regiondata; + ED_view3d_win_to_segment(ar, v3d, mval, ray_start, ray_end); /* clipping */ if (rv3d->rflag & RV3D_CLIPPING) { + /* if the ray is totally clipped, + * restore the original values but return FALSE + * caller can choose what to do */ + float tray_start[3] = {UNPACK3(ray_start)}; + float tray_end[3] = {UNPACK3(ray_end)}; int a; for (a = 0; a < 4; a++) { - clip_line_plane(ray_start, ray_end, rv3d->clip[a]); + if (clip_line_plane(tray_start, tray_end, rv3d->clip[a]) == FALSE) { + return FALSE; + } } + + /* copy in clipped values */ + copy_v3_v3(ray_start, tray_start); + copy_v3_v3(ray_end, tray_end); } + + return TRUE; } diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 8af971b9b65..44db8d25b77 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1342,46 +1342,46 @@ typedef struct Scene { #define TESTBASE(v3d, base) ( \ ((base)->flag & SELECT) && \ ((base)->lay & v3d->lay) && \ - (((base)->object->restrictflag & OB_RESTRICT_VIEW)==0) ) + (((base)->object->restrictflag & OB_RESTRICT_VIEW) == 0)) #define TESTBASELIB(v3d, base) ( \ ((base)->flag & SELECT) && \ ((base)->lay & v3d->lay) && \ - ((base)->object->id.lib==NULL) && \ - (((base)->object->restrictflag & OB_RESTRICT_VIEW)==0) ) + ((base)->object->id.lib == NULL) && \ + (((base)->object->restrictflag & OB_RESTRICT_VIEW) == 0)) #define TESTBASELIB_BGMODE(v3d, scene, base) ( \ ((base)->flag & SELECT) && \ ((base)->lay & (v3d ? v3d->lay : scene->lay)) && \ - ((base)->object->id.lib==NULL) && \ - (((base)->object->restrictflag & OB_RESTRICT_VIEW)==0) ) + ((base)->object->id.lib == NULL) && \ + (((base)->object->restrictflag & OB_RESTRICT_VIEW) == 0)) #define BASE_EDITABLE_BGMODE(v3d, scene, base) ( \ ((base)->lay & (v3d ? v3d->lay : scene->lay)) && \ - ((base)->object->id.lib==NULL) && \ - (((base)->object->restrictflag & OB_RESTRICT_VIEW)==0)) + ((base)->object->id.lib == NULL) && \ + (((base)->object->restrictflag & OB_RESTRICT_VIEW) == 0)) #define BASE_SELECTABLE(v3d, base) ( \ (base->lay & v3d->lay) && \ - (base->object->restrictflag & (OB_RESTRICT_SELECT|OB_RESTRICT_VIEW))==0 ) + (base->object->restrictflag & (OB_RESTRICT_SELECT | OB_RESTRICT_VIEW)) == 0) #define BASE_VISIBLE(v3d, base) ( \ (base->lay & v3d->lay) && \ - (base->object->restrictflag & OB_RESTRICT_VIEW)==0 ) + (base->object->restrictflag & OB_RESTRICT_VIEW) == 0) #define FIRSTBASE scene->base.first #define LASTBASE scene->base.last #define BASACT (scene->basact) -#define OBACT (BASACT? BASACT->object: NULL) +#define OBACT (BASACT ? BASACT->object: NULL) #define V3D_CAMERA_LOCAL(v3d) ((!(v3d)->scenelock && (v3d)->camera) ? (v3d)->camera : NULL) #define V3D_CAMERA_SCENE(scene, v3d) ((!(v3d)->scenelock && (v3d)->camera) ? (v3d)->camera : (scene)->camera) -#define CFRA (scene->r.cfra) -#define SUBFRA (scene->r.subframe) -#define SFRA (scene->r.sfra) -#define EFRA (scene->r.efra) -#define PRVRANGEON (scene->r.flag & SCER_PRV_RANGE) -#define PSFRA ((PRVRANGEON) ? (scene->r.psfra) : (scene->r.sfra)) -#define PEFRA ((PRVRANGEON) ? (scene->r.pefra) : (scene->r.efra)) -#define FRA2TIME(a) ((((double) scene->r.frs_sec_base) * (double)(a)) / (double)scene->r.frs_sec) -#define TIME2FRA(a) ((((double) scene->r.frs_sec) * (double)(a)) / (double)scene->r.frs_sec_base) -#define FPS (((double) scene->r.frs_sec) / (double)scene->r.frs_sec_base) +#define CFRA (scene->r.cfra) +#define SUBFRA (scene->r.subframe) +#define SFRA (scene->r.sfra) +#define EFRA (scene->r.efra) +#define PRVRANGEON (scene->r.flag & SCER_PRV_RANGE) +#define PSFRA ((PRVRANGEON) ? (scene->r.psfra) : (scene->r.sfra)) +#define PEFRA ((PRVRANGEON) ? (scene->r.pefra) : (scene->r.efra)) +#define FRA2TIME(a) ((((double) scene->r.frs_sec_base) * (double)(a)) / (double)scene->r.frs_sec) +#define TIME2FRA(a) ((((double) scene->r.frs_sec) * (double)(a)) / (double)scene->r.frs_sec_base) +#define FPS (((double) scene->r.frs_sec) / (double)scene->r.frs_sec_base) /* base->flag is in DNA_object_types.h */ @@ -1614,4 +1614,4 @@ typedef enum SculptFlags { } #endif -#endif +#endif /* __DNA_SCENE_TYPES_H__ */ diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index bd51af77b34..1d08ea97b79 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -94,6 +94,15 @@ static EnumPropertyItem parent_type_items[] = { {0, NULL, 0, NULL, NULL} }; +static EnumPropertyItem dupli_items[] = { + {0, "NONE", 0, "None", ""}, + {OB_DUPLIFRAMES, "FRAMES", 0, "Frames", "Make copy of object for every frame"}, + {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Duplicate child objects on all vertices"}, + {OB_DUPLIFACES, "FACES", 0, "Faces", "Duplicate child objects on all faces"}, + {OB_DUPLIGROUP, "GROUP", 0, "Group", "Enable group instancing"}, + {0, NULL, 0, NULL, NULL} +}; + static EnumPropertyItem collision_bounds_items[] = { {OB_BOUND_BOX, "BOX", 0, "Box", ""}, {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", ""}, @@ -2019,15 +2028,7 @@ static void rna_def_object(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem dupli_items[] = { - {0, "NONE", 0, "None", ""}, - {OB_DUPLIFRAMES, "FRAMES", 0, "Frames", "Make copy of object for every frame"}, - {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Duplicate child objects on all vertices"}, - {OB_DUPLIFACES, "FACES", 0, "Faces", "Duplicate child objects on all faces"}, - {OB_DUPLIGROUP, "GROUP", 0, "Group", "Enable group instancing"}, - {0, NULL, 0, NULL, NULL} - }; - + /* XXX: this RNA enum define is currently duplicated for objects, * since there is some text here which is not applicable */ static EnumPropertyItem prop_rotmode_items[] = { @@ -2681,6 +2682,11 @@ static void rna_def_dupli_object(BlenderRNA *brna) RNA_def_property_array(prop, 2); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); RNA_def_property_ui_text(prop, "UV Coordinates", "UV coordinates in parent object space"); + + prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, dupli_items); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Dupli Type", "Duplicator type that generated this dupli object"); } static void rna_def_object_base(BlenderRNA *brna) diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 9a7e587ff56..03462738d58 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -719,6 +719,16 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int rendering, int /* *********************************************** */ +static void set_output_visible(bNode *node, int passflag, int index, int pass) +{ + bNodeSocket *sock = BLI_findlink(&node->outputs, index); + /* clear the SOCK_HIDDEN flag as well, in case a socket was hidden before */ + if (passflag & pass) + sock->flag &= ~(SOCK_HIDDEN | SOCK_UNAVAIL); + else + sock->flag |= SOCK_UNAVAIL; +} + /* clumsy checking... should do dynamic outputs once */ static void force_hidden_passes(bNode *node, int passflag) { @@ -727,68 +737,35 @@ static void force_hidden_passes(bNode *node, int passflag) for (sock= node->outputs.first; sock; sock= sock->next) sock->flag &= ~SOCK_UNAVAIL; - if (!(passflag & SCE_PASS_COMBINED)) { - sock= BLI_findlink(&node->outputs, RRES_OUT_IMAGE); - sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_ALPHA); - sock->flag |= SOCK_UNAVAIL; - } - - sock= BLI_findlink(&node->outputs, RRES_OUT_Z); - if (!(passflag & SCE_PASS_Z)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_NORMAL); - if (!(passflag & SCE_PASS_NORMAL)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_VEC); - if (!(passflag & SCE_PASS_VECTOR)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_UV); - if (!(passflag & SCE_PASS_UV)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_RGBA); - if (!(passflag & SCE_PASS_RGBA)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_DIFF); - if (!(passflag & SCE_PASS_DIFFUSE)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_SPEC); - if (!(passflag & SCE_PASS_SPEC)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_SHADOW); - if (!(passflag & SCE_PASS_SHADOW)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_AO); - if (!(passflag & SCE_PASS_AO)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_REFLECT); - if (!(passflag & SCE_PASS_REFLECT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_REFRACT); - if (!(passflag & SCE_PASS_REFRACT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_INDIRECT); - if (!(passflag & SCE_PASS_INDIRECT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_INDEXOB); - if (!(passflag & SCE_PASS_INDEXOB)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_INDEXMA); - if (!(passflag & SCE_PASS_INDEXMA)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_MIST); - if (!(passflag & SCE_PASS_MIST)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_EMIT); - if (!(passflag & SCE_PASS_EMIT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_ENV); - if (!(passflag & SCE_PASS_ENVIRONMENT)) sock->flag |= SOCK_UNAVAIL; - - sock= BLI_findlink(&node->outputs, RRES_OUT_DIFF_DIRECT); - if (!(passflag & SCE_PASS_DIFFUSE_DIRECT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_DIFF_INDIRECT); - if (!(passflag & SCE_PASS_DIFFUSE_INDIRECT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_DIFF_COLOR); - if (!(passflag & SCE_PASS_DIFFUSE_COLOR)) sock->flag |= SOCK_UNAVAIL; - - sock= BLI_findlink(&node->outputs, RRES_OUT_GLOSSY_DIRECT); - if (!(passflag & SCE_PASS_GLOSSY_DIRECT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_GLOSSY_INDIRECT); - if (!(passflag & SCE_PASS_GLOSSY_INDIRECT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_GLOSSY_COLOR); - if (!(passflag & SCE_PASS_GLOSSY_COLOR)) sock->flag |= SOCK_UNAVAIL; - - sock= BLI_findlink(&node->outputs, RRES_OUT_TRANSM_DIRECT); - if (!(passflag & SCE_PASS_TRANSM_DIRECT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_TRANSM_INDIRECT); - if (!(passflag & SCE_PASS_TRANSM_INDIRECT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_TRANSM_COLOR); - if (!(passflag & SCE_PASS_TRANSM_COLOR)) sock->flag |= SOCK_UNAVAIL; + set_output_visible(node, passflag, RRES_OUT_IMAGE, SCE_PASS_COMBINED); + set_output_visible(node, passflag, RRES_OUT_ALPHA, SCE_PASS_COMBINED); + + set_output_visible(node, passflag, RRES_OUT_Z, SCE_PASS_Z); + set_output_visible(node, passflag, RRES_OUT_NORMAL, SCE_PASS_NORMAL); + set_output_visible(node, passflag, RRES_OUT_VEC, SCE_PASS_VECTOR); + set_output_visible(node, passflag, RRES_OUT_UV, SCE_PASS_UV); + set_output_visible(node, passflag, RRES_OUT_RGBA, SCE_PASS_RGBA); + set_output_visible(node, passflag, RRES_OUT_DIFF, SCE_PASS_DIFFUSE); + set_output_visible(node, passflag, RRES_OUT_SPEC, SCE_PASS_SPEC); + set_output_visible(node, passflag, RRES_OUT_SHADOW, SCE_PASS_SHADOW); + set_output_visible(node, passflag, RRES_OUT_AO, SCE_PASS_AO); + set_output_visible(node, passflag, RRES_OUT_REFLECT, SCE_PASS_REFLECT); + set_output_visible(node, passflag, RRES_OUT_REFRACT, SCE_PASS_REFRACT); + set_output_visible(node, passflag, RRES_OUT_INDIRECT, SCE_PASS_INDIRECT); + set_output_visible(node, passflag, RRES_OUT_INDEXOB, SCE_PASS_INDEXOB); + set_output_visible(node, passflag, RRES_OUT_INDEXMA, SCE_PASS_INDEXMA); + set_output_visible(node, passflag, RRES_OUT_MIST, SCE_PASS_MIST); + set_output_visible(node, passflag, RRES_OUT_EMIT, SCE_PASS_EMIT); + set_output_visible(node, passflag, RRES_OUT_ENV, SCE_PASS_ENVIRONMENT); + set_output_visible(node, passflag, RRES_OUT_DIFF_DIRECT, SCE_PASS_DIFFUSE_DIRECT); + set_output_visible(node, passflag, RRES_OUT_DIFF_INDIRECT, SCE_PASS_DIFFUSE_INDIRECT); + set_output_visible(node, passflag, RRES_OUT_DIFF_COLOR, SCE_PASS_DIFFUSE_COLOR); + set_output_visible(node, passflag, RRES_OUT_GLOSSY_DIRECT, SCE_PASS_GLOSSY_DIRECT); + set_output_visible(node, passflag, RRES_OUT_GLOSSY_INDIRECT, SCE_PASS_GLOSSY_INDIRECT); + set_output_visible(node, passflag, RRES_OUT_GLOSSY_COLOR, SCE_PASS_GLOSSY_COLOR); + set_output_visible(node, passflag, RRES_OUT_TRANSM_DIRECT, SCE_PASS_TRANSM_DIRECT); + set_output_visible(node, passflag, RRES_OUT_TRANSM_INDIRECT, SCE_PASS_TRANSM_INDIRECT); + set_output_visible(node, passflag, RRES_OUT_TRANSM_COLOR, SCE_PASS_TRANSM_COLOR); } /* based on rules, force sockets hidden always */ diff --git a/source/blender/nodes/shader/nodes/node_shader_normal.c b/source/blender/nodes/shader/nodes/node_shader_normal.c index 98a56c85279..0ad58d6af76 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal.c +++ b/source/blender/nodes/shader/nodes/node_shader_normal.c @@ -34,12 +34,12 @@ /* **************** NORMAL ******************** */ static bNodeSocketTemplate sh_node_normal_in[] = { - { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE}, + { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_DIRECTION}, { -1, 0, "" } }; static bNodeSocketTemplate sh_node_normal_out[] = { - { SOCK_VECTOR, 0, N_("Normal")}, + { SOCK_VECTOR, 0, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_DIRECTION}, { SOCK_FLOAT, 0, N_("Dot")}, { -1, 0, "" } }; diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 1037542759f..8d885bf6d6f 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -171,6 +171,7 @@ void WM_event_timer_sleep(struct wmWindowManager *wm, struct wmWindow *win, str /* operator api, default callbacks */ /* invoke callback, uses enum property named "type" */ +int WM_operator_view3d_distance_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event); int WM_menu_invoke (struct bContext *C, struct wmOperator *op, struct wmEvent *event); int WM_enum_search_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event); /* invoke callback, confirm menu + exec */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index c555f771a48..8a0701b1063 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -87,6 +87,7 @@ #include "ED_screen.h" #include "ED_util.h" #include "ED_object.h" +#include "ED_view3d.h" #include "RNA_access.h" #include "RNA_define.h" @@ -689,6 +690,35 @@ void WM_operator_properties_free(PointerRNA *ptr) /* ************ default op callbacks, exported *********** */ +int WM_operator_view3d_distance_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *UNUSED(event)) +{ + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); + + const float dia = v3d ? ED_view3d_grid_scale(scene, v3d, NULL) : ED_scene_grid_scale(scene, NULL); + + /* always run, so the values are initialized, + * otherwise we may get differ behavior when (dia != 1.0) */ + RNA_STRUCT_BEGIN(op->ptr, prop) + { + if (RNA_property_type(prop) == PROP_FLOAT) { + PropertySubType pstype = RNA_property_subtype(prop); + if (pstype == PROP_DISTANCE) { + /* we don't support arrays yet */ + BLI_assert(RNA_property_array_check(prop) == FALSE); + /* initialize */ + if (!RNA_property_is_set_ex(op->ptr, prop, FALSE)) { + const float value = RNA_property_float_get_default(op->ptr, prop) * dia; + RNA_property_float_set(op->ptr, prop, value); + } + } + } + } + RNA_STRUCT_END; + + return op->type->exec(C, op); +} + /* invoke callback, uses enum property named "type" */ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { |