diff --git a/source/blender/bmesh/intern/bmesh_query_uv.cc b/source/blender/bmesh/intern/bmesh_query_uv.cc index d4863ebc29a..10af8462596 100644 --- a/source/blender/bmesh/intern/bmesh_query_uv.cc +++ b/source/blender/bmesh/intern/bmesh_query_uv.cc @@ -20,11 +20,11 @@ #include "bmesh.h" #include "intern/bmesh_private.h" -BMUVOffsets BM_uv_map_get_offsets(const BMesh *bm) +BMUVOffsets BM_uv_map_get_offsets_n(const BMesh *bm, int layer) { using namespace blender; using namespace blender::bke; - const int layer_index = CustomData_get_active_layer_index(&bm->ldata, CD_PROP_FLOAT2); + const int layer_index = CustomData_get_layer_index_n(&bm->ldata, CD_PROP_FLOAT2, layer); if (layer_index == -1) { return {-1, -1, -1, -1}; } @@ -44,6 +44,12 @@ BMUVOffsets BM_uv_map_get_offsets(const BMesh *bm) return offsets; } +BMUVOffsets BM_uv_map_get_offsets(const BMesh *bm) +{ + return BM_uv_map_get_offsets_n(bm, + CustomData_get_active_layer_index(&bm->ldata, CD_PROP_FLOAT2)); +} + static void uv_aspect(const BMLoop *l, const float aspect[2], const int cd_loop_uv_offset, diff --git a/source/blender/bmesh/intern/bmesh_query_uv.h b/source/blender/bmesh/intern/bmesh_query_uv.h index 422e858f1b7..4c0cb3a0f45 100644 --- a/source/blender/bmesh/intern/bmesh_query_uv.h +++ b/source/blender/bmesh/intern/bmesh_query_uv.h @@ -11,9 +11,11 @@ extern "C" { #endif /** - * Retrieve the custom data offsets for layers used for user interaction with the active UV map. + * Retrieve the custom data offsets for layers used for user interaction with a UV map, returns the + * active uv map if layer is -1. */ BMUVOffsets BM_uv_map_get_offsets(const BMesh *bm); +BMUVOffsets BM_uv_map_get_offsets_n(const BMesh *bm, int layer); float BM_loop_uv_calc_edge_length_squared(const BMLoop *l, int cd_loop_uv_offset) ATTR_WARN_UNUSED_RESULT diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c index 18276bed898..f2661375d57 100644 --- a/source/blender/python/bmesh/bmesh_py_types_customdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c @@ -1149,7 +1149,7 @@ PyObject *BPy_BMLayerItem_GetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer) PyErr_SetString(PyExc_ValueError, "BMElem[layer]: layer is from another mesh"); return NULL; } - ret = BPy_BMLoopUV_CreatePyObject(py_ele->bm, (BMLoop *)py_ele->ele); + ret = BPy_BMLoopUV_CreatePyObject(py_ele->bm, (BMLoop *)py_ele->ele, py_layer->index); break; } case CD_PROP_BYTE_COLOR: { diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c index c85984aa467..329d4fc2fa5 100644 --- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c @@ -209,11 +209,11 @@ int BPy_BMLoopUV_AssignPyObject(struct BMesh *bm, BMLoop *loop, PyObject *value) return 0; } -PyObject *BPy_BMLoopUV_CreatePyObject(struct BMesh *bm, BMLoop *loop) +PyObject *BPy_BMLoopUV_CreatePyObject(struct BMesh *bm, BMLoop *loop, int layer) { BPy_BMLoopUV *self = PyObject_New(BPy_BMLoopUV, &BPy_BMLoopUV_Type); - const BMUVOffsets offsets = BM_uv_map_get_offsets(bm); + const BMUVOffsets offsets = BM_uv_map_get_offsets_n(bm, layer); self->uv = BM_ELEM_CD_GET_FLOAT_P(loop, offsets.uv); self->vert_select = offsets.select_vert >= 0 ? BM_ELEM_CD_GET_BOOL_P(loop, offsets.select_vert) : diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.h b/source/blender/python/bmesh/bmesh_py_types_meshdata.h index 60f82893f1a..8f872450cb7 100644 --- a/source/blender/python/bmesh/bmesh_py_types_meshdata.h +++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.h @@ -23,7 +23,7 @@ struct MVertSkin; struct BMesh; int BPy_BMLoopUV_AssignPyObject(struct BMesh *bm, BMLoop *loop, PyObject *value); -PyObject *BPy_BMLoopUV_CreatePyObject(struct BMesh *bm, BMLoop *loop); +PyObject *BPy_BMLoopUV_CreatePyObject(struct BMesh *bm, BMLoop *loop, int layer); int BPy_BMVertSkin_AssignPyObject(struct MVertSkin *mvertskin, PyObject *value); PyObject *BPy_BMVertSkin_CreatePyObject(struct MVertSkin *mvertskin);