Merged changes in the trunk up to revision 31190.

This commit is contained in:
2010-08-09 11:32:55 +00:00
520 changed files with 17532 additions and 19845 deletions

View File

@@ -69,7 +69,7 @@ OPTION(WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON)
OPTION(WITH_LCMS "Enable color correction with lcms" OFF)
OPTION(WITH_PYTHON "Enable Embedded Python API" ON)
OPTION(WITH_BUILDINFO "Include extra build details" ON)
OPTION(WITH_ELBEEM "Enable Elbeem (Fluid Simulation)" ON)
OPTION(WITH_FLUID "Enable Elbeem (Fluid Simulation)" ON)
OPTION(WITH_FFTW3 "Enable FFTW3 support (Used for smoke and audio effects)" OFF)
OPTION(WITH_BULLET "Enable Bullet (Physics Engine)" ON)
OPTION(WITH_GAMEENGINE "Enable Game Engine" ON)
@@ -82,10 +82,12 @@ ELSE()
ENDIF()
# Image format support
OPTION(WITH_OPENEXR "Enable OpenEXR Support (http://www.openexr.com)" ON)
OPTION(WITH_OPENJPEG "Enable OpenJpeg Support (http://www.openjpeg.org/)" OFF)
OPTION(WITH_TIFF "Enable LibTIFF Support" ON)
OPTION(WITH_DDS "Enable DDS Support" ON)
OPTION(WITH_IMAGE_OPENEXR "Enable OpenEXR Support (http://www.openexr.com)" ON)
OPTION(WITH_IMAGE_OPENJPEG "Enable OpenJpeg Support (http://www.openjpeg.org/)" OFF)
OPTION(WITH_IMAGE_TIFF "Enable LibTIFF Support" ON)
OPTION(WITH_IMAGE_DDS "Enable DDS Image Support" ON)
OPTION(WITH_IMAGE_CINEON "Enable CINEON and DPX Image Support" ON)
OPTION(WITH_IMAGE_HDR "Enable HDR Image Support" ON)
# Audio format support
OPTION(WITH_FFMPEG "Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu/)" OFF)
@@ -220,7 +222,7 @@ IF(UNIX AND NOT APPLE)
ENDIF(NOT SDL_FOUND)
ENDIF(WITH_SDL)
IF(WITH_OPENEXR)
IF(WITH_IMAGE_OPENEXR)
SET(OPENEXR /usr CACHE FILEPATH "OPENEXR Directory")
FIND_PATH(OPENEXR_INC
ImfXdr.h
@@ -235,16 +237,16 @@ IF(UNIX AND NOT APPLE)
SET(OPENEXR_LIB Half IlmImf Iex Imath)
IF(NOT OPENEXR_INC)
SET(WITH_OPENEXR OFF)
SET(WITH_IMAGE_OPENEXR OFF)
ENDIF(NOT OPENEXR_INC)
ENDIF(WITH_OPENEXR)
ENDIF(WITH_IMAGE_OPENEXR)
IF(WITH_TIFF)
IF(WITH_IMAGE_TIFF)
FIND_PACKAGE(TIFF)
IF(NOT TIFF_FOUND)
SET(WITH_TIFF OFF)
SET(WITH_IMAGE_TIFF OFF)
ENDIF(NOT TIFF_FOUND)
ENDIF(WITH_TIFF)
ENDIF(WITH_IMAGE_TIFF)
FIND_PACKAGE(JPEG REQUIRED)
@@ -497,7 +499,7 @@ IF(WIN32)
SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
ENDIF(WITH_FFMPEG)
IF(WITH_OPENEXR)
IF(WITH_IMAGE_OPENEXR)
SET(OPENEXR ${LIBDIR}/openexr)
SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/IlmImf ${OPENEXR}/include/Iex ${OPENEXR}/include/Imath)
SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
@@ -509,14 +511,14 @@ IF(WIN32)
IF (MSVC90)
SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2008)
ENDIF(MSVC90)
ENDIF(WITH_OPENEXR)
ENDIF(WITH_IMAGE_OPENEXR)
IF(WITH_TIFF)
IF(WITH_IMAGE_TIFF)
SET(TIFF ${LIBDIR}/tiff)
SET(TIFF_LIBRARY libtiff)
SET(TIFF_INCLUDE_DIR ${TIFF}/include)
SET(TIFF_LIBPATH ${TIFF}/lib)
ENDIF(WITH_TIFF)
ENDIF(WITH_IMAGE_TIFF)
IF(WITH_JACK)
SET(JACK ${LIBDIR}/jack)
@@ -607,19 +609,19 @@ IF(WIN32)
SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
ENDIF(WITH_FFMPEG)
IF(WITH_OPENEXR)
IF(WITH_IMAGE_OPENEXR)
SET(OPENEXR ${LIBDIR}/gcc/openexr)
SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/OpenEXR)
SET(OPENEXR_LIB Half IlmImf Imath IlmThread)
SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
ENDIF(WITH_OPENEXR)
ENDIF(WITH_IMAGE_OPENEXR)
IF(WITH_TIFF)
IF(WITH_IMAGE_TIFF)
SET(TIFF ${LIBDIR}/gcc/tiff)
SET(TIFF_LIBRARY tiff)
SET(TIFF_INCLUDE_DIR ${TIFF}/include)
SET(TIFF_LIBPATH ${TIFF}/lib)
ENDIF(WITH_TIFF)
ENDIF(WITH_IMAGE_TIFF)
IF(WITH_JACK)
SET(JACK ${LIBDIR}/jack)
@@ -727,12 +729,12 @@ IF(APPLE)
SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
SET(FREETYPE_LIBRARY freetype)
IF(WITH_OPENEXR)
IF(WITH_IMAGE_OPENEXR)
SET(OPENEXR ${LIBDIR}/openexr)
SET(OPENEXR_INC ${OPENEXR}/include/OpenEXR ${OPENEXR}/include)
SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
ENDIF(WITH_OPENEXR)
ENDIF(WITH_IMAGE_OPENEXR)
IF(WITH_LCMS)
SET(LCMS ${LIBDIR}/lcms)
@@ -810,12 +812,12 @@ IF(APPLE)
SET(JPEG_INC "${JPEG}/include")
SET(JPEG_LIBPATH ${JPEG}/lib)
IF(WITH_TIFF)
IF(WITH_IMAGE_TIFF)
SET(TIFF ${LIBDIR}/tiff)
SET(TIFF_INCLUDE_DIR ${TIFF}/include)
SET(TIFF_LIBRARY tiff)
SET(TIFF_LIBPATH ${TIFF}/lib)
ENDIF(WITH_TIFF)
ENDIF(WITH_IMAGE_TIFF)
IF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
SET(PLATFORM_CFLAGS " -msse -msse2 ${PLATFORM_CFLAGS}")
@@ -869,11 +871,11 @@ ENDIF(WITH_BUILDINFO)
#-----------------------------------------------------------------------------
# Common.
IF(WITH_OPENJPEG)
IF(WITH_IMAGE_OPENJPEG)
set(OPENJPEG ${CMAKE_SOURCE_DIR}/extern/libopenjpeg)
set(OPENJPEG_INC ${OPENJPEG})
set(OPENJPEG_LIb extern_libopenjpeg)
ENDIF(WITH_OPENJPEG)
ENDIF(WITH_IMAGE_OPENJPEG)
#-----------------------------------------------------------------------------
# Blender WebPlugin

View File

@@ -210,14 +210,36 @@ SetOption('num_jobs', int(env['BF_NUMJOBS']))
print B.bc.OKGREEN + "Build with parallel jobs%s: %s" % (B.bc.ENDC, GetOption('num_jobs'))
print B.bc.OKGREEN + "Build with debug symbols%s: %s" % (B.bc.ENDC, env['BF_DEBUG'])
# BLENDERPATH is a unix only option to enable typical style paths this is
# spesifically a data-dir, which is used a lot but cant replace BF_INSTALLDIR
# because the blender binary is installed in $BF_INSTALLDIR/bin/blender
if 'blenderlite' in B.targets:
target_env_defs = {}
target_env_defs['WITH_BF_GAMEENGINE'] = False
target_env_defs['WITH_BF_OPENAL'] = False
target_env_defs['WITH_BF_OPENEXR'] = False
target_env_defs['WITH_BF_OPENMP'] = False
target_env_defs['WITH_BF_ICONV'] = False
target_env_defs['WITH_BF_INTERNATIONAL'] = False
target_env_defs['WITH_BF_OPENJPEG'] = False
target_env_defs['WITH_BF_FFMPEG'] = False
target_env_defs['WITH_BF_QUICKTIME'] = False
target_env_defs['WITH_BF_REDCODE'] = False
target_env_defs['WITH_BF_DDS'] = False
target_env_defs['WITH_BF_CINEON'] = False
target_env_defs['WITH_BF_HDR'] = False
target_env_defs['WITH_BF_ZLIB'] = False
target_env_defs['WITH_BF_SDL'] = False
target_env_defs['WITH_BF_JPEG'] = False
target_env_defs['WITH_BF_PNG'] = False
target_env_defs['WITH_BF_BULLET'] = False
target_env_defs['WITH_BF_BINRELOC'] = False
target_env_defs['BF_BUILDINFO'] = False
target_env_defs['BF_NO_ELBEEM'] = True
target_env_defs['WITH_BF_PYTHON'] = False
# Merge blenderlite, let command line to override
for k,v in target_env_defs.iteritems():
if k not in B.arguments:
env[k] = v
if env['WITH_BF_FHS']:
BLENDERPATH = os.path.join(env['BF_INSTALLDIR'], 'share', 'blender', env['BF_VERSION'])
else:
BLENDERPATH = env['BF_INSTALLDIR']
if env['WITH_BF_OPENMP'] == 1:
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
@@ -271,34 +293,6 @@ if 'blenderplayer' in B.targets:
if 'blendernogame' in B.targets:
env['WITH_BF_GAMEENGINE'] = False
if 'blenderlite' in B.targets:
target_env_defs = {}
target_env_defs['WITH_BF_GAMEENGINE'] = False
target_env_defs['WITH_BF_OPENAL'] = False
target_env_defs['WITH_BF_OPENEXR'] = False
target_env_defs['WITH_BF_OPENMP'] = False
target_env_defs['WITH_BF_ICONV'] = False
target_env_defs['WITH_BF_INTERNATIONAL'] = False
target_env_defs['WITH_BF_OPENJPEG'] = False
target_env_defs['WITH_BF_FFMPEG'] = False
target_env_defs['WITH_BF_QUICKTIME'] = False
target_env_defs['WITH_BF_REDCODE'] = False
target_env_defs['WITH_BF_DDS'] = False
target_env_defs['WITH_BF_ZLIB'] = False
target_env_defs['WITH_BF_SDL'] = False
target_env_defs['WITH_BF_JPEG'] = False
target_env_defs['WITH_BF_PNG'] = False
target_env_defs['WITH_BF_BULLET'] = False
target_env_defs['WITH_BF_BINRELOC'] = False
target_env_defs['BF_BUILDINFO'] = False
target_env_defs['BF_NO_ELBEEM'] = True
target_env_defs['WITH_BF_PYTHON'] = False
# Merge blenderlite, let command line to override
for k,v in target_env_defs.iteritems():
if k not in B.arguments:
env[k] = v
# disable elbeem (fluidsim) compilation?
if env['BF_NO_ELBEEM'] == 1:
env['CPPFLAGS'].append('-DDISABLE_ELBEEM')
@@ -311,7 +305,7 @@ if env['WITH_BF_SDL'] == False and env['OURPLATFORM'] in ('win32-vc', 'win32-min
# lastly we check for root_build_dir ( we should not do before, otherwise we might do wrong builddir
B.root_build_dir = env['BF_BUILDDIR']
B.doc_build_dir = os.path.join(BLENDERPATH, 'doc')
B.doc_build_dir = os.path.join(env['BF_INSTALLDIR'], 'doc')
if not B.root_build_dir[-1]==os.sep:
B.root_build_dir += os.sep
if not B.doc_build_dir[-1]==os.sep:
@@ -366,8 +360,9 @@ if not os.path.isdir ( B.root_build_dir):
os.makedirs ( B.root_build_dir + 'extern' )
os.makedirs ( B.root_build_dir + 'lib' )
os.makedirs ( B.root_build_dir + 'bin' )
if not os.path.isdir(B.doc_build_dir) and env['WITH_BF_DOCS']:
os.makedirs ( B.doc_build_dir )
# # Docs not working with epy anymore
# if not os.path.isdir(B.doc_build_dir) and env['WITH_BF_DOCS']:
# os.makedirs ( B.doc_build_dir )
Help(opts.GenerateHelpText(env))
@@ -436,10 +431,7 @@ if env['OURPLATFORM']=='darwin':
source=[dp+os.sep+f for f in df]
blenderinstall.append(env.Install(dir=dir,source=source))
else:
if env['WITH_BF_FHS']: dir= os.path.join(env['BF_INSTALLDIR'], 'bin')
else: dir= env['BF_INSTALLDIR']
blenderinstall = env.Install(dir=dir, source=B.program_list)
blenderinstall = env.Install(dir=env['BF_INSTALLDIR'], source=B.program_list)
#-- local path = config files in install dir: installdir\VERSION
#- dont do config and scripts for darwin, it is already in the bundle
@@ -466,15 +458,12 @@ if env['OURPLATFORM']!='darwin':
if 'locale' in dp:
datafileslist.append(os.path.join(dp,f))
if env['WITH_BF_FHS']: dir= os.path.join(*([BLENDERPATH] + ['datafiles'] + dp.split(os.sep)[2:])) # skip bin/.blender
else: dir= os.path.join(*([BLENDERPATH] + [VERSION] + ['datafiles'] + dp.split(os.sep)[1:])) # skip bin
dir= os.path.join(*([env['BF_INSTALLDIR']] + [VERSION] + ['datafiles'] + dp.split(os.sep)[1:])) # skip bin
datafilestargetlist.append(dir + os.sep + f)
else:
dotblendlist.append(os.path.join(dp, f))
if env['WITH_BF_FHS']: dir= os.path.join(*([BLENDERPATH] + ['config'] + dp.split(os.sep)[2:])) # skip bin/.blender
else: dir= os.path.join(*([BLENDERPATH] + [VERSION] + ['config'] + dp.split(os.sep)[1:])) # skip bin
dir= os.path.join(*([env['BF_INSTALLDIR']] + [VERSION] + ['config'] + dp.split(os.sep)[1:])) # skip bin
dottargetlist.append(dir + os.sep + f)
dotblenderinstall = []
@@ -493,8 +482,7 @@ if env['OURPLATFORM']!='darwin':
if '.svn' in dn:
dn.remove('.svn')
if env['WITH_BF_FHS']: dir = BLENDERPATH
else: dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
dir += os.sep + os.path.basename(scriptpath) + dp[len(scriptpath):]
source=[os.path.join(dp, f) for f in df if f[-3:]!='pyc']
@@ -510,7 +498,7 @@ if env['OURPLATFORM']=='linux2':
tn.remove('.svn')
for f in tf:
iconlist.append(os.path.join(tp, f))
icontargetlist.append( os.path.join(*([BLENDERPATH] + tp.split(os.sep)[2:] + [f])) )
icontargetlist.append( os.path.join(*([env['BF_INSTALLDIR']] + tp.split(os.sep)[2:] + [f])) )
iconinstall = []
for targetdir,srcfile in zip(icontargetlist, iconlist):
@@ -537,24 +525,24 @@ for tp, tn, tf in os.walk('release/plugins'):
df = tp[8:] # remove 'release/'
for f in tf:
pluglist.append(os.path.join(tp, f))
plugtargetlist.append( os.path.join(BLENDERPATH, df, f) )
plugtargetlist.append( os.path.join(env['BF_INSTALLDIR'], df, f) )
# header files for plugins
pluglist.append('source/blender/blenpluginapi/documentation.h')
plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'documentation.h'))
plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], 'plugins', 'include', 'documentation.h'))
pluglist.append('source/blender/blenpluginapi/externdef.h')
plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'externdef.h'))
plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], 'plugins', 'include', 'externdef.h'))
pluglist.append('source/blender/blenpluginapi/floatpatch.h')
plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'floatpatch.h'))
plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], 'plugins', 'include', 'floatpatch.h'))
pluglist.append('source/blender/blenpluginapi/iff.h')
plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'iff.h'))
plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], 'plugins', 'include', 'iff.h'))
pluglist.append('source/blender/blenpluginapi/plugin.h')
plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'plugin.h'))
plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], 'plugins', 'include', 'plugin.h'))
pluglist.append('source/blender/blenpluginapi/util.h')
plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'util.h'))
plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], 'plugins', 'include', 'util.h'))
pluglist.append('source/blender/blenpluginapi/plugin.DEF')
plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'plugin.def'))
plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], 'plugins', 'include', 'plugin.def'))
plugininstall = []
for targetdir,srcfile in zip(plugtargetlist, pluglist):
@@ -569,7 +557,7 @@ for tp, tn, tf in os.walk('release/text'):
for f in tf:
textlist.append(tp+os.sep+f)
textinstall = env.Install(dir=BLENDERPATH, source=textlist)
textinstall = env.Install(dir=env['BF_INSTALLDIR'], source=textlist)
if env['OURPLATFORM']=='darwin':
allinstall = [blenderinstall, plugininstall, textinstall]
@@ -662,17 +650,3 @@ Default(B.program_list)
if not env['WITHOUT_BF_INSTALL']:
Default(installtarget)
#------------ EPYDOC
if env['WITH_BF_DOCS']:
try:
import epydoc
except ImportError:
epydoc = None
if epydoc:
SConscript('source/gameengine/PyDoc/SConscript')
else:
print "No epydoc install detected, Python API and Gameengine API Docs will not be generated "

View File

@@ -58,12 +58,12 @@ MACRO(SETUP_LIBDIRS)
IF(WITH_FFMPEG)
LINK_DIRECTORIES(${FFMPEG_LIBPATH})
ENDIF(WITH_FFMPEG)
IF(WITH_OPENEXR)
IF(WITH_IMAGE_OPENEXR)
LINK_DIRECTORIES(${OPENEXR_LIBPATH})
ENDIF(WITH_OPENEXR)
IF(WITH_TIFF)
ENDIF(WITH_IMAGE_OPENEXR)
IF(WITH_IMAGE_TIFF)
LINK_DIRECTORIES(${TIFF_LIBPATH})
ENDIF(WITH_TIFF)
ENDIF(WITH_IMAGE_TIFF)
IF(WITH_LCMS)
LINK_DIRECTORIES(${LCMS_LIBPATH})
ENDIF(WITH_LCMS)
@@ -140,10 +140,10 @@ MACRO(SETUP_LIBLINKS
IF(WITH_QUICKTIME)
TARGET_LINK_LIBRARIES(${target} ${QUICKTIME_LIB})
ENDIF(WITH_QUICKTIME)
IF(WITH_TIFF)
IF(WITH_IMAGE_TIFF)
TARGET_LINK_LIBRARIES(${target} ${TIFF_LIBRARY})
ENDIF(WITH_TIFF)
IF(WITH_OPENEXR)
ENDIF(WITH_IMAGE_TIFF)
IF(WITH_IMAGE_OPENEXR)
IF(WIN32)
FOREACH(loop_var ${OPENEXR_LIB})
TARGET_LINK_LIBRARIES(${target} debug ${loop_var}_d)
@@ -152,7 +152,7 @@ MACRO(SETUP_LIBLINKS
ELSE(WIN32)
TARGET_LINK_LIBRARIES(${target} ${OPENEXR_LIB})
ENDIF(WIN32)
ENDIF(WITH_OPENEXR)
ENDIF(WITH_IMAGE_OPENEXR)
IF(WITH_LCMS)
TARGET_LINK_LIBRARIES(${target} ${LCMS_LIBRARY})
ENDIF(WITH_LCMS)
@@ -198,6 +198,7 @@ MACRO(TEST_SSE_SUPPORT)
SUPPORT_SSE_BUILD)
ENDMACRO(TEST_SSE_SUPPORT)
MACRO(GET_BLENDER_VERSION)
FILE(READ ${CMAKE_SOURCE_DIR}/source/blender/blenkernel/BKE_blender.h CONTENT)
STRING(REGEX REPLACE "\n" ";" CONTENT "${CONTENT}")

View File

@@ -89,7 +89,6 @@ ifeq ($(OS),darwin)
CCFLAGS += -pipe -fPIC -funsigned-char
endif
CFLAGS += -arch $(MACOSX_ARCHITECTURE) #-isysroot $(MACOSX_SDK) -mmacosx-version-min=$(MACOSX_MIN_VERS)
CCFLAGS += -arch $(MACOSX_ARCHITECTURE) #-isysroot $(MACOSX_SDK) -mmacosx-version-min=$(MACOSX_MIN_VERS)

View File

@@ -160,6 +160,17 @@ ifndef CONFIG_GUESS
export WITH_TIFF ?= true
#enable raytracing optimization (currently only for i386 and x86_64)
ifeq ($(CPU),powerpc)
export WITH_BF_RAYOPTIMIZATION ?= false
else
export WITH_BF_RAYOPTIMIZATION ?= true
endif
export WITH_LCMS ?= false
export WITH_CINEON ?= true
export WITH_HDR ?= true
# Compare recreated .mo files with committed ones
export BF_VERIFY_MO_FILES ?= true
@@ -622,6 +633,11 @@ ifndef CONFIG_GUESS
# default tiff libs
export NAN_TIFF_LIBS ?= $(NAN_TIFF)/lib/libtiff.a
# default path to lcms, may be overidden in platform sections above or in user-def.mk
export BF_LCMS ?= $(LCGDIR)/lcms
export BF_LCMS_INC ?= $(BF_LCMS)/include
export BF_LCMS_LIBS ?= $(BF_LCMS)/lib/liblcms.a
endif # CONFIG_GUESS
# Don't want to build the gameengine?

View File

@@ -195,4 +195,8 @@ ifeq ($(WITH_TIFF),true)
LLIBS += $(NAN_TIFF_LIBS)
endif
ifeq ($(WITH_LCMS),true)
LLIBS += $(BF_LCMS_LIBS)
endif
LLIBS += $(NAN_PYTHON_LIB)

View File

@@ -194,8 +194,6 @@ CXX_WARN = []
LLIBS = ['ws2_32', 'vfw32', 'winmm', 'kernel32', 'user32', 'gdi32', 'comdlg32', 'advapi32', 'shfolder', 'shell32', 'ole32', 'oleaut32', 'uuid']
WITH_BF_DOCS=False
BF_DEBUG=False
BF_BSC=False

View File

@@ -501,10 +501,7 @@ def AppIt(target=None, source=None, env=None):
installdir = env['BF_INSTALLDIR']
print("compiled architecture: %s"%(osxarch))
print("Installing to %s"%(installdir))
if libdir == '../lib/darwin-9.x.universal':
python_zip = 'python_' + osxarch + '.zip' # set specific python_arch.zip
else:
python_zip = 'python.zip' # compatibility for darwin8 python.zip
print("unzipping to app-bundle: %s"%(python_zip))
bldroot = env.Dir('.').abspath
binary = env['BINARYKIND']
@@ -571,8 +568,7 @@ def UnixPyBundle(target=None, source=None, env=None):
print 'Install command:', cmd
commands.getoutput(cmd)
if env['WITH_BF_FHS']: dir = os.path.join(env['BF_INSTALLDIR'], 'share', 'blender', env['BF_VERSION']) # BLENDERPATH
else: dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
dir = os.path.join(env['BF_INSTALLDIR'], VERSION)
py_src = env.subst( env['BF_PYTHON_LIBPATH'] + '/python'+env['BF_PYTHON_VERSION'] )
py_target = env.subst( dir + '/python/lib/python'+env['BF_PYTHON_VERSION'] )

View File

@@ -36,7 +36,7 @@ def validate_arguments(args, bc):
'WITH_BF_SNDFILE', 'BF_SNDFILE', 'BF_SNDFILE_INC', 'BF_SNDFILE_LIB', 'BF_SNDFILE_LIBPATH',
'BF_PTHREADS', 'BF_PTHREADS_INC', 'BF_PTHREADS_LIB', 'BF_PTHREADS_LIBPATH',
'WITH_BF_OPENEXR', 'BF_OPENEXR', 'BF_OPENEXR_INC', 'BF_OPENEXR_LIB', 'BF_OPENEXR_LIBPATH', 'WITH_BF_STATICOPENEXR', 'BF_OPENEXR_LIB_STATIC',
'WITH_BF_DDS',
'WITH_BF_DDS', 'WITH_BF_CINEON', 'WITH_BF_HDR',
'WITH_BF_FFMPEG', 'BF_FFMPEG_LIB','BF_FFMPEG_EXTRA', 'BF_FFMPEG', 'BF_FFMPEG_INC',
'WITH_BF_OGG', 'BF_OGG', 'BF_OGG_LIB',
'WITH_BF_JPEG', 'BF_JPEG', 'BF_JPEG_INC', 'BF_JPEG_LIB', 'BF_JPEG_LIBPATH',
@@ -78,7 +78,6 @@ def validate_arguments(args, bc):
'WITH_BF_DOCS',
'BF_NUMJOBS',
'BF_MSVS',
'WITH_BF_FHS',
'BF_VERSION',
'BF_GHOST_DEBUG',
'WITH_BF_RAYOPTIMIZATION',
@@ -224,7 +223,11 @@ def read_opts(env, cfg, args):
('BF_OPENEXR_LIBPATH', 'OPENEXR library path', ''),
('BF_OPENEXR_LIB_STATIC', 'OPENEXR static library', ''),
(BoolVariable('WITH_BF_DDS', 'Use DDS if true', True)),
(BoolVariable('WITH_BF_DDS', 'Support DDS image format if true', True)),
(BoolVariable('WITH_BF_CINEON', 'Support CINEON and DPX image formats if true', True)),
(BoolVariable('WITH_BF_HDR', 'Support HDR image formats if true', True)),
(BoolVariable('WITH_BF_FFMPEG', 'Use FFMPEG if true', False)),
('BF_FFMPEG', 'FFMPEG base path', ''),
@@ -428,13 +431,12 @@ def read_opts(env, cfg, args):
('BF_X264_CONFIG', 'configuration flags for x264', ''),
('BF_XVIDCORE_CONFIG', 'configuration flags for xvidcore', ''),
(BoolVariable('WITH_BF_DOCS', 'Generate API documentation', False)),
# (BoolVariable('WITH_BF_DOCS', 'Generate API documentation', False)),
('BF_CONFIG', 'SCons python config file used to set default options', 'user_config.py'),
('BF_NUMJOBS', 'Number of build processes to spawn', '1'),
('BF_MSVS', 'Generate MSVS project files and solution', False),
(BoolVariable('WITH_BF_FHS', 'Use the Unix "Filesystem Hierarchy Standard" rather then a redistributable directory layout', False)),
('BF_VERSION', 'The root path for Unix (non-apple)', '2.5'),
(BoolVariable('BF_UNIT_TEST', 'Build with unit test support.', False)),

View File

@@ -34,9 +34,9 @@ ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
ADD_SUBDIRECTORY(glew)
IF(WITH_OPENJPEG)
IF(WITH_IMAGE_OPENJPEG)
ADD_SUBDIRECTORY(libopenjpeg)
ENDIF(WITH_OPENJPEG)
ENDIF(WITH_IMAGE_OPENJPEG)
IF(WITH_LZO)
ADD_SUBDIRECTORY(lzo)

View File

@@ -38,8 +38,8 @@ ADD_SUBDIRECTORY(boolop)
ADD_SUBDIRECTORY(opennl)
ADD_SUBDIRECTORY(smoke)
IF(WITH_ELBEEM)
IF(WITH_FLUID)
ADD_SUBDIRECTORY(elbeem)
ENDIF(WITH_ELBEEM)
ENDIF(WITH_FLUID)
ADD_SUBDIRECTORY(bsp)

File diff suppressed because it is too large Load Diff

View File

@@ -922,7 +922,7 @@ def make_kf_obj_node(obj, name_to_id):
"""
# import BPyMessages
def save_3ds(filename, context):
def write(filename, context):
'''Save the Blender scene to a 3ds file.'''
# Time the export
@@ -1107,12 +1107,7 @@ def save_3ds(filename, context):
#primary.dump()
# if __name__=='__main__':
# if struct:
# Blender.Window.FileSelector(save_3ds, "Export 3DS", Blender.sys.makename(ext='.3ds'))
# else:
# Blender.Draw.PupMenu("Error%t|This script requires a full python installation")
# # save_3ds('/test_b.3ds')
# # write('/test_b.3ds')
from bpy.props import *
class Export3DS(bpy.types.Operator):
'''Export to 3DS file format (.3ds)'''
@@ -1127,7 +1122,10 @@ class Export3DS(bpy.types.Operator):
check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, options={'HIDDEN'})
def execute(self, context):
save_3ds(self.properties.filepath, context)
filepath = self.properties.filepath
filepath = bpy.path.ensure_ext(filepath, ".3ds")
write(filepath, context)
return {'FINISHED'}
def invoke(self, context, event):
@@ -1135,10 +1133,10 @@ class Export3DS(bpy.types.Operator):
wm.add_fileselect(self)
return {'RUNNING_MODAL'}
def poll(self, context): # Poll isnt working yet
@classmethod
def poll(cls, context): # Poll isnt working yet
return context.active_object != None
# Add to a menu
def menu_func(self, context):
default_path = os.path.splitext(bpy.data.filepath)[0] + ".3ds"
@@ -1146,11 +1144,9 @@ def menu_func(self, context):
def register():
bpy.types.register(Export3DS)
bpy.types.INFO_MT_file_export.append(menu_func)
def unregister():
bpy.types.unregister(Export3DS)
bpy.types.INFO_MT_file_export.remove(menu_func)
if __name__ == "__main__":

View File

@@ -75,7 +75,7 @@ def copy_images(dest_dir, textures):
image_paths = set()
for tex in textures:
image_paths.add(bpy.utils.expandpath(tex.filepath))
image_paths.add(bpy.path.abspath(tex.filepath))
# Now copy images
copyCount = 0
@@ -176,7 +176,7 @@ def sane_name(data, dct):
name = 'unnamed' # blank string, ASKING FOR TROUBLE!
else:
name = bpy.utils.clean_name(name) # use our own
name = bpy.path.clean_name(name) # use our own
while name in iter(dct.values()): name = increment_string(name)
@@ -200,14 +200,14 @@ def sane_groupname(data): return sane_name(data, sane_name_mapping_group)
# FORCE_CWD - dont use the basepath, just add a ./ to the filename.
# use when we know the file will be in the basepath.
# '''
# fname = bpy.utils.expandpath(fname_orig)
# fname = bpy.path.abspath(fname_orig)
# # fname = Blender.sys.expandpath(fname_orig)
# fname_strip = os.path.basename(fname)
# # fname_strip = strip_path(fname)
# if FORCE_CWD:
# fname_rel = '.' + os.sep + fname_strip
# else:
# fname_rel = bpy.utils.relpath(fname, basepath)
# fname_rel = bpy.path.relpath(fname, basepath)
# # fname_rel = Blender.sys.relpath(fname, basepath)
# if fname_rel.startswith('//'): fname_rel = '.' + os.sep + fname_rel[2:]
# return fname, fname_strip, fname_rel
@@ -354,8 +354,8 @@ def write(filename, batch_objects = None, \
new_fbxpath = fbxpath # own dir option modifies, we need to keep an original
for data in data_seq: # scene or group
newname = BATCH_FILE_PREFIX + bpy.utils.clean_name(data.name)
# newname = BATCH_FILE_PREFIX + BPySys.bpy.utils.clean_name(data.name)
newname = BATCH_FILE_PREFIX + bpy.path.clean_name(data.name)
# newname = BATCH_FILE_PREFIX + BPySys.bpy.path.clean_name(data.name)
if BATCH_OWN_DIR:
@@ -1250,7 +1250,7 @@ def write(filename, batch_objects = None, \
file.write('\n\t}')
def copy_image(image):
fn = bpy.utils.expandpath(image.filepath)
fn = bpy.path.abspath(image.filepath)
fn_strip = os.path.basename(fn)
if EXP_IMAGE_COPY:
@@ -3361,20 +3361,24 @@ class ExportFBX(bpy.types.Operator):
BATCH_FILE_PREFIX = StringProperty(name="Prefix", description="Prefix each file with this name", maxlen=1024, default="")
def poll(self, context):
@classmethod
def poll(cls, context):
return context.active_object
def execute(self, context):
if not self.properties.filepath:
raise Exception("filepath not set")
filepath = self.properties.filepath
filepath = bpy.path.ensure_ext(filepath, ".fbx")
GLOBAL_MATRIX = mtx4_identity
GLOBAL_MATRIX[0][0] = GLOBAL_MATRIX[1][1] = GLOBAL_MATRIX[2][2] = self.properties.TX_SCALE
if self.properties.TX_XROT90: GLOBAL_MATRIX = mtx4_x90n * GLOBAL_MATRIX
if self.properties.TX_YROT90: GLOBAL_MATRIX = mtx4_y90n * GLOBAL_MATRIX
if self.properties.TX_ZROT90: GLOBAL_MATRIX = mtx4_z90n * GLOBAL_MATRIX
write(self.properties.filepath,
write(filepath,
None, # XXX
context,
self.properties.EXP_OBS_SELECTED,
@@ -3394,7 +3398,8 @@ class ExportFBX(bpy.types.Operator):
self.properties.BATCH_ENABLE,
self.properties.BATCH_GROUP,
self.properties.BATCH_FILE_PREFIX,
self.properties.BATCH_OWN_DIR)
self.properties.BATCH_OWN_DIR,
)
return {'FINISHED'}
@@ -3412,7 +3417,7 @@ class ExportFBX(bpy.types.Operator):
# NOTES (all line numbers correspond to original export_fbx.py (under release/scripts)
# - Draw.PupMenu alternative in 2.5?, temporarily replaced PupMenu with print
# - get rid of bpy.utils.clean_name somehow
# - get rid of bpy.path.clean_name somehow
# + fixed: isinstance(inst, bpy.types.*) doesn't work on RNA objects: line 565
# + get rid of BPyObject_getObjectArmature, move it in RNA?
# - BATCH_ENABLE and BATCH_GROUP options: line 327
@@ -3427,7 +3432,7 @@ class ExportFBX(bpy.types.Operator):
# - bpy.data.remove_scene: line 366
# - bpy.sys.time move to bpy.sys.util?
# - new scene creation, activation: lines 327-342, 368
# - uses bpy.utils.expandpath, *.relpath - replace at least relpath
# - uses bpy.path.abspath, *.relpath - replace at least relpath
# SMALL or COSMETICAL
# - find a way to get blender version, and put it in bpy.util?, old was Blender.Get('version')
@@ -3439,12 +3444,10 @@ def menu_func(self, context):
def register():
bpy.types.register(ExportFBX)
bpy.types.INFO_MT_file_export.append(menu_func)
def unregister():
bpy.types.unregister(ExportFBX)
bpy.types.INFO_MT_file_export.remove(menu_func)
if __name__ == "__main__":

View File

@@ -165,15 +165,23 @@ class ExportMDD(bpy.types.Operator):
frame_start = IntProperty(name="Start Frame", description="Start frame for baking", min=minframe, max=maxframe, default=1)
frame_end = IntProperty(name="End Frame", description="End frame for baking", min=minframe, max=maxframe, default=250)
def poll(self, context):
@classmethod
def poll(cls, context):
ob = context.active_object
return (ob and ob.type == 'MESH')
def execute(self, context):
if not self.properties.filepath:
raise Exception("filename not set")
write(self.properties.filepath, context.scene, context.active_object,
self.properties.frame_start, self.properties.frame_end, self.properties.fps)
filepath = self.properties.filepath
filepath = bpy.path.ensure_ext(filepath, ".mdd")
write(filepath,
context.scene,
context.active_object,
self.properties.frame_start,
self.properties.frame_end,
self.properties.fps,
)
return {'FINISHED'}
def invoke(self, context, event):
@@ -189,12 +197,10 @@ def menu_func(self, context):
def register():
bpy.types.register(ExportMDD)
bpy.types.INFO_MT_file_export.append(menu_func)
def unregister():
bpy.types.unregister(ExportMDD)
bpy.types.INFO_MT_file_export.remove(menu_func)
if __name__ == "__main__":

View File

@@ -18,13 +18,6 @@
# <pep8 compliant>
"""
Name: 'Wavefront (.obj)...'
Blender: 248
Group: 'Export'
Tooltip: 'Save a Wavefront OBJ File'
"""
__author__ = "Campbell Barton, Jiri Hnidek, Paolo Ciccone"
__url__ = ['http://wiki.blender.org/index.php/Scripts/Manual/Export/wavefront_obj', 'www.blender.org', 'blenderartists.org']
__version__ = "1.21"
@@ -73,7 +66,7 @@ def write_mtl(scene, filepath, copy_images, mtl_dict):
dest_dir = os.path.dirname(filepath)
def copy_image(image):
fn = bpy.utils.expandpath(image.filepath)
fn = bpy.path.abspath(image.filepath)
fn_strip = os.path.basename(fn)
if copy_images:
rel = fn_strip
@@ -189,7 +182,7 @@ def copy_images(dest_dir):
copyCount = 0
# for bImage in uniqueImages.values():
# image_path = bpy.utils.expandpath(bImage.filepath)
# image_path = bpy.path.abspath(bImage.filepath)
# if bpy.sys.exists(image_path):
# # Make a name for the target path.
# dest_image_path = dest_dir + image_path.split('\\')[-1].split('/')[-1]
@@ -797,7 +790,7 @@ def write(filepath, objects, scene,
print("OBJ Export time: %.2f" % (time.clock() - time1))
# print "OBJ Export time: %.2f" % (sys.time() - time1)
def do_export(filepath, context,
def write(filepath, context,
EXPORT_APPLY_MODIFIERS = True, # not used
EXPORT_ROTX90 = True, # wrong
EXPORT_TRI = False, # ok
@@ -844,7 +837,7 @@ def do_export(filepath, context,
orig_frame = scn.frame_current
if EXPORT_ALL_SCENES: # Add scene name into the context_name
context_name[1] = '_%s' % bpy.utils.clean_name(scn.name) # WARNING, its possible that this could cause a collision. we could fix if were feeling parranoied.
context_name[1] = '_%s' % bpy.path.clean_name(scn.name) # WARNING, its possible that this could cause a collision. we could fix if were feeling parranoied.
# Export an animation?
if EXPORT_ANIMATION:
@@ -934,10 +927,9 @@ class ExportOBJ(bpy.types.Operator):
def execute(self, context):
filepath = self.properties.filepath
if not filepath.lower().endswith(".obj"):
filepath += ".obj"
filepath = bpy.path.ensure_ext(filepath, ".obj")
do_export(filepath, context,
write(filepath, context,
EXPORT_TRI=self.properties.use_triangles,
EXPORT_EDGES=self.properties.use_edges,
EXPORT_NORMALS=self.properties.use_normals,
@@ -954,7 +946,8 @@ class ExportOBJ(bpy.types.Operator):
EXPORT_POLYGROUPS=self.properties.use_vertex_groups,
EXPORT_CURVE_AS_NURBS=self.properties.use_nurbs,
EXPORT_SEL_ONLY=self.properties.use_selection,
EXPORT_ALL_SCENES=self.properties.use_all_scenes)
EXPORT_ALL_SCENES=self.properties.use_all_scenes,
)
return {'FINISHED'}
@@ -970,11 +963,9 @@ def menu_func(self, context):
def register():
bpy.types.register(ExportOBJ)
bpy.types.INFO_MT_file_export.append(menu_func)
def unregister():
bpy.types.unregister(ExportOBJ)
bpy.types.INFO_MT_file_export.remove(menu_func)

View File

@@ -275,16 +275,15 @@ class ExportPLY(bpy.types.Operator):
use_uvs = BoolProperty(name="UVs", description="Exort the active UV layer", default=True)
use_colors = BoolProperty(name="Vertex Colors", description="Exort the active vertex color layer", default=True)
def poll(self, context):
@classmethod
def poll(cls, context):
return context.active_object != None
def execute(self, context):
# print("Selected: " + context.active_object.name)
filepath = self.properties.filepath
filepath = bpy.path.ensure_ext(filepath, ".ply")
if not self.properties.filepath:
raise Exception("filename not set")
write(self.properties.filepath, context.scene, context.active_object,\
write(filepath, context.scene, context.active_object,\
EXPORT_APPLY_MODIFIERS=self.properties.use_modifiers,
EXPORT_NORMALS=self.properties.use_normals,
EXPORT_UV=self.properties.use_uvs,
@@ -317,12 +316,10 @@ def menu_func(self, context):
def register():
bpy.types.register(ExportPLY)
bpy.types.INFO_MT_file_export.append(menu_func)
def unregister():
bpy.types.unregister(ExportPLY)
bpy.types.INFO_MT_file_export.remove(menu_func)
if __name__ == "__main__":

View File

@@ -794,7 +794,7 @@ class x3d_class:
pic = tex.image
# using .expandpath just in case, os.path may not expect //
basename = os.path.basename(bpy.utils.expandpath(pic.filepath))
basename = os.path.basename(bpy.path.abspath(pic.filepath))
pic = alltextures[i].image
# pic = alltextures[i].getImage()
@@ -1140,7 +1140,7 @@ class x3d_class:
# Callbacks, needed before Main
##########################################################
def x3d_export(filename,
def write(filename,
context,
EXPORT_APPLY_MODIFIERS=False,
EXPORT_TRI=False,
@@ -1175,47 +1175,6 @@ def x3d_export(filename,
)
def x3d_export_ui(filename):
if not filename.endswith(extension):
filename += extension
#if _safeOverwrite and sys.exists(filename):
# result = Draw.PupMenu("File Already Exists, Overwrite?%t|Yes%x1|No%x0")
#if(result != 1):
# return
# Get user options
EXPORT_APPLY_MODIFIERS = Draw.Create(1)
EXPORT_TRI = Draw.Create(0)
EXPORT_GZIP = Draw.Create( filename.lower().endswith('.x3dz') )
# Get USER Options
pup_block = [\
('Apply Modifiers', EXPORT_APPLY_MODIFIERS, 'Use transformed mesh data from each object.'),\
('Triangulate', EXPORT_TRI, 'Triangulate quads.'),\
('Compress', EXPORT_GZIP, 'GZip the resulting file, requires a full python install'),\
]
if not Draw.PupBlock('Export...', pup_block):
return
Blender.Window.EditMode(0)
Blender.Window.WaitCursor(1)
x3d_export(filename,\
EXPORT_APPLY_MODIFIERS = EXPORT_APPLY_MODIFIERS.val,\
EXPORT_TRI = EXPORT_TRI.val,\
EXPORT_GZIP = EXPORT_GZIP.val\
)
Blender.Window.WaitCursor(0)
#########################################################
# main routine
#########################################################
from bpy.props import *
class ExportX3D(bpy.types.Operator):
@@ -1233,7 +1192,16 @@ class ExportX3D(bpy.types.Operator):
compress = BoolProperty(name="Compress", description="GZip the resulting file, requires a full python install", default=False)
def execute(self, context):
x3d_export(self.properties.filepath, context, self.properties.apply_modifiers, self.properties.triangulate, self.properties.compress)
filepath = self.properties.filepath
filepath = bpy.path.ensure_ext(filepath, ".x3d")
write(filepath,
context,
self.properties.apply_modifiers,
self.properties.triangulate,
self.properties.compress,
)
return {'FINISHED'}
def invoke(self, context, event):
@@ -1248,11 +1216,9 @@ def menu_func(self, context):
def register():
bpy.types.register(ExportX3D)
bpy.types.INFO_MT_file_export.append(menu_func)
def unregister():
bpy.types.unregister(ExportX3D)
bpy.types.INFO_MT_file_export.remove(menu_func)
# NOTES

View File

@@ -612,12 +612,10 @@ def menu_func(self, context):
def register():
bpy.types.register(BvhImporter)
bpy.types.INFO_MT_file_import.append(menu_func)
def unregister():
bpy.types.unregister(BvhImporter)
bpy.types.INFO_MT_file_import.remove(menu_func)
if __name__ == "__main__":

View File

@@ -1032,11 +1032,9 @@ def menu_func(self, context):
self.layout.operator(IMPORT_OT_autodesk_3ds.bl_idname, text="3D Studio (.3ds)")
def register():
bpy.types.register(IMPORT_OT_autodesk_3ds)
bpy.types.INFO_MT_file_import.append(menu_func)
def unregister():
bpy.types.unregister(IMPORT_OT_autodesk_3ds)
bpy.types.INFO_MT_file_import.remove(menu_func)
# NOTES:

View File

@@ -1606,11 +1606,9 @@ def menu_func(self, context):
def register():
bpy.types.register(IMPORT_OT_obj)
bpy.types.INFO_MT_file_import.append(menu_func)
def unregister():
bpy.types.unregister(IMPORT_OT_obj)
bpy.types.INFO_MT_file_import.remove(menu_func)

View File

@@ -120,7 +120,8 @@ class importMDD(bpy.types.Operator):
#fps = IntProperty(name="Frames Per Second", description="Number of frames/second", min=minfps, max=maxfps, default=25)
frame_start = IntProperty(name="Start Frame", description="Start frame for inserting animation", min=minframe, max=maxframe, default=0)
def poll(self, context):
@classmethod
def poll(cls, context):
ob = context.active_object
return (ob and ob.type == 'MESH')
@@ -143,12 +144,10 @@ def menu_func(self, context):
def register():
bpy.types.register(importMDD)
bpy.types.INFO_MT_file_import.append(menu_func)
def unregister():
bpy.types.unregister(importMDD)
bpy.types.INFO_MT_file_import.remove(menu_func)
if __name__ == "__main__":

View File

@@ -49,7 +49,7 @@ def addPointCache(job, ob, point_cache, default_path):
if name == "":
name = "".join(["%02X" % ord(c) for c in ob.name])
cache_path = bpy.utils.expandpath(point_cache.filepath) if point_cache.external else default_path
cache_path = bpy.path.abspath(point_cache.filepath) if point_cache.external else default_path
index = "%02i" % point_cache.index
@@ -113,7 +113,7 @@ def clientSendJob(conn, scene, anim = False):
# LIBRARIES
###########################
for lib in bpy.data.libraries:
file_path = bpy.utils.expandpath(lib.filepath)
file_path = bpy.path.abspath(lib.filepath)
if os.path.exists(file_path):
job.addFile(file_path)
@@ -122,7 +122,7 @@ def clientSendJob(conn, scene, anim = False):
###########################
for image in bpy.data.images:
if image.source == "FILE" and not image.packed_file:
file_path = bpy.utils.expandpath(image.filepath)
file_path = bpy.path.abspath(image.filepath)
if os.path.exists(file_path):
job.addFile(file_path)
@@ -139,7 +139,7 @@ def clientSendJob(conn, scene, anim = False):
for object in bpy.data.objects:
for modifier in object.modifiers:
if modifier.type == 'FLUID_SIMULATION' and modifier.settings.type == "DOMAIN":
addFluidFiles(job, bpy.utils.expandpath(modifier.settings.path))
addFluidFiles(job, bpy.path.abspath(modifier.settings.path))
elif modifier.type == "CLOTH":
addPointCache(job, object, modifier.point_cache, default_path)
elif modifier.type == "SOFT_BODY":
@@ -149,7 +149,7 @@ def clientSendJob(conn, scene, anim = False):
if modifier.domain_settings.highres:
addPointCache(job, object, modifier.domain_settings.point_cache_high, default_path)
elif modifier.type == "MULTIRES" and modifier.external:
file_path = bpy.utils.expandpath(modifier.filepath)
file_path = bpy.path.abspath(modifier.filepath)
job.addFile(file_path)
# particles modifier are stupid and don't contain data
@@ -189,7 +189,6 @@ def clientSendJob(conn, scene, anim = False):
def requestResult(conn, job_id, frame):
conn.request("GET", renderURL(job_id, frame))
@rnaType
class NetworkRenderEngine(bpy.types.RenderEngine):
bl_idname = 'NET_RENDER'
bl_label = "Network Render"

View File

@@ -26,13 +26,13 @@ from netrender.utils import *
import netrender.client as client
import netrender.model
@rnaType
class RENDER_OT_netslave_bake(bpy.types.Operator):
'''NEED DESCRIPTION'''
bl_idname = "render.netslavebake"
bl_label = "Bake all in file"
def poll(self, context):
@classmethod
def poll(cls, context):
return True
def execute(self, context):
@@ -84,13 +84,13 @@ class RENDER_OT_netslave_bake(bpy.types.Operator):
def invoke(self, context, event):
return self.execute(context)
@rnaType
class RENDER_OT_netclientanim(bpy.types.Operator):
'''Start rendering an animation on network'''
bl_idname = "render.netclientanim"
bl_label = "Animation on network"
def poll(self, context):
@classmethod
def poll(cls, context):
return True
def execute(self, context):
@@ -111,13 +111,13 @@ class RENDER_OT_netclientanim(bpy.types.Operator):
def invoke(self, context, event):
return self.execute(context)
@rnaType
class RENDER_OT_netclientrun(bpy.types.Operator):
'''Start network rendering service'''
bl_idname = "render.netclientstart"
bl_label = "Start Service"
def poll(self, context):
@classmethod
def poll(cls, context):
return True
def execute(self, context):
@@ -128,13 +128,13 @@ class RENDER_OT_netclientrun(bpy.types.Operator):
def invoke(self, context, event):
return self.execute(context)
@rnaType
class RENDER_OT_netclientsend(bpy.types.Operator):
'''Send Render Job to the Network'''
bl_idname = "render.netclientsend"
bl_label = "Send job"
def poll(self, context):
@classmethod
def poll(cls, context):
return True
def execute(self, context):
@@ -158,13 +158,13 @@ class RENDER_OT_netclientsend(bpy.types.Operator):
def invoke(self, context, event):
return self.execute(context)
@rnaType
class RENDER_OT_netclientsendframe(bpy.types.Operator):
'''Send Render Job with current frame to the Network'''
bl_idname = "render.netclientsendframe"
bl_label = "Send current frame job"
def poll(self, context):
@classmethod
def poll(cls, context):
return True
def execute(self, context):
@@ -188,13 +188,13 @@ class RENDER_OT_netclientsendframe(bpy.types.Operator):
def invoke(self, context, event):
return self.execute(context)
@rnaType
class RENDER_OT_netclientstatus(bpy.types.Operator):
'''Refresh the status of the current jobs'''
bl_idname = "render.netclientstatus"
bl_label = "Client Status"
def poll(self, context):
@classmethod
def poll(cls, context):
return True
def execute(self, context):
@@ -228,13 +228,13 @@ class RENDER_OT_netclientstatus(bpy.types.Operator):
def invoke(self, context, event):
return self.execute(context)
@rnaType
class RENDER_OT_netclientblacklistslave(bpy.types.Operator):
'''Operator documentation text, will be used for the operator tooltip and python docs.'''
bl_idname = "render.netclientblacklistslave"
bl_label = "Client Blacklist Slave"
def poll(self, context):
@classmethod
def poll(cls, context):
return True
def execute(self, context):
@@ -258,13 +258,13 @@ class RENDER_OT_netclientblacklistslave(bpy.types.Operator):
def invoke(self, context, event):
return self.execute(context)
@rnaType
class RENDER_OT_netclientwhitelistslave(bpy.types.Operator):
'''Operator documentation text, will be used for the operator tooltip and python docs.'''
bl_idname = "render.netclientwhitelistslave"
bl_label = "Client Whitelist Slave"
def poll(self, context):
@classmethod
def poll(cls, context):
return True
def execute(self, context):
@@ -289,13 +289,13 @@ class RENDER_OT_netclientwhitelistslave(bpy.types.Operator):
return self.execute(context)
@rnaType
class RENDER_OT_netclientslaves(bpy.types.Operator):
'''Refresh status about available Render slaves'''
bl_idname = "render.netclientslaves"
bl_label = "Client Slaves"
def poll(self, context):
@classmethod
def poll(cls, context):
return True
def execute(self, context):
@@ -334,13 +334,13 @@ class RENDER_OT_netclientslaves(bpy.types.Operator):
def invoke(self, context, event):
return self.execute(context)
@rnaType
class RENDER_OT_netclientcancel(bpy.types.Operator):
'''Cancel the selected network rendering job.'''
bl_idname = "render.netclientcancel"
bl_label = "Client Cancel"
def poll(self, context):
@classmethod
def poll(cls, context):
netsettings = context.scene.network_render
return netsettings.active_job_index >= 0 and len(netsettings.jobs) > 0
@@ -363,13 +363,13 @@ class RENDER_OT_netclientcancel(bpy.types.Operator):
def invoke(self, context, event):
return self.execute(context)
@rnaType
class RENDER_OT_netclientcancelall(bpy.types.Operator):
'''Cancel all running network rendering jobs.'''
bl_idname = "render.netclientcancelall"
bl_label = "Client Cancel All"
def poll(self, context):
@classmethod
def poll(cls, context):
return True
def execute(self, context):
@@ -390,13 +390,13 @@ class RENDER_OT_netclientcancelall(bpy.types.Operator):
def invoke(self, context, event):
return self.execute(context)
@rnaType
class netclientdownload(bpy.types.Operator):
'''Download render results from the network'''
bl_idname = "render.netclientdownload"
bl_label = "Client Download"
def poll(self, context):
@classmethod
def poll(cls, context):
netsettings = context.scene.network_render
return netsettings.active_job_index >= 0 and len(netsettings.jobs) > 0
@@ -435,13 +435,13 @@ class netclientdownload(bpy.types.Operator):
def invoke(self, context, event):
return self.execute(context)
@rnaType
class netclientscan(bpy.types.Operator):
'''Listen on network for master server broadcasting its address and port.'''
bl_idname = "render.netclientscan"
bl_label = "Client Scan"
def poll(self, context):
@classmethod
def poll(cls, context):
return True
def execute(self, context):
@@ -458,13 +458,13 @@ class netclientscan(bpy.types.Operator):
def invoke(self, context, event):
return self.execute(context)
@rnaType
class netclientweb(bpy.types.Operator):
'''Open new window with information about running rendering jobs'''
bl_idname = "render.netclientweb"
bl_label = "Open Master Monitor"
def poll(self, context):
@classmethod
def poll(cls, context):
netsettings = context.scene.network_render
return netsettings.server_address != "[default]"

View File

@@ -92,7 +92,7 @@ def process(paths):
# LIBRARIES
###########################
for lib in bpy.data.libraries:
file_path = bpy.utils.expandpath(lib.filepath)
file_path = bpy.path.abspath(lib.filepath)
new_path = path_map.get(os.path.split(file_path)[1], None)
if new_path:
lib.filepath = new_path
@@ -102,7 +102,7 @@ def process(paths):
###########################
for image in bpy.data.images:
if image.source == "FILE" and not image.packed_file:
file_path = bpy.utils.expandpath(image.filepath)
file_path = bpy.path.abspath(image.filepath)
new_path = path_map.get(os.path.split(file_path)[1], None)
if new_path:
image.filepath = new_path
@@ -124,7 +124,7 @@ def process(paths):
if modifier.domain_settings.highres:
processPointCache(modifier.domain_settings.point_cache_high)
elif modifier.type == "MULTIRES" and modifier.external:
file_path = bpy.utils.expandpath(modifier.filepath)
file_path = bpy.path.abspath(modifier.filepath)
new_path = path_map.get(file_path, None)
if new_path:
modifier.filepath = new_path

View File

@@ -36,6 +36,11 @@ DISPATCHED = 1
DONE = 2
ERROR = 3
def base_poll(cls, context):
rd = context.scene.render
return (rd.use_game_engine==False) and (rd.engine in cls.COMPAT_ENGINES)
def init_file():
if netrender.init_file != bpy.data.filepath:
netrender.init_file = bpy.data.filepath
@@ -82,16 +87,16 @@ class RenderButtonsPanel():
bl_context = "render"
# COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
def poll(self, context):
rd = context.scene.render
return (rd.use_game_engine==False) and (rd.engine in self.COMPAT_ENGINES)
# Setting panel, use in the scene for now.
@rnaType
class RENDER_PT_network_settings(bpy.types.Panel, RenderButtonsPanel):
bl_label = "Network Settings"
COMPAT_ENGINES = {'NET_RENDER'}
@classmethod
def poll(cls, context):
return base_poll(cls, context)
def draw(self, context):
layout = self.layout
@@ -122,15 +127,14 @@ class RENDER_PT_network_settings(bpy.types.Panel, RenderButtonsPanel):
layout.operator("render.netclientweb", icon='QUESTION')
@rnaType
class RENDER_PT_network_slave_settings(bpy.types.Panel, RenderButtonsPanel):
bl_label = "Slave Settings"
COMPAT_ENGINES = {'NET_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
scene = context.scene
return (super().poll(context)
and scene.network_render.mode == "RENDER_SLAVE")
return base_poll(cls, context) and scene.network_render.mode == "RENDER_SLAVE"
def draw(self, context):
layout = self.layout
@@ -147,15 +151,15 @@ class RENDER_PT_network_slave_settings(bpy.types.Panel, RenderButtonsPanel):
sub = layout.column()
sub.enabled = rd.threads_mode == 'FIXED'
sub.prop(rd, "threads")
@rnaType
class RENDER_PT_network_master_settings(bpy.types.Panel, RenderButtonsPanel):
bl_label = "Master Settings"
COMPAT_ENGINES = {'NET_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
scene = context.scene
return (super().poll(context)
and scene.network_render.mode == "RENDER_MASTER")
return base_poll(cls, context) and scene.network_render.mode == "RENDER_MASTER"
def draw(self, context):
layout = self.layout
@@ -166,15 +170,14 @@ class RENDER_PT_network_master_settings(bpy.types.Panel, RenderButtonsPanel):
layout.prop(netsettings, "master_broadcast")
layout.prop(netsettings, "master_clear")
@rnaType
class RENDER_PT_network_job(bpy.types.Panel, RenderButtonsPanel):
bl_label = "Job Settings"
COMPAT_ENGINES = {'NET_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
scene = context.scene
return (super().poll(context)
and scene.network_render.mode == "RENDER_CLIENT")
return base_poll(cls, context) and scene.network_render.mode == "RENDER_CLIENT"
def draw(self, context):
layout = self.layout
@@ -207,19 +210,18 @@ class RENDER_PT_network_job(bpy.types.Panel, RenderButtonsPanel):
row.prop(netsettings, "priority")
row.prop(netsettings, "chunks")
@rnaType
class RENDER_PT_network_slaves(bpy.types.Panel, RenderButtonsPanel):
bl_label = "Slaves Status"
COMPAT_ENGINES = {'NET_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
scene = context.scene
netsettings = scene.network_render
if netsettings.mode != "RENDER_CLIENT":
return False
verify_address(netsettings)
return (super().poll(context)
and netsettings.server_address != "[default]")
return base_poll(cls, context) and netsettings.server_address != "[default]"
def draw(self, context):
layout = self.layout
@@ -246,19 +248,18 @@ class RENDER_PT_network_slaves(bpy.types.Panel, RenderButtonsPanel):
layout.label(text="Seen: " + time.ctime(slave.last_seen))
layout.label(text="Stats: " + slave.stats)
@rnaType
class RENDER_PT_network_slaves_blacklist(bpy.types.Panel, RenderButtonsPanel):
bl_label = "Slaves Blacklist"
COMPAT_ENGINES = {'NET_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
scene = context.scene
netsettings = scene.network_render
if netsettings.mode != "RENDER_CLIENT":
return False
verify_address(netsettings)
return (super().poll(context)
and netsettings.server_address != "[default]")
return base_poll(cls, context) and netsettings.server_address != "[default]"
def draw(self, context):
layout = self.layout
@@ -284,19 +285,18 @@ class RENDER_PT_network_slaves_blacklist(bpy.types.Panel, RenderButtonsPanel):
layout.label(text="Seen: " + time.ctime(slave.last_seen))
layout.label(text="Stats: " + slave.stats)
@rnaType
class RENDER_PT_network_jobs(bpy.types.Panel, RenderButtonsPanel):
bl_label = "Jobs"
COMPAT_ENGINES = {'NET_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
scene = context.scene
netsettings = scene.network_render
if netsettings.mode != "RENDER_CLIENT":
return False
verify_address(netsettings)
return (super().poll(context)
and netsettings.server_address != "[default]")
return base_poll(cls, context) and netsettings.server_address != "[default]"
def draw(self, context):
layout = self.layout
@@ -325,15 +325,12 @@ class RENDER_PT_network_jobs(bpy.types.Panel, RenderButtonsPanel):
layout.label(text="Done: %04i" % job.results[DONE])
layout.label(text="Error: %04i" % job.results[ERROR])
@rnaType
class NetRenderSettings(bpy.types.IDPropertyGroup):
pass
@rnaType
class NetRenderSlave(bpy.types.IDPropertyGroup):
pass
@rnaType
class NetRenderJob(bpy.types.IDPropertyGroup):
pass

View File

@@ -57,10 +57,6 @@ FRAME_STATUS_TEXT = {
ERROR: "Error"
}
def rnaType(rna_type):
if bpy: bpy.types.register(rna_type)
return rna_type
def reporting(report, message, errorType = None):
if errorType:
t = 'ERROR'

View File

@@ -26,7 +26,7 @@ data = _bpy.data
context = _bpy.context
# python modules
from bpy import utils
from bpy import utils, path
from bpy import ops as _ops_module

View File

@@ -0,0 +1,174 @@
# ##### 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>
"""
This module has a similar scope to os.path, containing utility
functions for dealing with paths in Blender.
"""
import bpy as _bpy
import os as _os
def abspath(path):
"""
Returns the absolute path relative to the current blend file using the "//" prefix.
"""
if path.startswith("//"):
return _os.path.join(_os.path.dirname(_bpy.data.filepath), path[2:])
return path
def relpath(path, start=None):
"""
Returns the path relative to the current blend file using the "//" prefix.
:arg start: Relative to this path, when not set the current filename is used.
:type start: string
"""
if not path.startswith("//"):
if start is None:
start = _os.path.dirname(_bpy.data.filepath)
return "//" + _os.path.relpath(path, start)
return path
def clean_name(name, replace="_"):
"""
Returns a name with characters replaced that may cause problems under various circumstances, such as writing to a file.
All characters besides A-Z/a-z, 0-9 are replaced with "_"
or the replace argument if defined.
"""
unclean_chars = \
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\
\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\
\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\
\x2e\x2f\x3a\x3b\x3c\x3d\x3e\x3f\x40\x5b\x5c\x5d\x5e\x60\x7b\
\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\
\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\
\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\
\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\
\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\
\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\
\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\
\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\
\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe"
for ch in unclean_chars:
name = name.replace(ch, replace)
return name
def display_name(name):
"""
Creates a display string from name to be used menus and the user interface.
Capitalize the first letter in all lowercase names, mixed case names are kept as is.
Intended for use with filenames and module names.
"""
name_base = _os.path.splitext(name)[0]
# string replacements
name_base = name_base.replace("_colon_", ":")
name_base = name_base.replace("_", " ")
if name_base.islower():
return name_base.capitalize()
else:
return name_base
def resolve_ncase(path):
"""
Resolve a case insensitive path on a case sensitive system,
returning a string with the path if found else return the original path.
"""
import os
def _ncase_path_found(path):
if path=='' or os.path.exists(path):
return path, True
filename = os.path.basename(path) # filename may be a directory or a file
dirpath = os.path.dirname(path)
suffix = ""
if not filename: # dir ends with a slash?
if len(dirpath) < len(path):
suffix = path[:len(path)-len(dirpath)]
filename = os.path.basename(dirpath)
dirpath = os.path.dirname(dirpath)
if not os.path.exists(dirpath):
dirpath, found = _ncase_path_found(dirpath)
if not found:
return path, False
# at this point, the directory exists but not the file
# we are expecting 'dirpath' to be a directory, but it could be a file
if os.path.isdir(dirpath):
files = os.listdir(dirpath)
else:
return path, False
filename_low = filename.lower()
f_iter_nocase = None
for f_iter in files:
if f_iter.lower() == filename_low:
f_iter_nocase = f_iter
break
if f_iter_nocase:
return os.path.join(dirpath, f_iter_nocase) + suffix, True
else:
# cant find the right one, just return the path as is.
return path, False
ncase_path, found = _ncase_path_found(path)
return ncase_path if found else path
def ensure_ext(filepath, ext, case_sensitive=False):
"""
Return the path with the extension added its its not alredy set.
:arg ext: The extension to check for.
:type ext: string
:arg case_sensitive: Check for matching case when comparing extensions.
:type case_sensitive: bool
"""
import os
fn_base, fn_ext = os.path.splitext(filepath)
if fn_base and fn_ext:
if (case_sensitive and ext == fn_ext) or (ext.lower() == fn_ext.lower()):
return filepath
else:
return fn_base + ext
else:
return filepath + ext

View File

@@ -30,6 +30,7 @@ import sys as _sys
from _bpy import blend_paths
from _bpy import script_paths as _bpy_script_paths
_TEST_XML = _bpy.app.debug
def _test_import(module_name, loaded_modules):
import traceback
@@ -53,6 +54,35 @@ def _test_import(module_name, loaded_modules):
loaded_modules.add(mod.__name__) # should match mod.__name__ too
return mod
if _TEST_XML:
# TEST CODE
def _test_import_xml(path, f, loaded_modules):
import bpy_xml_ui
import traceback
f_full = _os.path.join(path, f)
_bpy_types._register_immediate = True
try:
classes = bpy_xml_ui.load_xml(f_full)
except:
traceback.print_exc()
classes = []
_bpy_types._register_immediate = False
if classes:
mod_name = f.split(".")[0]
# fake module
mod = type(traceback)(mod_name)
mod.__file__ = f_full
for cls in classes:
setattr(mod, cls.__name__, cls)
loaded_modules.add(mod_name)
_sys.modules[mod_name] = mod
mod.register = lambda: None # quiet errors
return mod
def modules_from_path(path, loaded_modules):
"""
@@ -80,13 +110,17 @@ def modules_from_path(path, loaded_modules):
else:
mod = None
if _TEST_XML:
if mod is None and f.endswith(".xml"):
mod = _test_import_xml(path, f, loaded_modules)
if mod:
modules.append(mod)
return modules
_loaded = [] # store loaded modules for reloading.
_bpy_types = __import__("bpy_types") # keep for comparisons, never ever reload this.
_global_loaded_modules = [] # store loaded module names for reloading.
import bpy_types as _bpy_types # keep for comparisons, never ever reload this.
def load_scripts(reload_scripts=False, refresh_scripts=False):
@@ -101,6 +135,9 @@ def load_scripts(reload_scripts=False, refresh_scripts=False):
import traceback
import time
# must be set back to True on exits
_bpy_types._register_immediate = False
t_main = time.time()
loaded_modules = set()
@@ -108,6 +145,30 @@ def load_scripts(reload_scripts=False, refresh_scripts=False):
if refresh_scripts:
original_modules = _sys.modules.values()
if reload_scripts:
_bpy_types.TypeMap.clear()
_bpy_types.PropertiesMap.clear()
def register_module_call(mod):
_bpy_types._register_module(mod.__name__)
register = getattr(mod, "register", None)
if register:
try:
register()
except:
traceback.print_exc()
else:
print("\nWarning! '%s' has no register function, this is now a requirement for registerable scripts." % mod.__file__)
def unregister_module_call(mod):
_bpy_types._unregister_module(mod.__name__)
unregister = getattr(mod, "unregister", None)
if unregister:
try:
unregister()
except:
traceback.print_exc()
def sys_path_ensure(path):
if path not in _sys.path: # reloading would add twice
_sys.path.insert(0, path)
@@ -134,48 +195,23 @@ def load_scripts(reload_scripts=False, refresh_scripts=False):
mod = test_reload(mod)
if mod:
register = getattr(mod, "register", None)
if register:
try:
register()
except:
traceback.print_exc()
else:
print("\nWarning! '%s' has no register function, this is now a requirement for registerable scripts." % mod.__file__)
_loaded.append(mod)
register_module_call(mod)
_global_loaded_modules.append(mod.__name__)
if reload_scripts:
# TODO, this is broken but should work, needs looking into
'''
# reload modules that may not be directly included
for type_class_name in dir(_bpy.types):
type_class = getattr(_bpy.types, type_class_name)
module_name = getattr(type_class, "__module__", "")
if module_name and module_name != "bpy.types": # hard coded for C types
loaded_modules.add(module_name)
# sorting isnt needed but rather it be pradictable
for module_name in sorted(loaded_modules):
print("Reloading:", module_name)
test_reload(_sys.modules[module_name])
'''
# module names -> modules
_global_loaded_modules[:] = [_sys.modules[mod_name] for mod_name in _global_loaded_modules]
# loop over and unload all scripts
_loaded.reverse()
for mod in _loaded:
unregister = getattr(mod, "unregister", None)
if unregister:
try:
unregister()
except:
traceback.print_exc()
_global_loaded_modules.reverse()
for mod in _global_loaded_modules:
unregister_module_call(mod)
for mod in _loaded:
reload(mod)
for mod in _global_loaded_modules:
test_reload(mod)
_loaded[:] = []
_global_loaded_modules[:] = []
user_path = user_script_path()
@@ -197,7 +233,7 @@ def load_scripts(reload_scripts=False, refresh_scripts=False):
# load addons
used_ext = {ext.module for ext in _bpy.context.user_preferences.addons}
paths = script_paths("addons")
paths = script_paths("addons") + script_paths("addons_contrib")
for path in paths:
sys_path_ensure(path)
@@ -212,76 +248,9 @@ def load_scripts(reload_scripts=False, refresh_scripts=False):
if _bpy.app.debug:
print("Python Script Load Time %.4f" % (time.time() - t_main))
def expandpath(path):
"""
Returns the absolute path relative to the current blend file using the "//" prefix.
"""
if path.startswith("//"):
return _os.path.join(_os.path.dirname(_bpy.data.filepath), path[2:])
return path
_bpy_types._register_immediate = True
def relpath(path, start=None):
"""
Returns the path relative to the current blend file using the "//" prefix.
:arg start: Relative to this path, when not set the current filename is used.
:type start: string
"""
if not path.startswith("//"):
if start is None:
start = _os.path.dirname(_bpy.data.filepath)
return "//" + _os.path.relpath(path, start)
return path
def clean_name(name, replace="_"):
"""
Returns a name with characters replaced that may cause problems under various circumstances, such as writing to a file.
All characters besides A-Z/a-z, 0-9 are replaced with "_"
or the replace argument if defined.
"""
unclean_chars = \
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\
\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\
\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\
\x2e\x2f\x3a\x3b\x3c\x3d\x3e\x3f\x40\x5b\x5c\x5d\x5e\x60\x7b\
\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\
\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\
\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\
\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\
\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\
\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\
\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\
\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\
\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe"
for ch in unclean_chars:
name = name.replace(ch, replace)
return name
def display_name(name):
"""
Creates a display string from name to be used menus and the user interface.
Capitalize the first letter in all lowercase names, mixed case names are kept as is.
Intended for use with filenames and module names.
"""
name_base = _os.path.splitext(name)[0]
# string replacements
name_base = name_base.replace("_colon_", ":")
name_base = name_base.replace("_", " ")
if name_base.islower():
return name_base.capitalize()
else:
return name_base
# base scripts
@@ -336,7 +305,7 @@ _presets = _os.path.join(_scripts[0], "presets") # FIXME - multiple paths
def preset_paths(subdir):
'''
Returns a list of paths for a spesific preset.
Returns a list of paths for a specific preset.
'''
return (_os.path.join(_presets, subdir), )

View File

@@ -19,6 +19,7 @@
# <pep8 compliant>
from _bpy import types as bpy_types
import _bpy
from mathutils import Vector
StructRNA = bpy_types.Struct.__bases__[0]
@@ -539,8 +540,83 @@ class Text(bpy_types.ID):
import collections
TypeMap = {}
# Properties (IDPropertyGroup) are different from types because they need to be registered
# before adding sub properties to them, so they are registered on definition
# and unregistered on unload
PropertiesMap = {}
class OrderedMeta(type):
# Using our own loading function we set this to false
# so when running a script directly in the text editor
# registers moduals instantly.
_register_immediate = True
def _unregister_module(module, free=True):
for t in TypeMap.get(module, ()):
try:
bpy_types.unregister(t)
except:
import traceback
print("bpy.utils._unregister_module(): Module '%s' failed to unregister class '%s.%s'" % (module, t.__module__, t.__name__))
traceback.print_exc()
if free == True and module in TypeMap:
del TypeMap[module]
for t in PropertiesMap.get(module, ()):
try:
bpy_types.unregister(t)
except:
import traceback
print("bpy.utils._unload_module(): Module '%s' failed to unregister class '%s.%s'" % (module, t.__module__, t.__name__))
traceback.print_exc()
if free == True and module in PropertiesMap:
del PropertiesMap[module]
def _register_module(module):
for t in TypeMap.get(module, ()):
try:
bpy_types.register(t)
except:
import traceback
print("bpy.utils._register_module(): Module '%s' failed to register class '%s.%s'" % (module, t.__module__, t.__name__))
traceback.print_exc()
class RNAMeta(type):
@classmethod
def _register_immediate(cls):
return _register_immediate
def __new__(cls, name, bases, classdict, **args):
result = type.__new__(cls, name, bases, classdict)
if bases and bases[0] != StructRNA:
module = result.__module__
ClassMap = TypeMap
# Register right away if needed
if cls._register_immediate():
bpy_types.register(result)
ClassMap = PropertiesMap
# first part of packages only
if "." in module:
module = module[:module.index(".")]
ClassMap.setdefault(module, []).append(result)
return result
class RNAMetaRegister(RNAMeta):
@classmethod
def _register_immediate(cls):
return True
class OrderedMeta(RNAMeta):
def __init__(cls, name, bases, attributes):
super(OrderedMeta, cls).__init__(name, bases, attributes)
@@ -549,7 +625,6 @@ class OrderedMeta(type):
def __prepare__(name, bases, **kwargs):
return collections.OrderedDict()
# Only defined so operators members can be used by accessing self.order
class Operator(StructRNA, metaclass=OrderedMeta):
__slots__ = ()
@@ -565,6 +640,11 @@ class Macro(StructRNA, metaclass=OrderedMeta):
from _bpy import ops
return ops.macro_define(self, opname)
class IDPropertyGroup(StructRNA, metaclass=RNAMetaRegister):
__slots__ = ()
class RenderEngine(StructRNA, metaclass=RNAMeta):
__slots__ = ()
class _GenericUI:
__slots__ = ()
@@ -606,15 +686,15 @@ class _GenericUI:
pass
class Panel(StructRNA, _GenericUI):
class Panel(StructRNA, _GenericUI, metaclass=RNAMeta):
__slots__ = ()
class Header(StructRNA, _GenericUI):
class Header(StructRNA, _GenericUI, metaclass=RNAMeta):
__slots__ = ()
class Menu(StructRNA, _GenericUI):
class Menu(StructRNA, _GenericUI, metaclass=RNAMeta):
__slots__ = ()
def path_menu(self, searchpaths, operator, props_default={}):
@@ -638,7 +718,7 @@ class Menu(StructRNA, _GenericUI):
if f.startswith("."):
continue
preset_name = bpy.utils.display_name(f)
preset_name = bpy.path.display_name(f)
props = layout.operator(operator, text=preset_name)
for attr, value in props_default.items():

View File

@@ -0,0 +1,151 @@
# ##### 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>
"""
This module translates XML into blender/ui function calls.
"""
import xml.dom.minidom
import bpy as _bpy
def parse_rna(prop, value):
if prop.type == 'FLOAT':
value = float(value)
elif prop.type == 'INT':
value = int(value)
elif prop.type == 'BOOLEAN':
if value not in ("true", "false"):
raise Exception("invalid bool value: %s", value)
value = bool(value == "true")
elif prop.type in ('STRING', 'ENUM'):
pass
elif prop.type == 'POINTER':
value = eval("_bpy." + value)
else:
raise Exception("type not supported %s.%s" % (prop.identifier, prop.type))
return value
def parse_args(base, xml_node):
args = {}
rna_params = base.bl_rna.functions[xml_node.tagName].parameters
for key, value in xml_node.attributes.items():
args[key] = parse_rna(rna_params[key], value)
return args
def ui_xml(base, xml_node):
name = xml_node.tagName
prop = base.bl_rna.properties.get(name)
if name in base.bl_rna.properties:
attr = xml_node.attributes.get("expr")
if attr:
value = attr.value
value = eval(value, {"context": _bpy.context})
setattr(base, name, value)
else:
attr = xml_node.attributes['value']
value = attr.value
value = parse_rna(prop, value)
setattr(base, name, value)
else:
func_new = getattr(base, name)
kw_args = parse_args(base, xml_node)
base_new = func_new(**kw_args) # call blender func
if xml_node.hasChildNodes():
ui_xml_list(base_new, xml_node.childNodes)
def ui_xml_list(base, xml_nodes):
import bpy
for node in xml_nodes:
if node.nodeType not in (node.TEXT_NODE, node.COMMENT_NODE):
ui_xml(base, node)
bpy.N = node
def test(layout):
uixml = xml.dom.minidom.parseString(open("/mnt/test/blender-svn/blender/release/scripts/ui/test.xml", 'r').read())
panel = uixml.getElementsByTagName('panel')[0]
ui_xml_list(layout, panel.childNodes)
def load_xml(filepath):
classes = []
fn = open(filepath, 'r')
data = fn.read()
uixml = xml.dom.minidom.parseString(data).getElementsByTagName("ui")[0]
fn.close()
def draw_xml(self, context):
node = self._xml_node.getElementsByTagName("draw")[0]
ui_xml_list(self.layout, node.childNodes)
def draw_header_xml(self, context):
node = self._xml_node.getElementsByTagName("draw_header")[0]
ui_xml_list(self.layout, node.childNodes)
for node in uixml.childNodes:
if node.nodeType not in (node.TEXT_NODE, node.COMMENT_NODE):
name = node.tagName
class_name = node.attributes["identifier"].value
if name == "panel":
class_dict = {
"bl_label": node.attributes["label"].value,
"bl_region_type": node.attributes["region_type"].value,
"bl_space_type": node.attributes["space_type"].value,
"bl_context": node.attributes["context"].value,
"bl_default_closed": ((node.attributes["default_closed"].value == "true") if "default_closed" in node.attributes else False),
"draw": draw_xml,
"_xml_node": node
}
if node.getElementsByTagName("draw_header"):
class_dict["draw_header"] = draw_header_xml
# will register instantly
class_new = type(class_name, (_bpy.types.Panel,), class_dict)
elif name == "menu":
class_dict = {
"bl_label": node.attributes["label"].value,
"draw": draw_xml,
"_xml_node": node
}
# will register instantly
class_new = type(class_name, (_bpy.types.Menu,), class_dict)
elif name == "header":
class_dict = {
"bl_label": node.attributes["label"].value,
"bl_space_type": node.attributes["space_type"].value,
"draw": draw_xml,
"_xml_node": node
}
# will register instantly
class_new = type(class_name, (_bpy.types.Header,), class_dict)
else:
raise Exception("invalid id found '%s': expected a value in ('header', 'panel', 'menu)'" % name)
classes.append(class_new)
return classes

View File

@@ -537,7 +537,7 @@ def generate_test_all(context, GRAPH=False):
base_name = os.path.splitext(bpy.data.filepath)[0]
for obj, obj_new in new_objects:
for obj in (obj, obj_new):
fn = base_name + "-" + bpy.utils.clean_name(obj.name)
fn = base_name + "-" + bpy.path.clean_name(obj.name)
path_dot = fn + ".dot"
path_png = fn + ".png"

View File

@@ -124,7 +124,7 @@ def draw(layout, context, context_member, use_edit=True):
assign_props(prop, val_draw, key)
class PropertyPanel(bpy.types.Panel):
class PropertyPanel():
"""
The subclass should have its own poll function
and the variable '_context_path' MUST be set.
@@ -132,133 +132,10 @@ class PropertyPanel(bpy.types.Panel):
bl_label = "Custom Properties"
bl_default_closed = True
@classmethod
def poll(cls, context):
bool(eval("context.%s" % cls._context_path))
def draw(self, context):
draw(self.layout, context, self._context_path)
from bpy.props import *
rna_path = StringProperty(name="Property Edit",
description="Property data_path edit", maxlen=1024, default="", options={'HIDDEN'})
rna_value = StringProperty(name="Property Value",
description="Property value edit", maxlen=1024, default="")
rna_property = StringProperty(name="Property Name",
description="Property name edit", maxlen=1024, default="")
rna_min = FloatProperty(name="Min", default=0.0, precision=3)
rna_max = FloatProperty(name="Max", default=1.0, precision=3)
class WM_OT_properties_edit(bpy.types.Operator):
'''Internal use (edit a property data_path)'''
bl_idname = "wm.properties_edit"
bl_label = "Edit Property"
data_path = rna_path
property = rna_property
value = rna_value
min = rna_min
max = rna_max
description = StringProperty(name="Tip", default="")
def execute(self, context):
data_path = self.properties.data_path
value = self.properties.value
prop = self.properties.property
prop_old = self._last_prop[0]
try:
value_eval = eval(value)
except:
value_eval = value
# First remove
item = eval("context.%s" % data_path)
rna_idprop_ui_prop_clear(item, prop_old)
exec_str = "del item['%s']" % prop_old
# print(exec_str)
exec(exec_str)
# Reassign
exec_str = "item['%s'] = %s" % (prop, repr(value_eval))
# print(exec_str)
exec(exec_str)
self._last_prop[:] = [prop]
prop_type = type(item[prop])
prop_ui = rna_idprop_ui_prop_get(item, prop)
if prop_type in (float, int):
prop_ui['soft_min'] = prop_ui['min'] = prop_type(self.properties.min)
prop_ui['soft_max'] = prop_ui['max'] = prop_type(self.properties.max)
prop_ui['description'] = self.properties.description
return {'FINISHED'}
def invoke(self, context, event):
self._last_prop = [self.properties.property]
item = eval("context.%s" % self.properties.data_path)
# setup defaults
prop_ui = rna_idprop_ui_prop_get(item, self.properties.property, False) # dont create
if prop_ui:
self.properties.min = prop_ui.get("min", -1000000000)
self.properties.max = prop_ui.get("max", 1000000000)
self.properties.description = prop_ui.get("description", "")
wm = context.manager
# This crashes, TODO - fix
#return wm.invoke_props_popup(self, event)
wm.invoke_props_popup(self, event)
return {'RUNNING_MODAL'}
class WM_OT_properties_add(bpy.types.Operator):
'''Internal use (edit a property data_path)'''
bl_idname = "wm.properties_add"
bl_label = "Add Property"
data_path = rna_path
def execute(self, context):
item = eval("context.%s" % self.properties.data_path)
def unique_name(names):
prop = 'prop'
prop_new = prop
i = 1
while prop_new in names:
prop_new = prop + str(i)
i += 1
return prop_new
property = unique_name(item.keys())
item[property] = 1.0
return {'FINISHED'}
class WM_OT_properties_remove(bpy.types.Operator):
'''Internal use (edit a property data_path)'''
bl_idname = "wm.properties_remove"
bl_label = "Remove Property"
data_path = rna_path
property = rna_property
def execute(self, context):
item = eval("context.%s" % self.properties.data_path)
del item[self.properties.property]
return {'FINISHED'}

View File

@@ -606,12 +606,10 @@ menu_func = (lambda self, context: self.layout.operator(AddHuman.bl_idname,
def register():
bpy.types.register(AddHuman)
bpy.types.INFO_MT_armature_add.append(menu_func)
def unregister():
bpy.types.unregister(AddHuman)
bpy.types.INFO_MT_armature_add.remove(menu_func)
if __name__ == "__main__":

View File

@@ -137,12 +137,10 @@ def menu_func(self, context):
def register():
bpy.types.register(AddTorus)
bpy.types.INFO_MT_mesh_add.append(menu_func)
def unregister():
bpy.types.unregister(AddTorus)
bpy.types.INFO_MT_mesh_add.remove(menu_func)
if __name__ == "__main__":

View File

@@ -44,16 +44,17 @@ def get_console(console_id):
from code import InteractiveConsole
consoles = getattr(get_console, "consoles", None)
hash_next = hash(bpy.context.manager)
if consoles is None:
consoles = get_console.consoles = {}
get_console.consoles_namespace_hash = hash_next
else:
# check if clearning the namespace is needed to avoid a memory leak.
# the window manager is normally loaded with new blend files
# so this is a reasonable way to deal with namespace clearing.
# bpy.data hashing is reset by undo so cant be used.
hash_prev = getattr(get_console, "consoles_namespace_hash", 0)
hash_next = hash(bpy.context.manager)
if hash_prev != hash_next:
get_console.consoles_namespace_hash = hash_next
@@ -205,6 +206,10 @@ def autocomplete(context):
scrollback = ""
scrollback_error = ""
if _BPY_MAIN_OWN:
main_mod_back = sys.modules["__main__"]
sys.modules["__main__"] = console._bpy_main_mod
try:
current_line = sc.history[-1]
line = current_line.line
@@ -223,6 +228,9 @@ def autocomplete(context):
import traceback
scrollback_error = traceback.format_exc()
if _BPY_MAIN_OWN:
sys.modules["__main__"] = main_mod_back
# Separate automplete output by command prompts
if scrollback != '':
bpy.ops.console.scrollback_append(text=sc.prompt + current_line.line, type='INPUT')

View File

@@ -48,7 +48,8 @@ class DiscontFilterOp(bpy.types.Operator):
bl_idname = "graph.euler_filter"
bl_label = "Filter out discontinuities in the active fcurves"
def poll(self, context):
@classmethod
def poll(cls, context):
return context.active_object != None
def execute(self, context):
@@ -56,10 +57,10 @@ class DiscontFilterOp(bpy.types.Operator):
return {'FINISHED'}
def register():
bpy.types.register(DiscontFilterOp)
pass
def unregister():
bpy.types.unregister(DiscontFilterOp)
pass
if __name__ == "__main__":
register()

View File

@@ -56,13 +56,15 @@ class EditExternally(bpy.types.Operator):
return image_editor
def execute(self, context):
import os
import subprocess
filepath = self.properties.filepath
image_editor = self._editor_guess(context)
filepath = bpy.path.abspath(self.properties.filepath)
cmd = []
cmd.extend(image_editor)
cmd.append(bpy.utils.expandpath(filepath))
if not os.path.exists(filepath):
self.report('ERROR', "Image path '%s' not found." % filepath)
return {'CANCELLED'}
cmd = self._editor_guess(context) + [filepath]
subprocess.Popen(cmd)
@@ -91,7 +93,7 @@ class SaveDirty(bpy.types.Operator):
unique_paths = set()
for image in bpy.data.images:
if image.dirty:
filepath = bpy.utils.expandpath(image.filepath)
filepath = bpy.path.abspath(image.filepath)
if "\\" not in filepath and "/" not in filepath:
self.report({'WARNING'}, "Invalid path: " + filepath)
elif filepath in unique_paths:
@@ -133,7 +135,7 @@ class ProjectEdit(bpy.types.Operator):
filepath = os.path.basename(bpy.data.filepath)
filepath = os.path.splitext(filepath)[0]
# filepath = bpy.utils.clean_name(filepath) # fixes <memory> rubbish, needs checking
# filepath = bpy.path.clean_name(filepath) # fixes <memory> rubbish, needs checking
if filepath.startswith(".") or filepath == "":
# TODO, have a way to check if the file is saved, assume .B25.blend
@@ -145,12 +147,12 @@ class ProjectEdit(bpy.types.Operator):
obj = context.object
if obj:
filepath += "_" + bpy.utils.clean_name(obj.name)
filepath += "_" + bpy.path.clean_name(obj.name)
filepath_final = filepath + "." + EXT
i = 0
while os.path.exists(bpy.utils.expandpath(filepath_final)):
while os.path.exists(bpy.path.abspath(filepath_final)):
filepath_final = filepath + ("%.3d.%s" % (i, EXT))
i += 1
@@ -186,23 +188,12 @@ class ProjectApply(bpy.types.Operator):
return {'FINISHED'}
classes = [
EditExternally,
SaveDirty,
ProjectEdit,
ProjectApply]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -28,7 +28,8 @@ class MeshSelectInteriorFaces(bpy.types.Operator):
bl_label = "Select Interior Faces"
bl_options = {'REGISTER', 'UNDO'}
def poll(self, context):
@classmethod
def poll(cls, context):
ob = context.active_object
return (ob and ob.type == 'MESH')
@@ -69,7 +70,8 @@ class MeshMirrorUV(bpy.types.Operator):
bl_label = "Copy Mirrored UV coords"
bl_options = {'REGISTER', 'UNDO'}
def poll(self, context):
@classmethod
def poll(cls, context):
ob = context.active_object
return (ob and ob.type == 'MESH')
@@ -172,22 +174,12 @@ class MeshMirrorUV(bpy.types.Operator):
return {'FINISHED'}
# Register the operator
classes = [
MeshSelectInteriorFaces,
MeshMirrorUV]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -178,12 +178,12 @@ class BakeAction(bpy.types.Operator):
def register():
bpy.types.register(BakeAction)
pass
# bpy.types.INFO_MT_mesh_add.append(menu_func)
def unregister():
bpy.types.unregister(BakeAction)
pass
# bpy.types.INFO_MT_mesh_add.remove(menu_func)
if __name__ == "__main__":

View File

@@ -80,7 +80,8 @@ class SelectCamera(bpy.types.Operator):
bl_label = "Select Camera"
bl_options = {'REGISTER', 'UNDO'}
def poll(self, context):
@classmethod
def poll(cls, context):
return context.scene.camera is not None
def execute(self, context):
@@ -109,7 +110,8 @@ class SelectHierarchy(bpy.types.Operator):
extend = BoolProperty(name="Extend", description="Extend the existing selection", default=False)
def poll(self, context):
@classmethod
def poll(cls, context):
return context.object
def execute(self, context):
@@ -167,7 +169,8 @@ class SubdivisionSet(bpy.types.Operator):
relative = BoolProperty(name="Relative", description="Apply the subsurf level as an offset relative to the current level", default=False)
def poll(self, context):
@classmethod
def poll(cls, context):
obs = context.selected_editable_objects
return (obs is not None)
@@ -379,7 +382,8 @@ class ShapeTransfer(bpy.types.Operator):
return {'FINISHED'}
def poll(self, context):
@classmethod
def poll(cls, context):
obj = context.active_object
return (obj and obj.mode != 'EDIT')
@@ -409,7 +413,8 @@ class JoinUVs(bpy.types.Operator):
bl_idname = "object.join_uvs"
bl_label = "Join as UVs"
def poll(self, context):
@classmethod
def poll(cls, context):
obj = context.active_object
return (obj and obj.type == 'MESH')
@@ -467,7 +472,8 @@ class MakeDupliFace(bpy.types.Operator):
bl_idname = "object.make_dupli_face"
bl_label = "Make DupliFace"
def poll(self, context):
@classmethod
def poll(cls, context):
obj = context.active_object
return (obj and obj.type == 'MESH')
@@ -558,28 +564,12 @@ class ClearAllRestrictRender(bpy.types.Operator):
return {'FINISHED'}
classes = [
SelectPattern,
SelectCamera,
SelectHierarchy,
SubdivisionSet,
ShapeTransfer,
JoinUVs,
IsolateTypeRender,
MakeDupliFace,
ClearAllRestrictRender]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -263,7 +263,8 @@ class AlignObjects(bpy.types.Operator):
align_z = BoolProperty(name="Align Z",
description="Align in the Z axis", default=False)
def poll(self, context):
@classmethod
def poll(cls, context):
return context.mode == 'OBJECT'
def execute(self, context):
@@ -286,12 +287,10 @@ def menu_func(self, context):
def register():
bpy.types.register(AlignObjects)
bpy.types.VIEW3D_MT_transform.append(menu_func)
def unregister():
bpy.types.unregister(AlignObjects)
bpy.types.VIEW3D_MT_transform.remove(menu_func)
if __name__ == "__main__":

View File

@@ -140,12 +140,10 @@ def menu_func(self, context):
def register():
bpy.types.register(RandomizeLocRotSize)
bpy.types.VIEW3D_MT_transform.append(menu_func)
def unregister():
bpy.types.unregister(RandomizeLocRotSize)
bpy.types.VIEW3D_MT_transform.remove(menu_func)
if __name__ == "__main__":

View File

@@ -22,7 +22,7 @@ import bpy
import os
class AddPresetBase(bpy.types.Operator):
class AddPresetBase():
'''Base preset class, only for subclassing
subclasses must define
- preset_values
@@ -91,7 +91,7 @@ class ExecutePreset(bpy.types.Operator):
return {'FINISHED'}
class AddPresetRender(AddPresetBase):
class AddPresetRender(AddPresetBase, bpy.types.Operator):
'''Add a Render Preset'''
bl_idname = "render.preset_add"
bl_label = "Add Render Preset"
@@ -113,7 +113,7 @@ class AddPresetRender(AddPresetBase):
preset_subdir = "render"
class AddPresetSSS(AddPresetBase):
class AddPresetSSS(AddPresetBase, bpy.types.Operator):
'''Add a Subsurface Scattering Preset'''
bl_idname = "material.sss_preset_add"
bl_label = "Add SSS Preset"
@@ -138,7 +138,7 @@ class AddPresetSSS(AddPresetBase):
preset_subdir = "sss"
class AddPresetCloth(AddPresetBase):
class AddPresetCloth(AddPresetBase, bpy.types.Operator):
'''Add a Cloth Preset'''
bl_idname = "cloth.preset_add"
bl_label = "Add Cloth Preset"
@@ -156,7 +156,7 @@ class AddPresetCloth(AddPresetBase):
preset_subdir = "cloth"
class AddPresetSunSky(AddPresetBase):
class AddPresetSunSky(AddPresetBase, bpy.types.Operator):
'''Add a Sky & Atmosphere Preset'''
bl_idname = "lamp.sunsky_preset_add"
bl_label = "Add Sunsky Preset"
@@ -181,7 +181,7 @@ class AddPresetSunSky(AddPresetBase):
preset_subdir = "sunsky"
class AddPresetInteraction(AddPresetBase):
class AddPresetInteraction(AddPresetBase, bpy.types.Operator):
'''Add an Application Interaction Preset'''
bl_idname = "wm.interaction_preset_add"
bl_label = "Add Interaction Preset"
@@ -203,25 +203,12 @@ class AddPresetInteraction(AddPresetBase):
preset_subdir = "interaction"
classes = [
ExecutePreset,
AddPresetRender,
AddPresetSSS,
AddPresetCloth,
AddPresetSunSky,
AddPresetInteraction]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -79,7 +79,7 @@ class PlayRenderedAnim(bpy.types.Operator):
preset = prefs.filepaths.animation_player_preset
player_path = prefs.filepaths.animation_player
file_path = bpy.utils.expandpath(rd.output_path)
file_path = bpy.path.abspath(rd.output_path)
is_movie = rd.is_movie_format
# try and guess a command line if it doesn't exist
@@ -105,7 +105,7 @@ class PlayRenderedAnim(bpy.types.Operator):
# works for movies and images
file = rd.frame_path(frame=scene.frame_start)
file = bpy.utils.expandpath(file) # expand '//'
file = bpy.path.abspath(file) # expand '//'
cmd = [player_path]
# extra options, fps controls etc.
@@ -144,11 +144,11 @@ class PlayRenderedAnim(bpy.types.Operator):
def register():
bpy.types.register(PlayRenderedAnim)
pass
def unregister():
bpy.types.unregister(PlayRenderedAnim)
pass
if __name__ == "__main__":
register()

View File

@@ -30,7 +30,8 @@ class SequencerCrossfadeSounds(bpy.types.Operator):
bl_label = "Crossfade sounds"
bl_options = {'REGISTER', 'UNDO'}
def poll(self, context):
@classmethod
def poll(cls, context):
if context.scene and context.scene.sequence_editor and context.scene.sequence_editor.active_strip:
return context.scene.sequence_editor.active_strip.type == 'SOUND'
else:
@@ -83,7 +84,8 @@ class SequencerCutMulticam(bpy.types.Operator):
camera = IntProperty(name="Camera",
default=1, min=1, max=32, soft_min=1, soft_max=32)
def poll(self, context):
@classmethod
def poll(cls, context):
if context.scene and context.scene.sequence_editor and context.scene.sequence_editor.active_strip:
return context.scene.sequence_editor.active_strip.type == 'MULTICAM'
else:
@@ -117,7 +119,8 @@ class SequencerDeinterlaceSelectedMovies(bpy.types.Operator):
bl_label = "Deinterlace Movies"
bl_options = {'REGISTER', 'UNDO'}
def poll(self, context):
@classmethod
def poll(cls, context):
if context.scene and context.scene.sequence_editor:
return True
else:
@@ -132,19 +135,11 @@ class SequencerDeinterlaceSelectedMovies(bpy.types.Operator):
def register():
register = bpy.types.register
register(SequencerCrossfadeSounds)
register(SequencerCutMulticam)
register(SequencerDeinterlaceSelectedMovies)
pass
def unregister():
unregister = bpy.types.unregister
unregister(SequencerCrossfadeSounds)
unregister(SequencerCutMulticam)
unregister(SequencerDeinterlaceSelectedMovies)
pass
if __name__ == "__main__":

View File

@@ -39,7 +39,8 @@ class ExportUVLayout(bpy.types.Operator):
description="File format to export the UV layout to",
default='SVG')
def poll(self, context):
@classmethod
def poll(cls, context):
obj = context.active_object
return (obj and obj.type == 'MESH')
@@ -113,7 +114,9 @@ class ExportUVLayout(bpy.types.Operator):
mode = self.properties.mode
file = open(self.properties.filepath, "w")
filepath = self.properties.filepath
filepath = bpy.path.ensure_ext(filepath, "." + mode.lower())
file = open(filepath, "w")
fw = file.write
if mode == 'SVG':
@@ -216,12 +219,10 @@ def menu_func(self, context):
def register():
bpy.types.register(ExportUVLayout)
bpy.types.IMAGE_MT_uvs.append(menu_func)
def unregister():
bpy.types.unregister(ExportUVLayout)
bpy.types.IMAGE_MT_uvs.remove(menu_func)
if __name__ == "__main__":

View File

@@ -249,7 +249,8 @@ class FollowActiveQuads(bpy.types.Operator):
description="Method to space UV edge loops",
default="LENGTH")
def poll(self, context):
@classmethod
def poll(cls, context):
obj = context.active_object
return (obj is not None and obj.type == 'MESH')
@@ -263,12 +264,10 @@ menu_func = (lambda self, context: self.layout.operator(FollowActiveQuads.bl_idn
def register():
bpy.types.register(FollowActiveQuads)
bpy.types.VIEW3D_MT_uv_map.append(menu_func)
def unregister():
bpy.types.unregister(FollowActiveQuads)
bpy.types.VIEW3D_MT_uv_map.remove(menu_func)
if __name__ == "__main__":

View File

@@ -1124,7 +1124,8 @@ class SmartProject(bpy.types.Operator):
description="Margin to reduce bleed from adjacent islands.",
default=0.0, min=0.0, max=1.0)
def poll(self, context):
@classmethod
def poll(cls, context):
return context.active_object != None
def execute(self, context):
@@ -1138,12 +1139,10 @@ menu_func = (lambda self, context: self.layout.operator(SmartProject.bl_idname,
def register():
bpy.types.register(SmartProject)
bpy.types.VIEW3D_MT_uv_map.append(menu_func)
def unregister():
bpy.types.unregister(SmartProject)
bpy.types.VIEW3D_MT_uv_map.remove(menu_func)
if __name__ == "__main__":

View File

@@ -180,11 +180,11 @@ class VertexPaintDirt(bpy.types.Operator):
def register():
bpy.types.register(VertexPaintDirt)
pass
def unregister():
bpy.types.unregister(VertexPaintDirt)
pass
if __name__ == "__main__":
register()

View File

@@ -21,7 +21,7 @@
import bpy
from bpy.props import *
from rna_prop_ui import rna_idprop_ui_prop_get, rna_idprop_ui_prop_clear
class MESH_OT_delete_edgeloop(bpy.types.Operator):
'''Delete an edge loop by merging the faces on each side to a single face loop'''
@@ -325,6 +325,42 @@ class WM_OT_context_cycle_enum(bpy.types.Operator):
exec("context.%s=advance_enum" % self.properties.data_path)
return {'FINISHED'}
class WM_OT_context_set_id(bpy.types.Operator):
'''Toggle a context value.'''
bl_idname = "wm.context_set_id"
bl_label = "Set Library ID"
bl_options = {'UNDO'}
data_path = rna_path_prop
value = StringProperty(name="Value",
description="Assign value", maxlen=1024, default="")
def execute(self, context):
value = self.properties.value
data_path = self.properties.data_path
# match the pointer type from the target property to bpy.data.*
# so we lookup the correct list.
data_path_base, data_path_prop = data_path.rsplit(".", 1)
data_prop_rna = eval("context.%s" % data_path_base).rna_type.properties[data_path_prop]
data_prop_rna_type = data_prop_rna.fixed_type
id_iter = None
for prop in bpy.data.rna_type.properties:
if prop.rna_type.identifier == "CollectionProperty":
if prop.fixed_type == data_prop_rna_type:
id_iter = prop.identifier
break
if id_iter:
value_id = getattr(bpy.data, id_iter).get(value)
exec("context.%s=value_id" % data_path)
return {'FINISHED'}
doc_id = StringProperty(name="Doc ID",
description="", maxlen=1024, default="", options={'HIDDEN'})
@@ -442,7 +478,7 @@ class WM_OT_path_open(bpy.types.Operator):
import os
import subprocess
filepath = bpy.utils.expandpath(self.properties.filepath)
filepath = bpy.path.abspath(self.properties.filepath)
filepath = os.path.normpath(filepath)
if not os.path.exists(filepath):
@@ -576,46 +612,139 @@ class WM_OT_doc_edit(bpy.types.Operator):
return wm.invoke_props_dialog(self, width=600)
import rna_prop_ui
from bpy.props import *
classes = [
MESH_OT_delete_edgeloop,
WM_OT_context_set_boolean,
WM_OT_context_set_int,
WM_OT_context_scale_int,
WM_OT_context_set_float,
WM_OT_context_set_string,
WM_OT_context_set_enum,
WM_OT_context_set_value,
WM_OT_context_toggle,
WM_OT_context_toggle_enum,
WM_OT_context_cycle_enum,
WM_OT_context_cycle_int,
WM_OT_context_modal_mouse,
rna_path = StringProperty(name="Property Edit",
description="Property data_path edit", maxlen=1024, default="", options={'HIDDEN'})
WM_OT_url_open,
WM_OT_path_open,
rna_value = StringProperty(name="Property Value",
description="Property value edit", maxlen=1024, default="")
WM_OT_doc_view,
WM_OT_doc_edit,
rna_property = StringProperty(name="Property Name",
description="Property name edit", maxlen=1024, default="")
# experemental!
rna_prop_ui.WM_OT_properties_edit,
rna_prop_ui.WM_OT_properties_add,
rna_prop_ui.WM_OT_properties_remove]
rna_min = FloatProperty(name="Min", default=0.0, precision=3)
rna_max = FloatProperty(name="Max", default=1.0, precision=3)
class WM_OT_properties_edit(bpy.types.Operator):
'''Internal use (edit a property data_path)'''
bl_idname = "wm.properties_edit"
bl_label = "Edit Property"
data_path = rna_path
property = rna_property
value = rna_value
min = rna_min
max = rna_max
description = StringProperty(name="Tip", default="")
def execute(self, context):
data_path = self.properties.data_path
value = self.properties.value
prop = self.properties.property
prop_old = self._last_prop[0]
try:
value_eval = eval(value)
except:
value_eval = value
# First remove
item = eval("context.%s" % data_path)
rna_idprop_ui_prop_clear(item, prop_old)
exec_str = "del item['%s']" % prop_old
# print(exec_str)
exec(exec_str)
# Reassign
exec_str = "item['%s'] = %s" % (prop, repr(value_eval))
# print(exec_str)
exec(exec_str)
self._last_prop[:] = [prop]
prop_type = type(item[prop])
prop_ui = rna_idprop_ui_prop_get(item, prop)
if prop_type in (float, int):
prop_ui['soft_min'] = prop_ui['min'] = prop_type(self.properties.min)
prop_ui['soft_max'] = prop_ui['max'] = prop_type(self.properties.max)
prop_ui['description'] = self.properties.description
return {'FINISHED'}
def invoke(self, context, event):
self._last_prop = [self.properties.property]
item = eval("context.%s" % self.properties.data_path)
# setup defaults
prop_ui = rna_idprop_ui_prop_get(item, self.properties.property, False) # dont create
if prop_ui:
self.properties.min = prop_ui.get("min", -1000000000)
self.properties.max = prop_ui.get("max", 1000000000)
self.properties.description = prop_ui.get("description", "")
wm = context.manager
# This crashes, TODO - fix
#return wm.invoke_props_popup(self, event)
wm.invoke_props_popup(self, event)
return {'RUNNING_MODAL'}
class WM_OT_properties_add(bpy.types.Operator):
'''Internal use (edit a property data_path)'''
bl_idname = "wm.properties_add"
bl_label = "Add Property"
data_path = rna_path
def execute(self, context):
item = eval("context.%s" % self.properties.data_path)
def unique_name(names):
prop = 'prop'
prop_new = prop
i = 1
while prop_new in names:
prop_new = prop + str(i)
i += 1
return prop_new
property = unique_name(item.keys())
item[property] = 1.0
return {'FINISHED'}
class WM_OT_properties_remove(bpy.types.Operator):
'''Internal use (edit a property data_path)'''
bl_idname = "wm.properties_remove"
bl_label = "Remove Property"
data_path = rna_path
property = rna_property
def execute(self, context):
item = eval("context.%s" % self.properties.data_path)
del item[self.properties.property]
return {'FINISHED'}
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -23,7 +23,8 @@ class ExportSomeData(bpy.types.Operator):
description="Choose between two items",
default='OPT_A')
def poll(self, context):
@classmethod
def poll(cls, context):
return context.active_object != None
def execute(self, context):
@@ -54,9 +55,6 @@ class ExportSomeData(bpy.types.Operator):
return self.execute(context)
bpy.types.register(ExportSomeData)
# Only needed if you want to add into a dynamic menu
menu_func = lambda self, context: self.layout.operator("export.some_data", text="Example Exporter...")
bpy.types.INFO_MT_file_export.append(menu_func)

View File

@@ -34,7 +34,5 @@ class ModalOperator(bpy.types.Operator):
return {'CANCELLED'}
bpy.types.register(ModalOperator)
if __name__ == "__main__":
bpy.ops.object.modal_operator()

View File

@@ -64,15 +64,3 @@ class ModalDrawOperator(bpy.types.Operator):
else:
self.report({'WARNING'}, "View3D not found, cannot run operator")
return {'CANCELLED'}
def register():
bpy.types.register(ModalDrawOperator)
def unregister():
bpy.types.unregister(ModalDrawOperator)
if __name__ == "__main__":
register()

View File

@@ -51,6 +51,3 @@ class ViewOperator(bpy.types.Operator):
else:
self.report({'WARNING'}, "Active space must be a View3d")
return {'CANCELLED'}
bpy.types.register(ViewOperator)

View File

@@ -9,18 +9,14 @@ class SimpleOperator(bpy.types.Operator):
bl_idname = "object.simple_operator"
bl_label = "Simple Object Operator"
def poll(self, context):
@classmethod
def poll(cls, context):
return context.active_object != None
def execute(self, context):
main(context)
return {'FINISHED'}
def register():
bpy.types.register(SimpleOperator)
def unregister():
bpy.types.unregister(SimpleOperator)
if __name__ == "__main__":
register()
bpy.ops.object.simple_operator()

View File

@@ -24,12 +24,14 @@ def main(context):
if is_editmode:
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
class UvOperator(bpy.types.Operator):
''''''
'''UV Operator description'''
bl_idname = "uv.simple_operator"
bl_label = "Simple UV Operator"
def poll(self, context):
@classmethod
def poll(cls, context):
obj = context.active_object
return (obj and obj.type == 'MESH')
@@ -37,7 +39,6 @@ class UvOperator(bpy.types.Operator):
main(context)
return {'FINISHED'}
bpy.types.register(UvOperator)
if __name__ == "__main__":
bpy.ops.uv.simple_operator()

View File

@@ -18,5 +18,3 @@ class OBJECT_PT_hello(bpy.types.Panel):
row.label(text="Active object is: " + obj.name)
row = layout.row()
row.prop(obj, "name")
bpy.types.register(OBJECT_PT_hello)

View File

@@ -19,27 +19,22 @@
# <pep8 compliant>
import bpy
narrowui = bpy.context.user_preferences.view.properties_width_check
################################################
# Generic Panels (Independent of DataType)
class MotionPathButtonsPanel(bpy.types.Panel):
class MotionPathButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_label = "Motion Paths"
bl_default_closed = True
def draw_settings(self, context, avs, wide_ui, bones=False):
def draw_settings(self, context, avs, bones=False):
layout = self.layout
mps = avs.motion_paths
if wide_ui:
layout.prop(mps, "type", expand=True)
else:
layout.prop(mps, "type", text="")
split = layout.split()
@@ -56,7 +51,6 @@ class MotionPathButtonsPanel(bpy.types.Panel):
if bones:
col.row().prop(mps, "bake_location", expand=True)
if wide_ui:
col = split.column()
col.label(text="Display:")
col.prop(mps, "show_frame_numbers", text="Frame Numbers")
@@ -67,7 +61,7 @@ class MotionPathButtonsPanel(bpy.types.Panel):
# FIXME: this panel still needs to be ported so that it will work correctly with animviz
class OnionSkinButtonsPanel(bpy.types.Panel):
class OnionSkinButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_label = "Onion Skinning"
@@ -77,12 +71,8 @@ class OnionSkinButtonsPanel(bpy.types.Panel):
layout = self.layout
arm = context.armature
wide_ui = context.region.width > narrowui
if wide_ui:
layout.prop(arm, "ghost_type", expand=True)
else:
layout.prop(arm, "ghost_type", text="")
split = layout.split()
@@ -97,124 +87,23 @@ class OnionSkinButtonsPanel(bpy.types.Panel):
sub.prop(arm, "ghost_step", text="Range")
sub.prop(arm, "ghost_size", text="Step")
if wide_ui:
col = split.column()
col.label(text="Display:")
col.prop(arm, "ghost_only_selected", text="Selected Only")
################################################
# Specific Panels for DataTypes
class OBJECT_PT_motion_paths(MotionPathButtonsPanel):
#bl_label = "Object Motion Paths"
bl_context = "object"
def poll(self, context):
return (context.object)
def draw(self, context):
layout = self.layout
ob = context.object
wide_ui = context.region.width > narrowui
self.draw_settings(context, ob.animation_visualisation, wide_ui)
layout.separator()
split = layout.split()
col = split.column()
col.operator("object.paths_calculate", text="Calculate Paths")
if wide_ui:
col = split.column()
col.operator("object.paths_clear", text="Clear Paths")
class OBJECT_PT_onion_skinning(OnionSkinButtonsPanel):
#bl_label = "Object Onion Skinning"
bl_context = "object"
def poll(self, context):
return (context.object)
def draw(self, context):
layout = self.layout
ob = context.object
wide_ui = context.region.width > narrowui
self.draw_settings(context, ob.animation_visualisation, wide_ui)
class DATA_PT_motion_paths(MotionPathButtonsPanel):
#bl_label = "Bones Motion Paths"
bl_context = "data"
def poll(self, context):
# XXX: include posemode check?
return (context.object) and (context.armature)
def draw(self, context):
layout = self.layout
ob = context.object
wide_ui = context.region.width > narrowui
self.draw_settings(context, ob.pose.animation_visualisation, wide_ui, bones=True)
layout.separator()
split = layout.split()
col = split.column()
col.operator("pose.paths_calculate", text="Calculate Paths")
if wide_ui:
col = split.column()
col.operator("pose.paths_clear", text="Clear Paths")
class DATA_PT_onion_skinning(OnionSkinButtonsPanel):
#bl_label = "Bones Onion Skinning"
bl_context = "data"
def poll(self, context):
# XXX: include posemode check?
return (context.object) and (context.armature)
def draw(self, context):
layout = self.layout
ob = context.object
wide_ui = context.region.width > narrowui
self.draw_settings(context, ob.pose.animation_visualisation, wide_ui, bones=True)
# NOTE:
# The specialised panel types defined here (i.e. OBJECT_PT_*, etc.)
# aren't registered here, but are rather imported to (and registered)
# in the files defining the contexts where they reside. Otherwise,
# these panels appear at the top of the lists by default.
#
# However, we keep these empty register funcs here just in case
# something will need them again one day, and also to make
# it easier to maintain these scripts.
classes = []
# The specialised panel types are derived in their respective UI modules
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -20,19 +20,18 @@
import bpy
from rna_prop_ui import PropertyPanel
narrowui = bpy.context.user_preferences.view.properties_width_check
class DataButtonsPanel(bpy.types.Panel):
class ArmatureButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "data"
def poll(self, context):
@classmethod
def poll(cls, context):
return context.armature
class DATA_PT_context_arm(DataButtonsPanel):
class DATA_PT_context_arm(ArmatureButtonsPanel, bpy.types.Panel):
bl_label = ""
bl_show_header = False
@@ -42,9 +41,7 @@ class DATA_PT_context_arm(DataButtonsPanel):
ob = context.object
arm = context.armature
space = context.space_data
wide_ui = context.region.width > narrowui
if wide_ui:
split = layout.split(percentage=0.65)
if ob:
split.template_ID(ob, "data")
@@ -52,27 +49,22 @@ class DATA_PT_context_arm(DataButtonsPanel):
elif arm:
split.template_ID(space, "pin_id")
split.separator()
else:
layout.template_ID(ob, "data")
class DATA_PT_custom_props_arm(DataButtonsPanel, PropertyPanel):
class DATA_PT_custom_props_arm(ArmatureButtonsPanel, PropertyPanel, bpy.types.Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
_context_path = "object.data"
class DATA_PT_skeleton(DataButtonsPanel):
class DATA_PT_skeleton(ArmatureButtonsPanel, bpy.types.Panel):
bl_label = "Skeleton"
def draw(self, context):
layout = self.layout
arm = context.armature
wide_ui = context.region.width > narrowui
if wide_ui:
layout.prop(arm, "pose_position", expand=True)
else:
layout.prop(arm, "pose_position", text="")
split = layout.split()
@@ -90,12 +82,11 @@ class DATA_PT_skeleton(DataButtonsPanel):
col.prop(arm, "deform_vertexgroups", text="Vertex Groups")
col.prop(arm, "deform_envelope", text="Envelopes")
if wide_ui:
col = split.column()
col.prop(arm, "deform_quaternion", text="Quaternion")
class DATA_PT_display(DataButtonsPanel):
class DATA_PT_display(ArmatureButtonsPanel, bpy.types.Panel):
bl_label = "Display"
def draw(self, context):
@@ -103,12 +94,8 @@ class DATA_PT_display(DataButtonsPanel):
ob = context.object
arm = context.armature
wide_ui = context.region.width > narrowui
if wide_ui:
layout.row().prop(arm, "drawtype", expand=True)
else:
layout.row().prop(arm, "drawtype", text="")
split = layout.split()
@@ -117,17 +104,17 @@ class DATA_PT_display(DataButtonsPanel):
col.prop(arm, "draw_axes", text="Axes")
col.prop(arm, "draw_custom_bone_shapes", text="Shapes")
if wide_ui:
col = split.column()
col.prop(arm, "draw_group_colors", text="Colors")
col.prop(ob, "x_ray", text="X-Ray")
col.prop(arm, "delay_deform", text="Delay Refresh")
class DATA_PT_bone_groups(DataButtonsPanel):
class DATA_PT_bone_groups(ArmatureButtonsPanel, bpy.types.Panel):
bl_label = "Bone Groups"
def poll(self, context):
@classmethod
def poll(cls, context):
return (context.object and context.object.type == 'ARMATURE' and context.object.pose)
def draw(self, context):
@@ -135,7 +122,6 @@ class DATA_PT_bone_groups(DataButtonsPanel):
ob = context.object
pose = ob.pose
wide_ui = context.region.width > narrowui
row = layout.row()
row.template_list(pose, "bone_groups", pose, "active_bone_group_index", rows=2)
@@ -157,7 +143,6 @@ class DATA_PT_bone_groups(DataButtonsPanel):
col = split.column()
col.prop(group, "color_set")
if group.color_set:
if wide_ui:
col = split.column()
col.template_triColorSet(group, "colors")
@@ -174,19 +159,15 @@ class DATA_PT_bone_groups(DataButtonsPanel):
# TODO: this panel will soon be depreceated too
class DATA_PT_ghost(DataButtonsPanel):
class DATA_PT_ghost(ArmatureButtonsPanel, bpy.types.Panel):
bl_label = "Ghost"
def draw(self, context):
layout = self.layout
arm = context.armature
wide_ui = context.region.width > narrowui
if wide_ui:
layout.prop(arm, "ghost_type", expand=True)
else:
layout.prop(arm, "ghost_type", text="")
split = layout.split()
@@ -201,17 +182,17 @@ class DATA_PT_ghost(DataButtonsPanel):
sub.prop(arm, "ghost_step", text="Range")
sub.prop(arm, "ghost_size", text="Step")
if wide_ui:
col = split.column()
col.label(text="Display:")
col.prop(arm, "ghost_only_selected", text="Selected Only")
class DATA_PT_iksolver_itasc(DataButtonsPanel):
class DATA_PT_iksolver_itasc(ArmatureButtonsPanel, bpy.types.Panel):
bl_label = "iTaSC parameters"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
ob = context.object
return (ob and ob.pose)
@@ -221,7 +202,6 @@ class DATA_PT_iksolver_itasc(DataButtonsPanel):
ob = context.object
itasc = ob.pose.ik_param
wide_ui = (context.region.width > narrowui)
row = layout.row()
row.prop(ob.pose, "ik_solver")
@@ -238,7 +218,6 @@ class DATA_PT_iksolver_itasc(DataButtonsPanel):
col = split.column()
col.prop(itasc, "precision")
if wide_ui:
col = split.column()
col.prop(itasc, "num_iter")
@@ -261,33 +240,57 @@ class DATA_PT_iksolver_itasc(DataButtonsPanel):
row.prop(itasc, "dampmax", text="Damp", slider=True)
row.prop(itasc, "dampeps", text="Eps", slider=True)
# import generic panels from other files
from properties_animviz import DATA_PT_motion_paths, DATA_PT_onion_skinning
from properties_animviz import MotionPathButtonsPanel, OnionSkinButtonsPanel
classes = [
DATA_PT_context_arm,
DATA_PT_skeleton,
DATA_PT_display,
DATA_PT_bone_groups,
DATA_PT_ghost,
DATA_PT_iksolver_itasc,
class DATA_PT_motion_paths(MotionPathButtonsPanel, bpy.types.Panel):
#bl_label = "Bones Motion Paths"
bl_context = "data"
DATA_PT_motion_paths,
#DATA_PT_onion_skinning,
@classmethod
def poll(cls, context):
# XXX: include posemode check?
return (context.object) and (context.armature)
DATA_PT_custom_props_arm]
def draw(self, context):
layout = self.layout
ob = context.object
self.draw_settings(context, ob.pose.animation_visualisation, bones=True)
layout.separator()
split = layout.split()
col = split.column()
col.operator("pose.paths_calculate", text="Calculate Paths")
col = split.column()
col.operator("pose.paths_clear", text="Clear Paths")
class DATA_PT_onion_skinning(OnionSkinButtonsPanel): #, bpy.types.Panel): # inherit from panel when ready
#bl_label = "Bones Onion Skinning"
bl_context = "data"
@classmethod
def poll(cls, context):
# XXX: include posemode check?
return (context.object) and (context.armature)
def draw(self, context):
layout = self.layout
ob = context.object
self.draw_settings(context, ob.pose.animation_visualisation, bones=True)
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -19,8 +19,6 @@
# <pep8 compliant>
import bpy
narrowui = bpy.context.user_preferences.view.properties_width_check
class PoseTemplateSettings(bpy.types.IDPropertyGroup):
pass
@@ -44,7 +42,8 @@ class DATA_PT_template(bpy.types.Panel):
templates = []
def poll(self, context):
@classmethod
def poll(cls, context):
if not context.armature:
return False
obj = context.object
@@ -212,7 +211,7 @@ class Graph(bpy.types.Operator):
import bpy
reload(graphviz_export)
obj = bpy.context.object
path = os.path.splitext(bpy.data.filepath)[0] + "-" + bpy.utils.clean_name(obj.name)
path = os.path.splitext(bpy.data.filepath)[0] + "-" + bpy.path.clean_name(obj.name)
path_dot = path + ".dot"
path_png = path + ".png"
saved = graphviz_export.graph_armature(bpy.context.object, path_dot, CONSTRAINTS=False, DRIVERS=False)
@@ -249,7 +248,7 @@ class AsScript(bpy.types.Operator):
def invoke(self, context, event):
import os
obj = context.object
self.properties.filepath = os.path.splitext(bpy.data.filepath)[0] + "-" + bpy.utils.clean_name(obj.name) + ".py"
self.properties.filepath = os.path.splitext(bpy.data.filepath)[0] + "-" + bpy.path.clean_name(obj.name) + ".py"
wm = context.manager
wm.add_fileselect(self)
return {'RUNNING_MODAL'}
@@ -262,7 +261,8 @@ class ActiveAssign(bpy.types.Operator):
bl_idname = "pose.metarig_assign"
bl_label = "Assign to the active posebone"
def poll(self, context):
@classmethod
def poll(cls, context):
bone = context.active_pose_bone
return bool(bone and bone.id_data.mode == 'POSE')
@@ -280,7 +280,8 @@ class ActiveClear(bpy.types.Operator):
bl_idname = "pose.metarig_clear"
bl_label = "Metarig Clear Type"
def poll(self, context):
@classmethod
def poll(cls, context):
bone = context.active_pose_bone
return bool(bone and bone.id_data.mode == 'POSE')
@@ -304,36 +305,14 @@ class INFO_MT_armature_metarig_add(bpy.types.Menu):
layout.operator_context = 'INVOKE_REGION_WIN'
for submodule_type in rigify.get_submodule_types():
text = bpy.utils.display_name(submodule_type)
text = bpy.path.display_name(submodule_type)
layout.operator("pose.metarig_sample_add", text=text, icon='OUTLINER_OB_ARMATURE').metarig_type = submodule_type
classes = [
DATA_PT_template,
PoseTemplateSettings,
PoseTemplate,
Reload,
Generate,
Validate,
Sample,
Graph,
AsScript,
ActiveAssign,
ActiveClear,
INFO_MT_armature_metarig_add]
menu_func = (lambda self, context: self.layout.menu("INFO_MT_armature_metarig_add", icon='OUTLINER_OB_ARMATURE'))
import space_info # ensure the menu is loaded first
def register():
register = bpy.types.register
for cls in classes:
register(cls)
PoseTemplate.StringProperty(attr="name",
name="Name of the slave",
description="",
@@ -361,10 +340,6 @@ def register():
def unregister():
bpy.types.Scene.RemoveProperty("pose_templates")
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
space_info.INFO_MT_armature_add.remove(menu_func)
if __name__ == "__main__":

View File

@@ -20,19 +20,18 @@
import bpy
from rna_prop_ui import PropertyPanel
narrowui = bpy.context.user_preferences.view.properties_width_check
class BoneButtonsPanel(bpy.types.Panel):
class BoneButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "bone"
def poll(self, context):
@classmethod
def poll(cls, context):
return (context.bone or context.edit_bone)
class BONE_PT_context_bone(BoneButtonsPanel):
class BONE_PT_context_bone(BoneButtonsPanel, bpy.types.Panel):
bl_label = ""
bl_show_header = False
@@ -48,7 +47,8 @@ class BONE_PT_context_bone(BoneButtonsPanel):
row.prop(bone, "name", text="")
class BONE_PT_custom_props(BoneButtonsPanel, PropertyPanel):
class BONE_PT_custom_props(BoneButtonsPanel, PropertyPanel, bpy.types.Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@property
def _context_path(self):
@@ -59,7 +59,7 @@ class BONE_PT_custom_props(BoneButtonsPanel, PropertyPanel):
return "active_bone"
class BONE_PT_transform(BoneButtonsPanel):
class BONE_PT_transform(BoneButtonsPanel, bpy.types.Panel):
bl_label = "Transform"
def draw(self, context):
@@ -67,11 +67,9 @@ class BONE_PT_transform(BoneButtonsPanel):
ob = context.object
bone = context.bone
wide_ui = context.region.width > narrowui
if not bone:
bone = context.edit_bone
if wide_ui:
row = layout.row()
row.column().prop(bone, "head")
row.column().prop(bone, "tail")
@@ -82,17 +80,10 @@ class BONE_PT_transform(BoneButtonsPanel):
sub.prop(bone, "roll", text="")
sub.label()
sub.prop(bone, "lock")
else:
col = layout.column()
col.prop(bone, "head")
col.prop(bone, "tail")
col.prop(bone, "roll")
col.prop(bone, "lock")
else:
pchan = ob.pose.bones[context.bone.name]
if wide_ui:
row = layout.row()
col = row.column()
col.prop(pchan, "location")
@@ -112,27 +103,14 @@ class BONE_PT_transform(BoneButtonsPanel):
row.column().prop(pchan, "scale")
layout.prop(pchan, "rotation_mode")
else:
col = layout.column()
sub = col.column()
sub.active = not (bone.parent and bone.connected)
sub.prop(pchan, "location")
col.label(text="Rotation:")
col.prop(pchan, "rotation_mode", text="")
if pchan.rotation_mode == 'QUATERNION':
col.prop(pchan, "rotation_quaternion", text="")
elif pchan.rotation_mode == 'AXIS_ANGLE':
col.prop(pchan, "rotation_axis_angle", text="")
else:
col.prop(pchan, "rotation_euler", text="")
col.prop(pchan, "scale")
class BONE_PT_transform_locks(BoneButtonsPanel):
class BONE_PT_transform_locks(BoneButtonsPanel, bpy.types.Panel):
bl_label = "Transform Locks"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
return context.bone
def draw(self, context):
@@ -159,7 +137,7 @@ class BONE_PT_transform_locks(BoneButtonsPanel):
row.column().prop(pchan, "lock_scale")
class BONE_PT_relations(BoneButtonsPanel):
class BONE_PT_relations(BoneButtonsPanel, bpy.types.Panel):
bl_label = "Relations"
def draw(self, context):
@@ -168,7 +146,6 @@ class BONE_PT_relations(BoneButtonsPanel):
ob = context.object
bone = context.bone
arm = context.armature
wide_ui = context.region.width > narrowui
if not bone:
bone = context.edit_bone
@@ -188,7 +165,6 @@ class BONE_PT_relations(BoneButtonsPanel):
col.label(text="Bone Group:")
col.prop_object(pchan, "bone_group", ob.pose, "bone_groups", text="")
if wide_ui:
col = split.column()
col.label(text="Parent:")
if context.bone:
@@ -206,10 +182,11 @@ class BONE_PT_relations(BoneButtonsPanel):
sub.prop(bone, "local_location", text="Local Location")
class BONE_PT_display(BoneButtonsPanel):
class BONE_PT_display(BoneButtonsPanel, bpy.types.Panel):
bl_label = "Display"
def poll(self, context):
@classmethod
def poll(cls, context):
return context.bone
def draw(self, context):
@@ -217,7 +194,6 @@ class BONE_PT_display(BoneButtonsPanel):
ob = context.object
bone = context.bone
wide_ui = context.region.width > narrowui
if not bone:
bone = context.edit_bone
@@ -233,7 +209,6 @@ class BONE_PT_display(BoneButtonsPanel):
col.prop(bone, "draw_wire", text="Wireframe")
col.prop(bone, "hide", text="Hide")
if wide_ui:
col = split.column()
col.label(text="Custom Shape:")
@@ -242,11 +217,12 @@ class BONE_PT_display(BoneButtonsPanel):
col.prop_object(pchan, "custom_shape_transform", ob.pose, "bones", text="At")
class BONE_PT_inverse_kinematics(BoneButtonsPanel):
class BONE_PT_inverse_kinematics(BoneButtonsPanel, bpy.types.Panel):
bl_label = "Inverse Kinematics"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
return context.active_pose_bone
def draw(self, context):
@@ -255,7 +231,6 @@ class BONE_PT_inverse_kinematics(BoneButtonsPanel):
ob = context.object
bone = context.bone
pchan = ob.pose.bones[bone.name]
wide_ui = context.region.width > narrowui
row = layout.row()
row.prop(ob.pose, "ik_solver")
@@ -267,14 +242,11 @@ class BONE_PT_inverse_kinematics(BoneButtonsPanel):
row.prop(pchan, "ik_stiffness_x", text="Stiffness", slider=True)
row.active = pchan.ik_dof_x and pchan.has_ik
if wide_ui:
split = layout.split(percentage=0.25)
sub = split.row()
else:
sub = layout.column(align=True)
sub.prop(pchan, "ik_limit_x", text="Limit")
sub.active = pchan.ik_dof_x and pchan.has_ik
if wide_ui:
sub = split.row(align=True)
sub.prop(pchan, "ik_min_x", text="")
sub.prop(pchan, "ik_max_x", text="")
@@ -287,14 +259,12 @@ class BONE_PT_inverse_kinematics(BoneButtonsPanel):
row.prop(pchan, "ik_stiffness_y", text="Stiffness", slider=True)
row.active = pchan.ik_dof_y and pchan.has_ik
if wide_ui:
split = layout.split(percentage=0.25)
sub = split.row()
else:
sub = layout.column(align=True)
sub.prop(pchan, "ik_limit_y", text="Limit")
sub.active = pchan.ik_dof_y and pchan.has_ik
if wide_ui:
sub = split.row(align=True)
sub.prop(pchan, "ik_min_y", text="")
sub.prop(pchan, "ik_max_y", text="")
@@ -307,21 +277,17 @@ class BONE_PT_inverse_kinematics(BoneButtonsPanel):
sub.prop(pchan, "ik_stiffness_z", text="Stiffness", slider=True)
sub.active = pchan.ik_dof_z and pchan.has_ik
if wide_ui:
split = layout.split(percentage=0.25)
sub = split.row()
else:
sub = layout.column(align=True)
sub.prop(pchan, "ik_limit_z", text="Limit")
sub.active = pchan.ik_dof_z and pchan.has_ik
if wide_ui:
sub = split.row(align=True)
sub.prop(pchan, "ik_min_z", text="")
sub.prop(pchan, "ik_max_z", text="")
sub.active = pchan.ik_dof_z and pchan.ik_limit_z and pchan.has_ik
split = layout.split()
split.prop(pchan, "ik_stretch", text="Stretch", slider=True)
if wide_ui:
split.label()
split.active = pchan.has_ik
@@ -330,7 +296,6 @@ class BONE_PT_inverse_kinematics(BoneButtonsPanel):
col = split.column()
col.prop(pchan, "ik_rot_control", text="Control Rotation")
col.active = pchan.has_ik
if wide_ui:
col = split.column()
col.prop(pchan, "ik_rot_weight", text="Weight", slider=True)
col.active = pchan.has_ik
@@ -340,7 +305,7 @@ class BONE_PT_inverse_kinematics(BoneButtonsPanel):
#row.prop(pchan, "ik_lin_weight", text="Weight", slider=True)
class BONE_PT_deform(BoneButtonsPanel):
class BONE_PT_deform(BoneButtonsPanel, bpy.types.Panel):
bl_label = "Deform"
bl_default_closed = True
@@ -356,7 +321,6 @@ class BONE_PT_deform(BoneButtonsPanel):
layout = self.layout
bone = context.bone
wide_ui = context.region.width > narrowui
if not bone:
bone = context.edit_bone
@@ -378,7 +342,6 @@ class BONE_PT_deform(BoneButtonsPanel):
sub.prop(bone, "head_radius", text="Head")
sub.prop(bone, "tail_radius", text="Tail")
if wide_ui:
col = split.column()
col.label(text="Curved Bones:")
@@ -390,28 +353,13 @@ class BONE_PT_deform(BoneButtonsPanel):
col.label(text="Offset:")
col.prop(bone, "cyclic_offset")
classes = [
BONE_PT_context_bone,
BONE_PT_transform,
BONE_PT_transform_locks,
BONE_PT_relations,
BONE_PT_display,
BONE_PT_inverse_kinematics,
BONE_PT_deform,
BONE_PT_custom_props]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -20,20 +20,19 @@
import bpy
from rna_prop_ui import PropertyPanel
narrowui = bpy.context.user_preferences.view.properties_width_check
class DataButtonsPanel(bpy.types.Panel):
class CameraButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "data"
def poll(self, context):
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
return context.camera and (engine in self.COMPAT_ENGINES)
return context.camera and (engine in cls.COMPAT_ENGINES)
class DATA_PT_context_camera(DataButtonsPanel):
class DATA_PT_context_camera(CameraButtonsPanel, bpy.types.Panel):
bl_label = ""
bl_show_header = False
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -44,9 +43,7 @@ class DATA_PT_context_camera(DataButtonsPanel):
ob = context.object
cam = context.camera
space = context.space_data
wide_ui = context.region.width > narrowui
if wide_ui:
split = layout.split(percentage=0.65)
if ob:
split.template_ID(ob, "data")
@@ -54,19 +51,14 @@ class DATA_PT_context_camera(DataButtonsPanel):
elif cam:
split.template_ID(space, "pin_id")
split.separator()
else:
if ob:
layout.template_ID(ob, "data")
elif cam:
layout.template_ID(space, "pin_id")
class DATA_PT_custom_props_camera(DataButtonsPanel, PropertyPanel):
_context_path = "object.data"
class DATA_PT_custom_props_camera(CameraButtonsPanel, PropertyPanel, bpy.types.Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
_context_path = "object.data"
class DATA_PT_camera(DataButtonsPanel):
class DATA_PT_camera(CameraButtonsPanel, bpy.types.Panel):
bl_label = "Lens"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -74,12 +66,8 @@ class DATA_PT_camera(DataButtonsPanel):
layout = self.layout
cam = context.camera
wide_ui = context.region.width > narrowui
if wide_ui:
layout.prop(cam, "type", expand=True)
else:
layout.prop(cam, "type", text="")
split = layout.split()
@@ -89,7 +77,6 @@ class DATA_PT_camera(DataButtonsPanel):
col.prop(cam, "lens", text="Angle")
elif cam.lens_unit == 'DEGREES':
col.prop(cam, "angle")
if wide_ui:
col = split.column()
col.prop(cam, "lens_unit", text="")
@@ -105,7 +92,6 @@ class DATA_PT_camera(DataButtonsPanel):
col.prop(cam, "shift_x", text="X")
col.prop(cam, "shift_y", text="Y")
if wide_ui:
col = split.column(align=True)
col.label(text="Clipping:")
col.prop(cam, "clip_start", text="Start")
@@ -118,16 +104,14 @@ class DATA_PT_camera(DataButtonsPanel):
col = split.column()
col.prop(cam, "dof_object", text="")
if wide_ui:
col = split.column()
else:
col = col.column()
if cam.dof_object != None:
col.enabled = False
col.prop(cam, "dof_distance", text="Distance")
class DATA_PT_camera_display(DataButtonsPanel):
class DATA_PT_camera_display(CameraButtonsPanel, bpy.types.Panel):
bl_label = "Display"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -135,7 +119,6 @@ class DATA_PT_camera_display(DataButtonsPanel):
layout = self.layout
cam = context.camera
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -145,7 +128,6 @@ class DATA_PT_camera_display(DataButtonsPanel):
col.prop(cam, "show_title_safe", text="Title Safe")
col.prop(cam, "show_name", text="Name")
if wide_ui:
col = split.column()
col.prop(cam, "draw_size", text="Size")
col.separator()
@@ -155,24 +137,12 @@ class DATA_PT_camera_display(DataButtonsPanel):
sub.prop(cam, "passepartout_alpha", text="Alpha", slider=True)
classes = [
DATA_PT_context_camera,
DATA_PT_camera,
DATA_PT_camera_display,
DATA_PT_custom_props_camera]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -20,34 +20,35 @@
import bpy
from rna_prop_ui import PropertyPanel
narrowui = bpy.context.user_preferences.view.properties_width_check
class DataButtonsPanel(bpy.types.Panel):
class CurveButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "data"
def poll(self, context):
@classmethod
def poll(cls, context):
return (context.object and context.object.type in ('CURVE', 'SURFACE', 'TEXT') and context.curve)
class DataButtonsPanelCurve(DataButtonsPanel):
class CurveButtonsPanelCurve(CurveButtonsPanel):
'''Same as above but for curves only'''
def poll(self, context):
@classmethod
def poll(cls, context):
return (context.object and context.object.type == 'CURVE' and context.curve)
class DataButtonsPanelActive(DataButtonsPanel):
class CurveButtonsPanelActive(CurveButtonsPanel):
'''Same as above but for curves only'''
def poll(self, context):
@classmethod
def poll(cls, context):
curve = context.curve
return (curve and type(curve) is not bpy.types.TextCurve and curve.splines.active)
class DATA_PT_context_curve(DataButtonsPanel):
class DATA_PT_context_curve(CurveButtonsPanel, bpy.types.Panel):
bl_label = ""
bl_show_header = False
@@ -57,10 +58,7 @@ class DATA_PT_context_curve(DataButtonsPanel):
ob = context.object
curve = context.curve
space = context.space_data
wide_ui = context.region.width > narrowui
if wide_ui:
split = layout.split(percentage=0.65)
if ob:
@@ -69,15 +67,14 @@ class DATA_PT_context_curve(DataButtonsPanel):
elif curve:
split.template_ID(space, "pin_id")
split.separator()
else:
layout.template_ID(ob, "data")
class DATA_PT_custom_props_curve(DataButtonsPanel, PropertyPanel):
class DATA_PT_custom_props_curve(CurveButtonsPanel, PropertyPanel, bpy.types.Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
_context_path = "object.data"
class DATA_PT_shape_curve(DataButtonsPanel):
class DATA_PT_shape_curve(CurveButtonsPanel, bpy.types.Panel):
bl_label = "Shape"
def draw(self, context):
@@ -85,7 +82,6 @@ class DATA_PT_shape_curve(DataButtonsPanel):
ob = context.object
curve = context.curve
wide_ui = context.region.width > narrowui
is_surf = (ob.type == 'SURFACE')
is_curve = (ob.type == 'CURVE')
is_text = (ob.type == 'TEXT')
@@ -109,7 +105,6 @@ class DATA_PT_shape_curve(DataButtonsPanel):
col.label(text="Display:")
col.prop(curve, "fast", text="Fast Editing")
if wide_ui:
col = split.column()
if is_surf:
@@ -130,10 +125,11 @@ class DATA_PT_shape_curve(DataButtonsPanel):
col.prop(curve, "auto_texspace")
class DATA_PT_geometry_curve(DataButtonsPanel):
class DATA_PT_geometry_curve(CurveButtonsPanel, bpy.types.Panel):
bl_label = "Geometry"
def poll(self, context):
@classmethod
def poll(cls, context):
obj = context.object
if obj and obj.type == 'SURFACE':
return False
@@ -144,7 +140,6 @@ class DATA_PT_geometry_curve(DataButtonsPanel):
layout = self.layout
curve = context.curve
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -155,7 +150,6 @@ class DATA_PT_geometry_curve(DataButtonsPanel):
col.label(text="Taper Object:")
col.prop(curve, "taper_object", text="")
if wide_ui:
col = split.column()
col.label(text="Bevel:")
col.prop(curve, "bevel_depth", text="Depth")
@@ -164,7 +158,7 @@ class DATA_PT_geometry_curve(DataButtonsPanel):
col.prop(curve, "bevel_object", text="")
class DATA_PT_pathanim(DataButtonsPanelCurve):
class DATA_PT_pathanim(CurveButtonsPanelCurve, bpy.types.Panel):
bl_label = "Path Animation"
def draw_header(self, context):
@@ -176,7 +170,6 @@ class DATA_PT_pathanim(DataButtonsPanelCurve):
layout = self.layout
curve = context.curve
wide_ui = context.region.width > narrowui
layout.active = curve.use_path
@@ -189,14 +182,14 @@ class DATA_PT_pathanim(DataButtonsPanelCurve):
col = split.column()
col.prop(curve, "use_path_follow")
col.prop(curve, "use_stretch")
col.prop(curve, "use_deform_bounds")
if wide_ui:
col = split.column()
col.prop(curve, "use_radius")
col.prop(curve, "use_time_offset", text="Offset Children")
class DATA_PT_active_spline(DataButtonsPanelActive):
class DATA_PT_active_spline(CurveButtonsPanelActive, bpy.types.Panel):
bl_label = "Active Spline"
def draw(self, context):
@@ -267,10 +260,11 @@ class DATA_PT_active_spline(DataButtonsPanelActive):
layout.prop(act_spline, "smooth")
class DATA_PT_font(DataButtonsPanel):
class DATA_PT_font(CurveButtonsPanel, bpy.types.Panel):
bl_label = "Font"
def poll(self, context):
@classmethod
def poll(cls, context):
return (context.object and context.object.type == 'TEXT' and context.curve)
def draw(self, context):
@@ -278,20 +272,15 @@ class DATA_PT_font(DataButtonsPanel):
text = context.curve
char = context.curve.edit_format
wide_ui = context.region.width > narrowui
layout.template_ID(text, "font", open="font.open", unlink="font.unlink")
#if wide_ui:
# layout.prop(text, "font")
#else:
# layout.prop(text, "font", text="")
#layout.prop(text, "font")
split = layout.split()
col = split.column()
col.prop(text, "text_size", text="Size")
if wide_ui:
col = split.column()
col.prop(text, "shear")
@@ -301,7 +290,6 @@ class DATA_PT_font(DataButtonsPanel):
col.label(text="Object Font:")
col.prop(text, "family", text="")
if wide_ui:
col = split.column()
col.label(text="Text on Curve:")
col.prop(text, "text_on_curve", text="")
@@ -314,7 +302,6 @@ class DATA_PT_font(DataButtonsPanel):
colsub.prop(text, "ul_position", text="Position")
colsub.prop(text, "ul_height", text="Thickness")
if wide_ui:
col = split.column()
col.label(text="Character:")
col.prop(char, "bold")
@@ -329,23 +316,20 @@ class DATA_PT_font(DataButtonsPanel):
col.prop(char, "use_small_caps")
class DATA_PT_paragraph(DataButtonsPanel):
class DATA_PT_paragraph(CurveButtonsPanel, bpy.types.Panel):
bl_label = "Paragraph"
def poll(self, context):
@classmethod
def poll(cls, context):
return (context.object and context.object.type == 'TEXT' and context.curve)
def draw(self, context):
layout = self.layout
text = context.curve
wide_ui = context.region.width > narrowui
layout.label(text="Align:")
if wide_ui:
layout.prop(text, "spacemode", expand=True)
else:
layout.prop(text, "spacemode", text="")
split = layout.split()
@@ -355,29 +339,27 @@ class DATA_PT_paragraph(DataButtonsPanel):
col.prop(text, "word_spacing", text="Word")
col.prop(text, "line_dist", text="Line")
if wide_ui:
col = split.column(align=True)
col.label(text="Offset:")
col.prop(text, "offset_x", text="X")
col.prop(text, "offset_y", text="Y")
class DATA_PT_textboxes(DataButtonsPanel):
class DATA_PT_textboxes(CurveButtonsPanel, bpy.types.Panel):
bl_label = "Text Boxes"
def poll(self, context):
@classmethod
def poll(cls, context):
return (context.object and context.object.type == 'TEXT' and context.curve)
def draw(self, context):
layout = self.layout
text = context.curve
wide_ui = context.region.width > narrowui
split = layout.split()
col = split.column()
col.operator("font.textbox_add", icon='ZOOMIN')
if wide_ui:
col = split.column()
for i, box in enumerate(text.textboxes):
@@ -394,7 +376,6 @@ class DATA_PT_textboxes(DataButtonsPanel):
col.prop(box, "width", text="Width")
col.prop(box, "height", text="Height")
if wide_ui:
col = split.column(align=True)
col.label(text="Offset:")
@@ -404,29 +385,12 @@ class DATA_PT_textboxes(DataButtonsPanel):
row.operator("font.textbox_remove", text='', icon='X', emboss=False).index = i
classes = [
DATA_PT_context_curve,
DATA_PT_shape_curve,
DATA_PT_geometry_curve,
DATA_PT_pathanim,
DATA_PT_active_spline,
DATA_PT_font,
DATA_PT_paragraph,
DATA_PT_textboxes,
DATA_PT_custom_props_curve]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -19,49 +19,37 @@
# <pep8 compliant>
import bpy
narrowui = bpy.context.user_preferences.view.properties_width_check
class DataButtonsPanel(bpy.types.Panel):
class DataButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "data"
def poll(self, context):
@classmethod
def poll(cls, context):
return (context.object and context.object.type == 'EMPTY')
class DATA_PT_empty(DataButtonsPanel):
class DATA_PT_empty(DataButtonsPanel, bpy.types.Panel):
bl_label = "Empty"
def draw(self, context):
layout = self.layout
ob = context.object
wide_ui = context.region.width > narrowui
if wide_ui:
layout.prop(ob, "empty_draw_type", text="Display")
else:
layout.prop(ob, "empty_draw_type", text="")
layout.prop(ob, "empty_draw_size", text="Size")
classes = [
DATA_PT_empty]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -20,8 +20,6 @@
import bpy
from rna_prop_ui import PropertyPanel
narrowui = bpy.context.user_preferences.view.properties_width_check
class LAMP_MT_sunsky_presets(bpy.types.Menu):
bl_label = "Sun & Sky Presets"
@@ -31,25 +29,25 @@ class LAMP_MT_sunsky_presets(bpy.types.Menu):
draw = bpy.types.Menu.draw_preset
class DataButtonsPanel(bpy.types.Panel):
class DataButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "data"
def poll(self, context):
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
return context.lamp and (engine in self.COMPAT_ENGINES)
return context.lamp and (engine in cls.COMPAT_ENGINES)
class DATA_PT_preview(DataButtonsPanel):
class DATA_PT_preview(DataButtonsPanel, bpy.types.Panel):
bl_label = "Preview"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def draw(self, context):
self.layout.template_preview(context.lamp)
class DATA_PT_context_lamp(DataButtonsPanel):
class DATA_PT_context_lamp(DataButtonsPanel, bpy.types.Panel):
bl_label = ""
bl_show_header = False
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -60,29 +58,23 @@ class DATA_PT_context_lamp(DataButtonsPanel):
ob = context.object
lamp = context.lamp
space = context.space_data
wide_ui = context.region.width > narrowui
if wide_ui:
split = layout.split(percentage=0.65)
if ob:
split.template_ID(ob, "data")
split.separator()
elif lamp:
split.template_ID(space, "pin_id")
split.separator()
else:
if ob:
layout.template_ID(ob, "data")
elif lamp:
layout.template_ID(space, "pin_id")
class DATA_PT_custom_props_lamp(DataButtonsPanel, PropertyPanel):
_context_path = "object.data"
class DATA_PT_custom_props_lamp(DataButtonsPanel, PropertyPanel, bpy.types.Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
_context_path = "object.data"
class DATA_PT_lamp(DataButtonsPanel):
class DATA_PT_lamp(DataButtonsPanel, bpy.types.Panel):
bl_label = "Lamp"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -90,12 +82,8 @@ class DATA_PT_lamp(DataButtonsPanel):
layout = self.layout
lamp = context.lamp
wide_ui = context.region.width > narrowui
if wide_ui:
layout.prop(lamp, "type", expand=True)
else:
layout.prop(lamp, "type", text="")
split = layout.split()
@@ -121,7 +109,6 @@ class DATA_PT_lamp(DataButtonsPanel):
col.prop(lamp, "distance")
col.prop(lamp, "gamma")
if wide_ui:
col = split.column()
col.prop(lamp, "negative")
col.prop(lamp, "layer", text="This Layer Only")
@@ -129,20 +116,20 @@ class DATA_PT_lamp(DataButtonsPanel):
col.prop(lamp, "diffuse")
class DATA_PT_sunsky(DataButtonsPanel):
class DATA_PT_sunsky(DataButtonsPanel, bpy.types.Panel):
bl_label = "Sky & Atmosphere"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
lamp = context.lamp
engine = context.scene.render.engine
return (lamp and lamp.type == 'SUN') and (engine in self.COMPAT_ENGINES)
return (lamp and lamp.type == 'SUN') and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
lamp = context.lamp.sky
wide_ui = context.region.width > narrowui
row = layout.row(align=True)
row.prop(lamp, "use_sky")
@@ -167,7 +154,6 @@ class DATA_PT_sunsky(DataButtonsPanel):
sub.row().prop(lamp, "sky_color_space", expand=True)
sub.prop(lamp, "sky_exposure", text="Exposure")
if wide_ui:
col = split.column()
col.active = lamp.use_sky
col.label(text="Horizon:")
@@ -193,7 +179,6 @@ class DATA_PT_sunsky(DataButtonsPanel):
col.prop(lamp, "sun_intensity", text="Sun")
col.prop(lamp, "atmosphere_distance_factor", text="Distance")
if wide_ui:
col = split.column()
col.active = lamp.use_atmosphere
col.label(text="Scattering:")
@@ -202,25 +187,36 @@ class DATA_PT_sunsky(DataButtonsPanel):
sub.prop(lamp, "atmosphere_extinction", slider=True, text="Extinction")
class DATA_PT_shadow(DataButtonsPanel):
class DATA_PT_shadow(DataButtonsPanel, bpy.types.Panel):
bl_label = "Shadow"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
lamp = context.lamp
engine = context.scene.render.engine
return (lamp and lamp.type in ('POINT', 'SUN', 'SPOT', 'AREA')) and (engine in self.COMPAT_ENGINES)
return (lamp and lamp.type in ('POINT', 'SUN', 'SPOT', 'AREA')) and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
lamp = context.lamp
wide_ui = context.region.width > narrowui
if wide_ui:
layout.prop(lamp, "shadow_method", expand=True)
else:
layout.prop(lamp, "shadow_method", text="")
if lamp.shadow_method == 'NOSHADOW' and lamp.type == 'AREA':
split = layout.split()
col= split.column()
col.label(text="Form factor sampling:")
sub=col.row(align=True)
if lamp.shape == 'SQUARE':
sub.prop(lamp, "shadow_ray_samples_x", text="Samples")
elif lamp.shape == 'RECTANGLE':
sub.prop(lamp, "shadow_ray_samples_x", text="Samples X")
sub.prop(lamp, "shadow_ray_samples_y", text="Samples Y")
if lamp.shadow_method != 'NOSHADOW':
split = layout.split()
@@ -228,65 +224,51 @@ class DATA_PT_shadow(DataButtonsPanel):
col = split.column()
col.prop(lamp, "shadow_color", text="")
if wide_ui:
col = split.column()
col.prop(lamp, "shadow_layer", text="This Layer Only")
col.prop(lamp, "only_shadow")
if lamp.shadow_method == 'RAY_SHADOW':
col = layout.column()
split = layout.split()
col = split.column()
col.label(text="Sampling:")
if wide_ui:
col.row().prop(lamp, "shadow_ray_sampling_method", expand=True)
else:
col.prop(lamp, "shadow_ray_sampling_method", text="")
if lamp.type in ('POINT', 'SUN', 'SPOT'):
split = layout.split()
sub = col.row()
col = split.column()
col.prop(lamp, "shadow_soft_size", text="Soft Size")
col.prop(lamp, "shadow_ray_samples", text="Samples")
if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
col.prop(lamp, "shadow_adaptive_threshold", text="Threshold")
if wide_ui:
col = split.column()
sub.prop(lamp, "shadow_ray_samples", text="Samples")
sub.prop(lamp, "shadow_soft_size", text="Soft Size")
elif lamp.type == 'AREA':
split = layout.split()
col = split.column()
sub = col.row(align=True)
if lamp.shape == 'SQUARE':
col.prop(lamp, "shadow_ray_samples_x", text="Samples")
sub.prop(lamp, "shadow_ray_samples_x", text="Samples")
elif lamp.shape == 'RECTANGLE':
col.prop(lamp, "shadow_ray_samples_x", text="Samples X")
col.prop(lamp, "shadow_ray_samples_y", text="Samples Y")
sub.prop(lamp, "shadow_ray_samples_x", text="Samples X")
sub.prop(lamp, "shadow_ray_samples_y", text="Samples Y")
col.row().prop(lamp, "shadow_ray_sampling_method", expand=True)
split = layout.split()
col = split.column()
if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
col.prop(lamp, "shadow_adaptive_threshold", text="Threshold")
if wide_ui:
col = split.column()
elif lamp.shadow_ray_sampling_method == 'CONSTANT_JITTERED':
if wide_ui:
if lamp.type == 'AREA' and lamp.shadow_ray_sampling_method == 'CONSTANT_JITTERED':
col = split.column()
col = split.column()
col.prop(lamp, "umbra")
col.prop(lamp, "dither")
col.prop(lamp, "jitter")
else:
if wide_ui:
col = split.column()
elif lamp.shadow_method == 'BUFFER_SHADOW':
col = layout.column()
col.label(text="Buffer Type:")
if wide_ui:
col.row().prop(lamp, "shadow_buffer_type", expand=True)
else:
col.row().prop(lamp, "shadow_buffer_type", text="")
if lamp.shadow_buffer_type in ('REGULAR', 'HALFWAY', 'DEEP'):
split = layout.split()
@@ -298,7 +280,6 @@ class DATA_PT_shadow(DataButtonsPanel):
sub.prop(lamp, "shadow_buffer_soft", text="Soft")
sub.prop(lamp, "shadow_buffer_bias", text="Bias")
if wide_ui:
col = split.column()
col.label(text="Sample Buffers:")
col.prop(lamp, "shadow_sample_buffers", text="")
@@ -319,7 +300,6 @@ class DATA_PT_shadow(DataButtonsPanel):
sub.active = not lamp.auto_clip_start
sub.prop(lamp, "shadow_buffer_clip_start", text="Clip Start")
if wide_ui:
col = split.column()
col.prop(lamp, "auto_clip_end", text="Autoclip End")
sub = col.column()
@@ -327,26 +307,27 @@ class DATA_PT_shadow(DataButtonsPanel):
sub.prop(lamp, "shadow_buffer_clip_end", text=" Clip End")
class DATA_PT_area(DataButtonsPanel):
class DATA_PT_area(DataButtonsPanel, bpy.types.Panel):
bl_label = "Area Shape"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
lamp = context.lamp
engine = context.scene.render.engine
return (lamp and lamp.type == 'AREA') and (engine in self.COMPAT_ENGINES)
return (lamp and lamp.type == 'AREA') and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
lamp = context.lamp
layout = self.layout
split = layout.split()
col = split.column()
col.row().prop(lamp, "shape", expand=True)
sub = col.column(align=True)
col.row().prop(lamp, "shape", expand=True)
sub = col.row(align=True)
if (lamp.shape == 'SQUARE'):
sub.prop(lamp, "size")
elif (lamp.shape == 'RECTANGLE'):
@@ -354,20 +335,20 @@ class DATA_PT_area(DataButtonsPanel):
sub.prop(lamp, "size_y", text="Size Y")
class DATA_PT_spot(DataButtonsPanel):
class DATA_PT_spot(DataButtonsPanel, bpy.types.Panel):
bl_label = "Spot Shape"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
lamp = context.lamp
engine = context.scene.render.engine
return (lamp and lamp.type == 'SPOT') and (engine in self.COMPAT_ENGINES)
return (lamp and lamp.type == 'SPOT') and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
lamp = context.lamp
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -378,10 +359,8 @@ class DATA_PT_spot(DataButtonsPanel):
col.prop(lamp, "square")
col.prop(lamp, "show_cone")
if wide_ui:
col = split.column()
else:
col.separator()
col.prop(lamp, "halo")
sub = col.column(align=True)
sub.active = lamp.halo
@@ -390,16 +369,17 @@ class DATA_PT_spot(DataButtonsPanel):
sub.prop(lamp, "halo_step", text="Step")
class DATA_PT_falloff_curve(DataButtonsPanel):
class DATA_PT_falloff_curve(DataButtonsPanel, bpy.types.Panel):
bl_label = "Falloff Curve"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
lamp = context.lamp
engine = context.scene.render.engine
return (lamp and lamp.type in ('POINT', 'SPOT') and lamp.falloff_type == 'CUSTOM_CURVE') and (engine in self.COMPAT_ENGINES)
return (lamp and lamp.type in ('POINT', 'SPOT') and lamp.falloff_type == 'CUSTOM_CURVE') and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
lamp = context.lamp
@@ -407,31 +387,12 @@ class DATA_PT_falloff_curve(DataButtonsPanel):
self.layout.template_curve_mapping(lamp, "falloff_curve")
classes = [
LAMP_MT_sunsky_presets,
DATA_PT_context_lamp,
DATA_PT_preview,
DATA_PT_lamp,
DATA_PT_falloff_curve,
DATA_PT_area,
DATA_PT_spot,
DATA_PT_shadow,
DATA_PT_sunsky,
DATA_PT_custom_props_lamp]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -20,19 +20,18 @@
import bpy
from rna_prop_ui import PropertyPanel
narrowui = bpy.context.user_preferences.view.properties_width_check
class DataButtonsPanel(bpy.types.Panel):
class DataButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "data"
def poll(self, context):
@classmethod
def poll(cls, context):
return context.lattice
class DATA_PT_context_lattice(DataButtonsPanel):
class DATA_PT_context_lattice(DataButtonsPanel, bpy.types.Panel):
bl_label = ""
bl_show_header = False
@@ -42,9 +41,7 @@ class DATA_PT_context_lattice(DataButtonsPanel):
ob = context.object
lat = context.lattice
space = context.space_data
wide_ui = context.region.width > narrowui
if wide_ui:
split = layout.split(percentage=0.65)
if ob:
split.template_ID(ob, "data")
@@ -52,44 +49,36 @@ class DATA_PT_context_lattice(DataButtonsPanel):
elif lat:
split.template_ID(space, "pin_id")
split.separator()
else:
if ob:
layout.template_ID(ob, "data")
elif lat:
layout.template_ID(space, "pin_id")
class DATA_PT_custom_props_lattice(DataButtonsPanel, PropertyPanel):
class DATA_PT_custom_props_lattice(DataButtonsPanel, PropertyPanel, bpy.types.Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
_context_path = "object.data"
class DATA_PT_lattice(DataButtonsPanel):
class DATA_PT_lattice(DataButtonsPanel, bpy.types.Panel):
bl_label = "Lattice"
def draw(self, context):
layout = self.layout
lat = context.lattice
wide_ui = context.region.width > narrowui
split = layout.split()
col = split.column()
col.prop(lat, "points_u")
if wide_ui:
col = split.column()
col.prop(lat, "interpolation_type_u", text="")
split = layout.split()
col = split.column()
col.prop(lat, "points_v")
if wide_ui:
col = split.column()
col.prop(lat, "interpolation_type_v", text="")
split = layout.split()
col = split.column()
col.prop(lat, "points_w")
if wide_ui:
col = split.column()
col.prop(lat, "interpolation_type_w", text="")
@@ -98,23 +87,12 @@ class DATA_PT_lattice(DataButtonsPanel):
row.prop_object(lat, "vertex_group", context.object, "vertex_groups", text="")
classes = [
DATA_PT_context_lattice,
DATA_PT_lattice,
DATA_PT_custom_props_lattice]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -20,8 +20,6 @@
import bpy
from rna_prop_ui import PropertyPanel
narrowui = bpy.context.user_preferences.view.properties_width_check
class MESH_MT_vertex_group_specials(bpy.types.Menu):
bl_label = "Vertex Group Specials"
@@ -49,17 +47,18 @@ class MESH_MT_shape_key_specials(bpy.types.Menu):
layout.operator("object.shape_key_mirror", icon='ARROW_LEFTRIGHT')
class DataButtonsPanel(bpy.types.Panel):
class MeshButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "data"
def poll(self, context):
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
return context.mesh and (engine in self.COMPAT_ENGINES)
return context.mesh and (engine in cls.COMPAT_ENGINES)
class DATA_PT_context_mesh(DataButtonsPanel):
class DATA_PT_context_mesh(MeshButtonsPanel, bpy.types.Panel):
bl_label = ""
bl_show_header = False
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -70,9 +69,7 @@ class DATA_PT_context_mesh(DataButtonsPanel):
ob = context.object
mesh = context.mesh
space = context.space_data
wide_ui = context.region.width > narrowui
if wide_ui:
split = layout.split(percentage=0.65)
if ob:
split.template_ID(ob, "data")
@@ -80,19 +77,14 @@ class DATA_PT_context_mesh(DataButtonsPanel):
elif mesh:
split.template_ID(space, "pin_id")
split.separator()
else:
if ob:
layout.template_ID(ob, "data")
elif mesh:
layout.template_ID(space, "pin_id")
class DATA_PT_custom_props_mesh(DataButtonsPanel, PropertyPanel):
_context_path = "object.data"
class DATA_PT_custom_props_mesh(MeshButtonsPanel, PropertyPanel, bpy.types.Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
_context_path = "object.data"
class DATA_PT_normals(DataButtonsPanel):
class DATA_PT_normals(MeshButtonsPanel, bpy.types.Panel):
bl_label = "Normals"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -100,7 +92,6 @@ class DATA_PT_normals(DataButtonsPanel):
layout = self.layout
mesh = context.mesh
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -110,14 +101,12 @@ class DATA_PT_normals(DataButtonsPanel):
sub.active = mesh.autosmooth
sub.prop(mesh, "autosmooth_angle", text="Angle")
if wide_ui:
col = split.column()
else:
col.separator()
col.prop(mesh, "double_sided")
class DATA_PT_settings(DataButtonsPanel):
class DATA_PT_settings(MeshButtonsPanel, bpy.types.Panel):
bl_label = "Settings"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -129,13 +118,15 @@ class DATA_PT_settings(DataButtonsPanel):
layout.prop(mesh, "texture_mesh")
class DATA_PT_vertex_groups(DataButtonsPanel):
class DATA_PT_vertex_groups(MeshButtonsPanel, bpy.types.Panel):
bl_label = "Vertex Groups"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
return (context.object and context.object.type in ('MESH', 'LATTICE') and (engine in self.COMPAT_ENGINES))
obj = context.object
return (obj and obj.type in ('MESH', 'LATTICE') and (engine in cls.COMPAT_ENGINES))
def draw(self, context):
layout = self.layout
@@ -176,13 +167,15 @@ class DATA_PT_vertex_groups(DataButtonsPanel):
layout.prop(context.tool_settings, "vertex_group_weight", text="Weight")
class DATA_PT_shape_keys(DataButtonsPanel):
class DATA_PT_shape_keys(MeshButtonsPanel, bpy.types.Panel):
bl_label = "Shape Keys"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
return (context.object and context.object.type in ('MESH', 'LATTICE', 'CURVE', 'SURFACE') and (engine in self.COMPAT_ENGINES))
obj = context.object
return (obj and obj.type in ('MESH', 'LATTICE', 'CURVE', 'SURFACE') and (engine in cls.COMPAT_ENGINES))
def draw(self, context):
layout = self.layout
@@ -190,7 +183,6 @@ class DATA_PT_shape_keys(DataButtonsPanel):
ob = context.object
key = ob.data.shape_keys
kb = ob.active_shape_key
wide_ui = context.region.width > narrowui
enable_edit = ob.mode != 'EDIT'
enable_edit_value = False
@@ -223,17 +215,11 @@ class DATA_PT_shape_keys(DataButtonsPanel):
split = layout.split(percentage=0.4)
row = split.row()
row.enabled = enable_edit
if wide_ui:
row.prop(key, "relative")
row = split.row()
row.alignment = 'RIGHT'
if not wide_ui:
layout.prop(key, "relative")
row = layout.row()
sub = row.row(align=True)
subsub = sub.row(align=True)
subsub.active = enable_edit_value
@@ -261,7 +247,6 @@ class DATA_PT_shape_keys(DataButtonsPanel):
col.prop(kb, "slider_min", text="Min")
col.prop(kb, "slider_max", text="Max")
if wide_ui:
col = split.column(align=True)
col.active = enable_edit_value
col.label(text="Blend:")
@@ -274,7 +259,7 @@ class DATA_PT_shape_keys(DataButtonsPanel):
row.prop(key, "slurph")
class DATA_PT_uv_texture(DataButtonsPanel):
class DATA_PT_uv_texture(MeshButtonsPanel, bpy.types.Panel):
bl_label = "UV Texture"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -297,11 +282,12 @@ class DATA_PT_uv_texture(DataButtonsPanel):
layout.prop(lay, "name")
class DATA_PT_texface(DataButtonsPanel):
class DATA_PT_texface(MeshButtonsPanel, bpy.types.Panel):
bl_label = "Texture Face"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
ob = context.active_object
rd = context.scene.render
@@ -311,7 +297,6 @@ class DATA_PT_texface(DataButtonsPanel):
layout = self.layout
col = layout.column()
wide_ui = context.region.width > narrowui
me = context.mesh
tf = me.faces.active_tface
@@ -329,7 +314,6 @@ class DATA_PT_texface(DataButtonsPanel):
col.prop(tf, "twoside")
col.prop(tf, "object_color")
if wide_ui:
col = split.column()
col.prop(tf, "halo")
@@ -344,7 +328,7 @@ class DATA_PT_texface(DataButtonsPanel):
col.label(text="No UV Texture")
class DATA_PT_vertex_colors(DataButtonsPanel):
class DATA_PT_vertex_colors(MeshButtonsPanel, bpy.types.Panel):
bl_label = "Vertex Colors"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -367,32 +351,12 @@ class DATA_PT_vertex_colors(DataButtonsPanel):
layout.prop(lay, "name")
classes = [
MESH_MT_vertex_group_specials,
MESH_MT_shape_key_specials,
DATA_PT_context_mesh,
DATA_PT_normals,
DATA_PT_settings,
DATA_PT_vertex_groups,
DATA_PT_shape_keys,
DATA_PT_uv_texture,
DATA_PT_texface,
DATA_PT_vertex_colors,
DATA_PT_custom_props_mesh]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -20,19 +20,18 @@
import bpy
from rna_prop_ui import PropertyPanel
narrowui = bpy.context.user_preferences.view.properties_width_check
class DataButtonsPanel(bpy.types.Panel):
class DataButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "data"
def poll(self, context):
@classmethod
def poll(cls, context):
return context.meta_ball
class DATA_PT_context_metaball(DataButtonsPanel):
class DATA_PT_context_metaball(DataButtonsPanel, bpy.types.Panel):
bl_label = ""
bl_show_header = False
@@ -42,9 +41,7 @@ class DATA_PT_context_metaball(DataButtonsPanel):
ob = context.object
mball = context.meta_ball
space = context.space_data
wide_ui = context.region.width > narrowui
if wide_ui:
split = layout.split(percentage=0.65)
if ob:
split.template_ID(ob, "data")
@@ -52,25 +49,20 @@ class DATA_PT_context_metaball(DataButtonsPanel):
elif mball:
split.template_ID(space, "pin_id")
split.separator()
else:
if ob:
layout.template_ID(ob, "data")
elif mball:
layout.template_ID(space, "pin_id")
class DATA_PT_custom_props_metaball(DataButtonsPanel, PropertyPanel):
class DATA_PT_custom_props_metaball(DataButtonsPanel, PropertyPanel, bpy.types.Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
_context_path = "object.data"
class DATA_PT_metaball(DataButtonsPanel):
class DATA_PT_metaball(DataButtonsPanel, bpy.types.Panel):
bl_label = "Metaball"
def draw(self, context):
layout = self.layout
mball = context.meta_ball
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -80,34 +72,27 @@ class DATA_PT_metaball(DataButtonsPanel):
sub.prop(mball, "wire_size", text="View")
sub.prop(mball, "render_size", text="Render")
if wide_ui:
col = split.column()
col.label(text="Settings:")
col.prop(mball, "threshold", text="Threshold")
layout.label(text="Update:")
if wide_ui:
layout.prop(mball, "flag", expand=True)
else:
layout.prop(mball, "flag", text="")
class DATA_PT_metaball_element(DataButtonsPanel):
class DATA_PT_metaball_element(DataButtonsPanel, bpy.types.Panel):
bl_label = "Active Element"
def poll(self, context):
@classmethod
def poll(cls, context):
return (context.meta_ball and context.meta_ball.active_element)
def draw(self, context):
layout = self.layout
metaelem = context.meta_ball.active_element
wide_ui = context.region.width > narrowui
if wide_ui:
layout.prop(metaelem, "type")
else:
layout.prop(metaelem, "type", text="")
split = layout.split()
@@ -117,7 +102,6 @@ class DATA_PT_metaball_element(DataButtonsPanel):
col.prop(metaelem, "negative", text="Negative")
col.prop(metaelem, "hide", text="Hide")
if wide_ui:
col = split.column(align=True)
if metaelem.type in ('CUBE', 'ELLIPSOID'):
@@ -136,24 +120,12 @@ class DATA_PT_metaball_element(DataButtonsPanel):
col.prop(metaelem, "size_y", text="Y")
classes = [
DATA_PT_context_metaball,
DATA_PT_metaball,
DATA_PT_metaball_element,
DATA_PT_custom_props_metaball]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -19,46 +19,40 @@
# <pep8 compliant>
import bpy
narrowui = bpy.context.user_preferences.view.properties_width_check
narrowmod = 260
class DataButtonsPanel(bpy.types.Panel):
class ModifierButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "modifier"
class DATA_PT_modifiers(DataButtonsPanel):
class DATA_PT_modifiers(ModifierButtonsPanel, bpy.types.Panel):
bl_label = "Modifiers"
def draw(self, context):
layout = self.layout
ob = context.object
wide_ui = context.region.width > narrowui
compact_mod = context.region.width < narrowmod
layout.operator_menu_enum("object.modifier_add", "type")
for md in ob.modifiers:
box = layout.template_modifier(md, compact=compact_mod)
box = layout.template_modifier(md)
if box:
# match enum type to our functions, avoids a lookup table.
getattr(self, md.type)(box, ob, md, wide_ui)
getattr(self, md.type)(box, ob, md)
# the mt.type enum is (ab)used for a lookup on function names
# ...to avoid lengthy if statements
# so each type must have a function here.
def ARMATURE(self, layout, ob, md, wide_ui):
def ARMATURE(self, layout, ob, md):
split = layout.split()
col = split.column()
col.label(text="Object:")
col.prop(md, "object", text="")
if wide_ui:
col = split.column()
col.label(text="Vertex Group::")
col.prop_object(md, "vertex_group", ob, "vertex_groups", text="")
@@ -73,18 +67,13 @@ class DATA_PT_modifiers(DataButtonsPanel):
col.prop(md, "use_vertex_groups", text="Vertex Groups")
col.prop(md, "use_bone_envelopes", text="Bone Envelopes")
if wide_ui:
col = split.column()
col.label(text="Deformation:")
col.prop(md, "quaternion")
col.prop(md, "multi_modifier")
def ARRAY(self, layout, ob, md, wide_ui):
if wide_ui:
def ARRAY(self, layout, ob, md):
layout.prop(md, "fit_type")
else:
layout.prop(md, "fit_type", text="")
if md.fit_type == 'FIXED_COUNT':
layout.prop(md, "count")
@@ -111,7 +100,6 @@ class DATA_PT_modifiers(DataButtonsPanel):
sub.prop(md, "merge_end_vertices", text="First Last")
sub.prop(md, "merge_distance", text="Distance")
if wide_ui:
col = split.column()
col.prop(md, "relative_offset")
sub = col.column()
@@ -131,13 +119,12 @@ class DATA_PT_modifiers(DataButtonsPanel):
col.prop(md, "start_cap")
col.prop(md, "end_cap")
def BEVEL(self, layout, ob, md, wide_ui):
def BEVEL(self, layout, ob, md):
split = layout.split()
col = split.column()
col.prop(md, "width")
if wide_ui:
col = split.column()
col.prop(md, "only_vertices")
@@ -148,40 +135,35 @@ class DATA_PT_modifiers(DataButtonsPanel):
elif md.limit_method == 'WEIGHT':
layout.row().prop(md, "edge_weight_method", expand=True)
def BOOLEAN(self, layout, ob, md, wide_ui):
def BOOLEAN(self, layout, ob, md):
split = layout.split()
col = split.column()
col.label(text="Operation:")
col.prop(md, "operation", text="")
if wide_ui:
col = split.column()
col.label(text="Object:")
col.prop(md, "object", text="")
def BUILD(self, layout, ob, md, wide_ui):
def BUILD(self, layout, ob, md):
split = layout.split()
col = split.column()
col.prop(md, "frame_start")
col.prop(md, "length")
if wide_ui:
col = split.column()
col.prop(md, "randomize")
sub = col.column()
sub.active = md.randomize
sub.prop(md, "seed")
def CAST(self, layout, ob, md, wide_ui):
def CAST(self, layout, ob, md):
split = layout.split(percentage=0.25)
if wide_ui:
split.label(text="Cast Type:")
split.prop(md, "cast_type", text="")
else:
layout.prop(md, "cast_type", text="")
split = layout.split(percentage=0.25)
@@ -201,37 +183,35 @@ class DATA_PT_modifiers(DataButtonsPanel):
col = split.column()
col.label(text="Vertex Group:")
col.prop_object(md, "vertex_group", ob, "vertex_groups", text="")
if wide_ui:
col = split.column()
col.label(text="Control Object:")
col.prop(md, "object", text="")
if md.object:
col.prop(md, "use_transform")
def CLOTH(self, layout, ob, md, wide_ui):
def CLOTH(self, layout, ob, md):
layout.label(text="See Cloth panel.")
def COLLISION(self, layout, ob, md, wide_ui):
def COLLISION(self, layout, ob, md):
layout.label(text="See Collision panel.")
def CURVE(self, layout, ob, md, wide_ui):
def CURVE(self, layout, ob, md):
split = layout.split()
col = split.column()
col.label(text="Object:")
col.prop(md, "object", text="")
if wide_ui:
col = split.column()
col.label(text="Vertex Group:")
col.prop_object(md, "vertex_group", ob, "vertex_groups", text="")
layout.label(text="Deformation Axis:")
layout.row().prop(md, "deform_axis", expand=True)
def DECIMATE(self, layout, ob, md, wide_ui):
def DECIMATE(self, layout, ob, md):
layout.prop(md, "ratio")
layout.label(text="Face Count: %s" % str(md.face_count))
def DISPLACE(self, layout, ob, md, wide_ui):
def DISPLACE(self, layout, ob, md):
split = layout.split()
col = split.column()
@@ -240,7 +220,6 @@ class DATA_PT_modifiers(DataButtonsPanel):
col.label(text="Vertex Group:")
col.prop_object(md, "vertex_group", ob, "vertex_groups", text="")
if wide_ui:
col = split.column()
col.label(text="Direction:")
col.prop(md, "direction", text="")
@@ -258,11 +237,10 @@ class DATA_PT_modifiers(DataButtonsPanel):
col = split.column()
col.prop(md, "midlevel")
if wide_ui:
col = split.column()
col.prop(md, "strength")
def EDGE_SPLIT(self, layout, ob, md, wide_ui):
def EDGE_SPLIT(self, layout, ob, md):
split = layout.split()
col = split.column()
@@ -271,11 +249,10 @@ class DATA_PT_modifiers(DataButtonsPanel):
sub.active = md.use_edge_angle
sub.prop(md, "split_angle")
if wide_ui:
col = split.column()
col.prop(md, "use_sharp", text="Sharp Edges")
def EXPLODE(self, layout, ob, md, wide_ui):
def EXPLODE(self, layout, ob, md):
split = layout.split()
col = split.column()
@@ -285,7 +262,6 @@ class DATA_PT_modifiers(DataButtonsPanel):
sub.active = bool(md.vertex_group)
sub.prop(md, "protect")
if wide_ui:
col = split.column()
col.prop(md, "split_edges")
col.prop(md, "unborn")
@@ -295,10 +271,10 @@ class DATA_PT_modifiers(DataButtonsPanel):
layout.operator("object.explode_refresh", text="Refresh")
def FLUID_SIMULATION(self, layout, ob, md, wide_ui):
def FLUID_SIMULATION(self, layout, ob, md):
layout.label(text="See Fluid panel.")
def HOOK(self, layout, ob, md, wide_ui):
def HOOK(self, layout, ob, md):
split = layout.split()
col = split.column()
@@ -307,7 +283,6 @@ class DATA_PT_modifiers(DataButtonsPanel):
if md.object and md.object.type == 'ARMATURE':
col.label(text="Bone:")
col.prop_object(md, "subtarget", md.object.data, "bones", text="")
if wide_ui:
col = split.column()
col.label(text="Vertex Group:")
col.prop_object(md, "vertex_group", ob, "vertex_groups", text="")
@@ -319,10 +294,8 @@ class DATA_PT_modifiers(DataButtonsPanel):
col = split.column()
col.prop(md, "falloff")
col.prop(md, "force", slider=True)
if wide_ui:
col = split.column()
else:
col.separator()
col.operator("object.hook_reset", text="Reset")
col.operator("object.hook_recenter", text="Recenter")
@@ -332,25 +305,23 @@ class DATA_PT_modifiers(DataButtonsPanel):
row.operator("object.hook_select", text="Select")
row.operator("object.hook_assign", text="Assign")
def LATTICE(self, layout, ob, md, wide_ui):
def LATTICE(self, layout, ob, md):
split = layout.split()
col = split.column()
col.label(text="Object:")
col.prop(md, "object", text="")
if wide_ui:
col = split.column()
col.label(text="Vertex Group:")
col.prop_object(md, "vertex_group", ob, "vertex_groups", text="")
def MASK(self, layout, ob, md, wide_ui):
def MASK(self, layout, ob, md):
split = layout.split()
col = split.column()
col.label(text="Mode:")
col.prop(md, "mode", text="")
if wide_ui:
col = split.column()
if md.mode == 'ARMATURE':
col.label(text="Armature:")
@@ -363,14 +334,13 @@ class DATA_PT_modifiers(DataButtonsPanel):
sub.active = bool(md.vertex_group)
sub.prop(md, "invert")
def MESH_DEFORM(self, layout, ob, md, wide_ui):
def MESH_DEFORM(self, layout, ob, md):
split = layout.split()
col = split.column()
sub = col.column()
sub.label(text="Object:")
sub.prop(md, "object", text="")
sub.active = not md.is_bound
if wide_ui:
col = split.column()
col.label(text="Vertex Group:")
col.prop_object(md, "vertex_group", ob, "vertex_groups", text="")
@@ -391,16 +361,12 @@ class DATA_PT_modifiers(DataButtonsPanel):
col = split.column()
col.prop(md, "precision")
if wide_ui:
col = split.column()
col.prop(md, "dynamic")
def MIRROR(self, layout, ob, md, wide_ui):
def MIRROR(self, layout, ob, md):
layout.prop(md, "merge_limit")
if wide_ui:
split = layout.split(percentage=0.25)
else:
split = layout.split(percentage=0.4)
col = split.column()
col.label(text="Axis:")
@@ -408,11 +374,7 @@ class DATA_PT_modifiers(DataButtonsPanel):
col.prop(md, "y")
col.prop(md, "z")
if wide_ui:
col = split.column()
else:
subsplit = layout.split()
col = subsplit.column()
col.label(text="Options:")
col.prop(md, "clip", text="Clipping")
col.prop(md, "mirror_vertex_groups", text="Vertex Groups")
@@ -426,11 +388,8 @@ class DATA_PT_modifiers(DataButtonsPanel):
col.label(text="Mirror Object:")
col.prop(md, "mirror_object", text="")
def MULTIRES(self, layout, ob, md, wide_ui):
if wide_ui:
def MULTIRES(self, layout, ob, md):
layout.row().prop(md, "subdivision_type", expand=True)
else:
layout.row().prop(md, "subdivision_type", text="")
split = layout.split()
col = split.column()
@@ -438,7 +397,6 @@ class DATA_PT_modifiers(DataButtonsPanel):
col.prop(md, "sculpt_levels", text="Sculpt")
col.prop(md, "render_levels", text="Render")
if wide_ui:
col = split.column()
col.enabled = ob.mode != 'EDIT'
@@ -460,7 +418,7 @@ class DATA_PT_modifiers(DataButtonsPanel):
row.operator("object.multires_external_save", text="Save External...")
row.label()
def PARTICLE_INSTANCE(self, layout, ob, md, wide_ui):
def PARTICLE_INSTANCE(self, layout, ob, md):
layout.prop(md, "object")
layout.prop(md, "particle_system_number", text="Particle System")
@@ -471,7 +429,6 @@ class DATA_PT_modifiers(DataButtonsPanel):
col.prop(md, "children")
col.prop(md, "size")
if wide_ui:
col = split.column()
col.label(text="Show Particles When:")
col.prop(md, "alive")
@@ -488,15 +445,14 @@ class DATA_PT_modifiers(DataButtonsPanel):
col.row().prop(md, "axis", expand=True)
col.prop(md, "keep_shape")
if wide_ui:
col = split.column()
col.prop(md, "position", slider=True)
col.prop(md, "random_position", text="Random", slider=True)
def PARTICLE_SYSTEM(self, layout, ob, md, wide_ui):
def PARTICLE_SYSTEM(self, layout, ob, md):
layout.label(text="See Particle panel.")
def SCREW(self, layout, ob, md, wide_ui):
def SCREW(self, layout, ob, md):
split = layout.split()
col = split.column()
@@ -506,7 +462,6 @@ class DATA_PT_modifiers(DataButtonsPanel):
col.prop(md, "steps")
col.prop(md, "render_steps")
if wide_ui:
col = split.column()
row = col.row()
row.active = (md.object is None or md.use_object_screw_offset == False)
@@ -518,12 +473,11 @@ class DATA_PT_modifiers(DataButtonsPanel):
col.prop(md, "use_normal_flip")
col.prop(md, "iterations")
def SHRINKWRAP(self, layout, ob, md, wide_ui):
def SHRINKWRAP(self, layout, ob, md):
split = layout.split()
col = split.column()
col.label(text="Target:")
col.prop(md, "target", text="")
if wide_ui:
col = split.column()
col.label(text="Vertex Group:")
col.prop_object(md, "vertex_group", ob, "vertex_groups", text="")
@@ -534,15 +488,12 @@ class DATA_PT_modifiers(DataButtonsPanel):
col.prop(md, "offset")
col.prop(md, "subsurf_levels")
if wide_ui:
col = split.column()
col.label(text="Mode:")
col.prop(md, "mode", text="")
if wide_ui:
split = layout.split(percentage=0.25)
else:
split = layout.split(percentage=0.35)
col = split.column()
if md.mode == 'PROJECT':
@@ -556,11 +507,8 @@ class DATA_PT_modifiers(DataButtonsPanel):
col.prop(md, "negative")
col.prop(md, "positive")
if wide_ui:
col = split.column()
else:
subsplit = layout.split()
col = subsplit.column()
col.label(text="Cull Faces:")
col.prop(md, "cull_front_faces", text="Front")
col.prop(md, "cull_back_faces", text="Back")
@@ -571,14 +519,13 @@ class DATA_PT_modifiers(DataButtonsPanel):
elif md.mode == 'NEAREST_SURFACEPOINT':
layout.prop(md, "keep_above_surface")
def SIMPLE_DEFORM(self, layout, ob, md, wide_ui):
def SIMPLE_DEFORM(self, layout, ob, md):
split = layout.split()
col = split.column()
col.label(text="Mode:")
col.prop(md, "mode", text="")
if wide_ui:
col = split.column()
col.label(text="Vertex Group:")
col.prop_object(md, "vertex_group", ob, "vertex_groups", text="")
@@ -592,7 +539,6 @@ class DATA_PT_modifiers(DataButtonsPanel):
sub.active = (md.origin != "")
sub.prop(md, "relative")
if wide_ui:
col = split.column()
col.label(text="Deform:")
col.prop(md, "factor")
@@ -601,10 +547,10 @@ class DATA_PT_modifiers(DataButtonsPanel):
col.prop(md, "lock_x_axis")
col.prop(md, "lock_y_axis")
def SMOKE(self, layout, ob, md, wide_ui):
def SMOKE(self, layout, ob, md):
layout.label(text="See Smoke panel.")
def SMOOTH(self, layout, ob, md, wide_ui):
def SMOOTH(self, layout, ob, md):
split = layout.split(percentage=0.25)
col = split.column()
@@ -619,10 +565,10 @@ class DATA_PT_modifiers(DataButtonsPanel):
col.label(text="Vertex Group:")
col.prop_object(md, "vertex_group", ob, "vertex_groups", text="")
def SOFT_BODY(self, layout, ob, md, wide_ui):
def SOFT_BODY(self, layout, ob, md):
layout.label(text="See Soft Body panel.")
def SOLIDIFY(self, layout, ob, md, wide_ui):
def SOLIDIFY(self, layout, ob, md):
split = layout.split()
@@ -635,7 +581,6 @@ class DATA_PT_modifiers(DataButtonsPanel):
col.prop(md, "edge_crease_outer", text="Outer")
col.prop(md, "edge_crease_rim", text="Rim")
if wide_ui:
col = split.column()
col.prop(md, "offset")
@@ -655,11 +600,8 @@ class DATA_PT_modifiers(DataButtonsPanel):
# col.label(text="Vertex Group:")
# col.prop_object(md, "vertex_group", ob, "vertex_groups", text="")
def SUBSURF(self, layout, ob, md, wide_ui):
if wide_ui:
def SUBSURF(self, layout, ob, md):
layout.row().prop(md, "subdivision_type", expand=True)
else:
layout.row().prop(md, "subdivision_type", text="")
split = layout.split()
col = split.column()
@@ -667,16 +609,15 @@ class DATA_PT_modifiers(DataButtonsPanel):
col.prop(md, "levels", text="View")
col.prop(md, "render_levels", text="Render")
if wide_ui:
col = split.column()
col.label(text="Options:")
col.prop(md, "subsurf_uv")
col.prop(md, "optimal_display")
def SURFACE(self, layout, ob, md, wide_ui):
def SURFACE(self, layout, ob, md):
layout.label(text="See Fields panel.")
def UV_PROJECT(self, layout, ob, md, wide_ui):
def UV_PROJECT(self, layout, ob, md):
if ob.type == 'MESH':
split = layout.split()
@@ -684,7 +625,6 @@ class DATA_PT_modifiers(DataButtonsPanel):
col.label(text="Image:")
col.prop(md, "image", text="")
if wide_ui:
col = split.column()
col.label(text="UV Layer:")
col.prop_object(md, "uv_layer", ob.data, "uv_textures", text="")
@@ -696,7 +636,6 @@ class DATA_PT_modifiers(DataButtonsPanel):
for proj in md.projectors:
col.prop(proj, "object", text="")
if wide_ui:
col = split.column()
sub = col.column(align=True)
sub.prop(md, "aspect_x", text="Aspect X")
@@ -706,7 +645,7 @@ class DATA_PT_modifiers(DataButtonsPanel):
sub.prop(md, "scale_x", text="Scale X")
sub.prop(md, "scale_y", text="Scale Y")
def WAVE(self, layout, ob, md, wide_ui):
def WAVE(self, layout, ob, md):
split = layout.split()
col = split.column()
@@ -715,7 +654,6 @@ class DATA_PT_modifiers(DataButtonsPanel):
col.prop(md, "y")
col.prop(md, "cyclic")
if wide_ui:
col = split.column()
col.prop(md, "normals")
sub = col.column()
@@ -733,7 +671,6 @@ class DATA_PT_modifiers(DataButtonsPanel):
sub.prop(md, "lifetime", text="Life")
col.prop(md, "damping_time", text="Damping")
if wide_ui:
col = split.column()
col.label(text="Position:")
sub = col.column(align=True)
@@ -760,26 +697,17 @@ class DATA_PT_modifiers(DataButtonsPanel):
col.prop(md, "speed", slider=True)
col.prop(md, "height", slider=True)
if wide_ui:
col = split.column()
col.prop(md, "width", slider=True)
col.prop(md, "narrowness", slider=True)
classes = [
DATA_PT_modifiers]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -19,36 +19,31 @@
# <pep8 compliant>
import bpy
narrowui = bpy.context.user_preferences.view.properties_width_check
class PhysicsButtonsPanel(bpy.types.Panel):
class PhysicsButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "physics"
def poll(self, context):
ob = context.active_object
rd = context.scene.render
return ob and ob.game and (rd.engine in self.COMPAT_ENGINES)
class PHYSICS_PT_game_physics(PhysicsButtonsPanel):
class PHYSICS_PT_game_physics(PhysicsButtonsPanel, bpy.types.Panel):
bl_label = "Physics"
COMPAT_ENGINES = {'BLENDER_GAME'}
@classmethod
def poll(cls, context):
ob = context.active_object
rd = context.scene.render
return ob and ob.game and (rd.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
ob = context.active_object
game = ob.game
soft = ob.game.soft_body
wide_ui = context.region.width > narrowui
if wide_ui:
layout.prop(game, "physics_type")
else:
layout.prop(game, "physics_type", text="")
layout.separator()
#if game.physics_type == 'DYNAMIC':
@@ -60,7 +55,6 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel):
col.prop(game, "ghost")
col.prop(ob, "hide_render", text="Invisible") # out of place but useful
if wide_ui:
col = split.column()
col.prop(game, "material_physics")
col.prop(game, "rotate_from_normal")
@@ -76,7 +70,6 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel):
col.prop(game, "radius")
col.prop(game, "form_factor")
if wide_ui:
col = split.column()
sub = col.column()
sub.active = (game.physics_type == 'RIGID_BODY')
@@ -93,7 +86,6 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel):
sub.prop(game, "minimum_velocity", text="Minimum")
sub.prop(game, "maximum_velocity", text="Maximum")
if wide_ui:
col = split.column()
col.label(text="Damping:")
sub = col.column(align=True)
@@ -136,7 +128,6 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel):
col.prop(soft, "margin", slider=True)
col.prop(soft, "bending_const", text="Bending Constraints")
if wide_ui:
col = split.column()
col.prop(soft, "shape_match")
sub = col.column()
@@ -162,14 +153,15 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel):
layout.prop(ob, "hide_render", text="Invisible")
class PHYSICS_PT_game_collision_bounds(PhysicsButtonsPanel):
class PHYSICS_PT_game_collision_bounds(PhysicsButtonsPanel, bpy.types.Panel):
bl_label = "Collision Bounds"
COMPAT_ENGINES = {'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
game = context.object.game
rd = context.scene.render
return (game.physics_type in ('DYNAMIC', 'RIGID_BODY', 'SENSOR', 'SOFT_BODY', 'STATIC')) and (rd.engine in self.COMPAT_ENGINES)
return (game.physics_type in ('DYNAMIC', 'RIGID_BODY', 'SENSOR', 'SOFT_BODY', 'STATIC')) and (rd.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
game = context.active_object.game
@@ -180,35 +172,31 @@ class PHYSICS_PT_game_collision_bounds(PhysicsButtonsPanel):
layout = self.layout
game = context.active_object.game
wide_ui = context.region.width > narrowui
layout.active = game.use_collision_bounds
if wide_ui:
layout.prop(game, "collision_bounds", text="Bounds")
else:
layout.prop(game, "collision_bounds", text="")
split = layout.split()
col = split.column()
col.prop(game, "collision_margin", text="Margin", slider=True)
if wide_ui:
col = split.column()
col.prop(game, "collision_compound", text="Compound")
class RenderButtonsPanel(bpy.types.Panel):
class RenderButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "render"
def poll(self, context):
@classmethod
def poll(cls, context):
rd = context.scene.render
return (rd.engine in self.COMPAT_ENGINES)
return (rd.engine in cls.COMPAT_ENGINES)
class RENDER_PT_game(RenderButtonsPanel):
class RENDER_PT_game(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Game"
COMPAT_ENGINES = {'BLENDER_GAME'}
@@ -220,7 +208,7 @@ class RENDER_PT_game(RenderButtonsPanel):
row.label()
class RENDER_PT_game_player(RenderButtonsPanel):
class RENDER_PT_game_player(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Standalone Player"
COMPAT_ENGINES = {'BLENDER_GAME'}
@@ -228,7 +216,6 @@ class RENDER_PT_game_player(RenderButtonsPanel):
layout = self.layout
gs = context.scene.game_data
wide_ui = context.region.width > narrowui
layout.prop(gs, "fullscreen")
@@ -240,7 +227,6 @@ class RENDER_PT_game_player(RenderButtonsPanel):
sub.prop(gs, "resolution_x", slider=False, text="X")
sub.prop(gs, "resolution_y", slider=False, text="Y")
if wide_ui:
col = split.column()
col.label(text="Quality:")
sub = col.column(align=True)
@@ -250,15 +236,12 @@ class RENDER_PT_game_player(RenderButtonsPanel):
# framing:
col = layout.column()
col.label(text="Framing:")
if wide_ui:
col.row().prop(gs, "framing_type", expand=True)
else:
col.prop(gs, "framing_type", text="")
if gs.framing_type == 'LETTERBOX':
col.prop(gs, "framing_color", text="")
class RENDER_PT_game_stereo(RenderButtonsPanel):
class RENDER_PT_game_stereo(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Stereo"
COMPAT_ENGINES = {'BLENDER_GAME'}
@@ -267,7 +250,6 @@ class RENDER_PT_game_stereo(RenderButtonsPanel):
gs = context.scene.game_data
stereo_mode = gs.stereo
wide_ui = context.region.width > narrowui
# stereo options:
layout.prop(gs, "stereo", expand=True)
@@ -279,10 +261,7 @@ class RENDER_PT_game_stereo(RenderButtonsPanel):
# dome:
elif stereo_mode == 'DOME':
if wide_ui:
layout.prop(gs, "dome_mode", text="Dome Type")
else:
layout.prop(gs, "dome_mode", text="")
dome_type = gs.dome_mode
@@ -296,7 +275,6 @@ class RENDER_PT_game_stereo(RenderButtonsPanel):
col.prop(gs, "dome_buffer_resolution", text="Resolution", slider=True)
col.prop(gs, "dome_angle", slider=True)
if wide_ui:
col = split.column()
col.prop(gs, "dome_tesselation", text="Tesselation")
col.prop(gs, "dome_tilt")
@@ -305,20 +283,19 @@ class RENDER_PT_game_stereo(RenderButtonsPanel):
col = split.column()
col.prop(gs, "dome_buffer_resolution", text="Resolution", slider=True)
if wide_ui:
col = split.column()
col.prop(gs, "dome_tesselation", text="Tesselation")
else: # cube map
col = split.column()
col.prop(gs, "dome_buffer_resolution", text="Resolution", slider=True)
if wide_ui:
col = split.column()
layout.prop(gs, "dome_text")
class RENDER_PT_game_shading(RenderButtonsPanel):
class RENDER_PT_game_shading(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Shading"
COMPAT_ENGINES = {'BLENDER_GAME'}
@@ -326,12 +303,8 @@ class RENDER_PT_game_shading(RenderButtonsPanel):
layout = self.layout
gs = context.scene.game_data
wide_ui = context.region.width > narrowui
if wide_ui:
layout.prop(gs, "material_mode", expand=True)
else:
layout.prop(gs, "material_mode", text="")
if gs.material_mode == 'GLSL':
split = layout.split()
@@ -347,7 +320,7 @@ class RENDER_PT_game_shading(RenderButtonsPanel):
col.prop(gs, "glsl_extra_textures", text="Extra Textures")
class RENDER_PT_game_performance(RenderButtonsPanel):
class RENDER_PT_game_performance(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Performance"
COMPAT_ENGINES = {'BLENDER_GAME'}
@@ -355,7 +328,6 @@ class RENDER_PT_game_performance(RenderButtonsPanel):
layout = self.layout
gs = context.scene.game_data
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -366,14 +338,14 @@ class RENDER_PT_game_performance(RenderButtonsPanel):
col.prop(gs, "show_physics_visualization", text="Physics Visualization")
col.prop(gs, "use_deprecation_warnings")
if wide_ui:
col = split.column()
col.label(text="Render:")
col.prop(gs, "use_frame_rate")
col.prop(gs, "use_display_lists")
class RENDER_PT_game_sound(RenderButtonsPanel):
class RENDER_PT_game_sound(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Sound"
COMPAT_ENGINES = {'BLENDER_GAME'}
@@ -381,32 +353,26 @@ class RENDER_PT_game_sound(RenderButtonsPanel):
layout = self.layout
scene = context.scene
wide_ui = context.region.width > narrowui
if wide_ui:
layout.prop(scene, "distance_model")
else:
layout.prop(scene, "distance_model", text="")
layout.prop(scene, "speed_of_sound", text="Speed")
layout.prop(scene, "doppler_factor")
class WorldButtonsPanel(bpy.types.Panel):
class WorldButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "world"
def poll(self, context):
scene = context.scene
return (scene.render.engine in self.COMPAT_ENGINES) and (scene.world is not None)
class WORLD_PT_game_context_world(WorldButtonsPanel):
class WORLD_PT_game_context_world(WorldButtonsPanel, bpy.types.Panel):
bl_label = ""
bl_show_header = False
COMPAT_ENGINES = {'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
rd = context.scene.render
return (context.scene) and (rd.use_game_engine)
@@ -416,45 +382,46 @@ class WORLD_PT_game_context_world(WorldButtonsPanel):
scene = context.scene
world = context.world
space = context.space_data
wide_ui = context.region.width > narrowui
if wide_ui:
split = layout.split(percentage=0.65)
if scene:
split.template_ID(scene, "world", new="world.new")
elif world:
split.template_ID(space, "pin_id")
else:
if scene:
layout.template_ID(scene, "world", new="world.new")
elif world:
layout.template_ID(space, "pin_id")
class WORLD_PT_game_world(WorldButtonsPanel):
class WORLD_PT_game_world(WorldButtonsPanel, bpy.types.Panel):
bl_label = "World"
COMPAT_ENGINES = {'BLENDER_GAME'}
@classmethod
def poll(cls, context):
scene = context.scene
return (scene.world and scene.render.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
world = context.world
wide_ui = context.region.width > narrowui
split = layout.split()
col = split.column()
col.prop(world, "horizon_color")
if wide_ui:
col = split.column()
col.prop(world, "ambient_color")
class WORLD_PT_game_mist(WorldButtonsPanel):
class WORLD_PT_game_mist(WorldButtonsPanel, bpy.types.Panel):
bl_label = "Mist"
COMPAT_ENGINES = {'BLENDER_GAME'}
@classmethod
def poll(cls, context):
scene = context.scene
return (scene.world and scene.render.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
world = context.world
@@ -464,7 +431,6 @@ class WORLD_PT_game_mist(WorldButtonsPanel):
layout = self.layout
world = context.world
wide_ui = context.region.width > narrowui
layout.active = world.mist.use_mist
split = layout.split()
@@ -472,20 +438,23 @@ class WORLD_PT_game_mist(WorldButtonsPanel):
col = split.column()
col.prop(world.mist, "start")
if wide_ui:
col = split.column()
col.prop(world.mist, "depth")
class WORLD_PT_game_physics(WorldButtonsPanel):
class WORLD_PT_game_physics(WorldButtonsPanel, bpy.types.Panel):
bl_label = "Physics"
COMPAT_ENGINES = {'BLENDER_GAME'}
@classmethod
def poll(cls, context):
scene = context.scene
return (scene.world and scene.render.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
gs = context.scene.game_data
wide_ui = context.region.width > narrowui
layout.prop(gs, "physics_engine")
if gs.physics_engine != 'NONE':
@@ -500,7 +469,6 @@ class WORLD_PT_game_physics(WorldButtonsPanel):
sub.prop(gs, "physics_step_sub", text="Substeps")
col.prop(gs, "fps", text="FPS")
if wide_ui:
col = split.column()
col.label(text="Logic Steps:")
col.prop(gs, "logic_step_max", text="Max")
@@ -523,33 +491,12 @@ class WORLD_PT_game_physics(WorldButtonsPanel):
col.prop(gs, "logic_step_max", text="Max")
classes = [
PHYSICS_PT_game_physics,
PHYSICS_PT_game_collision_bounds,
RENDER_PT_game,
RENDER_PT_game_player,
RENDER_PT_game_stereo,
RENDER_PT_game_shading,
RENDER_PT_game_performance,
RENDER_PT_game_sound,
WORLD_PT_game_context_world,
WORLD_PT_game_world,
WORLD_PT_game_mist,
WORLD_PT_game_physics]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -20,8 +20,6 @@
import bpy
from rna_prop_ui import PropertyPanel
narrowui = bpy.context.user_preferences.view.properties_width_check
def active_node_mat(mat):
# TODO, 2.4x has a pipeline section, for 2.5 we need to communicate
@@ -54,19 +52,18 @@ class MATERIAL_MT_specials(bpy.types.Menu):
layout.operator("material.paste", icon='PASTEDOWN')
class MaterialButtonsPanel(bpy.types.Panel):
class MaterialButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "material"
# COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
def poll(self, context):
mat = context.material
engine = context.scene.render.engine
return mat and (engine in self.COMPAT_ENGINES)
@classmethod
def poll(cls, context):
return context.material and (context.scene.render.engine in cls.COMPAT_ENGINES)
class MATERIAL_PT_preview(MaterialButtonsPanel):
class MATERIAL_PT_preview(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Preview"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -74,17 +71,18 @@ class MATERIAL_PT_preview(MaterialButtonsPanel):
self.layout.template_preview(context.material)
class MATERIAL_PT_context_material(MaterialButtonsPanel):
class MATERIAL_PT_context_material(MaterialButtonsPanel, bpy.types.Panel):
bl_label = ""
bl_show_header = False
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
# An exception, dont call the parent poll func because
# this manages materials for all engine types
engine = context.scene.render.engine
return (context.material or context.object) and (engine in self.COMPAT_ENGINES)
return (context.material or context.object) and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -93,7 +91,6 @@ class MATERIAL_PT_context_material(MaterialButtonsPanel):
ob = context.object
slot = context.material_slot
space = context.space_data
wide_ui = context.region.width > narrowui
if ob:
row = layout.row()
@@ -112,7 +109,6 @@ class MATERIAL_PT_context_material(MaterialButtonsPanel):
row.operator("object.material_slot_select", text="Select")
row.operator("object.material_slot_deselect", text="Deselect")
if wide_ui:
split = layout.split(percentage=0.65)
if ob:
@@ -128,38 +124,30 @@ class MATERIAL_PT_context_material(MaterialButtonsPanel):
elif mat:
split.template_ID(space, "pin_id")
split.separator()
else:
if ob:
layout.template_ID(ob, "active_material", new="material.new")
elif mat:
layout.template_ID(space, "pin_id")
if mat:
if wide_ui:
layout.prop(mat, "type", expand=True)
else:
layout.prop(mat, "type", text="")
class MATERIAL_PT_custom_props(MaterialButtonsPanel, PropertyPanel):
COMPAT_ENGINES = {'BLENDER_RENDER'}
class MATERIAL_PT_custom_props(MaterialButtonsPanel, PropertyPanel, bpy.types.Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
_context_path = "material"
class MATERIAL_PT_shading(MaterialButtonsPanel):
class MATERIAL_PT_shading(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Shading"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
mat = active_node_mat(context.material)
engine = context.scene.render.engine
return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in self.COMPAT_ENGINES)
return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = active_node_mat(context.material)
wide_ui = context.region.width > narrowui
if mat.type in ('SURFACE', 'WIRE'):
split = layout.split()
@@ -172,7 +160,6 @@ class MATERIAL_PT_shading(MaterialButtonsPanel):
sub = col.column()
sub.prop(mat, "translucency")
if wide_ui:
col = split.column()
col.prop(mat, "shadeless")
sub = col.column()
@@ -184,22 +171,22 @@ class MATERIAL_PT_shading(MaterialButtonsPanel):
layout.prop(mat, "alpha")
class MATERIAL_PT_strand(MaterialButtonsPanel):
class MATERIAL_PT_strand(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Strand"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in self.COMPAT_ENGINES)
return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = context.material # dont use node material
tan = mat.strand
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -215,7 +202,6 @@ class MATERIAL_PT_strand(MaterialButtonsPanel):
sub.prop(tan, "tangent_shading")
col.prop(tan, "shape")
if wide_ui:
col = split.column()
col.label(text="Shading:")
col.prop(tan, "width_fade")
@@ -233,15 +219,18 @@ class MATERIAL_PT_strand(MaterialButtonsPanel):
sub.prop(tan, "blend_distance", text="Distance")
class MATERIAL_PT_physics(MaterialButtonsPanel):
class MATERIAL_PT_physics(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Physics"
COMPAT_ENGINES = {'BLENDER_GAME'}
@classmethod
def poll(cls, context):
return context.material and (context.scene.render.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
phys = context.material.physics # dont use node material
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -250,27 +239,26 @@ class MATERIAL_PT_physics(MaterialButtonsPanel):
col.prop(phys, "friction")
col.prop(phys, "align_to_normal")
if wide_ui:
col = split.column()
col.prop(phys, "force", slider=True)
col.prop(phys, "elasticity", slider=True)
col.prop(phys, "damp", slider=True)
class MATERIAL_PT_options(MaterialButtonsPanel):
class MATERIAL_PT_options(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Options"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
mat = active_node_mat(context.material)
engine = context.scene.render.engine
return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in self.COMPAT_ENGINES)
return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = active_node_mat(context.material)
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -290,7 +278,6 @@ class MATERIAL_PT_options(MaterialButtonsPanel):
row.active = bool(mat.light_group)
row.prop(mat, "light_group_exclusive", text="Exclusive")
if wide_ui:
col = split.column()
col.prop(mat, "face_texture")
sub = col.column()
@@ -302,21 +289,21 @@ class MATERIAL_PT_options(MaterialButtonsPanel):
col.prop(mat, "object_color")
class MATERIAL_PT_shadow(MaterialButtonsPanel):
class MATERIAL_PT_shadow(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Shadow"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
mat = active_node_mat(context.material)
engine = context.scene.render.engine
return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = active_node_mat(context.material)
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -327,7 +314,6 @@ class MATERIAL_PT_shadow(MaterialButtonsPanel):
col.prop(mat, "cast_shadows_only", text="Cast Only")
col.prop(mat, "shadow_casting_alpha", text="Casting Alpha")
if wide_ui:
col = split.column()
col.prop(mat, "cast_buffer_shadows")
sub = col.column()
@@ -339,21 +325,20 @@ class MATERIAL_PT_shadow(MaterialButtonsPanel):
sub.prop(mat, "shadow_ray_bias", text="Ray Bias")
col.prop(mat, "cast_approximate")
class MATERIAL_PT_diffuse(MaterialButtonsPanel):
class MATERIAL_PT_diffuse(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Diffuse"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
mat = active_node_mat(context.material)
engine = context.scene.render.engine
return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = active_node_mat(context.material)
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -363,7 +348,6 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel):
sub.active = (not mat.shadeless)
sub.prop(mat, "diffuse_intensity", text="Intensity")
if wide_ui:
col = split.column()
col.active = (not mat.shadeless)
col.prop(mat, "diffuse_shader", text="")
@@ -381,7 +365,6 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel):
col = split.column()
col.prop(mat, "diffuse_toon_size", text="Size")
if wide_ui:
col = split.column()
col.prop(mat, "diffuse_toon_smooth", text="Smooth")
elif mat.diffuse_shader == 'FRESNEL':
@@ -390,7 +373,6 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel):
col = split.column()
col.prop(mat, "diffuse_fresnel", text="Fresnel")
if wide_ui:
col = split.column()
col.prop(mat, "diffuse_fresnel_factor", text="Factor")
@@ -404,27 +386,26 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel):
col = split.column()
col.prop(mat, "diffuse_ramp_input", text="Input")
if wide_ui:
col = split.column()
col.prop(mat, "diffuse_ramp_blend", text="Blend")
row = layout.row()
row.prop(mat, "diffuse_ramp_factor", text="Factor")
class MATERIAL_PT_specular(MaterialButtonsPanel):
class MATERIAL_PT_specular(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Specular"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
mat = active_node_mat(context.material)
engine = context.scene.render.engine
return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = active_node_mat(context.material)
wide_ui = context.region.width > narrowui
layout.active = (not mat.shadeless)
@@ -434,7 +415,6 @@ class MATERIAL_PT_specular(MaterialButtonsPanel):
col.prop(mat, "specular_color", text="")
col.prop(mat, "specular_intensity", text="Intensity")
if wide_ui:
col = split.column()
col.prop(mat, "specular_shader", text="")
col.prop(mat, "use_specular_ramp", text="Ramp")
@@ -448,7 +428,6 @@ class MATERIAL_PT_specular(MaterialButtonsPanel):
col = split.column()
col.prop(mat, "specular_hardness", text="Hardness")
if wide_ui:
col = split.column()
col.prop(mat, "specular_ior", text="IOR")
elif mat.specular_shader == 'WARDISO':
@@ -459,7 +438,6 @@ class MATERIAL_PT_specular(MaterialButtonsPanel):
col = split.column()
col.prop(mat, "specular_toon_size", text="Size")
if wide_ui:
col = split.column()
col.prop(mat, "specular_toon_smooth", text="Smooth")
@@ -472,7 +450,6 @@ class MATERIAL_PT_specular(MaterialButtonsPanel):
col = split.column()
col.prop(mat, "specular_ramp_input", text="Input")
if wide_ui:
col = split.column()
col.prop(mat, "specular_ramp_blend", text="Blend")
@@ -480,15 +457,16 @@ class MATERIAL_PT_specular(MaterialButtonsPanel):
row.prop(mat, "specular_ramp_factor", text="Factor")
class MATERIAL_PT_sss(MaterialButtonsPanel):
class MATERIAL_PT_sss(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Subsurface Scattering"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
mat = active_node_mat(context.material)
engine = context.scene.render.engine
return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
mat = active_node_mat(context.material)
@@ -502,7 +480,6 @@ class MATERIAL_PT_sss(MaterialButtonsPanel):
mat = active_node_mat(context.material)
sss = mat.subsurface_scattering
wide_ui = context.region.width > narrowui
layout.active = (sss.enabled) and (not mat.shadeless)
@@ -519,7 +496,6 @@ class MATERIAL_PT_sss(MaterialButtonsPanel):
col.prop(sss, "color", text="")
col.prop(sss, "radius", text="RGB Radius", expand=True)
if wide_ui:
col = split.column()
sub = col.column(align=True)
sub.label(text="Blend:")
@@ -532,15 +508,16 @@ class MATERIAL_PT_sss(MaterialButtonsPanel):
col.prop(sss, "error_tolerance", text="Error")
class MATERIAL_PT_mirror(MaterialButtonsPanel):
class MATERIAL_PT_mirror(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Mirror"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
mat = active_node_mat(context.material)
engine = context.scene.render.engine
return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
raym = active_node_mat(context.material).raytrace_mirror
@@ -552,7 +529,6 @@ class MATERIAL_PT_mirror(MaterialButtonsPanel):
mat = active_node_mat(context.material)
raym = mat.raytrace_mirror
wide_ui = context.region.width > narrowui
layout.active = raym.enabled
@@ -562,7 +538,6 @@ class MATERIAL_PT_mirror(MaterialButtonsPanel):
col.prop(raym, "reflect_factor")
col.prop(mat, "mirror_color", text="")
if wide_ui:
col = split.column()
col.prop(raym, "fresnel")
sub = col.column()
@@ -581,7 +556,6 @@ class MATERIAL_PT_mirror(MaterialButtonsPanel):
sub.label(text="Fade To:")
sub.prop(raym, "fade_to", text="")
if wide_ui:
col = split.column()
col.label(text="Gloss:")
col.prop(raym, "gloss_factor", text="Amount")
@@ -592,15 +566,16 @@ class MATERIAL_PT_mirror(MaterialButtonsPanel):
sub.prop(raym, "gloss_anisotropic", text="Anisotropic")
class MATERIAL_PT_transp(MaterialButtonsPanel):
class MATERIAL_PT_transp(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Transparency"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
mat = active_node_mat(context.material)
engine = context.scene.render.engine
return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
mat = active_node_mat(context.material)
@@ -612,14 +587,10 @@ class MATERIAL_PT_transp(MaterialButtonsPanel):
mat = active_node_mat(context.material)
rayt = mat.raytrace_transparency
wide_ui = context.region.width > narrowui
row = layout.row()
row.active = mat.transparency and (not mat.shadeless)
if wide_ui:
row.prop(mat, "transparency_method", expand=True)
else:
row.prop(mat, "transparency_method", text="")
split = layout.split()
@@ -629,7 +600,6 @@ class MATERIAL_PT_transp(MaterialButtonsPanel):
row.active = mat.transparency and (not mat.shadeless)
row.prop(mat, "specular_alpha", text="Specular")
if wide_ui:
col = split.column()
col.active = (not mat.shadeless)
col.prop(rayt, "fresnel")
@@ -649,7 +619,6 @@ class MATERIAL_PT_transp(MaterialButtonsPanel):
col.prop(rayt, "limit")
col.prop(rayt, "depth")
if wide_ui:
col = split.column()
col.label(text="Gloss:")
col.prop(rayt, "gloss_factor", text="Amount")
@@ -659,15 +628,16 @@ class MATERIAL_PT_transp(MaterialButtonsPanel):
sub.prop(rayt, "gloss_samples", text="Samples")
class MATERIAL_PT_transp_game(MaterialButtonsPanel):
class MATERIAL_PT_transp_game(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Transparency"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
mat = active_node_mat(context.material)
engine = context.scene.render.engine
return mat and (engine in self.COMPAT_ENGINES)
return mat and (engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
mat = active_node_mat(context.material)
@@ -679,14 +649,10 @@ class MATERIAL_PT_transp_game(MaterialButtonsPanel):
mat = active_node_mat(context.material)
rayt = mat.raytrace_transparency
wide_ui = context.region.width > narrowui
row = layout.row()
row.active = mat.transparency and (not mat.shadeless)
if wide_ui:
row.prop(mat, "transparency_method", expand=True)
else:
row.prop(mat, "transparency_method", text="")
split = layout.split()
@@ -694,21 +660,21 @@ class MATERIAL_PT_transp_game(MaterialButtonsPanel):
col.prop(mat, "alpha")
class MATERIAL_PT_halo(MaterialButtonsPanel):
class MATERIAL_PT_halo(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Halo"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return mat and (mat.type == 'HALO') and (engine in self.COMPAT_ENGINES)
return mat and (mat.type == 'HALO') and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = context.material # dont use node material
halo = mat.halo
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -724,7 +690,6 @@ class MATERIAL_PT_halo(MaterialButtonsPanel):
col.prop(halo, "shaded")
col.prop(halo, "soft")
if wide_ui:
col = split.column()
col.prop(halo, "ring")
sub = col.column()
@@ -744,14 +709,15 @@ class MATERIAL_PT_halo(MaterialButtonsPanel):
sub.prop(halo, "star_tips")
class MATERIAL_PT_flare(MaterialButtonsPanel):
class MATERIAL_PT_flare(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Flare"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return mat and (mat.type == 'HALO') and (engine in self.COMPAT_ENGINES)
return mat and (mat.type == 'HALO') and (engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
halo = context.material.halo
@@ -763,7 +729,6 @@ class MATERIAL_PT_flare(MaterialButtonsPanel):
mat = context.material # dont use node material
halo = mat.halo
wide_ui = context.region.width > narrowui
layout.active = halo.flare_mode
@@ -773,24 +738,26 @@ class MATERIAL_PT_flare(MaterialButtonsPanel):
col.prop(halo, "flare_size", text="Size")
col.prop(halo, "flare_boost", text="Boost")
col.prop(halo, "flare_seed", text="Seed")
if wide_ui:
col = split.column()
col.prop(halo, "flares_sub", text="Subflares")
col.prop(halo, "flare_subsize", text="Subsize")
class VolumeButtonsPanel(bpy.types.Panel):
class VolumeButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "material"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return mat and (mat.type == 'VOLUME') and (engine in self.COMPAT_ENGINES)
return mat and (mat.type == 'VOLUME') and (engine in cls.COMPAT_ENGINES)
class MATERIAL_PT_volume_density(VolumeButtonsPanel):
class MATERIAL_PT_volume_density(VolumeButtonsPanel, bpy.types.Panel):
bl_label = "Density"
bl_default_closed = False
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -799,18 +766,16 @@ class MATERIAL_PT_volume_density(VolumeButtonsPanel):
layout = self.layout
vol = context.material.volume # dont use node material
wide_ui = context.region.width > narrowui
split = layout.split()
col = split.column()
col.prop(vol, "density")
if wide_ui:
col = split.column()
col.prop(vol, "density_scale")
class MATERIAL_PT_volume_shading(VolumeButtonsPanel):
class MATERIAL_PT_volume_shading(VolumeButtonsPanel, bpy.types.Panel):
bl_label = "Shading"
bl_default_closed = False
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -819,7 +784,6 @@ class MATERIAL_PT_volume_shading(VolumeButtonsPanel):
layout = self.layout
vol = context.material.volume # dont use node material
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -828,7 +792,6 @@ class MATERIAL_PT_volume_shading(VolumeButtonsPanel):
col.prop(vol, "asymmetry")
col.prop(vol, "transmission_color")
if wide_ui:
col = split.column()
sub = col.column(align=True)
sub.prop(vol, "emission")
@@ -838,7 +801,7 @@ class MATERIAL_PT_volume_shading(VolumeButtonsPanel):
sub.prop(vol, "reflection_color", text="")
class MATERIAL_PT_volume_lighting(VolumeButtonsPanel):
class MATERIAL_PT_volume_lighting(VolumeButtonsPanel, bpy.types.Panel):
bl_label = "Lighting"
bl_default_closed = False
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -847,14 +810,12 @@ class MATERIAL_PT_volume_lighting(VolumeButtonsPanel):
layout = self.layout
vol = context.material.volume # dont use node material
wide_ui = context.region.width > narrowui
split = layout.split()
col = split.column()
col.prop(vol, "lighting_mode", text="")
if wide_ui:
col = split.column()
if vol.lighting_mode == 'SHADED':
@@ -876,7 +837,7 @@ class MATERIAL_PT_volume_lighting(VolumeButtonsPanel):
sub.prop(vol, "ms_intensity")
class MATERIAL_PT_volume_transp(VolumeButtonsPanel):
class MATERIAL_PT_volume_transp(VolumeButtonsPanel, bpy.types.Panel):
bl_label = "Transparency"
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -884,15 +845,11 @@ class MATERIAL_PT_volume_transp(VolumeButtonsPanel):
layout = self.layout
mat = context.material # dont use node material
wide_ui = context.region.width > narrowui
if wide_ui:
layout.prop(mat, "transparency_method", expand=True)
else:
layout.prop(mat, "transparency_method", text="")
class MATERIAL_PT_volume_integration(VolumeButtonsPanel):
class MATERIAL_PT_volume_integration(VolumeButtonsPanel, bpy.types.Panel):
bl_label = "Integration"
bl_default_closed = False
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -901,7 +858,6 @@ class MATERIAL_PT_volume_integration(VolumeButtonsPanel):
layout = self.layout
vol = context.material.volume # dont use node material
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -911,13 +867,12 @@ class MATERIAL_PT_volume_integration(VolumeButtonsPanel):
col = col.column(align=True)
col.prop(vol, "step_size")
if wide_ui:
col = split.column()
col.label()
col.prop(vol, "depth_cutoff")
class MATERIAL_PT_volume_options(VolumeButtonsPanel):
class MATERIAL_PT_volume_options(VolumeButtonsPanel, bpy.types.Panel):
bl_label = "Options"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
bl_default_closed = True
@@ -926,7 +881,6 @@ class MATERIAL_PT_volume_options(VolumeButtonsPanel):
layout = self.layout
mat = active_node_mat(context.material)
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -943,46 +897,12 @@ class MATERIAL_PT_volume_options(VolumeButtonsPanel):
row.prop(mat, "light_group_exclusive", text="Exclusive")
classes = [
MATERIAL_PT_context_material,
MATERIAL_PT_preview,
MATERIAL_PT_diffuse,
MATERIAL_PT_specular,
MATERIAL_PT_shading,
MATERIAL_PT_transp,
MATERIAL_PT_mirror,
MATERIAL_PT_sss,
MATERIAL_PT_halo,
MATERIAL_PT_flare,
MATERIAL_PT_physics,
MATERIAL_PT_strand,
MATERIAL_PT_options,
MATERIAL_PT_shadow,
MATERIAL_PT_transp_game,
MATERIAL_MT_sss_presets,
MATERIAL_MT_specials,
MATERIAL_PT_volume_density,
MATERIAL_PT_volume_shading,
MATERIAL_PT_volume_lighting,
MATERIAL_PT_volume_transp,
MATERIAL_PT_volume_integration,
MATERIAL_PT_volume_options,
MATERIAL_PT_custom_props]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -20,16 +20,14 @@
import bpy
from rna_prop_ui import PropertyPanel
narrowui = bpy.context.user_preferences.view.properties_width_check
class ObjectButtonsPanel(bpy.types.Panel):
class ObjectButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "object"
class OBJECT_PT_context_object(ObjectButtonsPanel):
class OBJECT_PT_context_object(ObjectButtonsPanel, bpy.types.Panel):
bl_label = ""
bl_show_header = False
@@ -46,20 +44,14 @@ class OBJECT_PT_context_object(ObjectButtonsPanel):
row.prop(ob, "name", text="")
class OBJECT_PT_custom_props(ObjectButtonsPanel, PropertyPanel):
_context_path = "object"
class OBJECT_PT_transform(ObjectButtonsPanel):
class OBJECT_PT_transform(ObjectButtonsPanel, bpy.types.Panel):
bl_label = "Transform"
def draw(self, context):
layout = self.layout
ob = context.object
wide_ui = context.region.width > narrowui
if wide_ui:
row = layout.row()
row.column().prop(ob, "location")
@@ -76,21 +68,9 @@ class OBJECT_PT_transform(ObjectButtonsPanel):
row.column().prop(ob, "scale")
layout.prop(ob, "rotation_mode")
else:
col = layout.column()
col.prop(ob, "location")
col.label(text="Rotation:")
col.prop(ob, "rotation_mode", text="")
if ob.rotation_mode == 'QUATERNION':
col.prop(ob, "rotation_quaternion", text="")
elif ob.rotation_mode == 'AXIS_ANGLE':
col.prop(ob, "rotation_axis_angle", text="")
else:
col.prop(ob, "rotation_euler", text="")
col.prop(ob, "scale")
class OBJECT_PT_transform_locks(ObjectButtonsPanel):
class OBJECT_PT_transform_locks(ObjectButtonsPanel, bpy.types.Panel):
bl_label = "Transform Locks"
bl_default_closed = True
@@ -98,7 +78,6 @@ class OBJECT_PT_transform_locks(ObjectButtonsPanel):
layout = self.layout
ob = context.object
# wide_ui = context.region.width > narrowui
row = layout.row()
@@ -117,14 +96,13 @@ class OBJECT_PT_transform_locks(ObjectButtonsPanel):
row.column().prop(ob, "lock_scale", text="Scale")
class OBJECT_PT_relations(ObjectButtonsPanel):
class OBJECT_PT_relations(ObjectButtonsPanel, bpy.types.Panel):
bl_label = "Relations"
def draw(self, context):
layout = self.layout
ob = context.object
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -133,7 +111,6 @@ class OBJECT_PT_relations(ObjectButtonsPanel):
col.separator()
col.prop(ob, "pass_index")
if wide_ui:
col = split.column()
col.label(text="Parent:")
col.prop(ob, "parent", text="")
@@ -146,14 +123,13 @@ class OBJECT_PT_relations(ObjectButtonsPanel):
sub.active = (parent is not None)
class OBJECT_PT_groups(ObjectButtonsPanel):
class OBJECT_PT_groups(ObjectButtonsPanel, bpy.types.Panel):
bl_label = "Groups"
def draw(self, context):
layout = self.layout
ob = context.object
wide_ui = context.region.width > narrowui
row = layout.row(align=True)
row.operator("object.group_link", text="Add to Group")
@@ -177,7 +153,6 @@ class OBJECT_PT_groups(ObjectButtonsPanel):
col = split.column()
col.prop(group, "layer", text="Dupli")
if wide_ui:
col = split.column()
col.prop(group, "dupli_offset", text="")
@@ -187,20 +162,18 @@ class OBJECT_PT_groups(ObjectButtonsPanel):
index += 1
class OBJECT_PT_display(ObjectButtonsPanel):
class OBJECT_PT_display(ObjectButtonsPanel, bpy.types.Panel):
bl_label = "Display"
def draw(self, context):
layout = self.layout
ob = context.object
wide_ui = context.region.width > narrowui
split = layout.split()
col = split.column()
col.prop(ob, "max_draw_type", text="Type")
if wide_ui:
col = split.column()
row = col.row()
row.prop(ob, "draw_bounds", text="Bounds")
@@ -216,26 +189,21 @@ class OBJECT_PT_display(ObjectButtonsPanel):
col.prop(ob, "draw_wire", text="Wire")
col.prop(ob, "color", text="Object Color")
if wide_ui:
col = split.column()
col.prop(ob, "draw_texture_space", text="Texture Space")
col.prop(ob, "x_ray", text="X-Ray")
col.prop(ob, "draw_transparent", text="Transparency")
class OBJECT_PT_duplication(ObjectButtonsPanel):
class OBJECT_PT_duplication(ObjectButtonsPanel, bpy.types.Panel):
bl_label = "Duplication"
def draw(self, context):
layout = self.layout
ob = context.object
wide_ui = context.region.width > narrowui
if wide_ui:
layout.prop(ob, "dupli_type", expand=True)
else:
layout.prop(ob, "dupli_type", text="")
if ob.dupli_type == 'FRAMES':
split = layout.split()
@@ -244,7 +212,6 @@ class OBJECT_PT_duplication(ObjectButtonsPanel):
col.prop(ob, "dupli_frames_start", text="Start")
col.prop(ob, "dupli_frames_end", text="End")
if wide_ui:
col = split.column(align=True)
col.prop(ob, "dupli_frames_on", text="On")
col.prop(ob, "dupli_frames_off", text="Off")
@@ -260,20 +227,16 @@ class OBJECT_PT_duplication(ObjectButtonsPanel):
col = split.column()
col.prop(ob, "use_dupli_faces_scale", text="Scale")
if wide_ui:
col = split.column()
col.prop(ob, "dupli_faces_scale", text="Inherit Scale")
elif ob.dupli_type == 'GROUP':
if wide_ui:
layout.prop(ob, "dupli_group", text="Group")
else:
layout.prop(ob, "dupli_group", text="")
# XXX: the following options are all quite buggy, ancient hacks that should be dropped
class OBJECT_PT_animation(ObjectButtonsPanel):
class OBJECT_PT_animation(ObjectButtonsPanel, bpy.types.Panel):
bl_label = "Animation Hacks"
bl_default_closed = True
@@ -281,7 +244,6 @@ class OBJECT_PT_animation(ObjectButtonsPanel):
layout = self.layout
ob = context.object
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -300,42 +262,67 @@ class OBJECT_PT_animation(ObjectButtonsPanel):
col.prop(ob, "time_offset", text="Offset")
# XXX: these are still used for a few curve-related tracking features
if wide_ui:
col = split.column()
col.label(text="Tracking Axes:")
col.prop(ob, "track_axis", text="Axis")
col.prop(ob, "up_axis", text="Up Axis")
from properties_animviz import MotionPathButtonsPanel, OnionSkinButtonsPanel
# import generic panels from other files
from properties_animviz import OBJECT_PT_motion_paths, OBJECT_PT_onion_skinning
classes = [
OBJECT_PT_context_object,
OBJECT_PT_transform,
OBJECT_PT_transform_locks,
OBJECT_PT_relations,
OBJECT_PT_groups,
OBJECT_PT_display,
OBJECT_PT_duplication,
OBJECT_PT_animation, # XXX: panel of old hacks pending to be removed...
class OBJECT_PT_motion_paths(MotionPathButtonsPanel, bpy.types.Panel):
#bl_label = "Object Motion Paths"
bl_context = "object"
OBJECT_PT_motion_paths,
#OBJECT_PT_onion_skinning,
@classmethod
def poll(cls, context):
return (context.object)
OBJECT_PT_custom_props]
def draw(self, context):
layout = self.layout
ob = context.object
self.draw_settings(context, ob.animation_visualisation)
layout.separator()
split = layout.split()
col = split.column()
col.operator("object.paths_calculate", text="Calculate Paths")
col = split.column()
col.operator("object.paths_clear", text="Clear Paths")
class OBJECT_PT_onion_skinning(OnionSkinButtonsPanel): #, bpy.types.Panel): # inherit from panel when ready
#bl_label = "Object Onion Skinning"
bl_context = "object"
@classmethod
def poll(cls, context):
return (context.object)
def draw(self, context):
layout = self.layout
ob = context.object
self.draw_settings(context, ob.animation_visualisation)
class OBJECT_PT_custom_props(ObjectButtonsPanel, PropertyPanel, bpy.types.Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
_context_path = "object"
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -19,11 +19,8 @@
# <pep8 compliant>
import bpy
narrowui = bpy.context.user_preferences.view.properties_width_check
narrowcon = 260
class ConstraintButtonsPanel(bpy.types.Panel):
class ConstraintButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "constraint"
@@ -31,52 +28,38 @@ class ConstraintButtonsPanel(bpy.types.Panel):
def draw_constraint(self, context, con):
layout = self.layout
wide_ui = context.region.width > narrowui
compact_con = context.region.width < narrowcon
box = layout.template_constraint(con, compact=compact_con)
box = layout.template_constraint(con)
if box:
# match enum type to our functions, avoids a lookup table.
getattr(self, con.type)(context, box, con, wide_ui)
getattr(self, con.type)(context, box, con)
if con.type not in ('RIGID_BODY_JOINT', 'NULL'):
box.prop(con, "influence")
def space_template(self, layout, con, wide_ui, target=True, owner=True):
def space_template(self, layout, con, target=True, owner=True):
if target or owner:
split = layout.split(percentage=0.2)
if wide_ui:
split.label(text="Space:")
row = split.row()
else:
row = layout.row()
if target:
row.prop(con, "target_space", text="")
if wide_ui:
if target and owner:
row.label(icon='ARROW_LEFTRIGHT')
else:
row = layout.row()
if owner:
row.prop(con, "owner_space", text="")
def target_template(self, layout, con, wide_ui, subtargets=True):
if wide_ui:
def target_template(self, layout, con, subtargets=True):
layout.prop(con, "target") # XXX limiting settings for only 'curves' or some type of object
else:
layout.prop(con, "target", text="")
if con.target and subtargets:
if con.target.type == 'ARMATURE':
if wide_ui:
layout.prop_object(con, "subtarget", con.target.data, "bones", text="Bone")
else:
layout.prop_object(con, "subtarget", con.target.data, "bones", text="")
if con.type in ('COPY_LOCATION', 'STRETCH_TO', 'TRACK_TO', 'PIVOT'):
row = layout.row()
@@ -85,7 +68,7 @@ class ConstraintButtonsPanel(bpy.types.Panel):
elif con.target.type in ('MESH', 'LATTICE'):
layout.prop_object(con, "subtarget", con.target, "vertex_groups", text="Vertex Group")
def ik_template(self, layout, con, wide_ui):
def ik_template(self, layout, con):
# only used for iTaSC
layout.prop(con, "pole_target")
@@ -106,8 +89,8 @@ class ConstraintButtonsPanel(bpy.types.Panel):
col.prop(con, "chain_length")
col.prop(con, "use_target")
def CHILD_OF(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
def CHILD_OF(self, context, layout, con):
self.target_template(layout, con)
split = layout.split()
@@ -134,15 +117,13 @@ class ConstraintButtonsPanel(bpy.types.Panel):
col = split.column()
col.operator("constraint.childof_set_inverse")
if wide_ui:
col = split.column()
col.operator("constraint.childof_clear_inverse")
def TRACK_TO(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
def TRACK_TO(self, context, layout, con):
self.target_template(layout, con)
row = layout.row()
if wide_ui:
row.label(text="To:")
row.prop(con, "track", expand=True)
@@ -151,33 +132,26 @@ class ConstraintButtonsPanel(bpy.types.Panel):
col = split.column()
col.prop(con, "up", text="Up")
if wide_ui:
col = split.column()
col.prop(con, "target_z")
self.space_template(layout, con, wide_ui)
self.space_template(layout, con)
def IK(self, context, layout, con, wide_ui):
def IK(self, context, layout, con):
if context.object.pose.ik_solver == "ITASC":
layout.prop(con, "ik_type")
getattr(self, 'IK_' + con.ik_type)(context, layout, con, wide_ui)
getattr(self, 'IK_' + con.ik_type)(context, layout, con)
else:
# Legacy IK constraint
self.target_template(layout, con, wide_ui)
if wide_ui:
self.target_template(layout, con)
layout.prop(con, "pole_target")
else:
layout.prop(con, "pole_target", text="")
if con.pole_target and con.pole_target.type == 'ARMATURE':
if wide_ui:
layout.prop_object(con, "pole_subtarget", con.pole_target.data, "bones", text="Bone")
else:
layout.prop_object(con, "pole_subtarget", con.pole_target.data, "bones", text="")
if con.pole_target:
row = layout.row()
row.prop(con, "pole_angle")
if wide_ui:
row.label()
split = layout.split()
@@ -191,7 +165,6 @@ class ConstraintButtonsPanel(bpy.types.Panel):
sub.active = con.use_rotation
sub.prop(con, "orient_weight", text="Rotation", slider=True)
if wide_ui:
col = split.column()
col.prop(con, "use_tail")
col.prop(con, "use_stretch")
@@ -199,9 +172,9 @@ class ConstraintButtonsPanel(bpy.types.Panel):
col.prop(con, "use_target")
col.prop(con, "use_rotation")
def IK_COPY_POSE(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
self.ik_template(layout, con, wide_ui)
def IK_COPY_POSE(self, context, layout, con):
self.target_template(layout, con)
self.ik_template(layout, con)
row = layout.row()
row.label(text="Axis Ref:")
@@ -234,17 +207,17 @@ class ConstraintButtonsPanel(bpy.types.Panel):
row.prop(con, "rot_lock_z", text="Z")
split.active = con.use_rotation
def IK_DISTANCE(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
self.ik_template(layout, con, wide_ui)
def IK_DISTANCE(self, context, layout, con):
self.target_template(layout, con)
self.ik_template(layout, con)
layout.prop(con, "limit_mode")
row = layout.row()
row.prop(con, "weight", text="Weight", slider=True)
row.prop(con, "distance", text="Distance", slider=True)
def FOLLOW_PATH(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
def FOLLOW_PATH(self, context, layout, con):
self.target_template(layout, con)
split = layout.split()
@@ -252,7 +225,6 @@ class ConstraintButtonsPanel(bpy.types.Panel):
col.prop(con, "use_curve_follow")
col.prop(con, "use_curve_radius")
if wide_ui:
col = split.column()
col.prop(con, "use_fixed_position")
if con.use_fixed_position:
@@ -261,16 +233,14 @@ class ConstraintButtonsPanel(bpy.types.Panel):
col.prop(con, "offset")
row = layout.row()
if wide_ui:
row.label(text="Forward:")
row.prop(con, "forward", expand=True)
row = layout.row()
row.prop(con, "up", text="Up")
if wide_ui:
row.label()
def LIMIT_ROTATION(self, context, layout, con, wide_ui):
def LIMIT_ROTATION(self, context, layout, con):
split = layout.split()
@@ -281,7 +251,6 @@ class ConstraintButtonsPanel(bpy.types.Panel):
sub.prop(con, "minimum_x", text="Min")
sub.prop(con, "maximum_x", text="Max")
if wide_ui:
col = split.column(align=True)
col.prop(con, "use_limit_y")
sub = col.column()
@@ -289,7 +258,6 @@ class ConstraintButtonsPanel(bpy.types.Panel):
sub.prop(con, "minimum_y", text="Min")
sub.prop(con, "maximum_y", text="Max")
if wide_ui:
col = split.column(align=True)
col.prop(con, "use_limit_z")
sub = col.column()
@@ -299,15 +267,13 @@ class ConstraintButtonsPanel(bpy.types.Panel):
row = layout.row()
row.prop(con, "limit_transform")
if wide_ui:
row.label()
row = layout.row()
if wide_ui:
row.label(text="Convert:")
row.prop(con, "owner_space", text="")
def LIMIT_LOCATION(self, context, layout, con, wide_ui):
def LIMIT_LOCATION(self, context, layout, con):
split = layout.split()
col = split.column()
@@ -320,7 +286,6 @@ class ConstraintButtonsPanel(bpy.types.Panel):
sub.active = con.use_maximum_x
sub.prop(con, "maximum_x", text="")
if wide_ui:
col = split.column()
col.prop(con, "use_minimum_y")
sub = col.column()
@@ -331,7 +296,6 @@ class ConstraintButtonsPanel(bpy.types.Panel):
sub.active = con.use_maximum_y
sub.prop(con, "maximum_y", text="")
if wide_ui:
col = split.column()
col.prop(con, "use_minimum_z")
sub = col.column()
@@ -344,15 +308,13 @@ class ConstraintButtonsPanel(bpy.types.Panel):
row = layout.row()
row.prop(con, "limit_transform")
if wide_ui:
row.label()
row = layout.row()
if wide_ui:
row.label(text="Convert:")
row.prop(con, "owner_space", text="")
def LIMIT_SCALE(self, context, layout, con, wide_ui):
def LIMIT_SCALE(self, context, layout, con):
split = layout.split()
col = split.column()
@@ -365,7 +327,6 @@ class ConstraintButtonsPanel(bpy.types.Panel):
sub.active = con.use_maximum_x
sub.prop(con, "maximum_x", text="")
if wide_ui:
col = split.column()
col.prop(con, "use_minimum_y")
sub = col.column()
@@ -376,7 +337,6 @@ class ConstraintButtonsPanel(bpy.types.Panel):
sub.active = con.use_maximum_y
sub.prop(con, "maximum_y", text="")
if wide_ui:
col = split.column()
col.prop(con, "use_minimum_z")
sub = col.column()
@@ -389,16 +349,14 @@ class ConstraintButtonsPanel(bpy.types.Panel):
row = layout.row()
row.prop(con, "limit_transform")
if wide_ui:
row.label()
row = layout.row()
if wide_ui:
row.label(text="Convert:")
row.prop(con, "owner_space", text="")
def COPY_ROTATION(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
def COPY_ROTATION(self, context, layout, con):
self.target_template(layout, con)
split = layout.split()
@@ -422,10 +380,10 @@ class ConstraintButtonsPanel(bpy.types.Panel):
layout.prop(con, "use_offset")
self.space_template(layout, con, wide_ui)
self.space_template(layout, con)
def COPY_LOCATION(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
def COPY_LOCATION(self, context, layout, con):
self.target_template(layout, con)
split = layout.split()
@@ -449,10 +407,10 @@ class ConstraintButtonsPanel(bpy.types.Panel):
layout.prop(con, "use_offset")
self.space_template(layout, con, wide_ui)
self.space_template(layout, con)
def COPY_SCALE(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
def COPY_SCALE(self, context, layout, con):
self.target_template(layout, con)
row = layout.row(align=True)
row.prop(con, "use_x", text="X")
@@ -461,38 +419,31 @@ class ConstraintButtonsPanel(bpy.types.Panel):
layout.prop(con, "use_offset")
self.space_template(layout, con, wide_ui)
self.space_template(layout, con)
def MAINTAIN_VOLUME(self, context, layout, con, wide_ui):
def MAINTAIN_VOLUME(self, context, layout, con):
row = layout.row()
if wide_ui:
row.label(text="Free:")
row.prop(con, "axis", expand=True)
layout.prop(con, "volume")
self.space_template(layout, con, wide_ui)
self.space_template(layout, con)
def COPY_TRANSFORMS(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
def COPY_TRANSFORMS(self, context, layout, con):
self.target_template(layout, con)
self.space_template(layout, con, wide_ui)
self.space_template(layout, con)
#def SCRIPT(self, context, layout, con):
def ACTION(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
def ACTION(self, context, layout, con):
self.target_template(layout, con)
if wide_ui:
layout.prop(con, "action")
else:
layout.prop(con, "action", text="")
if wide_ui:
layout.prop(con, "transform_channel")
else:
layout.prop(con, "transform_channel", text="")
split = layout.split()
@@ -501,32 +452,28 @@ class ConstraintButtonsPanel(bpy.types.Panel):
col.prop(con, "frame_start", text="Start")
col.prop(con, "frame_end", text="End")
if wide_ui:
col = split.column(align=True)
col.label(text="Target Range:")
col.prop(con, "minimum", text="Min")
col.prop(con, "maximum", text="Max")
row = layout.row()
if wide_ui:
row.label(text="Convert:")
row.prop(con, "target_space", text="")
def LOCKED_TRACK(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
def LOCKED_TRACK(self, context, layout, con):
self.target_template(layout, con)
row = layout.row()
if wide_ui:
row.label(text="To:")
row.prop(con, "track", expand=True)
row = layout.row()
if wide_ui:
row.label(text="Lock:")
row.prop(con, "lock", expand=True)
def LIMIT_DISTANCE(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
def LIMIT_DISTANCE(self, context, layout, con):
self.target_template(layout, con)
col = layout.column(align=True)
col.prop(con, "distance")
@@ -536,15 +483,14 @@ class ConstraintButtonsPanel(bpy.types.Panel):
row.label(text="Clamp Region:")
row.prop(con, "limit_mode", text="")
def STRETCH_TO(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
def STRETCH_TO(self, context, layout, con):
self.target_template(layout, con)
split = layout.split()
col = split.column()
col.prop(con, "original_length", text="Rest Length")
if wide_ui:
col = split.column()
col.operator("constraint.stretchto_reset", text="Reset")
@@ -552,53 +498,42 @@ class ConstraintButtonsPanel(bpy.types.Panel):
col.prop(con, "bulge", text="Volume Variation")
row = layout.row()
if wide_ui:
row.label(text="Volume:")
row.prop(con, "volume", expand=True)
if not wide_ui:
row = layout.row()
row.label(text="Plane:")
row.prop(con, "keep_axis", expand=True)
def FLOOR(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
def FLOOR(self, context, layout, con):
self.target_template(layout, con)
split = layout.split()
col = split.column()
col.prop(con, "sticky")
if wide_ui:
col = split.column()
col.prop(con, "use_rotation")
layout.prop(con, "offset")
row = layout.row()
if wide_ui:
row.label(text="Min/Max:")
row.prop(con, "floor_location", expand=True)
self.space_template(layout, con, wide_ui)
self.space_template(layout, con)
def RIGID_BODY_JOINT(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
def RIGID_BODY_JOINT(self, context, layout, con):
self.target_template(layout, con)
if wide_ui:
layout.prop(con, "pivot_type")
else:
layout.prop(con, "pivot_type", text="")
if wide_ui:
layout.prop(con, "child")
else:
layout.prop(con, "child", text="")
split = layout.split()
col = split.column()
col.prop(con, "disable_linked_collision", text="No Collision")
if wide_ui:
col = split.column()
col.prop(con, "draw_pivot", text="Display Pivot")
@@ -610,7 +545,6 @@ class ConstraintButtonsPanel(bpy.types.Panel):
col.prop(con, "pivot_y", text="Y")
col.prop(con, "pivot_z", text="Z")
if wide_ui:
col = split.column(align=True)
col.label(text="Axis:")
col.prop(con, "axis_x", text="X")
@@ -619,19 +553,18 @@ class ConstraintButtonsPanel(bpy.types.Panel):
#Missing: Limit arrays (not wrapped in RNA yet)
def CLAMP_TO(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
def CLAMP_TO(self, context, layout, con):
self.target_template(layout, con)
row = layout.row()
if wide_ui:
row.label(text="Main Axis:")
row.prop(con, "main_axis", expand=True)
row = layout.row()
row.prop(con, "cyclic")
def TRANSFORM(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
def TRANSFORM(self, context, layout, con):
self.target_template(layout, con)
layout.prop(con, "extrapolate_motion", text="Extrapolate")
@@ -646,13 +579,11 @@ class ConstraintButtonsPanel(bpy.types.Panel):
sub.prop(con, "from_min_x", text="Min")
sub.prop(con, "from_max_x", text="Max")
if wide_ui:
sub = split.column(align=True)
sub.label(text="Y:")
sub.prop(con, "from_min_y", text="Min")
sub.prop(con, "from_max_y", text="Max")
if wide_ui:
sub = split.column(align=True)
sub.label(text="Z:")
sub.prop(con, "from_min_z", text="Min")
@@ -674,7 +605,6 @@ class ConstraintButtonsPanel(bpy.types.Panel):
sub.prop(con, "to_min_x", text="Min")
sub.prop(con, "to_max_x", text="Max")
if wide_ui:
col = split.column()
col.label(text="Y:")
col.row().prop(con, "map_to_y_from", expand=True)
@@ -683,7 +613,6 @@ class ConstraintButtonsPanel(bpy.types.Panel):
sub.prop(con, "to_min_y", text="Min")
sub.prop(con, "to_max_y", text="Max")
if wide_ui:
col = split.column()
col.label(text="Z:")
col.row().prop(con, "map_to_z_from", expand=True)
@@ -692,10 +621,10 @@ class ConstraintButtonsPanel(bpy.types.Panel):
sub.prop(con, "to_min_z", text="Min")
sub.prop(con, "to_max_z", text="Max")
self.space_template(layout, con, wide_ui)
self.space_template(layout, con)
def SHRINKWRAP(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
def SHRINKWRAP(self, context, layout, con):
self.target_template(layout, con)
layout.prop(con, "distance")
layout.prop(con, "shrinkwrap_type")
@@ -706,16 +635,15 @@ class ConstraintButtonsPanel(bpy.types.Panel):
row.prop(con, "use_y")
row.prop(con, "use_z")
def DAMPED_TRACK(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
def DAMPED_TRACK(self, context, layout, con):
self.target_template(layout, con)
row = layout.row()
if wide_ui:
row.label(text="To:")
row.prop(con, "track", expand=True)
def SPLINE_IK(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
def SPLINE_IK(self, context, layout, con):
self.target_template(layout, con)
col = layout.column()
col.label(text="Spline Fitting:")
@@ -726,14 +654,11 @@ class ConstraintButtonsPanel(bpy.types.Panel):
col = layout.column()
col.label(text="Chain Scaling:")
col.prop(con, "y_stretch")
if wide_ui:
col.prop(con, "xz_scaling_mode")
else:
col.prop(con, "xz_scaling_mode", text="")
col.prop(con, "use_curve_radius")
def PIVOT(self, context, layout, con, wide_ui):
self.target_template(layout, con, wide_ui)
def PIVOT(self, context, layout, con):
self.target_template(layout, con)
if con.target:
col = layout.column()
@@ -749,12 +674,12 @@ class ConstraintButtonsPanel(bpy.types.Panel):
col = layout.column()
col.prop(con, "enabled_rotation_range", text="Pivot When")
class OBJECT_PT_constraints(ConstraintButtonsPanel):
class OBJECT_PT_constraints(ConstraintButtonsPanel, bpy.types.Panel):
bl_label = "Object Constraints"
bl_context = "constraint"
def poll(self, context):
@classmethod
def poll(cls, context):
return (context.object)
def draw(self, context):
@@ -768,11 +693,12 @@ class OBJECT_PT_constraints(ConstraintButtonsPanel):
self.draw_constraint(context, con)
class BONE_PT_constraints(ConstraintButtonsPanel):
class BONE_PT_constraints(ConstraintButtonsPanel, bpy.types.Panel):
bl_label = "Bone Constraints"
bl_context = "bone_constraint"
def poll(self, context):
@classmethod
def poll(cls, context):
return (context.pose_bone)
def draw(self, context):
@@ -784,21 +710,12 @@ class BONE_PT_constraints(ConstraintButtonsPanel):
self.draw_constraint(context, con)
classes = [
OBJECT_PT_constraints,
BONE_PT_constraints]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -25,40 +25,40 @@ from properties_physics_common import effector_weights_ui
from properties_physics_common import basic_force_field_settings_ui
from properties_physics_common import basic_force_field_falloff_ui
narrowui = bpy.context.user_preferences.view.properties_width_check
def particle_panel_enabled(context, psys):
return (psys.point_cache.baked is False) and (not psys.edited) and (not context.particle_system_editable)
def particle_panel_poll(panel, context):
def particle_panel_poll(cls, context):
psys = context.particle_system
engine = context.scene.render.engine
if psys is None:
return False
if psys.settings is None:
return False
return psys.settings.type in ('EMITTER', 'REACTOR', 'HAIR') and (engine in panel.COMPAT_ENGINES)
return psys.settings.type in ('EMITTER', 'REACTOR', 'HAIR') and (engine in cls.COMPAT_ENGINES)
class ParticleButtonsPanel(bpy.types.Panel):
class ParticleButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "particle"
def poll(self, context):
return particle_panel_poll(self, context)
@classmethod
def poll(cls, context):
return particle_panel_poll(cls, context)
class PARTICLE_PT_context_particles(ParticleButtonsPanel):
class PARTICLE_PT_context_particles(ParticleButtonsPanel, bpy.types.Panel):
bl_label = ""
bl_show_header = False
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
return (context.particle_system or context.object) and (engine in self.COMPAT_ENGINES)
return (context.particle_system or context.object) and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -136,17 +136,18 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel):
split.prop(psys, "reactor_target_particle_system", text="Particle System")
class PARTICLE_PT_custom_props(ParticleButtonsPanel, PropertyPanel):
class PARTICLE_PT_custom_props(ParticleButtonsPanel, PropertyPanel, bpy.types.Panel):
COMPAT_ENGINES = {'BLENDER_RENDER'}
_context_path = "particle_system.settings"
class PARTICLE_PT_emission(ParticleButtonsPanel):
class PARTICLE_PT_emission(ParticleButtonsPanel, bpy.types.Panel):
bl_label = "Emission"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
if particle_panel_poll(self, context):
@classmethod
def poll(cls, context):
if particle_panel_poll(PARTICLE_PT_emission, context):
return not context.particle_system.point_cache.external
else:
return False
@@ -156,7 +157,6 @@ class PARTICLE_PT_emission(ParticleButtonsPanel):
psys = context.particle_system
part = psys.settings
wide_ui = context.region.width > narrowui
layout.enabled = particle_panel_enabled(context, psys) and not psys.multiple_caches
@@ -178,10 +178,8 @@ class PARTICLE_PT_emission(ParticleButtonsPanel):
layout.row().label(text="Emit From:")
row = layout.row()
if wide_ui:
row.prop(part, "emit_from", expand=True)
else:
row.prop(part, "emit_from", text="")
row = layout.row()
row.prop(part, "trand")
if part.distribution != 'GRID':
@@ -189,10 +187,8 @@ class PARTICLE_PT_emission(ParticleButtonsPanel):
if part.emit_from == 'FACE' or part.emit_from == 'VOLUME':
row = layout.row()
if wide_ui:
row.prop(part, "distribution", expand=True)
else:
row.prop(part, "distribution", text="")
row = layout.row()
@@ -203,19 +199,20 @@ class PARTICLE_PT_emission(ParticleButtonsPanel):
row.prop(part, "grid_resolution")
class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel):
class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, bpy.types.Panel):
bl_label = "Hair dynamics"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
psys = context.particle_system
engine = context.scene.render.engine
if psys is None:
return False
if psys.settings is None:
return False
return psys.settings.type == 'HAIR' and (engine in self.COMPAT_ENGINES)
return psys.settings.type == 'HAIR' and (engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
#cloth = context.cloth.collision_settings
@@ -260,12 +257,13 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel):
col.prop(cloth, "quality", text="Steps", slider=True)
class PARTICLE_PT_cache(ParticleButtonsPanel):
class PARTICLE_PT_cache(ParticleButtonsPanel, bpy.types.Panel):
bl_label = "Cache"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
psys = context.particle_system
engine = context.scene.render.engine
if psys is None:
@@ -275,7 +273,7 @@ class PARTICLE_PT_cache(ParticleButtonsPanel):
phystype = psys.settings.physics_type
if phystype == 'NO' or phystype == 'KEYED':
return False
return (psys.settings.type in ('EMITTER', 'REACTOR') or (psys.settings.type == 'HAIR' and psys.hair_dynamics)) and engine in self.COMPAT_ENGINES
return (psys.settings.type in ('EMITTER', 'REACTOR') or (psys.settings.type == 'HAIR' and psys.hair_dynamics)) and engine in cls.COMPAT_ENGINES
def draw(self, context):
psys = context.particle_system
@@ -283,12 +281,13 @@ class PARTICLE_PT_cache(ParticleButtonsPanel):
point_cache_ui(self, context, psys.point_cache, True, 'HAIR' if psys.hair_dynamics else 'PSYS')
class PARTICLE_PT_velocity(ParticleButtonsPanel):
class PARTICLE_PT_velocity(ParticleButtonsPanel, bpy.types.Panel):
bl_label = "Velocity"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
if particle_panel_poll(self, context):
@classmethod
def poll(cls, context):
if particle_panel_poll(PARTICLE_PT_velocity, context):
psys = context.particle_system
return psys.settings.physics_type != 'BOIDS' and not psys.point_cache.external
else:
@@ -330,12 +329,13 @@ class PARTICLE_PT_velocity(ParticleButtonsPanel):
# sub.prop(part, "reaction_shape", slider=True)
class PARTICLE_PT_rotation(ParticleButtonsPanel):
class PARTICLE_PT_rotation(ParticleButtonsPanel, bpy.types.Panel):
bl_label = "Rotation"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
if particle_panel_poll(self, context):
@classmethod
def poll(cls, context):
if particle_panel_poll(PARTICLE_PT_rotation, context):
psys = context.particle_system
return psys.settings.physics_type != 'BOIDS' and not psys.point_cache.external
else:
@@ -346,7 +346,6 @@ class PARTICLE_PT_rotation(ParticleButtonsPanel):
psys = context.particle_system
part = psys.settings
wide_ui = context.region.width > narrowui
layout.enabled = particle_panel_enabled(context, psys)
@@ -364,10 +363,7 @@ class PARTICLE_PT_rotation(ParticleButtonsPanel):
sub.prop(part, "random_phase_factor", text="Random", slider=True)
layout.row().label(text="Angular Velocity:")
if wide_ui:
layout.row().prop(part, "angular_velocity_mode", expand=True)
else:
layout.row().prop(part, "angular_velocity_mode", text="")
split = layout.split()
sub = split.column()
@@ -376,12 +372,13 @@ class PARTICLE_PT_rotation(ParticleButtonsPanel):
sub.prop(part, "angular_velocity_factor", text="")
class PARTICLE_PT_physics(ParticleButtonsPanel):
class PARTICLE_PT_physics(ParticleButtonsPanel, bpy.types.Panel):
bl_label = "Physics"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
if particle_panel_poll(self, context):
@classmethod
def poll(cls, context):
if particle_panel_poll(PARTICLE_PT_physics, context):
return not context.particle_system.point_cache.external
else:
return False
@@ -391,15 +388,11 @@ class PARTICLE_PT_physics(ParticleButtonsPanel):
psys = context.particle_system
part = psys.settings
wide_ui = context.region.width > narrowui
layout.enabled = particle_panel_enabled(context, psys)
row = layout.row()
if wide_ui:
row.prop(part, "physics_type", expand=True)
else:
row.prop(part, "physics_type", text="")
row = layout.row()
col = row.column(align=True)
@@ -573,11 +566,12 @@ class PARTICLE_PT_physics(ParticleButtonsPanel):
sub.prop(key, "system", text="System")
class PARTICLE_PT_boidbrain(ParticleButtonsPanel):
class PARTICLE_PT_boidbrain(ParticleButtonsPanel, bpy.types.Panel):
bl_label = "Boid Brain"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
psys = context.particle_system
engine = context.scene.render.engine
if psys is None:
@@ -586,7 +580,7 @@ class PARTICLE_PT_boidbrain(ParticleButtonsPanel):
return False
if psys.point_cache.external:
return False
return psys.settings.physics_type == 'BOIDS' and engine in self.COMPAT_ENGINES
return psys.settings.physics_type == 'BOIDS' and engine in cls.COMPAT_ENGINES
def draw(self, context):
layout = self.layout
@@ -673,25 +667,25 @@ class PARTICLE_PT_boidbrain(ParticleButtonsPanel):
row.prop(rule, "flee_distance")
class PARTICLE_PT_render(ParticleButtonsPanel):
class PARTICLE_PT_render(ParticleButtonsPanel, bpy.types.Panel):
bl_label = "Render"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
psys = context.particle_system
engine = context.scene.render.engine
if psys is None:
return False
if psys.settings is None:
return False
return engine in self.COMPAT_ENGINES
return engine in cls.COMPAT_ENGINES
def draw(self, context):
layout = self.layout
psys = context.particle_system
part = psys.settings
wide_ui = context.region.width > narrowui
row = layout.row()
row.prop(part, "material")
@@ -707,10 +701,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel):
sub.prop(part, "died")
row = layout.row()
if wide_ui:
row.prop(part, "ren_as", expand=True)
else:
row.prop(part, "ren_as", text="")
split = layout.split()
@@ -797,10 +788,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel):
sub.label(text="Align:")
row = layout.row()
if wide_ui:
row.prop(part, "billboard_align", expand=True)
else:
row.prop(part, "billboard_align", text="")
row.prop(part, "billboard_lock", text="Lock")
row = layout.row()
row.prop(part, "billboard_object")
@@ -843,32 +831,29 @@ class PARTICLE_PT_render(ParticleButtonsPanel):
col.label(text="")
class PARTICLE_PT_draw(ParticleButtonsPanel):
class PARTICLE_PT_draw(ParticleButtonsPanel, bpy.types.Panel):
bl_label = "Display"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
psys = context.particle_system
engine = context.scene.render.engine
if psys is None:
return False
if psys.settings is None:
return False
return engine in self.COMPAT_ENGINES
return engine in cls.COMPAT_ENGINES
def draw(self, context):
layout = self.layout
psys = context.particle_system
part = psys.settings
wide_ui = context.region.width > narrowui
row = layout.row()
if wide_ui:
row.prop(part, "draw_as", expand=True)
else:
row.prop(part, "draw_as", text="")
if part.draw_as == 'NONE' or (part.ren_as == 'NONE' and part.draw_as == 'RENDER'):
return
@@ -902,22 +887,22 @@ class PARTICLE_PT_draw(ParticleButtonsPanel):
#sub.label(text="Override material color")
class PARTICLE_PT_children(ParticleButtonsPanel):
class PARTICLE_PT_children(ParticleButtonsPanel, bpy.types.Panel):
bl_label = "Children"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
@classmethod
def poll(cls, context):
return particle_panel_poll(cls, context)
def draw(self, context):
layout = self.layout
psys = context.particle_system
part = psys.settings
wide_ui = context.region.width > narrowui
if wide_ui:
layout.row().prop(part, "child_type", expand=True)
else:
layout.row().prop(part, "child_type", text="")
if part.child_type == 'NONE':
return
@@ -973,10 +958,7 @@ class PARTICLE_PT_children(ParticleButtonsPanel):
col.label(text="hair parting controls")
layout.row().label(text="Kink:")
if wide_ui:
layout.row().prop(part, "kink", expand=True)
else:
layout.row().prop(part, "kink", text="")
split = layout.split()
@@ -987,7 +969,7 @@ class PARTICLE_PT_children(ParticleButtonsPanel):
col.prop(part, "kink_shape", slider=True)
class PARTICLE_PT_field_weights(ParticleButtonsPanel):
class PARTICLE_PT_field_weights(ParticleButtonsPanel, bpy.types.Panel):
bl_label = "Field Weights"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -1000,7 +982,7 @@ class PARTICLE_PT_field_weights(ParticleButtonsPanel):
self.layout.prop(part.effector_weights, "do_growing_hair")
class PARTICLE_PT_force_fields(ParticleButtonsPanel):
class PARTICLE_PT_force_fields(ParticleButtonsPanel, bpy.types.Panel):
bl_label = "Force Field Settings"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -1028,7 +1010,7 @@ class PARTICLE_PT_force_fields(ParticleButtonsPanel):
basic_force_field_falloff_ui(self, context, part.force_field_2)
class PARTICLE_PT_vertexgroups(ParticleButtonsPanel):
class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, bpy.types.Panel):
bl_label = "Vertexgroups"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -1096,35 +1078,12 @@ class PARTICLE_PT_vertexgroups(ParticleButtonsPanel):
row.prop(psys, "vertex_group_field_negate", text="")
classes = [
PARTICLE_PT_context_particles,
PARTICLE_PT_hair_dynamics,
PARTICLE_PT_cache,
PARTICLE_PT_emission,
PARTICLE_PT_velocity,
PARTICLE_PT_rotation,
PARTICLE_PT_physics,
PARTICLE_PT_boidbrain,
PARTICLE_PT_render,
PARTICLE_PT_draw,
PARTICLE_PT_children,
PARTICLE_PT_field_weights,
PARTICLE_PT_force_fields,
PARTICLE_PT_vertexgroups,
PARTICLE_PT_custom_props]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -19,8 +19,6 @@
# <pep8 compliant>
import bpy
narrowui = bpy.context.user_preferences.view.properties_width_check
from properties_physics_common import point_cache_ui
from properties_physics_common import effector_weights_ui
@@ -40,18 +38,19 @@ class CLOTH_MT_presets(bpy.types.Menu):
draw = bpy.types.Menu.draw_preset
class PhysicButtonsPanel(bpy.types.Panel):
class PhysicButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "physics"
def poll(self, context):
@classmethod
def poll(cls, context):
ob = context.object
rd = context.scene.render
return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
class PHYSICS_PT_cloth(PhysicButtonsPanel):
class PHYSICS_PT_cloth(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Cloth"
def draw(self, context):
@@ -59,7 +58,6 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel):
md = context.cloth
ob = context.object
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -74,7 +72,6 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel):
else:
# add modifier
split.operator("object.modifier_add", text="Add").type = 'CLOTH'
if wide_ui:
split.label()
if md:
@@ -99,7 +96,6 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel):
col.prop(cloth, "structural_stiffness", text="Structural")
col.prop(cloth, "bending_stiffness", text="Bending")
if wide_ui:
col = split.column()
col.label(text="Damping:")
@@ -133,11 +129,12 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel):
col.prop_object(cloth, "rest_shape_key", key, "keys", text="")
class PHYSICS_PT_cloth_cache(PhysicButtonsPanel):
class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Cloth Cache"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
return context.cloth
def draw(self, context):
@@ -145,11 +142,12 @@ class PHYSICS_PT_cloth_cache(PhysicButtonsPanel):
point_cache_ui(self, context, md.point_cache, cloth_panel_enabled(md), 'CLOTH')
class PHYSICS_PT_cloth_collision(PhysicButtonsPanel):
class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Cloth Collision"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
return context.cloth
def draw_header(self, context):
@@ -163,7 +161,6 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel):
cloth = context.cloth.collision_settings
md = context.cloth
wide_ui = context.region.width > narrowui
layout.active = cloth.enable_collision and cloth_panel_enabled(md)
@@ -174,7 +171,6 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel):
col.prop(cloth, "min_distance", slider=True, text="Distance")
col.prop(cloth, "friction")
if wide_ui:
col = split.column()
col.prop(cloth, "enable_self_collision", text="Self Collision")
sub = col.column()
@@ -185,11 +181,12 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel):
layout.prop(cloth, "group")
class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel):
class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Cloth Stiffness Scaling"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
return context.cloth
def draw_header(self, context):
@@ -204,7 +201,6 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel):
md = context.cloth
ob = context.object
cloth = context.cloth.settings
wide_ui = context.region.width > narrowui
layout.active = cloth.stiffness_scaling and cloth_panel_enabled(md)
@@ -215,18 +211,18 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel):
col.prop_object(cloth, "structural_stiffness_vertex_group", ob, "vertex_groups", text="")
col.prop(cloth, "structural_stiffness_max", text="Max")
if wide_ui:
col = split.column()
col.label(text="Bending Stiffness:")
col.prop_object(cloth, "bending_vertex_group", ob, "vertex_groups", text="")
col.prop(cloth, "bending_stiffness_max", text="Max")
class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel):
class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Cloth Field Weights"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
return (context.cloth)
def draw(self, context):
@@ -234,26 +230,12 @@ class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel):
effector_weights_ui(self, context, cloth.effector_weights)
classes = [
CLOTH_MT_presets,
PHYSICS_PT_cloth,
PHYSICS_PT_cloth_cache,
PHYSICS_PT_cloth_collision,
PHYSICS_PT_cloth_stiffness,
PHYSICS_PT_cloth_field_weights]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -20,15 +20,12 @@
import bpy
narrowui = bpy.context.user_preferences.view.properties_width_check
#cachetype can be 'PSYS' 'HAIR' 'SMOKE' etc
def point_cache_ui(self, context, cache, enabled, cachetype):
layout = self.layout
wide_ui = context.region.width > narrowui
layout.set_context_pointer("point_cache", cache)
row = layout.row()
@@ -66,7 +63,6 @@ def point_cache_ui(self, context, cache, enabled, cachetype):
if cachetype != 'SMOKE':
col.prop(cache, "step")
if wide_ui:
col = split.column()
if cachetype != 'SMOKE':
@@ -102,7 +98,6 @@ def point_cache_ui(self, context, cache, enabled, cachetype):
sub.operator("ptcache.bake_from_cache", text="Current Cache to Bake")
if wide_ui:
col = split.column()
col.operator("ptcache.bake_all", text="Bake All Dynamics").bake = True
col.operator("ptcache.free_bake_all", text="Free All Bakes")
@@ -112,7 +107,6 @@ def point_cache_ui(self, context, cache, enabled, cachetype):
def effector_weights_ui(self, context, weights):
layout = self.layout
wide_ui = context.region.width > narrowui
layout.prop(weights, "group")
@@ -121,7 +115,6 @@ def effector_weights_ui(self, context, weights):
col = split.column()
col.prop(weights, "gravity", slider=True)
if wide_ui:
col = split.column()
col.prop(weights, "all", slider=True)
@@ -137,7 +130,6 @@ def effector_weights_ui(self, context, weights):
col.prop(weights, "curveguide", slider=True)
col.prop(weights, "texture", slider=True)
if wide_ui:
col = split.column()
col.prop(weights, "harmonic", slider=True)
col.prop(weights, "charge", slider=True)
@@ -150,7 +142,6 @@ def effector_weights_ui(self, context, weights):
def basic_force_field_settings_ui(self, context, field):
layout = self.layout
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -177,7 +168,6 @@ def basic_force_field_settings_ui(self, context, field):
else:
col.prop(field, "flow")
if wide_ui:
col = split.column()
col.prop(field, "noise")
col.prop(field, "seed")
@@ -193,7 +183,6 @@ def basic_force_field_settings_ui(self, context, field):
col.prop(field, "do_location")
col.prop(field, "do_rotation")
if wide_ui:
col = split.column()
col.label(text="Collision:")
col.prop(field, "do_absorption")
@@ -202,12 +191,9 @@ def basic_force_field_settings_ui(self, context, field):
def basic_force_field_falloff_ui(self, context, field):
layout = self.layout
wide_ui = context.region.width > narrowui
# XXX: This doesn't update for some reason.
#if wide_ui:
# split = layout.split()
#else:
#split = layout.split()
split = layout.split(percentage=0.35)
if not field or field.type == 'NONE':
@@ -218,7 +204,6 @@ def basic_force_field_falloff_ui(self, context, field):
col.prop(field, "use_min_distance", text="Use Minimum")
col.prop(field, "use_max_distance", text="Use Maximum")
if wide_ui:
col = split.column()
col.prop(field, "falloff_power", text="Power")

View File

@@ -19,24 +19,23 @@
# <pep8 compliant>
import bpy
narrowui = bpy.context.user_preferences.view.properties_width_check
from properties_physics_common import basic_force_field_settings_ui
from properties_physics_common import basic_force_field_falloff_ui
class PhysicButtonsPanel(bpy.types.Panel):
class PhysicButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "physics"
def poll(self, context):
@classmethod
def poll(cls, context):
rd = context.scene.render
return (context.object) and (not rd.use_game_engine)
class PHYSICS_PT_field(PhysicButtonsPanel):
class PHYSICS_PT_field(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Force Fields"
def draw(self, context):
@@ -44,22 +43,15 @@ class PHYSICS_PT_field(PhysicButtonsPanel):
ob = context.object
field = ob.field
wide_ui = context.region.width > narrowui
if wide_ui:
split = layout.split(percentage=0.2)
split.label(text="Type:")
else:
split = layout.split()
split.prop(field, "type", text="")
if field.type not in ('NONE', 'GUIDE', 'TEXTURE'):
if wide_ui:
split = layout.split(percentage=0.2)
split.label(text="Shape:")
else:
split = layout.split()
split.prop(field, "shape", text="")
split = layout.split()
@@ -74,7 +66,6 @@ class PHYSICS_PT_field(PhysicButtonsPanel):
col.prop(field, "guide_path_add")
col.prop(field, "use_guide_path_weight")
if wide_ui:
col = split.column()
col.label(text="Clumping:")
col.prop(field, "guide_clump_amount")
@@ -98,7 +89,6 @@ class PHYSICS_PT_field(PhysicButtonsPanel):
col.prop(field, "guide_kink_frequency")
col.prop(field, "guide_kink_shape")
if wide_ui:
col = split.column()
col.prop(field, "guide_kink_amplitude")
@@ -109,7 +99,6 @@ class PHYSICS_PT_field(PhysicButtonsPanel):
col.prop(field, "texture_mode", text="")
col.prop(field, "texture_nabla")
if wide_ui:
col = split.column()
col.prop(field, "use_coordinates")
col.prop(field, "root_coordinates")
@@ -134,7 +123,6 @@ class PHYSICS_PT_field(PhysicButtonsPanel):
col.prop(field, "use_radial_min", text="Use Minimum")
col.prop(field, "use_radial_max", text="Use Maximum")
if wide_ui:
col = split.column()
col.prop(field, "radial_falloff", text="Power")
@@ -156,7 +144,6 @@ class PHYSICS_PT_field(PhysicButtonsPanel):
col.prop(field, "use_radial_min", text="Use Minimum")
col.prop(field, "use_radial_max", text="Use Maximum")
if wide_ui:
col = split.column()
col.prop(field, "radial_falloff", text="Power")
@@ -169,11 +156,12 @@ class PHYSICS_PT_field(PhysicButtonsPanel):
sub.prop(field, "radial_maximum", text="Distance")
class PHYSICS_PT_collision(PhysicButtonsPanel):
class PHYSICS_PT_collision(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Collision"
#bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
ob = context.object
rd = context.scene.render
return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
@@ -182,7 +170,6 @@ class PHYSICS_PT_collision(PhysicButtonsPanel):
layout = self.layout
md = context.collision
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -190,7 +177,6 @@ class PHYSICS_PT_collision(PhysicButtonsPanel):
# remove modifier + settings
split.set_context_pointer("modifier", md)
split.operator("object.modifier_remove", text="Remove")
if wide_ui:
col = split.column()
#row = split.row(align=True)
@@ -202,7 +188,6 @@ class PHYSICS_PT_collision(PhysicButtonsPanel):
else:
# add modifier
split.operator("object.modifier_add", text="Add").type = 'COLLISION'
if wide_ui:
split.label()
coll = None
@@ -229,7 +214,6 @@ class PHYSICS_PT_collision(PhysicButtonsPanel):
sub.prop(settings, "friction_factor", text="Factor", slider=True)
sub.prop(settings, "random_friction", text="Random", slider=True)
if wide_ui:
col = split.column()
col.label(text="Soft Body and Cloth:")
sub = col.column(align=True)
@@ -243,21 +227,12 @@ class PHYSICS_PT_collision(PhysicButtonsPanel):
col.prop(settings, "absorption", text="Absorption")
classes = [
PHYSICS_PT_field,
PHYSICS_PT_collision]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -19,28 +19,26 @@
# <pep8 compliant>
import bpy
narrowui = bpy.context.user_preferences.view.properties_width_check
class PhysicButtonsPanel(bpy.types.Panel):
class PhysicButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "physics"
def poll(self, context):
@classmethod
def poll(cls, context):
ob = context.object
rd = context.scene.render
return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
class PHYSICS_PT_fluid(PhysicButtonsPanel):
class PHYSICS_PT_fluid(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Fluid"
def draw(self, context):
layout = self.layout
md = context.fluid
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -58,22 +56,16 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel):
else:
# add modifier
split.operator("object.modifier_add", text="Add").type = 'FLUID_SIMULATION'
if wide_ui:
split.label()
fluid = None
if fluid:
if wide_ui:
row = layout.row()
row.prop(fluid, "type")
if fluid.type not in ('NONE', 'DOMAIN', 'PARTICLE'):
row.prop(fluid, "active", text="")
else:
layout.prop(fluid, "type", text="")
if fluid.type not in ('NONE', 'DOMAIN', 'PARTICLE'):
layout.prop(fluid, "active", text="")
layout = layout.column()
if fluid.type not in ('NONE', 'DOMAIN', 'PARTICLE'):
@@ -89,7 +81,6 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel):
col.label(text="Render Display:")
col.prop(fluid, "render_display_mode", text="")
if wide_ui:
col = split.column()
col.label(text="Required Memory: " + fluid.memory_estimate)
col.prop(fluid, "preview_resolution", text="Preview")
@@ -104,7 +95,6 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel):
sub.prop(fluid, "start_time", text="Start")
sub.prop(fluid, "end_time", text="End")
if wide_ui:
col = split.column()
col.label()
col.prop(fluid, "generate_speed_vectors")
@@ -120,7 +110,6 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel):
col.prop(fluid, "volume_initialization", text="")
col.prop(fluid, "export_animated_mesh")
if wide_ui:
col = split.column()
col.label(text="Initial Velocity:")
col.prop(fluid, "initial_velocity", text="")
@@ -133,7 +122,6 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel):
col.prop(fluid, "volume_initialization", text="")
col.prop(fluid, "export_animated_mesh")
if wide_ui:
col = split.column()
col.label(text="Slip Type:")
col.prop(fluid, "slip_type", text="")
@@ -152,7 +140,6 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel):
col.prop(fluid, "export_animated_mesh")
col.prop(fluid, "local_coordinates")
if wide_ui:
col = split.column()
col.label(text="Inflow Velocity:")
col.prop(fluid, "inflow_velocity", text="")
@@ -165,7 +152,6 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel):
col.prop(fluid, "volume_initialization", text="")
col.prop(fluid, "export_animated_mesh")
if wide_ui:
split.column()
elif fluid.type == 'PARTICLE':
@@ -176,7 +162,6 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel):
col.prop(fluid, "particle_influence", text="Size")
col.prop(fluid, "alpha_influence", text="Alpha")
if wide_ui:
col = split.column()
col.label(text="Type:")
col.prop(fluid, "drops")
@@ -193,7 +178,6 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel):
col.prop(fluid, "quality", slider=True)
col.prop(fluid, "reverse_frames")
if wide_ui:
col = split.column()
col.label(text="Time:")
sub = col.column(align=True)
@@ -208,7 +192,6 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel):
sub.prop(fluid, "attraction_strength", text="Strength")
sub.prop(fluid, "attraction_radius", text="Radius")
if wide_ui:
col = split.column()
col.label(text="Velocity Force:")
sub = col.column(align=True)
@@ -216,20 +199,20 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel):
sub.prop(fluid, "velocity_radius", text="Radius")
class PHYSICS_PT_domain_gravity(PhysicButtonsPanel):
class PHYSICS_PT_domain_gravity(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Domain World"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
md = context.fluid
return md and (md.settings.type == 'DOMAIN')
return md and md.settings and (md.settings.type == 'DOMAIN')
def draw(self, context):
layout = self.layout
fluid = context.fluid.settings
scene = context.scene
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -252,7 +235,6 @@ class PHYSICS_PT_domain_gravity(PhysicButtonsPanel):
col.label(text="Real World Size:")
col.prop(fluid, "real_world_size", text="Metres")
if wide_ui:
col = split.column()
col.label(text="Viscosity Presets:")
sub = col.column(align=True)
@@ -267,19 +249,19 @@ class PHYSICS_PT_domain_gravity(PhysicButtonsPanel):
col.prop(fluid, "compressibility", slider=True)
class PHYSICS_PT_domain_boundary(PhysicButtonsPanel):
class PHYSICS_PT_domain_boundary(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Domain Boundary"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
md = context.fluid
return md and (md.settings.type == 'DOMAIN')
return md and md.settings and (md.settings.type == 'DOMAIN')
def draw(self, context):
layout = self.layout
fluid = context.fluid.settings
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -289,20 +271,20 @@ class PHYSICS_PT_domain_boundary(PhysicButtonsPanel):
if fluid.slip_type == 'PARTIALSLIP':
col.prop(fluid, "partial_slip_factor", slider=True, text="Amount")
if wide_ui:
col = split.column()
col.label(text="Surface:")
col.prop(fluid, "surface_smoothing", text="Smoothing")
col.prop(fluid, "surface_subdivisions", text="Subdivisions")
class PHYSICS_PT_domain_particles(PhysicButtonsPanel):
class PHYSICS_PT_domain_particles(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Domain Particles"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
md = context.fluid
return md and (md.settings.type == 'DOMAIN')
return md and md.settings and (md.settings.type == 'DOMAIN')
def draw(self, context):
layout = self.layout
@@ -314,23 +296,12 @@ class PHYSICS_PT_domain_particles(PhysicButtonsPanel):
col.prop(fluid, "generate_particles")
classes = [
PHYSICS_PT_fluid,
PHYSICS_PT_domain_gravity,
PHYSICS_PT_domain_boundary,
PHYSICS_PT_domain_particles]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -19,25 +19,24 @@
# <pep8 compliant>
import bpy
narrowui = bpy.context.user_preferences.view.properties_width_check
from properties_physics_common import point_cache_ui
from properties_physics_common import effector_weights_ui
class PhysicButtonsPanel(bpy.types.Panel):
class PhysicButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "physics"
def poll(self, context):
@classmethod
def poll(cls, context):
ob = context.object
rd = context.scene.render
return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
class PHYSICS_PT_smoke(PhysicButtonsPanel):
class PHYSICS_PT_smoke(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Smoke"
def draw(self, context):
@@ -45,7 +44,6 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel):
md = context.smoke
ob = context.object
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -61,14 +59,10 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel):
else:
# add modifier
split.operator("object.modifier_add", text="Add").type = 'SMOKE'
if wide_ui:
split.label()
if md:
if wide_ui:
layout.prop(md, "smoke_type", expand=True)
else:
layout.prop(md, "smoke_type", text="")
if md.smoke_type == 'DOMAIN':
domain = md.domain_settings
@@ -83,7 +77,6 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel):
col.label(text="Border Collisions:")
col.prop(domain, "smoke_domain_colli", text="")
if wide_ui:
col = split.column()
col.label(text="Behavior:")
col.prop(domain, "alpha")
@@ -114,7 +107,7 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel):
sub.active = flow.initial_velocity
sub.prop(flow, "velocity_multiplier", text="Multiplier")
if wide_ui:
sub = split.column()
sub.active = not md.flow_settings.outflow
sub.label(text="Behavior:")
@@ -126,11 +119,12 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel):
# layout.separator()
class PHYSICS_PT_smoke_groups(PhysicButtonsPanel):
class PHYSICS_PT_smoke_groups(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Smoke Groups"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
md = context.smoke
return md and (md.smoke_type == 'DOMAIN')
@@ -138,7 +132,6 @@ class PHYSICS_PT_smoke_groups(PhysicButtonsPanel):
layout = self.layout
group = context.smoke.domain_settings
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -149,17 +142,17 @@ class PHYSICS_PT_smoke_groups(PhysicButtonsPanel):
#col.label(text="Effector Group:")
#col.prop(group, "eff_group", text="")
if wide_ui:
col = split.column()
col.label(text="Collision Group:")
col.prop(group, "coll_group", text="")
class PHYSICS_PT_smoke_cache(PhysicButtonsPanel):
class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Smoke Cache"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
md = context.smoke
return md and (md.smoke_type == 'DOMAIN')
@@ -175,11 +168,12 @@ class PHYSICS_PT_smoke_cache(PhysicButtonsPanel):
point_cache_ui(self, context, cache, (cache.baked is False), 'SMOKE')
class PHYSICS_PT_smoke_highres(PhysicButtonsPanel):
class PHYSICS_PT_smoke_highres(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Smoke High Resolution"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
md = context.smoke
return md and (md.smoke_type == 'DOMAIN')
@@ -192,7 +186,6 @@ class PHYSICS_PT_smoke_highres(PhysicButtonsPanel):
layout = self.layout
md = context.smoke.domain_settings
wide_ui = context.region.width > narrowui
layout.active = md.highres
@@ -204,18 +197,18 @@ class PHYSICS_PT_smoke_highres(PhysicButtonsPanel):
col.prop(md, "smoothemitter")
col.prop(md, "viewhighres")
if wide_ui:
col = split.column()
col.label(text="Noise Method:")
col.row().prop(md, "noise_type", text="")
col.prop(md, "strength")
class PHYSICS_PT_smoke_cache_highres(PhysicButtonsPanel):
class PHYSICS_PT_smoke_cache_highres(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Smoke High Resolution Cache"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
md = context.smoke
return md and (md.smoke_type == 'DOMAIN') and md.domain_settings.highres
@@ -231,11 +224,12 @@ class PHYSICS_PT_smoke_cache_highres(PhysicButtonsPanel):
point_cache_ui(self, context, cache, (cache.baked is False), 'SMOKE')
class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel):
class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Smoke Field Weights"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
smoke = context.smoke
return (smoke and smoke.smoke_type == 'DOMAIN')
@@ -244,25 +238,12 @@ class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel):
effector_weights_ui(self, context, domain.effector_weights)
classes = [
PHYSICS_PT_smoke,
PHYSICS_PT_smoke_field_weights,
PHYSICS_PT_smoke_cache,
PHYSICS_PT_smoke_highres,
PHYSICS_PT_smoke_groups,
PHYSICS_PT_smoke_cache_highres]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -19,8 +19,6 @@
# <pep8 compliant>
import bpy
narrowui = bpy.context.user_preferences.view.properties_width_check
from properties_physics_common import point_cache_ui
from properties_physics_common import effector_weights_ui
@@ -30,12 +28,13 @@ def softbody_panel_enabled(md):
return (md.point_cache.baked is False)
class PhysicButtonsPanel(bpy.types.Panel):
class PhysicButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "physics"
def poll(self, context):
@classmethod
def poll(cls, context):
ob = context.object
rd = context.scene.render
# return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
@@ -43,7 +42,7 @@ class PhysicButtonsPanel(bpy.types.Panel):
return (ob and (ob.type == 'MESH' or ob.type == 'LATTICE'or ob.type == 'CURVE')) and (not rd.use_game_engine)
class PHYSICS_PT_softbody(PhysicButtonsPanel):
class PHYSICS_PT_softbody(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Soft Body"
def draw(self, context):
@@ -51,7 +50,6 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel):
md = context.soft_body
ob = context.object
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -66,7 +64,6 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel):
else:
# add modifier
split.operator("object.modifier_add", text="Add").type = 'SOFT_BODY'
if wide_ui:
split.column()
if md:
@@ -82,17 +79,17 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel):
col.prop(softbody, "mass")
col.prop_object(softbody, "mass_vertex_group", ob, "vertex_groups", text="Mass:")
if wide_ui:
col = split.column()
col.label(text="Simulation:")
col.prop(softbody, "speed")
class PHYSICS_PT_softbody_cache(PhysicButtonsPanel):
class PHYSICS_PT_softbody_cache(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Soft Body Cache"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
return context.soft_body
def draw(self, context):
@@ -100,11 +97,12 @@ class PHYSICS_PT_softbody_cache(PhysicButtonsPanel):
point_cache_ui(self, context, md.point_cache, softbody_panel_enabled(md), 'SOFTBODY')
class PHYSICS_PT_softbody_goal(PhysicButtonsPanel):
class PHYSICS_PT_softbody_goal(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Soft Body Goal"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
return context.soft_body
def draw_header(self, context):
@@ -119,7 +117,6 @@ class PHYSICS_PT_softbody_goal(PhysicButtonsPanel):
md = context.soft_body
softbody = md.settings
ob = context.object
wide_ui = context.region.width > narrowui
layout.active = softbody.use_goal and softbody_panel_enabled(md)
@@ -135,7 +132,6 @@ class PHYSICS_PT_softbody_goal(PhysicButtonsPanel):
sub.prop(softbody, "goal_min", text="Minimum")
sub.prop(softbody, "goal_max", text="Maximum")
if wide_ui:
col = split.column()
col.label(text="Goal Settings:")
col.prop(softbody, "goal_spring", text="Stiffness")
@@ -144,11 +140,12 @@ class PHYSICS_PT_softbody_goal(PhysicButtonsPanel):
layout.prop_object(softbody, "goal_vertex_group", ob, "vertex_groups", text="Vertex Group")
class PHYSICS_PT_softbody_edge(PhysicButtonsPanel):
class PHYSICS_PT_softbody_edge(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Soft Body Edges"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
return context.soft_body
def draw_header(self, context):
@@ -163,7 +160,6 @@ class PHYSICS_PT_softbody_edge(PhysicButtonsPanel):
md = context.soft_body
softbody = md.settings
ob = context.object
wide_ui = context.region.width > narrowui
layout.active = softbody.use_edges and softbody_panel_enabled(md)
@@ -179,7 +175,6 @@ class PHYSICS_PT_softbody_edge(PhysicButtonsPanel):
col.prop(softbody, "spring_length", text="Length")
col.prop_object(softbody, "spring_vertex_group", ob, "vertex_groups", text="Springs:")
if wide_ui:
col = split.column()
col.prop(softbody, "stiff_quads")
sub = col.column()
@@ -199,11 +194,12 @@ class PHYSICS_PT_softbody_edge(PhysicButtonsPanel):
col.prop(softbody, "face_collision", text="Face")
class PHYSICS_PT_softbody_collision(PhysicButtonsPanel):
class PHYSICS_PT_softbody_collision(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Soft Body Self Collision"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
return context.soft_body
def draw_header(self, context):
@@ -217,15 +213,11 @@ class PHYSICS_PT_softbody_collision(PhysicButtonsPanel):
md = context.soft_body
softbody = md.settings
wide_ui = context.region.width > narrowui
layout.active = softbody.self_collision and softbody_panel_enabled(md)
layout.label(text="Collision Ball Size Calculation:")
if wide_ui:
layout.prop(softbody, "collision_type", expand=True)
else:
layout.prop(softbody, "collision_type", text="")
col = layout.column(align=True)
col.label(text="Ball:")
@@ -234,11 +226,12 @@ class PHYSICS_PT_softbody_collision(PhysicButtonsPanel):
col.prop(softbody, "ball_damp", text="Dampening")
class PHYSICS_PT_softbody_solver(PhysicButtonsPanel):
class PHYSICS_PT_softbody_solver(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Soft Body Solver"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
return context.soft_body
def draw(self, context):
@@ -246,7 +239,6 @@ class PHYSICS_PT_softbody_solver(PhysicButtonsPanel):
md = context.soft_body
softbody = md.settings
wide_ui = context.region.width > narrowui
layout.active = softbody_panel_enabled(md)
@@ -259,7 +251,6 @@ class PHYSICS_PT_softbody_solver(PhysicButtonsPanel):
col.prop(softbody, "maxstep")
col.prop(softbody, "auto_step", text="Auto-Step")
if wide_ui:
col = split.column()
col.prop(softbody, "error_limit")
col.label(text="Helpers:")
@@ -271,11 +262,12 @@ class PHYSICS_PT_softbody_solver(PhysicButtonsPanel):
layout.prop(softbody, "estimate_matrix")
class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel):
class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Soft Body Field Weights"
bl_default_closed = True
def poll(self, context):
@classmethod
def poll(cls, context):
return (context.soft_body)
def draw(self, context):
@@ -285,26 +277,12 @@ class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel):
effector_weights_ui(self, context, softbody.effector_weights)
classes = [
PHYSICS_PT_softbody,
PHYSICS_PT_softbody_cache,
PHYSICS_PT_softbody_goal,
PHYSICS_PT_softbody_edge,
PHYSICS_PT_softbody_collision,
PHYSICS_PT_softbody_solver,
PHYSICS_PT_softbody_field_weights]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -19,8 +19,6 @@
# <pep8 compliant>
import bpy
narrowui = bpy.context.user_preferences.view.properties_width_check
class RENDER_MT_presets(bpy.types.Menu):
bl_label = "Render Presets"
@@ -36,18 +34,19 @@ class RENDER_MT_ffmpeg_presets(bpy.types.Menu):
draw = bpy.types.Menu.draw_preset
class RenderButtonsPanel(bpy.types.Panel):
class RenderButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "render"
# COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
def poll(self, context):
@classmethod
def poll(cls, context):
rd = context.scene.render
return (context.scene and rd.use_game_engine is False) and (rd.engine in self.COMPAT_ENGINES)
return (context.scene and rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES)
class RENDER_PT_render(RenderButtonsPanel):
class RENDER_PT_render(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Render"
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -55,21 +54,19 @@ class RENDER_PT_render(RenderButtonsPanel):
layout = self.layout
rd = context.scene.render
wide_ui = context.region.width > narrowui
split = layout.split()
col = split.column()
col.operator("render.render", text="Image", icon='RENDER_STILL')
if wide_ui:
col = split.column()
col.operator("render.render", text="Animation", icon='RENDER_ANIMATION').animation = True
layout.prop(rd, "display_mode", text="Display")
class RENDER_PT_layers(RenderButtonsPanel):
class RENDER_PT_layers(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Layers"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -79,7 +76,6 @@ class RENDER_PT_layers(RenderButtonsPanel):
scene = context.scene
rd = scene.render
wide_ui = context.region.width > narrowui
row = layout.row()
row.template_list(rd, "layers", rd, "active_layer_index", rows=2)
@@ -100,7 +96,7 @@ class RENDER_PT_layers(RenderButtonsPanel):
col.label(text="")
col.prop(rl, "light_override", text="Light")
col.prop(rl, "material_override", text="Material")
if wide_ui:
col = split.column()
col.prop(rl, "visible_layers", text="Layer")
col.label(text="Mask Layers:")
@@ -145,7 +141,6 @@ class RENDER_PT_layers(RenderButtonsPanel):
col.prop(rl, "pass_object_index")
col.prop(rl, "pass_color")
if wide_ui:
col = split.column()
col.label()
col.prop(rl, "pass_diffuse")
@@ -175,11 +170,12 @@ class RENDER_PT_layers(RenderButtonsPanel):
row.prop(rl, "pass_refraction_exclude", text="")
class RENDER_PT_freestyle(RenderButtonsPanel):
class RENDER_PT_freestyle(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Freestyle"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
rd = context.scene.render
rl = rd.layers[rd.active_layer_index]
return rl and rl.freestyle
@@ -279,11 +275,12 @@ class RENDER_PT_freestyle(RenderButtonsPanel):
row.operator("scene.freestyle_module_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
class RENDER_PT_freestyle_linestyle(RenderButtonsPanel):
class RENDER_PT_freestyle_linestyle(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Freestyle: Line Style"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
rd = context.scene.render
rl = rd.layers[rd.active_layer_index]
if rl and rl.freestyle:
@@ -421,7 +418,7 @@ class RENDER_PT_freestyle_linestyle(RenderButtonsPanel):
pass
class RENDER_PT_shading(RenderButtonsPanel):
class RENDER_PT_shading(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Shading"
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -429,7 +426,6 @@ class RENDER_PT_shading(RenderButtonsPanel):
layout = self.layout
rd = context.scene.render
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -439,14 +435,13 @@ class RENDER_PT_shading(RenderButtonsPanel):
col.prop(rd, "use_sss", text="Subsurface Scattering")
col.prop(rd, "use_envmaps", text="Environment Map")
if wide_ui:
col = split.column()
col.prop(rd, "use_raytracing", text="Ray Tracing")
col.prop(rd, "color_management")
col.prop(rd, "alpha_mode", text="Alpha")
class RENDER_PT_performance(RenderButtonsPanel):
class RENDER_PT_performance(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Performance"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -455,7 +450,6 @@ class RENDER_PT_performance(RenderButtonsPanel):
layout = self.layout
rd = context.scene.render
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -470,7 +464,6 @@ class RENDER_PT_performance(RenderButtonsPanel):
sub.prop(rd, "parts_x", text="X")
sub.prop(rd, "parts_y", text="Y")
if wide_ui:
col = split.column()
col.label(text="Memory:")
sub = col.column()
@@ -490,7 +483,7 @@ class RENDER_PT_performance(RenderButtonsPanel):
sub.prop(rd, "use_local_coords", text="Local Coordinates")
class RENDER_PT_post_processing(RenderButtonsPanel):
class RENDER_PT_post_processing(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Post Processing"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -499,7 +492,6 @@ class RENDER_PT_post_processing(RenderButtonsPanel):
layout = self.layout
rd = context.scene.render
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -507,7 +499,6 @@ class RENDER_PT_post_processing(RenderButtonsPanel):
col.prop(rd, "use_compositing")
col.prop(rd, "use_sequencer")
if wide_ui:
col = split.column()
col.prop(rd, "dither_intensity", text="Dither", slider=True)
@@ -523,10 +514,7 @@ class RENDER_PT_post_processing(RenderButtonsPanel):
sub.prop(rd, "fields_still", text="Still")
if wide_ui:
col = split.column()
else:
col.separator()
col.prop(rd, "edge")
sub = col.column()
sub.active = rd.edge
@@ -540,7 +528,7 @@ class RENDER_PT_post_processing(RenderButtonsPanel):
col.prop(rd, "freestyle", text="Freestyle")
class RENDER_PT_output(RenderButtonsPanel):
class RENDER_PT_output(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Output"
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -549,7 +537,6 @@ class RENDER_PT_output(RenderButtonsPanel):
rd = context.scene.render
file_format = rd.file_format
wide_ui = context.region.width > narrowui
layout.prop(rd, "output_path", text="")
@@ -558,7 +545,6 @@ class RENDER_PT_output(RenderButtonsPanel):
col.prop(rd, "file_format", text="")
col.row().prop(rd, "color_mode", text="Color", expand=True)
if wide_ui:
col = split.column()
col.prop(rd, "use_file_extension")
col.prop(rd, "use_overwrite")
@@ -578,7 +564,6 @@ class RENDER_PT_output(RenderButtonsPanel):
col = split.column()
col.label(text="Codec:")
col.prop(rd, "exr_codec", text="")
if wide_ui:
col = split.column()
elif file_format == 'OPEN_EXR':
@@ -588,13 +573,11 @@ class RENDER_PT_output(RenderButtonsPanel):
col.label(text="Codec:")
col.prop(rd, "exr_codec", text="")
if wide_ui:
subsplit = split.split()
col = subsplit.column()
col.prop(rd, "exr_half")
col.prop(rd, "exr_zbuf")
if wide_ui:
col = subsplit.column()
col.prop(rd, "exr_preview")
@@ -604,7 +587,6 @@ class RENDER_PT_output(RenderButtonsPanel):
col.label(text="Depth:")
col.row().prop(rd, "jpeg2k_depth", expand=True)
if wide_ui:
col = split.column()
col.prop(rd, "jpeg2k_preset", text="")
col.prop(rd, "jpeg2k_ycc")
@@ -614,7 +596,6 @@ class RENDER_PT_output(RenderButtonsPanel):
col = split.column()
col.prop(rd, "cineon_log", text="Convert to Log")
if wide_ui:
col = split.column(align=True)
col.active = rd.cineon_log
col.prop(rd, "cineon_black", text="Black")
@@ -642,7 +623,7 @@ class RENDER_PT_output(RenderButtonsPanel):
col = split.column()
if rd.quicktime_audiocodec_type == 'LPCM':
col.prop(rd, "quicktime_audio_bitdepth", text="")
if wide_ui:
col = split.column()
col.prop(rd, "quicktime_audio_samplerate", text="")
@@ -650,22 +631,24 @@ class RENDER_PT_output(RenderButtonsPanel):
col = split.column()
if rd.quicktime_audiocodec_type == 'AAC':
col.prop(rd, "quicktime_audio_bitrate")
if wide_ui:
subsplit = split.split()
col = subsplit.column()
if rd.quicktime_audiocodec_type == 'AAC':
col.prop(rd, "quicktime_audio_codec_isvbr")
if wide_ui:
col = subsplit.column()
col.prop(rd, "quicktime_audio_resampling_hq")
class RENDER_PT_encoding(RenderButtonsPanel):
class RENDER_PT_encoding(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Encoding"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
rd = context.scene.render
return rd.file_format in ('FFMPEG', 'XVID', 'H264', 'THEORA')
@@ -673,7 +656,6 @@ class RENDER_PT_encoding(RenderButtonsPanel):
layout = self.layout
rd = context.scene.render
wide_ui = context.region.width > narrowui
layout.menu("RENDER_MT_ffmpeg_presets", text="Presets")
@@ -682,18 +664,16 @@ class RENDER_PT_encoding(RenderButtonsPanel):
col = split.column()
col.prop(rd, "ffmpeg_format")
if rd.ffmpeg_format in ('AVI', 'QUICKTIME', 'MKV', 'OGG'):
if wide_ui:
col = split.column()
col.prop(rd, "ffmpeg_codec")
else:
if wide_ui:
split.label()
split = layout.split()
col = split.column()
col.prop(rd, "ffmpeg_video_bitrate")
if wide_ui:
col = split.column()
col.prop(rd, "ffmpeg_gopsize")
@@ -705,7 +685,6 @@ class RENDER_PT_encoding(RenderButtonsPanel):
col.prop(rd, "ffmpeg_maxrate", text="Maximum")
col.prop(rd, "ffmpeg_buffersize", text="Buffer")
if wide_ui:
col = split.column()
col.prop(rd, "ffmpeg_autosplit")
@@ -727,12 +706,11 @@ class RENDER_PT_encoding(RenderButtonsPanel):
col.prop(rd, "ffmpeg_audio_bitrate")
col.prop(rd, "ffmpeg_audio_mixrate")
if wide_ui:
col = split.column()
col.prop(rd, "ffmpeg_audio_volume", slider=True)
class RENDER_PT_antialiasing(RenderButtonsPanel):
class RENDER_PT_antialiasing(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Anti-Aliasing"
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -745,7 +723,6 @@ class RENDER_PT_antialiasing(RenderButtonsPanel):
layout = self.layout
rd = context.scene.render
wide_ui = context.region.width > narrowui
layout.active = rd.render_antialiasing
split = layout.split()
@@ -756,13 +733,12 @@ class RENDER_PT_antialiasing(RenderButtonsPanel):
sub.enabled = not rd.use_border
sub.prop(rd, "full_sample")
if wide_ui:
col = split.column()
col.prop(rd, "pixel_filter", text="")
col.prop(rd, "filter_size", text="Size")
class RENDER_PT_motion_blur(RenderButtonsPanel):
class RENDER_PT_motion_blur(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Full Sample Motion Blur"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -782,8 +758,7 @@ class RENDER_PT_motion_blur(RenderButtonsPanel):
row.prop(rd, "motion_blur_samples")
row.prop(rd, "motion_blur_shutter")
class RENDER_PT_dimensions(RenderButtonsPanel):
class RENDER_PT_dimensions(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Dimensions"
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -792,7 +767,6 @@ class RENDER_PT_dimensions(RenderButtonsPanel):
scene = context.scene
rd = scene.render
wide_ui = context.region.width > narrowui
row = layout.row(align=True)
row.menu("RENDER_MT_presets", text=bpy.types.RENDER_MT_presets.bl_label)
@@ -817,7 +791,6 @@ class RENDER_PT_dimensions(RenderButtonsPanel):
sub.active = rd.use_border
sub.prop(rd, "crop_to_border", text="Crop")
if wide_ui:
col = split.column()
sub = col.column(align=True)
sub.label(text="Frame Range:")
@@ -830,7 +803,7 @@ class RENDER_PT_dimensions(RenderButtonsPanel):
sub.prop(rd, "fps_base", text="/")
class RENDER_PT_stamp(RenderButtonsPanel):
class RENDER_PT_stamp(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Stamp"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -844,7 +817,6 @@ class RENDER_PT_stamp(RenderButtonsPanel):
layout = self.layout
rd = context.scene.render
wide_ui = context.region.width > narrowui
layout.active = rd.render_stamp
@@ -861,7 +833,6 @@ class RENDER_PT_stamp(RenderButtonsPanel):
col.prop(rd, "stamp_marker", text="Marker")
col.prop(rd, "stamp_sequencer_strip", text="Seq. Strip")
if wide_ui:
col = split.column()
col.active = rd.render_stamp
col.prop(rd, "stamp_foreground", slider=True)
@@ -876,7 +847,7 @@ class RENDER_PT_stamp(RenderButtonsPanel):
sub.prop(rd, "stamp_note_text", text="")
class RENDER_PT_bake(RenderButtonsPanel):
class RENDER_PT_bake(RenderButtonsPanel, bpy.types.Panel):
bl_label = "Bake"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -885,20 +856,13 @@ class RENDER_PT_bake(RenderButtonsPanel):
layout = self.layout
rd = context.scene.render
wide_ui = context.region.width > narrowui
layout.operator("object.bake_image", icon='RENDER_STILL')
if wide_ui:
layout.prop(rd, "bake_type")
else:
layout.prop(rd, "bake_type", text="")
if rd.bake_type == 'NORMALS':
if wide_ui:
layout.prop(rd, "bake_normal_space")
else:
layout.prop(rd, "bake_normal_space", text="")
elif rd.bake_type in ('DISPLACEMENT', 'AO'):
layout.prop(rd, "bake_normalized")
@@ -914,7 +878,6 @@ class RENDER_PT_bake(RenderButtonsPanel):
col.prop(rd, "bake_margin")
col.prop(rd, "bake_quad_split", text="Split")
if wide_ui:
col = split.column()
col.prop(rd, "bake_active")
sub = col.column()
@@ -923,35 +886,12 @@ class RENDER_PT_bake(RenderButtonsPanel):
sub.prop(rd, "bake_bias")
classes = [
RENDER_MT_presets,
RENDER_MT_ffmpeg_presets,
RENDER_PT_render,
RENDER_PT_layers,
RENDER_PT_freestyle,
RENDER_PT_freestyle_linestyle,
RENDER_PT_dimensions,
RENDER_PT_antialiasing,
RENDER_PT_motion_blur,
RENDER_PT_shading,
RENDER_PT_output,
RENDER_PT_encoding,
RENDER_PT_performance,
RENDER_PT_post_processing,
RENDER_PT_stamp,
RENDER_PT_bake]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -0,0 +1,79 @@
<ui>
<panel identifier="RENDER_PT_stamp_test" label="Stamp (XML)" space_type="PROPERTIES" region_type="WINDOW" context="render" default_closed="true">
<draw_header>
<prop data="context.scene.render" property="render_stamp" text=""/>
</draw_header>
<draw>
<split>
<column>
<prop data="context.scene.render" property="stamp_time" text="Time"/>
<prop data="context.scene.render" property="stamp_date" text="Date"/>
<prop data="context.scene.render" property="stamp_render_time" text="RenderTime"/>
<prop data="context.scene.render" property="stamp_frame" text="Frame"/>
<prop data="context.scene.render" property="stamp_scene" text="Scene"/>
<prop data="context.scene.render" property="stamp_camera" text="Camera"/>
<prop data="context.scene.render" property="stamp_filename" text="Filename"/>
<prop data="context.scene.render" property="stamp_marker" text="Marker"/>
<prop data="context.scene.render" property="stamp_sequencer_strip" text="Seq. Strip"/>
</column>
<column>
<active expr="context.scene.render.render_stamp"/>
<prop data="context.scene.render" property="stamp_foreground" slider="true"/>
<prop data="context.scene.render" property="stamp_background" slider="true"/>
<separator/>
<prop data="context.scene.render" property="stamp_font_size" text="Font Size"/>
</column>
</split>
<split percentage="0.2">
<prop data="context.scene.render" property="stamp_note" text="Note"/>
<row>
<active expr="context.scene.render.stamp_note"/>
<prop data="context.scene.render" property="stamp_note_text" text=""/>
</row>
</split>
</draw>
</panel>
<panel identifier="RENDER_PT_dimensions_test" label="Dimensions (XML)" space_type="PROPERTIES" region_type="WINDOW" context="render">
<draw>
<row align="true">
<menu menu="RENDER_MT_presets"/>
<operator operator="render.preset_add" text="" icon="ZOOMIN"/>
</row>
<split>
<column>
<column align="true">
<label text="Resolution:"/>
<prop data="context.scene.render" property="resolution_x" text="X"/>
<prop data="context.scene.render" property="resolution_y" text="Y"/>
<prop data="context.scene.render" property="resolution_percentage" text=""/>
<label text="Aspect Ratio:"/>
<prop data="context.scene.render" property="pixel_aspect_x" text="X"/>
<prop data="context.scene.render" property="pixel_aspect_y" text="Y"/>
</column>
<row>
<prop data="context.scene.render" property="use_border" text="Border"/>
<row>
<active expr="context.scene.render.use_border"/>
<prop data="context.scene.render" property="crop_to_border" text="Crop"/>
</row>
</row>
</column>
<column>
<column align="true">
<label text="Frame Range:"/>
<prop data="context.scene" property="frame_start" text="Start"/>
<prop data="context.scene" property="frame_end" text="End"/>
<prop data="context.scene" property="frame_step" text="Step"/>
<label text="Frame Rate:"/>
<prop data="context.scene.render" property="fps"/>
<prop data="context.scene.render" property="fps_base" text="/"/>
</column>
</column>
</split>
</draw>
</panel>
</ui>

View File

@@ -20,46 +20,40 @@
import bpy
from rna_prop_ui import PropertyPanel
narrowui = bpy.context.user_preferences.view.properties_width_check
class SceneButtonsPanel(bpy.types.Panel):
class SceneButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "scene"
def poll(self, context):
@classmethod
def poll(cls, context):
return context.scene
class SCENE_PT_scene(SceneButtonsPanel):
class SCENE_PT_scene(SceneButtonsPanel, bpy.types.Panel):
bl_label = "Scene"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def draw(self, context):
layout = self.layout
wide_ui = context.region.width > narrowui
scene = context.scene
if wide_ui:
layout.prop(scene, "camera")
layout.prop(scene, "set", text="Background")
else:
layout.prop(scene, "camera", text="")
layout.prop(scene, "set", text="")
class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel):
class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, bpy.types.Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
_context_path = "scene"
class SCENE_PT_unit(SceneButtonsPanel):
class SCENE_PT_unit(SceneButtonsPanel, bpy.types.Panel):
bl_label = "Units"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def draw(self, context):
layout = self.layout
wide_ui = context.region.width > narrowui
unit = context.scene.unit_settings
col = layout.column()
@@ -71,21 +65,19 @@ class SCENE_PT_unit(SceneButtonsPanel):
col = split.column()
col.prop(unit, "scale_length", text="Scale")
if wide_ui:
col = split.column()
col.prop(unit, "use_separate")
layout.column().prop(unit, "rotation_units")
class SCENE_PT_keying_sets(SceneButtonsPanel):
class SCENE_PT_keying_sets(SceneButtonsPanel, bpy.types.Panel):
bl_label = "Keying Sets"
def draw(self, context):
layout = self.layout
scene = context.scene
wide_ui = context.region.width > narrowui
row = layout.row()
col = row.column()
@@ -107,7 +99,6 @@ class SCENE_PT_keying_sets(SceneButtonsPanel):
op = subcol.operator("anim.keying_set_export", text="Export to File")
op.filepath = "keyingset.py"
if wide_ui:
col = row.column()
col.label(text="Keyframing Settings:")
col.prop(ks, "insertkey_needed", text="Needed")
@@ -115,10 +106,11 @@ class SCENE_PT_keying_sets(SceneButtonsPanel):
col.prop(ks, "insertkey_xyz_to_rgb", text="XYZ to RGB")
class SCENE_PT_keying_set_paths(SceneButtonsPanel):
class SCENE_PT_keying_set_paths(SceneButtonsPanel, bpy.types.Panel):
bl_label = "Active Keying Set"
def poll(self, context):
@classmethod
def poll(cls, context):
return (context.scene.active_keying_set and context.scene.active_keying_set.absolute)
def draw(self, context):
@@ -126,7 +118,6 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel):
scene = context.scene
ks = scene.active_keying_set
wide_ui = context.region.width > narrowui
row = layout.row()
row.label(text="Paths:")
@@ -156,7 +147,6 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel):
if ksp.entire_array is False:
col.prop(ksp, "array_index")
if wide_ui:
col = row.column()
col.label(text="F-Curve Grouping:")
col.prop(ksp, "grouping")
@@ -169,7 +159,7 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel):
col.prop(ksp, "insertkey_xyz_to_rgb", text="XYZ to RGB")
class SCENE_PT_physics(SceneButtonsPanel):
class SCENE_PT_physics(SceneButtonsPanel, bpy.types.Panel):
bl_label = "Gravity"
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -180,17 +170,13 @@ class SCENE_PT_physics(SceneButtonsPanel):
layout = self.layout
scene = context.scene
wide_ui = context.region.width > narrowui
layout.active = scene.use_gravity
if wide_ui:
layout.prop(scene, "gravity", text="")
else:
layout.column().prop(scene, "gravity", text="")
class SCENE_PT_simplify(SceneButtonsPanel):
class SCENE_PT_simplify(SceneButtonsPanel, bpy.types.Panel):
bl_label = "Simplify"
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -203,7 +189,6 @@ class SCENE_PT_simplify(SceneButtonsPanel):
layout = self.layout
scene = context.scene
rd = scene.render
wide_ui = context.region.width > narrowui
layout.active = rd.use_simplify
@@ -215,7 +200,6 @@ class SCENE_PT_simplify(SceneButtonsPanel):
col.prop(rd, "simplify_triangulate")
if wide_ui:
col = split.column()
col.prop(rd, "simplify_shadow_samples", text="Shadow Samples")
col.prop(rd, "simplify_ao_sss", text="AO and SSS")
@@ -334,29 +318,12 @@ class ANIM_OT_keying_set_export(bpy.types.Operator):
return {'RUNNING_MODAL'}
classes = [
SCENE_PT_scene,
SCENE_PT_unit,
SCENE_PT_keying_sets,
SCENE_PT_keying_set_paths,
SCENE_PT_physics,
SCENE_PT_simplify,
SCENE_PT_custom_props,
ANIM_OT_keying_set_export]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -20,8 +20,6 @@
import bpy
from rna_prop_ui import PropertyPanel
narrowui = bpy.context.user_preferences.view.properties_width_check
class TEXTURE_MT_specials(bpy.types.Menu):
bl_label = "Texture Specials"
@@ -65,20 +63,18 @@ def context_tex_datablock(context):
return idblock
class TextureButtonsPanel(bpy.types.Panel):
class TextureButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "texture"
def poll(self, context):
@classmethod
def poll(cls, context):
tex = context.texture
if not tex:
return False
engine = context.scene.render.engine
return (tex.type != 'NONE' or tex.use_nodes) and (engine in self.COMPAT_ENGINES)
return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.scene.render.engine in cls.COMPAT_ENGINES)
class TEXTURE_PT_preview(TextureButtonsPanel):
class TEXTURE_PT_preview(TextureButtonsPanel, bpy.types.Panel):
bl_label = "Preview"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -95,17 +91,18 @@ class TEXTURE_PT_preview(TextureButtonsPanel):
layout.template_preview(tex, slot=slot)
class TEXTURE_PT_context_texture(TextureButtonsPanel):
class TEXTURE_PT_context_texture(TextureButtonsPanel, bpy.types.Panel):
bl_label = ""
bl_show_header = False
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
if not hasattr(context, "texture_slot"):
return False
return ((context.material or context.world or context.lamp or context.brush or context.texture)
and (engine in self.COMPAT_ENGINES))
and (engine in cls.COMPAT_ENGINES))
def draw(self, context):
layout = self.layout
@@ -113,7 +110,6 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel):
node = context.texture_node
space = context.space_data
tex = context.texture
wide_ui = context.region.width > narrowui
idblock = context_tex_datablock(context)
tex_collection = space.pin_id == None and type(idblock) != bpy.types.Brush and not node
@@ -127,11 +123,8 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel):
col.operator("texture.slot_move", text="", icon='TRIA_DOWN').type = 'DOWN'
col.menu("TEXTURE_MT_specials", icon='DOWNARROW_HLT', text="")
if wide_ui:
split = layout.split(percentage=0.65)
col = split.column()
else:
col = layout.column()
if tex_collection:
col.template_ID(idblock, "active_texture", new="texture.new")
@@ -143,7 +136,6 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel):
if space.pin_id:
col.template_ID(space, "pin_id")
if wide_ui:
col = split.column()
if not space.pin_id:
@@ -159,23 +151,16 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel):
split.prop(slot, "output_node", text="")
else:
if wide_ui:
split.label(text="Type:")
split.prop(tex, "type", text="")
else:
layout.prop(tex, "type", text="")
class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel):
_context_path = "texture"
class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel, bpy.types.Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context): # use alternate poll since NONE texture type is ok
engine = context.scene.render.engine
return context.texture and (engine in self.COMPAT_ENGINES)
_context_path = "texture"
class TEXTURE_PT_colors(TextureButtonsPanel):
class TEXTURE_PT_colors(TextureButtonsPanel, bpy.types.Panel):
bl_label = "Colors"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -184,7 +169,6 @@ class TEXTURE_PT_colors(TextureButtonsPanel):
layout = self.layout
tex = context.texture
wide_ui = context.region.width > narrowui
layout.prop(tex, "use_color_ramp", text="Ramp")
if tex.use_color_ramp:
@@ -199,7 +183,6 @@ class TEXTURE_PT_colors(TextureButtonsPanel):
sub.prop(tex, "factor_green", text="G")
sub.prop(tex, "factor_blue", text="B")
if wide_ui:
col = split.column()
col.label(text="Adjust:")
col.prop(tex, "brightness")
@@ -212,19 +195,21 @@ class TEXTURE_PT_colors(TextureButtonsPanel):
class TextureSlotPanel(TextureButtonsPanel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
if not hasattr(context, "texture_slot"):
return False
engine = context.scene.render.engine
return TextureButtonsPanel.poll(self, context) and (engine in self.COMPAT_ENGINES)
return TextureButtonsPanel.poll(self, context) and (engine in cls.COMPAT_ENGINES)
class TEXTURE_PT_mapping(TextureSlotPanel):
class TEXTURE_PT_mapping(TextureSlotPanel, bpy.types.Panel):
bl_label = "Mapping"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
idblock = context_tex_datablock(context)
if type(idblock) == bpy.types.Brush and not context.sculpt_object:
return False
@@ -233,7 +218,7 @@ class TEXTURE_PT_mapping(TextureSlotPanel):
return False
engine = context.scene.render.engine
return (engine in self.COMPAT_ENGINES)
return (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -242,7 +227,6 @@ class TEXTURE_PT_mapping(TextureSlotPanel):
tex = context.texture_slot
# textype = context.texture
wide_ui = context.region.width > narrowui
if type(idblock) != bpy.types.Brush:
split = layout.split(percentage=0.3)
@@ -294,10 +278,9 @@ class TEXTURE_PT_mapping(TextureSlotPanel):
col.prop(tex, "from_dupli")
elif tex.texture_coordinates == 'OBJECT':
col.prop(tex, "from_original")
elif wide_ui:
else:
col.label()
if wide_ui:
col = split.column()
row = col.row()
row.prop(tex, "x_mapping", text="")
@@ -309,19 +292,17 @@ class TEXTURE_PT_mapping(TextureSlotPanel):
col = split.column()
col.prop(tex, "offset")
if wide_ui:
col = split.column()
else:
col.separator()
col.prop(tex, "size")
class TEXTURE_PT_influence(TextureSlotPanel):
class TEXTURE_PT_influence(TextureSlotPanel, bpy.types.Panel):
bl_label = "Influence"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
idblock = context_tex_datablock(context)
if type(idblock) == bpy.types.Brush:
return False
@@ -330,7 +311,7 @@ class TEXTURE_PT_influence(TextureSlotPanel):
return False
engine = context.scene.render.engine
return (engine in self.COMPAT_ENGINES)
return (engine in cls.COMPAT_ENGINES)
def draw(self, context):
@@ -340,7 +321,6 @@ class TEXTURE_PT_influence(TextureSlotPanel):
# textype = context.texture
tex = context.texture_slot
wide_ui = context.region.width > narrowui
def factor_but(layout, active, toggle, factor, name):
row = layout.row(align=True)
@@ -365,7 +345,6 @@ class TEXTURE_PT_influence(TextureSlotPanel):
factor_but(col, tex.map_colorspec, "map_colorspec", "colorspec_factor", "Color")
factor_but(col, tex.map_hardness, "map_hardness", "hardness_factor", "Hardness")
if wide_ui:
col = split.column()
col.label(text="Shading:")
factor_but(col, tex.map_ambient, "map_ambient", "ambient_factor", "Ambient")
@@ -391,7 +370,6 @@ class TEXTURE_PT_influence(TextureSlotPanel):
factor_but(col, tex.map_scattering, "map_scattering", "scattering_factor", "Scattering")
factor_but(col, tex.map_reflection, "map_reflection", "reflection_factor", "Reflection")
if wide_ui:
col = split.column()
col.label(text=" ")
factor_but(col, tex.map_coloremission, "map_coloremission", "coloremission_factor", "Emission Color")
@@ -404,7 +382,6 @@ class TEXTURE_PT_influence(TextureSlotPanel):
col = split.column()
factor_but(col, tex.map_color, "map_color", "color_factor", "Color")
if wide_ui:
col = split.column()
factor_but(col, tex.map_shadow, "map_shadow", "shadow_factor", "Shadow")
@@ -415,7 +392,6 @@ class TEXTURE_PT_influence(TextureSlotPanel):
factor_but(col, tex.map_blend, "map_blend", "blend_factor", "Blend")
factor_but(col, tex.map_horizon, "map_horizon", "horizon_factor", "Horizon")
if wide_ui:
col = split.column()
factor_but(col, tex.map_zenith_up, "map_zenith_up", "zenith_up_factor", "Zenith Up")
factor_but(col, tex.map_zenith_down, "map_zenith_down", "zenith_down_factor", "Zenith Down")
@@ -431,7 +407,6 @@ class TEXTURE_PT_influence(TextureSlotPanel):
sub.active = tex.rgb_to_intensity
sub.prop(tex, "color", text="")
if wide_ui:
col = split.column()
col.prop(tex, "negate", text="Negative")
col.prop(tex, "stencil")
@@ -443,15 +418,15 @@ class TEXTURE_PT_influence(TextureSlotPanel):
class TextureTypePanel(TextureButtonsPanel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
tex = context.texture
engine = context.scene.render.engine
return ((tex and tex.type == self.tex_type and not tex.use_nodes) and (engine in self.COMPAT_ENGINES))
return tex and ((tex.type == cls.tex_type and not tex.use_nodes) and (engine in cls.COMPAT_ENGINES))
class TEXTURE_PT_clouds(TextureTypePanel):
class TEXTURE_PT_clouds(TextureTypePanel, bpy.types.Panel):
bl_label = "Clouds"
tex_type = 'CLOUDS'
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -460,15 +435,11 @@ class TEXTURE_PT_clouds(TextureTypePanel):
layout = self.layout
tex = context.texture
wide_ui = context.region.width > narrowui
layout.prop(tex, "stype", expand=True)
layout.label(text="Noise:")
layout.prop(tex, "noise_type", text="Type", expand=True)
if wide_ui:
layout.prop(tex, "noise_basis", text="Basis")
else:
layout.prop(tex, "noise_basis", text="")
split = layout.split()
@@ -476,12 +447,11 @@ class TEXTURE_PT_clouds(TextureTypePanel):
col.prop(tex, "noise_size", text="Size")
col.prop(tex, "noise_depth", text="Depth")
if wide_ui:
col = split.column()
col.prop(tex, "nabla", text="Nabla")
class TEXTURE_PT_wood(TextureTypePanel):
class TEXTURE_PT_wood(TextureTypePanel, bpy.types.Panel):
bl_label = "Wood"
tex_type = 'WOOD'
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -490,22 +460,15 @@ class TEXTURE_PT_wood(TextureTypePanel):
layout = self.layout
tex = context.texture
wide_ui = context.region.width > narrowui
layout.prop(tex, "noisebasis2", expand=True)
if wide_ui:
layout.prop(tex, "stype", expand=True)
else:
layout.prop(tex, "stype", text="")
col = layout.column()
col.active = tex.stype in ('RINGNOISE', 'BANDNOISE')
col.label(text="Noise:")
col.row().prop(tex, "noise_type", text="Type", expand=True)
if wide_ui:
layout.prop(tex, "noise_basis", text="Basis")
else:
layout.prop(tex, "noise_basis", text="")
split = layout.split()
split.active = tex.stype in ('RINGNOISE', 'BANDNOISE')
@@ -518,7 +481,7 @@ class TEXTURE_PT_wood(TextureTypePanel):
col.prop(tex, "nabla")
class TEXTURE_PT_marble(TextureTypePanel):
class TEXTURE_PT_marble(TextureTypePanel, bpy.types.Panel):
bl_label = "Marble"
tex_type = 'MARBLE'
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -527,16 +490,12 @@ class TEXTURE_PT_marble(TextureTypePanel):
layout = self.layout
tex = context.texture
wide_ui = context.region.width > narrowui
layout.prop(tex, "stype", expand=True)
layout.prop(tex, "noisebasis2", expand=True)
layout.label(text="Noise:")
layout.prop(tex, "noise_type", text="Type", expand=True)
if wide_ui:
layout.prop(tex, "noise_basis", text="Basis")
else:
layout.prop(tex, "noise_basis", text="")
split = layout.split()
@@ -544,13 +503,12 @@ class TEXTURE_PT_marble(TextureTypePanel):
col.prop(tex, "noise_size", text="Size")
col.prop(tex, "noise_depth", text="Depth")
if wide_ui:
col = split.column()
col.prop(tex, "turbulence")
col.prop(tex, "nabla")
class TEXTURE_PT_magic(TextureTypePanel):
class TEXTURE_PT_magic(TextureTypePanel, bpy.types.Panel):
bl_label = "Magic"
tex_type = 'MAGIC'
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -559,19 +517,17 @@ class TEXTURE_PT_magic(TextureTypePanel):
layout = self.layout
tex = context.texture
wide_ui = context.region.width > narrowui
split = layout.split()
col = split.column()
col.prop(tex, "noise_depth", text="Depth")
if wide_ui:
col = split.column()
col.prop(tex, "turbulence")
class TEXTURE_PT_blend(TextureTypePanel):
class TEXTURE_PT_blend(TextureTypePanel, bpy.types.Panel):
bl_label = "Blend"
tex_type = 'BLEND'
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -580,12 +536,8 @@ class TEXTURE_PT_blend(TextureTypePanel):
layout = self.layout
tex = context.texture
wide_ui = context.region.width > narrowui
if wide_ui:
layout.prop(tex, "progression")
else:
layout.prop(tex, "progression", text="")
sub = layout.row()
@@ -593,7 +545,7 @@ class TEXTURE_PT_blend(TextureTypePanel):
sub.prop(tex, "flip_axis", expand=True)
class TEXTURE_PT_stucci(TextureTypePanel):
class TEXTURE_PT_stucci(TextureTypePanel, bpy.types.Panel):
bl_label = "Stucci"
tex_type = 'STUCCI'
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -602,27 +554,22 @@ class TEXTURE_PT_stucci(TextureTypePanel):
layout = self.layout
tex = context.texture
wide_ui = context.region.width > narrowui
layout.prop(tex, "stype", expand=True)
layout.label(text="Noise:")
layout.prop(tex, "noise_type", text="Type", expand=True)
if wide_ui:
layout.prop(tex, "noise_basis", text="Basis")
else:
layout.prop(tex, "noise_basis", text="")
split = layout.split()
col = split.column()
col.prop(tex, "noise_size", text="Size")
if wide_ui:
col = split.column()
col.prop(tex, "turbulence")
class TEXTURE_PT_image(TextureTypePanel):
class TEXTURE_PT_image(TextureTypePanel, bpy.types.Panel):
bl_label = "Image"
tex_type = 'IMAGE'
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -648,7 +595,7 @@ def texture_filter_common(tex, layout):
layout.prop(tex, "filter_size_minimum")
class TEXTURE_PT_image_sampling(TextureTypePanel):
class TEXTURE_PT_image_sampling(TextureTypePanel, bpy.types.Panel):
bl_label = "Image Sampling"
bl_default_closed = True
tex_type = 'IMAGE'
@@ -659,7 +606,6 @@ class TEXTURE_PT_image_sampling(TextureTypePanel):
tex = context.texture
# slot = context.texture_slot
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -671,10 +617,8 @@ class TEXTURE_PT_image_sampling(TextureTypePanel):
col.separator()
col.prop(tex, "flip_axis", text="Flip X/Y Axis")
if wide_ui:
col = split.column()
else:
col.separator()
col.prop(tex, "normal_map")
row = col.row()
row.active = tex.normal_map
@@ -689,7 +633,7 @@ class TEXTURE_PT_image_sampling(TextureTypePanel):
texture_filter_common(tex, col)
class TEXTURE_PT_image_mapping(TextureTypePanel):
class TEXTURE_PT_image_mapping(TextureTypePanel, bpy.types.Panel):
bl_label = "Image Mapping"
bl_default_closed = True
tex_type = 'IMAGE'
@@ -699,12 +643,8 @@ class TEXTURE_PT_image_mapping(TextureTypePanel):
layout = self.layout
tex = context.texture
wide_ui = context.region.width > narrowui
if wide_ui:
layout.prop(tex, "extension")
else:
layout.prop(tex, "extension", text="")
split = layout.split()
@@ -714,7 +654,6 @@ class TEXTURE_PT_image_mapping(TextureTypePanel):
col.prop(tex, "repeat_x", text="X")
col.prop(tex, "repeat_y", text="Y")
if wide_ui:
col = split.column(align=True)
col.label(text="Mirror:")
col.prop(tex, "mirror_x", text="X")
@@ -727,7 +666,6 @@ class TEXTURE_PT_image_mapping(TextureTypePanel):
row.prop(tex, "checker_even", text="Even")
row.prop(tex, "checker_odd", text="Odd")
if wide_ui:
col = split.column()
col.prop(tex, "checker_distance", text="Distance")
@@ -741,14 +679,13 @@ class TEXTURE_PT_image_mapping(TextureTypePanel):
col.prop(tex, "crop_min_x", text="X")
col.prop(tex, "crop_min_y", text="Y")
if wide_ui:
col = split.column(align=True)
col.label(text="Crop Maximum:")
col.prop(tex, "crop_max_x", text="X")
col.prop(tex, "crop_max_y", text="Y")
class TEXTURE_PT_plugin(TextureTypePanel):
class TEXTURE_PT_plugin(TextureTypePanel, bpy.types.Panel):
bl_label = "Plugin"
tex_type = 'PLUGIN'
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -761,7 +698,7 @@ class TEXTURE_PT_plugin(TextureTypePanel):
layout.label(text="Nothing yet")
class TEXTURE_PT_envmap(TextureTypePanel):
class TEXTURE_PT_envmap(TextureTypePanel, bpy.types.Panel):
bl_label = "Environment Map"
tex_type = 'ENVIRONMENT_MAP'
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -772,7 +709,6 @@ class TEXTURE_PT_envmap(TextureTypePanel):
tex = context.texture
env = tex.environment_map
wide_ui = context.region.width > narrowui
row = layout.row()
row.prop(env, "source", expand=True)
@@ -794,7 +730,6 @@ class TEXTURE_PT_envmap(TextureTypePanel):
col.prop(env, "resolution")
col.prop(env, "depth")
if wide_ui:
col = split.column(align=True)
col.label(text="Clipping:")
@@ -802,7 +737,7 @@ class TEXTURE_PT_envmap(TextureTypePanel):
col.prop(env, "clip_end", text="End")
class TEXTURE_PT_envmap_sampling(TextureTypePanel):
class TEXTURE_PT_envmap_sampling(TextureTypePanel, bpy.types.Panel):
bl_label = "Environment Map Sampling"
bl_default_closed = True
tex_type = 'ENVIRONMENT_MAP'
@@ -816,7 +751,7 @@ class TEXTURE_PT_envmap_sampling(TextureTypePanel):
texture_filter_common(tex, layout)
class TEXTURE_PT_musgrave(TextureTypePanel):
class TEXTURE_PT_musgrave(TextureTypePanel, bpy.types.Panel):
bl_label = "Musgrave"
tex_type = 'MUSGRAVE'
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -825,12 +760,8 @@ class TEXTURE_PT_musgrave(TextureTypePanel):
layout = self.layout
tex = context.texture
wide_ui = context.region.width > narrowui
if wide_ui:
layout.prop(tex, "musgrave_type")
else:
layout.prop(tex, "musgrave_type", text="")
split = layout.split()
@@ -839,7 +770,6 @@ class TEXTURE_PT_musgrave(TextureTypePanel):
col.prop(tex, "lacunarity")
col.prop(tex, "octaves")
if wide_ui:
col = split.column()
if (tex.musgrave_type in ('HETERO_TERRAIN', 'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')):
col.prop(tex, "offset")
@@ -849,22 +779,18 @@ class TEXTURE_PT_musgrave(TextureTypePanel):
layout.label(text="Noise:")
if wide_ui:
layout.prop(tex, "noise_basis", text="Basis")
else:
layout.prop(tex, "noise_basis", text="")
split = layout.split()
col = split.column()
col.prop(tex, "noise_size", text="Size")
if wide_ui:
col = split.column()
col.prop(tex, "nabla")
class TEXTURE_PT_voronoi(TextureTypePanel):
class TEXTURE_PT_voronoi(TextureTypePanel, bpy.types.Panel):
bl_label = "Voronoi"
tex_type = 'VORONOI'
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -873,7 +799,6 @@ class TEXTURE_PT_voronoi(TextureTypePanel):
layout = self.layout
tex = context.texture
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -887,7 +812,6 @@ class TEXTURE_PT_voronoi(TextureTypePanel):
col.prop(tex, "coloring", text="")
col.prop(tex, "noise_intensity", text="Intensity")
if wide_ui:
col = split.column()
sub = col.column(align=True)
sub.label(text="Feature Weights:")
@@ -903,12 +827,11 @@ class TEXTURE_PT_voronoi(TextureTypePanel):
col = split.column()
col.prop(tex, "noise_size", text="Size")
if wide_ui:
col = split.column()
col.prop(tex, "nabla")
class TEXTURE_PT_distortednoise(TextureTypePanel):
class TEXTURE_PT_distortednoise(TextureTypePanel, bpy.types.Panel):
bl_label = "Distorted Noise"
tex_type = 'DISTORTED_NOISE'
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -917,14 +840,9 @@ class TEXTURE_PT_distortednoise(TextureTypePanel):
layout = self.layout
tex = context.texture
wide_ui = context.region.width > narrowui
if wide_ui:
layout.prop(tex, "noise_distortion")
layout.prop(tex, "noise_basis", text="Basis")
else:
layout.prop(tex, "noise_distortion", text="")
layout.prop(tex, "noise_basis", text="")
split = layout.split()
@@ -932,19 +850,19 @@ class TEXTURE_PT_distortednoise(TextureTypePanel):
col.prop(tex, "distortion", text="Distortion")
col.prop(tex, "noise_size", text="Size")
if wide_ui:
col = split.column()
col.prop(tex, "nabla")
class TEXTURE_PT_voxeldata(TextureButtonsPanel):
class TEXTURE_PT_voxeldata(TextureButtonsPanel, bpy.types.Panel):
bl_label = "Voxel Data"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
tex = context.texture
engine = context.scene.render.engine
return (tex and tex.type == 'VOXEL_DATA' and (engine in self.COMPAT_ENGINES))
return tex and (tex.type == 'VOXEL_DATA' and (engine in cls.COMPAT_ENGINES))
def draw(self, context):
layout = self.layout
@@ -975,26 +893,23 @@ class TEXTURE_PT_voxeldata(TextureButtonsPanel):
layout.prop(vd, "intensity")
class TEXTURE_PT_pointdensity(TextureButtonsPanel):
class TEXTURE_PT_pointdensity(TextureButtonsPanel, bpy.types.Panel):
bl_label = "Point Density"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
tex = context.texture
engine = context.scene.render.engine
return (tex and tex.type == 'POINT_DENSITY' and (engine in self.COMPAT_ENGINES))
return tex and (tex.type == 'POINT_DENSITY' and (engine in cls.COMPAT_ENGINES))
def draw(self, context):
layout = self.layout
tex = context.texture
pd = tex.pointdensity
wide_ui = context.region.width > narrowui
if wide_ui:
layout.prop(pd, "point_source", expand=True)
else:
layout.prop(pd, "point_source", text="")
split = layout.split()
@@ -1025,7 +940,6 @@ class TEXTURE_PT_pointdensity(TextureButtonsPanel):
if pd.color_source in ('PARTICLE_SPEED', 'PARTICLE_AGE'):
layout.template_color_ramp(pd, "color_ramp", expand=True)
if wide_ui:
col = split.column()
col.label()
col.prop(pd, "radius")
@@ -1035,14 +949,15 @@ class TEXTURE_PT_pointdensity(TextureButtonsPanel):
col.prop(pd, "falloff_softness")
class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel):
class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel, bpy.types.Panel):
bl_label = "Turbulence"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def poll(self, context):
@classmethod
def poll(cls, context):
tex = context.texture
engine = context.scene.render.engine
return (tex and tex.type == 'POINT_DENSITY' and (engine in self.COMPAT_ENGINES))
return tex and (tex.type == 'POINT_DENSITY' and (engine in cls.COMPAT_ENGINES))
def draw_header(self, context):
layout = self.layout
@@ -1058,7 +973,6 @@ class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel):
tex = context.texture
pd = tex.pointdensity
layout.active = pd.turbulence
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -1068,7 +982,6 @@ class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel):
col.label(text="Noise Basis:")
col.prop(pd, "noise_basis", text="")
if wide_ui:
col = split.column()
col.label()
col.prop(pd, "turbulence_size")
@@ -1076,49 +989,12 @@ class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel):
col.prop(pd, "turbulence_strength")
classes = [
TEXTURE_MT_specials,
TEXTURE_MT_envmap_specials,
TEXTURE_PT_context_texture,
TEXTURE_PT_preview,
TEXTURE_PT_clouds, # Texture Type Panels
TEXTURE_PT_wood,
TEXTURE_PT_marble,
TEXTURE_PT_magic,
TEXTURE_PT_blend,
TEXTURE_PT_stucci,
TEXTURE_PT_image,
TEXTURE_PT_image_sampling,
TEXTURE_PT_image_mapping,
TEXTURE_PT_plugin,
TEXTURE_PT_envmap,
TEXTURE_PT_envmap_sampling,
TEXTURE_PT_musgrave,
TEXTURE_PT_voronoi,
TEXTURE_PT_distortednoise,
TEXTURE_PT_voxeldata,
TEXTURE_PT_pointdensity,
TEXTURE_PT_pointdensity_turbulence,
TEXTURE_PT_colors,
TEXTURE_PT_mapping,
TEXTURE_PT_influence,
TEXTURE_PT_custom_props]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -20,36 +20,41 @@
import bpy
from rna_prop_ui import PropertyPanel
narrowui = bpy.context.user_preferences.view.properties_width_check
class WorldButtonsPanel(bpy.types.Panel):
class WorldButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "world"
# COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
def poll(self, context):
@classmethod
def poll(cls, context):
rd = context.scene.render
return (context.world) and (not rd.use_game_engine) and (rd.engine in self.COMPAT_ENGINES)
return (rd.engine in cls.COMPAT_ENGINES)
class WORLD_PT_preview(WorldButtonsPanel):
class WORLD_PT_preview(WorldButtonsPanel, bpy.types.Panel):
bl_label = "Preview"
COMPAT_ENGINES = {'BLENDER_RENDER'}
@classmethod
def poll(cls, context):
rd = context.scene.render
return (context.world) and (not rd.use_game_engine) and (rd.engine in cls.COMPAT_ENGINES)
def draw(self, context):
self.layout.template_preview(context.world)
class WORLD_PT_context_world(WorldButtonsPanel):
class WORLD_PT_context_world(WorldButtonsPanel, bpy.types.Panel):
bl_label = ""
bl_show_header = False
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
rd = context.scene.render
return (not rd.use_game_engine) and (rd.engine in self.COMPAT_ENGINES)
return (not rd.use_game_engine) and (rd.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -57,43 +62,31 @@ class WORLD_PT_context_world(WorldButtonsPanel):
scene = context.scene
world = context.world
space = context.space_data
wide_ui = context.region.width > narrowui
if wide_ui:
split = layout.split(percentage=0.65)
if scene:
split.template_ID(scene, "world", new="world.new")
elif world:
split.template_ID(space, "pin_id")
else:
layout.template_ID(scene, "world", new="world.new")
class WORLD_PT_custom_props(WorldButtonsPanel, PropertyPanel):
COMPAT_ENGINES = {'BLENDER_RENDER'}
class WORLD_PT_custom_props(WorldButtonsPanel, PropertyPanel, bpy.types.Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
_context_path = "world"
class WORLD_PT_world(WorldButtonsPanel):
class WORLD_PT_world(WorldButtonsPanel, bpy.types.Panel):
bl_label = "World"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def draw(self, context):
layout = self.layout
wide_ui = context.region.width > narrowui
world = context.world
if wide_ui:
row = layout.row()
row.prop(world, "paper_sky")
row.prop(world, "blend_sky")
row.prop(world, "real_sky")
else:
col = layout.column()
col.prop(world, "paper_sky")
col.prop(world, "blend_sky")
col.prop(world, "real_sky")
row = layout.row()
row.column().prop(world, "horizon_color")
@@ -103,7 +96,7 @@ class WORLD_PT_world(WorldButtonsPanel):
row.column().prop(world, "ambient_color")
class WORLD_PT_mist(WorldButtonsPanel):
class WORLD_PT_mist(WorldButtonsPanel, bpy.types.Panel):
bl_label = "Mist"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -115,7 +108,6 @@ class WORLD_PT_mist(WorldButtonsPanel):
def draw(self, context):
layout = self.layout
wide_ui = context.region.width > narrowui
world = context.world
layout.active = world.mist.use_mist
@@ -126,7 +118,6 @@ class WORLD_PT_mist(WorldButtonsPanel):
col.prop(world.mist, "intensity", slider=True)
col.prop(world.mist, "start")
if wide_ui:
col = split.column()
col.prop(world.mist, "depth")
col.prop(world.mist, "height")
@@ -134,7 +125,7 @@ class WORLD_PT_mist(WorldButtonsPanel):
layout.prop(world.mist, "falloff")
class WORLD_PT_stars(WorldButtonsPanel):
class WORLD_PT_stars(WorldButtonsPanel, bpy.types.Panel):
bl_label = "Stars"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -146,7 +137,6 @@ class WORLD_PT_stars(WorldButtonsPanel):
def draw(self, context):
layout = self.layout
wide_ui = context.region.width > narrowui
world = context.world
layout.active = world.stars.use_stars
@@ -157,13 +147,12 @@ class WORLD_PT_stars(WorldButtonsPanel):
col.prop(world.stars, "size")
col.prop(world.stars, "color_randomization", text="Colors")
if wide_ui:
col = split.column()
col.prop(world.stars, "min_distance", text="Min. Dist")
col.prop(world.stars, "average_separation", text="Separation")
class WORLD_PT_ambient_occlusion(WorldButtonsPanel):
class WORLD_PT_ambient_occlusion(WorldButtonsPanel, bpy.types.Panel):
bl_label = "Ambient Occlusion"
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -182,7 +171,7 @@ class WORLD_PT_ambient_occlusion(WorldButtonsPanel):
split.prop(light, "ao_blend_mode", text="")
class WORLD_PT_environment_lighting(WorldButtonsPanel):
class WORLD_PT_environment_lighting(WorldButtonsPanel, bpy.types.Panel):
bl_label = "Environment Lighting"
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -201,11 +190,12 @@ class WORLD_PT_environment_lighting(WorldButtonsPanel):
split.prop(light, "environment_color", text="")
class WORLD_PT_indirect_lighting(WorldButtonsPanel):
class WORLD_PT_indirect_lighting(WorldButtonsPanel, bpy.types.Panel):
bl_label = "Indirect Lighting"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def poll(self, context):
@classmethod
def poll(cls, context):
light = context.world.lighting
return light.gather_method == 'APPROXIMATE'
@@ -224,7 +214,7 @@ class WORLD_PT_indirect_lighting(WorldButtonsPanel):
split.prop(light, "indirect_bounces", text="Bounces")
class WORLD_PT_gather(WorldButtonsPanel):
class WORLD_PT_gather(WorldButtonsPanel, bpy.types.Panel):
bl_label = "Gather"
COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -272,30 +262,12 @@ class WORLD_PT_gather(WorldButtonsPanel):
col.prop(light, "correction")
classes = [
WORLD_PT_context_world,
WORLD_PT_preview,
WORLD_PT_world,
WORLD_PT_ambient_occlusion,
WORLD_PT_environment_lighting,
WORLD_PT_indirect_lighting,
WORLD_PT_gather,
WORLD_PT_mist,
WORLD_PT_stars,
WORLD_PT_custom_props]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -138,7 +138,8 @@ class ConsoleAutocomplete(bpy.types.Operator):
bl_idname = "console.autocomplete"
bl_label = "Console Autocomplete"
def poll(self, context):
@classmethod
def poll(cls, context):
return context.space_data.console_type != 'REPORT'
def execute(self, context):
@@ -196,31 +197,12 @@ class ConsoleLanguage(bpy.types.Operator):
return {'FINISHED'}
classes = [
CONSOLE_HT_header,
CONSOLE_MT_console,
CONSOLE_MT_report,
CONSOLE_MT_language,
# Stubs that call the language operators
ConsoleExec,
ConsoleAutocomplete,
ConsoleBanner,
# Set the language and call the banner
ConsoleLanguage]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -196,25 +196,12 @@ class DOPESHEET_MT_key_transform(bpy.types.Menu):
layout.operator("transform.transform", text="Scale").mode = 'TIME_SCALE'
classes = [
DOPESHEET_HT_header, # header/menu classes
DOPESHEET_MT_view,
DOPESHEET_MT_select,
DOPESHEET_MT_channel,
DOPESHEET_MT_key,
DOPESHEET_MT_key_transform]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -65,20 +65,12 @@ class FILEBROWSER_HT_header(bpy.types.Header):
row.prop(params, "filter_text", text="")
classes = [
FILEBROWSER_HT_header]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -204,25 +204,12 @@ class GRAPH_MT_key_transform(bpy.types.Menu):
layout.operator("transform.resize", text="Scale")
classes = [
GRAPH_HT_header, # header/menu classes
GRAPH_MT_view,
GRAPH_MT_select,
GRAPH_MT_channel,
GRAPH_MT_key,
GRAPH_MT_key_transform]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -19,7 +19,16 @@
# <pep8 compliant>
import bpy
narrowui = bpy.context.user_preferences.view.properties_width_check
class BrushButtonsPanel():
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
@classmethod
def poll(cls, context):
sima = context.space_data
toolsettings = context.tool_settings.image_paint
return sima.show_paint and toolsettings.brush
class IMAGE_MT_view(bpy.types.Menu):
@@ -335,7 +344,8 @@ class IMAGE_PT_image_properties(bpy.types.Panel):
bl_region_type = 'UI'
bl_label = "Image"
def poll(self, context):
@classmethod
def poll(cls, context):
sima = context.space_data
return (sima.image)
@@ -354,7 +364,8 @@ class IMAGE_PT_game_properties(bpy.types.Panel):
bl_region_type = 'UI'
bl_label = "Game Properties"
def poll(self, context):
@classmethod
def poll(cls, context):
rd = context.scene.render
sima = context.space_data
return (sima and sima.image) and (rd.engine == 'BLENDER_GAME')
@@ -364,7 +375,6 @@ class IMAGE_PT_game_properties(bpy.types.Panel):
sima = context.space_data
ima = sima.image
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -385,7 +395,6 @@ class IMAGE_PT_game_properties(bpy.types.Panel):
sub.prop(ima, "tiles_x", text="X")
sub.prop(ima, "tiles_y", text="Y")
if wide_ui:
col = split.column()
col.label(text="Clamp:")
col.prop(ima, "clamp_x", text="X")
@@ -399,7 +408,8 @@ class IMAGE_PT_view_histogram(bpy.types.Panel):
bl_region_type = 'PREVIEW'
bl_label = "Histogram"
def poll(self, context):
@classmethod
def poll(cls, context):
sima = context.space_data
return (sima and sima.image)
@@ -417,7 +427,8 @@ class IMAGE_PT_view_waveform(bpy.types.Panel):
bl_region_type = 'PREVIEW'
bl_label = "Waveform"
def poll(self, context):
@classmethod
def poll(cls, context):
sima = context.space_data
return (sima and sima.image)
@@ -436,7 +447,8 @@ class IMAGE_PT_view_vectorscope(bpy.types.Panel):
bl_region_type = 'PREVIEW'
bl_label = "Vectorscope"
def poll(self, context):
@classmethod
def poll(cls, context):
sima = context.space_data
return (sima and sima.image)
@@ -453,7 +465,8 @@ class IMAGE_PT_sample_line(bpy.types.Panel):
bl_region_type = 'PREVIEW'
bl_label = "Sample Line"
def poll(self, context):
@classmethod
def poll(cls, context):
sima = context.space_data
return (sima and sima.image)
@@ -470,7 +483,8 @@ class IMAGE_PT_scope_sample(bpy.types.Panel):
bl_region_type = 'PREVIEW'
bl_label = "Scope Samples"
def poll(self, context):
@classmethod
def poll(cls, context):
sima = context.space_data
return sima
@@ -490,7 +504,8 @@ class IMAGE_PT_view_properties(bpy.types.Panel):
bl_region_type = 'UI'
bl_label = "Display"
def poll(self, context):
@classmethod
def poll(cls, context):
sima = context.space_data
return (sima and (sima.image or sima.show_uvedit))
@@ -501,7 +516,6 @@ class IMAGE_PT_view_properties(bpy.types.Panel):
ima = sima.image
show_uvedit = sima.show_uvedit
uvedit = sima.uv_editor
wide_ui = context.region.width > narrowui
split = layout.split()
@@ -509,7 +523,6 @@ class IMAGE_PT_view_properties(bpy.types.Panel):
if ima:
col.prop(ima, "display_aspect", text="Aspect Ratio")
if wide_ui:
col = split.column()
col.label(text="Coordinates:")
col.prop(sima, "draw_repeated", text="Repeat")
@@ -528,10 +541,7 @@ class IMAGE_PT_view_properties(bpy.types.Panel):
col = layout.column()
col.label(text="UVs:")
row = col.row()
if wide_ui:
row.prop(uvedit, "edge_draw_type", expand=True)
else:
row.prop(uvedit, "edge_draw_type", text="")
split = layout.split()
col = split.column()
@@ -540,7 +550,6 @@ class IMAGE_PT_view_properties(bpy.types.Panel):
#col.prop(uvedit, "draw_edges")
#col.prop(uvedit, "draw_faces")
if wide_ui:
col = split.column()
col.prop(uvedit, "draw_stretch", text="Stretch")
sub = col.column()
@@ -553,7 +562,8 @@ class IMAGE_PT_paint(bpy.types.Panel):
bl_region_type = 'UI'
bl_label = "Paint"
def poll(self, context):
@classmethod
def poll(cls, context):
sima = context.space_data
return sima.show_paint
@@ -592,17 +602,10 @@ class IMAGE_PT_paint(bpy.types.Panel):
col.prop(brush, "clone_alpha", text="Alpha")
class IMAGE_PT_tools_brush_texture(bpy.types.Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, bpy.types.Panel):
bl_label = "Texture"
bl_default_closed = True
def poll(self, context):
sima = context.space_data
toolsettings = context.tool_settings.image_paint
return sima.show_paint and toolsettings.brush
def draw(self, context):
layout = self.layout
@@ -616,17 +619,10 @@ class IMAGE_PT_tools_brush_texture(bpy.types.Panel):
col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
class IMAGE_PT_paint_stroke(bpy.types.Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
class IMAGE_PT_paint_stroke(BrushButtonsPanel, bpy.types.Panel):
bl_label = "Paint Stroke"
bl_default_closed = True
def poll(self, context):
sima = context.space_data
toolsettings = context.tool_settings.image_paint
return sima.show_paint and toolsettings.brush
def draw(self, context):
layout = self.layout
@@ -647,17 +643,10 @@ class IMAGE_PT_paint_stroke(bpy.types.Panel):
layout.prop(brush, "use_wrap")
class IMAGE_PT_paint_curve(bpy.types.Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
class IMAGE_PT_paint_curve(BrushButtonsPanel, bpy.types.Panel):
bl_label = "Paint Curve"
bl_default_closed = True
def poll(self, context):
sima = context.space_data
toolsettings = context.tool_settings.image_paint
return sima.show_paint and toolsettings.brush
def draw(self, context):
layout = self.layout
@@ -674,41 +663,12 @@ class IMAGE_PT_paint_curve(bpy.types.Panel):
row.operator("brush.curve_preset", icon="LINCURVE", text="").shape = 'LINE'
row.operator("brush.curve_preset", icon="NOCURVE", text="").shape = 'MAX'
classes = [
IMAGE_MT_view,
IMAGE_MT_select,
IMAGE_MT_image,
IMAGE_MT_uvs_showhide,
IMAGE_MT_uvs_transform,
IMAGE_MT_uvs_snap,
IMAGE_MT_uvs_mirror,
IMAGE_MT_uvs_weldalign,
IMAGE_MT_uvs,
IMAGE_HT_header,
IMAGE_PT_image_properties,
IMAGE_PT_paint,
IMAGE_PT_tools_brush_texture,
IMAGE_PT_paint_stroke,
IMAGE_PT_paint_curve,
IMAGE_PT_game_properties,
IMAGE_PT_view_properties,
IMAGE_PT_view_histogram,
IMAGE_PT_view_waveform,
IMAGE_PT_view_vectorscope,
IMAGE_PT_sample_line,
IMAGE_PT_scope_sample]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -354,34 +354,13 @@ class HELP_OT_operator_cheat_sheet(bpy.types.Operator):
return {'FINISHED'}
classes = [
INFO_HT_header,
INFO_MT_file,
INFO_MT_file_import,
INFO_MT_file_export,
INFO_MT_file_external_data,
INFO_MT_add,
INFO_MT_mesh_add,
INFO_MT_curve_add,
INFO_MT_surface_add,
INFO_MT_armature_add,
INFO_MT_game,
INFO_MT_render,
INFO_MT_help,
HELP_OT_operator_cheat_sheet]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -25,7 +25,8 @@ class LOGIC_PT_properties(bpy.types.Panel):
bl_region_type = 'UI'
bl_label = "Properties"
def poll(self, context):
@classmethod
def poll(cls, context):
ob = context.active_object
return ob and ob.game
@@ -88,24 +89,12 @@ class LOGIC_MT_view(bpy.types.Menu):
layout.operator("logic.properties", icon='MENU_PANEL')
classes = [
LOGIC_HT_header,
LOGIC_MT_view,
LOGIC_PT_properties,
LOGIC_MT_logicbricks_add]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -159,25 +159,12 @@ class NLA_MT_edit_transform(bpy.types.Menu):
layout.operator("transform.resize", text="Scale")
classes = [
NLA_HT_header, # header/menu classes
NLA_MT_view,
NLA_MT_select,
NLA_MT_edit,
NLA_MT_add,
NLA_MT_edit_transform]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -160,23 +160,12 @@ class NODE_MT_node(bpy.types.Menu):
layout.operator("node.show_cyclic_dependencies")
classes = [
NODE_HT_header,
NODE_MT_view,
NODE_MT_select,
NODE_MT_node]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -117,23 +117,12 @@ class OUTLINER_MT_edit_datablocks(bpy.types.Menu):
col.operator("outliner.drivers_delete_selected")
classes = [
OUTLINER_HT_header,
OUTLINER_MT_view,
OUTLINER_MT_search,
OUTLINER_MT_edit_datablocks]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -312,29 +312,33 @@ class SEQUENCER_MT_strip(bpy.types.Menu):
layout.operator("sequencer.swap_data")
class SequencerButtonsPanel(bpy.types.Panel):
class SequencerButtonsPanel():
bl_space_type = 'SEQUENCE_EDITOR'
bl_region_type = 'UI'
def has_sequencer(self, context):
@staticmethod
def has_sequencer(context):
return (context.space_data.view_type == 'SEQUENCER') or (context.space_data.view_type == 'SEQUENCER_PREVIEW')
def poll(self, context):
return self.has_sequencer(context) and (act_strip(context) is not None)
@classmethod
def poll(cls, context):
return cls.has_sequencer(context) and (act_strip(context) is not None)
class SequencerButtonsPanel_Output(bpy.types.Panel):
class SequencerButtonsPanel_Output():
bl_space_type = 'SEQUENCE_EDITOR'
bl_region_type = 'UI'
def has_preview(self, context):
@staticmethod
def has_preview(context):
return (context.space_data.view_type == 'PREVIEW') or (context.space_data.view_type == 'SEQUENCER_PREVIEW')
def poll(self, context):
return self.has_preview(context)
@classmethod
def poll(cls, context):
return cls.has_preview(context)
class SEQUENCER_PT_edit(SequencerButtonsPanel):
class SEQUENCER_PT_edit(SequencerButtonsPanel, bpy.types.Panel):
bl_label = "Edit Strip"
def draw(self, context):
@@ -381,11 +385,12 @@ class SEQUENCER_PT_edit(SequencerButtonsPanel):
col.label(text="Frame Still %d:%d" % (strip.frame_still_start, strip.frame_still_end))
class SEQUENCER_PT_effect(SequencerButtonsPanel):
class SEQUENCER_PT_effect(SequencerButtonsPanel, bpy.types.Panel):
bl_label = "Effect Strip"
def poll(self, context):
if not self.has_sequencer(context):
@classmethod
def poll(cls, context):
if not cls.has_sequencer(context):
return False
strip = act_strip(context)
@@ -510,11 +515,12 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel):
col.prop(strip, "rotation_start", text="Rotation")
class SEQUENCER_PT_input(SequencerButtonsPanel):
class SEQUENCER_PT_input(SequencerButtonsPanel, bpy.types.Panel):
bl_label = "Strip Input"
def poll(self, context):
if not self.has_sequencer(context):
@classmethod
def poll(cls, context):
if not cls.has_sequencer(context):
return False
strip = act_strip(context)
@@ -528,15 +534,41 @@ class SEQUENCER_PT_input(SequencerButtonsPanel):
'WIPE', 'GLOW', 'TRANSFORM', 'COLOR',
'MULTICAM', 'SPEED')
def draw_filename(self, context):
pass
def draw(self, context):
layout = self.layout
strip = act_strip(context)
self.draw_filename(context)
seq_type = strip.type
# draw a filename if we have one
if seq_type == 'IMAGE':
split = layout.split(percentage=0.2)
col = split.column()
col.label(text="Path:")
col = split.column()
col.prop(strip, "directory", text="")
# Current element for the filename
elem = strip.getStripElem(context.scene.frame_current)
if elem:
split = layout.split(percentage=0.2)
col = split.column()
col.label(text="File:")
col = split.column()
col.prop(elem, "filename", text="") # strip.elements[0] could be a fallback
elif seq_type == 'MOVIE':
split = layout.split(percentage=0.2)
col = split.column()
col.label(text="Path:")
col = split.column()
col.prop(strip, "filepath", text="")
col.prop(strip, "mpeg_preseek", text="MPEG Preseek")
# TODO, sound???
# end drawing filename
layout.prop(strip, "use_translation", text="Image Offset:")
if strip.use_translation:
@@ -554,93 +586,16 @@ class SEQUENCER_PT_input(SequencerButtonsPanel):
col = layout.column(align=True)
col.label(text="Trim Duration:")
col.prop(strip, "animation_start_offset", text="Start")
col.prop(strip, "animation_end_offset", text="End")
col.prop(strip, "frame_offset_start", text="Start")
col.prop(strip, "frame_offset_end", text="End")
class SEQUENCER_PT_input_movie(SEQUENCER_PT_input):
bl_label = "Strip Input"
def poll(self, context):
if not self.has_sequencer(context):
return False
strip = act_strip(context)
if not strip:
return False
return strip.type == 'MOVIE'
def draw_filename(self, context):
layout = self.layout
strip = act_strip(context)
split = layout.split(percentage=0.2)
col = split.column()
col.label(text="Path:")
col = split.column()
col.prop(strip, "filepath", text="")
col.prop(strip, "mpeg_preseek", text="MPEG Preseek")
class SEQUENCER_PT_input_image(SEQUENCER_PT_input):
bl_label = "Strip Input"
def poll(self, context):
if not self.has_sequencer(context):
return False
strip = act_strip(context)
if not strip:
return False
return strip.type == 'IMAGE'
def draw_filename(self, context):
layout = self.layout
strip = act_strip(context)
split = layout.split(percentage=0.2)
col = split.column()
col.label(text="Path:")
col = split.column()
col.prop(strip, "directory", text="")
# Current element for the filename
elem = strip.getStripElem(context.scene.frame_current)
if elem:
split = layout.split(percentage=0.2)
col = split.column()
col.label(text="File:")
col = split.column()
col.prop(elem, "filename", text="") # strip.elements[0] could be a fallback
class SEQUENCER_PT_input_secondary(SEQUENCER_PT_input):
bl_label = "Strip Input"
def poll(self, context):
if not self.has_sequencer(context):
return False
strip = act_strip(context)
if not strip:
return False
return strip.type in ('SCENE', 'META')
def draw_filename(self, context):
pass
class SEQUENCER_PT_sound(SequencerButtonsPanel):
class SEQUENCER_PT_sound(SequencerButtonsPanel, bpy.types.Panel):
bl_label = "Sound"
def poll(self, context):
if not self.has_sequencer(context):
@classmethod
def poll(cls, context):
if not cls.has_sequencer(context):
return False
strip = act_strip(context)
@@ -676,11 +631,12 @@ class SEQUENCER_PT_sound(SequencerButtonsPanel):
col.prop(strip, "animation_end_offset", text="End")
class SEQUENCER_PT_scene(SequencerButtonsPanel):
class SEQUENCER_PT_scene(SequencerButtonsPanel, bpy.types.Panel):
bl_label = "Scene"
def poll(self, context):
if not self.has_sequencer(context):
@classmethod
def poll(cls, context):
if not cls.has_sequencer(context):
return False
strip = act_strip(context)
@@ -700,11 +656,12 @@ class SEQUENCER_PT_scene(SequencerButtonsPanel):
layout.template_ID(strip, "scene_camera")
class SEQUENCER_PT_filter(SequencerButtonsPanel):
class SEQUENCER_PT_filter(SequencerButtonsPanel, bpy.types.Panel):
bl_label = "Filter"
def poll(self, context):
if not self.has_sequencer(context):
@classmethod
def poll(cls, context):
if not cls.has_sequencer(context):
return False
strip = act_strip(context)
@@ -761,11 +718,12 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel):
col.prop(strip.color_balance, "inverse_gain", text="Inverse")
class SEQUENCER_PT_proxy(SequencerButtonsPanel):
class SEQUENCER_PT_proxy(SequencerButtonsPanel, bpy.types.Panel):
bl_label = "Proxy"
def poll(self, context):
if not self.has_sequencer(context):
@classmethod
def poll(cls, context):
if not cls.has_sequencer(context):
return False
strip = act_strip(context)
@@ -794,7 +752,7 @@ class SEQUENCER_PT_proxy(SequencerButtonsPanel):
flow.prop(strip.proxy, "filepath")
class SEQUENCER_PT_preview(SequencerButtonsPanel_Output):
class SEQUENCER_PT_preview(SequencerButtonsPanel_Output, bpy.types.Panel):
bl_label = "Scene Preview/Render"
bl_space_type = 'SEQUENCE_EDITOR'
bl_region_type = 'UI'
@@ -818,7 +776,7 @@ class SEQUENCER_PT_preview(SequencerButtonsPanel_Output):
'''
class SEQUENCER_PT_view(SequencerButtonsPanel_Output):
class SEQUENCER_PT_view(SequencerButtonsPanel_Output, bpy.types.Panel):
bl_label = "View Settings"
def draw(self, context):
@@ -834,40 +792,12 @@ class SEQUENCER_PT_view(SequencerButtonsPanel_Output):
col.prop(st, "separate_color_preview")
col.prop(st, "proxy_render_size")
classes = [
SEQUENCER_HT_header, # header/menu classes
SEQUENCER_MT_view,
SEQUENCER_MT_view_toggle,
SEQUENCER_MT_select,
SEQUENCER_MT_marker,
SEQUENCER_MT_add,
SEQUENCER_MT_add_effect,
SEQUENCER_MT_strip,
SEQUENCER_PT_edit, # sequencer panels
SEQUENCER_PT_effect,
SEQUENCER_PT_input_movie,
SEQUENCER_PT_input_image,
SEQUENCER_PT_input_secondary,
SEQUENCER_PT_sound,
SEQUENCER_PT_scene,
SEQUENCER_PT_filter,
SEQUENCER_PT_proxy,
SEQUENCER_PT_preview,
SEQUENCER_PT_view] # view panels
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -141,6 +141,11 @@ class TEXT_MT_view(bpy.types.Menu):
layout.operator("screen.area_dupli")
layout.operator("screen.screen_full_area")
layout.separator()
layout.operator("text.move", text="Top of File").type = 'FILE_TOP'
layout.operator("text.move", text="Bottom of File").type = 'FILE_BOTTOM'
class TEXT_MT_text(bpy.types.Menu):
bl_label = "Text"
@@ -188,16 +193,6 @@ class TEXT_MT_templates(bpy.types.Menu):
self.path_menu(bpy.utils.script_paths("templates"), "text.open", {"internal": True})
class TEXT_MT_edit_view(bpy.types.Menu):
bl_label = "View"
def draw(self, context):
layout = self.layout
layout.operator("text.move", text="Top of File").type = 'FILE_TOP'
layout.operator("text.move", text="Bottom of File").type = 'FILE_BOTTOM'
class TEXT_MT_edit_select(bpy.types.Menu):
bl_label = "Select"
@@ -251,7 +246,8 @@ class TEXT_MT_edit_to3d(bpy.types.Menu):
class TEXT_MT_edit(bpy.types.Menu):
bl_label = "Edit"
def poll(self, context):
@classmethod
def poll(cls, context):
return (context.space_data.text)
def draw(self, context):
@@ -268,7 +264,6 @@ class TEXT_MT_edit(bpy.types.Menu):
layout.separator()
layout.menu("TEXT_MT_edit_view")
layout.menu("TEXT_MT_edit_select")
layout.menu("TEXT_MT_edit_markers")
@@ -297,33 +292,12 @@ class TEXT_MT_toolbox(bpy.types.Menu):
layout.operator("text.run_script")
classes = [
TEXT_HT_header,
TEXT_PT_properties,
TEXT_PT_find,
TEXT_MT_view,
TEXT_MT_text,
TEXT_MT_templates,
TEXT_MT_format,
TEXT_MT_edit,
TEXT_MT_edit_view,
TEXT_MT_edit_select,
TEXT_MT_edit_markers,
TEXT_MT_edit_to3d,
TEXT_MT_toolbox]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

View File

@@ -192,25 +192,12 @@ class TIME_MT_autokey(bpy.types.Menu):
layout.prop_enum(tools, "autokey_mode", 'ADD_REPLACE_KEYS')
layout.prop_enum(tools, "autokey_mode", 'REPLACE_KEYS')
classes = [
TIME_HT_header,
TIME_MT_view,
TIME_MT_cache,
TIME_MT_frame,
TIME_MT_autokey,
TIME_MT_playback]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
pass
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
pass
if __name__ == "__main__":
register()

Some files were not shown because too many files have changed in this diff Show More