Fix #106430: Index the right UVmap in BMesh #106537

Closed
Martijn Versteegh wants to merge 5 commits from Baardaap:fix-named-uvmap_bmesh into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
2 changed files with 6 additions and 7 deletions
Showing only changes of commit 85cfb3df77 - Show all commits

View File

@ -20,14 +20,13 @@
#include "bmesh.h"
#include "intern/bmesh_private.h"
BMUVOffsets BM_uv_map_get_offsets_n(const BMesh *bm, int layer)
Review

int layer -> const int layer

`int layer` -> `const int layer`
{
using namespace blender;
using namespace blender::bke;
const int layer_index = layer == -1 ? CustomData_get_active_layer_index(&bm->ldata, CD_PROP_FLOAT2) :
CustomData_get_layer_index_n(&bm->ldata, CD_PROP_FLOAT2, layer);
const int layer_index = layer == -1 ?
HooglyBoogly marked this conversation as resolved Outdated

It might be simper/clearer if BM_uv_map_get_offsets called CustomData_get_active_layer_index directly. Then BM_uv_map_get_offsets_n wouldn't have to have a special case for -1.

It might be simper/clearer if `BM_uv_map_get_offsets` called `CustomData_get_active_layer_index` directly. Then `BM_uv_map_get_offsets_n` wouldn't have to have a special case for -1.
CustomData_get_active_layer_index(&bm->ldata, CD_PROP_FLOAT2) :
CustomData_get_layer_index_n(&bm->ldata, CD_PROP_FLOAT2, layer);
if (layer_index == -1) {
return {-1, -1, -1, -1};
}
@ -49,10 +48,9 @@ BMUVOffsets BM_uv_map_get_offsets_n(const BMesh *bm, int layer)
BMUVOffsets BM_uv_map_get_offsets(const BMesh *bm)
HooglyBoogly marked this conversation as resolved Outdated

Missing clang format here (line is 101 characters long)

Missing clang format here (line is 101 characters long)
{
return BM_uv_map_get_offsets_n(bm, -1);
return BM_uv_map_get_offsets_n(bm, -1);
}
static void uv_aspect(const BMLoop *l,
const float aspect[2],
const int cd_loop_uv_offset,

View File

@ -11,7 +11,8 @@ extern "C" {
#endif
/**
* Retrieve the custom data offsets for layers used for user interaction with a UV map, returns the active uv map if layer is -1.
* 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);