Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new Cylinder node MK2 (WIP) #2377

Merged
merged 3 commits into from
Mar 10, 2019

Conversation

DolphinDream
Copy link
Collaborator

@DolphinDream DolphinDream commented Mar 4, 2019

Extend the features of the first cylinder node.
This includes:

  • show/hide top/bottom caps separately

  • add twist to the parallel cuts

  • add overall phase to the parallel cuts

  • add parallel and meridian profiles to modulate the parallel loops and meridian lines

  • add overall scale

  • add centering option

  • Code changes complete.

  • Code documentation complete.

  • Documentation for users complete (or not required, if user never sees these changes).

  • Manual testing done.

  • Unit-tests implemented.

  • Ready for merge.

img_7600

sv-cylindermk2-example1

Example showing a combination of meridian & parallel profiles with a twist :)

Extend the features of the first cylinder node.
This includes:
- show/hide top/bottom caps separately
- add twist to the parallel cuts
- add overall phase to the parallel cuts
- add parallel and meridian profiles to modulate the parallel loops and meridian lines
- add overall scale
- add centering option
@DolphinDream
Copy link
Collaborator Author

Latest additions and UI (optimization, fixes, cleanup + angle units option)

SV-CylinderMK2-UI2

@DolphinDream
Copy link
Collaborator Author

DolphinDream commented Mar 10, 2019

A quick profiling of the Cylinder vs Cylinder MK2 also seems to indicate over 2x speedup:

SV-CylinderMK2-profilingSetup

Cylinder profiling for 100 calls:

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
      100    0.005    0.000   12.143    0.121 cylinder.py:135(process)
      100    0.016    0.000    7.264    0.073 cylinder.py:150(<listcomp>)
    10000    2.428    0.000    7.249    0.001 cylinder.py:30(cylinder_vertices)
  2253200    2.832    0.000    3.755    0.000 data_structure.py:170(sv_zip)
      100    0.004    0.000    2.817    0.028 cylinder.py:155(<listcomp>)
    10000    2.593    0.000    2.813    0.000 cylinder.py:60(cylinder_edges)
      100    0.005    0.000    1.685    0.017 cylinder.py:160(<listcomp>)
    10000    1.517    0.000    1.680    0.000 cylinder.py:73(cylinder_faces)
 20209300    1.275    0.000    1.275    0.000 {method 'append' of 'list' objects}
  6739600    0.430    0.000    0.430    0.000 {built-in method builtins.next}
      300    0.000    0.000    0.344    0.001 node_tree.py:130(sv_set)
      300    0.340    0.001    0.343    0.001 socket_data.py:70(SvSetSocket)
  4486400    0.284    0.000    0.284    0.000 {built-in method math.radians}
  2243200    0.186    0.000    0.186    0.000 {built-in method math.cos}
  2243200    0.185    0.000    0.185    0.000 {built-in method math.sin}
      100    0.006    0.000    0.016    0.000 data_structure.py:91(match_long_repeat)
      500    0.001    0.000    0.012    0.000 node_tree.py:439(sv_get)
    10000    0.008    0.000    0.011    0.000 data_structure.py:174(<listcomp>)
    30500    0.008    0.000    0.010    0.000 data_structure.py:76(repeat_last)
      300    0.001    0.000    0.007    0.000 socket_data.py:85(SvGetSocket)
      600    0.000    0.000    0.006    0.000 node_tree.py:95(other)
      600    0.001    0.000    0.006    0.000 data_structure.py:649(get_other_socket)
      600    0.001    0.000    0.005    0.000 bpy_types.py:844(links)
      600    0.003    0.000    0.004    0.000 node_tree.py:103(socket_id)
      300    0.000    0.000    0.004    0.000 node_tree.py:242(convert_data)
     1200    0.003    0.000    0.003    0.000 bpy_types.py:847(<genexpr>)
      300    0.000    0.000    0.003    0.000 node_tree.py:237(needs_data_conversion)
    30000    0.003    0.000    0.003    0.000 {built-in method builtins.iter}
    31200    0.002    0.000    0.002    0.000 {built-in method builtins.len}
  600/300    0.001    0.000    0.001    0.000 socket_data.py:37(sv_deep_copy)
      300    0.000    0.000    0.001    0.000 socket_data.py:42(<listcomp>)
    10000    0.001    0.000    0.001    0.000 {method 'reverse' of 'list' objects}
      100    0.000    0.000    0.001    0.000 cylinder.py:145(<listcomp>)
      100    0.000    0.000    0.001    0.000 cylinder_mk2.py:252(process)

