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
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-12-13 03:26:07 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-12-14 18:17:29 +0300
commit2afed99da3a8e76b8041e9f636fb198b332896cc (patch)
tree685db211975adce08a3b299e3eb9cbf7fb7a8d44 /source/blender/draw/modes/edit_curve_mode.c
parent77164e30c730be27910d92a666d4b6c2d2d30721 (diff)
Curve Batch Cache: Rework Implementation to use new batch request
Shaded triangles are not yet implemented (request from gpumaterials). This also changes the mechanism to draw curve normals to make it not dependant on normal size display. This way different viewport can reuse the same batch.
Diffstat (limited to 'source/blender/draw/modes/edit_curve_mode.c')
-rw-r--r--source/blender/draw/modes/edit_curve_mode.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/source/blender/draw/modes/edit_curve_mode.c b/source/blender/draw/modes/edit_curve_mode.c
index 3d716d77405..b3cb2cb3d80 100644
--- a/source/blender/draw/modes/edit_curve_mode.c
+++ b/source/blender/draw/modes/edit_curve_mode.c
@@ -47,11 +47,13 @@ extern struct GlobalsUboStorage ts; /* draw_common.c */
extern char datatoc_common_globals_lib_glsl[];
extern char datatoc_edit_curve_overlay_loosevert_vert_glsl[];
+extern char datatoc_edit_curve_overlay_normals_vert_glsl[];
extern char datatoc_edit_curve_overlay_handle_vert_glsl[];
extern char datatoc_edit_curve_overlay_handle_geom_glsl[];
extern char datatoc_gpu_shader_point_varying_color_frag_glsl[];
extern char datatoc_gpu_shader_3D_smooth_color_frag_glsl[];
+extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
/* *********** LISTS *********** */
/* All lists are per viewport specific datas.
@@ -83,6 +85,7 @@ typedef struct EDIT_CURVE_Data {
static struct {
GPUShader *wire_sh;
+ GPUShader *wire_normals_sh;
GPUShader *overlay_edge_sh; /* handles and nurbs control cage */
GPUShader *overlay_vert_sh;
} e_data = {NULL}; /* Engine data */
@@ -90,6 +93,7 @@ static struct {
typedef struct EDIT_CURVE_PrivateData {
/* resulting curve as 'wire' for curves (and optionally normals) */
DRWShadingGroup *wire_shgrp;
+ DRWShadingGroup *wire_normals_shgrp;
DRWShadingGroup *overlay_edge_shgrp;
DRWShadingGroup *overlay_vert_shgrp;
@@ -108,6 +112,12 @@ static void EDIT_CURVE_engine_init(void *UNUSED(vedata))
e_data.wire_sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
}
+ if (!e_data.wire_normals_sh) {
+ e_data.wire_normals_sh = DRW_shader_create(
+ datatoc_edit_curve_overlay_normals_vert_glsl, NULL,
+ datatoc_gpu_shader_uniform_color_frag_glsl, NULL);
+ }
+
if (!e_data.overlay_edge_sh) {
e_data.overlay_edge_sh = DRW_shader_create_with_lib(
datatoc_edit_curve_overlay_handle_vert_glsl,
@@ -152,6 +162,12 @@ static void EDIT_CURVE_cache_init(void *vedata)
DRW_shgroup_uniform_vec4(grp, "color", ts.colorWireEdit, 1);
stl->g_data->wire_shgrp = grp;
+
+ grp = DRW_shgroup_create(e_data.wire_normals_sh, psl->wire_pass);
+ DRW_shgroup_uniform_vec4(grp, "color", ts.colorWireEdit, 1);
+ DRW_shgroup_uniform_float_copy(grp, "normalSize", v3d->overlay.normals_length);
+ stl->g_data->wire_normals_shgrp = grp;
+
psl->overlay_edge_pass = DRW_pass_create(
"Curve Handle Overlay",
DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND);
@@ -190,8 +206,9 @@ static void EDIT_CURVE_cache_populate(void *vedata, Object *ob)
DRW_shgroup_call_add(stl->g_data->wire_shgrp, geom, ob->obmat);
if ((cu->flag & CU_3D) && (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_CU_NORMALS) != 0) {
- geom = DRW_cache_curve_edge_normal_get(ob, v3d->overlay.normals_length);
- DRW_shgroup_call_add(stl->g_data->wire_shgrp, geom, ob->obmat);
+ static uint instance_len = 2;
+ geom = DRW_cache_curve_edge_normal_get(ob);
+ DRW_shgroup_call_instances_add(stl->g_data->wire_normals_shgrp, geom, ob->obmat, &instance_len);
}
geom = DRW_cache_curve_edge_overlay_get(ob);
@@ -242,6 +259,7 @@ static void EDIT_CURVE_draw_scene(void *vedata)
* Mostly used for freeing shaders */
static void EDIT_CURVE_engine_free(void)
{
+ DRW_SHADER_FREE_SAFE(e_data.wire_normals_sh);
DRW_SHADER_FREE_SAFE(e_data.overlay_edge_sh);
DRW_SHADER_FREE_SAFE(e_data.overlay_vert_sh);
}