pep8 cleanup

This commit is contained in:
Campbell Barton
2011-02-04 09:27:25 +00:00
parent f0eb3b56de
commit 736a7b7a22
21 changed files with 328 additions and 234 deletions

View File

@@ -21,6 +21,8 @@
# #
# ***** END GPL LICENSE BLOCK ***** # ***** END GPL LICENSE BLOCK *****
# <pep8 compliant>
IGNORE = \ IGNORE = \
"/test/",\ "/test/",\
"/decimate_glut_test/",\ "/decimate_glut_test/",\
@@ -45,6 +47,8 @@ global_c = set()
import os import os
from os.path import splitext from os.path import splitext
def source_list(path, filename_check=None): def source_list(path, filename_check=None):
for dirpath, dirnames, filenames in os.walk(path): for dirpath, dirnames, filenames in os.walk(path):
@@ -56,31 +60,37 @@ def source_list(path, filename_check=None):
if filename_check is None or filename_check(filename): if filename_check is None or filename_check(filename):
yield os.path.join(dirpath, filename) yield os.path.join(dirpath, filename)
# extension checking # extension checking
def is_c_header(filename): def is_c_header(filename):
ext = splitext(filename)[1] ext = splitext(filename)[1]
return (ext in (".h", ".hpp", ".hxx")) return (ext in (".h", ".hpp", ".hxx"))
def is_cmake(filename): def is_cmake(filename):
ext = splitext(filename)[1] ext = splitext(filename)[1]
return (ext == ".cmake") or (filename == "CMakeLists.txt") return (ext == ".cmake") or (filename == "CMakeLists.txt")
def is_c_header(filename): def is_c_header(filename):
ext = splitext(filename)[1] ext = splitext(filename)[1]
return (ext in (".h", ".hpp", ".hxx")) return (ext in (".h", ".hpp", ".hxx"))
def is_c(filename): def is_c(filename):
ext = splitext(filename)[1] ext = splitext(filename)[1]
return (ext in (".c", ".cpp", ".cxx", ".m", ".mm", ".rc")) return (ext in (".c", ".cpp", ".cxx", ".m", ".mm", ".rc"))
def is_c_any(filename): def is_c_any(filename):
return is_c(filename) or is_c_header(filename) return is_c(filename) or is_c_header(filename)
def cmake_get_src(f): def cmake_get_src(f):
sources_h = [] sources_h = []
sources_c = [] sources_c = []
filen = open(f, "r", encoding="utf8") filen = open(f, "r", encoding="utf8")
it = iter(filen) it = iter(filen)
found = False found = False
@@ -101,7 +111,7 @@ def cmake_get_src(f):
raise Exception("strict formatting not kept 'set(SRC*' %s:%d" % (f, i)) raise Exception("strict formatting not kept 'set(SRC*' %s:%d" % (f, i))
found = True found = True
break break
if "list(APPEND SRC" in l: if "list(APPEND SRC" in l:
if l.endswith(")"): if l.endswith(")"):
raise Exception("strict formatting not kept 'list(APPEND SRC...)' on 1 line %s:%d" % (f, i)) raise Exception("strict formatting not kept 'list(APPEND SRC...)' on 1 line %s:%d" % (f, i))
@@ -118,11 +128,11 @@ def cmake_get_src(f):
except StopIteration: except StopIteration:
it = None it = None
break break
l = l.strip() l = l.strip()
if not l.startswith("#"): if not l.startswith("#"):
if ")" in l: if ")" in l:
if l.strip() != ")": if l.strip() != ")":
raise Exception("strict formatting not kept '*)' %s:%d" % (f, i)) raise Exception("strict formatting not kept '*)' %s:%d" % (f, i))
@@ -130,7 +140,6 @@ def cmake_get_src(f):
# replace dirs # replace dirs
l = l.replace("${CMAKE_CURRENT_SOURCE_DIR}", cmake_base) l = l.replace("${CMAKE_CURRENT_SOURCE_DIR}", cmake_base)
if not l: if not l:
pass pass
@@ -140,7 +149,7 @@ def cmake_get_src(f):
raise Exception("Multi-line define '%s' %s:%d" % (l, f, i)) raise Exception("Multi-line define '%s' %s:%d" % (l, f, i))
else: else:
new_file = normpath(join(cmake_base, l)) new_file = normpath(join(cmake_base, l))
if is_c_header(new_file): if is_c_header(new_file):
sources_h.append(new_file) sources_h.append(new_file)
elif is_c(new_file): elif is_c(new_file):
@@ -168,19 +177,20 @@ def cmake_get_src(f):
if ff not in sources_c: if ff not in sources_c:
print(" missing: " + ff) print(" missing: " + ff)
''' '''
filen.close() filen.close()
for cmake in source_list(base, is_cmake): for cmake in source_list(base, is_cmake):
cmake_get_src(cmake) cmake_get_src(cmake)
def is_ignore(f): def is_ignore(f):
for ig in IGNORE: for ig in IGNORE:
if ig in f: if ig in f:
return True return True
return False return False
# First do stupid check, do these files exist? # First do stupid check, do these files exist?
for f in (global_h | global_c): for f in (global_h | global_c):
if f.endswith("dna.c"): if f.endswith("dna.c"):
@@ -189,7 +199,7 @@ for f in (global_h | global_c):
if not os.path.exists(f): if not os.path.exists(f):
raise Exception("CMake referenced file missing: " + f) raise Exception("CMake referenced file missing: " + f)
# now check on files not accounted for. # now check on files not accounted for.
print("\nC/C++ Files CMake doesnt know about...") print("\nC/C++ Files CMake doesnt know about...")
for cf in sorted(source_list(base, is_c)): for cf in sorted(source_list(base, is_c)):

View File

@@ -21,6 +21,8 @@
# #
# ***** END GPL LICENSE BLOCK ***** # ***** END GPL LICENSE BLOCK *****
# <pep8 compliant>
import os import os
from os.path import join, dirname, normpath, abspath, splitext, relpath, exists from os.path import join, dirname, normpath, abspath, splitext, relpath, exists
@@ -28,6 +30,7 @@ base = join(os.path.dirname(__file__), "..", "..")
base = normpath(base) base = normpath(base)
base = abspath(base) base = abspath(base)
def source_list(path, filename_check=None): def source_list(path, filename_check=None):
for dirpath, dirnames, filenames in os.walk(path): for dirpath, dirnames, filenames in os.walk(path):
@@ -40,33 +43,40 @@ def source_list(path, filename_check=None):
if filename_check is None or filename_check(filepath): if filename_check is None or filename_check(filepath):
yield filepath yield filepath
# extension checking # extension checking
def is_c_header(filename): def is_c_header(filename):
ext = splitext(filename)[1] ext = splitext(filename)[1]
return (ext in (".h", ".hpp", ".hxx")) return (ext in (".h", ".hpp", ".hxx"))
def is_cmake(filename): def is_cmake(filename):
ext = splitext(filename)[1] ext = splitext(filename)[1]
return (ext == ".cmake") or (filename == "CMakeLists.txt") return (ext == ".cmake") or (filename == "CMakeLists.txt")
def is_c_header(filename): def is_c_header(filename):
ext = splitext(filename)[1] ext = splitext(filename)[1]
return (ext in (".h", ".hpp", ".hxx")) return (ext in (".h", ".hpp", ".hxx"))
def is_c(filename): def is_c(filename):
ext = splitext(filename)[1] ext = splitext(filename)[1]
return (ext in (".c", ".cpp", ".cxx", ".m", ".mm", ".rc")) return (ext in (".c", ".cpp", ".cxx", ".m", ".mm", ".rc"))
def is_c_any(filename): def is_c_any(filename):
return is_c(filename) or is_c_header(filename) return is_c(filename) or is_c_header(filename)
def is_svn_file(filename): def is_svn_file(filename):
dn, fn = os.path.split(filename) dn, fn = os.path.split(filename)
filename_svn = join(dn, ".svn", "text-base", "%s.svn-base" % fn) filename_svn = join(dn, ".svn", "text-base", "%s.svn-base" % fn)
return exists(filename_svn) return exists(filename_svn)
def is_project_file(filename): def is_project_file(filename):
return (is_c_any(filename) or is_cmake(filename)) and is_svn_file(filename) return (is_c_any(filename) or is_cmake(filename)) and is_svn_file(filename)
files = list(source_list(base, filename_check=is_project_file)) files = list(source_list(base, filename_check=is_project_file))
files_rel = [relpath(f, start=base) for f in files] files_rel = [relpath(f, start=base) for f in files]
@@ -87,8 +97,8 @@ f.write("[General]\n")
qtc_cfg = join(base, "%s.config" % PROJECT_NAME) qtc_cfg = join(base, "%s.config" % PROJECT_NAME)
if not exists(qtc_cfg): if not exists(qtc_cfg):
f = open(qtc_cfg, 'w') f = open(qtc_cfg, 'w')
f.write("// ADD PREDEFINED MACROS HERE!\n") f.write("// ADD PREDEFINED MACROS HERE!\n")
print("Project file written to: %s" % qtc_prj) print("Project file written to: %s" % qtc_prj)
# --- end # --- end

View File

