add poll function for VIEW3D_OT_camera_to_view_selected & remove some unused code.

also made it so copying camera sets the dof object to extern.
This commit is contained in:
Campbell Barton 2011-11-19 01:24:40 +00:00
parent 4924abaad6
commit f3613be1fb
4 changed files with 28 additions and 15 deletions

@ -94,7 +94,6 @@ void object_to_mat3(struct Object *ob, float mat[][3]);
void object_to_mat4(struct Object *ob, float mat[][4]);
void object_apply_mat4(struct Object *ob, float mat[][4], const short use_compat, const short use_parent);
void set_no_parent_ipo(int val);
struct Object *object_pose_armature_get(struct Object *ob);
void where_is_object_time(struct Scene *scene, struct Object *ob, float ctime);

@ -74,7 +74,9 @@ Camera *copy_camera(Camera *cam)
Camera *camn;
camn= copy_libblock(&cam->id);
id_lib_extern((ID *)camn->dof_ob);
return camn;
}
@ -454,6 +456,7 @@ static void camera_to_frame_view_cb(const float co[3], void *user_data)
}
/* dont move the camera, just yield the fit location */
/* only valid for perspective cameras */
int camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object *camera_ob, float r_co[3])
{
float shift[2];

@ -1887,13 +1887,6 @@ static void ob_parvert3(Object *ob, Object *par, float mat[][4])
}
}
// XXX what the hell is this?
static int no_parent_ipo=0;
void set_no_parent_ipo(int val)
{
no_parent_ipo= val;
}
static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[4][4])
{
float *fp1, *fp2;
@ -1933,7 +1926,7 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime)
/* hurms, code below conflicts with depgraph... (ton) */
/* and even worse, it gives bad effects for NLA stride too (try ctime != par->ctime, with MBlur) */
if(no_parent_ipo==0 && stime != par->ctime) {
if(stime != par->ctime) {
// only for ipo systems?
Object tmp= *par;

@ -342,7 +342,7 @@ void VIEW3D_OT_smoothview(wmOperatorType *ot)
/* ****************** change view operators ****************** */
static int view3d_setcameratoview_exec(bContext *C, wmOperator *UNUSED(op))
static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op))
{
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d= CTX_wm_region_view3d(C);
@ -369,7 +369,7 @@ static int view3d_setcameratoview_exec(bContext *C, wmOperator *UNUSED(op))
}
static int view3d_setcameratoview_poll(bContext *C)
static int view3d_camera_to_view_poll(bContext *C)
{
View3D *v3d= CTX_wm_view3d(C);
if(v3d && v3d->camera && v3d->camera->id.lib==NULL) {
@ -390,8 +390,8 @@ void VIEW3D_OT_camera_to_view(wmOperatorType *ot)
ot->idname= "VIEW3D_OT_camera_to_view";
/* api callbacks */
ot->exec= view3d_setcameratoview_exec;
ot->poll= view3d_setcameratoview_poll;
ot->exec= view3d_camera_to_view_exec;
ot->poll= view3d_camera_to_view_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@ -431,6 +431,24 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *UNUSED(o
}
}
static int view3d_camera_to_view_selected_poll(bContext *C)
{
View3D *v3d= CTX_wm_view3d(C);
if(v3d && v3d->camera && v3d->camera->id.lib==NULL) {
RegionView3D *rv3d= CTX_wm_region_view3d(C);
if(rv3d) {
if (rv3d->is_persp == FALSE) {
CTX_wm_operator_poll_msg_set(C, "Only valid for a perspective camera view");
}
else if (!rv3d->viewlock) {
return 1;
}
}
}
return 0;
}
void VIEW3D_OT_camera_to_view_selected(wmOperatorType *ot)
{
/* identifiers */
@ -440,7 +458,7 @@ void VIEW3D_OT_camera_to_view_selected(wmOperatorType *ot)
/* api callbacks */
ot->exec= view3d_camera_to_view_selected_exec;
// ot->poll= view3d_setcameratoview_poll;
ot->poll= view3d_camera_to_view_selected_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;