-
Notifications
You must be signed in to change notification settings - Fork 233
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
New offset line node. #1958
New offset line node. #1958
Conversation
nodes/modifier_change/offset_line.py
Outdated
|
||
from mathutils import Vector, Matrix | ||
from math import radians, pi, sin | ||
from mathutils.geometry import normal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stick imports at the top of the file, around the bpy import. See how other nodes do this.
-
- standard python imports, (math, collections... etc)
-
- bpy/blender imports, (mathutils...etc)
-
- sverchok imports (utils..etc)
nodes/modifier_change/offset_line.py
Outdated
offset = FloatProperty( | ||
name='offset', description='distance of offset', | ||
default=0.1, | ||
options={'ANIMATABLE'}, update=updateNode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
option={'ANIMATABLE'}
is not needed, properties have this attribute set to animatable by default.
nodes/modifier_change/offset_line.py
Outdated
if not ((self.outputs['Vers'].is_linked or self.outputs['Faces'].is_linked | ||
or self.outputs['OuterEdges'].is_linked or self.outputs['VersMask'].is_linked) | ||
and (self.inputs['Vers'].is_linked or self.inputs['Edgs'].is_linked)): | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would first test if the input
vers and edges is linked. Then test if there's also useful output links.
the goal is to keep the process is best for
The worker functions are cohesive blocks of code that are often specialized enough to stick into their own function. |
@zeffii Okay, I understood. I will fix. |
I think it will not be efficient. I don't use any preparation for these sockets, just assign values for variables in different places of the code. I think that checking boolean values only can to increase time of runtime.
I tried to imagine situation when it can be useful. I suppose that in most cases TWO_PI = 2 * pi I am not quite understand benefit of creating the variable. Why not just to use |
because |
I added this node in Alpha. Must it be in beta? |
No, alpha is fine ) |
It is seems that I fixed all. )) |
I am an Alpha Rebel.
--
…------------------------------------------------------------
- Jimmy Gunawan
http://blendersushi.blogspot.com.au
http://mayaspiral.blogspot.com.au
http://houdoodles.blogspot.com.au
http://puppetar.blogspot.com.au
|
Sorry, don't understand. |
@zeffii Yes, didn't notice :/ |
i have a question about the
def make_verts_new_mask(verts_in, verts_out):
num_original_verts = len(verts_in)
num_verts_out = len(verts_out)
num_new_verts = num_verts_out - num_original_verts
f = ([0] * num_original_verts) + ([1] * num_new_verts)
return f
f = make_verts_new_mask(verts_in=[5,2,3,4,5], verts_out=[5,2,3,4,5,5,5,5,2,2,2,3,3,3,4])
print(f) # [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] |
It's not quite exactly. In my script at first I add new points and after that add old points thus the order is changed. vers_mask = [0 for _ in verts_out]
...
vers_mask.append(1)
...
vers_mask.append(1) Is there point to change this? I think it must work faster than if writ seperate function for this. |
OK .
this is not a problem. I will merge if you think you're ready to have more people test it :) |
Ok. I am ready. )) |
thanks for the cool new node @Durman . hopefully the process was not too painful. First time is the most difficult (eye - opening). |
i think i can implement variable offset, if you're interested. |
imagine for a moment that we can generate a #Setting points
findex_new_points = [0]
for i in range(len(verts_in)):
if len(neighbours[i]) == 1:
verts_out.extend(get_end_points(i))
findex_new_points.append(findex_new_points[-1] + 2)
else:
p = get_middle_points(i)
verts_out.extend(p)
findex_new_points.append(findex_new_points[-1] + len(p)) and.. # (not displayed here) we always ensure radii is as long as verts_in
# meaning we can enumerate radii and use the idx it produces
findex_new_points = [0]
for idx, radius in enumerate(radii):
if len(neighbours[idx]) == 1:
verts_out.extend(get_end_points(idx, radius))
findex_new_points.append(findex_new_points[-1] + 2)
else:
p = get_middle_points(idx, radius)
verts_out.extend(p)
findex_new_points.append(findex_new_points[-1] + len(p)) for speed I would probably make variable offset optional. and modify the |
@zeffii Okay, I agree with it. |
Z stuff is not important / not interesting use of this node. @enzyme69 often tries to cut grass using a nail clipper. (wrong tool for job) |
I like cutting tree using nail clipper.
|
My first node)) not sure that I did all right :/
#1914