Merge branch 'master' into blender2.8

This commit is contained in:
2018-06-26 22:56:39 +02:00
68 changed files with 1554 additions and 1454 deletions

View File

@@ -15,6 +15,7 @@ font_info = {
"handler": None, "handler": None,
} }
def init(): def init():
"""init function - runs once""" """init function - runs once"""
import os import os

View File

@@ -17,4 +17,5 @@ from bpy.app.handlers import persistent
def load_handler(dummy): def load_handler(dummy):
print("Load Handler:", bpy.data.filepath) print("Load Handler:", bpy.data.filepath)
bpy.app.handlers.load_post.append(load_handler) bpy.app.handlers.load_post.append(load_handler)

View File

@@ -11,4 +11,5 @@ import bpy
def my_handler(scene): def my_handler(scene):
print("Frame Change", scene.frame_current) print("Frame Change", scene.frame_current)
bpy.app.handlers.frame_change_pre.append(my_handler) bpy.app.handlers.frame_change_pre.append(my_handler)

View File

@@ -81,6 +81,7 @@ for msg in translations_tuple:
# Define remaining addon (operators, UI...) here. # Define remaining addon (operators, UI...) here.
def register(): def register():
# Usual operator/UI/etc. registration... # Usual operator/UI/etc. registration...

View File

@@ -14,6 +14,7 @@ class MaterialSettings(bpy.types.PropertyGroup):
my_float = bpy.props.FloatProperty() my_float = bpy.props.FloatProperty()
my_string = bpy.props.StringProperty() my_string = bpy.props.StringProperty()
bpy.utils.register_class(MaterialSettings) bpy.utils.register_class(MaterialSettings)
bpy.types.Material.my_settings = \ bpy.types.Material.my_settings = \

View File

@@ -14,6 +14,7 @@ class SceneSettingItem(bpy.types.PropertyGroup):
name = bpy.props.StringProperty(name="Test Prop", default="Unknown") name = bpy.props.StringProperty(name="Test Prop", default="Unknown")
value = bpy.props.IntProperty(name="Test Prop", default=22) value = bpy.props.IntProperty(name="Test Prop", default=22)
bpy.utils.register_class(SceneSettingItem) bpy.utils.register_class(SceneSettingItem)
bpy.types.Scene.my_settings = \ bpy.types.Scene.my_settings = \

View File

@@ -14,6 +14,7 @@ import bpy
def update_func(self, context): def update_func(self, context):
print("my test function", self) print("my test function", self)
bpy.types.Scene.testprop = bpy.props.FloatProperty(update=update_func) bpy.types.Scene.testprop = bpy.props.FloatProperty(update=update_func)
bpy.context.scene.testprop = 11.0 bpy.context.scene.testprop = 11.0

View File

@@ -19,6 +19,7 @@ def get_float(self):
def set_float(self, value): def set_float(self, value):
self["testprop"] = value self["testprop"] = value
bpy.types.Scene.test_float = bpy.props.FloatProperty(get=get_float, set=set_float) bpy.types.Scene.test_float = bpy.props.FloatProperty(get=get_float, set=set_float)
@@ -27,6 +28,7 @@ def get_date(self):
import datetime import datetime
return str(datetime.datetime.now()) return str(datetime.datetime.now())
bpy.types.Scene.test_date = bpy.props.StringProperty(get=get_date) bpy.types.Scene.test_date = bpy.props.StringProperty(get=get_date)
@@ -40,6 +42,7 @@ def get_array(self):
def set_array(self, values): def set_array(self, values):
self["somebool"] = values[0] and values[1] self["somebool"] = values[0] and values[1]
bpy.types.Scene.test_array = bpy.props.BoolVectorProperty(size=2, get=get_array, set=set_array) bpy.types.Scene.test_array = bpy.props.BoolVectorProperty(size=2, get=get_array, set=set_array)
@@ -61,6 +64,7 @@ def get_enum(self):
def set_enum(self, value): def set_enum(self, value):
print("setting value", value) print("setting value", value)
bpy.types.Scene.test_enum = bpy.props.EnumProperty(items=test_items, get=get_enum, set=set_enum) bpy.types.Scene.test_enum = bpy.props.EnumProperty(items=test_items, get=get_enum, set=set_enum)

View File

@@ -14,4 +14,5 @@ import bpy
def menu_draw(self, context): def menu_draw(self, context):
self.layout.operator("wm.save_homefile") self.layout.operator("wm.save_homefile")
bpy.types.INFO_MT_file.append(menu_draw) bpy.types.INFO_MT_file.append(menu_draw)

View File

