Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-10-01 14:00:15 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-10-01 17:10:38 +0300
commit5e98187ddb3319ab94618c9232fd0cb3538c2e02 (patch)
tree71e442db9a36a6fd9100f42d0eccb83e2932697b /source
parentd3c88336cdd54c227aa837814f4bd7850656daf0 (diff)
Cleanup: make sculpt vertex random access API read-only
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c107
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h2
2 files changed, 33 insertions, 76 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 093503c8cc0..0298ba9bbad 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -95,23 +95,12 @@
#include <stdlib.h>
#include <string.h>
-/* Sculpt PBVH abstraction API */
-
-/* Do not use these functions while working with PBVH_GRIDS data in SculptSession */
-
-float *sculpt_vertex_co_get(SculptSession *ss, int index)
-{
- switch (BKE_pbvh_type(ss->pbvh)) {
- case PBVH_FACES:
- return ss->mvert[index].co;
- case PBVH_BMESH:
- return BM_vert_at_index(BKE_pbvh_get_bmesh(ss->pbvh), index)->co;
- case PBVH_GRIDS:
- BLI_assert(!"This fuction is not supposed to be used for PBVH_GRIDS");
- break;
- }
- return NULL;
-}
+/* Sculpt PBVH abstraction API
+ *
+ * This is read-only, for writing use PBVH vertex iterators. There vd.index matches
+ * the indices used here.
+ *
+ * Do not use these functions while working with PBVH_GRIDS data in SculptSession. */
static void sculpt_vertex_random_access_init(SculptSession *ss)
{
@@ -120,26 +109,6 @@ static void sculpt_vertex_random_access_init(SculptSession *ss)
}
}
-static int sculpt_active_vertex_get(SculptSession *ss)
-{
- BLI_assert(BKE_pbvh_type(ss->pbvh) != PBVH_GRIDS);
- switch (BKE_pbvh_type(ss->pbvh)) {
- case PBVH_FACES:
- return ss->active_vertex_index;
- case PBVH_BMESH:
- return ss->active_vertex_index;
- case PBVH_GRIDS:
- BLI_assert(!"This fuction is not supposed to be used for PBVH_GRIDS");
- break;
- }
- return 0;
-}
-
-static float *sculpt_active_vertex_co_get(SculptSession *ss)
-{
- return sculpt_vertex_co_get(ss, sculpt_active_vertex_get(ss));
-}
-
static int sculpt_vertex_count_get(SculptSession *ss)
{
switch (BKE_pbvh_type(ss->pbvh)) {
@@ -152,44 +121,34 @@ static int sculpt_vertex_count_get(SculptSession *ss)
}
}
-static void sculpt_vertex_normal_get(SculptSession *ss, int index, float no[3])
+const float *sculpt_vertex_co_get(SculptSession *ss, int index)
{
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES:
- normal_short_to_float_v3(no, ss->mvert[index].no);
- return;
+ return ss->mvert[index].co;
case PBVH_BMESH:
- copy_v3_v3(no, BM_vert_at_index(BKE_pbvh_get_bmesh(ss->pbvh), index)->no);
+ return BM_vert_at_index(BKE_pbvh_get_bmesh(ss->pbvh), index)->co;
+ case PBVH_GRIDS:
+ BLI_assert(!"This fuction is not supposed to be used for PBVH_GRIDS");
break;
- default:
- zero_v3(no);
- return;
}
+ return NULL;
}
-static void sculpt_active_vertex_normal_get(SculptSession *ss, float normal[3])
-{
- sculpt_vertex_normal_get(ss, sculpt_active_vertex_get(ss), normal);
-}
-
-static void UNUSED_FUNCTION(sculpt_vertex_mask_set)(SculptSession *ss, int index, float mask)
+static void sculpt_vertex_normal_get(SculptSession *ss, int index, float no[3])
{
- BMVert *v;
- float *mask_p;
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES:
- ss->vmask[index] = mask;
+ normal_short_to_float_v3(no, ss->mvert[index].no);
return;
case PBVH_BMESH:
- v = BM_vert_at_index(BKE_pbvh_get_bmesh(ss->pbvh), index);
- mask_p = BM_ELEM_CD_GET_VOID_P(v, CustomData_get_offset(&ss->bm->vdata, CD_PAINT_MASK));
- *(mask_p) = mask;
- return;
+ copy_v3_v3(no, BM_vert_at_index(BKE_pbvh_get_bmesh(ss->pbvh), index)->no);
+ break;
default:
+ zero_v3(no);
return;
}
}
-
static float sculpt_vertex_mask_get(SculptSession *ss, int index)
{
BMVert *v;
@@ -206,31 +165,29 @@ static float sculpt_vertex_mask_get(SculptSession *ss, int index)
}
}
-static void UNUSED_FUNCTION(sculpt_vertex_co_set)(SculptSession *ss, int index, float co[3])
+static int sculpt_active_vertex_get(SculptSession *ss)
{
+ BLI_assert(BKE_pbvh_type(ss->pbvh) != PBVH_GRIDS);
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES:
- copy_v3_v3(ss->mvert[index].co, co);
- return;
+ return ss->active_vertex_index;
case PBVH_BMESH:
- copy_v3_v3(BM_vert_at_index(BKE_pbvh_get_bmesh(ss->pbvh), index)->co, co);
- return;
- default:
- return;
+ return ss->active_vertex_index;
+ case PBVH_GRIDS:
+ BLI_assert(!"This fuction is not supposed to be used for PBVH_GRIDS");
+ break;
}
+ return 0;
}
-static void UNUSED_FUNCTION(sculpt_vertex_tag_update)(SculptSession *ss, int index)
+static const float *sculpt_active_vertex_co_get(SculptSession *ss)
{
- switch (BKE_pbvh_type(ss->pbvh)) {
- case PBVH_FACES:
- ss->mvert[index].flag |= ME_VERT_PBVH_UPDATE;
- return;
- case PBVH_BMESH:
- return;
- default:
- return;
- }
+ return sculpt_vertex_co_get(ss, sculpt_active_vertex_get(ss));
+}
+
+static void sculpt_active_vertex_normal_get(SculptSession *ss, float normal[3])
+{
+ sculpt_vertex_normal_get(ss, sculpt_active_vertex_get(ss), normal);
}
#define SCULPT_VERTEX_NEIGHBOR_FIXED_CAPACITY 256
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index b895ff421f9..201aade44cd 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -75,7 +75,7 @@ void sculpt_pose_calc_pose_data(struct Sculpt *sd,
float *r_pose_factor);
/* Sculpt PBVH abstraction API */
-float *sculpt_vertex_co_get(struct SculptSession *ss, int index);
+const float *sculpt_vertex_co_get(struct SculptSession *ss, int index);
/* Dynamic topology */
void sculpt_pbvh_clear(Object *ob);