forked from blender/blender
WIP: uv-simple-select #1
@ -496,7 +496,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_lattice_wire_clipped)
|
||||
GPU_SHADER_CREATE_INFO(overlay_edit_particle_strand)
|
||||
.do_static_compilation(true)
|
||||
.vertex_in(0, Type::VEC3, "pos")
|
||||
.vertex_in(1, Type::FLOAT, "color")
|
||||
.vertex_in(1, Type::FLOAT, "selection")
|
||||
.sampler(0, ImageType::FLOAT_1D, "weightTex")
|
||||
.push_constant(Type::BOOL, "useWeight")
|
||||
.vertex_out(overlay_edit_smooth_color_iface)
|
||||
@ -512,7 +512,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_particle_strand_clipped)
|
||||
GPU_SHADER_CREATE_INFO(overlay_edit_particle_point)
|
||||
.do_static_compilation(true)
|
||||
.vertex_in(0, Type::VEC3, "pos")
|
||||
.vertex_in(1, Type::FLOAT, "color")
|
||||
.vertex_in(1, Type::FLOAT, "selection")
|
||||
.vertex_out(overlay_edit_flat_color_iface)
|
||||
.fragment_out(0, Type::VEC4, "fragColor")
|
||||
.vertex_source("overlay_edit_particle_point_vert.glsl")
|
||||
|
@ -7,7 +7,7 @@ void main()
|
||||
vec3 world_pos = point_object_to_world(pos);
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
|
||||
finalColor = mix(colorWire, colorVertexSelect, color);
|
||||
finalColor = mix(colorWire, colorVertexSelect, selection);
|
||||
|
||||
gl_PointSize = sizeVertex * 2.0;
|
||||
|
||||
|
@ -25,10 +25,10 @@ void main()
|
||||
gl_Position = point_world_to_ndc(world_pos);
|
||||
|
||||
if (useWeight) {
|
||||
finalColor = vec4(weight_to_rgb(color), 1.0);
|
||||
finalColor = vec4(weight_to_rgb(selection), 1.0);
|
||||
}
|
||||
else {
|
||||
finalColor = mix(colorWire, colorVertexSelect, color);
|
||||
finalColor = mix(colorWire, colorVertexSelect, selection);
|
||||
}
|
||||
|
||||
view_clipping_distances(world_pos);
|
||||
|
@ -54,11 +54,11 @@ struct CurvesBatchCache {
|
||||
GPUBatch *edit_points;
|
||||
GPUBatch *edit_lines;
|
||||
|
||||
/* Editmode (original) point positions. */
|
||||
/* Crazy-space point positions for original points. */
|
||||
GPUVertBuf *edit_points_pos;
|
||||
|
||||
/* Editmode data (such as selection). */
|
||||
GPUVertBuf *edit_points_data;
|
||||
/* Selection of original points. */
|
||||
GPUVertBuf *edit_points_selection;
|
||||
|
||||
GPUIndexBuf *edit_lines_ibo;
|
||||
|
||||
@ -113,7 +113,7 @@ static void curves_batch_cache_clear_edit_data(CurvesBatchCache *cache)
|
||||
{
|
||||
/* TODO: more granular update tagging. */
|
||||
GPU_VERTBUF_DISCARD_SAFE(cache->edit_points_pos);
|
||||
GPU_VERTBUF_DISCARD_SAFE(cache->edit_points_data);
|
||||
GPU_VERTBUF_DISCARD_SAFE(cache->edit_points_selection);
|
||||
GPU_INDEXBUF_DISCARD_SAFE(cache->edit_lines_ibo);
|
||||
|
||||
GPU_BATCH_DISCARD_SAFE(cache->edit_points);
|
||||
@ -255,18 +255,19 @@ static void curves_batch_cache_ensure_edit_points_pos(const bke::CurvesGeometry
|
||||
GPU_vertbuf_attr_fill(cache.edit_points_pos, pos, deformed_positions.data());
|
||||
}
|
||||
|
||||
static void curves_batch_cache_ensure_edit_points_data(const bke::CurvesGeometry &curves,
|
||||
static void curves_batch_cache_ensure_edit_points_selection(const bke::CurvesGeometry &curves,
|
||||
const eAttrDomain selection_domain,
|
||||
CurvesBatchCache &cache)
|
||||
{
|
||||
static GPUVertFormat format_data = {0};
|
||||
static uint color;
|
||||
static uint selection_id;
|
||||
if (format_data.attr_len == 0) {
|
||||
color = GPU_vertformat_attr_add(&format_data, "color", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
|
||||
selection_id = GPU_vertformat_attr_add(
|
||||
&format_data, "selection", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
|
||||
}
|
||||
|
||||
GPU_vertbuf_init_with_format(cache.edit_points_data, &format_data);
|
||||
GPU_vertbuf_data_alloc(cache.edit_points_data, curves.points_num());
|
||||
GPU_vertbuf_init_with_format(cache.edit_points_selection, &format_data);
|
||||
GPU_vertbuf_data_alloc(cache.edit_points_selection, curves.points_num());
|
||||
|
||||
const OffsetIndices points_by_curve = curves.points_by_curve();
|
||||
|
||||
@ -276,7 +277,7 @@ static void curves_batch_cache_ensure_edit_points_data(const bke::CurvesGeometry
|
||||
case ATTR_DOMAIN_POINT:
|
||||
for (const int point_i : selection.index_range()) {
|
||||
const float point_selection = selection[point_i] ? 1.0f : 0.0f;
|
||||
GPU_vertbuf_attr_set(cache.edit_points_data, color, point_i, &point_selection);
|
||||
GPU_vertbuf_attr_set(cache.edit_points_selection, selection_id, point_i, &point_selection);
|
||||
}
|
||||
break;
|
||||
case ATTR_DOMAIN_CURVE:
|
||||
@ -284,7 +285,8 @@ static void curves_batch_cache_ensure_edit_points_data(const bke::CurvesGeometry
|
||||
const float curve_selection = selection[curve_i] ? 1.0f : 0.0f;
|
||||
const IndexRange points = points_by_curve[curve_i];
|
||||
for (const int point_i : points) {
|
||||
GPU_vertbuf_attr_set(cache.edit_points_data, color, point_i, &curve_selection);
|
||||
GPU_vertbuf_attr_set(
|
||||
cache.edit_points_selection, selection_id, point_i, &curve_selection);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -760,18 +762,18 @@ void DRW_curves_batch_cache_create_requested(Object *ob)
|
||||
|
||||
if (DRW_batch_requested(cache.edit_points, GPU_PRIM_POINTS)) {
|
||||
DRW_vbo_request(cache.edit_points, &cache.edit_points_pos);
|
||||
DRW_vbo_request(cache.edit_points, &cache.edit_points_data);
|
||||
DRW_vbo_request(cache.edit_points, &cache.edit_points_selection);
|
||||
}
|
||||
if (DRW_batch_requested(cache.edit_lines, GPU_PRIM_LINE_STRIP)) {
|
||||
DRW_ibo_request(cache.edit_lines, &cache.edit_lines_ibo);
|
||||
DRW_vbo_request(cache.edit_lines, &cache.edit_points_pos);
|
||||
DRW_vbo_request(cache.edit_lines, &cache.edit_points_data);
|
||||
DRW_vbo_request(cache.edit_lines, &cache.edit_points_selection);
|
||||
}
|
||||
if (DRW_vbo_requested(cache.edit_points_pos)) {
|
||||
curves_batch_cache_ensure_edit_points_pos(curves_orig, deformation.positions, cache);
|
||||
}
|
||||
if (DRW_vbo_requested(cache.edit_points_data)) {
|
||||
curves_batch_cache_ensure_edit_points_data(
|
||||
if (DRW_vbo_requested(cache.edit_points_selection)) {
|
||||
curves_batch_cache_ensure_edit_points_selection(
|
||||
curves_orig, eAttrDomain(curves_id->selection_domain), cache);
|
||||
}
|
||||
if (DRW_ibo_requested(cache.edit_lines_ibo)) {
|
||||
|
@ -89,21 +89,21 @@ typedef struct HairAttributeID {
|
||||
|
||||
typedef struct EditStrandData {
|
||||
float pos[3];
|
||||
float color;
|
||||
float selection;
|
||||
} EditStrandData;
|
||||
|
||||
static GPUVertFormat *edit_points_vert_format_get(uint *r_pos_id, uint *r_color_id)
|
||||
static GPUVertFormat *edit_points_vert_format_get(uint *r_pos_id, uint *r_selection_id)
|
||||
{
|
||||
static GPUVertFormat edit_point_format = {0};
|
||||
static uint pos_id, color_id;
|
||||
static uint pos_id, selection_id;
|
||||
if (edit_point_format.attr_len == 0) {
|
||||
/* Keep in sync with EditStrandData */
|
||||
pos_id = GPU_vertformat_attr_add(&edit_point_format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
||||
color_id = GPU_vertformat_attr_add(
|
||||
&edit_point_format, "color", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
|
||||
selection_id = GPU_vertformat_attr_add(
|
||||
&edit_point_format, "selection", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
|
||||
}
|
||||
*r_pos_id = pos_id;
|
||||
*r_color_id = color_id;
|
||||
*r_selection_id = selection_id;
|
||||
return &edit_point_format;
|
||||
}
|
||||
|
||||
@ -697,11 +697,11 @@ static int particle_batch_cache_fill_segments_edit(
|
||||
if (particle) {
|
||||
float weight = particle_key_weight(particle, i, strand_t);
|
||||
/* NaN or unclamped become 1.0f */
|
||||
seg_data->color = (weight < 1.0f) ? weight : 1.0f;
|
||||
seg_data->selection = (weight < 1.0f) ? weight : 1.0f;
|
||||
}
|
||||
else {
|
||||
/* Computed in psys_cache_edit_paths_iter(). */
|
||||
seg_data->color = path[j].col[0];
|
||||
seg_data->selection = path[j].col[0];
|
||||
}
|
||||
GPU_indexbuf_add_generic_vert(elb, curr_point);
|
||||
curr_point++;
|
||||
@ -1530,8 +1530,8 @@ static void particle_batch_cache_ensure_edit_pos_and_seg(PTCacheEdit *edit,
|
||||
|
||||
GPUVertBufRaw data_step;
|
||||
GPUIndexBufBuilder elb;
|
||||
uint pos_id, color_id;
|
||||
GPUVertFormat *edit_point_format = edit_points_vert_format_get(&pos_id, &color_id);
|
||||
uint pos_id, selection_id;
|
||||
GPUVertFormat *edit_point_format = edit_points_vert_format_get(&pos_id, &selection_id);
|
||||
|
||||
hair_cache->pos = GPU_vertbuf_create_with_format(edit_point_format);
|
||||
GPU_vertbuf_data_alloc(hair_cache->pos, hair_cache->point_len);
|
||||
@ -1594,8 +1594,8 @@ static void particle_batch_cache_ensure_edit_inner_pos(PTCacheEdit *edit,
|
||||
return;
|
||||
}
|
||||
|
||||
uint pos_id, color_id;
|
||||
GPUVertFormat *edit_point_format = edit_points_vert_format_get(&pos_id, &color_id);
|
||||
uint pos_id, selection_id;
|
||||
GPUVertFormat *edit_point_format = edit_points_vert_format_get(&pos_id, &selection_id);
|
||||
|
||||
cache->edit_inner_pos = GPU_vertbuf_create_with_format(edit_point_format);
|
||||
GPU_vertbuf_data_alloc(cache->edit_inner_pos, cache->edit_inner_point_len);
|
||||
@ -1608,9 +1608,9 @@ static void particle_batch_cache_ensure_edit_inner_pos(PTCacheEdit *edit,
|
||||
}
|
||||
for (int key_index = 0; key_index < point->totkey - 1; key_index++) {
|
||||
PTCacheEditKey *key = &point->keys[key_index];
|
||||
float color = (key->flag & PEK_SELECT) ? 1.0f : 0.0f;
|
||||
float selection = (key->flag & PEK_SELECT) ? 1.0f : 0.0f;
|
||||
GPU_vertbuf_attr_set(cache->edit_inner_pos, pos_id, global_key_index, key->world_co);
|
||||
GPU_vertbuf_attr_set(cache->edit_inner_pos, color_id, global_key_index, &color);
|
||||
GPU_vertbuf_attr_set(cache->edit_inner_pos, selection_id, global_key_index, &selection);
|
||||
global_key_index++;
|
||||
}
|
||||
}
|
||||
@ -1652,8 +1652,8 @@ static void particle_batch_cache_ensure_edit_tip_pos(PTCacheEdit *edit, Particle
|
||||
return;
|
||||
}
|
||||
|
||||
uint pos_id, color_id;
|
||||
GPUVertFormat *edit_point_format = edit_points_vert_format_get(&pos_id, &color_id);
|
||||
uint pos_id, selection_id;
|
||||
GPUVertFormat *edit_point_format = edit_points_vert_format_get(&pos_id, &selection_id);
|
||||
|
||||
cache->edit_tip_pos = GPU_vertbuf_create_with_format(edit_point_format);
|
||||
GPU_vertbuf_data_alloc(cache->edit_tip_pos, cache->edit_tip_point_len);
|
||||
@ -1665,10 +1665,10 @@ static void particle_batch_cache_ensure_edit_tip_pos(PTCacheEdit *edit, Particle
|
||||
continue;
|
||||
}
|
||||
PTCacheEditKey *key = &point->keys[point->totkey - 1];
|
||||
float color = (key->flag & PEK_SELECT) ? 1.0f : 0.0f;
|
||||
float selection = (key->flag & PEK_SELECT) ? 1.0f : 0.0f;
|
||||
|
||||
GPU_vertbuf_attr_set(cache->edit_tip_pos, pos_id, global_point_index, key->world_co);
|
||||
GPU_vertbuf_attr_set(cache->edit_tip_pos, color_id, global_point_index, &color);
|
||||
GPU_vertbuf_attr_set(cache->edit_tip_pos, selection_id, global_point_index, &selection);
|
||||
global_point_index++;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user