Python Write Access to Hair Particle Data Broken (2.8 vs. 2.79) #65624

Closed
opened 2019-06-08 02:49:36 +02:00 by Olivier Maury · 12 comments

System Information
Operating system: Windows-10-10.0.17763 64 Bits
Graphics card: GeForce GTX 1060/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 388.73

Blender Version
Broken: version: 2.80 (sub 74), branch: blender2.7, commit date: 2019-06-04 00:52, hash: blender/blender@c13e10a740
Worked: version 2.79, any build.

Short description of error
The python bindings to edit hair particle data don't appear to be working in blender 2.8. The same bindings work perfectly in blender 2.79 builds.

CONTEXT: We have been using this hair particle data editing mechanism in blender 2.79 to load Alembic hair curves and convert them to Cycles hair rendering primitives. Importing the curves in Blender creates Bezier curves which need to be tessellated in order to render in Cycles. If there is another mechanism to import Alembic curves directly into Blender as Cycles hair primitives, please let me know.

Exact steps for others to reproduce the error

  1. Load "hair_python_280.blend". In the Python console,
bpy.ops.particle.particle_edit_toggle()  
dg = bpy.context.evaluated_depsgraph_get()
hair = dg.objects["hair_emitter"].particle_systems["hair"]
hair.particles[0].hair_keys[0].co = Vector((5, 5, 5))
bpy.ops.particle.particle_edit_toggle()

Note that I'm trying to use the new depsgraph through "evaluated_depsgraph_get()". It's interesting to see that the particle position snaps back as soon as the last bpy.ops.particle.particle_edit_toggle() is called. I suspect a python binding needs to be exposed to trigger the same scene graph update which occurs after a brush edit.

  1. For reference, using the following lines in blender 2.79 works. I'm including a file where you can try it "hair_python_279.blend".
bpy.ops.particle.particle_edit_toggle()  
hair = bpy.data.objects["hair_emitter"].particle_systems["hair"]
hair.particles[0].hair_keys[0].co = Vector((5, 5, 5))
bpy.ops.particle.particle_edit_toggle()

hair_python_280.blend

hair_python_279.blend

**System Information** Operating system: Windows-10-10.0.17763 64 Bits Graphics card: GeForce GTX 1060/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 388.73 **Blender Version** Broken: version: 2.80 (sub 74), branch: blender2.7, commit date: 2019-06-04 00:52, hash: `blender/blender@c13e10a740` Worked: version 2.79, any build. **Short description of error** The python bindings to edit hair particle data don't appear to be working in blender 2.8. The same bindings work perfectly in blender 2.79 builds. CONTEXT: We have been using this hair particle data editing mechanism in blender 2.79 to load Alembic hair curves and convert them to Cycles hair rendering primitives. Importing the curves in Blender creates Bezier curves which need to be tessellated in order to render in Cycles. If there is another mechanism to import Alembic curves directly into Blender as Cycles hair primitives, please let me know. **Exact steps for others to reproduce the error** 1. Load "hair_python_280.blend". In the Python console, ``` bpy.ops.particle.particle_edit_toggle() dg = bpy.context.evaluated_depsgraph_get() hair = dg.objects["hair_emitter"].particle_systems["hair"] hair.particles[0].hair_keys[0].co = Vector((5, 5, 5)) bpy.ops.particle.particle_edit_toggle() ``` Note that I'm trying to use the new depsgraph through "evaluated_depsgraph_get()". It's interesting to see that the particle position snaps back as soon as the last bpy.ops.particle.particle_edit_toggle() is called. I suspect a python binding needs to be exposed to trigger the same scene graph update which occurs after a brush edit. 2. For reference, using the following lines in blender 2.79 works. I'm including a file where you can try it "hair_python_279.blend". ``` bpy.ops.particle.particle_edit_toggle() hair = bpy.data.objects["hair_emitter"].particle_systems["hair"] hair.particles[0].hair_keys[0].co = Vector((5, 5, 5)) bpy.ops.particle.particle_edit_toggle() ``` [hair_python_280.blend](https://archive.blender.org/developer/F7092882/hair_python_280.blend) [hair_python_279.blend](https://archive.blender.org/developer/F7092880/hair_python_279.blend)
Author

Added subscriber: @olivier.fx

Added subscriber: @olivier.fx

Added subscriber: @daniel.erpelding94

Added subscriber: @daniel.erpelding94

Removed subscriber: @daniel.erpelding94

Removed subscriber: @daniel.erpelding94
Sergey Sharybin was assigned by Sebastian Parborg 2019-06-14 15:28:53 +02:00
Author

@Sergey, I see that you've worked on https://developer.blender.org/T64805 earlier today, which is very similar in spirit to this task: modifying hair particle data from Python in order to convert blender curves to hair particles. Fixing this issue would allow us to start using Blender 2.8.

Converting helps us render curves natively in Cycles. I'm interested in getting your opinion on the best way to import Alembic curves directly to hair particles (instead of Blender curves), what do you suggest? FYI, converting 300k curves to hair particles (in Blender 2.79 where it worked) is pretty slow, is there a way to set an array of particles directly from Python?

@Sergey, I see that you've worked on https://developer.blender.org/T64805 earlier today, which is very similar in spirit to this task: modifying hair particle data from Python in order to convert blender curves to hair particles. Fixing this issue would allow us to start using Blender 2.8. Converting helps us render curves natively in Cycles. I'm interested in getting your opinion on the best way to import Alembic curves directly to hair particles (instead of Blender curves), what do you suggest? FYI, converting 300k curves to hair particles (in Blender 2.79 where it worked) is pretty slow, is there a way to set an array of particles directly from Python?

Added subscriber: @Jandals

Added subscriber: @Jandals

Added subscriber: @JoseConseco

Added subscriber: @JoseConseco

@olivier.fx seting particle hair_key.co works ok in blender now, since blender/blender#64805 fix. You just have to generate comb cache that was mentioned in blender/blender#64805 bug.

@olivier.fx seting particle hair_key.co works ok in blender now, since blender/blender#64805 fix. You just have to generate comb cache that was mentioned in blender/blender#64805 bug.
Author

Thanks Jose, it does work now :)

For reference, I ended up writing a custom command in C (in particle_edit.c), transferring the curves to existing hair particles. The python route was getting unreasonably slow: We are importing Alembic caches with animated grooms, and transferring 300k curves per frames would not have been reasonable in terms of performance. Do you have any suggestions on how to do this otherwise? Maybe creating an animated hair cache externally?

Thanks Jose, it does work now :) For reference, I ended up writing a custom command in C (in particle_edit.c), transferring the curves to existing hair particles. The python route was getting unreasonably slow: We are importing Alembic caches with animated grooms, and transferring 300k curves per frames would not have been reasonable in terms of performance. Do you have any suggestions on how to do this otherwise? Maybe creating an animated hair cache externally?
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Member

@olivier.fx: I assume this can be closed now? (from reading this, all issues seem to be resolved?)

Will actually do this (closing), feel free to comment again (or reopen) if issues persist...

@olivier.fx: I assume this can be closed now? (from reading this, all issues seem to be resolved?) Will actually do this (closing), feel free to comment again (or reopen) if issues persist...

This comment was removed by @Jandals

*This comment was removed by @Jandals*
Sign in to join this conversation.
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#65624
No description provided.