Commit 3c5d5fb1 authored by Bastien Montagne's avatar Bastien Montagne
Browse files

Merge branch 'master' into fbx_io_export_ignore_parents

Conflicts:
	io_scene_fbx/import_fbx.py
parents 039f3646 6266b413
Pipeline #4746 failed with stages
in 15 seconds
......@@ -22,12 +22,13 @@ bl_info = {
"name": "Extra Objects",
"author": "Multiple Authors",
"version": (0, 1),
"blender": (2, 63, 0),
"blender": (2, 76, 0),
"location": "View3D > Add > Curve > Extra Objects",
"description": "Add extra curve object types",
"warning": "",
"wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
"Scripts/Curve/Curve_Objects",
"tracker_url": "https://developer.blender.org/maniphest/task/create/?project=3&type=Bug",
"category": "Add Curve"}
if "bpy" in locals():
......@@ -52,7 +53,7 @@ class INFO_MT_curve_extras_add(bpy.types.Menu):
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("mesh.curveaceous_galore",
text="Curves Galore!")
text="Curve Profiles")
layout.operator("curve.spirals",
text="Spirals")
layout.operator("curve.torus_knot_plus",
......@@ -60,7 +61,7 @@ class INFO_MT_curve_extras_add(bpy.types.Menu):
# Define "Extras" menu
def menu_func(self, context):
self.layout.operator("mesh.curveaceous_galore",
text="Curves Galore!")
text="Curve Profiles")
self.layout.operator("curve.torus_knot_plus",
text="Torus Knot Plus")
self.layout.operator("curve.spirals",
......
......@@ -34,9 +34,17 @@ bl_info = {
##------------------------------------------------------------
#### import modules
import bpy
from bpy.props import *
from mathutils import *
from math import *
from bpy.props import (
BoolProperty,
EnumProperty,
FloatProperty,
IntProperty,
)
from mathutils import (
Matrix,
Vector,
)
from math import sin, cos, pi
import mathutils.noise as Noise
###------------------------------------------------------------
#### Some functions to use with others:
......@@ -641,13 +649,13 @@ def vertsToPoints(Verts, splineType):
return vertArray
# create new CurveObject from vertarray and splineType
def createCurve(vertArray, self, align_matrix):
def createCurve(context, vertArray, self, align_matrix):
# options to vars
splineType = self.outputType # output splineType 'POLY' 'NURBS' 'BEZIER'
name = self.GalloreType # GalloreType as name
name = self.ProfileType # GalloreType as name
# create curve
scene = bpy.context.scene
scene = context.scene
newCurve = bpy.data.curves.new(name, type = 'CURVE') # curvedatablock
newSpline = newCurve.splines.new(type = splineType) # spline
......@@ -686,57 +694,55 @@ def main(context, self, align_matrix):
bpy.ops.object.select_all(action='DESELECT')
# options
galType = self.GalloreType
proType = self.ProfileType
splineType = self.outputType
innerRadius = self.innerRadius
middleRadius = self.middleRadius
outerRadius = self.outerRadius
# get verts
if galType == 'Profile':
if proType == 'Profile':
verts = ProfileCurve(self.ProfileCurveType,
self.ProfileCurvevar1,
self.ProfileCurvevar2)
if galType == 'Miscellaneous':
if proType == 'Miscellaneous':
verts = MiscCurve(self.MiscCurveType,
self.MiscCurvevar1,
self.MiscCurvevar2,
self.MiscCurvevar3)
if galType == 'Flower':
if proType == 'Flower':
verts = FlowerCurve(self.petals,
innerRadius,
outerRadius,
self.petalWidth)
if galType == 'Star':
if proType == 'Star':
verts = StarCurve(self.starPoints,
innerRadius,
outerRadius,
self.starTwist)
if galType == 'Arc':
if proType == 'Arc':
verts = ArcCurve(self.arcSides,
self.startAngle,
self.endAngle,
innerRadius,
outerRadius,
self.arcType)
if galType == 'Cogwheel':
if proType == 'Cogwheel':
verts = CogCurve(self.teeth,
innerRadius,
middleRadius,
outerRadius,
self.bevel)
if galType == 'Nsided':
if proType == 'Nsided':
verts = nSideCurve(self.Nsides,
outerRadius)
if galType == 'Splat':
if proType == 'Splat':
verts = SplatCurve(self.splatSides,
self.splatScale,
self.seed,
self.basis,
outerRadius)
if galType == 'Helix':
if proType == 'Helix':
verts = HelixCurve(self.helixPoints,
self.helixHeight,
self.helixStart,
......@@ -744,7 +750,7 @@ def main(context, self, align_matrix):
self.helixWidth,
self.helix_a,
self.helix_b)
if galType == 'Cycloid':
if proType == 'Cycloid':
verts = CycloidCurve(self.cycloPoints,
self.cyclo_d,
self.cycloType,
......@@ -757,21 +763,21 @@ def main(context, self, align_matrix):
vertArray = vertsToPoints(verts, splineType)
# create object
createCurve(vertArray, self, align_matrix)
createCurve(context, vertArray, self, align_matrix)
return
class Curveaceous_galore(bpy.types.Operator):
"""Add many types of curves"""
bl_idname = "mesh.curveaceous_galore"
bl_label = "Curveaceous galore"
bl_label = "Curve Profiles"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
# align_matrix for the invoke
align_matrix = Matrix()
align_matrix = None
#### general properties
GalloreTypes = [
ProfileTypes = [
('Profile', 'Profile', 'Profile'),
('Miscellaneous', 'Miscellaneous', 'Miscellaneous'),
('Flower', 'Flower', 'Flower'),
......@@ -782,9 +788,9 @@ class Curveaceous_galore(bpy.types.Operator):
('Splat', 'Splat', 'Splat'),
('Cycloid', 'Cycloid', 'Cycloid'),
('Helix', 'Helix (3D)', 'Helix')]
GalloreType = EnumProperty(name="Type",
ProfileType = EnumProperty(name="Type",
description="Form of Curve to create",
items=GalloreTypes)
items=ProfileTypes)
SplineTypes = [
('POLY', 'Poly', 'POLY'),
('NURBS', 'Nurbs', 'NURBS'),
......@@ -993,56 +999,62 @@ class Curveaceous_galore(bpy.types.Operator):
# general options
col = layout.column()
col.prop(self, 'GalloreType')
col.label(text=self.GalloreType + " Options:")
col.prop(self, 'ProfileType')
col.label(text=self.ProfileType + " Options:")
# options per GalloreType
# options per ProfileType
box = layout.box()
if self.GalloreType == 'Profile':
if self.ProfileType == 'Profile':
box.prop(self, 'ProfileCurveType')
box.prop(self, 'ProfileCurvevar1')
box.prop(self, 'ProfileCurvevar2')
elif self.GalloreType == 'Miscellaneous':
elif self.ProfileType == 'Miscellaneous':
box.prop(self, 'MiscCurveType')
box.prop(self, 'MiscCurvevar1', text='Width')
box.prop(self, 'MiscCurvevar2', text='Height')
if self.MiscCurveType == 5:
box.prop(self, 'MiscCurvevar3', text='Rounded')
elif self.GalloreType == 'Flower':
elif self.ProfileType == 'Flower':
box.prop(self, 'petals')
box.prop(self, 'petalWidth')
box.prop(self, 'innerRadius')
box.prop(self, 'outerRadius')
elif self.GalloreType == 'Star':
elif self.ProfileType == 'Star':
box.prop(self, 'starPoints')
box.prop(self, 'starTwist')
box.prop(self, 'innerRadius')
box.prop(self, 'outerRadius')
elif self.GalloreType == 'Arc':
elif self.ProfileType == 'Arc':
box.prop(self, 'arcSides')
box.prop(self, 'arcType') # has only one Type?
box.prop(self, 'startAngle')
box.prop(self, 'endAngle')
box.prop(self, 'innerRadius') # doesn't seem to do anything
box.prop(self, 'outerRadius')
elif self.GalloreType == 'Cogwheel':
elif self.ProfileType == 'Cogwheel':
box.prop(self, 'teeth')
box.prop(self, 'bevel')
box.prop(self, 'innerRadius')
box.prop(self, 'middleRadius')
box.prop(self, 'outerRadius')
elif self.GalloreType == 'Nsided':
elif self.ProfileType == 'Nsided':
box.prop(self, 'Nsides')
box.prop(self, 'outerRadius', text='Radius')
elif self.GalloreType == 'Splat':
elif self.ProfileType == 'Splat':
box.prop(self, 'splatSides')
box.prop(self, 'outerRadius')
box.prop(self, 'splatScale')
box.prop(self, 'seed')
box.prop(self, 'basis')
elif self.GalloreType == 'Helix':
elif self.ProfileType == 'Helix':
box.prop(self, 'helixPoints')
box.prop(self, 'helixHeight')
box.prop(self, 'helixWidth')
......@@ -1050,7 +1062,8 @@ class Curveaceous_galore(bpy.types.Operator):
box.prop(self, 'helixEnd')
box.prop(self, 'helix_a')
box.prop(self, 'helix_b')
elif self.GalloreType == 'Cycloid':
elif self.ProfileType == 'Cycloid':
box.prop(self, 'cycloPoints')
#box.prop(self, 'cycloType') # needs the other types first
box.prop(self, 'cycloStart')
......@@ -1081,7 +1094,6 @@ class Curveaceous_galore(bpy.types.Operator):
box.row().prop(self, 'handleType', expand=True)
#box.prop(self, 'use_cyclic_u')
##### POLL #####
@classmethod
def poll(cls, context):
......@@ -1090,26 +1102,25 @@ class Curveaceous_galore(bpy.types.Operator):
##### EXECUTE #####
def execute(self, context):
# turn off undo
undo = bpy.context.user_preferences.edit.use_global_undo
bpy.context.user_preferences.edit.use_global_undo = False
undo = context.user_preferences.edit.use_global_undo
context.user_preferences.edit.use_global_undo = False
# deal with 2D - 3D curve differences
if self.GalloreType in ['Helix', 'Cycloid']:
if self.ProfileType in ['Helix', 'Cycloid']:
self.shape = '3D'
#else:
#self.shape = '2D' # someone decide if we want this
if self.GalloreType in ['Helix']:
if self.ProfileType in ['Helix']:
self.use_cyclic_u = False
else:
self.use_cyclic_u = True
# main function
main(context, self, self.align_matrix)
main(context, self, self.align_matrix or Matrix())
# restore pre operator undo state
bpy.context.user_preferences.edit.use_global_undo = undo
context.user_preferences.edit.use_global_undo = undo
return {'FINISHED'}
......
......@@ -14,7 +14,11 @@
}
'''
import bpy, time
from bpy.props import *
from bpy.props import (
BoolProperty,
FloatProperty,
IntProperty,
)
from math import sin, cos, pi, exp
from bpy_extras.object_utils import AddObjectHelper, object_data_add
......@@ -170,8 +174,7 @@ def draw_curve(props, context):
spline.points.add( len(verts)*0.25-1 ) #Add only one quarter of points as elements in verts, because verts looks like: "x,y,z,?,x,y,z,?,x,..."
spline.points.foreach_set('co', verts)
# new_obj = object_data_add(bpy.context, curve_data)
new_obj = object_data_add(context, curve_data)
new_obj = object_data_add(context, curve_data)
class spirals(bpy.types.Operator):
bl_idname = "curve.spirals"
......
......@@ -402,16 +402,16 @@ def adhesion(loc, ob, max_l):
# Compute the adhesion vector by finding the nearest point
nearest_result = ob.closest_point_on_mesh(tran_loc, max_l)
adhesion_vector = Vector((0.0, 0.0, 0.0))
if nearest_result[2] != -1:
if nearest_result[0]:
# Compute the distance to the nearest point
adhesion_vector = ob.matrix_world * nearest_result[0] - loc
adhesion_vector = ob.matrix_world * nearest_result[1] - loc
distance = adhesion_vector.length
# If it's less than the maximum allowed and not 0, continue
if distance:
# Compute the direction vector between the closest point and loc
adhesion_vector.normalize()
adhesion_vector *= 1.0 - distance / max_l
#adhesion_vector *= getFaceWeight(ob.data, nearest_result[2])
#adhesion_vector *= getFaceWeight(ob.data, nearest_result[3])
return adhesion_vector
......@@ -423,15 +423,16 @@ def collision(ob, pos, new_pos):
tran_mat = ob.matrix_world.inverted()
tran_pos = tran_mat * pos
tran_new_pos = tran_mat * new_pos
tran_dir = tran_new_pos - tran_pos
ray_result = ob.ray_cast(tran_pos, tran_new_pos)
ray_result = ob.ray_cast(tran_pos, tran_dir, tran_dir.length)
# If there's a collision we need to check it
if ray_result[2] != -1:
if ray_result[0]:
# Check whether the collision is going into the object
if (tran_new_pos - tran_pos).dot(ray_result[1]) < 0.0:
if tran_dir.dot(ray_result[2]) < 0.0:
# Find projection of the piont onto the plane
p0 = tran_new_pos - (tran_new_pos -
ray_result[0]).project(ray_result[1])
ray_result[1]).project(ray_result[2])
# Reflect in the plane
tran_new_pos += 2 * (p0 - tran_new_pos)
new_pos *= 0
......
......@@ -396,6 +396,10 @@ class AddTree(bpy.types.Operator):
def poll(cls, context):
return context.mode == 'OBJECT'
def check(self, context):
# TODO, should check exact vars which require redraw
return True
def draw(self, context):
layout = self.layout
......
......@@ -278,21 +278,12 @@ def xyz_function_surface_faces(self, x_eq, y_eq, z_eq,
# Try to evaluate the equations.
try:
a = float(eval(*expr_args_a))
b = float(eval(*expr_args_b))
c = float(eval(*expr_args_c))
safe_dict['a'] = a
safe_dict['b'] = b
safe_dict['c'] = c
f = float(eval(*expr_args_f))
g = float(eval(*expr_args_g))
h = float(eval(*expr_args_h))
safe_dict['f'] = f
safe_dict['g'] = g
safe_dict['h'] = h
safe_dict['a'] = float(eval(*expr_args_a))
safe_dict['b'] = float(eval(*expr_args_b))
safe_dict['c'] = float(eval(*expr_args_c))
safe_dict['f'] = float(eval(*expr_args_f))
safe_dict['g'] = float(eval(*expr_args_g))
safe_dict['h'] = float(eval(*expr_args_h))
verts.append((
float(eval(*expr_args_x)),
......
......@@ -192,7 +192,12 @@ class add_mesh_honeycomb(bpy.types.Operator):
name = 'Num of cols', default = 2,
min = 1, max = 100,
description='Number of the columns')
layers = BoolVectorProperty(
name="Layers",
size=20,
subtype='LAYER',
options={'HIDDEN', 'SKIP_SAVE'},
)
def fix_edge(self, context):
m = edge_max(self.diam)
if self.edge > m: self.edge = m
......
......@@ -4,7 +4,7 @@
import bpy
from bpy.props import IntProperty, BoolProperty, FloatVectorProperty, FloatProperty
from bpy.props import IntProperty, BoolProperty, BoolVectorProperty, FloatVectorProperty, FloatProperty
import bpy
import mathutils
......@@ -166,7 +166,12 @@ class AddMengerSponge(bpy.types.Operator):
name="Rotation",
subtype='EULER',
)
layers = BoolVectorProperty(
name="Layers",
size=20,
subtype='LAYER',
options={'HIDDEN', 'SKIP_SAVE'},
)
def execute(self, context):
sponger = MengerSponge(self.level)
vertices, faces = sponger.create(self.radius * 2, self.radius * 2)
......
......@@ -320,7 +320,7 @@ class AddRoundCube(bpy.types.Operator, object_utils.AddObjectHelper):
"""Add Round Cube Primitive"""
bl_idname = 'mesh.primitive_round_cube_add'
bl_label = 'Add Round Cube'
bl_description = 'Add mesh primitives: Quadspheres, Capsules, Rounded Cuboids, 3D Grids, etc.'
bl_description = 'Add mesh primitives: Quadspheres, Capsules, Rounded Cuboids, 3D Grids, etc'
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
sanity_check_verts = 200000
......
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ***** END GPL LICENCE BLOCK *****
bl_info = {
"name": "Bone Selection Groups",
"author": "Antony Riakiotakis",
"version": (1, 0, 2),
"blender": (2, 75, 0),
"location": "Properties > Object Buttons",
"description": "Operator and storage for restoration of bone selection state.",
"category": "Animation",
}
import bpy
from bpy.types import (
Operator,
Panel,
UIList,
)
from bpy.props import (
StringProperty,
BoolProperty,
IntProperty,
FloatProperty,
EnumProperty,
CollectionProperty,
BoolVectorProperty,
FloatVectorProperty,
)
class POSE_PT_selection_sets(Panel):
bl_label = "Selection Sets"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "data"
@classmethod
def poll(cls, context):
return context.object.type == 'ARMATURE'
def draw(self, context):
layout = self.layout
armature = context.object
# Rig type list
row = layout.row()
row.template_list(
"POSE_UL_selection_set", "",
armature, "selection_sets",
armature, "active_selection_set")
col = row.column()
colsub = col.column(align=True)
colsub.operator("pose.selection_set_add", icon='ZOOMIN', text="")
colsub.operator("pose.selection_set_remove", icon='ZOOMOUT', text="")
layout.operator("pose.selection_set_toggle")
class POSE_UL_selection_set(UIList):
def draw_item(self, context, layout, data, set, icon, active_data, active_propname, index):
layout.prop(set, "name", text="", emboss=False)
class SelectionEntry(bpy.types.PropertyGroup):
name = StringProperty(name="Bone Name")
class SelectionSet(bpy.types.PropertyGroup):
name = StringProperty(name="Set Name")
bone_ids = CollectionProperty(type=SelectionEntry)
class PluginOperator(Operator):
@classmethod
def poll(self, context):
return (context.object and
context.object.type == 'ARMATURE' and
context.mode == 'POSE')
class POSE_OT_selection_set_add(PluginOperator):
bl_idname = "pose.selection_set_add"
bl_label = "Add Selection Set"
bl_options = {'UNDO', 'REGISTER'}
def execute(self, context):
keep = False
armature = context.object
pose = armature.pose
selection_set = armature.selection_sets.add()
selection_set.name = "SelectionSet.%d" % len(armature.selection_sets)
armature.active_selection_set = len(armature.selection_sets) - 1
for bone in pose.bones:
if (bone.bone.select):
bone_id = selection_set.bone_ids.add()
bone_id.name = bone.name
keep = True
if (not keep):
armature.selection_sets.remove(armature.active_selection_set)
numsets = len(armature.selection_sets)
if (armature.active_selection_set > (numsets - 1) and numsets > 0):
armature.active_selection_set = len(armature.selection_sets) - 1
return {'CANCELLED'}
return {'FINISHED'}
class POSE_OT_selection_set_remove(PluginOperator):
bl_idname = "pose.selection_set_remove"
bl_label = "Delete Selection Set"