diff options
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r-- | source/blender/editors/space_view3d/drawanimviz.c | 50 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawarmature.c | 32 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawmesh.c | 74 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 166 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_buttons.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 32 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 132 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_fly.c | 18 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_header.c | 5 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_intern.h | 40 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ops.c | 7 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_snap.c | 10 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 28 |
15 files changed, 372 insertions, 240 deletions
diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c index ca5b21012aa..f8d942b4fd1 100644 --- a/source/blender/editors/space_view3d/drawanimviz.c +++ b/source/blender/editors/space_view3d/drawanimviz.c @@ -88,38 +88,50 @@ void draw_motion_path_instance(Scene *scene, //RegionView3D *rv3d= ar->regiondata; bMotionPathVert *mpv, *mpv_start; int i, stepsize = avs->path_step; - int sfra, efra, len; - + int sfra, efra, sind, len; /* get frame ranges */ if (avs->path_type == MOTIONPATH_TYPE_ACFRA) { - int sind; - /* With "Around Current", we only choose frames from around - * the current frame to draw. However, this range is still - * restricted by the limits of the original path. + * the current frame to draw. */ sfra = CFRA - avs->path_bc; efra = CFRA + avs->path_ac; - if (sfra < mpath->start_frame) sfra = mpath->start_frame; - if (efra > mpath->end_frame) efra = mpath->end_frame; - - len = efra - sfra; - - sind = sfra - mpath->start_frame; - mpv_start = (mpath->points + sind); } else { + /* Use the current display range */ + sfra = avs->path_sf; + efra = avs->path_ef; + } + + /* no matter what, we can only show what is in the cache and no more + * - abort if whole range is past ends of path + * - otherwise clamp endpoints to extents of path + */ + if ((sfra > mpath->end_frame) || (efra < mpath->start_frame)) { + /* whole path is out of bounds */ + return; + } + + if (sfra < mpath->start_frame) { + /* start clamp */ sfra = mpath->start_frame; - efra = sfra + mpath->length; - len = mpath->length; - mpv_start = mpath->points; } - + if (efra > mpath->end_frame) { + /* end clamp */ + efra = mpath->end_frame; + } + + len = efra - sfra; + if (len <= 0) { return; } - + + /* get pointers to parts of path */ + sind = sfra - mpath->start_frame; + mpv_start = (mpath->points + sind); + /* draw curve-line of path */ glShadeModel(GL_SMOOTH); @@ -258,7 +270,7 @@ void draw_motion_path_instance(Scene *scene, * unless an option is set to always use the whole action */ if ((pchan) && (avs->path_viewflag & MOTIONPATH_VIEW_KFACT) == 0) { - bActionGroup *agrp = action_groups_find_named(adt->action, pchan->name); + bActionGroup *agrp = BKE_action_group_find_name(adt->action, pchan->name); if (agrp) { agroup_to_keylist(adt, agrp, &keys, NULL); diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 15e6994dfe4..2211b1ddb62 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -2338,9 +2338,9 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base /* copy the pose */ poseo = ob->pose; - copy_pose(&posen, ob->pose, 1); + BKE_pose_copy_data(&posen, ob->pose, 1); ob->pose = posen; - armature_rebuild_pose(ob, ob->data); /* child pointers for IK */ + BKE_pose_rebuild(ob, ob->data); /* child pointers for IK */ ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ glEnable(GL_BLEND); @@ -2352,20 +2352,20 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128 - (int)(120.0 * sqrt(colfac))); BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); } glDisable(GL_BLEND); if (v3d->zbuf) glEnable(GL_DEPTH_TEST); ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ - free_pose(posen); + BKE_pose_free(posen); /* restore */ CFRA = cfrao; ob->pose = poseo; arm->flag = flago; - armature_rebuild_pose(ob, ob->data); + BKE_pose_rebuild(ob, ob->data); ob->mode |= OB_MODE_POSE; ob->ipoflag = ipoflago; } @@ -2415,9 +2415,9 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * /* copy the pose */ poseo = ob->pose; - copy_pose(&posen, ob->pose, 1); + BKE_pose_copy_data(&posen, ob->pose, 1); ob->pose = posen; - armature_rebuild_pose(ob, ob->data); /* child pointers for IK */ + BKE_pose_rebuild(ob, ob->data); /* child pointers for IK */ ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ glEnable(GL_BLEND); @@ -2431,7 +2431,7 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * CFRA = (int)ak->cfra; BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); } glDisable(GL_BLEND); @@ -2439,13 +2439,13 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ BLI_dlrbTree_free(&keys); - free_pose(posen); + BKE_pose_free(posen); /* restore */ CFRA = cfrao; ob->pose = poseo; arm->flag = flago; - armature_rebuild_pose(ob, ob->data); + BKE_pose_rebuild(ob, ob->data); ob->mode |= OB_MODE_POSE; } @@ -2481,9 +2481,9 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) /* copy the pose */ poseo = ob->pose; - copy_pose(&posen, ob->pose, 1); + BKE_pose_copy_data(&posen, ob->pose, 1); ob->pose = posen; - armature_rebuild_pose(ob, ob->data); /* child pointers for IK */ + BKE_pose_rebuild(ob, ob->data); /* child pointers for IK */ ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ glEnable(GL_BLEND); @@ -2501,7 +2501,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) if (CFRA != cfrao) { BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); } } @@ -2516,7 +2516,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) if (CFRA != cfrao) { BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); } } @@ -2525,13 +2525,13 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) if (v3d->zbuf) glEnable(GL_DEPTH_TEST); ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ - free_pose(posen); + BKE_pose_free(posen); /* restore */ CFRA = cfrao; ob->pose = poseo; arm->flag = flago; - armature_rebuild_pose(ob, ob->data); + BKE_pose_rebuild(ob, ob->data); ob->mode |= OB_MODE_POSE; } diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 530b26d566a..b5c44fd1a8c 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -926,14 +926,14 @@ static int tex_mat_set_face_editmesh_cb(void *userData, int index) return !BM_elem_flag_test(efa, BM_ELEM_HIDDEN); } -void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags) +void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, const int draw_flags) { - if ((!scene_use_new_shading_nodes(scene)) || (draw_flags & DRAW_MODIFIERS_PREVIEW)) { + if ((!BKE_scene_use_new_shading_nodes(scene)) || (draw_flags & DRAW_MODIFIERS_PREVIEW)) { draw_mesh_textured_old(scene, v3d, rv3d, ob, dm, draw_flags); return; } else if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) { - draw_mesh_paint(rv3d, ob, dm, draw_flags); + draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags); return; } @@ -1002,51 +1002,79 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o /* Vertex Paint and Weight Paint */ -void draw_mesh_paint(RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags) +void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags) { DMSetDrawOptions facemask = NULL; Mesh *me = ob->data; + const short do_light = (v3d->drawtype >= OB_SOLID); /* hide faces in face select mode */ if (draw_flags & DRAW_FACE_SELECT) facemask = wpaint__setSolidDrawOptions_facemask; if (ob && ob->mode & OB_MODE_WEIGHT_PAINT) { - /* enforce default material settings */ - GPU_enable_material(0, NULL); + + if (do_light) { + /* enforce default material settings */ + GPU_enable_material(0, NULL); - /* but set default spec */ - glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); - glEnable(GL_COLOR_MATERIAL); /* according manpages needed */ - glColor3ub(120, 120, 120); - glDisable(GL_COLOR_MATERIAL); + /* but set default spec */ + glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); + glEnable(GL_COLOR_MATERIAL); /* according manpages needed */ + glColor3ub(120, 120, 120); + glDisable(GL_COLOR_MATERIAL); - /* diffuse */ - glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); - glEnable(GL_LIGHTING); - glEnable(GL_COLOR_MATERIAL); + /* diffuse */ + glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); + glEnable(GL_LIGHTING); + glEnable(GL_COLOR_MATERIAL); + } dm->drawMappedFaces(dm, facemask, GPU_enable_material, NULL, me, - DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); + DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); - glDisable(GL_COLOR_MATERIAL); - glDisable(GL_LIGHTING); + if (do_light) { + glDisable(GL_COLOR_MATERIAL); + glDisable(GL_LIGHTING); - GPU_disable_material(); + GPU_disable_material(); + } } else if (ob->mode & OB_MODE_VERTEX_PAINT) { - if (me->mloopcol) + if (me->mloopcol) { dm->drawMappedFaces(dm, facemask, GPU_enable_material, NULL, me, - DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); + DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); + } else { glColor3f(1.0f, 1.0f, 1.0f); dm->drawMappedFaces(dm, facemask, GPU_enable_material, NULL, me, - DM_DRAW_ALWAYS_SMOOTH); + DM_DRAW_ALWAYS_SMOOTH); } } /* draw face selection on top */ - if (draw_flags & DRAW_FACE_SELECT) + if (draw_flags & DRAW_FACE_SELECT) { draw_mesh_face_select(rv3d, me, dm); + } + else if ((do_light == FALSE) || (ob->dtx & OB_DRAWWIRE)) { + + /* weight paint in solid mode, special case. focus on making the weights clear + * rather than the shading, this is also forced in wire view */ + + bglPolygonOffset(rv3d->dist, 1.0); + glDepthMask(0); // disable write in zbuffer, selected edge wires show better + + glEnable(GL_BLEND); + glColor4ub(255, 255, 255, 96); + glEnable(GL_LINE_STIPPLE); + glLineStipple(1, 0xAAAA); + + dm->drawEdges(dm, 1, 1); + + bglPolygonOffset(rv3d->dist, 0.0); + glDepthMask(1); + glDisable(GL_LINE_STIPPLE); + glDisable(GL_BLEND); + } } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index e9b7ef2c6ef..29e6b77e0d4 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -190,7 +190,7 @@ static int check_object_draw_texture(Scene *scene, View3D *v3d, int drawtype) return TRUE; /* textured solid */ - if (v3d->drawtype == OB_SOLID && (v3d->flag2 & V3D_SOLID_TEX) && !scene_use_new_shading_nodes(scene)) + if (v3d->drawtype == OB_SOLID && (v3d->flag2 & V3D_SOLID_TEX) && !BKE_scene_use_new_shading_nodes(scene)) return TRUE; return FALSE; @@ -332,7 +332,7 @@ int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt) return 0; if (ob == OBACT && (ob && ob->mode & OB_MODE_WEIGHT_PAINT)) return 0; - if (scene_use_new_shading_nodes(scene)) + if (BKE_scene_use_new_shading_nodes(scene)) return 0; return (scene->gm.matmode == GAME_MAT_GLSL) && (dt > OB_SOLID); @@ -1740,7 +1740,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base int i; float drawsize; const short is_view = (rv3d->persp == RV3D_CAMOB && ob == v3d->camera); - MovieClip *clip = object_get_movieclip(scene, base->object, 0); + MovieClip *clip = BKE_object_movieclip_get(scene, base->object, 0); /* draw data for movie clip set as active for scene */ if (clip) { @@ -1763,7 +1763,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base scale[2] = 1.0f / len_v3(ob->obmat[2]); BKE_camera_view_frame_ex(scene, cam, cam->drawsize, is_view, scale, - asp, shift, &drawsize, vec); + asp, shift, &drawsize, vec); glDisable(GL_LIGHTING); glDisable(GL_CULL_FACE); @@ -1924,7 +1924,7 @@ void lattice_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, BPo Object *obedit = vc->obedit; Lattice *lt = obedit->data; BPoint *bp = lt->editlatt->latt->def; - DispList *dl = find_displist(&obedit->disp, DL_VERTS); + DispList *dl = BKE_displist_find(&obedit->disp, DL_VERTS); float *co = dl ? dl->verts : NULL; int i, N = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; short s[2] = {IS_CLIPPED, 0}; @@ -1971,8 +1971,8 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob) /* now we default make displist, this will modifiers work for non animated case */ if (ob->disp.first == NULL) - lattice_calc_modifiers(scene, ob); - dl = find_displist(&ob->disp, DL_VERTS); + BKE_lattice_modifiers_calc(scene, ob); + dl = BKE_displist_find(&ob->disp, DL_VERTS); if (is_edit) { lt = lt->editlatt->latt; @@ -2209,9 +2209,9 @@ void mesh_foreachScreenFace( } void nurbs_foreachScreenVert( - ViewContext *vc, - void (*func)(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, int x, int y), - void *userData) + ViewContext *vc, + void (*func)(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, int x, int y), + void *userData) { Curve *cu = vc->obedit->data; short s[2] = {IS_CLIPPED, 0}; @@ -2921,7 +2921,7 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS mul_v3_fl(vmid, 1.0f / (float)n); \ if (unit->system) \ bUnit_AsString(numstr, sizeof(numstr), \ - (double)(area * unit->scale_length), \ + (double)(area * unit->scale_length), \ 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); \ else \ BLI_snprintf(numstr, sizeof(numstr), conv_float, area); \ @@ -2971,35 +2971,45 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col); - for (efa = BM_iter_new(&iter, em->bm, BM_FACES_OF_MESH, NULL); - efa; efa = BM_iter_step(&iter)) - { - BMIter liter; - BMLoop *loop; + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { + const int is_face_sel = BM_elem_flag_test(efa, BM_ELEM_SELECT); - BM_face_calc_center_bounds(efa, vmid); + if (is_face_sel || do_moving) { + BMIter liter; + BMLoop *loop; + int cent_ok = FALSE; - for (loop = BM_iter_new(&liter, em->bm, BM_LOOPS_OF_FACE, efa); - loop; loop = BM_iter_step(&liter)) - { - float v1[3], v2[3], v3[3]; + BM_ITER_ELEM(loop, &liter, efa, BM_LOOPS_OF_FACE) { + if (is_face_sel || (do_moving && BM_elem_flag_test(loop->v, BM_ELEM_SELECT))) { + /* yes, we should avoid triple matrix multiply every vertex for 'global' */ + float angle; - copy_v3_v3(v1, loop->prev->v->co); - copy_v3_v3(v2, loop->v->co); - copy_v3_v3(v3, loop->next->v->co); + /* lazy init center calc */ + if (cent_ok == FALSE) { + BM_face_calc_center_bounds(efa, vmid); + cent_ok = TRUE; + } - if (do_global) { - mul_mat3_m4_v3(ob->obmat, v1); - mul_mat3_m4_v3(ob->obmat, v2); - mul_mat3_m4_v3(ob->obmat, v3); - } + if (do_global) { + copy_v3_v3(v1, loop->prev->v->co); + copy_v3_v3(v2, loop->v->co); + copy_v3_v3(v3, loop->next->v->co); - if ( (BM_elem_flag_test(efa, BM_ELEM_SELECT)) || - (do_moving && BM_elem_flag_test(loop->v, BM_ELEM_SELECT))) - { - BLI_snprintf(numstr, sizeof(numstr), "%.3g", RAD2DEGF(angle_v3v3v3(v1, v2, v3))); - interp_v3_v3v3(fvec, vmid, v2, 0.8f); - view3d_cached_text_draw_add(fvec, numstr, 0, txt_flag, col); + mul_mat3_m4_v3(ob->obmat, v1); + mul_mat3_m4_v3(ob->obmat, v2); + mul_mat3_m4_v3(ob->obmat, v3); + + angle = angle_v3v3v3(v1, v2, v3); + interp_v3_v3v3(fvec, vmid, v2, 0.8f); + } + else { + angle = angle_v3v3v3(loop->prev->v->co, loop->v->co, loop->v->co); + interp_v3_v3v3(fvec, vmid, loop->v->co, 0.8f); + } + + BLI_snprintf(numstr, sizeof(numstr), "%.3f", RAD2DEGF(angle)); + view3d_cached_text_draw_add(fvec, numstr, 0, txt_flag, col); + } } } } @@ -3387,34 +3397,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } } else if (dt == OB_SOLID) { - if (is_obact && ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) { - /* weight paint in solid mode, special case. focus on making the weights clear - * rather than the shading, this is also forced in wire view */ - GPU_enable_material(0, NULL); - dm->drawMappedFaces(dm, NULL, GPU_enable_material, NULL, me->mpoly, - DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); - - bglPolygonOffset(rv3d->dist, 1.0); - glDepthMask(0); // disable write in zbuffer, selected edge wires show better - - glEnable(GL_BLEND); - glColor4ub(255, 255, 255, 96); - glEnable(GL_LINE_STIPPLE); - glLineStipple(1, 0xAAAA); - - dm->drawEdges(dm, 1, 1); - - bglPolygonOffset(rv3d->dist, 0.0); - glDepthMask(1); - glDisable(GL_LINE_STIPPLE); - glDisable(GL_BLEND); - - GPU_disable_material(); - - /* since we already draw wire as wp guide, don't draw over the top */ - draw_wire = OBDRAW_WIRE_OFF; - } - else if (draw_flags & DRAW_MODIFIERS_PREVIEW) { + if (draw_flags & DRAW_MODIFIERS_PREVIEW) { /* for object selection draws no shade */ if (flag & (DRAW_PICKING | DRAW_CONSTCOLOR)) { dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); @@ -3505,7 +3488,10 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } } else if (dt == OB_PAINT) { - draw_mesh_paint(rv3d, ob, dm, draw_flags); + draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags); + + /* since we already draw wire as wp guide, don't draw over the top */ + draw_wire = OBDRAW_WIRE_OFF; } /* set default draw color back for wire or for draw-extra later on */ @@ -3629,8 +3615,8 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D finalDM->release(finalDM); } else { - /* don't create boundbox here with mesh_get_bb(), the derived system will make it, puts deformed bb's OK */ - if (me->totpoly <= 4 || ED_view3d_boundbox_clip(rv3d, ob->obmat, (ob->bb) ? ob->bb : me->bb)) { + /* ob->bb was set by derived mesh system, do NULL check just to be sure */ + if (me->totpoly <= 4 || (ob->bb && ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb))) { glsl = draw_glsl_material(scene, ob, v3d, dt); check_alpha = check_alpha_pass(base); @@ -3947,10 +3933,10 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas dl = lb->first; if (dl == NULL) return 1; - if (dl->nors == NULL) addnormalsDispList(lb); + if (dl->nors == NULL) BKE_displist_normals_add(lb); index3_nors_incr = 0; - if (displist_has_faces(lb) == 0) { + if (BKE_displist_has_faces(lb) == 0) { if (!render_only) { draw_index_wire = 0; drawDispListwire(lb); @@ -3978,7 +3964,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas index3_nors_incr = 1; } else { - if (!render_only || (render_only && displist_has_faces(lb))) { + if (!render_only || (render_only && BKE_displist_has_faces(lb))) { draw_index_wire = 0; retval = drawDispListwire(lb); draw_index_wire = 1; @@ -3993,7 +3979,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas dl = lb->first; if (dl == NULL) return 1; - if (dl->nors == NULL) addnormalsDispList(lb); + if (dl->nors == NULL) BKE_displist_normals_add(lb); if (draw_glsl_material(scene, ob, v3d, dt)) { GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL); @@ -4012,9 +3998,9 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas break; case OB_MBALL: - if (BKE_metaball_is_basis(ob)) { + if (BKE_mball_is_basis(ob)) { lb = &ob->disp; - if (lb->first == NULL) makeDispListMBall(scene, ob); + if (lb->first == NULL) BKE_displist_make_mball(scene, ob); if (lb->first == NULL) return 1; if (solid) { @@ -4315,7 +4301,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv totpart = psys->totpart; - cfra = BKE_curframe(scene); + cfra = BKE_scene_frame_get(scene); if (draw_as == PART_DRAW_PATH && psys->pathcache == NULL && psys->childcache == NULL) draw_as = PART_DRAW_DOT; @@ -5530,7 +5516,7 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel) } } - ++index; + index++; nu = nu->next; } } @@ -5559,7 +5545,7 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, tekenhandlesN_active(nu); tekenhandlesN(nu, 0, hide_handles); } - ++index; + index++; } draw_editnurb(ob, nurb, 0); draw_editnurb(ob, nurb, 1); @@ -6122,7 +6108,7 @@ static void draw_box(float vec[8][3]) #if 0 static void get_local_bounds(Object *ob, float center[3], float size[3]) { - BoundBox *bb = object_get_boundbox(ob); + BoundBox *bb = BKE_object_boundbox_get(ob); if (bb == NULL) { zero_v3(center); @@ -6183,22 +6169,22 @@ static void draw_bounding_volume(Scene *scene, Object *ob, char type) BoundBox *bb = NULL; if (ob->type == OB_MESH) { - bb = mesh_get_bb(ob); + bb = BKE_mesh_boundbox_get(ob); } else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { bb = ob->bb ? ob->bb : ( (Curve *)ob->data)->bb; } else if (ob->type == OB_MBALL) { - if (BKE_metaball_is_basis(ob)) { + if (BKE_mball_is_basis(ob)) { bb = ob->bb; if (bb == NULL) { - makeDispListMBall(scene, ob); + BKE_displist_make_mball(scene, ob); bb = ob->bb; } } } else if (ob->type == OB_ARMATURE) { - bb = BKE_armature_get_bb(ob); + bb = BKE_armature_boundbox_get(ob); } else { drawcube(); @@ -6217,7 +6203,7 @@ static void drawtexspace(Object *ob) float vec[8][3], loc[3], size[3]; if (ob->type == OB_MESH) { - mesh_get_texspace(ob->data, loc, NULL, size); + BKE_mesh_texspace_get(ob->data, loc, NULL, size); } else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { Curve *cu = ob->data; @@ -6265,7 +6251,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base) hasfaces = dm->getNumTessFaces(dm); } else { - hasfaces = displist_has_faces(&ob->disp); + hasfaces = BKE_displist_has_faces(&ob->disp); } if (hasfaces && ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { @@ -6280,7 +6266,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base) } } else if (ob->type == OB_MBALL) { - if (BKE_metaball_is_basis(ob)) { + if (BKE_mball_is_basis(ob)) { if ((base->flag & OB_FROMDUPLI) == 0) drawDispListwire(&ob->disp); } @@ -6340,7 +6326,7 @@ static void drawWireExtra(Scene *scene, RegionView3D *rv3d, Object *ob) } } else if (ob->type == OB_MBALL) { - if (BKE_metaball_is_basis(ob)) { + if (BKE_mball_is_basis(ob)) { drawDispListwire(&ob->disp); } } @@ -6465,7 +6451,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) view3d_cached_text_draw_begin(); /* patch? children objects with a timeoffs change the parents. How to solve! */ - /* if ( ((int)ob->ctime) != F_(scene->r.cfra)) where_is_object(scene, ob); */ + /* if ( ((int)ob->ctime) != F_(scene->r.cfra)) BKE_object_where_is_calc(scene, ob); */ /* draw motion paths (in view space) */ if (ob->mpath && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { @@ -6575,8 +6561,10 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) zbufoff = 1; dt = OB_SOLID; } - else if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) + + if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) { dt = OB_PAINT; + } glEnable(GL_DEPTH_TEST); } @@ -6604,7 +6592,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* bad exception, solve this! otherwise outline shows too late */ if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { /* still needed for curves hidden in other layers. depgraph doesnt handle that yet */ - if (ob->disp.first == NULL) makeDispListCurveTypes(scene, ob, 0); + if (ob->disp.first == NULL) BKE_displist_make_curveTypes(scene, ob, 0); } /* draw outline for selected objects, mesh does itself */ @@ -6677,7 +6665,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) setlinestyle(0); - if (BKE_font_getselection(ob, &selstart, &selend) && cu->selboxes) { + if (BKE_vfont_select_get(ob, &selstart, &selend) && cu->selboxes) { float selboxw; cpack(0xffffff); @@ -7171,7 +7159,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) for (ct = targets.first; ct; ct = ct->next) { /* calculate target's matrix */ if (cti->get_target_matrix) - cti->get_target_matrix(curcon, cob, ct, BKE_curframe(scene)); + cti->get_target_matrix(curcon, cob, ct, BKE_scene_frame_get(scene)); else unit_m4(ct->matrix); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 72b67c2a716..28fd2c8bc74 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -1016,7 +1016,7 @@ static void space_view3d_listener(struct ScrArea *sa, struct wmNotifier *wmn) break; } - // removed since BKE_image_user_calc_frame is now called in draw_bgpic because screen_ops doesnt call the notifier. + // removed since BKE_image_user_frame_calc is now called in draw_bgpic because screen_ops doesnt call the notifier. #if 0 if (wmn->category == NC_SCENE && wmn->data == ND_FRAME) { View3D *v3d = area->spacedata.first; @@ -1025,7 +1025,7 @@ static void space_view3d_listener(struct ScrArea *sa, struct wmNotifier *wmn) for (; bgpic; bgpic = bgpic->next) { if (bgpic->ima) { Scene *scene = wmn->reference; - BKE_image_user_calc_frame(&bgpic->iuser, scene->r.cfra, 0); + BKE_image_user_frame_calc(&bgpic->iuser, scene->r.cfra, 0); } } } @@ -1071,7 +1071,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes for (base = scene->base.first; base; base = base->next) { if ((base->flag & SELECT) && (base->lay & lay)) { if ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0) { - if (0 == object_is_libdata(base->object)) { + if (0 == BKE_object_is_libdata(base->object)) { if (selected_editable_objects) CTX_data_id_list_add(result, &base->object->id); else diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 13129616843..4a135f91d91 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -83,8 +83,8 @@ /* ******************* view3d space & buttons ************** */ -#define B_NOP 1 -#define B_REDR 2 +#define B_NOP 1 +#define B_REDR 2 #define B_OBJECTPANELMEDIAN 1008 /* temporary struct for storing transform properties */ @@ -595,7 +595,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } else { bp->weight = scale_w > 0.0f ? bp->weight * scale_w : - 1.0f + ((1.0f - bp->weight) * scale_w); + 1.0f + ((1.0f - bp->weight) * scale_w); CLAMP(bp->weight, 0.0f, 1.0f); } } @@ -939,7 +939,7 @@ static void v3d_posearmature_buts(uiLayout *layout, Object *ob) PointerRNA pchanptr; uiLayout *col; - pchan = get_active_posechannel(ob); + pchan = BKE_pose_channel_active(ob); if (!pchan) { uiItemL(layout, IFACE_("No Bone Active"), ICON_NONE); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index f48b45f9793..682d8950440 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -102,7 +102,7 @@ static void star_stuff_init_func(void) glPointSize(1.0); glBegin(GL_POINTS); } -static void star_stuff_vertex_func(float*i) +static void star_stuff_vertex_func(float *i) { glVertex3fv(i); } @@ -716,7 +716,7 @@ static void draw_rotation_guide(RegionView3D *rv3d) glColor4fv(color); glBegin(GL_LINE_LOOP); for (i = 0, angle = 0.f; i < ROT_AXIS_DETAIL; ++i, angle += step) { - float p[3] = {s * cosf(angle), s * sinf(angle), 0.0f}; + float p[3] = {s *cosf(angle), s * sinf(angle), 0.0f}; if (!upright) { mul_qt_v3(q, p); @@ -847,7 +847,7 @@ static void draw_selected_name(Scene *scene, Object *ob) short offset = 30; /* get name of marker on current frame (if available) */ - markern = scene_find_marker_name(scene, CFRA); + markern = BKE_scene_find_marker_name(scene, CFRA); /* check if there is an object */ if (ob) { @@ -910,7 +910,7 @@ static void draw_selected_name(Scene *scene, Object *ob) } /* color depends on whether there is a keyframe */ - if (id_frame_has_keyframe((ID *)ob, /*BKE_curframe(scene)*/ (float)(CFRA), ANIMFILTER_KEYS_LOCAL)) + if (id_frame_has_keyframe((ID *)ob, /*BKE_scene_frame_get(scene)*/ (float)(CFRA), ANIMFILTER_KEYS_LOCAL)) UI_ThemeColor(TH_VERTEX_SELECT); else UI_ThemeColor(TH_TEXT_HI); @@ -1544,7 +1544,7 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, int foreground) ima = bgpic->ima; if (ima == NULL) continue; - BKE_image_user_calc_frame(&bgpic->iuser, CFRA, 0); + BKE_image_user_frame_calc(&bgpic->iuser, CFRA, 0); ibuf = BKE_image_get_ibuf(ima, &bgpic->iuser); } else { @@ -1552,7 +1552,7 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, int foreground) if (bgpic->flag & V3D_BGPIC_CAMERACLIP) { if (scene->camera) - clip = object_get_movieclip(scene, scene->camera, 1); + clip = BKE_object_movieclip_get(scene, scene->camera, 1); } else clip = bgpic->clip; @@ -1699,7 +1699,7 @@ static void draw_bgpics(Scene *scene, ARegion *ar, View3D *v3d, int foreground) } } else { - draw_bgpic(scene, ar, v3d, foreground); + draw_bgpic(scene, ar, v3d, foreground); } } @@ -1861,12 +1861,12 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas * offset feature (used in group-duplicate.blend but no longer works in 2.5) * so for now it should be ok to - campbell */ - if (/* if this is the last no need to make a displist */ + if ( /* if this is the last no need to make a displist */ (dob_next == NULL || dob_next->ob != dob->ob) || /* lamp drawing messes with matrices, could be handled smarter... but this works */ (dob->ob->type == OB_LAMP) || (dob->type == OB_DUPLIGROUP && dob->animated) || - !(bb_tmp = object_get_boundbox(dob->ob))) + !(bb_tmp = BKE_object_boundbox_get(dob->ob))) { // printf("draw_dupli_objects_color: skipping displist for %s\n", dob->ob->id.name+2); use_displist = 0; @@ -1876,7 +1876,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas bb = *bb_tmp; /* must make a copy */ /* disable boundbox check for list creation */ - object_boundbox_flag(dob->ob, OB_BB_DISABLED, 1); + BKE_object_boundbox_flag(dob->ob, OB_BB_DISABLED, 1); /* need this for next part of code */ unit_m4(dob->ob->obmat); /* obmat gets restored */ @@ -1886,7 +1886,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas glEndList(); use_displist = 1; - object_boundbox_flag(dob->ob, OB_BB_DISABLED, 0); + BKE_object_boundbox_flag(dob->ob, OB_BB_DISABLED, 0); } } if (use_displist) { @@ -2043,7 +2043,7 @@ void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d) RegionView3D *rv3d = ar->regiondata; setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */ - setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */ + setviewmatrixview3d(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); invert_m4_m4(rv3d->persinv, rv3d->persmat); @@ -2078,7 +2078,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (*func)(void *)) U.obcenter_dia = 0; setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */ - setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */ + setviewmatrixview3d(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); invert_m4_m4(rv3d->persinv, rv3d->persmat); @@ -2297,7 +2297,7 @@ CustomDataMask ED_view3d_datamask(Scene *scene, View3D *v3d) { mask |= CD_MASK_MTFACE | CD_MASK_MCOL; - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { if (v3d->drawtype == OB_MATERIAL) mask |= CD_MASK_ORCO; } @@ -2367,7 +2367,7 @@ void ED_view3d_update_viewmat(Scene *scene, View3D *v3d, ARegion *ar, float view if (viewmat) copy_m4_m4(rv3d->viewmat, viewmat); else - setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */ + setviewmatrixview3d(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */ /* update utilitity matrices */ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); @@ -2556,7 +2556,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, /* transp and X-ray afterdraw stuff */ if (v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d); - if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used! + if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); /* clears zbuffer if it is used! */ if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1); if (rv3d->rflag & RV3D_CLIPPING) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index ea4d28ce32f..60a0d3bf12b 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -56,6 +56,8 @@ #include "BKE_report.h" #include "BKE_scene.h" #include "BKE_screen.h" +#include "BKE_action.h" +#include "BKE_armature.h" #include "BKE_depsgraph.h" /* for ED_view3d_camera_lock_sync */ @@ -68,6 +70,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "ED_armature.h" #include "ED_particle.h" #include "ED_screen.h" #include "ED_transform.h" @@ -121,9 +124,9 @@ int ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) mult_m4_m4m4(parent_mat, diff_mat, root_parent->obmat); - object_tfm_protected_backup(root_parent, &obtfm); - object_apply_mat4(root_parent, parent_mat, TRUE, FALSE); - object_tfm_protected_restore(root_parent, &obtfm, root_parent->protectflag); + BKE_object_tfm_protected_backup(root_parent, &obtfm); + BKE_object_apply_mat4(root_parent, parent_mat, TRUE, FALSE); + BKE_object_tfm_protected_restore(root_parent, &obtfm, root_parent->protectflag); ob_update = v3d->camera; while (ob_update) { @@ -133,9 +136,9 @@ int ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) } } else { - object_tfm_protected_backup(v3d->camera, &obtfm); + BKE_object_tfm_protected_backup(v3d->camera, &obtfm); ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist); - object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag); + BKE_object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag); DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); WM_main_add_notifier(NC_OBJECT | ND_TRANSFORM, v3d->camera); @@ -983,12 +986,12 @@ void VIEW3D_OT_rotate(wmOperatorType *ot) /* NDOF utility functions * (should these functions live in this file?) */ -float ndof_to_axis_angle(struct wmNDOFMotionData*ndof, float axis[3]) +float ndof_to_axis_angle(struct wmNDOFMotionData *ndof, float axis[3]) { return ndof->dt * normalize_v3_v3(axis, ndof->rvec); } -void ndof_to_quat(struct wmNDOFMotionData*ndof, float q[4]) +void ndof_to_quat(struct wmNDOFMotionData *ndof, float q[4]) { float axis[3]; float angle; @@ -1007,8 +1010,8 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event return OPERATOR_CANCELLED; else { View3D *v3d = CTX_wm_view3d(C); - RegionView3D*rv3d = CTX_wm_region_view3d(C); - wmNDOFMotionData*ndof = (wmNDOFMotionData *) event->customdata; + RegionView3D *rv3d = CTX_wm_region_view3d(C); + wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata; ED_view3d_camera_lock_init(v3d, rv3d); @@ -1159,8 +1162,8 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) return OPERATOR_CANCELLED; else { View3D *v3d = CTX_wm_view3d(C); - RegionView3D*rv3d = CTX_wm_region_view3d(C); - wmNDOFMotionData*ndof = (wmNDOFMotionData *) event->customdata; + RegionView3D *rv3d = CTX_wm_region_view3d(C); + wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata; ED_view3d_camera_lock_init(v3d, rv3d); @@ -2068,7 +2071,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in continue; } - minmax_object(base->object, min, max); + BKE_object_minmax(base->object, min, max); } } if (!onedone) { @@ -2214,8 +2217,8 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) } /* account for duplis */ - if (minmax_object_duplis(scene, base->object, min, max) == 0) - minmax_object(base->object, min, max); /* use if duplis not found */ + if (BKE_object_minmax_dupli(scene, base->object, min, max) == 0) + BKE_object_minmax(base->object, min, max); /* use if duplis not found */ ok = 1; } @@ -2236,7 +2239,7 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) size = v3d->near * 1.5f; } } - else /* ortho */ { + else { /* ortho */ if (size < 0.0001f) { /* bounding box was a single point so do not zoom */ ok_dist = 0; @@ -2291,6 +2294,89 @@ void VIEW3D_OT_view_selected(wmOperatorType *ot) ot->flag = 0; } +static int view_lock_clear_exec(bContext *C, wmOperator *UNUSED(op)) +{ + View3D *v3d = CTX_wm_view3d(C); + + if (v3d) { + ED_view3D_lock_clear(v3d); + + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +void VIEW3D_OT_view_lock_clear(wmOperatorType *ot) +{ + + /* identifiers */ + ot->name = "View Lock Clear"; + ot->description = "Clear all view locking"; + ot->idname = "VIEW3D_OT_view_lock_clear"; + + /* api callbacks */ + ot->exec = view_lock_clear_exec; + ot->poll = ED_operator_region_view3d_active; + + /* flags */ + ot->flag = 0; +} + +static int view_lock_to_active_exec(bContext *C, wmOperator *UNUSED(op)) +{ + View3D *v3d = CTX_wm_view3d(C); + Object *obact = CTX_data_active_object(C); + + if (v3d) { + + ED_view3D_lock_clear(v3d); + + v3d->ob_centre = obact; /* can be NULL */ + + if (obact && obact->type == OB_ARMATURE) { + if (obact->mode & OB_MODE_POSE) { + bPoseChannel *pcham_act = BKE_pose_channel_active(obact); + if (pcham_act) { + BLI_strncpy(v3d->ob_centre_bone, pcham_act->name, sizeof(v3d->ob_centre_bone)); + } + } + else { + EditBone *ebone_act = ((bArmature *)obact->data)->act_edbone; + if (ebone_act) { + BLI_strncpy(v3d->ob_centre_bone, ebone_act->name, sizeof(v3d->ob_centre_bone)); + } + } + } + + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +void VIEW3D_OT_view_lock_to_active(wmOperatorType *ot) +{ + + /* identifiers */ + ot->name = "View Lock to Active"; + ot->description = "Lock the view to the active object/bone"; + ot->idname = "VIEW3D_OT_view_lock_to_active"; + + /* api callbacks */ + ot->exec = view_lock_to_active_exec; + ot->poll = ED_operator_region_view3d_active; + + /* flags */ + ot->flag = 0; +} + static int viewcenter_cursor_exec(bContext *C, wmOperator *UNUSED(op)) { View3D *v3d = CTX_wm_view3d(C); @@ -2851,7 +2937,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) v3d->camera = ob; if (v3d->camera == NULL) - v3d->camera = scene_find_camera(scene); + v3d->camera = BKE_scene_camera_find(scene); /* couldnt find any useful camera, bail out */ if (v3d->camera == NULL) @@ -3094,11 +3180,11 @@ static int background_image_add_invoke(bContext *C, wmOperator *op, wmEvent *UNU char path[FILE_MAX]; RNA_string_get(op->ptr, "filepath", path); - ima = BKE_add_image_file(path); + ima = BKE_image_load_exists(path); } else if (RNA_struct_property_is_set(op->ptr, "name")) { RNA_string_get(op->ptr, "name", name); - ima = (Image *)find_id("IM", name); + ima = (Image *)BKE_libblock_find_name(ID_IM, name); } bgpic = background_image_add(C); @@ -3671,7 +3757,7 @@ void ED_view3d_to_object(Object *ob, const float ofs[3], const float quat[4], co { float mat[4][4]; ED_view3d_to_m4(mat, ofs, quat, dist); - object_apply_mat4(ob, mat, TRUE, TRUE); + BKE_object_apply_mat4(ob, mat, TRUE, TRUE); } BGpic *ED_view3D_background_image_new(View3D *v3d) @@ -3709,3 +3795,11 @@ void ED_view3D_background_image_clear(View3D *v3d) bgpic = next_bgpic; } } + +void ED_view3D_lock_clear(View3D *v3d) +{ + v3d->ob_centre = NULL; + v3d->ob_centre_bone[0] = '\0'; + v3d->ob_centre_cursor = FALSE; + v3d->flag2 &= ~V3D_LOCK_CAMERA; +} diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 5b6624889c8..2dab26e7781 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -174,7 +174,7 @@ typedef struct FlyInfo { unsigned char use_freelook; int mval[2]; /* latest 2D mouse values */ - wmNDOFMotionData*ndof; /* latest 3D mouse values */ + wmNDOFMotionData *ndof; /* latest 3D mouse values */ /* fly state state */ float speed; /* the speed the view is moving per redraw */ @@ -366,9 +366,9 @@ static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event /* store the original camera loc and rot */ /* TODO. axis angle etc */ - fly->obtfm = object_tfm_backup(ob_back); + fly->obtfm = BKE_object_tfm_backup(ob_back); - where_is_object(fly->scene, fly->v3d->camera); + BKE_object_where_is_calc(fly->scene, fly->v3d->camera); negate_v3_v3(fly->rv3d->ofs, fly->v3d->camera->obmat[3]); fly->rv3d->dist = 0.0; @@ -429,7 +429,7 @@ static int flyEnd(bContext *C, FlyInfo *fly) ob_back = (fly->root_parent) ? fly->root_parent : fly->v3d->camera; /* store the original camera loc and rot */ - object_tfm_restore(ob_back, fly->obtfm); + BKE_object_tfm_restore(ob_back, fly->obtfm); DAG_id_tag_update(&ob_back->id, OB_RECALC_OB); } @@ -690,7 +690,7 @@ static void move_camera(bContext *C, RegionView3D *rv3d, FlyInfo *fly, int orien { /* we are in camera view so apply the view ofs and quat to the view matrix and set the camera to the view */ - View3D*v3d = fly->v3d; + View3D *v3d = fly->v3d; Scene *scene = fly->scene; ID *id_key; @@ -709,9 +709,9 @@ static void move_camera(bContext *C, RegionView3D *rv3d, FlyInfo *fly, int orien ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist); mult_m4_m4m4(diff_mat, view_mat, prev_view_imat); mult_m4_m4m4(parent_mat, diff_mat, fly->root_parent->obmat); - object_apply_mat4(fly->root_parent, parent_mat, TRUE, FALSE); + BKE_object_apply_mat4(fly->root_parent, parent_mat, TRUE, FALSE); - // where_is_object(scene, fly->root_parent); + // BKE_object_where_is_calc(scene, fly->root_parent); ob_update = v3d->camera->parent; while (ob_update) { @@ -724,7 +724,7 @@ static void move_camera(bContext *C, RegionView3D *rv3d, FlyInfo *fly, int orien else { float view_mat[4][4]; ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist); - object_apply_mat4(v3d->camera, view_mat, TRUE, FALSE); + BKE_object_apply_mat4(v3d->camera, view_mat, TRUE, FALSE); id_key = &v3d->camera->id; } @@ -1031,7 +1031,7 @@ static int flyApply_ndof(bContext *C, FlyInfo *fly) /* shorthand for oft-used variables */ wmNDOFMotionData *ndof = fly->ndof; const float dt = ndof->dt; - RegionView3D*rv3d = fly->rv3d; + RegionView3D *rv3d = fly->rv3d; const int flag = U.ndof_flag; #if 0 diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index c4309980b18..a68caeb0719 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -431,9 +431,10 @@ static int object_mode_icon(int mode) EnumPropertyItem *item = object_mode_items; while (item->name != NULL) { - if (item->value == mode) + if (item->value == mode) { return item->icon; - ++item; + } + item++; } return ICON_OBJECT_DATAMODE; diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 66b8ceb7a85..f387e1dd844 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -53,9 +53,9 @@ struct wmWindowManager; #define BL_NEAR_CLIP 0.001 /* drawing flags: */ -#define DRAW_PICKING 1 -#define DRAW_CONSTCOLOR 2 -#define DRAW_SCENESET 4 +#define DRAW_PICKING 1 +#define DRAW_CONSTCOLOR 2 +#define DRAW_SCENESET 4 /* draw_mesh_fancy/draw_mesh_textured draw_flags */ #define DRAW_MODIFIERS_PREVIEW 1 @@ -78,6 +78,8 @@ void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot); void VIEW3D_OT_view_all(struct wmOperatorType *ot); void VIEW3D_OT_viewnumpad(struct wmOperatorType *ot); void VIEW3D_OT_view_selected(struct wmOperatorType *ot); +void VIEW3D_OT_view_lock_clear(struct wmOperatorType *ot); +void VIEW3D_OT_view_lock_to_active(struct wmOperatorType *ot); void VIEW3D_OT_view_center_cursor(struct wmOperatorType *ot); void VIEW3D_OT_view_center_camera(struct wmOperatorType *ot); void VIEW3D_OT_view_pan(struct wmOperatorType *ot); @@ -93,8 +95,8 @@ void VIEW3D_OT_render_border(struct wmOperatorType *ot); void VIEW3D_OT_zoom_border(struct wmOperatorType *ot); void view3d_boxview_copy(ScrArea *sa, ARegion *ar); -void ndof_to_quat(struct wmNDOFMotionData* ndof, float q[4]); -float ndof_to_axis_angle(struct wmNDOFMotionData* ndof, float axis[3]); +void ndof_to_quat(struct wmNDOFMotionData *ndof, float q[4]); +float ndof_to_axis_angle(struct wmNDOFMotionData *ndof, float axis[3]); /* view3d_fly.c */ void view3d_keymap(struct wmKeyConfig *keyconf); @@ -103,8 +105,8 @@ void VIEW3D_OT_fly(struct wmOperatorType *ot); /* drawanim.c */ void draw_motion_paths_init(View3D *v3d, struct ARegion *ar); void draw_motion_path_instance(Scene *scene, - struct Object *ob, struct bPoseChannel *pchan, - struct bAnimVizSettings *avs, struct bMotionPath *mpath); + struct Object *ob, struct bPoseChannel *pchan, + struct bAnimVizSettings *avs, struct bMotionPath *mpath); void draw_motion_paths_cleanup(View3D *v3d); @@ -118,23 +120,25 @@ void drawaxes(float size, char drawtype); void view3d_cached_text_draw_begin(void); void view3d_cached_text_draw_add(const float co[3], const char *str, short xoffs, short flag, const unsigned char col[4]); -void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, float mat[][4]); -#define V3D_CACHE_TEXT_ZBUF (1<<0) -#define V3D_CACHE_TEXT_WORLDSPACE (1<<1) -#define V3D_CACHE_TEXT_ASCII (1<<2) -#define V3D_CACHE_TEXT_GLOBALSPACE (1<<3) -#define V3D_CACHE_TEXT_LOCALCLIP (1<<4) +void view3d_cached_text_draw_end(View3D * v3d, ARegion * ar, int depth_write, float mat[][4]); +#define V3D_CACHE_TEXT_ZBUF (1 << 0) +#define V3D_CACHE_TEXT_WORLDSPACE (1 << 1) +#define V3D_CACHE_TEXT_ASCII (1 << 2) +#define V3D_CACHE_TEXT_GLOBALSPACE (1 << 3) +#define V3D_CACHE_TEXT_LOCALCLIP (1 << 4) /* drawarmature.c */ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, int flag, const short is_outline); /* drawmesh.c */ -void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob, struct DerivedMesh *dm, int faceselect); -void draw_mesh_paint(RegionView3D *rv3d, struct Object *ob, struct DerivedMesh *dm, int faceselect); +void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, + struct Object *ob, struct DerivedMesh *dm, const int draw_flags); +void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, + struct Object *ob, struct DerivedMesh *dm, const int draw_flags); /* view3d_draw.c */ void view3d_main_area_draw(const struct bContext *C, struct ARegion *ar); -void draw_depth(Scene *scene, struct ARegion *ar, View3D *v3d, int (* func)(void *)); +void draw_depth(Scene *scene, struct ARegion *ar, View3D *v3d, int (*func)(void *)); void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d); void add_view3d_after(ListBase *lb, Base *base, int flag); @@ -158,12 +162,12 @@ void VIEW3D_OT_localview(struct wmOperatorType *ot); void VIEW3D_OT_game_start(struct wmOperatorType *ot); -int ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[][4], struct BoundBox *bb); +int ED_view3d_boundbox_clip(RegionView3D * rv3d, float obmat[][4], struct BoundBox *bb); void smooth_view(struct bContext *C, struct View3D *v3d, struct ARegion *ar, struct Object *, struct Object *, float *ofs, float *quat, float *dist, float *lens); -void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect); /* rect: for picking */ +void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect); /* rect: for picking */ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d); void fly_modal_keymap(struct wmKeyConfig *keyconf); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 99da487f923..f760254e8d2 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -72,6 +72,8 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_background_image_add); WM_operatortype_append(VIEW3D_OT_background_image_remove); WM_operatortype_append(VIEW3D_OT_view_selected); + WM_operatortype_append(VIEW3D_OT_view_lock_clear); + WM_operatortype_append(VIEW3D_OT_view_lock_to_active); WM_operatortype_append(VIEW3D_OT_view_center_cursor); WM_operatortype_append(VIEW3D_OT_view_center_camera); WM_operatortype_append(VIEW3D_OT_select); @@ -135,7 +137,10 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "VIEW3D_OT_dolly", MIDDLEMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_view_center_cursor", PADPERIOD, KM_PRESS, KM_CTRL, 0); - + + WM_keymap_verify_item(keymap, "VIEW3D_OT_view_lock_to_active", PADPERIOD, KM_PRESS, KM_SHIFT, 0); + WM_keymap_verify_item(keymap, "VIEW3D_OT_view_lock_clear", PADPERIOD, KM_PRESS, KM_ALT, 0); + WM_keymap_verify_item(keymap, "VIEW3D_OT_fly", FKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_smoothview", TIMER1, KM_ANY, KM_ANY, 0); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index f106fcc268e..d7b03447d5b 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1407,7 +1407,7 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce /* index of bundle is 1<<16-based. if there's no "bone" index * in hight word, this buffer value belongs to camera,. not to bundle */ if (buffer[4 * i + 3] & 0xFFFF0000) { - MovieClip *clip = object_get_movieclip(scene, basact->object, 0); + MovieClip *clip = BKE_object_movieclip_get(scene, basact->object, 0); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase; MovieTrackingTrack *track; @@ -2055,7 +2055,7 @@ static int vertsel_vert_pick(struct bContext *C, Mesh *me, const int mval[2], un /* gets called via generic mouse select operator */ static int mouse_weight_paint_vertex_select(bContext *C, const int mval[2], short extend, Object *obact) { - Mesh*me = obact->data; /* already checked for NULL */ + Mesh *me = obact->data; /* already checked for NULL */ unsigned int index = 0; MVert *mv; diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 87edf6a37a0..367b36db583 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -582,7 +582,7 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) mul_m4_v3(ob->imat, vec); /* Get location of grid point in pose space. */ - armature_loc_pose_to_bone(pchan, vec, vec); + BKE_armature_loc_pose_to_bone(pchan, vec, vec); /* adjust location */ if ((pchan->protectflag & OB_LOCK_LOCX) == 0) @@ -613,7 +613,7 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) vec[2] = -ob->obmat[3][2] + gridf *floorf(0.5f + ob->obmat[3][2] / gridf); if (ob->parent) { - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); invert_m3_m3(imat, originmat); mul_m3_v3(imat, vec); @@ -707,7 +707,7 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) if (pchan->bone->layer & arm->layer) { if ((pchan->bone->flag & BONE_CONNECTED) == 0) { /* Get position in pchan (pose) space. */ - armature_loc_pose_to_bone(pchan, vec, vec); + BKE_armature_loc_pose_to_bone(pchan, vec, vec); /* copy new position */ if ((pchan->protectflag & OB_LOCK_LOCX) == 0) @@ -738,7 +738,7 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) vec[2] = -ob->obmat[3][2] + curs[2]; if (ob->parent) { - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); invert_m3_m3(imat, originmat); mul_m3_v3(imat, vec); @@ -818,7 +818,7 @@ void VIEW3D_OT_snap_cursor_to_grid(wmOperatorType *ot) static void bundle_midpoint(Scene *scene, Object *ob, float vec[3]) { - MovieClip *clip = object_get_movieclip(scene, ob, 0); + MovieClip *clip = BKE_object_movieclip_get(scene, ob, 0); MovieTracking *tracking; MovieTrackingObject *object; int ok = 0; diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 733c5c55bfc..95ae0ac971f 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -358,11 +358,11 @@ static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op)) rv3d->lpersp = rv3d->persp; } - object_tfm_protected_backup(v3d->camera, &obtfm); + BKE_object_tfm_protected_backup(v3d->camera, &obtfm); ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist); - object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag); + BKE_object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag); DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); rv3d->persp = RV3D_CAMOB; @@ -421,9 +421,9 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *UNUSED(o copy_v3_v3(obmat_new[3], r_co); /* only touch location */ - object_tfm_protected_backup(camera_ob, &obtfm); - object_apply_mat4(camera_ob, obmat_new, TRUE, TRUE); - object_tfm_protected_restore(camera_ob, &obtfm, OB_LOCK_SCALE | OB_LOCK_ROT4D); + BKE_object_tfm_protected_backup(camera_ob, &obtfm); + BKE_object_apply_mat4(camera_ob, obmat_new, TRUE, TRUE); + BKE_object_tfm_protected_restore(camera_ob, &obtfm, OB_LOCK_SCALE | OB_LOCK_ROT4D); /* notifiers */ DAG_id_tag_update(&camera_ob->id, OB_RECALC_OB); @@ -567,9 +567,9 @@ void ED_view3d_calc_clipping(BoundBox *bb, float planes[4][4], bglMats *mats, co if (flip_sign) negate_v3(planes[val]); - planes[val][3] = -planes[val][0] * bb->vec[val][0] - - planes[val][1] * bb->vec[val][1] - - planes[val][2] * bb->vec[val][2]; + planes[val][3] = -planes[val][0] * bb->vec[val][0] - + planes[val][1] * bb->vec[val][1] - + planes[val][2] * bb->vec[val][2]; } } @@ -1155,7 +1155,7 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d) { if (rv3d->persp == RV3D_CAMOB) { /* obs/camera */ if (v3d->camera) { - where_is_object(scene, v3d->camera); + BKE_object_where_is_calc(scene, v3d->camera); obmat_to_viewmat(v3d, rv3d, v3d->camera, 0); } else { @@ -1176,7 +1176,7 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d) copy_v3_v3(vec, ob->obmat[3]); if (ob->type == OB_ARMATURE && v3d->ob_centre_bone[0]) { - bPoseChannel *pchan = get_pose_channel(ob->pose, v3d->ob_centre_bone); + bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, v3d->ob_centre_bone); if (pchan) { copy_v3_v3(vec, pchan->pose_mat[3]); mul_m4_v3(ob->obmat, vec); @@ -1412,7 +1412,7 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) } else { if (scene->obedit) { - minmax_object(scene->obedit, min, max); + BKE_object_minmax(scene->obedit, min, max); ok = 1; @@ -1422,7 +1422,7 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) else { for (base = FIRSTBASE; base; base = base->next) { if (TESTBASE(v3d, base)) { - minmax_object(base->object, min, max); + BKE_object_minmax(base->object, min, max); base->lay |= locallay; base->object->lay = base->lay; ok = 1; @@ -1799,8 +1799,8 @@ static int game_engine_exec(bContext *C, wmOperator *op) RestoreState(C, prevwin); //XXX restore_all_scene_cfra(scene_cfra_store); - set_scene_bg(CTX_data_main(C), startscene); - //XXX scene_update_for_newframe(bmain, scene, scene->lay); + BKE_scene_set_background(CTX_data_main(C), startscene); + //XXX BKE_scene_update_for_newframe(bmain, scene, scene->lay); return OPERATOR_FINISHED; #else |