@@ -60,6 +60,7 @@ def menu_func(self, context):
layout.separator() layout.separator()
layout.operator(WM_OT_button_context_test.bl_idname) layout.operator(WM_OT_button_context_test.bl_idname)
classes = ( classes = (
WM_OT_button_context_test, WM_OT_button_context_test,
WM_MT_button_context, WM_MT_button_context,
@@ -77,5 +78,6 @@ def unregister():
bpy.utils.unregister_class(cls) bpy.utils.unregister_class(cls)
bpy.types.WM_MT_button_context.remove(menu_func) bpy.types.WM_MT_button_context.remove(menu_func)
if __name__ == "__main__": if __name__ == "__main__":
register() register()

View File

@@ -21,4 +21,5 @@ class CyclesNodeTree(bpy.types.NodeTree):
def poll(cls, context): def poll(cls, context):
return context.scene.render.engine == 'CYCLES' return context.scene.render.engine == 'CYCLES'
bpy.utils.register_class(CyclesNodeTree) bpy.utils.register_class(CyclesNodeTree)

View File

@@ -42,6 +42,7 @@ class SimpleMouseOperator(bpy.types.Operator):
self.y = event.mouse_y self.y = event.mouse_y
return self.execute(context) return self.execute(context)
bpy.utils.register_class(SimpleMouseOperator) bpy.utils.register_class(SimpleMouseOperator)
# Test call to the newly defined operator. # Test call to the newly defined operator.

View File

@@ -42,6 +42,7 @@ def menu_func(self, context):
self.layout.operator_context = 'INVOKE_DEFAULT' self.layout.operator_context = 'INVOKE_DEFAULT'
self.layout.operator(ExportSomeData.bl_idname, text="Text Export Operator") self.layout.operator(ExportSomeData.bl_idname, text="Text Export Operator")
# Register and add to the file selector # Register and add to the file selector
bpy.utils.register_class(ExportSomeData) bpy.utils.register_class(ExportSomeData)
bpy.types.INFO_MT_file_export.append(menu_func) bpy.types.INFO_MT_file_export.append(menu_func)

View File

@@ -41,6 +41,7 @@ class CustomDrawOperator(bpy.types.Operator):
col.prop(self, "my_string") col.prop(self, "my_string")
bpy.utils.register_class(CustomDrawOperator) bpy.utils.register_class(CustomDrawOperator)
# test call # test call

View File

@@ -22,6 +22,7 @@ class HelloWorldOperator(bpy.types.Operator):
print("Hello World") print("Hello World")
return {'FINISHED'} return {'FINISHED'}
bpy.utils.register_class(HelloWorldOperator) bpy.utils.register_class(HelloWorldOperator)
# test call to the newly defined operator # test call to the newly defined operator

View File

@@ -31,6 +31,7 @@ class MyPropertyGroup(bpy.types.PropertyGroup):
custom_1 = bpy.props.FloatProperty(name="My Float") custom_1 = bpy.props.FloatProperty(name="My Float")
custom_2 = bpy.props.IntProperty(name="My Int") custom_2 = bpy.props.IntProperty(name="My Int")
bpy.utils.register_class(MyPropertyGroup) bpy.utils.register_class(MyPropertyGroup)
bpy.types.Object.my_prop_grp = bpy.props.PointerProperty(type=MyPropertyGroup) bpy.types.Object.my_prop_grp = bpy.props.PointerProperty(type=MyPropertyGroup)

View File

@@ -10,4 +10,5 @@ import bpy
def draw(self, context): def draw(self, context):
self.layout.label("Hello World") self.layout.label("Hello World")
bpy.context.window_manager.popup_menu(draw, title="Greeting", icon='INFO') bpy.context.window_manager.popup_menu(draw, title="Greeting", icon='INFO')

View File

@@ -12,6 +12,7 @@ from bpy.props import PointerProperty
class MyPropGroup(bpy.types.PropertyGroup): class MyPropGroup(bpy.types.PropertyGroup):
nested = bpy.props.FloatProperty(name="Nested", default=0.0) nested = bpy.props.FloatProperty(name="Nested", default=0.0)
# register it so its available for all bones # register it so its available for all bones
bpy.utils.register_class(MyPropGroup) bpy.utils.register_class(MyPropGroup)
bpy.types.Bone.my_prop = PointerProperty(type=MyPropGroup, bpy.types.Bone.my_prop = PointerProperty(type=MyPropGroup,

View File

@@ -251,7 +251,8 @@ class BakeAction(Operator):
name="Bake Data", name="Bake Data",
description="Which data's transformations to bake", description="Which data's transformations to bake",
options={'ENUM_FLAG'}, options={'ENUM_FLAG'},
items=(('POSE', "Pose", "Bake bones transformations"), items=(
('POSE', "Pose", "Bake bones transformations"),
('OBJECT', "Object", "Bake object transformations"), ('OBJECT', "Object", "Bake object transformations"),
), ),
default={'POSE'}, default={'POSE'},
@@ -316,8 +317,10 @@ class ClearUselessActions(Operator):
for action in bpy.data.actions: for action in bpy.data.actions:
# if only user is "fake" user... # if only user is "fake" user...
if ((self.only_unused is False) or if (
(action.use_fake_user and action.users == 1)): (self.only_unused is False) or
(action.use_fake_user and action.users == 1)
):
# if it has F-Curves, then it's a "action library" # if it has F-Curves, then it's a "action library"
# (i.e. walk, wave, jump, etc.) # (i.e. walk, wave, jump, etc.)

View File

@@ -167,7 +167,8 @@ class CLIP_OT_filter_tracks(bpy.types.Operator):
relevant_tracks = [ relevant_tracks = [
track for track in clip.tracking.tracks track for track in clip.tracking.tracks
if (track.markers.find_frame(frame) and if (track.markers.find_frame(frame) and
track.markers.find_frame(frame - 1))] track.markers.find_frame(frame - 1))
]
if not relevant_tracks: if not relevant_tracks:
continue continue

View File

@@ -175,7 +175,8 @@ class WM_OT_previews_batch_clear(Operator):
name="Scenes", name="Scenes",
description="Clear scenes' previews", description="Clear scenes' previews",
) )
use_collections = BoolProperty(default=True, use_collections = BoolProperty(
default=True,
name="Collections", name="Collections",
description="Clear collections' previews", description="Clear collections' previews",
) )

View File

@@ -35,8 +35,10 @@ class MeshMirrorUV(Operator):
direction = EnumProperty( direction = EnumProperty(
name="Axis Direction", name="Axis Direction",
items=(('POSITIVE', "Positive", ""), items=(
('NEGATIVE', "Negative", "")), ('POSITIVE', "Positive", ""),
('NEGATIVE', "Negative", ""),
),
) )
precision = IntProperty( precision = IntProperty(

View File

@@ -368,7 +368,7 @@ class ShapeTransfer(Operator):
orig_normals = me_nos(me.vertices) orig_normals = me_nos(me.vertices)
# actual mesh vertex location isn't as reliable as the base shape :S # actual mesh vertex location isn't as reliable as the base shape :S
#~ orig_coords = me_cos(me.vertices) # orig_coords = me_cos(me.vertices)
orig_coords = me_cos(me.shape_keys.key_blocks[0].data) orig_coords = me_cos(me.shape_keys.key_blocks[0].data)
for ob_other in objects: for ob_other in objects:
@@ -697,22 +697,11 @@ class TransformsToDeltas(Operator):
bl_options = {'REGISTER', 'UNDO'} bl_options = {'REGISTER', 'UNDO'}
mode = EnumProperty( mode = EnumProperty(
items=(('ALL', items=(
"All Transforms", ('ALL', "All Transforms", "Transfer location, rotation, and scale transforms"),
"Transfer location, rotation, and scale transforms", ('LOC', "Location", "Transfer location transforms only"),
), ('ROT', "Rotation", "Transfer rotation transforms only"),
('LOC', ('SCALE', "Scale", "Transfer scale transforms only"),
"Location",
"Transfer location transforms only",
),
('ROT',
"Rotation",
"Transfer rotation transforms only",
),
('SCALE',
"Scale",
"Transfer scale transforms only",
),
), ),
name="Mode", name="Mode",
description="Which transforms to transfer", description="Which transforms to transfer",

View File

@@ -365,15 +365,18 @@ class AlignObjects(Operator):
bb_quality = BoolProperty( bb_quality = BoolProperty(
name="High Quality", name="High Quality",
description=("Enables high quality calculation of the " description=(
"Enables high quality calculation of the "
"bounding box for perfect results on complex " "bounding box for perfect results on complex "
"shape meshes with rotation/scale (Slow)"), "shape meshes with rotation/scale (Slow)"
),
default=True, default=True,
) )
align_mode = EnumProperty( align_mode = EnumProperty(
name="Align Mode:", name="Align Mode:",
description="Side of object to use for alignment", description="Side of object to use for alignment",
items=(('OPT_1', "Negative Sides", ""), items=(
('OPT_1', "Negative Sides", ""),
('OPT_2', "Centers", ""), ('OPT_2', "Centers", ""),
('OPT_3', "Positive Sides", ""), ('OPT_3', "Positive Sides", ""),
), ),
@@ -382,7 +385,8 @@ class AlignObjects(Operator):
relative_to = EnumProperty( relative_to = EnumProperty(
name="Relative To:", name="Relative To:",
description="Reference location to align to", description="Reference location to align to",
items=(('OPT_1', "Scene Origin", "Use the Scene Origin as the position for the selected objects to align to"), items=(
('OPT_1', "Scene Origin", "Use the Scene Origin as the position for the selected objects to align to"),
('OPT_2', "3D Cursor", "Use the 3D cursor as the position for the selected objects to align to"), ('OPT_2', "3D Cursor", "Use the 3D cursor as the position for the selected objects to align to"),
('OPT_3', "Selection", "Use the selected objects as the position for the selected objects to align to"), ('OPT_3', "Selection", "Use the selected objects as the position for the selected objects to align to"),
('OPT_4', "Active", "Use the active object as the position for the selected objects to align to"), ('OPT_4', "Active", "Use the active object as the position for the selected objects to align to"),
@@ -392,7 +396,8 @@ class AlignObjects(Operator):
align_axis = EnumProperty( align_axis = EnumProperty(
name="Align", name="Align",
description="Align to axis", description="Align to axis",
items=(('X', "X", ""), items=(
('X', "X", ""),
('Y', "Y", ""), ('Y', "Y", ""),
('Z', "Z", ""), ('Z', "Z", ""),
), ),

View File

@@ -54,9 +54,11 @@ class QuickFur(Operator):
density = EnumProperty( density = EnumProperty(
name="Fur Density", name="Fur Density",
items=(('LIGHT', "Light", ""), items=(
('LIGHT', "Light", ""),
('MEDIUM', "Medium", ""), ('MEDIUM', "Medium", ""),
('HEAVY', "Heavy", "")), ('HEAVY', "Heavy", "")
),
default='MEDIUM', default='MEDIUM',
) )
view_percentage = IntProperty( view_percentage = IntProperty(
@@ -118,8 +120,10 @@ class QuickExplode(Operator):
style = EnumProperty( style = EnumProperty(
name="Explode Style", name="Explode Style",
items=(('EXPLODE', "Explode", ""), items=(
('BLEND', "Blend", "")), ('EXPLODE', "Explode", ""),
('BLEND', "Blend", ""),
),
default='EXPLODE', default='EXPLODE',
) )
amount = IntProperty( amount = IntProperty(
@@ -304,7 +308,8 @@ class QuickSmoke(Operator):
style = EnumProperty( style = EnumProperty(
name="Smoke Style", name="Smoke Style",
items=(('SMOKE', "Smoke", ""), items=(
('SMOKE', "Smoke", ""),
('FIRE', "Fire", ""), ('FIRE', "Fire", ""),
('BOTH', "Smoke + Fire", ""), ('BOTH', "Smoke + Fire", ""),
), ),
@@ -407,8 +412,10 @@ class QuickFluid(Operator):
style = EnumProperty( style = EnumProperty(
name="Fluid Style", name="Fluid Style",
items=(('INFLOW', "Inflow", ""), items=(
('BASIC', "Basic", "")), ('INFLOW', "Inflow", ""),
('BASIC', "Basic", ""),
),
default='BASIC', default='BASIC',
) )
initial_velocity = FloatVectorProperty( initial_velocity = FloatVectorProperty(

View File

@@ -29,6 +29,7 @@ WindowManager.preset_name = StringProperty(
default="New Preset" default="New Preset"
) )
class AddPresetBase: class AddPresetBase:
"""Base preset class, only for subclassing """Base preset class, only for subclassing
subclasses must define subclasses must define
@@ -268,22 +269,26 @@ class PresetMenu(Panel):
@classmethod @classmethod
def draw_panel_header(cls, layout): def draw_panel_header(cls, layout):
layout.emboss = 'NONE' layout.emboss = 'NONE'
layout.popover(cls.bl_space_type, layout.popover(
cls.bl_space_type,
cls.bl_region_type, cls.bl_region_type,
cls.__name__, cls.__name__,
icon='PRESET', icon='PRESET',
text='') text="",
)
@classmethod @classmethod
def draw_menu(cls, layout, text=None): def draw_menu(cls, layout, text=None):
if text == None: if text is None:
text = cls.bl_label text = cls.bl_label
layout.popover(cls.bl_space_type, layout.popover(
cls.bl_space_type,
cls.bl_region_type, cls.bl_region_type,
cls.__name__, cls.__name__,
icon='PRESET', icon='PRESET',
text=text) text=text,
)
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout

View File

@@ -220,23 +220,29 @@ class ConnectRigidBodies(Operator):
name="Type", name="Type",
description="Type of generated constraint", description="Type of generated constraint",
# XXX Would be nice to get icons too, but currently not possible ;) # XXX Would be nice to get icons too, but currently not possible ;)
items=tuple((e.identifier, e.name, e.description, e. value) items=tuple(
for e in bpy.types.RigidBodyConstraint.bl_rna.properties["type"].enum_items), (e.identifier, e.name, e.description, e. value)
for e in bpy.types.RigidBodyConstraint.bl_rna.properties["type"].enum_items
),
default='FIXED', default='FIXED',
) )
pivot_type = EnumProperty( pivot_type = EnumProperty(
name="Location", name="Location",
description="Constraint pivot location", description="Constraint pivot location",
items=(('CENTER', "Center", "Pivot location is between the constrained rigid bodies"), items=(
('CENTER', "Center", "Pivot location is between the constrained rigid bodies"),
('ACTIVE', "Active", "Pivot location is at the active object position"), ('ACTIVE', "Active", "Pivot location is at the active object position"),
('SELECTED', "Selected", "Pivot location is at the selected object position")), ('SELECTED', "Selected", "Pivot location is at the selected object position"),
),
default='CENTER', default='CENTER',
) )
connection_pattern = EnumProperty( connection_pattern = EnumProperty(
name="Connection Pattern", name="Connection Pattern",
description="Pattern used to connect objects", description="Pattern used to connect objects",
items=(('SELECTED_TO_ACTIVE', "Selected to Active", "Connect selected objects to the active object"), items=(
('CHAIN_DISTANCE', "Chain by Distance", "Connect objects as a chain based on distance, starting at the active object")), ('SELECTED_TO_ACTIVE', "Selected to Active", "Connect selected objects to the active object"),
('CHAIN_DISTANCE', "Chain by Distance", "Connect objects as a chain based on distance, starting at the active object"),
),
default='SELECTED_TO_ACTIVE', default='SELECTED_TO_ACTIVE',
) )

View File

@@ -460,7 +460,7 @@ def lightmap_uvpack(meshes,
# Tall boxes in groups of 2 # Tall boxes in groups of 2
for d, boxes in list(odd_dict.items()): for d, boxes in list(odd_dict.items()):
if d[1] < max_int_dimension: if d[1] < max_int_dimension:
#\boxes.sort(key = lambda a: len(a.children)) # boxes.sort(key=lambda a: len(a.children))
while len(boxes) >= 2: while len(boxes) >= 2:
# print("foo", len(boxes)) # print("foo", len(boxes))
ok = True ok = True
@@ -597,6 +597,7 @@ def unwrap(operator, context, **kwargs):
return {'FINISHED'} return {'FINISHED'}
from bpy.props import BoolProperty, FloatProperty, IntProperty from bpy.props import BoolProperty, FloatProperty, IntProperty
@@ -617,7 +618,8 @@ class LightMapPack(Operator):
PREF_CONTEXT = bpy.props.EnumProperty( PREF_CONTEXT = bpy.props.EnumProperty(
name="Selection", name="Selection",
items=(('SEL_FACES', "Selected Faces", "Space all UVs evenly"), items=(
('SEL_FACES', "Selected Faces", "Space all UVs evenly"),
('ALL_FACES', "All Faces", "Average space UVs edge length of each loop"), ('ALL_FACES', "All Faces", "Average space UVs edge length of each loop"),
('ALL_OBJECTS', "Selected Mesh Object", "Average space UVs edge length of each loop") ('ALL_OBJECTS', "Selected Mesh Object", "Average space UVs edge length of each loop")
), ),
@@ -626,8 +628,10 @@ class LightMapPack(Operator):
# Image & UVs... # Image & UVs...
PREF_PACK_IN_ONE = BoolProperty( PREF_PACK_IN_ONE = BoolProperty(
name="Share Tex Space", name="Share Tex Space",
description=("Objects Share texture space, map all objects " description=(
"into 1 uvmap"), "Objects Share texture space, map all objects "
"into 1 uvmap"
),
default=True, default=True,
) )
PREF_NEW_UVLAYER = BoolProperty( PREF_NEW_UVLAYER = BoolProperty(
@@ -637,8 +641,10 @@ class LightMapPack(Operator):
) )
PREF_APPLY_IMAGE = BoolProperty( PREF_APPLY_IMAGE = BoolProperty(
name="New Image", name="New Image",
description=("Assign new images for every mesh (only one if " description=(
"shared tex space enabled)"), "Assign new images for every mesh (only one if "
"shared tex space enabled)"
),
default=False, default=False,
) )
PREF_IMG_PX_SIZE = IntProperty( PREF_IMG_PX_SIZE = IntProperty(

View File

@@ -38,6 +38,7 @@ global USER_FILL_HOLES_QUALITY
USER_FILL_HOLES = None USER_FILL_HOLES = None
USER_FILL_HOLES_QUALITY = None USER_FILL_HOLES_QUALITY = None
def pointInTri2D(v, v1, v2, v3): def pointInTri2D(v, v1, v2, v3):
key = v1.x, v1.y, v2.x, v2.y, v3.x, v3.y key = v1.x, v1.y, v2.x, v2.y, v3.x, v3.y
@@ -100,13 +101,18 @@ def boundsIsland(faces):
for uv in f.uv: for uv in f.uv:
x = uv.x x = uv.x
y = uv.y y = uv.y
if x<minx: minx= x if x < minx:
if y<miny: miny= y minx = x
if x>maxx: maxx= x if y < miny:
if y>maxy: maxy= y miny = y
if x > maxx:
maxx = x
if y > maxy:
maxy = y
return minx, miny, maxx, maxy return minx, miny, maxx, maxy
""" """
def boundsEdgeLoop(edges): def boundsEdgeLoop(edges):
minx = maxx = edges[0][0] # Set initial bounds. minx = maxx = edges[0][0] # Set initial bounds.
@@ -128,6 +134,7 @@ def boundsEdgeLoop(edges):
# Only for UV's # Only for UV's
# only returns outline edges for intersection tests. and unique points. # only returns outline edges for intersection tests. and unique points.
def island2Edge(island): def island2Edge(island):
# Vert index edges # Vert index edges
@@ -138,27 +145,31 @@ def island2Edge(island):
for f in island: for f in island:
f_uvkey = map(tuple, f.uv) f_uvkey = map(tuple, f.uv)
for vIdx, edkey in enumerate(f.edge_keys): for vIdx, edkey in enumerate(f.edge_keys):
unique_points[f_uvkey[vIdx]] = f.uv[vIdx] unique_points[f_uvkey[vIdx]] = f.uv[vIdx]
if f.v[vIdx].index > f.v[vIdx - 1].index: if f.v[vIdx].index > f.v[vIdx - 1].index:
i1= vIdx-1; i2= vIdx i1 = vIdx - 1
i2 = vIdx
else: else:
i1= vIdx; i2= vIdx-1 i1 = vIdx
i2 = vIdx - 1
try: edges[ f_uvkey[i1], f_uvkey[i2] ] *= 0 # sets any edge with more than 1 user to 0 are not returned. try:
except: edges[ f_uvkey[i1], f_uvkey[i2] ] = (f.uv[i1] - f.uv[i2]).length, edges[f_uvkey[i1], f_uvkey[i2]] *= 0 # sets any edge with more than 1 user to 0 are not returned.
except:
edges[f_uvkey[i1], f_uvkey[i2]] = (f.uv[i1] - f.uv[i2]).length,
# If 2 are the same then they will be together, but full [a,b] order is not correct. # If 2 are the same then they will be together, but full [a,b] order is not correct.
# Sort by length # Sort by length
length_sorted_edges = [(Vector(key[0]), Vector(key[1]), value) for key, value in edges.items() if value != 0] length_sorted_edges = [(Vector(key[0]), Vector(key[1]), value) for key, value in edges.items() if value != 0]
try: length_sorted_edges.sort(key = lambda A: -A[2]) # largest first try:
except: length_sorted_edges.sort(lambda A, B: cmp(B[2], A[2])) length_sorted_edges.sort(key=lambda A: -A[2]) # largest first
except:
length_sorted_edges.sort(lambda A, B: cmp(B[2], A[2]))
# Its okay to leave the length in there. # Its okay to leave the length in there.
# for e in length_sorted_edges: # for e in length_sorted_edges:
@@ -167,6 +178,7 @@ def island2Edge(island):
# return edges and unique points # return edges and unique points
return length_sorted_edges, [v.to_3d() for v in unique_points.values()] return length_sorted_edges, [v.to_3d() for v in unique_points.values()]
# ========================= NOT WORKING???? # ========================= NOT WORKING????
# Find if a points inside an edge loop, unordered. # Find if a points inside an edge loop, unordered.
# pt is and x/y # pt is and x/y
@@ -190,6 +202,7 @@ def pointInEdges(pt, edges):
return intersectCount % 2 return intersectCount % 2
""" """
def pointInIsland(pt, island): def pointInIsland(pt, island):
vec1, vec2, vec3 = Vector(), Vector(), Vector() vec1, vec2, vec3 = Vector(), Vector(), Vector()
for f in island: for f in island:
@@ -270,14 +283,12 @@ def mergeUvIslands(islandList):
global USER_FILL_HOLES global USER_FILL_HOLES
global USER_FILL_HOLES_QUALITY global USER_FILL_HOLES_QUALITY
# Pack islands to bottom LHS # Pack islands to bottom LHS
# Sync with island # Sync with island
# islandTotFaceArea = [] # A list of floats, each island area # islandTotFaceArea = [] # A list of floats, each island area
# islandArea = [] # a list of tuples ( area, w,h) # islandArea = [] # a list of tuples ( area, w,h)
decoratedIslandList = [] decoratedIslandList = []
islandIdx = len(islandList) islandIdx = len(islandList)
@@ -302,7 +313,6 @@ def mergeUvIslands(islandList):
decoratedIslandList.append([islandList[islandIdx], totFaceArea, efficiency, islandBoundsArea, w, h, edges, uniqueEdgePoints]) decoratedIslandList.append([islandList[islandIdx], totFaceArea, efficiency, islandBoundsArea, w, h, edges, uniqueEdgePoints])
# Sort by island bounding box area, smallest face area first. # Sort by island bounding box area, smallest face area first.
# no.. chance that to most simple edge loop first. # no.. chance that to most simple edge loop first.
decoratedIslandListAreaSort = decoratedIslandList[:] decoratedIslandListAreaSort = decoratedIslandList[:]
@@ -355,7 +365,6 @@ def mergeUvIslands(islandList):
targetIsland = decoratedIslandListEfficSort[efficIslandIdx] targetIsland = decoratedIslandListEfficSort[efficIslandIdx]
if sourceIsland[0] == targetIsland[0] or\ if sourceIsland[0] == targetIsland[0] or\
not targetIsland[0] or\ not targetIsland[0] or\
not sourceIsland[0]: not sourceIsland[0]:
@@ -365,7 +374,6 @@ def mergeUvIslands(islandList):
#~ ([island, totFaceArea, efficiency, islandArea, w,h]) #~ ([island, totFaceArea, efficiency, islandArea, w,h])
# Wasted space on target is greater then UV bounding island area. # Wasted space on target is greater then UV bounding island area.
#~ if targetIsland[3] > (sourceIsland[2]) and\ # #~ if targetIsland[3] > (sourceIsland[2]) and\ #
# ~ print USER_FREE_SPACE_TO_TEST_QUALITY # ~ print USER_FREE_SPACE_TO_TEST_QUALITY
if targetIsland[2] > (sourceIsland[1] * USER_FREE_SPACE_TO_TEST_QUALITY) and\ if targetIsland[2] > (sourceIsland[1] * USER_FREE_SPACE_TO_TEST_QUALITY) and\
@@ -382,7 +390,6 @@ def mergeUvIslands(islandList):
boxLeft = 0 boxLeft = 0
# Distance we can move between whilst staying inside the targets bounds. # Distance we can move between whilst staying inside the targets bounds.
testWidth = targetIsland[4] - sourceIsland[4] testWidth = targetIsland[4] - sourceIsland[4]
testHeight = targetIsland[5] - sourceIsland[5] testHeight = targetIsland[5] - sourceIsland[5]
@@ -397,7 +404,6 @@ def mergeUvIslands(islandList):
if yIncrement < sourceIsland[5] / 3: if yIncrement < sourceIsland[5] / 3:
yIncrement = sourceIsland[5] yIncrement = sourceIsland[5]
boxLeft = 0 # Start 1 back so we can jump into the loop. boxLeft = 0 # Start 1 back so we can jump into the loop.
boxBottom = 0 # -yIncrement boxBottom = 0 # -yIncrement
@@ -409,7 +415,7 @@ def mergeUvIslands(islandList):
# ~ BREAK= True # ~ BREAK= True
# ~ break # ~ break
##testcount+=1 # testcount+=1
# print 'Testing intersect' # print 'Testing intersect'
Intersect = islandIntersectUvIsland(sourceIsland, targetIsland, Vector((boxLeft, boxBottom))) Intersect = islandIntersectUvIsland(sourceIsland, targetIsland, Vector((boxLeft, boxBottom)))
# print 'Done', Intersect # print 'Done', Intersect
@@ -444,21 +450,21 @@ def mergeUvIslands(islandList):
del sourceIsland[0][:] # Empty del sourceIsland[0][:] # Empty
# Move edge loop into new and offset. # Move edge loop into new and offset.
# targetIsland[6].extend(sourceIsland[6]) # targetIsland[6].extend(sourceIsland[6])
# while sourceIsland[6]: # while sourceIsland[6]:
targetIsland[6].extend( [ (\ targetIsland[6].extend([(
(e[0]+offset, e[1]+offset, e[2])\ (e[0] + offset, e[1] + offset, e[2])
) for e in sourceIsland[6]]) ) for e in sourceIsland[6]])
del sourceIsland[6][:] # Empty del sourceIsland[6][:] # Empty
# Sort by edge length, reverse so biggest are first. # Sort by edge length, reverse so biggest are first.
try: targetIsland[6].sort(key = lambda A: A[2]) try:
except: targetIsland[6].sort(lambda B,A: cmp(A[2], B[2] )) targetIsland[6].sort(key=lambda A: A[2])
except:
targetIsland[6].sort(lambda B, A: cmp(A[2], B[2]))
targetIsland[7].extend(sourceIsland[7]) targetIsland[7].extend(sourceIsland[7])
offset = Vector((boxLeft, boxBottom, 0.0)) offset = Vector((boxLeft, boxBottom, 0.0))
@@ -467,7 +473,6 @@ def mergeUvIslands(islandList):
del sourceIsland[7][:] del sourceIsland[7][:]
# Decrement the efficiency # Decrement the efficiency
targetIsland[1] += sourceIsland[1] # Increment totFaceArea targetIsland[1] += sourceIsland[1] # Increment totFaceArea
targetIsland[2] -= sourceIsland[1] # Decrement efficiency targetIsland[2] -= sourceIsland[1] # Decrement efficiency
@@ -476,14 +481,13 @@ def mergeUvIslands(islandList):
break break
# INCREMENT NEXT LOCATION # INCREMENT NEXT LOCATION
if boxLeft > testWidth: if boxLeft > testWidth:
boxBottom += yIncrement boxBottom += yIncrement
boxLeft = 0.0 boxLeft = 0.0
else: else:
boxLeft += xIncrement boxLeft += xIncrement
##print testcount # print testcount
efficIslandIdx += 1 efficIslandIdx += 1
areaIslandIdx += 1 areaIslandIdx += 1
@@ -496,6 +500,8 @@ def mergeUvIslands(islandList):
del islandList[i] # Can increment islands removed here. del islandList[i] # Can increment islands removed here.
# Takes groups of faces. assumes face groups are UV groups. # Takes groups of faces. assumes face groups are UV groups.
def getUvIslands(faceGroups, me): def getUvIslands(faceGroups, me):
# Get seams so we don't cross over seams # Get seams so we don't cross over seams
@@ -505,7 +511,6 @@ def getUvIslands(faceGroups, me):
edge_seams[ed.key] = None # dummy var- use sets! edge_seams[ed.key] = None # dummy var- use sets!
# Done finding seams # Done finding seams
islandList = [] islandList = []
# XXX Window.DrawProgressBar(0.0, 'Splitting %d projection groups into UV islands:' % len(faceGroups)) # XXX Window.DrawProgressBar(0.0, 'Splitting %d projection groups into UV islands:' % len(faceGroups))
@@ -529,8 +534,10 @@ def getUvIslands(faceGroups, me):
if ed_key in edge_seams: # DELIMIT SEAMS! ;) if ed_key in edge_seams: # DELIMIT SEAMS! ;)
edge_users[ed_key] = [] # so as not to raise an error edge_users[ed_key] = [] # so as not to raise an error
else: else:
try: edge_users[ed_key].append(i) try:
except: edge_users[ed_key] = [i] edge_users[ed_key].append(i)
except:
edge_users[ed_key] = [i]
# Modes # Modes
# 0 - face not yet touched. # 0 - face not yet touched.
@@ -544,7 +551,6 @@ def getUvIslands(faceGroups, me):
newIsland.append(faces[0]) newIsland.append(faces[0])
ok = True ok = True
while ok: while ok:
@@ -587,7 +593,6 @@ def packIslands(islandList):
# XXX Window.DrawProgressBar(0.1, 'Merging Islands (Ctrl: skip merge)...') # XXX Window.DrawProgressBar(0.1, 'Merging Islands (Ctrl: skip merge)...')
mergeUvIslands(islandList) # Modify in place mergeUvIslands(islandList) # Modify in place
# Now we have UV islands, we need to pack them. # Now we have UV islands, we need to pack them.
# Make a synchronized list with the islands # Make a synchronized list with the islands
@@ -680,6 +685,7 @@ def VectoQuat(vec):
class thickface: class thickface:
__slost__ = "v", "uv", "no", "area", "edge_keys" __slost__ = "v", "uv", "no", "area", "edge_keys"
def __init__(self, face, uv_layer, mesh_verts): def __init__(self, face, uv_layer, mesh_verts):
self.v = [mesh_verts[i] for i in face.vertices] self.v = [mesh_verts[i] for i in face.vertices]
self.uv = [uv_layer[i].uv for i in face.loop_indices] self.uv = [uv_layer[i].uv for i in face.loop_indices]
@@ -712,6 +718,8 @@ def main_consts():
global ob global ob
ob = None ob = None
def main(context, def main(context,
island_margin, island_margin,
projection_limit, projection_limit,
@@ -779,7 +787,6 @@ def main(context,
USER_PROJECTION_LIMIT_CONVERTED = cos(USER_PROJECTION_LIMIT * DEG_TO_RAD) USER_PROJECTION_LIMIT_CONVERTED = cos(USER_PROJECTION_LIMIT * DEG_TO_RAD)
USER_PROJECTION_LIMIT_HALF_CONVERTED = cos((USER_PROJECTION_LIMIT / 2) * DEG_TO_RAD) USER_PROJECTION_LIMIT_HALF_CONVERTED = cos((USER_PROJECTION_LIMIT / 2) * DEG_TO_RAD)
# Toggle Edit mode # Toggle Edit mode
is_editmode = (context.active_object.mode == 'EDIT') is_editmode = (context.active_object.mode == 'EDIT')
if is_editmode: if is_editmode:
@@ -800,7 +807,6 @@ def main(context,
for me in bpy.data.meshes: for me in bpy.data.meshes:
me.tag = False me.tag = False
for ob in obList: for ob in obList:
me = ob.data me = ob.data
@@ -849,7 +855,6 @@ def main(context,
# 0d is 1.0 # 0d is 1.0
# 180 IS -0.59846 # 180 IS -0.59846
# Initialize projectVecs # Initialize projectVecs
if USER_VIEW_INIT: if USER_VIEW_INIT:
# Generate Projection # Generate Projection
@@ -860,15 +865,12 @@ def main(context,
newProjectVec = meshFaces[0].no newProjectVec = meshFaces[0].no
newProjectMeshFaces = [] # Popping stuffs it up. newProjectMeshFaces = [] # Popping stuffs it up.
# Pretend that the most unique angle is ages away to start the loop off # Pretend that the most unique angle is ages away to start the loop off
mostUniqueAngle = -1.0 mostUniqueAngle = -1.0
# This is popped # This is popped
tempMeshFaces = meshFaces[:] tempMeshFaces = meshFaces[:]
# This while only gathers projection vecs, faces are assigned later on. # This while only gathers projection vecs, faces are assigned later on.
while 1: while 1:
# If theres none there then start with the largest face # If theres none there then start with the largest face
@@ -895,7 +897,6 @@ def main(context,
if averageVec.x != 0 or averageVec.y != 0 or averageVec.z != 0: # Avoid NAN if averageVec.x != 0 or averageVec.y != 0 or averageVec.z != 0: # Avoid NAN
projectVecs.append(averageVec.normalized()) projectVecs.append(averageVec.normalized())
# Get the next vec! # Get the next vec!
# Pick the face thats most different to all existing angles :) # Pick the face thats most different to all existing angles :)
mostUniqueAngle = 1.0 # 1.0 is 0d. no difference. mostUniqueAngle = 1.0 # 1.0 is 0d. no difference.
@@ -924,12 +925,10 @@ def main(context,
newProjectVec = tempMeshFaces[mostUniqueIndex].no newProjectVec = tempMeshFaces[mostUniqueIndex].no
newProjectMeshFaces = [tempMeshFaces.pop(mostUniqueIndex)] newProjectMeshFaces = [tempMeshFaces.pop(mostUniqueIndex)]
else: else:
if len(projectVecs) >= 1: # Must have at least 2 projections if len(projectVecs) >= 1: # Must have at least 2 projections
break break
# If there are only zero area faces then its possible # If there are only zero area faces then its possible
# there are no projectionVecs # there are no projectionVecs
if not len(projectVecs): if not len(projectVecs):
@@ -962,7 +961,6 @@ def main(context,
# Cull faceProjectionGroupList, # Cull faceProjectionGroupList,
# Now faceProjectionGroupList is full of faces that face match the project Vecs list # Now faceProjectionGroupList is full of faces that face match the project Vecs list
for i in range(len(projectVecs)): for i in range(len(projectVecs)):
# Account for projectVecs having no faces. # Account for projectVecs having no faces.
@@ -979,7 +977,6 @@ def main(context,
# XXX - note, between mathutils in 2.4 and 2.5 the order changed. # XXX - note, between mathutils in 2.4 and 2.5 the order changed.
f_uv[j][:] = (MatQuat * v.co).xy f_uv[j][:] = (MatQuat * v.co).xy
if USER_SHARE_SPACE: if USER_SHARE_SPACE:
# Should we collect and pack later? # Should we collect and pack later?
islandList = getUvIslands(faceProjectionGroupList, me) islandList = getUvIslands(faceProjectionGroupList, me)
@@ -990,7 +987,6 @@ def main(context,
islandList = getUvIslands(faceProjectionGroupList, me) islandList = getUvIslands(faceProjectionGroupList, me)
packIslands(islandList) packIslands(islandList)
# update the mesh here if we need to. # update the mesh here if we need to.
# We want to pack all in 1 go, so pack now # We want to pack all in 1 go, so pack now
@@ -1009,10 +1005,10 @@ def main(context,
import bmesh import bmesh
aspect = context.scene.uvedit_aspect(context.active_object) aspect = context.scene.uvedit_aspect(context.active_object)
if aspect[0] > aspect[1]: if aspect[0] > aspect[1]:
aspect[0] = aspect[1]/aspect[0]; aspect[0] = aspect[1] / aspect[0]
aspect[1] = 1.0 aspect[1] = 1.0
else: else:
aspect[1] = aspect[0]/aspect[1]; aspect[1] = aspect[0] / aspect[1]
aspect[0] = 1.0 aspect[0] = 1.0
bm = bmesh.from_edit_mesh(me) bm = bmesh.from_edit_mesh(me)
@@ -1032,6 +1028,7 @@ def main(context,
# XXX Window.WaitCursor(0) # XXX Window.WaitCursor(0)
# XXX Window.RedrawAll() # XXX Window.RedrawAll()
""" """
pup_block = [\ pup_block = [\
'Projection',\ 'Projection',\

View File

@@ -39,13 +39,16 @@ class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator):
totface = mesh.total_face_sel totface = mesh.total_face_sel
totedge = mesh.total_edge_sel totedge = mesh.total_edge_sel
#~ totvert = mesh.total_vert_sel # totvert = mesh.total_vert_sel
if select_mode[2] and totface == 1: if select_mode[2] and totface == 1:
bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN', bpy.ops.mesh.extrude_region_move(
'INVOKE_REGION_WIN',
TRANSFORM_OT_translate={ TRANSFORM_OT_translate={
"constraint_orientation": 'NORMAL', "constraint_orientation": 'NORMAL',
"constraint_axis": (False, False, True)}) "constraint_axis": (False, False, True),
}
)
elif select_mode[2] and totface > 1: elif select_mode[2] and totface > 1:
bpy.ops.mesh.extrude_faces_move('INVOKE_REGION_WIN') bpy.ops.mesh.extrude_faces_move('INVOKE_REGION_WIN')
elif select_mode[1] and totedge >= 1: elif select_mode[1] and totedge >= 1:
@@ -77,25 +80,32 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
totface = mesh.total_face_sel totface = mesh.total_face_sel
totedge = mesh.total_edge_sel totedge = mesh.total_edge_sel
#~ totvert = mesh.total_vert_sel # totvert = mesh.total_vert_sel
if totface >= 1: if totface >= 1:
if use_vert_normals: if use_vert_normals:
bpy.ops.mesh.extrude_region_shrink_fatten('INVOKE_REGION_WIN', bpy.ops.mesh.extrude_region_shrink_fatten(
TRANSFORM_OT_shrink_fatten={}) 'INVOKE_REGION_WIN',
TRANSFORM_OT_shrink_fatten={},
)
else: else:
bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN', bpy.ops.mesh.extrude_region_move(
'INVOKE_REGION_WIN',
TRANSFORM_OT_translate={ TRANSFORM_OT_translate={
"constraint_orientation": 'NORMAL', "constraint_orientation": 'NORMAL',
"constraint_axis": (False, False, True)}) "constraint_axis": (False, False, True),
},
)
elif totedge == 1: elif totedge == 1:
bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN', bpy.ops.mesh.extrude_region_move(
'INVOKE_REGION_WIN',
TRANSFORM_OT_translate={ TRANSFORM_OT_translate={
"constraint_orientation": 'NORMAL', "constraint_orientation": 'NORMAL',
# not a popular choice, too restrictive for retopo. # not a popular choice, too restrictive for retopo.
#~ "constraint_axis": (True, True, False)}) # "constraint_axis": (True, True, False)})
"constraint_axis": (False, False, False)}) "constraint_axis": (False, False, False),
})
else: else:
bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN') bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN')

View File

@@ -59,6 +59,8 @@ def dopesheet_filter(layout, context, genericFiltersOnly=False):
# Generic Layout - Used as base for filtering popovers used in all animation editors # Generic Layout - Used as base for filtering popovers used in all animation editors
# Used for DopeSheet, NLA, and Graph Editors # Used for DopeSheet, NLA, and Graph Editors
class DopesheetFilterPopoverBase: class DopesheetFilterPopoverBase:
bl_region_type = 'HEADER' bl_region_type = 'HEADER'
bl_label = "Filters" bl_label = "Filters"
@@ -211,11 +213,13 @@ class DOPESHEET_HT_header(Header):
TIME_HT_editor_buttons.draw_header(context, layout) TIME_HT_editor_buttons.draw_header(context, layout)
else: else:
layout.prop(st, "ui_mode", text="") layout.prop(st, "ui_mode", text="")
layout.popover(space_type='DOPESHEET_EDITOR', layout.popover(
space_type='DOPESHEET_EDITOR',
region_type='HEADER', region_type='HEADER',
panel_type="DOPESHEET_PT_filters", panel_type="DOPESHEET_PT_filters",
text="", text="",
icon='FILTER') icon='FILTER',
)
DOPESHEET_MT_editor_menus.draw_collapsible(context, layout) DOPESHEET_MT_editor_menus.draw_collapsible(context, layout)
DOPESHEET_HT_editor_buttons.draw_header(context, layout) DOPESHEET_HT_editor_buttons.draw_header(context, layout)

View File

@@ -41,11 +41,13 @@ class GRAPH_HT_header(Header):
# Now a exposed as a sub-space type # Now a exposed as a sub-space type
# layout.prop(st, "mode", text="") # layout.prop(st, "mode", text="")
layout.popover(space_type='GRAPH_EDITOR', layout.popover(
space_type='GRAPH_EDITOR',
region_type='HEADER', region_type='HEADER',
panel_type="GRAPH_PT_filters", panel_type="GRAPH_PT_filters",
text="", text="",
icon='FILTER') icon='FILTER',
)
GRAPH_MT_editor_menus.draw_collapsible(context, layout) GRAPH_MT_editor_menus.draw_collapsible(context, layout)

View File

@@ -37,11 +37,13 @@ class NLA_HT_header(Header):
row = layout.row(align=True) row = layout.row(align=True)
row.template_header() row.template_header()
layout.popover(space_type='NLA_EDITOR', layout.popover(
space_type='NLA_EDITOR',
region_type='HEADER', region_type='HEADER',
panel_type="NLA_PT_filters", panel_type="NLA_PT_filters",
text="", text="",
icon='FILTER') icon='FILTER',
)
NLA_MT_editor_menus.draw_collapsible(context, layout) NLA_MT_editor_menus.draw_collapsible(context, layout)

View File

@@ -91,14 +91,18 @@ class TIME_MT_editor_menus(Menu):
@staticmethod @staticmethod
def draw_menus(layout, context): def draw_menus(layout, context):
layout.popover(space_type='DOPESHEET_EDITOR', layout.popover(
space_type='DOPESHEET_EDITOR',
region_type='HEADER', region_type='HEADER',
panel_type="TIME_PT_playback", panel_type="TIME_PT_playback",
text="Playback") text="Playback",
layout.popover(space_type='DOPESHEET_EDITOR', )
layout.popover(
space_type='DOPESHEET_EDITOR',
region_type='HEADER', region_type='HEADER',
panel_type="TIME_PT_keyframing_settings", panel_type="TIME_PT_keyframing_settings",
text="Keying") text="Keying",
)
layout.menu("TIME_MT_view") layout.menu("TIME_MT_view")
layout.menu("TIME_MT_marker") layout.menu("TIME_MT_marker")

View File

@@ -22,7 +22,8 @@ def add_object(self, context):
scale_x = self.scale.x scale_x = self.scale.x
scale_y = self.scale.y scale_y = self.scale.y
verts = [Vector((-1 * scale_x, 1 * scale_y, 0)), verts = [
Vector((-1 * scale_x, 1 * scale_y, 0)),
Vector((1 * scale_x, 1 * scale_y, 0)), Vector((1 * scale_x, 1 * scale_y, 0)),
Vector((1 * scale_x, -1 * scale_y, 0)), Vector((1 * scale_x, -1 * scale_y, 0)),
Vector((-1 * scale_x, -1 * scale_y, 0)), Vector((-1 * scale_x, -1 * scale_y, 0)),

View File

@@ -81,13 +81,19 @@ def main():
# Example utility, add some text and renders or saves it (with options) # Example utility, add some text and renders or saves it (with options)
# Possible types are: string, int, long, choice, float and complex. # Possible types are: string, int, long, choice, float and complex.
parser.add_argument("-t", "--text", dest="text", type=str, required=True, parser.add_argument(
help="This text will be used to render an image") "-t", "--text", dest="text", type=str, required=True,
help="This text will be used to render an image",
)
parser.add_argument("-s", "--save", dest="save_path", metavar='FILE', parser.add_argument(
help="Save the generated file to the specified path") "-s", "--save", dest="save_path", metavar='FILE',
parser.add_argument("-r", "--render", dest="render_path", metavar='FILE', help="Save the generated file to the specified path",
help="Render an image to the specified path") )
parser.add_argument(
"-r", "--render", dest="render_path", metavar='FILE',
help="Render an image to the specified path",
)
args = parser.parse_args(argv) # In this example we wont use the args args = parser.parse_args(argv) # In this example we wont use the args

View File

@@ -28,7 +28,7 @@ for obj in selection:
bpy.ops.export_scene.fbx(filepath=fn + ".fbx", use_selection=True) bpy.ops.export_scene.fbx(filepath=fn + ".fbx", use_selection=True)
## Can be used for multiple formats # Can be used for multiple formats
# bpy.ops.export_scene.x3d(filepath=fn + ".x3d", use_selection=True) # bpy.ops.export_scene.x3d(filepath=fn + ".x3d", use_selection=True)
obj.select_set(action='DESELECT') obj.select_set(action='DESELECT')

View File

@@ -124,6 +124,8 @@ from nodeitems_utils import NodeCategory, NodeItem
# our own base class with an appropriate poll function, # our own base class with an appropriate poll function,
# so the categories only show up in our own tree type # so the categories only show up in our own tree type
class MyNodeCategory(NodeCategory): class MyNodeCategory(NodeCategory):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
@@ -159,6 +161,7 @@ classes = (
MyCustomNode, MyCustomNode,
) )
def register(): def register():
from bpy.utils import register_class from bpy.utils import register_class
for cls in classes: for cls in classes:

View File

@@ -16,6 +16,7 @@ from bpy.props import (
FloatVectorProperty, FloatVectorProperty,
) )
def main(context, plane_co, plane_no): def main(context, plane_co, plane_no):
obj = context.active_object obj = context.active_object
matrix = obj.matrix_world.copy() matrix = obj.matrix_world.copy()
@@ -218,6 +219,7 @@ classes = (
SelectSideOfPlaneManipulatorGroup, SelectSideOfPlaneManipulatorGroup,
) )
def register(): def register():
for cls in classes: for cls in classes:
bpy.utils.register_class(cls) bpy.utils.register_class(cls)
@@ -227,5 +229,6 @@ def unregister():
for cls in reversed(classes): for cls in reversed(classes):
bpy.utils.unregister_class(cls) bpy.utils.unregister_class(cls)
if __name__ == "__main__": if __name__ == "__main__":
register() register()

View File

@@ -8,6 +8,7 @@ from bpy.types import (
ManipulatorGroup, ManipulatorGroup,
) )
class MyCameraWidgetGroup(ManipulatorGroup): class MyCameraWidgetGroup(ManipulatorGroup):
bl_idname = "OBJECT_WGT_test_camera" bl_idname = "OBJECT_WGT_test_camera"
bl_label = "Object Camera Test Widget" bl_label = "Object Camera Test Widget"
@@ -45,4 +46,5 @@ class MyCameraWidgetGroup(ManipulatorGroup):
mpr = self.roll_widget mpr = self.roll_widget
mpr.matrix_basis = ob.matrix_world.normalized() mpr.matrix_basis = ob.matrix_world.normalized()
bpy.utils.register_class(MyCameraWidgetGroup) bpy.utils.register_class(MyCameraWidgetGroup)

View File

@@ -9,6 +9,7 @@ from bpy.types import (
ManipulatorGroup, ManipulatorGroup,
) )
class MyLampWidgetGroup(ManipulatorGroup): class MyLampWidgetGroup(ManipulatorGroup):
bl_idname = "OBJECT_WGT_lamp_test" bl_idname = "OBJECT_WGT_lamp_test"
bl_label = "Test Lamp Widget" bl_label = "Test Lamp Widget"
@@ -42,4 +43,5 @@ class MyLampWidgetGroup(ManipulatorGroup):
mpr = self.energy_widget mpr = self.energy_widget
mpr.matrix_basis = ob.matrix_world.normalized() mpr.matrix_basis = ob.matrix_world.normalized()
bpy.utils.register_class(MyLampWidgetGroup) bpy.utils.register_class(MyLampWidgetGroup)

View File

@@ -42,8 +42,10 @@ class ExportSomeData(Operator, ExportHelper):
type = EnumProperty( type = EnumProperty(
name="Example Enum", name="Example Enum",
description="Choose between two items", description="Choose between two items",
items=(('OPT_A', "First Option", "Description one"), items=(
('OPT_B', "Second Option", "Description two")), ('OPT_A', "First Option", "Description one"),
('OPT_B', "Second Option", "Description two"),
),
default='OPT_A', default='OPT_A',
) )

View File

@@ -45,8 +45,10 @@ class ImportSomeData(Operator, ImportHelper):
type = EnumProperty( type = EnumProperty(
name="Example Enum", name="Example Enum",
description="Choose between two items", description="Choose between two items",
items=(('OPT_A', "First Option", "Description one"), items=(
('OPT_B', "Second Option", "Description two")), ('OPT_A', "First Option", "Description one"),
('OPT_B', "Second Option", "Description two"),
),
default='OPT_A', default='OPT_A',
) )

View File

@@ -8,7 +8,8 @@ def add_box(width, height, depth):
no actual mesh data creation is done here. no actual mesh data creation is done here.
""" """
verts = [(+1.0, +1.0, -1.0), verts = [
(+1.0, +1.0, -1.0),
(+1.0, -1.0, -1.0), (+1.0, -1.0, -1.0),
(-1.0, -1.0, -1.0), (-1.0, -1.0, -1.0),
(-1.0, +1.0, -1.0), (-1.0, +1.0, -1.0),
@@ -18,7 +19,8 @@ def add_box(width, height, depth):
(-1.0, +1.0, +1.0), (-1.0, +1.0, +1.0),
] ]
faces = [(0, 1, 2, 3), faces = [
(0, 1, 2, 3),
(4, 7, 6, 5), (4, 7, 6, 5),
(0, 4, 5, 1), (0, 4, 5, 1),
(1, 5, 6, 2), (1, 5, 6, 2),
@@ -88,7 +90,8 @@ class AddBox(bpy.types.Operator):
def execute(self, context): def execute(self, context):
verts_loc, faces = add_box(self.width, verts_loc, faces = add_box(
self.width,
self.height, self.height,
self.depth, self.depth,
) )
@@ -127,6 +130,7 @@ def unregister():
bpy.utils.unregister_class(AddBox) bpy.utils.unregister_class(AddBox)
bpy.types.INFO_MT_mesh_add.remove(menu_func) bpy.types.INFO_MT_mesh_add.remove(menu_func)
if __name__ == "__main__": if __name__ == "__main__":
register() register()

View File

@@ -75,5 +75,6 @@ def register():
def unregister(): def unregister():
bpy.utils.unregister_class(ModalDrawOperator) bpy.utils.unregister_class(ModalDrawOperator)
if __name__ == "__main__": if __name__ == "__main__":
register() register()

View File

@@ -42,6 +42,7 @@ def unregister():
bpy.types.INFO_HT_header.remove(draw_item) bpy.types.INFO_HT_header.remove(draw_item)
if __name__ == "__main__": if __name__ == "__main__":
register() register()

View File

@@ -19,6 +19,7 @@ def register():
def unregister(): def unregister():
bpy.utils.unregister_class(SimpleCustomMenu) bpy.utils.unregister_class(SimpleCustomMenu)
if __name__ == "__main__": if __name__ == "__main__":
register() register()

View File

@@ -368,7 +368,8 @@ void MESH_OT_bisect(struct wmOperatorType *ot)
RNA_def_boolean(ot->srna, "clear_inner", false, "Clear Inner", "Remove geometry behind the plane"); RNA_def_boolean(ot->srna, "clear_inner", false, "Clear Inner", "Remove geometry behind the plane");
RNA_def_boolean(ot->srna, "clear_outer", false, "Clear Outer", "Remove geometry in front of the plane"); RNA_def_boolean(ot->srna, "clear_outer", false, "Clear Outer", "Remove geometry in front of the plane");
RNA_def_float(ot->srna, "threshold", 0.0001, 0.0, 10.0, "Axis Threshold", "", 0.00001, 0.1); RNA_def_float(ot->srna, "threshold", 0.0001, 0.0, 10.0, "Axis Threshold",
"Preserves the existing geometry along the cut plane", 0.00001, 0.1);
WM_operator_properties_gesture_straightline(ot, CURSOR_EDIT); WM_operator_properties_gesture_straightline(ot, CURSOR_EDIT);

View File

@@ -4354,11 +4354,13 @@ void MESH_OT_fill_grid(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */ /* properties */
prop = RNA_def_int(ot->srna, "span", 1, 1, 1000, "Span", "Number of sides (zero disables)", 1, 100); prop = RNA_def_int(ot->srna, "span", 1, 1, 1000, "Span", "Number of grid columns", 1, 100);
RNA_def_property_flag(prop, PROP_SKIP_SAVE); RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_int(ot->srna, "offset", 0, -1000, 1000, "Offset", "Number of sides (zero disables)", -100, 100); prop = RNA_def_int(ot->srna, "offset", 0, -1000, 1000, "Offset",
"Vertex that is the corner of the grid", -100, 100);
RNA_def_property_flag(prop, PROP_SKIP_SAVE); RNA_def_property_flag(prop, PROP_SKIP_SAVE);
RNA_def_boolean(ot->srna, "use_interp_simple", false, "Simple Blending", ""); RNA_def_boolean(ot->srna, "use_interp_simple", false, "Simple Blending",
"Use simple interpolation of grid vertices");
} }
/** \} */ /** \} */
@@ -6610,7 +6612,8 @@ void MESH_OT_symmetrize(struct wmOperatorType *ot)
ot->srna, "direction", rna_enum_symmetrize_direction_items, ot->srna, "direction", rna_enum_symmetrize_direction_items,
BMO_SYMMETRIZE_NEGATIVE_X, BMO_SYMMETRIZE_NEGATIVE_X,
"Direction", "Which sides to copy from and to"); "Direction", "Which sides to copy from and to");
RNA_def_float(ot->srna, "threshold", 1e-4f, 0.0f, 10.0f, "Threshold", "", 1e-5f, 0.1f); RNA_def_float(ot->srna, "threshold", 1e-4f, 0.0f, 10.0f, "Threshold",
"Limit for snap middle vertices to the axis center", 1e-5f, 0.1f);
} }
/** \} */ /** \} */
@@ -6741,9 +6744,11 @@ void MESH_OT_symmetry_snap(struct wmOperatorType *ot)
ot->srna, "direction", rna_enum_symmetrize_direction_items, ot->srna, "direction", rna_enum_symmetrize_direction_items,
BMO_SYMMETRIZE_NEGATIVE_X, BMO_SYMMETRIZE_NEGATIVE_X,
"Direction", "Which sides to copy from and to"); "Direction", "Which sides to copy from and to");
RNA_def_float_distance(ot->srna, "threshold", 0.05f, 0.0f, 10.0f, "Threshold", "", 1e-4f, 1.0f); RNA_def_float_distance(ot->srna, "threshold", 0.05f, 0.0f, 10.0f, "Threshold",
RNA_def_float(ot->srna, "factor", 0.5f, 0.0f, 1.0f, "Factor", "", 0.0f, 1.0f); "Distance within which matching vertices are searched", 1e-4f, 1.0f);
RNA_def_boolean(ot->srna, "use_center", true, "Center", "Snap mid verts to the axis center"); RNA_def_float(ot->srna, "factor", 0.5f, 0.0f, 1.0f, "Factor",
"Mix factor of the locations of the vertices", 0.0f, 1.0f);
RNA_def_boolean(ot->srna, "use_center", true, "Center", "Snap middle vertices to the axis center");
} }
/** \} */ /** \} */

View File

@@ -358,9 +358,9 @@ void WM_operator_properties_checker_interval(wmOperatorType *ot, bool nth_can_di
{ {
const int nth_default = nth_can_disable ? 1 : 2; const int nth_default = nth_can_disable ? 1 : 2;
const int nth_min = min_ii(nth_default, 2); const int nth_min = min_ii(nth_default, 2);
RNA_def_int(ot->srna, "nth", nth_default, nth_min, INT_MAX, "Nth Selection", "", nth_min, 100); RNA_def_int(ot->srna, "nth", nth_default, nth_min, INT_MAX, "Nth Element", "Skip every Nth element", nth_min, 100);
RNA_def_int(ot->srna, "skip", 1, 1, INT_MAX, "Skip", "", 1, 100); RNA_def_int(ot->srna, "skip", 1, 1, INT_MAX, "Skip", "Number of elements to skip at once", 1, 100);
RNA_def_int(ot->srna, "offset", 0, INT_MIN, INT_MAX, "Offset", "", -100, 100); RNA_def_int(ot->srna, "offset", 0, INT_MIN, INT_MAX, "Offset", "Offset from the starting point", -100, 100);
} }
void WM_operator_properties_checker_interval_from_op( void WM_operator_properties_checker_interval_from_op(