DRW: overlay engine support for drawing isolated points

This matches similar functionality for drawing lines.
This commit is contained in:
Campbell Barton 2020-07-20 09:19:09 +10:00
parent 78e40ad21f
commit 9db4e44961
Notes: blender-bot 2023-02-14 00:44:02 +01:00
Referenced by issue #84397, Creating and removing many objects very quickly causes a crash
4 changed files with 17 additions and 0 deletions

View File

@ -178,6 +178,7 @@ void OVERLAY_armature_cache_init(OVERLAY_Data *vedata)
#define BUF_INSTANCE DRW_shgroup_call_buffer_instance
#define BUF_LINE(grp, format) DRW_shgroup_call_buffer(grp, format, GPU_PRIM_LINES)
#define BUF_POINT(grp, format) DRW_shgroup_call_buffer(grp, format, GPU_PRIM_POINTS)
{
format = formats->instance_bone;

View File

@ -199,6 +199,9 @@ void OVERLAY_extra_cache_init(OVERLAY_Data *vedata)
cb->extra_loose_points = grp = DRW_shgroup_create(sh, extra_ps);
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
/* Buffer access for drawing isolated points, matching `extra_lines`. */
cb->extra_points = BUF_POINT(grp, formats->point_extra);
}
{
format = formats->pos;
@ -230,6 +233,11 @@ void OVERLAY_extra_cache_init(OVERLAY_Data *vedata)
}
}
void OVERLAY_extra_point(OVERLAY_ExtraCallBuffers *cb, const float point[3], const float color[4])
{
DRW_buffer_add_entry(cb->extra_points, point, color);
}
void OVERLAY_extra_line_dashed(OVERLAY_ExtraCallBuffers *cb,
const float start[3],
const float end[3],

View File

@ -149,6 +149,7 @@ typedef struct OVERLAY_ExtraCallBuffers {
DRWCallBuffer *extra_dashed_lines;
DRWCallBuffer *extra_lines;
DRWCallBuffer *extra_points;
DRWCallBuffer *field_curve;
DRWCallBuffer *field_force;
@ -388,6 +389,7 @@ typedef struct OVERLAY_InstanceFormats {
struct GPUVertFormat *pos;
struct GPUVertFormat *pos_color;
struct GPUVertFormat *wire_extra;
struct GPUVertFormat *point_extra;
} OVERLAY_InstanceFormats;
/* Pack data into the last row of the 4x4 matrix. It will be decoded by the vertex shader. */
@ -481,6 +483,7 @@ void OVERLAY_lightprobe_cache_populate(OVERLAY_Data *vedata, Object *ob);
void OVERLAY_speaker_cache_populate(OVERLAY_Data *vedata, Object *ob);
OVERLAY_ExtraCallBuffers *OVERLAY_extra_call_buffer_get(OVERLAY_Data *vedata, Object *ob);
void OVERLAY_extra_point(OVERLAY_ExtraCallBuffers *cb, const float point[3], const float color[4]);
void OVERLAY_extra_line_dashed(OVERLAY_ExtraCallBuffers *cb,
const float start[3],
const float end[3],

View File

@ -1476,6 +1476,11 @@ OVERLAY_InstanceFormats *OVERLAY_shader_instance_formats_get(void)
{"pos", DRW_ATTR_FLOAT, 3},
{"colorid", DRW_ATTR_INT, 1},
});
DRW_shgroup_instance_format(g_formats.point_extra,
{
{"pos", DRW_ATTR_FLOAT, 3},
{"colorid", DRW_ATTR_INT, 1},
});
DRW_shgroup_instance_format(g_formats.instance_bone,
{
{"inst_obmat", DRW_ATTR_FLOAT, 16},