Fix T55547: "Fit camera to selected" fails
This commit is contained in:
@@ -126,7 +126,7 @@ void BKE_camera_view_frame(
|
||||
|
||||
bool BKE_camera_view_frame_fit_to_scene(
|
||||
struct Depsgraph *depsgraph,
|
||||
struct Scene *scene, struct ViewLayer *view_layer, struct Object *camera_ob,
|
||||
struct Scene *scene, struct Object *camera_ob,
|
||||
float r_co[3], float *r_scale);
|
||||
bool BKE_camera_view_frame_fit_to_coords(
|
||||
const struct Depsgraph *depsgraph,
|
||||
@@ -155,4 +155,3 @@ void BKE_camera_background_image_clear(struct Camera *cam);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -183,8 +183,6 @@ void BKE_object_foreach_display_point(
|
||||
void (*func_cb)(const float[3], void *), void *user_data);
|
||||
void BKE_scene_foreach_display_point(
|
||||
struct Depsgraph *depsgraph,
|
||||
struct Scene *scene,
|
||||
struct ViewLayer *view_layer,
|
||||
void (*func_cb)(const float[3], void *), void *user_data);
|
||||
|
||||
bool BKE_object_parent_loop_check(const struct Object *parent, const struct Object *ob);
|
||||
|
||||
@@ -649,7 +649,7 @@ static bool camera_frame_fit_calc_from_data(
|
||||
/* don't move the camera, just yield the fit location */
|
||||
/* r_scale only valid/useful for ortho cameras */
|
||||
bool BKE_camera_view_frame_fit_to_scene(
|
||||
Depsgraph *depsgraph, Scene *scene, ViewLayer *view_layer, Object *camera_ob, float r_co[3], float *r_scale)
|
||||
Depsgraph *depsgraph, Scene *scene, Object *camera_ob, float r_co[3], float *r_scale)
|
||||
{
|
||||
CameraParams params;
|
||||
CameraViewFrameData data_cb;
|
||||
@@ -660,7 +660,7 @@ bool BKE_camera_view_frame_fit_to_scene(
|
||||
camera_frame_fit_data_init(scene, camera_ob, ¶ms, &data_cb);
|
||||
|
||||
/* run callback on all visible points */
|
||||
BKE_scene_foreach_display_point(depsgraph, scene, view_layer, camera_to_frame_view_cb, &data_cb);
|
||||
BKE_scene_foreach_display_point(depsgraph, camera_to_frame_view_cb, &data_cb);
|
||||
|
||||
return camera_frame_fit_calc_from_data(¶ms, &data_cb, r_co, r_scale);
|
||||
}
|
||||
|
||||
@@ -2530,13 +2530,11 @@ void BKE_object_foreach_display_point(
|
||||
{
|
||||
float co[3];
|
||||
|
||||
if (ob->derivedFinal) {
|
||||
DerivedMesh *dm = ob->derivedFinal;
|
||||
MVert *mv = dm->getVertArray(dm);
|
||||
int totvert = dm->getNumVerts(dm);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < totvert; i++, mv++) {
|
||||
if (ob->runtime.mesh_eval) {
|
||||
const Mesh *me = ob->runtime.mesh_eval;
|
||||
const MVert *mv = me->mvert;
|
||||
const int totvert = me->totvert;
|
||||
for (int i = 0; i < totvert; i++, mv++) {
|
||||
mul_v3_m4v3(co, obmat, mv->co);
|
||||
func_cb(co, user_data);
|
||||
}
|
||||
@@ -2558,33 +2556,20 @@ void BKE_object_foreach_display_point(
|
||||
}
|
||||
|
||||
void BKE_scene_foreach_display_point(
|
||||
Depsgraph *depsgraph, Scene *scene, ViewLayer *view_layer,
|
||||
Depsgraph *depsgraph,
|
||||
void (*func_cb)(const float[3], void *), void *user_data)
|
||||
{
|
||||
Base *base;
|
||||
Object *ob;
|
||||
|
||||
for (base = FIRSTBASE(view_layer); base; base = base->next) {
|
||||
if (((base->flag & BASE_VISIBLED) != 0) && ((base->flag & BASE_SELECTED) != 0)) {
|
||||
ob = base->object;
|
||||
|
||||
if ((ob->transflag & OB_DUPLI) == 0) {
|
||||
BKE_object_foreach_display_point(ob, ob->obmat, func_cb, user_data);
|
||||
}
|
||||
else {
|
||||
ListBase *lb;
|
||||
DupliObject *dob;
|
||||
|
||||
lb = object_duplilist(depsgraph, scene, ob);
|
||||
for (dob = lb->first; dob; dob = dob->next) {
|
||||
if (dob->no_draw == 0) {
|
||||
BKE_object_foreach_display_point(dob->ob, dob->mat, func_cb, user_data);
|
||||
}
|
||||
}
|
||||
free_object_duplilist(lb); /* does restore */
|
||||
}
|
||||
DEG_OBJECT_ITER_BEGIN(
|
||||
depsgraph, ob,
|
||||
DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
|
||||
DEG_ITER_OBJECT_FLAG_VISIBLE |
|
||||
DEG_ITER_OBJECT_FLAG_DUPLI)
|
||||
{
|
||||
if ((ob->base_flag & BASE_SELECTED) != 0) {
|
||||
BKE_object_foreach_display_point(ob, ob->obmat, func_cb, user_data);
|
||||
}
|
||||
}
|
||||
DEG_OBJECT_ITER_END;
|
||||
}
|
||||
|
||||
/* copied from DNA_object_types.h */
|
||||
|
||||
@@ -509,7 +509,6 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
View3D *v3d = CTX_wm_view3d(C); /* can be NULL */
|
||||
Object *camera_ob = v3d ? v3d->camera : scene->camera;
|
||||
Object *camera_ob_eval = DEG_get_evaluated_object(depsgraph, camera_ob);
|
||||
@@ -523,7 +522,7 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
/* this function does all the important stuff */
|
||||
if (BKE_camera_view_frame_fit_to_scene(depsgraph, scene, view_layer, camera_ob_eval, r_co, &r_scale)) {
|
||||
if (BKE_camera_view_frame_fit_to_scene(depsgraph, scene, camera_ob_eval, r_co, &r_scale)) {
|
||||
ObjectTfmProtectedChannels obtfm;
|
||||
float obmat_new[4][4];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user