61 #define MARK_BOUNDARY 1
149 const float mouse_coord[2],
157 float radius_root =
sqrtf(radius);
178 tmp_uvdata[i].
b[0] =
diff[0] - sculptdata->
uv[i].
uv[0];
179 tmp_uvdata[i].
b[1] =
diff[1] - sculptdata->
uv[i].
uv[1];
198 diff[1] /= aspectRatio;
204 sculptdata->
uv[i].
uv[0] = (1.0f - strength) * sculptdata->
uv[i].
uv[0] +
206 (tmp_uvdata[i].
p[0] -
207 0.5f * (tmp_uvdata[i].
b[0] +
209 sculptdata->
uv[i].
uv[1] = (1.0f - strength) * sculptdata->
uv[i].
uv[1] +
211 (tmp_uvdata[i].
p[1] -
212 0.5f * (tmp_uvdata[i].
b[1] +
235 const float mouse_coord[2],
243 float radius_root =
sqrtf(radius);
262 copy_v2_v2(tmp_uvdata[i].p, tmp_uvdata[i].sum_co);
263 mul_v2_fl(tmp_uvdata[i].p, 1.0f / tmp_uvdata[i].ncounter);
276 diff[1] /= aspectRatio;
282 sculptdata->
uv[i].
uv[0] = (1.0f - strength) * sculptdata->
uv[i].
uv[0] +
283 strength * tmp_uvdata[i].
p[0];
284 sculptdata->
uv[i].
uv[1] = (1.0f - strength) * sculptdata->
uv[i].
uv[1] +
285 strength * tmp_uvdata[i].
p[1];
310 float co[2], radius, radius_root;
320 float alpha, zoomx, zoomy;
323 tool = sculptdata->
tool;
336 radius = radius * radius;
337 radius_root =
sqrtf(radius);
355 diff[1] /= aspectRatio;
362 sculptdata->
uv[i].
uv[0] -= strength *
diff[0] * 0.001f;
363 sculptdata->
uv[i].
uv[1] -= strength *
diff[1] * 0.001f;
406 sculptdata->
uv[uvindex].
uv[0] =
408 sculptdata->
uv[uvindex].
uv[1] =
433 if (
data->elementMap) {
442 if (
data->initial_stroke) {
443 if (
data->initial_stroke->initialSelection) {
474 if ((edge1->
uv1 == edge2->
uv1) && (edge1->
uv2 == edge2->
uv2)) {
507 int island_index = 0;
517 if (do_island_optimization) {
535 if (!
data->elementMap) {
544 if (do_island_optimization) {
550 island_index =
element->island;
554 for (i = 0; i <
data->elementMap->totalUVs; i++) {
555 if (
data->elementMap->buf[i].separate &&
556 (!do_island_optimization ||
data->elementMap->buf[i].island == island_index)) {
564 "uv_brush_unique_uv_map");
567 edges =
MEM_mallocN(
sizeof(*edges) *
data->elementMap->totalUVs,
"uv_brush_all_edges");
568 if (!
data->uv || !uniqueUv || !edgeHash || !edges) {
582 data->totalUniqueUvs = counter;
590 if (do_island_optimization && (
element->island != island_index)) {
603 data->uv[counter].flag = 0;
604 data->uv[counter].uv = luv->
uv;
607 uniqueUv[
element -
data->elementMap->buf] = counter;
616 data->elementMap, efa,
l, island_index, do_island_optimization);
618 data->elementMap, efa,
l->
next, island_index, do_island_optimization);
622 if (itmp1 == -1 || itmp2 == -1) {
626 offset1 = uniqueUv[itmp1];
627 offset2 = uniqueUv[itmp2];
629 edges[counter].
flag = 0;
632 if (offset1 < offset2) {
633 edges[counter].
uv1 = offset1;
634 edges[counter].
uv2 = offset2;
637 edges[counter].
uv1 = offset2;
638 edges[counter].
uv2 = offset1;
658 "uv_brush_edge_connectivity_data");
659 if (!
data->uvedges) {
679 for (i = 0; i <
data->totalUvEdges; i++) {
680 if (!
data->uvedges[i].flag) {
689 float radius, radius_root;
694 float alpha, zoomx, zoomy;
705 radius /= (
width * zoomx);
706 radius = radius * radius;
707 radius_root =
sqrtf(radius);
711 "uv_sculpt_initial_stroke");
712 if (!
data->initial_stroke) {
716 sizeof(*
data->initial_stroke->initialSelection) *
data->totalUniqueUvs,
717 "uv_sculpt_initial_selection");
718 if (!
data->initial_stroke->initialSelection) {
726 for (i = 0; i <
data->totalUniqueUvs; i++) {
733 diff[1] /= aspectRatio;
738 data->initial_stroke->initialSelection[counter].uv = i;
739 data->initial_stroke->initialSelection[counter].strength = strength;
740 copy_v2_v2(
data->initial_stroke->initialSelection[counter].initial_uv,
data->uv[i].uv);
745 data->initial_stroke->totalInitialSelected = counter;
779 switch (event->
type) {
830 "Invert action of brush for duration of stroke"},
835 "Switch brush to relax mode for duration of stroke"},
842 ot->
idname =
"SCULPT_OT_uv_sculpt_stroke";
typedef float(TangentPoint)[2]
float BKE_brush_alpha_get(const struct Scene *scene, const struct Brush *brush)
int BKE_brush_size_get(const struct Scene *scene, const struct Brush *brush)
float BKE_brush_curve_strength_clamped(struct Brush *br, float p, const float len)
struct Scene * CTX_data_scene(const bContext *C)
struct Object * CTX_data_edit_object(const bContext *C)
struct wmWindowManager * CTX_wm_manager(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
struct SpaceImage * CTX_wm_space_image(const bContext *C)
struct ToolSettings * CTX_data_tool_settings(const bContext *C)
struct wmWindow * CTX_wm_window(const bContext *C)
CustomData interface, see also DNA_customdata_types.h.
void * CustomData_bmesh_get(const struct CustomData *data, void *block, int type)
BMEditMesh * BKE_editmesh_from_object(struct Object *ob)
Return the BMEditMesh for a given object.
struct Brush * BKE_paint_brush(struct Paint *paint)
BLI_INLINE void * BLI_ghashIterator_getKey(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
unsigned int BLI_ghashutil_uinthash(unsigned int key)
#define GHASH_ITER(gh_iter_, ghash_)
GHash * BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
unsigned int BLI_ghash_len(GHash *gh) ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void * BLI_ghash_lookup(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void add_v2_v2(float r[2], const float a[2])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float normalize_v2(float r[2])
void DEG_id_tag_update(struct ID *id, int flag)
Object is a sort of wrapper for general info.
#define UV_SCULPT_TOOL_RELAX_HC
#define UV_SCULPT_LOCK_BORDERS
#define UV_SCULPT_ALL_ISLANDS
#define UV_SYNC_SELECTION
void ED_space_image_get_zoom(struct SpaceImage *sima, const struct ARegion *region, float *r_zoomx, float *r_zoomy)
void ED_space_image_get_size(struct SpaceImage *sima, int *r_width, int *r_height)
struct UvElement * BM_uv_element_get(struct UvElementMap *map, struct BMFace *efa, struct BMLoop *l)
struct UvElementMap * BM_uv_element_map_create(struct BMesh *bm, const struct Scene *scene, const bool face_selected, const bool uv_selected, const bool use_winding, const bool do_islands)
void BM_uv_element_map_free(struct UvElementMap *element_map)
bool ED_operator_uvedit_space_image(struct bContext *C)
void ED_region_tag_redraw(struct ARegion *region)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
Read Guarded memory(de)allocation.
void UI_view2d_region_to_view(const struct View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
#define BM_ITER_ELEM(ele, iter, data, itype)
#define BM_ITER_MESH(ele, iter, bm, itype)
ATTR_WARN_UNUSED_RESULT BMesh * bm
ATTR_WARN_UNUSED_RESULT const void * element
ATTR_WARN_UNUSED_RESULT const BMLoop * l
static CCL_NAMESPACE_BEGIN const double alpha
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt=1)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
static void HC_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *sculptdata, const float mouse_coord[2], float alpha, float radius, float aspectRatio)
static bool uv_sculpt_stroke_poll(bContext *C)
static UvSculptData * uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wmEvent *event)
struct UVInitialStroke UVInitialStroke
struct Temp_UvData Temp_UVData
static int uv_sculpt_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
void SCULPT_OT_uv_sculpt_stroke(wmOperatorType *ot)
struct UvAdjacencyElement UvAdjacencyElement
static bool uv_edge_compare(const void *a, const void *b)
static int uv_sculpt_stroke_invoke(bContext *C, wmOperator *op, const wmEvent *event)
struct UvSculptData UvSculptData
static void laplacian_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *sculptdata, const float mouse_coord[2], float alpha, float radius, float aspectRatio)
static void uv_sculpt_stroke_apply(bContext *C, wmOperator *op, const wmEvent *event, Object *obedit)
static uint uv_edge_hash(const void *key)
static int uv_element_offset_from_face_get(UvElementMap *map, BMFace *efa, BMLoop *l, int island_index, const bool doIslands)
static void uv_sculpt_stroke_exit(bContext *C, wmOperator *op)
struct UVInitialStrokeElement UVInitialStrokeElement
struct CurveMapping * curve
struct ToolSettings * toolsettings
UVInitialStrokeElement * initialSelection
UVInitialStroke * initial_stroke
UvElementMap * elementMap
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
bool uv_find_nearest_vert(struct Scene *scene, struct Object *obedit, const float co[2], const float penalty_dist, struct UvNearestHit *hit)
#define UV_NEAREST_HIT_INIT_MAX(v2d)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer)
wmTimer * WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep)