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:
authorJacques Lucke <jacques@blender.org>2022-06-07 16:03:38 +0300
committerJacques Lucke <jacques@blender.org>2022-06-07 16:03:58 +0300
commitb69aad60bda23a53482b2c2ae98715c23a715bc8 (patch)
tree5e1acb68cca393c33bf74e7bd644d90f3751d54a /source/blender/draw
parent1203bd58beffbfd517818521750cdc3f1d273cd2 (diff)
Curves: use root/tip radius of the first curve in the viewport
Viewport drawing does not support a per point radius attribute yet. Instead, it has a fixed set of radius parameters that are used for all curves in the same object. Now those radii are retrieved from the radius attribute of the points on the first curve. This allows users to control the radius of curves to some degree until proper per-point radius is supported.
Diffstat (limited to 'source/blender/draw')
-rw-r--r--source/blender/draw/intern/draw_curves.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/draw/intern/draw_curves.cc b/source/blender/draw/intern/draw_curves.cc
index 39d4845994f..749383edc6d 100644
--- a/source/blender/draw/intern/draw_curves.cc
+++ b/source/blender/draw/intern/draw_curves.cc
@@ -13,6 +13,9 @@
#include "DNA_curves_types.h"
#include "DNA_customdata_types.h"
+#include "BKE_curves.hh"
+#include "BKE_geometry_set.hh"
+
#include "GPU_batch.h"
#include "GPU_capabilities.h"
#include "GPU_compute.h"
@@ -325,6 +328,21 @@ DRWShadingGroup *DRW_shgroup_curves_create_sub(Object *object,
float hair_rad_tip = 0.0f;
bool hair_close_tip = true;
+ /* Use the radius of the root and tip of the first curve for now. This is a workaround that we
+ * use for now because we can't use a per-point radius yet. */
+ Curves &curves_id = *static_cast<Curves *>(object->data);
+ const blender::bke::CurvesGeometry &curves = blender::bke::CurvesGeometry::wrap(
+ curves_id.geometry);
+ if (curves.curves_num() >= 1) {
+ CurveComponent curves_component;
+ curves_component.replace(&curves_id, GeometryOwnershipType::ReadOnly);
+ blender::VArray<float> radii = curves_component.attribute_get_for_read(
+ "radius", ATTR_DOMAIN_POINT, 0.005f);
+ const blender::IndexRange first_curve_points = curves.points_for_curve(0);
+ hair_rad_root = radii[first_curve_points.first()];
+ hair_rad_tip = radii[first_curve_points.last()];
+ }
+
DRW_shgroup_uniform_texture(shgrp, "hairPointBuffer", curves_cache->final[subdiv].proc_tex);
if (curves_cache->length_tex) {
DRW_shgroup_uniform_texture(shgrp, "hairLen", curves_cache->length_tex);