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:
authorJoseph Eagar <joeedh@gmail.com>2010-07-19 08:44:37 +0400
committerJoseph Eagar <joeedh@gmail.com>2010-07-19 08:44:37 +0400
commitc11c196efadf5ef52293d782638497f86a209722 (patch)
tree43abcd60b2400d28db8686f4dbea68f17475ef58 /source/blender/editors/uvedit
parentf54aa7811029c90b6071ccc9e27e57a758e5884d (diff)
parent7f083c45bee15f7540e2a35a725efe28fc962239 (diff)
part 1 of merge from trunk at r30358; it compiles, but doesn't link quite yet :)
Diffstat (limited to 'source/blender/editors/uvedit')
-rw-r--r--source/blender/editors/uvedit/CMakeLists.txt36
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c17
-rw-r--r--source/blender/editors/uvedit/uvedit_intern.h2
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c42
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c92
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.h18
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c162
7 files changed, 129 insertions, 240 deletions
diff --git a/source/blender/editors/uvedit/CMakeLists.txt b/source/blender/editors/uvedit/CMakeLists.txt
new file mode 100644
index 00000000000..bb6caece99f
--- /dev/null
+++ b/source/blender/editors/uvedit/CMakeLists.txt
@@ -0,0 +1,36 @@
+# $Id: CMakeLists.txt 12931 2007-12-17 18:20:48Z theeth $
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Contributor(s): Jacques Beaurain.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+FILE(GLOB SRC *.c)
+
+SET(INC
+ ../../blenkernel
+ ../../blenlib
+ ../../bmesh
+ ../include
+ ../../../../intern/guardedalloc
+ ../../../../intern/opennl/extern
+ ../../makesdna
+ ../../makesrna
+ ../../windowmanager
+)
+
+BLENDERLIB(bf_editor_uvedit "${SRC}" "${INC}")
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index f13ea513987..7c6c37872f7 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -62,7 +62,6 @@
static void drawcursor_sima(SpaceImage *sima, ARegion *ar)
{
- View2D *v2d= &ar->v2d;
float zoomx, zoomy, w, h;
int width, height;
@@ -73,7 +72,7 @@ static void drawcursor_sima(SpaceImage *sima, ARegion *ar)
h= zoomy*height/256.0f;
cpack(0xFFFFFF);
- glTranslatef(v2d->cursor[0], v2d->cursor[1], 0.0f);
+ glTranslatef(sima->cursor[0], sima->cursor[1], 0.0f);
fdrawline(-0.05/w, 0, 0, 0.05/h);
fdrawline(0, 0.05/h, 0.05/w, 0);
fdrawline(0.05/w, 0, 0, -0.05/h);
@@ -101,7 +100,7 @@ static void drawcursor_sima(SpaceImage *sima, ARegion *ar)
fdrawline(0, -0.020/h, 0, -0.1/h);
fdrawline(0, 0.1/h, 0, 0.020/h);
- glTranslatef(-v2d->cursor[0], -v2d->cursor[1], 0.0f);
+ glTranslatef(-sima->cursor[0], -sima->cursor[1], 0.0f);
setlinestyle(0);
}
@@ -758,7 +757,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
pointsize = UI_GetThemeValuef(TH_FACEDOT_SIZE);
glPointSize(pointsize); // TODO - drawobject.c changes this value after - Investigate!
- /* unselected faces */
+ /* unselected faces */
UI_ThemeColor(TH_WIRE);
bglBegin(GL_POINTS);
@@ -792,7 +791,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
/* 6. draw uv vertices */
if(drawfaces != 2) { /* 2 means Mesh Face Mode */
- /* unselected uvs */
+ /* unselected uvs */
UI_ThemeColor(TH_VERTEX);
pointsize = UI_GetThemeValuef(TH_VERTEX_SIZE);
glPointSize(pointsize);
@@ -812,7 +811,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
/* pinned uvs */
/* give odd pointsizes odd pin pointsizes */
- glPointSize(pointsize*2 + (((int)pointsize % 2)? (-1): 0));
+ glPointSize(pointsize*2 + (((int)pointsize % 2)? (-1): 0));
cpack(0xFF);
bglBegin(GL_POINTS);
@@ -859,12 +858,6 @@ void draw_uvedit_main(SpaceImage *sima, ARegion *ar, Scene *scene, Object *obedi
show_uvshadow= ED_space_image_show_uvshadow(sima, obedit);
if(show_uvedit || show_uvshadow) {
- /* this is basically the same object_handle_update as in the 3d view,
- * here we have to do it as well for the object we are editing if we
- * are displaying the final result */
- if(obedit && (sima->flag & SI_DRAWSHADOW))
- object_handle_update(scene, obedit);
-
if(show_uvshadow)
draw_uvs_shadow(sima, obedit);
else
diff --git a/source/blender/editors/uvedit/uvedit_intern.h b/source/blender/editors/uvedit/uvedit_intern.h
index 59f19d85209..dedde856d4e 100644
--- a/source/blender/editors/uvedit/uvedit_intern.h
+++ b/source/blender/editors/uvedit/uvedit_intern.h
@@ -1,5 +1,5 @@
/**
- * $Id:
+ * $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 1f97aab8e1a..92ddc097041 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -35,13 +35,10 @@
#include "MEM_guardedalloc.h"
#include "DNA_object_types.h"
-#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_image_types.h"
#include "DNA_space_types.h"
#include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_windowmanager_types.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
@@ -66,7 +63,6 @@
#include "RNA_access.h"
#include "RNA_define.h"
-#include "RNA_types.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -2514,7 +2510,7 @@ int circle_select_exec(bContext *C, wmOperator *op)
MTexPoly *tface;
int x, y, radius, width, height, select;
float zoomx, zoomy, offset[2], ellipse[2];
- int gesture_mode= RNA_int_get(op->ptr, "gesture_mode");
+ int gesture_mode= RNA_int_get(op->ptr, "gesture_mode");
/* get operator properties */
select= (gesture_mode == GESTURE_MODAL_SELECT);
@@ -2580,17 +2576,17 @@ static void snap_uv_to_pixel(float *uvco, float w, float h)
uvco[1] = ((float)((int)((uvco[1]*h) + 0.5f)))/h;
}
-static void snap_cursor_to_pixels(SpaceImage *sima, View2D *v2d)
+static void snap_cursor_to_pixels(SpaceImage *sima)
{
int width= 0, height= 0;
ED_space_image_size(sima, &width, &height);
- snap_uv_to_pixel(v2d->cursor, width, height);
+ snap_uv_to_pixel(sima->cursor, width, height);
}
-static int snap_cursor_to_selection(Scene *scene, Image *ima, Object *obedit, View2D *v2d)
+static int snap_cursor_to_selection(Scene *scene, Image *ima, Object *obedit, SpaceImage *sima)
{
- return uvedit_center(scene, ima, obedit, v2d->cursor, 0);
+ return uvedit_center(scene, ima, obedit, sima->cursor, 0);
}
static int snap_cursor_exec(bContext *C, wmOperator *op)
@@ -2599,23 +2595,22 @@ static int snap_cursor_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
Image *ima= CTX_data_edit_image(C);
- ARegion *ar= CTX_wm_region(C);
int change= 0;
switch(RNA_boolean_get(op->ptr, "target")) {
case 0:
- snap_cursor_to_pixels(sima, &ar->v2d);
+ snap_cursor_to_pixels(sima);
change= 1;
break;
case 1:
- change= snap_cursor_to_selection(scene, ima, obedit, &ar->v2d);
+ change= snap_cursor_to_selection(scene, ima, obedit, sima);
break;
}
if(!change)
return OPERATOR_CANCELLED;
- ED_region_tag_redraw(ar);
+ WM_event_add_notifier(C, NC_SPACE|ND_SPACE_IMAGE, sima);
return OPERATOR_FINISHED;
}
@@ -2643,7 +2638,7 @@ void UV_OT_snap_cursor(wmOperatorType *ot)
/* ******************** snap selection operator **************** */
-static int snap_uvs_to_cursor(Scene *scene, Image *ima, Object *obedit, View2D *v2d)
+static int snap_uvs_to_cursor(Scene *scene, Image *ima, Object *obedit, SpaceImage *sima)
{
BMEditMesh *em= ((Mesh*)obedit->data)->edit_btmesh;
BMFace *efa;
@@ -2661,7 +2656,7 @@ static int snap_uvs_to_cursor(Scene *scene, Image *ima, Object *obedit, View2D *
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
if(uvedit_uv_selected(em, scene, l)) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
- VECCOPY2D(luv->uv, v2d->cursor);
+ VECCOPY2D(luv->uv, sima->cursor);
change= 1;
}
}
@@ -2804,7 +2799,6 @@ static int snap_selection_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
Image *ima= CTX_data_edit_image(C);
- ARegion *ar= CTX_wm_region(C);
int change= 0;
switch(RNA_boolean_get(op->ptr, "target")) {
@@ -2812,7 +2806,7 @@ static int snap_selection_exec(bContext *C, wmOperator *op)
change= snap_uvs_to_pixels(sima, scene, obedit);
break;
case 1:
- change= snap_uvs_to_cursor(scene, ima, obedit, &ar->v2d);
+ change= snap_uvs_to_cursor(scene, ima, obedit, sima);
break;
case 2:
change= snap_uvs_to_adjacent_unselected(scene, ima, obedit);
@@ -3085,14 +3079,14 @@ void UV_OT_reveal(wmOperatorType *ot)
static int set_2d_cursor_exec(bContext *C, wmOperator *op)
{
- ARegion *ar= CTX_wm_region(C);
+ SpaceImage *sima = CTX_wm_space_image(C);
float location[2];
RNA_float_get_array(op->ptr, "location", location);
- ar->v2d.cursor[0]= location[0];
- ar->v2d.cursor[1]= location[1];
+ sima->cursor[0]= location[0];
+ sima->cursor[1]= location[1];
- ED_area_tag_redraw(CTX_wm_area(C));
+ WM_event_add_notifier(C, NC_SPACE|ND_SPACE_IMAGE, NULL);
return OPERATOR_FINISHED;
}
@@ -3143,7 +3137,7 @@ static int set_tile_exec(bContext *C, wmOperator *op)
RNA_int_get_array(op->ptr, "tile", tile);
ED_uvedit_set_tile(C, CTX_data_scene(C), CTX_data_edit_object(C), ima, tile[0] + ima->xrep*tile[1]);
- ED_area_tag_redraw(CTX_wm_area(C));
+ WM_event_add_notifier(C, NC_SPACE|ND_SPACE_IMAGE, NULL);
return OPERATOR_FINISHED;
}
@@ -3265,7 +3259,7 @@ 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);
+ WM_keymap_add_menu(keymap, "IMAGE_MT_uvs_weldalign", WKEY, KM_PRESS, 0, 0);
/* uv operations */
WM_keymap_add_item(keymap, "UV_OT_stitch", VKEY, KM_PRESS, 0, 0);
@@ -3290,7 +3284,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf)
/* menus */
WM_keymap_add_menu(keymap, "IMAGE_MT_uvs_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
- ED_object_generic_keymap(keyconf, keymap, TRUE);
+ ED_object_generic_keymap(keyconf, keymap, 1);
transform_keymap_for_space(keyconf, keymap, SPACE_IMAGE);
}
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index b2d20eb7526..4ab04520582 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -388,7 +388,7 @@ static float p_face_area(PFace *f)
static float p_area_signed(float *v1, float *v2, float *v3)
{
return 0.5f*(((v2[0] - v1[0])*(v3[1] - v1[1])) -
- ((v3[0] - v1[0])*(v2[1] - v1[1])));
+ ((v3[0] - v1[0])*(v2[1] - v1[1])));
}
static float p_face_uv_area_signed(PFace *f)
@@ -397,30 +397,30 @@ static float p_face_uv_area_signed(PFace *f)
PVert *v1 = e1->vert, *v2 = e2->vert, *v3 = e3->vert;
return 0.5f*(((v2->uv[0] - v1->uv[0])*(v3->uv[1] - v1->uv[1])) -
- ((v3->uv[0] - v1->uv[0])*(v2->uv[1] - v1->uv[1])));
+ ((v3->uv[0] - v1->uv[0])*(v2->uv[1] - v1->uv[1])));
}
static float p_edge_length(PEdge *e)
{
- PVert *v1 = e->vert, *v2 = e->next->vert;
- float d[3];
+ PVert *v1 = e->vert, *v2 = e->next->vert;
+ float d[3];
- d[0] = v2->co[0] - v1->co[0];
- d[1] = v2->co[1] - v1->co[1];
- d[2] = v2->co[2] - v1->co[2];
+ d[0] = v2->co[0] - v1->co[0];
+ d[1] = v2->co[1] - v1->co[1];
+ d[2] = v2->co[2] - v1->co[2];
- return sqrt(d[0]*d[0] + d[1]*d[1] + d[2]*d[2]);
+ return sqrt(d[0]*d[0] + d[1]*d[1] + d[2]*d[2]);
}
static float p_edge_uv_length(PEdge *e)
{
- PVert *v1 = e->vert, *v2 = e->next->vert;
- float d[3];
+ PVert *v1 = e->vert, *v2 = e->next->vert;
+ float d[3];
- d[0] = v2->uv[0] - v1->uv[0];
- d[1] = v2->uv[1] - v1->uv[1];
+ d[0] = v2->uv[0] - v1->uv[0];
+ d[1] = v2->uv[1] - v1->uv[1];
- return sqrt(d[0]*d[0] + d[1]*d[1]);
+ return sqrt(d[0]*d[0] + d[1]*d[1]);
}
static void p_chart_uv_bbox(PChart *chart, float *minv, float *maxv)
@@ -522,7 +522,7 @@ static PEdge *p_boundary_edge_next(PEdge *e)
static PEdge *p_boundary_edge_prev(PEdge *e)
{
- PEdge *we = e, *last;
+ PEdge *we = e, *last;
do {
last = we;
@@ -591,7 +591,7 @@ static void p_vert_load_pin_select_uvs(PHandle *handle, PVert *v)
if (e->flag & PEDGE_SELECT)
v->flag |= PVERT_SELECT;
- if (e->flag & PEDGE_PIN) {
+ if (e->flag & PEDGE_PIN) {
pinuv[0] += e->orig_uv[0]*handle->aspx;
pinuv[1] += e->orig_uv[1]*handle->aspy;
npins++;
@@ -823,7 +823,7 @@ static PBool p_edge_has_pair(PHandle *handle, PEdge *e, PEdge **pair, PBool impl
/* don't connect seams and t-junctions */
if ((pe->flag & PEDGE_SEAM) || *pair ||
- (impl && p_edge_implicit_seam(e, pe))) {
+ (impl && p_edge_implicit_seam(e, pe))) {
*pair = NULL;
return P_FALSE;
}
@@ -1032,8 +1032,8 @@ static PFace *p_face_add(PHandle *handle)
}
static PFace *p_face_add_construct(PHandle *handle, ParamKey key, ParamKey *vkeys,
- float *co[3], float *uv[3], int i1, int i2, int i3,
- ParamBool *pin, ParamBool *select)
+ float *co[3], float *uv[3], int i1, int i2, int i3,
+ ParamBool *pin, ParamBool *select)
{
PFace *f = p_face_add(handle);
PEdge *e1 = f->edge, *e2 = e1->next, *e3 = e2->next;
@@ -1124,8 +1124,8 @@ static PBool p_quad_split_direction(PHandle *handle, float **co, PHashKey *vkeys
static void p_chart_boundaries(PChart *chart, int *nboundaries, PEdge **outer)
{
- PEdge *e, *be;
- float len, maxlen = -1.0;
+ PEdge *e, *be;
+ float len, maxlen = -1.0;
if (nboundaries)
*nboundaries = 0;
@@ -1133,29 +1133,29 @@ static void p_chart_boundaries(PChart *chart, int *nboundaries, PEdge **outer)
*outer = NULL;
for (e=chart->edges; e; e=e->nextlink) {
- if (e->pair || (e->flag & PEDGE_DONE))
- continue;
+ if (e->pair || (e->flag & PEDGE_DONE))
+ continue;
if (nboundaries)
(*nboundaries)++;
- len = 0.0f;
+ len = 0.0f;
be = e;
do {
- be->flag |= PEDGE_DONE;
- len += p_edge_length(be);
+ be->flag |= PEDGE_DONE;
+ len += p_edge_length(be);
be = be->next->vert->edge;
- } while(be != e);
+ } while(be != e);
- if (outer && (len > maxlen)) {
+ if (outer && (len > maxlen)) {
*outer = e;
- maxlen = len;
- }
- }
+ maxlen = len;
+ }
+ }
for (e=chart->edges; e; e=e->nextlink)
- e->flag &= ~PEDGE_DONE;
+ e->flag &= ~PEDGE_DONE;
}
static float p_edge_boundary_angle(PEdge *e)
@@ -1272,8 +1272,8 @@ static void p_chart_fill_boundaries(PChart *chart, PEdge *outer)
for (e=chart->edges; e; e=e->nextlink) {
/* enext = e->nextlink; - as yet unused */
- if (e->pair || (e->flag & PEDGE_FILLED))
- continue;
+ if (e->pair || (e->flag & PEDGE_FILLED))
+ continue;
nedges = 0;
be = e;
@@ -1285,7 +1285,7 @@ static void p_chart_fill_boundaries(PChart *chart, PEdge *outer)
if (e != outer)
p_chart_fill_boundary(chart, e, nedges);
- }
+ }
}
#if 0
@@ -1848,7 +1848,7 @@ static PBool p_collapse_allowed(PEdge *edge, PEdge *pair)
return P_FALSE;
return (p_collapse_allowed_topologic(edge, pair) &&
- p_collapse_allowed_geometric(edge, pair));
+ p_collapse_allowed_geometric(edge, pair));
}
static float p_collapse_cost(PEdge *edge, PEdge *pair)
@@ -2793,7 +2793,7 @@ static PBool p_chart_symmetry_pins(PChart *chart, PEdge *outer, PVert **pin1, PV
float maxlen = 0.0f, curlen = 0.0f, totlen = 0.0f, firstlen = 0.0f;
float len1, len2;
- /* find longest series of verts split in the chart itself, these are
+ /* find longest series of verts split in the chart itself, these are
marked during construction */
be = outer;
lastbe = p_boundary_edge_prev(be);
@@ -2804,7 +2804,7 @@ static PBool p_chart_symmetry_pins(PChart *chart, PEdge *outer, PVert **pin1, PV
nextbe = p_boundary_edge_next(be);
if ((be->vert->flag & PVERT_SPLIT) ||
- (lastbe->vert->flag & nextbe->vert->flag & PVERT_SPLIT)) {
+ (lastbe->vert->flag & nextbe->vert->flag & PVERT_SPLIT)) {
if (!cure) {
if (be == outer)
firste1 = be;
@@ -3192,11 +3192,11 @@ static float p_face_stretch(PFace *f)
copy_v3_v3(tmp, v2->co);
mul_v3_fl(tmp, (v3->uv[1] - v1->uv[1]));
- add_v3_v3v3(Ps, Ps, tmp);
+ add_v3_v3(Ps, tmp);
copy_v3_v3(tmp, v3->co);
mul_v3_fl(tmp, (v1->uv[1] - v2->uv[1]));
- add_v3_v3v3(Ps, Ps, tmp);
+ add_v3_v3(Ps, tmp);
mul_v3_fl(Ps, w);
@@ -3205,11 +3205,11 @@ static float p_face_stretch(PFace *f)
copy_v3_v3(tmp, v2->co);
mul_v3_fl(tmp, (v1->uv[0] - v3->uv[0]));
- add_v3_v3v3(Pt, Pt, tmp);
+ add_v3_v3(Pt, tmp);
copy_v3_v3(tmp, v3->co);
mul_v3_fl(tmp, (v2->uv[0] - v1->uv[0]));
- add_v3_v3v3(Pt, Pt, tmp);
+ add_v3_v3(Pt, tmp);
mul_v3_fl(Pt, w);
@@ -4029,7 +4029,7 @@ static void p_smooth(PChart *chart)
MEM_freeN(nodesx);
MEM_freeN(nodesy);
- arena = BLI_memarena_new(1<<16);
+ arena = BLI_memarena_new(1<<16, "param smooth arena");
root = p_node_new(arena, tri, esize*2, minv, maxv, 0);
for (v=chart->verts; v; v=v->nextlink)
@@ -4049,7 +4049,7 @@ ParamHandle *param_construct_begin()
PHandle *handle = MEM_callocN(sizeof*handle, "PHandle");
handle->construction_chart = p_chart_new(handle);
handle->state = PHANDLE_STATE_ALLOCATED;
- handle->arena = BLI_memarena_new((1<<16));
+ handle->arena = BLI_memarena_new((1<<16), "param construct arena");
handle->aspx = 1.0f;
handle->aspy = 1.0f;
@@ -4074,7 +4074,7 @@ void param_delete(ParamHandle *handle)
int i;
param_assert((phandle->state == PHANDLE_STATE_ALLOCATED) ||
- (phandle->state == PHANDLE_STATE_CONSTRUCTED));
+ (phandle->state == PHANDLE_STATE_CONSTRUCTED));
for (i = 0; i < phandle->ncharts; i++)
p_chart_delete(phandle->charts[i]);
@@ -4095,8 +4095,8 @@ void param_delete(ParamHandle *handle)
}
void param_face_add(ParamHandle *handle, ParamKey key, int nverts,
- ParamKey *vkeys, float **co, float **uv,
- ParamBool *pin, ParamBool *select)
+ ParamKey *vkeys, float **co, float **uv,
+ ParamBool *pin, ParamBool *select)
{
PHandle *phandle = (PHandle*)handle;
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.h b/source/blender/editors/uvedit/uvedit_parametrizer.h
index 8d440e2e652..912270da9ca 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.h
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.h
@@ -22,7 +22,7 @@ typedef enum ParamBool {
- vertices are implicitly created
- in construct_end the mesh will be split up according to the seams
- the resulting charts must be:
- - manifold, connected, open (at least one boundary loop)
+ - manifold, connected, open (at least one boundary loop)
- output will be written to the uv pointers
*/
@@ -33,16 +33,16 @@ void param_aspect_ratio(ParamHandle *handle, float aspx, float aspy);
int p_face_exists(ParamHandle *handle, ParamKey *vkeys, int i1, int i2, int i3);
void param_face_add(ParamHandle *handle,
- ParamKey key,
- int nverts,
- ParamKey *vkeys,
- float **co,
- float **uv,
+ ParamKey key,
+ int nverts,
+ ParamKey *vkeys,
+ float **co,
+ float **uv,
ParamBool *pin,
ParamBool *select);
void param_edge_set_seam(ParamHandle *handle,
- ParamKey *vkeys);
+ ParamKey *vkeys);
void param_construct_end(ParamHandle *handle, ParamBool fill, ParamBool impl);
void param_delete(ParamHandle *chart);
@@ -51,8 +51,8 @@ void param_delete(ParamHandle *chart);
-----------------------------
- charts with less than two pinned vertices are assigned 2 pins
- lscm is divided in three steps:
- - begin: compute matrix and it's factorization (expensive)
- - solve using pinned coordinates (cheap)
+ - begin: compute matrix and it's factorization (expensive)
+ - solve using pinned coordinates (cheap)
- end: clean up
- uv coordinates are allowed to change within begin/end, for
quick re-solving
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 6275549e3c5..d0fee1b3620 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -34,12 +34,9 @@
#include "MEM_guardedalloc.h"
#include "DNA_camera_types.h"
-#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_space_types.h"
#include "BKE_context.h"
#include "BKE_customdata.h"
@@ -55,6 +52,7 @@
#include "BLI_editVert.h"
#include "BLI_scanfill.h"
#include "BLI_array.h"
+#include "BLI_uvproject.h"
#include "PIL_time.h"
@@ -67,7 +65,6 @@
#include "RNA_access.h"
#include "RNA_define.h"
-#include "UI_interface.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -450,7 +447,7 @@ void UV_OT_minimize_stretch(wmOperatorType *ot)
ot->name= "Minimize Stretch";
ot->idname= "UV_OT_minimize_stretch";
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
- ot->description="DOC_BROKEN";
+ ot->description="Reduce UV stretching by relaxing angles";
/* api callbacks */
ot->exec= minimize_stretch_exec;
@@ -898,115 +895,7 @@ void UV_OT_unwrap(wmOperatorType *ot)
}
/**************** Project From View operator **************/
-
-static void uv_from_view_bounds(float target[2], float source[3], float rotmat[4][4])
-{
- float pv[3];
-
- mul_m4_v3(rotmat, pv);
-
- /* ortho projection */
- target[0] = -pv[0];
- target[1] = pv[2];
-}
-
-typedef struct UvCameraInfo {
- float camangle;
- float camsize;
- float xasp, yasp;
- float shiftx, shifty;
- float rotmat[4][4];
- float caminv[4][4];
- short do_persp, do_pano;
-} UvCameraInfo;
-
-//static void uv_from_camera(float camsize, float camangle, float xasp, float yasp, float target[2], float source[3], float rotmat[4][4], float caminv[4][4], int persp, int pano)
-static void uv_from_camera(UvCameraInfo *uci, float target[2], float source[3])
-{
- float pv4[4];
-
- copy_v3_v3(pv4, source);
- pv4[3]= 1.0;
-
- /* rotmat is the object matrix in this case */
- mul_m4_v4(uci->rotmat, pv4);
-
- /* caminv is the inverse camera matrix */
- mul_m4_v4(uci->caminv, pv4);
-
- if(uci->do_pano) {
- float angle= atan2f(pv4[0], -pv4[2]) / (M_PI * 2.0); /* angle around the camera */
- if (uci->do_persp==0) {
- target[0] = angle; /* no correct method here, just map to 0-1 */
- target[1] = pv4[1] / uci->camsize;
- }
- else {
- float vec2d[2]= {pv4[0], pv4[2]}; /* 2D position from the camera */
- target[0] = angle * (M_PI / uci->camangle);
- target[1] = pv4[1] / (len_v2(vec2d) * uci->camsize);
- }
- }
- else {
- if (pv4[2]==0.0f) pv4[2]=0.00001f; /* don't allow div by 0 */
-
- if (uci->do_persp==0) {
- target[0]=(pv4[0]/uci->camsize) * uci->xasp;
- target[1]=(pv4[1]/uci->camsize) * uci->yasp;
- }
- else {
- target[0]=(-pv4[0]*((1.0f/uci->camsize)/pv4[2])*uci->xasp) / 2.0f;
- target[1]=(-pv4[1]*((1.0f/uci->camsize)/pv4[2])*uci->yasp) / 2.0f;
- }
- }
-
- /* adds camera shift + 0.5 */
- target[0] += uci->shiftx;
- target[1] += uci->shifty;
-}
-
-static void uv_from_view(ARegion *ar, float target[2], float source[3], float rotmat[4][4])
-{
- RegionView3D *rv3d = ar->regiondata;
- float pv[3], pv4[4], dx, dy, x= 0.0, y= 0.0;
-
- mul_m4_v3(rotmat, pv);
-
- dx= ar->winx;
- dy= ar->winy;
-
- copy_v3_v3(pv4, source);
- pv4[3]= 1.0;
-
- /* rotmat is the object matrix in this case */
- mul_m4_v4(rotmat, pv4);
-
- /* almost project_short */
- mul_m4_v4(rv3d->persmat, pv4);
- if(fabs(pv4[3]) > 0.00001) { /* avoid division by zero */
- target[0] = dx/2.0 + (dx/2.0)*pv4[0]/pv4[3];
- target[1] = dy/2.0 + (dy/2.0)*pv4[1]/pv4[3];
- }
- else {
- /* scaling is lost but give a valid result */
- target[0] = dx/2.0 + (dx/2.0)*pv4[0];
- target[1] = dy/2.0 + (dy/2.0)*pv4[1];
- }
-
- /* v3d->persmat seems to do this funky scaling */
- if(dx > dy) {
- y= (dx-dy)/2.0;
- dy = dx;
- }
- else {
- x= (dy-dx)/2.0;
- dx = dy;
- }
-
- target[0]= (x + target[0])/dx;
- target[1]= (y + target[1])/dy;
-}
-
-static int from_view_exec(bContext *C, wmOperator *op)
+static int uv_from_view_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
@@ -1040,48 +929,25 @@ static int from_view_exec(bContext *C, wmOperator *op)
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
- uv_from_view_bounds(luv->uv, l->v->co, rotmat);
+ project_from_view_ortho(luv->uv, l->v->co, rotmat);
}
}
}
else if (camera) {
- UvCameraInfo uci;
-
- uci.do_pano = (camera->flag & CAM_PANORAMA);
- uci.do_persp = (camera->type==CAM_PERSP);
-
- uci.camangle= DEG2RAD(camera->angle)/2.0f;
- uci.camsize= uci.do_persp ? uci.camsize= tanf(uci.camangle) : camera->ortho_scale;
-
- if (invert_m4_m4(uci.caminv, v3d->camera->obmat)) {
-
- /* normal projection */
- copy_m4_m4(uci.rotmat, obedit->obmat);
-
- /* also make aspect ratio adjustment factors */
- if (scene->r.xsch > scene->r.ysch) {
- uci.xasp= 1.0f;
- uci.yasp= (float)(scene->r.xsch)/(float)(scene->r.ysch);
- }
- else {
- uci.xasp= (float)(scene->r.ysch)/(float)(scene->r.xsch);
- uci.yasp= 1.0f;
- }
-
-
- /* include 0.5f here to move the UVs into the center */
- uci.shiftx = 0.5f - camera->shiftx;
- uci.shifty = 0.5f - camera->shifty;
-
+ struct UvCameraInfo *uci= project_camera_info(v3d->camera, obedit->obmat, scene->r.xsch, scene->r.ysch);
+
+ if(uci) {
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
if (!BM_TestHFlag(efa, BM_SELECT))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
- uv_from_camera(&uci, luv->uv, l->v->co);
+ project_from_camera(luv->uv, l->v->co, uci);
}
}
+
+ MEM_freeN(uci);
}
}
else {
@@ -1093,7 +959,7 @@ static int from_view_exec(bContext *C, wmOperator *op)
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
- uv_from_view(ar, luv->uv, l->v->co, rotmat);
+ project_from_view(luv->uv, l->v->co, rv3d->persmat, rotmat, ar->winx, ar->winy);
}
}
}
@@ -1106,7 +972,7 @@ static int from_view_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-static int from_view_poll(bContext *C)
+static int uv_from_view_poll(bContext *C)
{
RegionView3D *rv3d= CTX_wm_region_view3d(C);
@@ -1124,8 +990,8 @@ void UV_OT_from_view(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* api callbacks */
- ot->exec= from_view_exec;
- ot->poll= from_view_poll;
+ ot->exec= uv_from_view_exec;
+ ot->poll= uv_from_view_poll;
/* properties */
RNA_def_boolean(ot->srna, "orthographic", 0, "Orthographic", "Use orthographic projection.");