[Bf-blender-cvs] [c438ca96bae] greasepencil-object: GP: Fix control points size when change zoom
Antonioya
noreply at git.blender.org
Tue Dec 11 15:22:48 CET 2018
Commit: c438ca96bae6983e10e2bca438c035abbdb350d8
Author: Antonioya
Date: Tue Dec 11 15:22:16 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rBc438ca96bae6983e10e2bca438c035abbdb350d8
GP: Fix control points size when change zoom
Also replaced the shader used.
===================================================================
M source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M source/blender/draw/engines/gpencil/gpencil_draw_utils.c
===================================================================
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 82c62684e3f..89b08966e9d 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -391,12 +391,11 @@ GPUBatch *DRW_gpencil_get_buffer_ctrlpoint_geom(bGPdata *gpd)
int totpoints = gpd->runtime.tot_cp_points;
static GPUVertFormat format = { 0 };
- static uint pos_id, color_id, thickness_id, uvdata_id;
+ static uint pos_id, color_id, size_id;
if (format.attr_len == 0) {
pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ size_id = GPU_vertformat_attr_add(&format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
color_id = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
- thickness_id = GPU_vertformat_attr_add(&format, "thickness", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
- uvdata_id = GPU_vertformat_attr_add(&format, "uvdata", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
}
GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
@@ -410,13 +409,9 @@ GPUBatch *DRW_gpencil_get_buffer_ctrlpoint_geom(bGPdata *gpd)
color[3] = 0.8f;
GPU_vertbuf_attr_set(vbo, color_id, idx, color);
- /* transfer both values using the same shader variable */
- float uvdata[2] = { 0.0f, 0.0f };
- GPU_vertbuf_attr_set(vbo, uvdata_id, idx, uvdata);
-
- /* scale size to get more visible points */
- float size = cp->size * 8.0f;
- GPU_vertbuf_attr_set(vbo, thickness_id, idx, &size);
+ /* scale size */
+ float size = cp->size * 0.8f;
+ GPU_vertbuf_attr_set(vbo, size_id, idx, &size);
GPU_vertbuf_attr_set(vbo, pos_id, idx, &cp->x);
idx++;
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index c9b4def0124..04acd89d9ac 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -560,39 +560,6 @@ static DRWShadingGroup *DRW_gpencil_shgroup_point_create(
return grp;
}
-/* create shading group for control points */
-static DRWShadingGroup *DRW_gpencil_shgroup_ctrlpoint_create(
- GPENCIL_e_data *e_data, GPENCIL_Data *vedata, DRWPass *pass, GPUShader *shader, Object *ob,
- bGPdata *gpd)
-{
- GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
- const float *viewport_size = DRW_viewport_size_get();
-
- /* e_data.gpencil_stroke_sh */
- DRWShadingGroup *grp = DRW_shgroup_create(shader, pass);
-
- DRW_shgroup_uniform_vec2(grp, "Viewport", viewport_size, 1);
- DRW_shgroup_uniform_float(grp, "pixsize", stl->storage->pixsize, 1);
-
- stl->storage->obj_scale = 1.0f;
- stl->storage->keep_size = 0;
- stl->storage->pixfactor = GP_DEFAULT_PIX_FACTOR;
- stl->storage->mode = GP_STYLE_STROKE_STYLE_SOLID;
- DRW_shgroup_uniform_float(grp, "objscale", &stl->storage->obj_scale, 1);
- const int keep = 1;
- DRW_shgroup_uniform_int(grp, "keep_size", &keep, 1);
- DRW_shgroup_uniform_int(grp, "color_type", &stl->storage->color_type, 1);
- DRW_shgroup_uniform_int(grp, "mode", &stl->storage->mode, 1);
- DRW_shgroup_uniform_float(grp, "pixfactor", &stl->storage->pixfactor, 1);
-
- /* for drawing always on on predefined z-depth */
- DRW_shgroup_uniform_int(grp, "xraymode", &stl->storage->xray, 1);
-
- DRW_shgroup_uniform_texture(grp, "myTexture", e_data->gpencil_blank_texture);
-
- return grp;
-}
-
/* add fill vertex info */
static void gpencil_add_fill_vertexdata(
GpencilBatchCache *cache,
@@ -1295,8 +1262,8 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data, void *vedata, T
((gpd->runtime.sbuffer_sflag & GP_STROKE_ERASER) == 0))
{
- DRWShadingGroup *shgrp = DRW_gpencil_shgroup_ctrlpoint_create(
- e_data, vedata, psl->drawing_pass, e_data->gpencil_point_sh, NULL, gpd);
+ DRWShadingGroup *shgrp = DRW_shgroup_create(
+ e_data->gpencil_edit_point_sh, psl->drawing_pass);
/* clean previous version of the batch */
if (stl->storage->buffer_ctrlpoint) {
More information about the Bf-blender-cvs
mailing list