[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56172] trunk/blender: uv project from camera now sets defaults so the image maps to the camera bounds ,
Campbell Barton
ideasman42 at gmail.com
Fri Apr 19 17:50:17 CEST 2013
Revision: 56172
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56172
Author: campbellbarton
Date: 2013-04-19 15:50:17 +0000 (Fri, 19 Apr 2013)
Log Message:
-----------
uv project from camera now sets defaults so the image maps to the camera bounds,
also rename newly added `Mesh Debug` -> `Mesh Analysis`
Modified Paths:
--------------
trunk/blender/release/scripts/startup/bl_ui/space_view3d.py
trunk/blender/source/blender/editors/uvedit/uvedit_unwrap_ops.c
Modified: trunk/blender/release/scripts/startup/bl_ui/space_view3d.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_view3d.py 2013-04-19 15:46:32 UTC (rev 56171)
+++ trunk/blender/release/scripts/startup/bl_ui/space_view3d.py 2013-04-19 15:50:17 UTC (rev 56172)
@@ -323,7 +323,7 @@
layout.separator()
- layout.operator_context = 'EXEC_REGION_WIN'
+ layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("uv.project_from_view").scale_to_bounds = False
layout.operator("uv.project_from_view", text="Project from View (Bounds)").scale_to_bounds = True
@@ -2610,7 +2610,7 @@
class VIEW3D_PT_view3d_meshstatvis(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
- bl_label = "Mesh Debug"
+ bl_label = "Mesh Analysis"
@classmethod
def poll(cls, context):
Modified: trunk/blender/source/blender/editors/uvedit/uvedit_unwrap_ops.c
===================================================================
--- trunk/blender/source/blender/editors/uvedit/uvedit_unwrap_ops.c 2013-04-19 15:46:32 UTC (rev 56171)
+++ trunk/blender/source/blender/editors/uvedit/uvedit_unwrap_ops.c 2013-04-19 15:50:17 UTC (rev 56172)
@@ -1243,16 +1243,45 @@
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 @@
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 @@
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;
More information about the Bf-blender-cvs
mailing list