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.
This commit is contained in:
parent
1203bd58be
commit
b69aad60bd
Notes:
blender-bot
2023-02-14 06:42:53 +01:00
Referenced by commit 1a71f9d2b8
, Curves: use radius of middle point to determine curve shape
Referenced by issue #99786, Wrong Radius visuals when joining two hair curves
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue