Particles: add Size attribute

This commit is contained in:
Jacques Lucke 2020-07-29 10:05:27 +02:00
parent 7a07683060
commit 4cad74e589
2 changed files with 4 additions and 1 deletions

View File

@ -114,10 +114,12 @@ static PointCloud *modifyPointCloud(ModifierData *md,
const float3 *positions = (const float3 *)CustomData_get_layer_named(
&state->attributes, CD_PROP_FLOAT3, "Position");
const float *sizes = (const float *)CustomData_get_layer_named(
&state->attributes, CD_PROP_FLOAT, "Size");
memcpy(pointcloud->co, positions, sizeof(float3) * state->tot_particles);
for (int i = 0; i < state->tot_particles; i++) {
pointcloud->radius[i] = 0.03f;
pointcloud->radius[i] = sizes[i] / 2.0f;
}
return pointcloud;

View File

@ -740,6 +740,7 @@ static void initialize_particle_attribute_builders(CollectContext &context)
/* TODO: Use uint32_t, but we don't have a corresponding custom property type. */
attributes_builder.add<int>("Hash", 0);
attributes_builder.add<float>("Birth Time", 0.0f);
attributes_builder.add<float>("Size", 0.03f);
context.influences.particle_attributes_builder.add_new(name, &attributes_builder);
}
}