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
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/uvedit')
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c2
-rw-r--r--source/blender/editors/uvedit/uvedit_intern.h2
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c50
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c69
4 files changed, 72 insertions, 51 deletions
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index c5dccc14b03..17010c25e31 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
diff --git a/source/blender/editors/uvedit/uvedit_intern.h b/source/blender/editors/uvedit/uvedit_intern.h
index e9d128adc3a..5dabaf91b1a 100644
--- a/source/blender/editors/uvedit/uvedit_intern.h
+++ b/source/blender/editors/uvedit/uvedit_intern.h
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index a0e0ec30912..8998b59b353 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
@@ -1037,14 +1037,14 @@ static int align_exec(bContext *C, wmOperator *op)
void UV_OT_align(wmOperatorType *ot)
{
static EnumPropertyItem axis_items[] = {
- {'a', "ALIGN_AUTO", 0, "Align Auto", "Automatically choose the axis on which there is most alignment already."},
- {'x', "ALIGN_X", 0, "Align X", "Align UVs on X axis."},
- {'y', "ALIGN_Y", 0, "Align Y", "Align UVs on Y axis."},
+ {'a', "ALIGN_AUTO", 0, "Align Auto", "Automatically choose the axis on which there is most alignment already"},
+ {'x', "ALIGN_X", 0, "Align X", "Align UVs on X axis"},
+ {'y', "ALIGN_Y", 0, "Align Y", "Align UVs on Y axis"},
{0, NULL, 0, NULL, NULL}};
/* identifiers */
ot->name= "Align";
- ot->description= "Align selected UV vertices to an axis.";
+ ot->description= "Align selected UV vertices to an axis";
ot->idname= "UV_OT_align";
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1069,7 +1069,7 @@ void UV_OT_weld(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Weld";
- ot->description= "Weld selected UV vertices together.";
+ ot->description= "Weld selected UV vertices together";
ot->idname= "UV_OT_weld";
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1255,7 +1255,7 @@ void UV_OT_stitch(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Stitch";
- ot->description= "Stitch selected UV vertices by proximity.";
+ ot->description= "Stitch selected UV vertices by proximity";
ot->idname= "UV_OT_stitch";
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1312,7 +1312,7 @@ void UV_OT_select_inverse(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Select Inverse";
- ot->description= "Select inverse of (un)selected UV vertices.";
+ ot->description= "Select inverse of (un)selected UV vertices";
ot->idname= "UV_OT_select_inverse";
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1412,7 +1412,7 @@ void UV_OT_select_all(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Select or Deselect All";
- ot->description= "Change selection of all UV vertices.";
+ ot->description= "Change selection of all UV vertices";
ot->idname= "UV_OT_select_all";
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1747,7 +1747,7 @@ void UV_OT_select(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Select";
- ot->description= "Select UV vertice.";
+ ot->description= "Select UV vertice";
ot->idname= "UV_OT_select";
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1796,7 +1796,7 @@ void UV_OT_select_loop(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Loop Select";
- ot->description= "Select a loop of connected UV vertices.";
+ ot->description= "Select a loop of connected UV vertices";
ot->idname= "UV_OT_select_loop";
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1877,7 +1877,7 @@ void UV_OT_select_linked(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Select Linked";
- ot->description= "Select all UV vertices linked to the active UV map.";
+ ot->description= "Select all UV vertices linked to the active UV map";
ot->idname= "UV_OT_select_linked";
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1904,7 +1904,7 @@ void UV_OT_select_linked_pick(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Select Linked Pick";
- ot->description= "Select all UV vertices linked under the mouse.";
+ ot->description= "Select all UV vertices linked under the mouse";
ot->idname= "UV_OT_select_linked_pick";
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1965,7 +1965,7 @@ void UV_OT_unlink_selection(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Unlink Selection";
- ot->description= "Unlink selected UV vertices from active UV map.";
+ ot->description= "Unlink selected UV vertices from active UV map";
ot->idname= "UV_OT_unlink_selection";
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -2246,7 +2246,7 @@ void UV_OT_select_border(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Border Select";
- ot->description= "Select UV vertices using border selection.";
+ ot->description= "Select UV vertices using border selection";
ot->idname= "UV_OT_select_border";
/* api callbacks */
@@ -2335,7 +2335,7 @@ void UV_OT_circle_select(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Circle Select";
- ot->description= "Select UV vertices using circle selection.";
+ ot->description= "Select UV vertices using circle selection";
ot->idname= "UV_OT_circle_select";
/* api callbacks */
@@ -2411,7 +2411,7 @@ void UV_OT_snap_cursor(wmOperatorType *ot)
/* identifiers */
ot->name= "Snap Cursor";
- ot->description= "Snap cursor to target type.";
+ ot->description= "Snap cursor to target type";
ot->idname= "UV_OT_snap_cursor";
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -2653,7 +2653,7 @@ void UV_OT_snap_selection(wmOperatorType *ot)
/* identifiers */
ot->name= "Snap Selection";
- ot->description= "Snap selected UV vertices to target type.";
+ ot->description= "Snap selected UV vertices to target type";
ot->idname= "UV_OT_snap_selection";
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -2708,7 +2708,7 @@ void UV_OT_pin(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Pin";
- ot->description= "Set/clear selected UV vertices as anchored between multiple unwrap operations.";
+ ot->description= "Set/clear selected UV vertices as anchored between multiple unwrap operations";
ot->idname= "UV_OT_pin";
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -2754,7 +2754,7 @@ void UV_OT_select_pinned(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Selected Pinned";
- ot->description= "Select all pinned UV vertices.";
+ ot->description= "Select all pinned UV vertices";
ot->idname= "UV_OT_select_pinned";
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -2896,7 +2896,7 @@ void UV_OT_hide(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Hide Selected";
- ot->description= "Hide (un)selected UV vertices.";
+ ot->description= "Hide (un)selected UV vertices";
ot->idname= "UV_OT_hide";
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -3030,7 +3030,7 @@ void UV_OT_reveal(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Reveal Hidden";
- ot->description= "Reveal all hidden UV vertices.";
+ ot->description= "Reveal all hidden UV vertices";
ot->idname= "UV_OT_reveal";
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -3073,7 +3073,7 @@ void UV_OT_cursor_set(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Set 2D Cursor";
- ot->description= "Set 2D cursor location.";
+ ot->description= "Set 2D cursor location";
ot->idname= "UV_OT_cursor_set";
/* api callbacks */
@@ -3139,7 +3139,7 @@ void UV_OT_tile_set(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Set Tile";
- ot->description= "Set UV image tile coordinates.";
+ ot->description= "Set UV image tile coordinates";
ot->idname= "UV_OT_tile_set";
/* api callbacks */
@@ -3223,6 +3223,8 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "UV_OT_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "UV_OT_select_pinned", PKEY, KM_PRESS, KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, "UV_OT_weld", WKEY, KM_PRESS, 0, 0);
+
/* uv operations */
WM_keymap_add_item(keymap, "UV_OT_stitch", VKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "UV_OT_pin", PKEY, KM_PRESS, 0, 0);
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 3dff61505c5..eecf091c46b 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
@@ -668,14 +668,14 @@ static void uv_map_transform(bContext *C, wmOperator *op, float center[3], float
static void uv_transform_properties(wmOperatorType *ot, int radius)
{
static EnumPropertyItem direction_items[]= {
- {VIEW_ON_EQUATOR, "VIEW_ON_EQUATOR", 0, "View on Equator", "3D view is on the equator."},
- {VIEW_ON_POLES, "VIEW_ON_POLES", 0, "View on Poles", "3D view is on the poles."},
- {ALIGN_TO_OBJECT, "ALIGN_TO_OBJECT", 0, "Align to Object", "Align according to object transform."},
+ {VIEW_ON_EQUATOR, "VIEW_ON_EQUATOR", 0, "View on Equator", "3D view is on the equator"},
+ {VIEW_ON_POLES, "VIEW_ON_POLES", 0, "View on Poles", "3D view is on the poles"},
+ {ALIGN_TO_OBJECT, "ALIGN_TO_OBJECT", 0, "Align to Object", "Align according to object transform"},
{0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem align_items[]= {
- {POLAR_ZX, "POLAR_ZX", 0, "Polar ZX", "Polar 0 is X."},
- {POLAR_ZY, "POLAR_ZY", 0, "Polar ZY", "Polar 0 is Y."},
+ {POLAR_ZX, "POLAR_ZX", 0, "Polar ZX", "Polar 0 is X"},
+ {POLAR_ZY, "POLAR_ZY", 0, "Polar ZY", "Polar 0 is Y"},
{0, NULL, 0, NULL, NULL}
};
@@ -881,9 +881,8 @@ static void uv_from_view_bounds(float target[2], float source[3], float rotmat[4
target[1] = pv[2];
}
-static void uv_from_camera(float camsize, float xasp, float yasp, float target[2], float source[3], float rotmat[4][4], float cammat[4][4], int persp)
+static void uv_from_camera(float camsize, float camangle, float xasp, float yasp, float target[2], float source[3], float rotmat[4][4], float cammat[4][4], int persp, int pano)
{
-
float pv4[4];
copy_v3_v3(pv4, source);
@@ -895,15 +894,31 @@ static void uv_from_camera(float camsize, float xasp, float yasp, float target[2
/* cammat is the inverse camera matrix */
mul_m4_v4(cammat, pv4);
- if (pv4[2]==0.0f) pv4[2]=0.00001f; /* don't allow div by 0 */
-
- if (persp&&CAM_ORTHO) {
- target[0]=((pv4[0]/camsize)*xasp)+0.5f;
- target[1]=((pv4[1]/camsize)*yasp)+0.5f;
+ if(pano) {
+ float angle= atan2f(pv4[0], -pv4[2]) / (M_PI * 2.0); /* angle around the camera */
+ if (persp & CAM_ORTHO) {
+ target[0] = angle; /* no correct method here, just map to 0-1 */
+ target[1] = pv4[1] / camsize;
+ }
+ else {
+ float vec2d[2]= {pv4[0], pv4[2]}; /* 2D position from the camera */
+ target[0] = angle * (M_PI / camangle);
+ target[1] = pv4[1] / (len_v2(vec2d) * camsize);
+ }
+ target[0]+= 0.5f; /* aspect is ignored for now */
+ target[1]+= 0.5f;
}
else {
- target[0]=((-pv4[0]*(camsize/pv4[2])*xasp)/2)+0.5;
- target[1]=((-pv4[1]*(camsize/pv4[2])*yasp)/2)+0.5;
+ if (pv4[2]==0.0f) pv4[2]=0.00001f; /* don't allow div by 0 */
+
+ if (persp & CAM_ORTHO) {
+ target[0]=((pv4[0]/camsize)*xasp)+0.5f;
+ target[1]=((pv4[1]/camsize)*yasp)+0.5f;
+ }
+ else {
+ target[0]=((-pv4[0]*((1.0f/camsize)/pv4[2])*xasp)/2)+0.5;
+ target[1]=((-pv4[1]*((1.0f/camsize)/pv4[2])*yasp)/2)+0.5;
+ }
}
}
@@ -956,11 +971,12 @@ static int from_view_exec(bContext *C, wmOperator *op)
Camera *camera= NULL;
EditMesh *em= BKE_mesh_get_editmesh((Mesh*)obedit->data);
ARegion *ar= CTX_wm_region(C);
+ View3D *v3d= CTX_wm_view3d(C);
RegionView3D *rv3d= ar->regiondata;
EditFace *efa;
MTFace *tf;
float invmat[4][4],rotmat[4][4];
- float xasp, yasp, camsize;
+ float xasp, yasp, camsize, camangle;
/* add uvs if they don't exist yet */
if(!ED_uvedit_ensure_uvs(C, scene, obedit)) {
@@ -969,8 +985,8 @@ static int from_view_exec(bContext *C, wmOperator *op)
}
/* establish the camera object, so we can default to view mapping if anything is wrong with it */
- if ((rv3d->persp==RV3D_CAMOB) && (scene->camera) && (scene->camera->type==OB_CAMERA)) {
- camera=scene->camera->data;
+ if ((rv3d->persp==RV3D_CAMOB) && (v3d->camera) && (v3d->camera->type==OB_CAMERA)) {
+ camera= v3d->camera->data;
}
if(RNA_boolean_get(op->ptr, "orthographic")) {
@@ -989,15 +1005,18 @@ static int from_view_exec(bContext *C, wmOperator *op)
}
}
else if (camera) {
-
+ int pano = camera->flag & CAM_PANORAMA;
+ camangle= DEG2RAD(camera->angle)/2.0f;
+
if (camera->type==CAM_PERSP) {
- camsize=1/tan(DEG2RAD(camera->angle)/2.0f); /* calcs ez as distance from camera plane to viewer */
+ camsize= tanf(camangle); /* calcs ez as distance from camera plane to viewer */
}
else {
camsize=camera->ortho_scale;
}
- if (invert_m4_m4(invmat,scene->camera->obmat)) {
+ if (invert_m4_m4(invmat, v3d->camera->obmat)) {
+ /* normal projection */
copy_m4_m4(rotmat, obedit->obmat);
/* also make aspect ratio adjustment factors */
@@ -1014,11 +1033,11 @@ static int from_view_exec(bContext *C, wmOperator *op)
if(efa->f & SELECT) {
tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
- uv_from_camera(camsize, xasp, yasp, tf->uv[0], efa->v1->co, rotmat, invmat, camera->type);
- uv_from_camera(camsize, xasp, yasp, tf->uv[1], efa->v2->co, rotmat, invmat, camera->type);
- uv_from_camera(camsize, xasp, yasp, tf->uv[2], efa->v3->co, rotmat, invmat, camera->type);
+ uv_from_camera(camsize, camangle, xasp, yasp, tf->uv[0], efa->v1->co, rotmat, invmat, camera->type, pano);
+ uv_from_camera(camsize, camangle, xasp, yasp, tf->uv[1], efa->v2->co, rotmat, invmat, camera->type, pano);
+ uv_from_camera(camsize, camangle, xasp, yasp, tf->uv[2], efa->v3->co, rotmat, invmat, camera->type, pano);
if(efa->v4)
- uv_from_camera(camsize, xasp, yasp, tf->uv[3], efa->v4->co, rotmat, invmat, camera->type);
+ uv_from_camera(camsize, camangle, xasp, yasp, tf->uv[3], efa->v4->co, rotmat, invmat, camera->type, pano);
}
}
}