From b724c7f27e5876c70c7cc2a42a16ba4e85c9dfc3 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 12 Jul 2011 18:59:54 +0000 Subject: Add delete with reconnect feature. this will reconnect nodes as if the deleted node is muted. Operation is added to the space_node node menu and to the keymap as CTRL-X to test this just add some nodes to the space_node select one or multiple nodes and press CTRL-X It should reconnect the nodes as they were muted limitations: 1. it performs a delete and reconnect per node. It does not evaluate all selected nodes as one whole 2. mute only supports Value, Vector and Color data types, so does this feature 3. not usable for nodes where input and output does not match (like colorToBW) Where reconnect could not be preformed the links will be removed from the model. Undo works with this delete with reconnect. --- release/scripts/startup/bl_ui/space_node.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'release') diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index fed1cc49c4c..831fd359782 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -135,9 +135,10 @@ class NODE_MT_node(bpy.types.Menu): layout.operator("transform.resize") layout.separator() - + layout.operator("node.duplicate_move") layout.operator("node.delete") + layout.operator("node.delete_reconnect") layout.separator() layout.operator("node.link_make") -- cgit v1.2.3 From b0ffa7fc580c49a2c50377cbe19c76279d303dfb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Jul 2011 07:50:21 +0000 Subject: patch [#27950] Patch to add the ability to generate random points on mesh faces from Andrew Hale (trumanblending) --- release/scripts/modules/bpy_extras/mesh_utils.py | 73 +++++++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) (limited to 'release') diff --git a/release/scripts/modules/bpy_extras/mesh_utils.py b/release/scripts/modules/bpy_extras/mesh_utils.py index 34925ccb5e9..c42d3d0236a 100644 --- a/release/scripts/modules/bpy_extras/mesh_utils.py +++ b/release/scripts/modules/bpy_extras/mesh_utils.py @@ -16,7 +16,7 @@ # # ##### END GPL LICENSE BLOCK ##### -# +# __all__ = ( "mesh_linked_faces", @@ -25,6 +25,7 @@ __all__ = ( "edge_loops_from_faces", "edge_loops_from_edges", "ngon_tesselate", + "face_random_points", ) @@ -67,7 +68,8 @@ def mesh_linked_faces(mesh): if mapped_index != nxt_mapped_index: ok = True - # Assign mapping to this group so they all map to this group + # Assign mapping to this group so they + # all map to this group for grp_f in face_groups[nxt_mapped_index]: face_mapping[grp_f.index] = mapped_index @@ -433,3 +435,70 @@ def ngon_tesselate(from_data, indices, fix_loops=True): fill[i] = tuple([ii for ii in reversed(fi)]) return fill + + +def face_random_points(num_points, faces): + """ + Generates a list of random points over mesh faces. + + :arg num_points: the number of random points to generate on each face. + :type int: + :arg faces: list of the faces to generate points on. + :type faces: :class:`MeshFaces`, sequence + :return: list of random points over all faces. + :rtype: list + """ + + from random import random + from mathutils.geometry import area_tri + + # Split all quads into 2 tris, tris remain unchanged + tri_faces = [] + for f in faces: + tris = [] + verts = f.id_data.vertices + fv = f.vertices[:] + tris.append((verts[fv[0]].co, + verts[fv[1]].co, + verts[fv[2]].co, + )) + if len(fv) == 4: + tris.append((verts[fv[0]].co, + verts[fv[3]].co, + verts[fv[2]].co, + )) + tri_faces.append(tris) + + # For each face, generate the required number of random points + sampled_points = [None] * (num_points * len(faces)) + for i, tf in enumerate(tri_faces): + for k in range(num_points): + # If this is a quad, we need to weight its 2 tris by their area + if len(tf) != 1: + area1 = area_tri(*tf[0]) + area2 = area_tri(*tf[1]) + area_tot = area1 + area2 + + area1 = area1 / area_tot + area2 = area2 / area_tot + + vecs = tf[0 if (random() < area1) else 1] + else: + vecs = tf[0] + + u1 = random() + u2 = random() + u_tot = u1 + u2 + + if u_tot > 1: + u1 = 1.0 - u1 + u2 = 1.0 - u2 + + side1 = vecs[1] - vecs[0] + side2 = vecs[2] - vecs[0] + + p = vecs[0] + u1 * side1 + u2 * side2 + + sampled_points[num_points * i + k] = p + + return sampled_points -- cgit v1.2.3 From 74536efa9180da90daf651b162296a474e5bfde8 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 13 Jul 2011 17:52:23 +0000 Subject: Fix #26704: activating a texture node inside material nodes did not show that texture in the texture properties. --- release/scripts/startup/bl_ui/properties_texture.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'release') diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py index f0265f8db67..292e43a01a6 100644 --- a/release/scripts/startup/bl_ui/properties_texture.py +++ b/release/scripts/startup/bl_ui/properties_texture.py @@ -88,15 +88,15 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, bpy.types.Panel): @classmethod def poll(cls, context): engine = context.scene.render.engine - if not hasattr(context, "texture_slot"): + if not (hasattr(context, "texture_slot") or hasattr(context, "texture_node")): return False return ((context.material or context.world or context.lamp or context.brush or context.texture or context.particle_system or isinstance(context.space_data.pin_id, bpy.types.ParticleSettings)) and (engine in cls.COMPAT_ENGINES)) def draw(self, context): layout = self.layout - slot = context.texture_slot - node = context.texture_node + slot = getattr(context, "texture_slot", None) + node = getattr(context, "texture_node", None) space = context.space_data tex = context.texture idblock = context_tex_datablock(context) -- cgit v1.2.3 From f94c9d5d612879aa5b7fec8be224b25aac870b5c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 13 Jul 2011 18:07:30 +0000 Subject: Fix python error in image sampling panel drawing when there is no texture slot available. --- release/scripts/startup/bl_ui/properties_texture.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'release') diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py index 292e43a01a6..7ca8818cbd2 100644 --- a/release/scripts/startup/bl_ui/properties_texture.py +++ b/release/scripts/startup/bl_ui/properties_texture.py @@ -393,7 +393,7 @@ class TEXTURE_PT_image_sampling(TextureTypePanel, bpy.types.Panel): idblock = context_tex_datablock(context) tex = context.texture - slot = context.texture_slot + slot = getattr(context, "texture_slot", None) split = layout.split() @@ -408,7 +408,7 @@ class TEXTURE_PT_image_sampling(TextureTypePanel, bpy.types.Panel): col = split.column() #Only for Material based textures, not for Lamp/World... - if isinstance(idblock, bpy.types.Material): + if slot and isinstance(idblock, bpy.types.Material): col.prop(tex, "use_normal_map") row = col.row() row.active = tex.use_normal_map -- cgit v1.2.3