@@ -18,6 +18,8 @@
# #
# #**** END GPL LICENSE BLOCK #**** # #**** END GPL LICENSE BLOCK #****
# <pep8 compliant>
script_help_msg = ''' script_help_msg = '''
Usage: Usage:
@@ -31,11 +33,11 @@ For HTML generation
assuming that ./blender.bin is or links to the blender executable assuming that ./blender.bin is or links to the blender executable
- Generate html docs by running... - Generate html docs by running...
sphinx-build doc/python_api/sphinx-in doc/python_api/sphinx-out sphinx-build doc/python_api/sphinx-in doc/python_api/sphinx-out
assuming that you have sphinx 0.6.7 installed assuming that you have sphinx 0.6.7 installed
For PDF generation For PDF generation
------------------ ------------------
- After you have built doc/python_api/sphinx-in (see above), run: - After you have built doc/python_api/sphinx-in (see above), run:
@@ -81,10 +83,12 @@ def range_str(val):
Converts values to strings for the range directive. Converts values to strings for the range directive.
(unused function it seems) (unused function it seems)
''' '''
if val < -10000000: return '-inf' if val < -10000000:
if val > 10000000: return 'inf' return '-inf'
if type(val)==float: elif val > 10000000:
return '%g' % val return 'inf'
elif type(val) == float:
return '%g' % val
else: else:
return str(val) return str(val)
@@ -139,7 +143,7 @@ def pyfunc2sphinx(ident, fw, identifier, py_func, is_class=True):
if not is_class: if not is_class:
func_type = "function" func_type = "function"
# ther rest are class methods # ther rest are class methods
elif arg_str.startswith("(self, "): elif arg_str.startswith("(self, "):
arg_str = "(" + arg_str[7:] arg_str = "(" + arg_str[7:]
@@ -156,14 +160,14 @@ def pyfunc2sphinx(ident, fw, identifier, py_func, is_class=True):
fw("\n") fw("\n")
def py_descr2sphinx(ident, fw, descr, module_name, type_name, identifier): def py_descr2sphinx(ident, fw, descr, module_name, type_name, identifier):
if identifier.startswith("_"): if identifier.startswith("_"):
return return
doc = descr.__doc__ doc = descr.__doc__
if not doc: if not doc:
doc = undocumented_message(module_name, type_name, identifier) doc = undocumented_message(module_name, type_name, identifier)
if type(descr) == GetSetDescriptorType: if type(descr) == GetSetDescriptorType:
fw(ident + ".. attribute:: %s\n\n" % identifier) fw(ident + ".. attribute:: %s\n\n" % identifier)
write_indented_lines(ident + " ", fw, doc, False) write_indented_lines(ident + " ", fw, doc, False)
@@ -180,7 +184,7 @@ def py_c_func2sphinx(ident, fw, module_name, type_name, identifier, py_func, is_
''' '''
c defined function to sphinx. c defined function to sphinx.
''' '''
# dump the docstring, assume its formatted correctly # dump the docstring, assume its formatted correctly
if py_func.__doc__: if py_func.__doc__:
write_indented_lines(ident, fw, py_func.__doc__, False) write_indented_lines(ident, fw, py_func.__doc__, False)
@@ -208,30 +212,30 @@ def pymodule2sphinx(BASEPATH, module_name, module, title):
import types import types
attribute_set = set() attribute_set = set()
filepath = os.path.join(BASEPATH, module_name + ".rst") filepath = os.path.join(BASEPATH, module_name + ".rst")
file = open(filepath, "w") file = open(filepath, "w")
fw = file.write fw = file.write
fw(title + "\n") fw(title + "\n")
fw(("=" * len(title)) + "\n\n") fw(("=" * len(title)) + "\n\n")
fw(".. module:: %s\n\n" % module_name) fw(".. module:: %s\n\n" % module_name)
if module.__doc__: if module.__doc__:
# Note, may contain sphinx syntax, dont mangle! # Note, may contain sphinx syntax, dont mangle!
fw(module.__doc__.strip()) fw(module.__doc__.strip())
fw("\n\n") fw("\n\n")
write_example_ref("", fw, module_name) write_example_ref("", fw, module_name)
# write members of the module # write members of the module
# only tested with PyStructs which are not exactly modules # only tested with PyStructs which are not exactly modules
for key, descr in sorted(type(module).__dict__.items()): for key, descr in sorted(type(module).__dict__.items()):
if key.startswith("__"): if key.startswith("__"):
continue continue
# naughty, we also add getset's into PyStructs, this is not typical py but also not incorrect. # naughty, we also add getset's into PyStructs, this is not typical py but also not incorrect.
if type(descr) == types.GetSetDescriptorType: # 'bpy_app_type' name is only used for examples and messages if type(descr) == types.GetSetDescriptorType: # 'bpy_app_type' name is only used for examples and messages
py_descr2sphinx("", fw, descr, module_name, "bpy_app_type", key) py_descr2sphinx("", fw, descr, module_name, "bpy_app_type", key)
attribute_set.add(key) attribute_set.add(key)
for key, descr in sorted(type(module).__dict__.items()): for key, descr in sorted(type(module).__dict__.items()):
@@ -245,7 +249,7 @@ def pymodule2sphinx(BASEPATH, module_name, module, title):
attribute_set.add(key) attribute_set.add(key)
fw("\n") fw("\n")
del key, descr del key, descr
classes = [] classes = []
for attribute in sorted(dir(module)): for attribute in sorted(dir(module)):
@@ -254,16 +258,16 @@ def pymodule2sphinx(BASEPATH, module_name, module, title):
if attribute in attribute_set: if attribute in attribute_set:
continue continue
if attribute.startswith("n_"): # annoying exception, needed for bpy.app if attribute.startswith("n_"): # annoying exception, needed for bpy.app
continue continue
value = getattr(module, attribute) value = getattr(module, attribute)
value_type = type(value) value_type = type(value)
if value_type == types.FunctionType: if value_type == types.FunctionType:
pyfunc2sphinx("", fw, attribute, value, is_class=False) pyfunc2sphinx("", fw, attribute, value, is_class=False)
elif value_type in (types.BuiltinMethodType, types.BuiltinFunctionType): # both the same at the moment but to be future proof elif value_type in (types.BuiltinMethodType, types.BuiltinFunctionType): # both the same at the moment but to be future proof
# note: can't get args from these, so dump the string as is # note: can't get args from these, so dump the string as is
# this means any module used like this must have fully formatted docstrings. # this means any module used like this must have fully formatted docstrings.
py_c_func2sphinx("", fw, module_name, module, attribute, value, is_class=False) py_c_func2sphinx("", fw, module_name, module, attribute, value, is_class=False)
@@ -310,7 +314,6 @@ def pymodule2sphinx(BASEPATH, module_name, module, title):
file.close() file.close()
def rna2sphinx(BASEPATH): def rna2sphinx(BASEPATH):
structs, funcs, ops, props = rna_info.BuildRNAInfo() structs, funcs, ops, props = rna_info.BuildRNAInfo()
@@ -325,14 +328,13 @@ def rna2sphinx(BASEPATH):
file = open(filepath, "w") file = open(filepath, "w")
fw = file.write fw = file.write
version_string = bpy.app.version_string.split("(")[0] version_string = bpy.app.version_string.split("(")[0]
if bpy.app.build_revision != "Unknown": if bpy.app.build_revision != "Unknown":
version_string = version_string + " r" + bpy.app.build_revision version_string = version_string + " r" + bpy.app.build_revision
# for use with files # for use with files
version_string_fp = "_".join(str(v) for v in bpy.app.version) version_string_fp = "_".join(str(v) for v in bpy.app.version)
fw("project = 'Blender'\n") fw("project = 'Blender'\n")
# fw("master_doc = 'index'\n") # fw("master_doc = 'index'\n")
fw("copyright = u'Blender Foundation'\n") fw("copyright = u'Blender Foundation'\n")
@@ -349,11 +351,11 @@ def rna2sphinx(BASEPATH):
fw("latex_paper_size = 'a4paper'\n") fw("latex_paper_size = 'a4paper'\n")
file.close() file.close()
# main page needed for sphinx (index.html)
filepath = os.path.join(BASEPATH, "contents.rst") filepath = os.path.join(BASEPATH, "contents.rst")
file = open(filepath, "w") file = open(filepath, "w")
fw = file.write fw = file.write
fw("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n") fw("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n")
fw(" Blender Documentation contents\n") fw(" Blender Documentation contents\n")
fw("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n") fw("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n")
@@ -388,15 +390,15 @@ def rna2sphinx(BASEPATH):
fw("\n") fw("\n")
fw(".. toctree::\n") fw(".. toctree::\n")
fw(" :maxdepth: 1\n\n") fw(" :maxdepth: 1\n\n")
fw(" bpy.data.rst\n\n") # note: not actually a module fw(" bpy.data.rst\n\n") # note: not actually a module
fw(" bpy.ops.rst\n\n") fw(" bpy.ops.rst\n\n")
fw(" bpy.types.rst\n\n") fw(" bpy.types.rst\n\n")
# py modules # py modules
fw(" bpy.utils.rst\n\n") fw(" bpy.utils.rst\n\n")
fw(" bpy.path.rst\n\n") fw(" bpy.path.rst\n\n")
fw(" bpy.app.rst\n\n") fw(" bpy.app.rst\n\n")
# C modules # C modules
fw(" bpy.props.rst\n\n") fw(" bpy.props.rst\n\n")
@@ -407,14 +409,13 @@ def rna2sphinx(BASEPATH):
fw(".. toctree::\n") fw(".. toctree::\n")
fw(" :maxdepth: 1\n\n") fw(" :maxdepth: 1\n\n")
fw(" mathutils.rst\n\n") fw(" mathutils.rst\n\n")
fw(" mathutils.geometry.rst\n\n") fw(" mathutils.geometry.rst\n\n")
# XXX TODO # XXX TODO
#fw(" bgl.rst\n\n") #fw(" bgl.rst\n\n")
fw(" blf.rst\n\n") fw(" blf.rst\n\n")
fw(" aud.rst\n\n") fw(" aud.rst\n\n")
# game engine # game engine
fw("===================\n") fw("===================\n")
fw("Game Engine Modules\n") fw("Game Engine Modules\n")
@@ -429,7 +430,6 @@ def rna2sphinx(BASEPATH):
file.close() file.close()
# internal modules # internal modules
filepath = os.path.join(BASEPATH, "bpy.ops.rst") filepath = os.path.join(BASEPATH, "bpy.ops.rst")
file = open(filepath, "w") file = open(filepath, "w")
@@ -451,7 +451,6 @@ def rna2sphinx(BASEPATH):
fw(" bpy.types.*\n\n") fw(" bpy.types.*\n\n")
file.close() file.close()
# not actually a module, only write this file so we # not actually a module, only write this file so we
# can reference in the TOC # can reference in the TOC
filepath = os.path.join(BASEPATH, "bpy.data.rst") filepath = os.path.join(BASEPATH, "bpy.data.rst")
@@ -474,7 +473,6 @@ def rna2sphinx(BASEPATH):
EXAMPLE_SET_USED.add("bpy.data") EXAMPLE_SET_USED.add("bpy.data")
# python modules # python modules
from bpy import utils as module from bpy import utils as module
pymodule2sphinx(BASEPATH, "bpy.utils", module, "Utilities (bpy.utils)") pymodule2sphinx(BASEPATH, "bpy.utils", module, "Utilities (bpy.utils)")
@@ -488,11 +486,11 @@ def rna2sphinx(BASEPATH):
from bpy import props as module from bpy import props as module
pymodule2sphinx(BASEPATH, "bpy.props", module, "Property Definitions (bpy.props)") pymodule2sphinx(BASEPATH, "bpy.props", module, "Property Definitions (bpy.props)")
import mathutils as module import mathutils as module
pymodule2sphinx(BASEPATH, "mathutils", module, "Math Types & Utilities (mathutils)") pymodule2sphinx(BASEPATH, "mathutils", module, "Math Types & Utilities (mathutils)")
del module del module
import mathutils.geometry as module import mathutils.geometry as module
pymodule2sphinx(BASEPATH, "mathutils.geometry", module, "Geometry Utilities (mathutils.geometry)") pymodule2sphinx(BASEPATH, "mathutils.geometry", module, "Geometry Utilities (mathutils.geometry)")
del module del module
@@ -500,7 +498,7 @@ def rna2sphinx(BASEPATH):
import blf as module import blf as module
pymodule2sphinx(BASEPATH, "blf", module, "Font Drawing (blf)") pymodule2sphinx(BASEPATH, "blf", module, "Font Drawing (blf)")
del module del module
# XXX TODO # XXX TODO
#import bgl as module #import bgl as module
#pymodule2sphinx(BASEPATH, "bgl", module, "Blender OpenGl wrapper (bgl)") #pymodule2sphinx(BASEPATH, "bgl", module, "Blender OpenGl wrapper (bgl)")
@@ -513,17 +511,16 @@ def rna2sphinx(BASEPATH):
## game engine ## game engine
import shutil import shutil
# copy2 keeps time/date stamps # copy2 keeps time/date stamps
shutil.copy2(os.path.join(BASEPATH,"..","rst","bge.types.rst"), BASEPATH) shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bge.types.rst"), BASEPATH)
shutil.copy2(os.path.join(BASEPATH,"..","rst","bge.logic.rst"), BASEPATH) shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bge.logic.rst"), BASEPATH)
shutil.copy2(os.path.join(BASEPATH,"..","rst","bge.render.rst"), BASEPATH) shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bge.render.rst"), BASEPATH)
shutil.copy2(os.path.join(BASEPATH,"..","rst","bge.events.rst"), BASEPATH) shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bge.events.rst"), BASEPATH)
if 0: if 0:
filepath = os.path.join(BASEPATH, "bpy.rst") filepath = os.path.join(BASEPATH, "bpy.rst")
file = open(filepath, "w") file = open(filepath, "w")
fw = file.write fw = file.write
fw("\n") fw("\n")
title = ":mod:`bpy` --- Blender Python Module" title = ":mod:`bpy` --- Blender Python Module"
@@ -558,7 +555,7 @@ def rna2sphinx(BASEPATH):
filepath = os.path.join(BASEPATH, "bpy.types.%s.rst" % struct.identifier) filepath = os.path.join(BASEPATH, "bpy.types.%s.rst" % struct.identifier)
file = open(filepath, "w") file = open(filepath, "w")
fw = file.write fw = file.write
base_id = getattr(struct.base, "identifier", "") base_id = getattr(struct.base, "identifier", "")
if _BPY_STRUCT_FAKE: if _BPY_STRUCT_FAKE:
@@ -571,16 +568,16 @@ def rna2sphinx(BASEPATH):
title = struct.identifier title = struct.identifier
fw("%s\n%s\n\n" % (title, "=" * len(title))) fw("%s\n%s\n\n" % (title, "=" * len(title)))
fw(".. module:: bpy.types\n\n") fw(".. module:: bpy.types\n\n")
base_ids = [base.identifier for base in struct.get_bases()] base_ids = [base.identifier for base in struct.get_bases()]
if _BPY_STRUCT_FAKE: if _BPY_STRUCT_FAKE:
base_ids.append(_BPY_STRUCT_FAKE) base_ids.append(_BPY_STRUCT_FAKE)
base_ids.reverse() base_ids.reverse()
if base_ids: if base_ids:
if len(base_ids) > 1: if len(base_ids) > 1:
fw("base classes --- ") fw("base classes --- ")
@@ -589,13 +586,13 @@ def rna2sphinx(BASEPATH):
fw(", ".join((":class:`%s`" % base_id) for base_id in base_ids)) fw(", ".join((":class:`%s`" % base_id) for base_id in base_ids))
fw("\n\n") fw("\n\n")
subclass_ids = [s.identifier for s in structs.values() if s.base is struct if not rna_info.rna_id_ignore(s.identifier)] subclass_ids = [s.identifier for s in structs.values() if s.base is struct if not rna_info.rna_id_ignore(s.identifier)]
if subclass_ids: if subclass_ids:
fw("subclasses --- \n" + ", ".join((":class:`%s`" % s) for s in subclass_ids) + "\n\n") fw("subclasses --- \n" + ", ".join((":class:`%s`" % s) for s in subclass_ids) + "\n\n")
base_id = getattr(struct.base, "identifier", "") base_id = getattr(struct.base, "identifier", "")
if _BPY_STRUCT_FAKE: if _BPY_STRUCT_FAKE:
if not base_id: if not base_id:
base_id = _BPY_STRUCT_FAKE base_id = _BPY_STRUCT_FAKE
@@ -606,7 +603,7 @@ def rna2sphinx(BASEPATH):
fw(".. class:: %s\n\n" % struct.identifier) fw(".. class:: %s\n\n" % struct.identifier)
fw(" %s\n\n" % struct.description) fw(" %s\n\n" % struct.description)
# properties sorted in alphabetical order # properties sorted in alphabetical order
sorted_struct_properties = struct.properties[:] sorted_struct_properties = struct.properties[:]
sorted_struct_properties.sort(key=lambda prop: prop.identifier) sorted_struct_properties.sort(key=lambda prop: prop.identifier)
@@ -621,7 +618,7 @@ def rna2sphinx(BASEPATH):
if prop.description: if prop.description:
fw(" %s\n\n" % prop.description) fw(" %s\n\n" % prop.description)
fw(" :type: %s\n\n" % type_descr) fw(" :type: %s\n\n" % type_descr)
# python attributes # python attributes
py_properties = struct.get_py_properties() py_properties = struct.get_py_properties()
py_prop = None py_prop = None
@@ -634,13 +631,13 @@ def rna2sphinx(BASEPATH):
fw(" .. %s:: %s(%s)\n\n" % ("classmethod" if func.is_classmethod else "method", func.identifier, args_str)) fw(" .. %s:: %s(%s)\n\n" % ("classmethod" if func.is_classmethod else "method", func.identifier, args_str))
fw(" %s\n\n" % func.description) fw(" %s\n\n" % func.description)
for prop in func.args: for prop in func.args:
write_param(" ", fw, prop) write_param(" ", fw, prop)
if len(func.return_values) == 1: if len(func.return_values) == 1:
write_param(" ", fw, func.return_values[0], is_return=True) write_param(" ", fw, func.return_values[0], is_return=True)
elif func.return_values: # multiple return values elif func.return_values: # multiple return values
fw(" :return (%s):\n" % ", ".join(prop.identifier for prop in func.return_values)) fw(" :return (%s):\n" % ", ".join(prop.identifier for prop in func.return_values))
for prop in func.return_values: for prop in func.return_values:
type_descr = prop.get_type_description(as_ret=True, class_fmt=":class:`%s`") type_descr = prop.get_type_description(as_ret=True, class_fmt=":class:`%s`")
@@ -651,11 +648,10 @@ def rna2sphinx(BASEPATH):
fw("\n") fw("\n")
# python methods # python methods
py_funcs = struct.get_py_functions() py_funcs = struct.get_py_functions()
py_func = None py_func = None
for identifier, py_func in py_funcs: for identifier, py_func in py_funcs:
pyfunc2sphinx(" ", fw, identifier, py_func, is_class=True) pyfunc2sphinx(" ", fw, identifier, py_func, is_class=True)
del py_funcs, py_func del py_funcs, py_func
@@ -667,10 +663,10 @@ def rna2sphinx(BASEPATH):
# props # props
lines[:] = [] lines[:] = []
if _BPY_STRUCT_FAKE: if _BPY_STRUCT_FAKE:
descr_items = [(key, descr) for key, descr in sorted(bpy.types.Struct.__bases__[0].__dict__.items()) if not key.startswith("__")] descr_items = [(key, descr) for key, descr in sorted(bpy.types.Struct.__bases__[0].__dict__.items()) if not key.startswith("__")]
if _BPY_STRUCT_FAKE: if _BPY_STRUCT_FAKE:
for key, descr in descr_items: for key, descr in descr_items:
if type(descr) == GetSetDescriptorType: if type(descr) == GetSetDescriptorType:
@@ -682,10 +678,10 @@ def rna2sphinx(BASEPATH):
for identifier, py_prop in base.get_py_properties(): for identifier, py_prop in base.get_py_properties():
lines.append(" * :class:`%s.%s`\n" % (base.identifier, identifier)) lines.append(" * :class:`%s.%s`\n" % (base.identifier, identifier))
for identifier, py_prop in base.get_py_properties(): for identifier, py_prop in base.get_py_properties():
lines.append(" * :class:`%s.%s`\n" % (base.identifier, identifier)) lines.append(" * :class:`%s.%s`\n" % (base.identifier, identifier))
if lines: if lines:
fw(".. rubric:: Inherited Properties\n\n") fw(".. rubric:: Inherited Properties\n\n")
@@ -696,7 +692,6 @@ def rna2sphinx(BASEPATH):
fw(line) fw(line)
fw("\n") fw("\n")
# funcs # funcs
lines[:] = [] lines[:] = []
@@ -720,9 +715,8 @@ def rna2sphinx(BASEPATH):
for line in lines: for line in lines:
fw(line) fw(line)
fw("\n") fw("\n")
lines[:] = []
lines[:] = []
if struct.references: if struct.references:
# use this otherwise it gets in the index for a normal heading. # use this otherwise it gets in the index for a normal heading.
@@ -738,13 +732,12 @@ def rna2sphinx(BASEPATH):
fw(" * :class:`%s`\n" % ref) fw(" * :class:`%s`\n" % ref)
fw("\n") fw("\n")
for struct in structs.values(): for struct in structs.values():
# TODO, rna_info should filter these out! # TODO, rna_info should filter these out!
if "_OT_" in struct.identifier: if "_OT_" in struct.identifier:
continue continue
write_struct(struct) write_struct(struct)
# special case, bpy_struct # special case, bpy_struct
if _BPY_STRUCT_FAKE: if _BPY_STRUCT_FAKE:
filepath = os.path.join(BASEPATH, "bpy.types.%s.rst" % _BPY_STRUCT_FAKE) filepath = os.path.join(BASEPATH, "bpy.types.%s.rst" % _BPY_STRUCT_FAKE)
@@ -769,41 +762,40 @@ def rna2sphinx(BASEPATH):
descr_items = [(key, descr) for key, descr in sorted(bpy.types.Struct.__bases__[0].__dict__.items()) if not key.startswith("__")] descr_items = [(key, descr) for key, descr in sorted(bpy.types.Struct.__bases__[0].__dict__.items()) if not key.startswith("__")]
for key, descr in descr_items: for key, descr in descr_items:
if type(descr) == MethodDescriptorType: # GetSetDescriptorType, GetSetDescriptorType's are not documented yet if type(descr) == MethodDescriptorType: # GetSetDescriptorType, GetSetDescriptorType's are not documented yet
py_descr2sphinx(" ", fw, descr, "bpy.types", _BPY_STRUCT_FAKE, key) py_descr2sphinx(" ", fw, descr, "bpy.types", _BPY_STRUCT_FAKE, key)
for key, descr in descr_items: for key, descr in descr_items:
if type(descr) == GetSetDescriptorType: if type(descr) == GetSetDescriptorType:
py_descr2sphinx(" ", fw, descr, "bpy.types", _BPY_STRUCT_FAKE, key) py_descr2sphinx(" ", fw, descr, "bpy.types", _BPY_STRUCT_FAKE, key)
# operators # operators
def write_ops(): def write_ops():
API_BASEURL='https://svn.blender.org/svnroot/bf-blender/trunk/blender/release/scripts' API_BASEURL = "https://svn.blender.org/svnroot/bf-blender/trunk/blender/release/scripts"
fw = None fw = None
last_mod = '' last_mod = ''
for op_key in sorted(ops.keys()): for op_key in sorted(ops.keys()):
op = ops[op_key] op = ops[op_key]
if last_mod != op.module_name: if last_mod != op.module_name:
filepath = os.path.join(BASEPATH, "bpy.ops.%s.rst" % op.module_name) filepath = os.path.join(BASEPATH, "bpy.ops.%s.rst" % op.module_name)
file = open(filepath, "w") file = open(filepath, "w")
fw = file.write fw = file.write
title = "%s Operators" % (op.module_name[0].upper() + op.module_name[1:]) title = "%s Operators" % (op.module_name[0].upper() + op.module_name[1:])
fw("%s\n%s\n\n" % (title, "=" * len(title))) fw("%s\n%s\n\n" % (title, "=" * len(title)))
fw(".. module:: bpy.ops.%s\n\n" % op.module_name) fw(".. module:: bpy.ops.%s\n\n" % op.module_name)
last_mod = op.module_name last_mod = op.module_name
args_str = ", ".join(prop.get_arg_default(force=True) for prop in op.args) args_str = ", ".join(prop.get_arg_default(force=True) for prop in op.args)
fw(".. function:: %s(%s)\n\n" % (op.func_name, args_str)) fw(".. function:: %s(%s)\n\n" % (op.func_name, args_str))
# if the description isn't valid, we output the standard warning # if the description isn't valid, we output the standard warning
# with a link to the wiki so that people can help # with a link to the wiki so that people can help
if not op.description or op.description == "(undocumented operator)": if not op.description or op.description == "(undocumented operator)":
operator_description = undocumented_message('bpy.ops',op.module_name,op.func_name) operator_description = undocumented_message('bpy.ops', op.module_name, op.func_name)
else: else:
operator_description = op.description operator_description = op.description
@@ -815,12 +807,13 @@ def rna2sphinx(BASEPATH):
location = op.get_location() location = op.get_location()
if location != (None, None): if location != (None, None):
fw(" :file: `%s <%s/%s>`_:%d\n\n" % (location[0],API_BASEURL,location[0],location[1])) fw(" :file: `%s <%s/%s>`_:%d\n\n" % (location[0], API_BASEURL, location[0], location[1]))
write_ops() write_ops()
file.close() file.close()
def main(): def main():
import bpy import bpy
if 'bpy' not in dir(): if 'bpy' not in dir():
@@ -830,9 +823,9 @@ def main():
import shutil import shutil
script_dir = os.path.dirname(__file__) script_dir = os.path.dirname(__file__)
path_in = os.path.join(script_dir,'sphinx-in') path_in = os.path.join(script_dir, "sphinx-in")
path_out = os.path.join(script_dir,'sphinx-out') path_out = os.path.join(script_dir, "sphinx-out")
path_examples = os.path.join(script_dir,'examples') path_examples = os.path.join(script_dir, "examples")
# only for partial updates # only for partial updates
path_in_tmp = path_in + "-tmp" path_in_tmp = path_in + "-tmp"
@@ -843,7 +836,6 @@ def main():
if f.endswith(".py"): if f.endswith(".py"):
EXAMPLE_SET.add(os.path.splitext(f)[0]) EXAMPLE_SET.add(os.path.splitext(f)[0])
# only for full updates # only for full updates
if _BPY_FULL_REBUILD: if _BPY_FULL_REBUILD:
shutil.rmtree(path_in, True) shutil.rmtree(path_in, True)
@@ -860,7 +852,7 @@ def main():
# now move changed files from 'path_in_tmp' --> 'path_in' # now move changed files from 'path_in_tmp' --> 'path_in'
file_list_path_in = set(os.listdir(path_in)) file_list_path_in = set(os.listdir(path_in))
file_list_path_in_tmp = set(os.listdir(path_in_tmp)) file_list_path_in_tmp = set(os.listdir(path_in_tmp))
# remove deprecated files that have been removed. # remove deprecated files that have been removed.
for f in sorted(file_list_path_in): for f in sorted(file_list_path_in):
if f not in file_list_path_in_tmp: if f not in file_list_path_in_tmp:
@@ -876,14 +868,13 @@ def main():
if f in file_list_path_in: if f in file_list_path_in:
if filecmp.cmp(f_from, f_to): if filecmp.cmp(f_from, f_to):
do_copy = False do_copy = False
if do_copy: if do_copy:
print("\tupdating: %s" % f) print("\tupdating: %s" % f)
shutil.copy(f_from, f_to) shutil.copy(f_from, f_to)
'''else: '''else:
print("\tkeeping: %s" % f) # eh, not that useful''' print("\tkeeping: %s" % f) # eh, not that useful'''
EXAMPLE_SET_UNUSED = EXAMPLE_SET - EXAMPLE_SET_USED EXAMPLE_SET_UNUSED = EXAMPLE_SET - EXAMPLE_SET_USED
if EXAMPLE_SET_UNUSED: if EXAMPLE_SET_UNUSED:
print("\nUnused examples found in '%s'..." % path_examples) print("\nUnused examples found in '%s'..." % path_examples)

View File

@@ -18,6 +18,8 @@
# #
# ##### END GPL LICENSE BLOCK ##### # ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
""" """
Thumbnailer runs with python 2.6 and 3.x. Thumbnailer runs with python 2.6 and 3.x.
To run automatically with nautilus: To run automatically with nautilus:

View File

@@ -1,7 +1,29 @@
# Built-In Keying Sets # ##### BEGIN GPL LICENSE BLOCK #####
# None of these Keying Sets should be removed, as these #
# are needed by various parts of Blender in order for them # This program is free software; you can redistribute it and/or
# to work correctly. # 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 LICENSE BLOCK #####
# <pep8 compliant>
"""
Built-In Keying Sets
None of these Keying Sets should be removed, as these
are needed by various parts of Blender in order for them
to work correctly.
"""
import bpy import bpy
from keyingsets_utils import * from keyingsets_utils import *
@@ -9,6 +31,7 @@ from keyingsets_utils import *
############################### ###############################
# Built-In KeyingSets # Built-In KeyingSets
# Location # Location
class BUILTIN_KSI_Location(bpy.types.KeyingSetInfo): class BUILTIN_KSI_Location(bpy.types.KeyingSetInfo):
bl_label = "Location" bl_label = "Location"
@@ -19,9 +42,10 @@ class BUILTIN_KSI_Location(bpy.types.KeyingSetInfo):
# iterator - use callback for selected bones/objects # iterator - use callback for selected bones/objects
iterator = RKS_ITER_selected_item iterator = RKS_ITER_selected_item
# generator - use callback for location # generator - use callback for location
generate = RKS_GEN_location generate = RKS_GEN_location
# Rotation # Rotation
class BUILTIN_KSI_Rotation(bpy.types.KeyingSetInfo): class BUILTIN_KSI_Rotation(bpy.types.KeyingSetInfo):
bl_label = "Rotation" bl_label = "Rotation"
@@ -32,9 +56,10 @@ class BUILTIN_KSI_Rotation(bpy.types.KeyingSetInfo):
# iterator - use callback for selected bones/objects # iterator - use callback for selected bones/objects
iterator = RKS_ITER_selected_item iterator = RKS_ITER_selected_item
# generator - use callback for location # generator - use callback for location
generate = RKS_GEN_rotation generate = RKS_GEN_rotation
# Scale # Scale
class BUILTIN_KSI_Scaling(bpy.types.KeyingSetInfo): class BUILTIN_KSI_Scaling(bpy.types.KeyingSetInfo):
bl_label = "Scaling" bl_label = "Scaling"
@@ -45,11 +70,12 @@ class BUILTIN_KSI_Scaling(bpy.types.KeyingSetInfo):
# iterator - use callback for selected bones/objects # iterator - use callback for selected bones/objects
iterator = RKS_ITER_selected_item iterator = RKS_ITER_selected_item
# generator - use callback for location # generator - use callback for location
generate = RKS_GEN_scaling generate = RKS_GEN_scaling
# ------------ # ------------
# LocRot # LocRot
class BUILTIN_KSI_LocRot(bpy.types.KeyingSetInfo): class BUILTIN_KSI_LocRot(bpy.types.KeyingSetInfo):
bl_label = "LocRot" bl_label = "LocRot"
@@ -60,13 +86,14 @@ class BUILTIN_KSI_LocRot(bpy.types.KeyingSetInfo):
# iterator - use callback for selected bones/objects # iterator - use callback for selected bones/objects
iterator = RKS_ITER_selected_item iterator = RKS_ITER_selected_item
# generator # generator
def generate(self, context, ks, data): def generate(self, context, ks, data):
# location # location
RKS_GEN_location(self, context, ks, data) RKS_GEN_location(self, context, ks, data)
# rotation # rotation
RKS_GEN_rotation(self, context, ks, data) RKS_GEN_rotation(self, context, ks, data)
# LocScale # LocScale
class BUILTIN_KSI_LocScale(bpy.types.KeyingSetInfo): class BUILTIN_KSI_LocScale(bpy.types.KeyingSetInfo):
bl_label = "LocScale" bl_label = "LocScale"
@@ -77,13 +104,14 @@ class BUILTIN_KSI_LocScale(bpy.types.KeyingSetInfo):
# iterator - use callback for selected bones/objects # iterator - use callback for selected bones/objects
iterator = RKS_ITER_selected_item iterator = RKS_ITER_selected_item
# generator # generator
def generate(self, context, ks, data): def generate(self, context, ks, data):
# location # location
RKS_GEN_location(self, context, ks, data) RKS_GEN_location(self, context, ks, data)
# scale # scale
RKS_GEN_scaling(self, context, ks, data) RKS_GEN_scaling(self, context, ks, data)
# LocRotScale # LocRotScale
class BUILTIN_KSI_LocRotScale(bpy.types.KeyingSetInfo): class BUILTIN_KSI_LocRotScale(bpy.types.KeyingSetInfo):
bl_label = "LocRotScale" bl_label = "LocRotScale"
@@ -94,7 +122,7 @@ class BUILTIN_KSI_LocRotScale(bpy.types.KeyingSetInfo):
# iterator - use callback for selected bones/objects # iterator - use callback for selected bones/objects
iterator = RKS_ITER_selected_item iterator = RKS_ITER_selected_item
# generator # generator
def generate(self, context, ks, data): def generate(self, context, ks, data):
# location # location
RKS_GEN_location(self, context, ks, data) RKS_GEN_location(self, context, ks, data)
@@ -103,6 +131,7 @@ class BUILTIN_KSI_LocRotScale(bpy.types.KeyingSetInfo):
# scale # scale
RKS_GEN_scaling(self, context, ks, data) RKS_GEN_scaling(self, context, ks, data)
# RotScale # RotScale
class BUILTIN_KSI_RotScale(bpy.types.KeyingSetInfo): class BUILTIN_KSI_RotScale(bpy.types.KeyingSetInfo):
bl_label = "RotScale" bl_label = "RotScale"
@@ -113,15 +142,16 @@ class BUILTIN_KSI_RotScale(bpy.types.KeyingSetInfo):
# iterator - use callback for selected bones/objects # iterator - use callback for selected bones/objects
iterator = RKS_ITER_selected_item iterator = RKS_ITER_selected_item
# generator # generator
def generate(self, context, ks, data): def generate(self, context, ks, data):
# rotation # rotation
RKS_GEN_rotation(self, context, ks, data) RKS_GEN_rotation(self, context, ks, data)
# scaling # scaling
RKS_GEN_scaling(self, context, ks, data) RKS_GEN_scaling(self, context, ks, data)
# ------------ # ------------
# Location # Location
class BUILTIN_KSI_VisualLoc(bpy.types.KeyingSetInfo): class BUILTIN_KSI_VisualLoc(bpy.types.KeyingSetInfo):
bl_label = "Visual Location" bl_label = "Visual Location"
@@ -134,9 +164,10 @@ class BUILTIN_KSI_VisualLoc(bpy.types.KeyingSetInfo):
# iterator - use callback for selected bones/objects # iterator - use callback for selected bones/objects
iterator = RKS_ITER_selected_item iterator = RKS_ITER_selected_item
# generator - use callback for location # generator - use callback for location
generate = RKS_GEN_location generate = RKS_GEN_location
# Rotation # Rotation
class BUILTIN_KSI_VisualRot(bpy.types.KeyingSetInfo): class BUILTIN_KSI_VisualRot(bpy.types.KeyingSetInfo):
bl_label = "Visual Rotation" bl_label = "Visual Rotation"
@@ -149,9 +180,10 @@ class BUILTIN_KSI_VisualRot(bpy.types.KeyingSetInfo):
# iterator - use callback for selected bones/objects # iterator - use callback for selected bones/objects
iterator = RKS_ITER_selected_item iterator = RKS_ITER_selected_item
# generator - use callback for rotation # generator - use callback for rotation
generate = RKS_GEN_rotation generate = RKS_GEN_rotation
# VisualLocRot # VisualLocRot
class BUILTIN_KSI_VisualLocRot(bpy.types.KeyingSetInfo): class BUILTIN_KSI_VisualLocRot(bpy.types.KeyingSetInfo):
bl_label = "Visual LocRot" bl_label = "Visual LocRot"
@@ -164,7 +196,7 @@ class BUILTIN_KSI_VisualLocRot(bpy.types.KeyingSetInfo):
# iterator - use callback for selected bones/objects # iterator - use callback for selected bones/objects
iterator = RKS_ITER_selected_item iterator = RKS_ITER_selected_item
# generator # generator
def generate(self, context, ks, data): def generate(self, context, ks, data):
# location # location
RKS_GEN_location(self, context, ks, data) RKS_GEN_location(self, context, ks, data)
@@ -173,39 +205,41 @@ class BUILTIN_KSI_VisualLocRot(bpy.types.KeyingSetInfo):
# ------------ # ------------
# Available # Available
class BUILTIN_KSI_Available(bpy.types.KeyingSetInfo): class BUILTIN_KSI_Available(bpy.types.KeyingSetInfo):
bl_label = "Available" bl_label = "Available"
# poll - use predefined callback for selected objects # poll - use predefined callback for selected objects
# TODO: this should really check whether the selected object (or datablock) # TODO: this should really check whether the selected object (or datablock)
# has any animation data defined yet # has any animation data defined yet
poll = RKS_POLL_selected_objects poll = RKS_POLL_selected_objects
# iterator - use callback for selected bones/objects # iterator - use callback for selected bones/objects
iterator = RKS_ITER_selected_item iterator = RKS_ITER_selected_item
# generator - use callback for doing this # generator - use callback for doing this
generate = RKS_GEN_available generate = RKS_GEN_available
############################### ###############################
# All properties that are likely to get animated in a character rig # All properties that are likely to get animated in a character rig
class BUILTIN_KSI_WholeCharacter(bpy.types.KeyingSetInfo): class BUILTIN_KSI_WholeCharacter(bpy.types.KeyingSetInfo):
bl_label = "Whole Character" bl_label = "Whole Character"
# these prefixes should be avoided, as they are not really bones # these prefixes should be avoided, as they are not really bones
# that animators should be touching (or need to touch) # that animators should be touching (or need to touch)
badBonePrefixes = ( badBonePrefixes = (
'DEF', 'DEF',
'GEO', 'GEO',
'MCH', 'MCH',
'ORG', 'ORG',
'COR', 'COR',
'VIS', 'VIS',
# ... more can be added here as you need in your own rigs ... # ... more can be added here as you need in your own rigs ...
) )
# poll - pose-mode on active object only # poll - pose-mode on active object only
def poll(ksi, context): def poll(ksi, context):
return ((context.active_object) and (context.active_object.pose) and return ((context.active_object) and (context.active_object.pose) and
@@ -221,39 +255,39 @@ class BUILTIN_KSI_WholeCharacter(bpy.types.KeyingSetInfo):
def generate(ksi, context, ks, bone): def generate(ksi, context, ks, bone):
# loc, rot, scale - only include unlocked ones # loc, rot, scale - only include unlocked ones
ksi.doLoc(ks, bone) ksi.doLoc(ks, bone)
if bone.rotation_mode in ('QUATERNION', 'AXIS_ANGLE'): if bone.rotation_mode in ('QUATERNION', 'AXIS_ANGLE'):
ksi.doRot4d(ks, bone) ksi.doRot4d(ks, bone)
else: else:
ksi.doRot3d(ks, bone) ksi.doRot3d(ks, bone)
ksi.doScale(ks, bone) ksi.doScale(ks, bone)
# custom props? # custom props?
ksi.doCustomProps(ks, bone) ksi.doCustomProps(ks, bone)
# ---------------- # ----------------
# helper to add some bone's property to the Keying Set # helper to add some bone's property to the Keying Set
def addProp(ksi, ks, bone, prop, index=-1, use_groups=True): def addProp(ksi, ks, bone, prop, index=-1, use_groups=True):
# add the property name to the base path # add the property name to the base path
id_path = bone.path_from_id() id_path = bone.path_from_id()
id_block = bone.id_data id_block = bone.id_data
if prop.startswith('['): if prop.startswith('['):
# custom properties # custom properties
path = id_path + prop path = id_path + prop
else: else:
# standard transforms/properties # standard transforms/properties
path = path_add_property(id_path, prop) path = path_add_property(id_path, prop)
# add Keying Set entry for this... # add Keying Set entry for this...
if use_groups: if use_groups:
ks.paths.add(id_block, path, index, group_method='NAMED', group_name=bone.name) ks.paths.add(id_block, path, index, group_method='NAMED', group_name=bone.name)
else: else:
ks.paths.add(id_block, path, index) ks.paths.add(id_block, path, index)
# ---------------- # ----------------
# location properties # location properties
def doLoc(ksi, ks, bone): def doLoc(ksi, ks, bone):
if bone.lock_location == (False, False, False): if bone.lock_location == (False, False, False):
@@ -262,7 +296,7 @@ class BUILTIN_KSI_WholeCharacter(bpy.types.KeyingSetInfo):
for i in range(3): for i in range(3):
if not bone.lock_location[i]: if not bone.lock_location[i]:
ksi.addProp(ks, bone, "location", i) ksi.addProp(ks, bone, "location", i)
# rotation properties # rotation properties
def doRot4d(ksi, ks, bone): def doRot4d(ksi, ks, bone):
# rotation mode affects the property used # rotation mode affects the property used
@@ -270,7 +304,7 @@ class BUILTIN_KSI_WholeCharacter(bpy.types.KeyingSetInfo):
prop = "rotation_quaternion" prop = "rotation_quaternion"
elif bone.rotation_mode == 'AXIS_ANGLE': elif bone.rotation_mode == 'AXIS_ANGLE':
prop = "rotation_axis_angle" prop = "rotation_axis_angle"
# add rotation properties if they will # add rotation properties if they will
if bone.lock_rotations_4d: if bone.lock_rotations_4d:
# can check individually # can check individually
@@ -278,16 +312,16 @@ class BUILTIN_KSI_WholeCharacter(bpy.types.KeyingSetInfo):
ksi.addProp(ks, bone, prop) ksi.addProp(ks, bone, prop)
else: else:
if bone.lock_rotation_w == False: if bone.lock_rotation_w == False:
ksi.addProp(ks, bone, prop, 0) # w = 0 ksi.addProp(ks, bone, prop, 0) # w = 0
for i in range(3): for i in range(3):
if not bone.lock_rotation[i]: if not bone.lock_rotation[i]:
ksi.addProp(ks, bone, prop, i+1) # i+1, since here x,y,z = 1,2,3, and w=0 ksi.addProp(ks, bone, prop, i + 1) # i + 1, since here x,y,z = 1,2,3, and w=0
elif True not in bone.lock_rotation: elif True not in bone.lock_rotation:
# if axis-angle rotations get locked as eulers, then it's too messy to allow anything # if axis-angle rotations get locked as eulers, then it's too messy to allow anything
# other than all open unless we keyframe the whole lot # other than all open unless we keyframe the whole lot
ksi.addProp(ks, bone, prop) ksi.addProp(ks, bone, prop)
def doRot3d(ksi, ks, bone): def doRot3d(ksi, ks, bone):
if bone.lock_rotation == (False, False, False): if bone.lock_rotation == (False, False, False):
ksi.addProp(ks, bone, "rotation_euler") ksi.addProp(ks, bone, "rotation_euler")
@@ -295,30 +329,30 @@ class BUILTIN_KSI_WholeCharacter(bpy.types.KeyingSetInfo):
for i in range(3): for i in range(3):
if not bone.lock_rotation[i]: if not bone.lock_rotation[i]:
ksi.addProp(ks, bone, "rotation_euler", i) ksi.addProp(ks, bone, "rotation_euler", i)
# scale properties # scale properties
def doScale(ksi, ks, bone): def doScale(ksi, ks, bone):
if bone.lock_scale == (0,0,0): if bone.lock_scale == (0, 0, 0):
ksi.addProp(ks, bone, "scale") ksi.addProp(ks, bone, "scale")
else: else:
for i in range(3): for i in range(3):
if not bone.lock_scale[i]: if not bone.lock_scale[i]:
ksi.addProp(ks, bone, "scale", i) ksi.addProp(ks, bone, "scale", i)
# ---------------- # ----------------
# custom properties # custom properties
def doCustomProps(ksi, ks, bone): def doCustomProps(ksi, ks, bone):
# go over all custom properties for bone # go over all custom properties for bone
for prop,val in bone.items(): for prop, val in bone.items():
# ignore special "_RNA_UI" used for UI editing # ignore special "_RNA_UI" used for UI editing
if prop == "_RNA_UI": if prop == "_RNA_UI":
continue continue
# for now, just add all of 'em # for now, just add all of 'em
ksi.addProp(ks, bone, '["%s"]' % (prop)) ksi.addProp(ks, bone, '["%s"]' % (prop))
############################### ###############################
classes = [ classes = [
BUILTIN_KSI_Location, BUILTIN_KSI_Location,
@@ -329,7 +363,7 @@ classes = [
BUILTIN_KSI_LocScale, BUILTIN_KSI_LocScale,
BUILTIN_KSI_LocRotScale, BUILTIN_KSI_LocRotScale,
BUILTIN_KSI_RotScale, BUILTIN_KSI_RotScale,
BUILTIN_KSI_WholeCharacter, BUILTIN_KSI_WholeCharacter,
BUILTIN_KSI_VisualLoc, BUILTIN_KSI_VisualLoc,
@@ -354,4 +388,4 @@ def unregister():
if __name__ == "__main__": if __name__ == "__main__":
register() register()
############################### ###############################

View File

@@ -1,45 +1,51 @@
# This file defines a set of methods that are useful for various # This file defines a set of methods that are useful for various
# Relative Keying Set (RKS) related operations, such as: callbacks # Relative Keying Set (RKS) related operations, such as: callbacks
# for polling, iterator callbacks, and also generate callbacks. # for polling, iterator callbacks, and also generate callbacks.
# All of these can be used in conjunction with the others. # All of these can be used in conjunction with the others.
# <pep8 compliant>
import bpy import bpy
########################### ###########################
# General Utilities # General Utilities
# Append the specified property name on the the existing path # Append the specified property name on the the existing path
def path_add_property(path, prop): def path_add_property(path, prop):
if len(path): if len(path):
return path + "." + prop; return path + "." + prop
else: else:
return prop; return prop
########################### ###########################
# Poll Callbacks # Poll Callbacks
# selected objects # selected objects
def RKS_POLL_selected_objects(ksi, context): def RKS_POLL_selected_objects(ksi, context):
return context.active_object or len(context.selected_objects); return context.active_object or len(context.selected_objects)
# selected bones # selected bones
def RKS_POLL_selected_bones(ksi, context): def RKS_POLL_selected_bones(ksi, context):
# we must be in Pose Mode, and there must be some bones selected # we must be in Pose Mode, and there must be some bones selected
if (context.active_object) and (context.active_object.mode == 'POSE'): if (context.active_object) and (context.active_object.mode == 'POSE'):
if context.active_pose_bone or len(context.selected_pose_bones): if context.active_pose_bone or len(context.selected_pose_bones):
return True; return True
# nothing selected # nothing selected
return False; return False
# selected bones or objects # selected bones or objects
def RKS_POLL_selected_items(ksi, context): def RKS_POLL_selected_items(ksi, context):
return RKS_POLL_selected_bones(ksi, context) or RKS_POLL_selected_objects(ksi, context); return RKS_POLL_selected_bones(ksi, context) or RKS_POLL_selected_objects(ksi, context)
########################### ###########################
# Iterator Callbacks # Iterator Callbacks
# all selected objects or pose bones, depending on which we've got # all selected objects or pose bones, depending on which we've got
def RKS_ITER_selected_item(ksi, context, ks): def RKS_ITER_selected_item(ksi, context, ks):
if (context.active_object) and (context.active_object.mode == 'POSE'): if (context.active_object) and (context.active_object.mode == 'POSE'):
@@ -52,25 +58,26 @@ def RKS_ITER_selected_item(ksi, context, ks):
########################### ###########################
# Generate Callbacks # Generate Callbacks
# 'Available' F-Curves # 'Available' F-Curves
def RKS_GEN_available(ksi, context, ks, data): def RKS_GEN_available(ksi, context, ks, data):
# try to get the animation data associated with the closest # try to get the animation data associated with the closest
# ID-block to the data (neither of which may exist/be easy to find) # ID-block to the data (neither of which may exist/be easy to find)
id_block = data.id_data id_block = data.id_data
adt = getattr(id_block, "animation_data", None) adt = getattr(id_block, "animation_data", None)
# there must also be an active action... # there must also be an active action...
if adt is None or adt.action is None: if adt is None or adt.action is None:
return; return
# if we haven't got an ID-block as 'data', try to restrict # if we haven't got an ID-block as 'data', try to restrict
# paths added to only those which branch off from here # paths added to only those which branch off from here
# i.e. for bones # i.e. for bones
if id_block != data: if id_block != data:
basePath = data.path_from_id() basePath = data.path_from_id()
else: else:
basePath = None; # this is not needed... basePath = None # this is not needed...
# for each F-Curve, include a path to key it # for each F-Curve, include a path to key it
# NOTE: we don't need to set the group settings here # NOTE: we don't need to set the group settings here
for fcu in adt.action.fcurves: for fcu in adt.action.fcurves:
@@ -79,19 +86,20 @@ def RKS_GEN_available(ksi, context, ks, data):
ks.paths.add(id_block, fcu.data_path, index=fcu.array_index) ks.paths.add(id_block, fcu.data_path, index=fcu.array_index)
else: else:
ks.paths.add(id_block, fcu.data_path, index=fcu.array_index) ks.paths.add(id_block, fcu.data_path, index=fcu.array_index)
# ------ # ------
# get ID block and based ID path for transform generators # get ID block and based ID path for transform generators
def get_transform_generators_base_info(data): def get_transform_generators_base_info(data):
# ID-block for the data # ID-block for the data
id_block = data.id_data id_block = data.id_data
# get base path and grouping method/name # get base path and grouping method/name
if isinstance(data, bpy.types.ID): if isinstance(data, bpy.types.ID):
# no path in this case # no path in this case
path = "" path = ""
# data on ID-blocks directly should get grouped by the KeyingSet # data on ID-blocks directly should get grouped by the KeyingSet
grouping = None grouping = None
else: else:
@@ -101,29 +109,31 @@ def get_transform_generators_base_info(data):
# try to use the name of the data element to group the F-Curve # try to use the name of the data element to group the F-Curve
# else fallback on the KeyingSet name # else fallback on the KeyingSet name
grouping = getattr(data, "name", None) grouping = getattr(data, "name", None)
# return the ID-block and the path # return the ID-block and the path
return id_block, path, grouping return id_block, path, grouping
# Location
# Location
def RKS_GEN_location(ksi, context, ks, data): def RKS_GEN_location(ksi, context, ks, data):
# get id-block and path info # get id-block and path info
id_block, base_path, grouping = get_transform_generators_base_info(data) id_block, base_path, grouping = get_transform_generators_base_info(data)
# add the property name to the base path # add the property name to the base path
path = path_add_property(base_path, "location") path = path_add_property(base_path, "location")
# add Keying Set entry for this... # add Keying Set entry for this...
if grouping: if grouping:
ks.paths.add(id_block, path, group_method='NAMED', group_name=grouping) ks.paths.add(id_block, path, group_method='NAMED', group_name=grouping)
else: else:
ks.paths.add(id_block, path) ks.paths.add(id_block, path)
# Rotation
# Rotation
def RKS_GEN_rotation(ksi, context, ks, data): def RKS_GEN_rotation(ksi, context, ks, data):
# get id-block and path info # get id-block and path info
id_block, base_path, grouping= get_transform_generators_base_info(data) id_block, base_path, grouping = get_transform_generators_base_info(data)
# add the property name to the base path # add the property name to the base path
# rotation mode affects the property used # rotation mode affects the property used
if data.rotation_mode == 'QUATERNION': if data.rotation_mode == 'QUATERNION':
@@ -132,21 +142,22 @@ def RKS_GEN_rotation(ksi, context, ks, data):
path = path_add_property(base_path, "rotation_axis_angle") path = path_add_property(base_path, "rotation_axis_angle")
else: else:
path = path_add_property(base_path, "rotation_euler") path = path_add_property(base_path, "rotation_euler")
# add Keying Set entry for this... # add Keying Set entry for this...
if grouping: if grouping:
ks.paths.add(id_block, path, group_method='NAMED', group_name=grouping) ks.paths.add(id_block, path, group_method='NAMED', group_name=grouping)
else: else:
ks.paths.add(id_block, path) ks.paths.add(id_block, path)
# Scaling
# Scaling
def RKS_GEN_scaling(ksi, context, ks, data): def RKS_GEN_scaling(ksi, context, ks, data):
# get id-block and path info # get id-block and path info
id_block, base_path, grouping= get_transform_generators_base_info(data) id_block, base_path, grouping = get_transform_generators_base_info(data)
# add the property name to the base path # add the property name to the base path
path = path_add_property(base_path, "scale") path = path_add_property(base_path, "scale")
# add Keying Set entry for this... # add Keying Set entry for this...
if grouping: if grouping:
ks.paths.add(id_block, path, group_method='NAMED', group_name=grouping) ks.paths.add(id_block, path, group_method='NAMED', group_name=grouping)
@@ -158,6 +169,7 @@ def RKS_GEN_scaling(ksi, context, ks, data):
classes = [] classes = []
def register(): def register():
pass pass

View File

@@ -1,7 +1,28 @@
# ##### 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 LICENSE BLOCK #####
# <pep8 compliant>
from math import * from math import *
import bpy import bpy
from mathutils import * from mathutils import *
def main(context): def main(context):
def cleanupEulCurve(fcv): def cleanupEulCurve(fcv):
keys = [] keys = []
@@ -12,37 +33,38 @@ def main(context):
for i in range(len(keys)): for i in range(len(keys)):
cur = keys[i] cur = keys[i]
prev = keys[i-1] if i > 0 else None prev = keys[i - 1] if i > 0 else None
next = keys[i+1] if i < len(keys)-1 else None next = keys[i + 1] if i < len(keys) - 1 else None
if prev is None: if prev is None:
continue continue
th = pi th = pi
if abs(prev[1][1] - cur[1][1]) >= th: # more than 180 degree jump if abs(prev[1][1] - cur[1][1]) >= th: # more than 180 degree jump
fac = pi*2 fac = pi * 2.0
if prev[1][1] > cur[1][1]: if prev[1][1] > cur[1][1]:
while abs(cur[1][1]-prev[1][1]) >= th: # < prev[1][1]: while abs(cur[1][1] - prev[1][1]) >= th: # < prev[1][1]:
cur[0][1] += fac cur[0][1] += fac
cur[1][1] += fac cur[1][1] += fac
cur[2][1] += fac cur[2][1] += fac
elif prev[1][1] < cur[1][1]: elif prev[1][1] < cur[1][1]:
while abs(cur[1][1]-prev[1][1]) >= th: while abs(cur[1][1] - prev[1][1]) >= th:
cur[0][1] -= fac cur[0][1] -= fac
cur[1][1] -= fac cur[1][1] -= fac
cur[2][1] -= fac cur[2][1] -= fac
for i in range(len(keys)): for i in range(len(keys)):
for x in range(2): for x in range(2):
fcv.keyframe_points[i].handle_left[x] = keys[i][0][x] fcv.keyframe_points[i].handle_left[x] = keys[i][0][x]
fcv.keyframe_points[i].co[x] = keys[i][1][x] fcv.keyframe_points[i].co[x] = keys[i][1][x]
fcv.keyframe_points[i].handle_right[x] = keys[i][2][x] fcv.keyframe_points[i].handle_right[x] = keys[i][2][x]
flist = bpy.context.active_object.animation_data.action.fcurves flist = bpy.context.active_object.animation_data.action.fcurves
for f in flist: for f in flist:
if f.select and f.data_path.endswith("rotation_euler"): if f.select and f.data_path.endswith("rotation_euler"):
cleanupEulCurve(f) cleanupEulCurve(f)
class DiscontFilterOp(bpy.types.Operator): class DiscontFilterOp(bpy.types.Operator):
"""Fixes the most common causes of gimbal lock in the fcurves of the active bone""" """Fixes the most common causes of gimbal lock in the fcurves of the active bone"""
bl_idname = "graph.euler_filter" bl_idname = "graph.euler_filter"
@@ -56,9 +78,11 @@ class DiscontFilterOp(bpy.types.Operator):
main(context) main(context)
return {'FINISHED'} return {'FINISHED'}
def register(): def register():
pass pass
def unregister(): def unregister():
pass pass

View File

@@ -14,7 +14,7 @@ else:
bpy.context.scene.render.ffmpeg_video_bitrate = 6000 bpy.context.scene.render.ffmpeg_video_bitrate = 6000
bpy.context.scene.render.ffmpeg_maxrate = 9000 bpy.context.scene.render.ffmpeg_maxrate = 9000
bpy.context.scene.render.ffmpeg_minrate = 0 bpy.context.scene.render.ffmpeg_minrate = 0
bpy.context.scene.render.ffmpeg_buffersize = 224*8 bpy.context.scene.render.ffmpeg_buffersize = 224 * 8
bpy.context.scene.render.ffmpeg_packetsize = 2048 bpy.context.scene.render.ffmpeg_packetsize = 2048
bpy.context.scene.render.ffmpeg_muxrate = 10080000 bpy.context.scene.render.ffmpeg_muxrate = 10080000

View File

@@ -14,7 +14,7 @@ else:
bpy.context.scene.render.ffmpeg_video_bitrate = 2040 bpy.context.scene.render.ffmpeg_video_bitrate = 2040
bpy.context.scene.render.ffmpeg_maxrate = 2516 bpy.context.scene.render.ffmpeg_maxrate = 2516
bpy.context.scene.render.ffmpeg_minrate = 0 bpy.context.scene.render.ffmpeg_minrate = 0
bpy.context.scene.render.ffmpeg_buffersize = 224*8 bpy.context.scene.render.ffmpeg_buffersize = 224 * 8
bpy.context.scene.render.ffmpeg_packetsize = 2324 bpy.context.scene.render.ffmpeg_packetsize = 2324
bpy.context.scene.render.ffmpeg_muxrate = 0 bpy.context.scene.render.ffmpeg_muxrate = 0

View File

@@ -14,7 +14,7 @@ else:
bpy.context.scene.render.ffmpeg_video_bitrate = 1150 bpy.context.scene.render.ffmpeg_video_bitrate = 1150
bpy.context.scene.render.ffmpeg_maxrate = 1150 bpy.context.scene.render.ffmpeg_maxrate = 1150
bpy.context.scene.render.ffmpeg_minrate = 1150 bpy.context.scene.render.ffmpeg_minrate = 1150
bpy.context.scene.render.ffmpeg_buffersize = 40*8 bpy.context.scene.render.ffmpeg_buffersize = 40 * 8
bpy.context.scene.render.ffmpeg_packetsize = 2324 bpy.context.scene.render.ffmpeg_packetsize = 2324
bpy.context.scene.render.ffmpeg_muxrate = 2352 * 75 * 8 bpy.context.scene.render.ffmpeg_muxrate = 2352 * 75 * 8

View File

@@ -12,6 +12,6 @@ else:
bpy.context.scene.render.ffmpeg_video_bitrate = 6000 bpy.context.scene.render.ffmpeg_video_bitrate = 6000
bpy.context.scene.render.ffmpeg_maxrate = 9000 bpy.context.scene.render.ffmpeg_maxrate = 9000
bpy.context.scene.render.ffmpeg_minrate = 0 bpy.context.scene.render.ffmpeg_minrate = 0
bpy.context.scene.render.ffmpeg_buffersize = 224*8 bpy.context.scene.render.ffmpeg_buffersize = 224 * 8
bpy.context.scene.render.ffmpeg_packetsize = 2048 bpy.context.scene.render.ffmpeg_packetsize = 2048
bpy.context.scene.render.ffmpeg_muxrate = 10080000 bpy.context.scene.render.ffmpeg_muxrate = 10080000

View File

@@ -12,6 +12,6 @@ else:
bpy.context.scene.render.ffmpeg_video_bitrate = 6000 bpy.context.scene.render.ffmpeg_video_bitrate = 6000
bpy.context.scene.render.ffmpeg_maxrate = 9000 bpy.context.scene.render.ffmpeg_maxrate = 9000
bpy.context.scene.render.ffmpeg_minrate = 0 bpy.context.scene.render.ffmpeg_minrate = 0
bpy.context.scene.render.ffmpeg_buffersize = 224*8 bpy.context.scene.render.ffmpeg_buffersize = 224 * 8
bpy.context.scene.render.ffmpeg_packetsize = 2048 bpy.context.scene.render.ffmpeg_packetsize = 2048
bpy.context.scene.render.ffmpeg_muxrate = 10080000 bpy.context.scene.render.ffmpeg_muxrate = 10080000

View File

@@ -12,6 +12,6 @@ else:
bpy.context.scene.render.ffmpeg_video_bitrate = 6000 bpy.context.scene.render.ffmpeg_video_bitrate = 6000
bpy.context.scene.render.ffmpeg_maxrate = 9000 bpy.context.scene.render.ffmpeg_maxrate = 9000
bpy.context.scene.render.ffmpeg_minrate = 0 bpy.context.scene.render.ffmpeg_minrate = 0
bpy.context.scene.render.ffmpeg_buffersize = 224*8 bpy.context.scene.render.ffmpeg_buffersize = 224 * 8
bpy.context.scene.render.ffmpeg_packetsize = 2048 bpy.context.scene.render.ffmpeg_packetsize = 2048
bpy.context.scene.render.ffmpeg_muxrate = 10080000 bpy.context.scene.render.ffmpeg_muxrate = 10080000

View File

@@ -1,5 +1,5 @@
import bpy import bpy
material = (bpy.context.material.active_node_material if bpy.context.material.active_node_material else bpy.context.material) material = (bpy.context.material.active_node_material if bpy.context.material.active_node_material else bpy.context.material)
material.subsurface_scattering.radius = 11.605, 3.884, 1.754 material.subsurface_scattering.radius = 11.605, 3.884, 1.754
material.subsurface_scattering.color = 0.430, 0.210, 0.168 material.subsurface_scattering.color = 0.430, 0.210, 0.168

View File

@@ -20,6 +20,7 @@
import bpy import bpy
class PhysicButtonsPanel(): class PhysicButtonsPanel():
bl_space_type = 'PROPERTIES' bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW' bl_region_type = 'WINDOW'
@@ -29,7 +30,8 @@ class PhysicButtonsPanel():
def poll(cls, context): def poll(cls, context):
rd = context.scene.render rd = context.scene.render
return (context.object) and (not rd.use_game_engine) return (context.object) and (not rd.use_game_engine)
def physics_add(self, layout, md, name, type, typeicon, toggles): def physics_add(self, layout, md, name, type, typeicon, toggles):
sub = layout.row(align=True) sub = layout.row(align=True)
if md: if md:
@@ -41,35 +43,36 @@ def physics_add(self, layout, md, name, type, typeicon, toggles):
else: else:
sub.operator("object.modifier_add", text=name, icon=typeicon).type = type sub.operator("object.modifier_add", text=name, icon=typeicon).type = type
class PHYSICS_PT_add(PhysicButtonsPanel, bpy.types.Panel): class PHYSICS_PT_add(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "" bl_label = ""
bl_options = {'HIDE_HEADER'} bl_options = {'HIDE_HEADER'}
def draw(self, context): def draw(self, context):
ob = context.object ob = context.object
layout = self.layout layout = self.layout
layout.label("Enable physics for:") layout.label("Enable physics for:")
split = layout.split() split = layout.split()
col = split.column() col = split.column()
if(context.object.field.type == 'NONE'): if(context.object.field.type == 'NONE'):
col.operator("object.forcefield_toggle", text="Force Field", icon='FORCE_FORCE') col.operator("object.forcefield_toggle", text="Force Field", icon='FORCE_FORCE')
else: else:
col.operator("object.forcefield_toggle", text="Force Field", icon='X') col.operator("object.forcefield_toggle", text="Force Field", icon='X')
if(ob.type == 'MESH'): if(ob.type == 'MESH'):
physics_add(self, col, context.collision, "Collision", 'COLLISION', 'MOD_PHYSICS', False); physics_add(self, col, context.collision, "Collision", 'COLLISION', 'MOD_PHYSICS', False)
physics_add(self, col, context.cloth, "Cloth", 'CLOTH', 'MOD_CLOTH', True); physics_add(self, col, context.cloth, "Cloth", 'CLOTH', 'MOD_CLOTH', True)
col = split.column() col = split.column()
if(ob.type == 'MESH' or ob.type == 'LATTICE'or ob.type == 'CURVE'): if(ob.type == 'MESH' or ob.type == 'LATTICE'or ob.type == 'CURVE'):
physics_add(self, col, context.soft_body, "Soft Body", 'SOFT_BODY', 'MOD_SOFT', True); physics_add(self, col, context.soft_body, "Soft Body", 'SOFT_BODY', 'MOD_SOFT', True)
if(ob.type == 'MESH'): if(ob.type == 'MESH'):
physics_add(self, col, context.fluid, "Fluid", 'FLUID_SIMULATION', 'MOD_FLUIDSIM', True); physics_add(self, col, context.fluid, "Fluid", 'FLUID_SIMULATION', 'MOD_FLUIDSIM', True)
physics_add(self, col, context.smoke, "Smoke", 'SMOKE', 'MOD_SMOKE', True); physics_add(self, col, context.smoke, "Smoke", 'SMOKE', 'MOD_SMOKE', True)
#cachetype can be 'PSYS' 'HAIR' 'SMOKE' etc #cachetype can be 'PSYS' 'HAIR' 'SMOKE' etc

View File

@@ -37,7 +37,7 @@ class PhysicButtonsPanel():
class PHYSICS_PT_field(PhysicButtonsPanel, bpy.types.Panel): class PHYSICS_PT_field(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Force Fields" bl_label = "Force Fields"
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
ob = context.object ob = context.object

View File

@@ -39,8 +39,8 @@ class RENDER_MT_framerate_presets(bpy.types.Menu):
preset_subdir = "framerate" preset_subdir = "framerate"
preset_operator = "script.execute_preset" preset_operator = "script.execute_preset"
draw = bpy.types.Menu.draw_preset draw = bpy.types.Menu.draw_preset
class RenderButtonsPanel(): class RenderButtonsPanel():
bl_space_type = 'PROPERTIES' bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW' bl_region_type = 'WINDOW'
@@ -566,20 +566,20 @@ class RENDER_PT_dimensions(RenderButtonsPanel, bpy.types.Panel):
fps_rate = round(rd.fps / rd.fps_base) fps_rate = round(rd.fps / rd.fps_base)
else: else:
fps_rate = round(rd.fps / rd.fps_base, 2) fps_rate = round(rd.fps / rd.fps_base, 2)
# TODO: Change the following to iterate over existing presets # TODO: Change the following to iterate over existing presets
if (fps_rate in (23.98, 24, 25, 29.97, 30, 50, 59.94, 60)): if (fps_rate in (23.98, 24, 25, 29.97, 30, 50, 59.94, 60)):
custom_framerate = False custom_framerate = False
else: else:
custom_framerate = True custom_framerate = True
if custom_framerate == True: if custom_framerate == True:
fps_label_text = "Custom (" + str(fps_rate) + " fps)" fps_label_text = "Custom (" + str(fps_rate) + " fps)"
else: else:
fps_label_text = str(fps_rate) + " fps" fps_label_text = str(fps_rate) + " fps"
sub.menu("RENDER_MT_framerate_presets", text=fps_label_text) sub.menu("RENDER_MT_framerate_presets", text=fps_label_text)
if (bpy.types.RENDER_MT_framerate_presets.bl_label == "Custom") or (custom_framerate == True): if (bpy.types.RENDER_MT_framerate_presets.bl_label == "Custom") or (custom_framerate == True):
sub.prop(rd, "fps") sub.prop(rd, "fps")
sub.prop(rd, "fps_base", text="/") sub.prop(rd, "fps_base", text="/")

View File

@@ -32,10 +32,10 @@ def dopesheet_filter(layout, context, genericFiltersOnly=False):
row = layout.row(align=True) row = layout.row(align=True)
row.prop(dopesheet, "show_only_selected", text="") row.prop(dopesheet, "show_only_selected", text="")
row.prop(dopesheet, "show_hidden", text="") row.prop(dopesheet, "show_hidden", text="")
if genericFiltersOnly: if genericFiltersOnly:
return return
row = layout.row(align=True) row = layout.row(align=True)
row.prop(dopesheet, "show_transforms", text="") row.prop(dopesheet, "show_transforms", text="")
@@ -114,8 +114,8 @@ class DOPESHEET_HT_header(bpy.types.Header):
if st.mode == 'DOPESHEET': if st.mode == 'DOPESHEET':
dopesheet_filter(layout, context) dopesheet_filter(layout, context)
elif st.mode == 'ACTION': elif st.mode == 'ACTION':
# 'genericFiltersOnly' limits the options to only the relevant 'generic' subset of # 'genericFiltersOnly' limits the options to only the relevant 'generic' subset of
# filters which will work here and are useful (especially for character animation) # filters which will work here and are useful (especially for character animation)
dopesheet_filter(layout, context, genericFiltersOnly=True) dopesheet_filter(layout, context, genericFiltersOnly=True)
if st.mode in ('ACTION', 'SHAPEKEY'): if st.mode in ('ACTION', 'SHAPEKEY'):

View File

@@ -163,8 +163,8 @@ class NODE_MT_node(bpy.types.Menu):
layout.operator("node.show_cyclic_dependencies") layout.operator("node.show_cyclic_dependencies")
layout.operator("node.read_renderlayers") layout.operator("node.read_renderlayers")
layout.operator("node.read_fullsamplelayers") layout.operator("node.read_fullsamplelayers")
# Node Backdrop options # Node Backdrop options
class NODE_PT_properties(bpy.types.Panel): class NODE_PT_properties(bpy.types.Panel):
bl_space_type = 'NODE_EDITOR' bl_space_type = 'NODE_EDITOR'
@@ -175,7 +175,7 @@ class NODE_PT_properties(bpy.types.Panel):
def poll(cls, context): def poll(cls, context):
snode = context.space_data snode = context.space_data
return snode.tree_type == 'COMPOSITING' return snode.tree_type == 'COMPOSITING'
def draw_header(self, context): def draw_header(self, context):
snode = context.space_data snode = context.space_data
self.layout.prop(snode, "show_backdrop", text="") self.layout.prop(snode, "show_backdrop", text="")

View File

@@ -34,6 +34,7 @@ def draw_repeat_tools(context, layout):
col.operator("screen.repeat_last") col.operator("screen.repeat_last")
col.operator("screen.repeat_history", text="History...") col.operator("screen.repeat_history", text="History...")
# Keyframing tools # Keyframing tools
def draw_keyframing_tools(context, layout): def draw_keyframing_tools(context, layout):
col = layout.column(align=True) col = layout.column(align=True)
@@ -42,6 +43,7 @@ def draw_keyframing_tools(context, layout):
row.operator("anim.keyframe_insert_menu", text="Insert") row.operator("anim.keyframe_insert_menu", text="Insert")
row.operator("anim.keyframe_delete_v3d", text="Remove") row.operator("anim.keyframe_delete_v3d", text="Remove")
# Grease Pencil tools # Grease Pencil tools
def draw_gpencil_tools(context, layout): def draw_gpencil_tools(context, layout):
col = layout.column(align=True) col = layout.column(align=True)
@@ -88,9 +90,9 @@ class VIEW3D_PT_tools_objectmode(View3DPanel, bpy.types.Panel):
col.label(text="Shading:") col.label(text="Shading:")
col.operator("object.shade_smooth", text="Smooth") col.operator("object.shade_smooth", text="Smooth")
col.operator("object.shade_flat", text="Flat") col.operator("object.shade_flat", text="Flat")
draw_keyframing_tools(context, layout) draw_keyframing_tools(context, layout)
col = layout.column(align=True) col = layout.column(align=True)
col.label(text="Motion Paths:") col.label(text="Motion Paths:")
col.operator("object.paths_calculate", text="Calculate Paths") col.operator("object.paths_calculate", text="Calculate Paths")
@@ -406,7 +408,7 @@ class VIEW3D_PT_tools_posemode(View3DPanel, bpy.types.Panel):
col.operator("poselib.pose_add", text="Add To Library") col.operator("poselib.pose_add", text="Add To Library")
draw_keyframing_tools(context, layout) draw_keyframing_tools(context, layout)
col = layout.column(align=True) col = layout.column(align=True)
col.label(text="Motion Paths:") col.label(text="Motion Paths:")
col.operator("pose.paths_calculate", text="Calculate Paths") col.operator("pose.paths_calculate", text="Calculate Paths")

View File

@@ -50,6 +50,12 @@ def is_pep8(path):
print(path) print(path)
if open(path, 'rb').read(3) == b'\xef\xbb\xbf': if open(path, 'rb').read(3) == b'\xef\xbb\xbf':
print("\nfile contains BOM, remove first 3 bytes: %r\n" % path) print("\nfile contains BOM, remove first 3 bytes: %r\n" % path)
# templates dont have a header but should be pep8
for d in ("presets", "templates", "examples"):
if ("%s%s%s" % (os.sep, d, os.sep)) in path:
return 1
f = open(path, 'r', encoding="utf8") f = open(path, 'r', encoding="utf8")
for i in range(PEP8_SEEK_COMMENT): for i in range(PEP8_SEEK_COMMENT):
line = f.readline() line = f.readline()