Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-04-19 19:50:17 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-04-19 19:50:17 +0400
commit98ef2d1d2e8115185b41d51e94cd2755eedd7867 (patch)
tree8edec98ec71a7f00a9655ce90711168ebfe06ee8 /source
parent7776e7e7d8b8ed54054216c3ad04e429557c543b (diff)
uv project from camera now sets defaults so the image maps to the camera bounds,
also rename newly added `Mesh Debug` -> `Mesh Analysis`
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 2f4847eb619..dd124edbf6a 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -1243,16 +1243,45 @@ void UV_OT_unwrap(wmOperatorType *ot)
RNA_def_float_factor(ot->srna, "margin", 0.001f, 0.0f, 1.0f, "Margin", "Space between islands", 0.0f, 1.0f);
}
+/* NOTE: could be generic function */
+static Camera *view3d_camera_get(View3D *v3d, RegionView3D *rv3d)
+{
+ /* establish the camera object, so we can default to view mapping if anything is wrong with it */
+ if ((rv3d->persp == RV3D_CAMOB) && (v3d->camera) && (v3d->camera->type == OB_CAMERA)) {
+ return v3d->camera->data;
+ }
+ else {
+ return NULL;
+ }
+}
+
/**************** Project From View operator **************/
+static int uv_from_view_exec(bContext *C, wmOperator *op);
+
+static int uv_from_view_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ View3D *v3d = CTX_wm_view3d(C);
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
+ Camera *camera = view3d_camera_get(v3d, rv3d);
+ PropertyRNA *prop;
+
+ prop = RNA_struct_find_property(op->ptr, "camera_bounds");
+ if (!RNA_property_is_set(op->ptr, prop)) RNA_property_boolean_set(op->ptr, prop, (camera != NULL));
+ prop = RNA_struct_find_property(op->ptr, "correct_aspect");
+ if (!RNA_property_is_set(op->ptr, prop)) RNA_property_boolean_set(op->ptr, prop, (camera == NULL));
+
+ return uv_from_view_exec(C, op);
+}
+
static int uv_from_view_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
- Camera *camera = NULL;
BMEditMesh *em = BKE_editmesh_from_object(obedit);
ARegion *ar = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
+ Camera *camera = view3d_camera_get(v3d, rv3d);
BMFace *efa;
BMLoop *l;
BMIter iter, liter;
@@ -1268,11 +1297,6 @@ static int uv_from_view_exec(bContext *C, wmOperator *op)
cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
- /* establish the camera object, so we can default to view mapping if anything is wrong with it */
- if ((rv3d->persp == RV3D_CAMOB) && (v3d->camera) && (v3d->camera->type == OB_CAMERA)) {
- camera = v3d->camera->data;
- }
-
if (RNA_boolean_get(op->ptr, "orthographic")) {
uv_map_rotation_matrix(rotmat, rv3d, obedit, 90.0f, 0.0f, 1.0f);
@@ -1351,6 +1375,7 @@ void UV_OT_project_from_view(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* api callbacks */
+ ot->invoke = uv_from_view_invoke;
ot->exec = uv_from_view_exec;
ot->poll = uv_from_view_poll;