UVEdit: Add function variants based on ToolSettings
This is better than passing a scene pointer when we don't have one.
This commit is contained in:
@@ -36,6 +36,7 @@ struct Main;
|
||||
struct Object;
|
||||
struct Scene;
|
||||
struct SpaceImage;
|
||||
struct ToolSettings;
|
||||
struct View3D;
|
||||
struct ViewLayer;
|
||||
struct bNode;
|
||||
@@ -62,6 +63,20 @@ void ED_object_assign_active_image(struct Main *bmain, struct Object *ob, int ma
|
||||
bool ED_uvedit_test(struct Object *obedit);
|
||||
|
||||
/* visibility and selection */
|
||||
bool uvedit_face_visible_nolocal_ex(
|
||||
const struct ToolSettings *ts, struct BMFace *efa);
|
||||
bool uvedit_face_visible_test_ex(
|
||||
const struct ToolSettings *ts, struct Object *obedit, struct Image *ima, struct BMFace *efa);
|
||||
bool uvedit_face_select_test_ex(
|
||||
const struct ToolSettings *ts, struct BMFace *efa,
|
||||
const int cd_loop_uv_offset);
|
||||
bool uvedit_edge_select_test_ex(
|
||||
const struct ToolSettings *ts, struct BMLoop *l,
|
||||
const int cd_loop_uv_offset);
|
||||
bool uvedit_uv_select_test_ex(
|
||||
const struct ToolSettings *ts, struct BMLoop *l,
|
||||
const int cd_loop_uv_offset);
|
||||
|
||||
bool uvedit_face_visible_nolocal(
|
||||
struct Scene *scene, struct BMFace *efa);
|
||||
bool uvedit_face_visible_test(
|
||||
|
||||
@@ -235,35 +235,38 @@ static void uvedit_vertex_select_tagged(BMEditMesh *em, Scene *scene, bool selec
|
||||
}
|
||||
}
|
||||
|
||||
bool uvedit_face_visible_nolocal(Scene *scene, BMFace *efa)
|
||||
bool uvedit_face_visible_nolocal_ex(const ToolSettings *ts, BMFace *efa)
|
||||
{
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
|
||||
if (ts->uv_flag & UV_SYNC_SELECTION)
|
||||
return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) == 0);
|
||||
else
|
||||
return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) == 0 && BM_elem_flag_test(efa, BM_ELEM_SELECT));
|
||||
}
|
||||
|
||||
bool uvedit_face_visible_test(Scene *scene, Object *obedit, Image *ima, BMFace *efa)
|
||||
bool uvedit_face_visible_nolocal(Scene *scene, BMFace *efa)
|
||||
{
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
return uvedit_face_visible_nolocal_ex(scene->toolsettings, efa);
|
||||
}
|
||||
|
||||
bool uvedit_face_visible_test_ex(const ToolSettings *ts, Object *obedit, Image *ima, BMFace *efa)
|
||||
{
|
||||
if (ts->uv_flag & UV_SHOW_SAME_IMAGE) {
|
||||
Image *face_image;
|
||||
ED_object_get_active_image(obedit, efa->mat_nr + 1, &face_image, NULL, NULL, NULL);
|
||||
return (face_image == ima) ? uvedit_face_visible_nolocal(scene, efa) : false;
|
||||
return (face_image == ima) ? uvedit_face_visible_nolocal_ex(ts, efa) : false;
|
||||
}
|
||||
else {
|
||||
return uvedit_face_visible_nolocal(scene, efa);
|
||||
return uvedit_face_visible_nolocal_ex(ts, efa);
|
||||
}
|
||||
}
|
||||
bool uvedit_face_visible_test(Scene *scene, Object *obedit, Image *ima, BMFace *efa)
|
||||
{
|
||||
return uvedit_face_visible_test_ex(scene->toolsettings, obedit, ima, efa);
|
||||
}
|
||||
|
||||
bool uvedit_face_select_test(
|
||||
Scene *scene, BMFace *efa,
|
||||
bool uvedit_face_select_test_ex(
|
||||
const ToolSettings *ts, BMFace *efa,
|
||||
const int cd_loop_uv_offset)
|
||||
{
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
if (ts->uv_flag & UV_SYNC_SELECTION) {
|
||||
return (BM_elem_flag_test(efa, BM_ELEM_SELECT));
|
||||
}
|
||||
@@ -281,6 +284,10 @@ bool uvedit_face_select_test(
|
||||
return true;
|
||||
}
|
||||
}
|
||||
bool uvedit_face_select_test(Scene *scene, BMFace *efa, const int cd_loop_uv_offset)
|
||||
{
|
||||
return uvedit_face_select_test_ex(scene->toolsettings, efa, cd_loop_uv_offset);
|
||||
}
|
||||
|
||||
bool uvedit_face_select_set(
|
||||
struct Scene *scene, struct BMEditMesh *em, struct BMFace *efa, const bool select,
|
||||
@@ -347,12 +354,10 @@ bool uvedit_face_select_disable(
|
||||
return false;
|
||||
}
|
||||
|
||||
bool uvedit_edge_select_test(
|
||||
Scene *scene, BMLoop *l,
|
||||
bool uvedit_edge_select_test_ex(
|
||||
const ToolSettings *ts, BMLoop *l,
|
||||
const int cd_loop_uv_offset)
|
||||
{
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
|
||||
if (ts->uv_flag & UV_SYNC_SELECTION) {
|
||||
if (ts->selectmode & SCE_SELECT_FACE) {
|
||||
return BM_elem_flag_test(l->f, BM_ELEM_SELECT);
|
||||
@@ -374,6 +379,10 @@ bool uvedit_edge_select_test(
|
||||
return (luv1->flag & MLOOPUV_VERTSEL) && (luv2->flag & MLOOPUV_VERTSEL);
|
||||
}
|
||||
}
|
||||
bool uvedit_edge_select_test(Scene *scene, BMLoop *l, const int cd_loop_uv_offset)
|
||||
{
|
||||
return uvedit_edge_select_test_ex(scene->toolsettings, l, cd_loop_uv_offset);
|
||||
}
|
||||
|
||||
void uvedit_edge_select_set(
|
||||
BMEditMesh *em, Scene *scene, BMLoop *l, const bool select,
|
||||
@@ -448,12 +457,10 @@ void uvedit_edge_select_disable(
|
||||
}
|
||||
}
|
||||
|
||||
bool uvedit_uv_select_test(
|
||||
Scene *scene, BMLoop *l,
|
||||
bool uvedit_uv_select_test_ex(
|
||||
const ToolSettings *ts, BMLoop *l,
|
||||
const int cd_loop_uv_offset)
|
||||
{
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
|
||||
if (ts->uv_flag & UV_SYNC_SELECTION) {
|
||||
if (ts->selectmode & SCE_SELECT_FACE)
|
||||
return BM_elem_flag_test_bool(l->f, BM_ELEM_SELECT);
|
||||
@@ -465,6 +472,10 @@ bool uvedit_uv_select_test(
|
||||
return (luv->flag & MLOOPUV_VERTSEL) != 0;
|
||||
}
|
||||
}
|
||||
bool uvedit_uv_select_test(Scene *scene, BMLoop *l, const int cd_loop_uv_offset)
|
||||
{
|
||||
return uvedit_uv_select_test_ex(scene->toolsettings, l, cd_loop_uv_offset);
|
||||
}
|
||||
|
||||
void uvedit_uv_select_set(
|
||||
BMEditMesh *em, Scene *scene, BMLoop *l, const bool select,
|
||||
|
||||
Reference in New Issue
Block a user