* Fixed vcol drawing in indexed smooth shading mode
This commit is contained in:
parent
73c590e1eb
commit
14be52f0fc
|
@ -157,7 +157,7 @@ static void pose_solve_scale_chain(SculptPoseIKChain *ik_chain, const float scal
|
|||
}
|
||||
}
|
||||
|
||||
ATTR_NO_OPT static void do_pose_brush_task_cb_ex(void *__restrict userdata,
|
||||
static void do_pose_brush_task_cb_ex(void *__restrict userdata,
|
||||
const int n,
|
||||
const TaskParallelTLS *__restrict UNUSED(tls))
|
||||
{
|
||||
|
@ -222,7 +222,7 @@ typedef struct PoseGrowFactorTLSData {
|
|||
int pos_count;
|
||||
} PoseGrowFactorTLSData;
|
||||
|
||||
ATTR_NO_OPT static void pose_brush_grow_factor_task_cb_ex(void *__restrict userdata,
|
||||
static void pose_brush_grow_factor_task_cb_ex(void *__restrict userdata,
|
||||
const int n,
|
||||
const TaskParallelTLS *__restrict tls)
|
||||
{
|
||||
|
@ -255,7 +255,7 @@ ATTR_NO_OPT static void pose_brush_grow_factor_task_cb_ex(void *__restrict userd
|
|||
BKE_pbvh_vertex_iter_end;
|
||||
}
|
||||
|
||||
ATTR_NO_OPT static void pose_brush_grow_factor_reduce(const void *__restrict UNUSED(userdata),
|
||||
static void pose_brush_grow_factor_reduce(const void *__restrict UNUSED(userdata),
|
||||
void *__restrict chunk_join,
|
||||
void *__restrict chunk)
|
||||
{
|
||||
|
@ -267,7 +267,7 @@ ATTR_NO_OPT static void pose_brush_grow_factor_reduce(const void *__restrict UNU
|
|||
|
||||
/* Grow the factor until its boundary is near to the offset pose origin or outside the target
|
||||
* distance. */
|
||||
ATTR_NO_OPT static void sculpt_pose_grow_pose_factor(Sculpt *sd,
|
||||
static void sculpt_pose_grow_pose_factor(Sculpt *sd,
|
||||
Object *ob,
|
||||
SculptSession *ss,
|
||||
float pose_origin[3],
|
||||
|
@ -413,8 +413,11 @@ typedef struct PoseFloodFillData {
|
|||
int target_face_set;
|
||||
} PoseFloodFillData;
|
||||
|
||||
static bool pose_topology_floodfill_cb(
|
||||
SculptSession *ss, SculptVertRef UNUSED(from_v), SculptVertRef to_vref, bool is_duplicate, void *userdata)
|
||||
static bool pose_topology_floodfill_cb(SculptSession *ss,
|
||||
SculptVertRef UNUSED(from_v),
|
||||
SculptVertRef to_vref,
|
||||
bool is_duplicate,
|
||||
void *userdata)
|
||||
{
|
||||
PoseFloodFillData *data = userdata;
|
||||
int to_v = BKE_pbvh_vertex_index_to_table(ss->pbvh, to_vref);
|
||||
|
@ -444,8 +447,11 @@ static bool pose_topology_floodfill_cb(
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool pose_face_sets_floodfill_cb(
|
||||
SculptSession *ss, SculptVertRef UNUSED(from_v), SculptVertRef to_v, bool is_duplicate, void *userdata)
|
||||
static bool pose_face_sets_floodfill_cb(SculptSession *ss,
|
||||
SculptVertRef UNUSED(from_v),
|
||||
SculptVertRef to_v,
|
||||
bool is_duplicate,
|
||||
void *userdata)
|
||||
{
|
||||
PoseFloodFillData *data = userdata;
|
||||
|
||||
|
@ -549,7 +555,7 @@ static bool pose_face_sets_floodfill_cb(
|
|||
* \param r_pose_origin: Must be a valid pointer.
|
||||
* \param r_pose_factor: Optional, when set to NULL it won't be calculated.
|
||||
*/
|
||||
ATTR_NO_OPT void SCULPT_pose_calc_pose_data(Sculpt *sd,
|
||||
void SCULPT_pose_calc_pose_data(Sculpt *sd,
|
||||
Object *ob,
|
||||
SculptSession *ss,
|
||||
float initial_location[3],
|
||||
|
@ -635,7 +641,7 @@ static SculptPoseIKChain *pose_ik_chain_new(const int totsegments, const int tot
|
|||
}
|
||||
|
||||
/* Init the origin/head pairs of all the segments from the calculated origins. */
|
||||
ATTR_NO_OPT static void pose_ik_chain_origin_heads_init(SculptPoseIKChain *ik_chain,
|
||||
static void pose_ik_chain_origin_heads_init(SculptPoseIKChain *ik_chain,
|
||||
const float initial_location[3])
|
||||
{
|
||||
float origin[3];
|
||||
|
@ -671,7 +677,7 @@ static int pose_brush_num_effective_segments(const Brush *brush)
|
|||
return brush->pose_ik_segments;
|
||||
}
|
||||
|
||||
ATTR_NO_OPT static SculptPoseIKChain *pose_ik_chain_init_topology(Sculpt *sd,
|
||||
static SculptPoseIKChain *pose_ik_chain_init_topology(Sculpt *sd,
|
||||
Object *ob,
|
||||
SculptSession *ss,
|
||||
Brush *br,
|
||||
|
@ -684,7 +690,8 @@ ATTR_NO_OPT static SculptPoseIKChain *pose_ik_chain_init_topology(Sculpt *sd,
|
|||
float next_chain_segment_target[3];
|
||||
|
||||
int totvert = SCULPT_vertex_count_get(ss);
|
||||
SculptVertRef nearest_vertex = SCULPT_nearest_vertex_get(sd, ob, initial_location, FLT_MAX, true);
|
||||
SculptVertRef nearest_vertex = SCULPT_nearest_vertex_get(
|
||||
sd, ob, initial_location, FLT_MAX, true);
|
||||
int nearest_vertex_index = BKE_pbvh_vertex_index_to_table(ss->pbvh, nearest_vertex);
|
||||
|
||||
/* Init the buffers used to keep track of the changes in the pose factors as more segments are
|
||||
|
@ -753,7 +760,7 @@ ATTR_NO_OPT static SculptPoseIKChain *pose_ik_chain_init_topology(Sculpt *sd,
|
|||
return ik_chain;
|
||||
}
|
||||
|
||||
ATTR_NO_OPT static SculptPoseIKChain *pose_ik_chain_init_face_sets(
|
||||
static SculptPoseIKChain *pose_ik_chain_init_face_sets(
|
||||
Sculpt *sd, Object *ob, SculptSession *ss, Brush *br, const float radius)
|
||||
{
|
||||
|
||||
|
@ -826,8 +833,11 @@ ATTR_NO_OPT static SculptPoseIKChain *pose_ik_chain_init_face_sets(
|
|||
return ik_chain;
|
||||
}
|
||||
|
||||
static bool pose_face_sets_fk_find_masked_floodfill_cb(
|
||||
SculptSession *ss, SculptVertRef from_vr, SculptVertRef to_vr, bool is_duplicate, void *userdata)
|
||||
static bool pose_face_sets_fk_find_masked_floodfill_cb(SculptSession *ss,
|
||||
SculptVertRef from_vr,
|
||||
SculptVertRef to_vr,
|
||||
bool is_duplicate,
|
||||
void *userdata)
|
||||
{
|
||||
PoseFloodFillData *data = userdata;
|
||||
int from_v = BKE_pbvh_vertex_index_to_table(ss->pbvh, from_vr);
|
||||
|
@ -862,15 +872,18 @@ static bool pose_face_sets_fk_find_masked_floodfill_cb(
|
|||
return SCULPT_vertex_has_face_set(ss, to_vr, data->initial_face_set);
|
||||
}
|
||||
|
||||
ATTR_NO_OPT static bool pose_face_sets_fk_set_weights_floodfill_cb(
|
||||
SculptSession *ss, SculptVertRef UNUSED(from_v), SculptVertRef to_v, bool UNUSED(is_duplicate), void *userdata)
|
||||
static bool pose_face_sets_fk_set_weights_floodfill_cb(SculptSession *ss,
|
||||
SculptVertRef UNUSED(from_v),
|
||||
SculptVertRef to_v,
|
||||
bool UNUSED(is_duplicate),
|
||||
void *userdata)
|
||||
{
|
||||
PoseFloodFillData *data = userdata;
|
||||
data->fk_weights[BKE_pbvh_vertex_index_to_table(ss->pbvh, to_v)] = 1.0f;
|
||||
return !SCULPT_vertex_has_face_set(ss, to_v, data->masked_face_set);
|
||||
}
|
||||
|
||||
ATTR_NO_OPT static SculptPoseIKChain *pose_ik_chain_init_face_sets_fk(
|
||||
static SculptPoseIKChain *pose_ik_chain_init_face_sets_fk(
|
||||
Sculpt *sd, Object *ob, SculptSession *ss, const float radius, const float *initial_location)
|
||||
{
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
|
@ -902,7 +915,8 @@ ATTR_NO_OPT static SculptPoseIKChain *pose_ik_chain_init_face_sets_fk(
|
|||
for (int i = 0; i < totvert; i++) {
|
||||
SculptVertRef vref = BKE_pbvh_table_index_to_vertex(ss->pbvh, i);
|
||||
|
||||
if (fdata.floodfill_it[i] != 0 && SCULPT_vertex_has_face_set(ss, vref, fdata.initial_face_set) &&
|
||||
if (fdata.floodfill_it[i] != 0 &&
|
||||
SCULPT_vertex_has_face_set(ss, vref, fdata.initial_face_set) &&
|
||||
SCULPT_vertex_has_face_set(ss, vref, fdata.masked_face_set)) {
|
||||
add_v3_v3(origin_acc, SCULPT_vertex_co_get(ss, vref));
|
||||
origin_count++;
|
||||
|
|
|
@ -790,7 +790,8 @@ static void gpu_bmesh_vert_to_buffer_copy(BMVert *v,
|
|||
const bool show_mask,
|
||||
const bool show_vcol,
|
||||
bool *empty_mask,
|
||||
int cd_vcol_offset)
|
||||
const int cd_vcol_offsets[MAX_MCOL],
|
||||
int totvcol)
|
||||
{
|
||||
/* Vertex should always be visible if it's used by a visible face. */
|
||||
BLI_assert(!BM_elem_flag_test(v, BM_ELEM_HIDDEN));
|
||||
|
@ -816,20 +817,22 @@ static void gpu_bmesh_vert_to_buffer_copy(BMVert *v,
|
|||
*empty_mask = *empty_mask && (cmask == 0);
|
||||
}
|
||||
|
||||
if (show_vcol && cd_vcol_offset >= 0) {
|
||||
ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX};
|
||||
|
||||
MPropCol *col = BM_ELEM_CD_GET_VOID_P(v, cd_vcol_offset);
|
||||
if (show_vcol && totvcol > 0) {
|
||||
for (int i = 0; i < totvcol; i++) {
|
||||
ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX};
|
||||
|
||||
vcol[0] = unit_float_to_ushort_clamp(col->color[0]);
|
||||
vcol[1] = unit_float_to_ushort_clamp(col->color[1]);
|
||||
vcol[2] = unit_float_to_ushort_clamp(col->color[2]);
|
||||
vcol[3] = unit_float_to_ushort_clamp(col->color[3]);
|
||||
MPropCol *col = BM_ELEM_CD_GET_VOID_P(v, cd_vcol_offsets[i]);
|
||||
|
||||
// const ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX};
|
||||
GPU_vertbuf_attr_set(vert_buf, g_vbo_id.col[0], v_index, vcol);
|
||||
vcol[0] = unit_float_to_ushort_clamp(col->color[0]);
|
||||
vcol[1] = unit_float_to_ushort_clamp(col->color[1]);
|
||||
vcol[2] = unit_float_to_ushort_clamp(col->color[2]);
|
||||
vcol[3] = unit_float_to_ushort_clamp(col->color[3]);
|
||||
|
||||
// const ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX};
|
||||
GPU_vertbuf_attr_set(vert_buf, g_vbo_id.col[i], v_index, vcol);
|
||||
}
|
||||
}
|
||||
else if (show_vcol) {
|
||||
else if (show_vcol) { // ensure first vcol attribute is not zero
|
||||
const ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX};
|
||||
GPU_vertbuf_attr_set(vert_buf, g_vbo_id.col[0], v_index, vcol);
|
||||
}
|
||||
|
@ -1299,8 +1302,8 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
|
|||
GHash *bm_vert_to_index = BLI_ghash_int_new_ex("bm_vert_to_index", totvert);
|
||||
BMFace *f;
|
||||
|
||||
for (int i=0; i<tribuf->totvert; i++) {
|
||||
BMVert *v = (BMVert*) tribuf->verts[i].i;
|
||||
for (int i = 0; i < tribuf->totvert; i++) {
|
||||
BMVert *v = (BMVert *)tribuf->verts[i].i;
|
||||
|
||||
gpu_bmesh_vert_to_buffer_copy(v,
|
||||
buffers->vert_buf,
|
||||
|
@ -1312,10 +1315,11 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
|
|||
show_mask,
|
||||
show_vcol,
|
||||
&empty_mask,
|
||||
cd_vcol_offset);
|
||||
cd_vcols,
|
||||
cd_vcol_count);
|
||||
}
|
||||
|
||||
for (int i=0; i<tribuf->tottri; i++) {
|
||||
for (int i = 0; i < tribuf->tottri; i++) {
|
||||
PBVHTri *tri = tribuf->tris + i;
|
||||
|
||||
GPU_indexbuf_add_tri_verts(&elb, tri->v[0], tri->v[1], tri->v[2]);
|
||||
|
@ -1323,7 +1327,6 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
|
|||
GPU_indexbuf_add_line_verts(&elb_lines, tri->v[0], tri->v[1]);
|
||||
GPU_indexbuf_add_line_verts(&elb_lines, tri->v[1], tri->v[2]);
|
||||
GPU_indexbuf_add_line_verts(&elb_lines, tri->v[2], tri->v[0]);
|
||||
|
||||
}
|
||||
|
||||
buffers->tot_tri = tottri;
|
||||
|
@ -1388,7 +1391,7 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
|
|||
show_mask,
|
||||
false,
|
||||
&empty_mask,
|
||||
-1);
|
||||
NULL, 0);
|
||||
|
||||
if (cd_vcol_count >= 0) {
|
||||
for (int j = 0; j < cd_vcol_count; j++) {
|
||||
|
|
Loading…
Reference in New Issue