1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 * 16 * The Original Code is Copyright (C) 2008 Blender Foundation. 17 * All rights reserved. 18 */ 19 20 /** \file 21 * \ingroup eduv 22 */ 23 24 #pragma once 25 26 struct BMFace; 27 struct BMLoop; 28 struct Image; 29 struct Object; 30 struct Scene; 31 struct SpaceImage; 32 struct wmOperatorType; 33 34 /* geometric utilities */ 35 void uv_poly_copy_aspect(float uv_orig[][2], float uv[][2], float aspx, float aspy, int len); 36 37 /* find nearest */ 38 39 typedef struct UvNearestHit { 40 /** Only for `*_multi(..)` versions of functions. */ 41 struct Object *ob; 42 /** Always set if we have a hit. */ 43 struct BMFace *efa; 44 struct BMLoop *l; 45 /** Needs to be set before calling nearest functions. */ 46 float dist_sq; 47 } UvNearestHit; 48 49 #define UV_NEAREST_HIT_INIT \ 50 { \ 51 .dist_sq = FLT_MAX, \ 52 } 53 54 bool uv_find_nearest_vert(struct Scene *scene, 55 struct Object *obedit, 56 const float co[2], 57 const float penalty_dist, 58 struct UvNearestHit *hit_final); 59 bool uv_find_nearest_vert_multi(struct Scene *scene, 60 struct Object **objects, 61 const uint objects_len, 62 const float co[2], 63 const float penalty_dist, 64 struct UvNearestHit *hit_final); 65 66 bool uv_find_nearest_edge(struct Scene *scene, 67 struct Object *obedit, 68 const float co[2], 69 struct UvNearestHit *hit_final); 70 bool uv_find_nearest_edge_multi(struct Scene *scene, 71 struct Object **objects, 72 const uint objects_len, 73 const float co[2], 74 struct UvNearestHit *hit_final); 75 76 bool uv_find_nearest_face(struct Scene *scene, 77 struct Object *obedit, 78 const float co[2], 79 struct UvNearestHit *hit_final); 80 bool uv_find_nearest_face_multi(struct Scene *scene, 81 struct Object **objects, 82 const uint objects_len, 83 const float co[2], 84 struct UvNearestHit *hit_final); 85 86 BMLoop *uv_find_nearest_loop_from_vert(struct Scene *scene, 87 struct Object *obedit, 88 struct BMVert *v, 89 const float co[2]); 90 BMLoop *uv_find_nearest_loop_from_edge(struct Scene *scene, 91 struct Object *obedit, 92 struct BMEdge *e, 93 const float co[2]); 94 95 /* utility tool functions */ 96 97 void uvedit_live_unwrap_update(struct SpaceImage *sima, 98 struct Scene *scene, 99 struct Object *obedit); 100 void uvedit_pixel_to_float(struct SpaceImage *sima, float pixeldist, float r_dist[2]); 101 102 /* operators */ 103 104 void UV_OT_average_islands_scale(struct wmOperatorType *ot); 105 void UV_OT_cube_project(struct wmOperatorType *ot); 106 void UV_OT_cylinder_project(struct wmOperatorType *ot); 107 void UV_OT_project_from_view(struct wmOperatorType *ot); 108 void UV_OT_minimize_stretch(struct wmOperatorType *ot); 109 void UV_OT_pack_islands(struct wmOperatorType *ot); 110 void UV_OT_reset(struct wmOperatorType *ot); 111 void UV_OT_sphere_project(struct wmOperatorType *ot); 112 void UV_OT_unwrap(struct wmOperatorType *ot); 113 void UV_OT_rip(struct wmOperatorType *ot); 114 void UV_OT_stitch(struct wmOperatorType *ot); 115 void UV_OT_smart_project(struct wmOperatorType *ot); 116 117 /* uvedit_path.c */ 118 void UV_OT_shortest_path_pick(struct wmOperatorType *ot); 119 void UV_OT_shortest_path_select(struct wmOperatorType *ot); 120 121 /* uvedit_select.c */ 122 123 bool uvedit_select_is_any_selected(struct Scene *scene, struct Object *obedit); 124 bool uvedit_select_is_any_selected_multi(struct Scene *scene, 125 struct Object **objects, 126 const uint objects_len); 127 const float *uvedit_first_selected_uv_from_vertex(struct Scene *scene, 128 struct BMVert *eve, 129 const int cd_loop_uv_offset); 130 131 void UV_OT_select_all(struct wmOperatorType *ot); 132 void UV_OT_select(struct wmOperatorType *ot); 133 void UV_OT_select_loop(struct wmOperatorType *ot); 134 void UV_OT_select_edge_ring(struct wmOperatorType *ot); 135 void UV_OT_select_linked(struct wmOperatorType *ot); 136 void UV_OT_select_linked_pick(struct wmOperatorType *ot); 137 void UV_OT_select_split(struct wmOperatorType *ot); 138 void UV_OT_select_pinned(struct wmOperatorType *ot); 139 void UV_OT_select_box(struct wmOperatorType *ot); 140 void UV_OT_select_lasso(struct wmOperatorType *ot); 141 void UV_OT_select_circle(struct wmOperatorType *ot); 142 void UV_OT_select_more(struct wmOperatorType *ot); 143 void UV_OT_select_less(struct wmOperatorType *ot); 144 void UV_OT_select_overlap(struct wmOperatorType *ot); 145