Cylinder MK2 profiling for 100 calls:

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
      100    0.038    0.000    5.518    0.055 cylinder_mk2.py:252(process)
    10000    1.686    0.000    2.116    0.000 cylinder_mk2.py:46(make_verts)
    10000    1.834    0.000    1.994    0.000 cylinder_mk2.py:107(make_edges)
    10000    0.949    0.000    1.082    0.000 cylinder_mk2.py:133(make_polys)
  5836900    0.387    0.000    0.387    0.000 {method 'append' of 'list' objects}
      300    0.000    0.000    0.247    0.001 node_tree.py:130(sv_set)
      300    0.245    0.001    0.247    0.001 socket_data.py:70(SvSetSocket)
  1606400    0.138    0.000    0.138    0.000 {built-in method math.sin}
  1606400    0.135    0.000    0.135    0.000 {built-in method math.cos}
      200    0.013    0.000    0.040    0.000 data_structure.py:91(match_long_repeat)
    10000    0.031    0.000    0.031    0.000 cylinder_mk2.py:157(<listcomp>)
      100    0.001    0.000    0.027    0.000 cylinder.py:135(process)
    91100    0.022    0.000    0.026    0.000 data_structure.py:76(repeat_last)
     1500    0.003    0.000    0.022    0.000 node_tree.py:439(sv_get)
    10000    0.019    0.000    0.019    0.000 cylinder_mk2.py:153(<listcomp>)
    50200    0.016    0.000    0.016    0.000 {method 'extend' of 'list' objects}
      600    0.002    0.000    0.011    0.000 socket_data.py:85(SvGetSocket)
     1200    0.001    0.000    0.011    0.000 node_tree.py:95(other)
     1200    0.002    0.000    0.010    0.000 data_structure.py:649(get_other_socket)
     1200    0.002    0.000    0.008    0.000 bpy_types.py:844(links)
   112800    0.006    0.000    0.006    0.000 {built-in method builtins.len}
      600    0.000    0.000    0.006    0.000 node_tree.py:242(convert_data)
     2400    0.006    0.000    0.006    0.000 bpy_types.py:847(<genexpr>)
      600    0.001    0.000    0.006    0.000 node_tree.py:237(needs_data_conversion)
      900    0.003    0.000    0.004    0.000 node_tree.py:103(socket_id)
 1200/600    0.002    0.000    0.002    0.000 socket_data.py:37(sv_deep_copy)
      600    0.000    0.000    0.001    0.000 socket_data.py:42(<listcomp>)
     1400    0.001    0.000    0.001    0.000 {built-in method builtins.getattr}
     3500    0.001    0.000    0.001    0.000 {built-in method builtins.max}
      100    0.000    0.000    0.001    0.000 cylinder.py:145(<listcomp>)

@DolphinDream
Copy link
Collaborator Author

DolphinDream commented Mar 10, 2019

Btw, since i'm trying to compare apples to apples and run the same number of calls on both nodes I am using playback over a given number of frames and in order to get the exact number of frames/calls in both cases I am using this script code I found at this link below to get the playback to stop automatically when the playback reaches the end frame:

https://blender.stackexchange.com/questions/28869/how-to-disable-loop-playback-of-animation#28877

import bpy

def stop_playback(scene):
    if scene.frame_current == scene.frame_end:
        bpy.ops.screen.animation_cancel(restore_frame=False)

# or restore frames:
def stop_playback_restore(scene):
    if scene.frame_current == scene.frame_end + 1:
        bpy.ops.screen.animation_cancel(restore_frame=True)

# add one of these functions to frame_change_pre handler:
bpy.app.handlers.frame_change_pre.append(stop_playback)

This works .. except that sometimes it crashes blender. I'm not sure if this is a SV issue or a blender issue. It seems that it crashes even when the node doesn't have profiling code and the profiling is stopped.

@Durman
Copy link
Collaborator

Durman commented Mar 10, 2019

This does the same.))
2019-03-10_07-48-43

@DolphinDream
Copy link
Collaborator Author

DolphinDream commented Mar 10, 2019

A starred icosahedron example :)

SV-CylinderMK2-example2

@enzyme69
Copy link
Collaborator

enzyme69 commented May 7, 2019

Screen Shot 2019-05-07 at 15 04 41

This Cylinder MK2 node is a pure joy...!! Procedural Pencil madness...

@DolphinDream
Copy link
Collaborator Author

This node is now available in 2.8 as well. #2404

@enzyme69
Copy link
Collaborator

enzyme69 commented May 9, 2019

When separating Cylinder MK2 as each individual disc, why can't I use extrude of solidify or other things? Maybe I am missing something... like maybe I need to split and join again?

Screen Shot 2019-05-09 at 17 48 57

@nortikin
Copy link
Owner

nortikin commented May 9, 2019

https://gist.github.com/25b8cadb250fa6011b278773e7c83e17
cylindermk2

@DolphinDream
Copy link
Collaborator Author

When separating Cylinder MK2 as each individual disc, why can't I use extrude of solidify or other things? Maybe I am missing something... like maybe I need to split and join again?

Screen Shot 2019-05-09 at 17 48 57

@enzyme69 It seems you need to change list levels:

SV-cylinderMK2-Solidify

@DolphinDream
Copy link
Collaborator Author

@enzyme69 as you noticed.. the parallel/meridian profiles are not vectorized (yet) :) one profile for all parrallel or meridian.

@enzyme69
Copy link
Collaborator

@DolphinDream Thanks for this awesome node and all the infor... I can use Monad trickery maybe!

@enzyme69
Copy link
Collaborator

Screen Shot 2019-05-11 at 09 32 02

Cylinder inside Monad....

Screen Shot 2019-05-11 at 09 29 41

Screen Shot 2019-05-11 at 09 29 29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants