7#include <pxr/base/gf/vec2f.h>
8#include <pxr/imaging/hd/tokens.h>
27static const pxr::TfToken
st(
"st", pxr::TfToken::Immortal);
32 pxr::SdfPath
const &prim_id)
62 pxr::HdDirtyBits bits = pxr::HdChangeTracker::Clean;
65 bits = pxr::HdChangeTracker::AllDirty;
69 bits |= pxr::HdChangeTracker::DirtyMaterialId | pxr::HdChangeTracker::DirtyDoubleSided;
73 bits |= pxr::HdChangeTracker::DirtyTransform;
76 if (bits == pxr::HdChangeTracker::Clean) {
86 if (key == pxr::HdTokens->points) {
89 else if (key == pxr::HdTokens->widths) {
93 return pxr::VtValue(
uvs_);
95 return pxr::VtValue();
101 return pxr::SdfPath();
115 return pxr::HdBasisCurvesTopology(pxr::HdTokens->linear,
117 pxr::HdTokens->nonperiodic,
123 pxr::HdInterpolation interpolation)
const
125 pxr::HdPrimvarDescriptorVector primvars;
126 if (interpolation == pxr::HdInterpolationVertex) {
128 primvars.emplace_back(pxr::HdTokens->points, interpolation, pxr::HdPrimvarRoleTokens->point);
131 primvars.emplace_back(pxr::HdTokens->widths, interpolation, pxr::HdPrimvarRoleTokens->none);
134 else if (interpolation == pxr::HdInterpolationUniform) {
136 primvars.emplace_back(
137 usdtokens::st, interpolation, pxr::HdPrimvarRoleTokens->textureCoordinate);
162 curves.points_by_curve(),
163 curves.curves_range(),
170 const VArray<float> radii = *curves.attributes().lookup_or_default<
float>(
172 widths_.resize(curves.points_num());
173 for (
const int i : curves.points_range()) {
177 const Span<float2> surface_uv_coords = curves.surface_uv_coords();
183 uvs_.resize(curves.curves_num());
189 pxr::SdfPath
const &prim_id,
191 :
CurvesData(scene_delegate, object, prim_id), particle_system_(particle_system)
212 prim_id, pxr::HdChangeTracker::AllDirty);
219 transform = pxr::GfMatrix4d(1.0);
225 if (cache ==
nullptr) {
237 (std::abs(object->object_to_world().ptr()[0][0]) +
238 std::abs(object->object_to_world().ptr()[1][1]) +
239 std::abs(object->object_to_world().ptr()[2][2])) /
242 float tip = scale * particle_system_->
part->
rad_tip;
243 float shape = particle_system_->
part->
shape;
246 for (
int pa_index = 0; pa_index < particle_system_->
totpart; ++pa_index) {
247 strand = cache[pa_index];
249 int point_count = strand->
segments + 1;
252 for (
int point_index = 0; point_index < point_count; ++point_index, ++strand) {
254 float x =
float(point_index) / (point_count - 1);
255 float radius =
pow(x,
pow(10.0f, -shape));
256 widths_.push_back(root + (tip - root) * radius);
268 float r_uv[2] = {0.0f, 0.0f};
272 const MFace *mface =
static_cast<const MFace *
>(
277 if (mface && mtface) {
282 uvs_.push_back(pxr::GfVec2f(r_uv[0], r_uv[1]));
Low-level operations for curves.
CustomData interface, see also DNA_customdata_types.h.
const void * CustomData_get_layer(const CustomData *data, eCustomDataType type)
General operations, lookup, etc. for materials.
int BKE_object_material_count_eval(const struct Object *ob)
struct Material * BKE_object_material_get_eval(struct Object *ob, short act)
struct ParticleSystemModifierData * psys_get_modifier(struct Object *ob, struct ParticleSystem *psys)
bool psys_check_enabled(struct Object *ob, struct ParticleSystem *psys, bool use_render_params)
void psys_interpolate_uvs(const struct MTFace *tface, int quad, const float w[4], float uvco[2])
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
constexpr void copy_from(Span< T > values) const
Span< NewT > constexpr cast() const
constexpr bool is_empty() const
virtual void write_curves()
void available_materials(Set< pxr::SdfPath > &paths) const override
pxr::VtIntArray curve_vertex_counts_
void write_materials() override
pxr::VtFloatArray widths_
pxr::VtValue get_data(pxr::TfToken const &key) const override
pxr::HdBasisCurvesTopology topology() const
pxr::VtVec3fArray vertices_
pxr::SdfPath material_id() const override
pxr::HdPrimvarDescriptorVector primvar_descriptors(pxr::HdInterpolation interpolation) const
CurvesData(HydraSceneDelegate *scene_delegate, const Object *object, pxr::SdfPath const &prim_id)
HairData(HydraSceneDelegate *scene_delegate, const Object *object, pxr::SdfPath const &prim_id, ParticleSystem *particle_system)
void write_curves() override
void write_transform() override
static bool is_supported(const ParticleSystem *particle_system)
static bool is_visible(HydraSceneDelegate *scene_delegate, Object *object, ParticleSystem *particle_system)
HydraSceneDelegate * scene_delegate_
MaterialData * get_or_create_material(const Material *mat)
virtual void write_transform()
pow(value.r - subtrahend, 2.0)") .do_static_compilation(true)
draw_view in_light_buf[] float
#define ID_LOG(level, msg,...)
#define ID_LOGN(level, msg,...)
static const pxr::TfToken st("st", pxr::TfToken::Immortal)
void copy_group_sizes(OffsetIndices< int > offsets, const IndexMask &mask, MutableSpan< int > sizes)
struct ParticleSystem * psys
struct ParticleCacheKey ** pathcache