WIP: Mesh: Store active and default UV map with strings #105779
|
@ -1477,6 +1477,7 @@ static BMOpDefine bmo_rotate_uvs_def = {
|
|||
/* slots_in */
|
||||
{{"faces", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}}, /* input faces */
|
||||
{"use_ccw", BMO_OP_SLOT_BOOL}, /* rotate counter-clockwise if true, otherwise clockwise */
|
||||
{"uv_index", BMO_OP_SLOT_INT}, /* Index of UV map to adjust */
|
||||
{{'\0'}},
|
||||
},
|
||||
{{{'\0'}}}, /* no output */
|
||||
|
@ -1493,6 +1494,7 @@ static BMOpDefine bmo_reverse_uvs_def = {
|
|||
"reverse_uvs",
|
||||
/* slots_in */
|
||||
{{"faces", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}}, /* input faces */
|
||||
{"uv_index", BMO_OP_SLOT_INT}, /* Index of UV map to adjust */
|
||||
{{'\0'}},
|
||||
},
|
||||
{{{'\0'}}}, /* no output */
|
||||
|
|
|
@ -216,7 +216,7 @@ void BM_mesh_calc_uvs_cone(BMesh *bm,
|
|||
* \param bm: The BMesh to operate on.
|
||||
* \param oflag: The flag to check faces with.
|
||||
*/
|
||||
void BM_mesh_calc_uvs_cube(BMesh *bm, short oflag);
|
||||
void BM_mesh_calc_uvs_cube(BMesh *bm, short oflag, const int cd_loop_uv_offset);
|
||||
|
||||
#include "intern/bmesh_operator_api_inline.h"
|
||||
|
||||
|
|
|
@ -1671,21 +1671,19 @@ void bmo_create_cube_exec(BMesh *bm, BMOperator *op)
|
|||
}
|
||||
|
||||
if (cd_loop_uv_offset != -1) {
|
||||
BM_mesh_calc_uvs_cube(bm, FACE_MARK);
|
||||
BM_mesh_calc_uvs_cube(bm, FACE_MARK, cd_loop_uv_offset);
|
||||
}
|
||||
|
||||
BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK);
|
||||
}
|
||||
|
||||
void BM_mesh_calc_uvs_cube(BMesh *bm, const short oflag)
|
||||
void BM_mesh_calc_uvs_cube(BMesh *bm, const short oflag, const int cd_loop_uv_offset)
|
||||
{
|
||||
BMFace *f;
|
||||
BMLoop *l;
|
||||
BMIter fiter, liter;
|
||||
const float width = 0.25f;
|
||||
|
||||
const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_PROP_FLOAT2);
|
||||
|
||||
float x = 0.375f;
|
||||
float y = 0.0f;
|
||||
|
||||
|
|
|
@ -478,7 +478,8 @@ void bmo_rotate_uvs_exec(BMesh *bm, BMOperator *op)
|
|||
BMIter l_iter; /* iteration loop */
|
||||
|
||||
const bool use_ccw = BMO_slot_bool_get(op->slots_in, "use_ccw");
|
||||
const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_PROP_FLOAT2);
|
||||
const int uv_index = BMO_slot_int_get(op->slots_in, "uv_index");
|
||||
const int cd_loop_uv_offset = CustomData_get_offset_n(&bm->ldata, CD_PROP_FLOAT2, uv_index);
|
||||
|
||||
if (cd_loop_uv_offset != -1) {
|
||||
BMO_ITER (fs, &fs_iter, op->slots_in, "faces", BM_FACE) {
|
||||
|
@ -561,7 +562,8 @@ void bmo_reverse_uvs_exec(BMesh *bm, BMOperator *op)
|
|||
{
|
||||
BMOIter iter;
|
||||
BMFace *f;
|
||||
const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_PROP_FLOAT2);
|
||||
const int uv_index = BMO_slot_int_get(op->slots_in, "uv_index");
|
||||
const int cd_loop_uv_offset = CustomData_get_offset_n(&bm->ldata, CD_PROP_FLOAT2, uv_index);
|
||||
|
||||
if (cd_loop_uv_offset != -1) {
|
||||
BMO_ITER (f, &iter, op->slots_in, "faces", BM_FACE) {
|
||||
|
|
|
@ -167,7 +167,7 @@ struct UvMapVert *BM_uv_vert_map_at_index(struct UvVertMap *vmap, unsigned int v
|
|||
/**
|
||||
* Return a new #UvVertMap from the edit-mesh.
|
||||
*/
|
||||
struct UvVertMap *BM_uv_vert_map_create(struct BMesh *bm, bool use_select);
|
||||
struct UvVertMap *BM_uv_vert_map_create(struct BMesh *bm, int cd_loop_uv_offset, bool use_select);
|
||||
|
||||
void EDBM_flag_enable_all(struct BMEditMesh *em, char hflag);
|
||||
void EDBM_flag_disable_all(struct BMEditMesh *em, char hflag);
|
||||
|
|
|
@ -3043,6 +3043,7 @@ static int edbm_rotate_uvs_exec(bContext *C, wmOperator *op)
|
|||
scene, view_layer, CTX_wm_view3d(C), &objects_len);
|
||||
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
|
||||
Object *obedit = objects[ob_index];
|
||||
Mesh *mesh = static_cast<Mesh *>(obedit->data);
|
||||
BMEditMesh *em = BKE_editmesh_from_object(obedit);
|
||||
|
||||
if (em->bm->totfacesel == 0) {
|
||||
|
@ -3051,7 +3052,16 @@ static int edbm_rotate_uvs_exec(bContext *C, wmOperator *op)
|
|||
|
||||
BMOperator bmop;
|
||||
|
||||
EDBM_op_init(em, &bmop, op, "rotate_uvs faces=%hf use_ccw=%b", BM_ELEM_SELECT, use_ccw);
|
||||
const int uv_index = CustomData_get_named_layer(
|
||||
&mesh->ldata, CD_PROP_FLOAT2, mesh->active_uv_attribute);
|
||||
|
||||
EDBM_op_init(em,
|
||||
&bmop,
|
||||
op,
|
||||
"rotate_uvs faces=%hf use_ccw=%b uv_index=%i",
|
||||
BM_ELEM_SELECT,
|
||||
use_ccw,
|
||||
uv_index);
|
||||
|
||||
BMO_op_exec(em->bm, &bmop);
|
||||
|
||||
|
|
|
@ -444,7 +444,7 @@ void EDBM_flag_enable_all(BMEditMesh *em, const char hflag)
|
|||
/** \name UV Vertex Map API
|
||||
* \{ */
|
||||
|
||||
UvVertMap *BM_uv_vert_map_create(BMesh *bm, const bool use_select)
|
||||
UvVertMap *BM_uv_vert_map_create(BMesh *bm, const int cd_loop_uv_offset, const bool use_select)
|
||||
{
|
||||
/* NOTE: delimiting on alternate face-winding was once supported and could be useful
|
||||
* in some cases. If this is need see: D17137 to restore support. */
|
||||
|
@ -453,7 +453,6 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm, const bool use_select)
|
|||
BMLoop *l;
|
||||
BMIter iter, liter;
|
||||
uint a;
|
||||
const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_PROP_FLOAT2);
|
||||
|
||||
BM_mesh_elem_index_ensure(bm, BM_VERT | BM_FACE);
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "DNA_brush_types.h"
|
||||
#include "DNA_mesh_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
@ -464,6 +465,7 @@ static void uv_sculpt_stroke_apply(bContext *C,
|
|||
float co[2], radius, radius_root;
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
Mesh *mesh = obedit->data;
|
||||
BMEditMesh *em = BKE_editmesh_from_object(obedit);
|
||||
uint tool;
|
||||
UvSculptData *sculptdata = (UvSculptData *)op->customdata;
|
||||
|
@ -490,7 +492,8 @@ static void uv_sculpt_stroke_apply(bContext *C,
|
|||
radius = radius * radius;
|
||||
radius_root = sqrtf(radius);
|
||||
|
||||
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_PROP_FLOAT2);
|
||||
const int cd_loop_uv_offset = CustomData_get_offset_named(
|
||||
&em->bm->ldata, CD_PROP_FLOAT2, mesh->active_uv_attribute);
|
||||
|
||||
/*
|
||||
* Pinch Tool
|
||||
|
|
|
@ -1791,7 +1791,7 @@ static void uv_select_linked_multi(Scene *scene,
|
|||
*
|
||||
* Better solve this by having a delimit option for select-linked operator,
|
||||
* keeping island-select working as is. */
|
||||
UvVertMap *vmap = BM_uv_vert_map_create(em->bm, !uv_sync_select);
|
||||
UvVertMap *vmap = BM_uv_vert_map_create(em->bm, offsets.uv, !uv_sync_select);
|
||||
if (vmap == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
@ -3290,7 +3290,7 @@ static void uv_select_flush_from_tag_face(const Scene *scene, Object *obedit, co
|
|||
uint efa_index;
|
||||
|
||||
BM_mesh_elem_table_ensure(em->bm, BM_FACE);
|
||||
struct UvVertMap *vmap = BM_uv_vert_map_create(em->bm, false);
|
||||
struct UvVertMap *vmap = BM_uv_vert_map_create(em->bm, offsets.uv, false);
|
||||
if (vmap == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -3379,7 +3379,7 @@ static void uv_select_flush_from_tag_loop(const Scene *scene, Object *obedit, co
|
|||
uint efa_index;
|
||||
|
||||
BM_mesh_elem_table_ensure(em->bm, BM_FACE);
|
||||
struct UvVertMap *vmap = BM_uv_vert_map_create(em->bm, false);
|
||||
struct UvVertMap *vmap = BM_uv_vert_map_create(em->bm, offsets.uv, false);
|
||||
if (vmap == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -3435,7 +3435,7 @@ static void uv_select_flush_from_loop_edge_flag(const Scene *scene, BMEditMesh *
|
|||
bm_clear_uv_vert_selection(scene, em->bm, offsets);
|
||||
|
||||
BM_mesh_elem_table_ensure(em->bm, BM_FACE);
|
||||
struct UvVertMap *vmap = BM_uv_vert_map_create(em->bm, false);
|
||||
struct UvVertMap *vmap = BM_uv_vert_map_create(em->bm, offsets.uv, false);
|
||||
if (vmap == NULL) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue