Page MenuHome

Curves: Add operator to convert hair particle system to new curves object.
ClosedPublic

Authored by Jacques Lucke (JacquesLucke) on May 10 2022, 5:09 PM.

Details

Summary

This creates a new curves object with the name of the particle system.
The generated curves match the current evaluated state of the active hair particle system.
Attachment information is not transferred currently, because it's not obvious how that should be transferred when there are modifiers before the particle system modifier (and we don't have the curve deformation system not in master yet).

Diff Detail

Repository
rB Blender

Event Timeline

Jacques Lucke (JacquesLucke) requested review of this revision.May 10 2022, 5:09 PM
Jacques Lucke (JacquesLucke) created this revision.
Jacques Lucke (JacquesLucke) retitled this revision from Curves: Add operator to convert hair particle system to new curves object. to Curves: Add operator to convert hair particle system to new curves object. (WIP).

Simpler than I expected! I guess bringing the child hairs into the conversion might make it a bit more complex.

source/blender/editors/curves/intern/curves_ops.cc
341

I don't really care here given the nature of this code, but where we care about performance I've usually been resizing once and using the new offsets array but keeping the point count the same, then resizing again with the final point count.

  • Merge branch 'master' into convert-hair-to-curves
  • support child hair
Jacques Lucke (JacquesLucke) retitled this revision from Curves: Add operator to convert hair particle system to new curves object. (WIP) to Curves: Add operator to convert hair particle system to new curves object. .May 11 2022, 2:20 PM

The round trip curves->particles->curves works well for me too. Looks good.

source/blender/editors/curves/intern/curves_ops.cc
323

I think it's a bit nicer to return bke::CurvesGeometry by value:

static bke::CurvesGeometry particles_to_curves(Object &object, ParticleSystem &psys)
{
  ParticleSettings &settings = *psys.part;
  if (psys.part->type != PART_HAIR) {
    return {};
  }
  ...
  bke::CurvesGeometry curves(points_num, curves_num);
  ...
  return curves;
}
...
  bke::CurvesGeometry::wrap(curves_id->geometry) = particles_to_curves(*ob_from_eval, *psys_eval);
408

ob_new->dtx |= OB_DRAWBOUNDOX; /* TODO: remove once there is actual drawing. */

This revision is now accepted and ready to land.May 11 2022, 2:54 PM
Jacques Lucke (JacquesLucke) retitled this revision from Curves: Add operator to convert hair particle system to new curves object. to Curves: Add operator to convert hair particle system to new curves object..
Jacques Lucke (JacquesLucke) edited the summary of this revision. (Show Details)
  • Merge branch 'master' into convert-hair-to-curves
  • ignore hair particles with no segments
  • cleanup