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:
authorKévin Dietrich <kevin.dietrich@mailoo.org>2022-04-08 19:23:40 +0300
committerKévin Dietrich <kevin.dietrich@mailoo.org>2022-04-08 19:23:40 +0300
commite15320568a29e163b32e261dc1aaee22404e0dac (patch)
tree8fd74e1dbd0bde5839e846c2f47da028a4a3ce06 /source/blender/draw/intern/draw_cache_impl_curves.cc
parent3039b215ba2af5ed63446aba72244b6bc5a4fd18 (diff)
Curves edit mode: show dots for points
This adds support to show dots for the curves points when in edit mode, using a specific overlay. This also adds `DRW_curves_batch_cache_create_requested` which for now only creates the point buffer for the newly added `edit_points` batch. In the future, this will also handle other edit mode overlays, and probably also replace the current curves batch cache creation. Maniphest Tasks: T95770 Differential Revision: https://developer.blender.org/D14262
Diffstat (limited to 'source/blender/draw/intern/draw_cache_impl_curves.cc')
-rw-r--r--source/blender/draw/intern/draw_cache_impl_curves.cc30
1 files changed, 28 insertions, 2 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc
index 0b8913402e6..b084a5e5945 100644
--- a/source/blender/draw/intern/draw_cache_impl_curves.cc
+++ b/source/blender/draw/intern/draw_cache_impl_curves.cc
@@ -21,6 +21,7 @@
#include "DNA_curves_types.h"
#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
#include "BKE_curves.hh"
@@ -28,7 +29,8 @@
#include "GPU_material.h"
#include "GPU_texture.h"
-#include "draw_cache_impl.h" /* own include */
+#include "draw_cache_impl.h" /* own include */
+#include "draw_cache_inline.h"
#include "draw_hair_private.h" /* own include */
using blender::float3;
@@ -41,6 +43,8 @@ using blender::Span;
struct CurvesBatchCache {
ParticleHairCache hair;
+ GPUBatch *edit_points;
+
/* To determine if cache is invalid. */
bool is_dirty;
};
@@ -74,6 +78,7 @@ static void curves_batch_cache_clear(Curves &curves)
}
particle_batch_cache_clear_hair(&cache->hair);
+ GPU_BATCH_DISCARD_SAFE(cache->edit_points);
}
void DRW_curves_batch_cache_validate(Curves *curves)
@@ -167,10 +172,11 @@ static void curves_batch_cache_ensure_procedural_pos(Curves &curves,
ParticleHairCache &cache,
GPUMaterial *gpu_material)
{
- if (cache.proc_point_buf == nullptr) {
+ if (cache.proc_point_buf == nullptr || DRW_vbo_requested(cache.proc_point_buf)) {
/* Initialize vertex format. */
GPUVertFormat format = {0};
uint pos_id = GPU_vertformat_attr_add(&format, "posTime", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
+ GPU_vertformat_alias_add(&format, "pos");
cache.proc_point_buf = GPU_vertbuf_create_with_format(&format);
GPU_vertbuf_data_alloc(cache.proc_point_buf, cache.point_len);
@@ -366,3 +372,23 @@ int DRW_curves_material_count_get(Curves *curves)
{
return max_ii(1, curves->totcol);
}
+
+GPUBatch *DRW_curves_batch_cache_get_edit_points(Curves *curves)
+{
+ CurvesBatchCache &cache = curves_batch_cache_get(*curves);
+ return DRW_batch_request(&cache.edit_points);
+}
+
+void DRW_curves_batch_cache_create_requested(const Object *ob)
+{
+ Curves *curves = static_cast<Curves *>(ob->data);
+ CurvesBatchCache &cache = curves_batch_cache_get(*curves);
+
+ if (DRW_batch_requested(cache.edit_points, GPU_PRIM_POINTS)) {
+ DRW_vbo_request(cache.edit_points, &cache.hair.proc_point_buf);
+ }
+
+ if (DRW_vbo_requested(cache.hair.proc_point_buf)) {
+ curves_batch_cache_ensure_procedural_pos(*curves, cache.hair, nullptr);
+ }
+}