Merged changes in the trunk up to revision 53729.

Conflicts resolved:
release/datafiles/startup.blend
source/blender/blenloader/intern/readfile.c
This commit is contained in:
2013-01-12 02:02:53 +00:00
237 changed files with 5828 additions and 2836 deletions
+42 -21
View File
@@ -276,6 +276,11 @@ if 'blenderlite' in B.targets:
if k not in B.arguments:
env[k] = v
if 'cudakernels' in B.targets:
env['WITH_BF_CYCLES'] = True
env['WITH_BF_CYCLES_CUDA_BINARIES'] = True
env['WITH_BF_PYTHON'] = False
# Extended OSX_SDK and 3D_CONNEXION_CLIENT_LIBRARY and JAckOSX detection for OSX
if env['OURPLATFORM']=='darwin':
print B.bc.OKGREEN + "Detected Xcode version: -- " + B.bc.ENDC + env['XCODE_CUR_VER'] + " --"
@@ -652,6 +657,7 @@ datafileslist = []
datafilestargetlist = []
dottargetlist = []
scriptinstall = []
cubininstall = []
if env['OURPLATFORM']!='darwin':
dotblenderinstall = []
@@ -745,29 +751,30 @@ if env['OURPLATFORM']!='darwin':
source=['intern/cycles/doc/license/'+s for s in source]
scriptinstall.append(env.Install(dir=dir,source=source))
# cuda binaries
if env['WITH_BF_CYCLES_CUDA_BINARIES']:
dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'lib')
for arch in env['BF_CYCLES_CUDA_BINARIES_ARCH']:
kernel_build_dir = os.path.join(B.root_build_dir, 'intern/cycles/kernel')
cubin_file = os.path.join(kernel_build_dir, "kernel_%s.cubin" % arch)
scriptinstall.append(env.Install(dir=dir,source=cubin_file))
if env['WITH_BF_CYCLES']:
# cuda binaries
if env['WITH_BF_CYCLES_CUDA_BINARIES']:
dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'lib')
for arch in env['BF_CYCLES_CUDA_BINARIES_ARCH']:
kernel_build_dir = os.path.join(B.root_build_dir, 'intern/cycles/kernel')
cubin_file = os.path.join(kernel_build_dir, "kernel_%s.cubin" % arch)
cubininstall.append(env.Install(dir=dir,source=cubin_file))
# osl shaders
if env['WITH_BF_CYCLES_OSL']:
dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'shader')
# osl shaders
if env['WITH_BF_CYCLES_OSL']:
dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'shader')
osl_source_dir = Dir('./intern/cycles/kernel/shaders').srcnode().path
oso_build_dir = os.path.join(B.root_build_dir, 'intern/cycles/kernel/shaders')
osl_source_dir = Dir('./intern/cycles/kernel/shaders').srcnode().path
oso_build_dir = os.path.join(B.root_build_dir, 'intern/cycles/kernel/shaders')
headers='node_color.h node_fresnel.h node_texture.h oslutil.h stdosl.h'.split()
source=['intern/cycles/kernel/shaders/'+s for s in headers]
scriptinstall.append(env.Install(dir=dir,source=source))
headers='node_color.h node_fresnel.h node_texture.h oslutil.h stdosl.h'.split()
source=['intern/cycles/kernel/shaders/'+s for s in headers]
scriptinstall.append(env.Install(dir=dir,source=source))
for f in os.listdir(osl_source_dir):
if f.endswith('.osl'):
oso_file = os.path.join(oso_build_dir, f.replace('.osl', '.oso'))
scriptinstall.append(env.Install(dir=dir,source=oso_file))
for f in os.listdir(osl_source_dir):
if f.endswith('.osl'):
oso_file = os.path.join(oso_build_dir, f.replace('.osl', '.oso'))
scriptinstall.append(env.Install(dir=dir,source=oso_file))
if env['WITH_BF_OCIO']:
colormanagement = os.path.join('release', 'datafiles', 'colormanagement')
@@ -862,9 +869,9 @@ textinstall = env.Install(dir=env['BF_INSTALLDIR'], source=textlist)
if env['OURPLATFORM']=='darwin':
allinstall = [blenderinstall, textinstall]
elif env['OURPLATFORM']=='linux':
allinstall = [blenderinstall, dotblenderinstall, scriptinstall, textinstall, iconinstall]
allinstall = [blenderinstall, dotblenderinstall, scriptinstall, textinstall, iconinstall, cubininstall]
else:
allinstall = [blenderinstall, dotblenderinstall, scriptinstall, textinstall]
allinstall = [blenderinstall, dotblenderinstall, scriptinstall, textinstall, cubininstall]
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
dllsources = []
@@ -994,6 +1001,20 @@ buildslave_alias = env.Alias('buildslave', buildslave_cmd)
Depends(buildslave_cmd, allinstall)
cudakernels_action = env.Action(btools.cudakernels, btools.cudakernels_print)
cudakernels_cmd = env.Command('cudakernels_exec', None, cudakernels_action)
cudakernels_alias = env.Alias('cudakernels', cudakernels_cmd)
cudakernel_dir = os.path.join(os.path.abspath(os.path.normpath(B.root_build_dir)), 'intern/cycles/kernel')
cuda_kernels = []
for x in env['BF_CYCLES_CUDA_BINARIES_ARCH']:
cubin = os.path.join(cudakernel_dir, 'kernel_' + x + '.cubin')
cuda_kernels.append(cubin)
Depends(cudakernels_cmd, cuda_kernels)
Depends(cudakernels_cmd, cubininstall)
Default(B.program_list)
if not env['WITHOUT_BF_INSTALL']:
@@ -0,0 +1,5 @@
BF_BUILDDIR = '../blender-build/linux-glibc211-i686'
BF_INSTALLDIR = '../blender-install/linux-glibc211-i686'
BF_NUMJOBS = 1
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_13', 'sm_20', 'sm_21', 'sm_30']
@@ -0,0 +1,5 @@
BF_BUILDDIR = '../blender-build/linux-glibc211-x86_64'
BF_INSTALLDIR = '../blender-install/linux-glibc211-x86_64'
BF_NUMJOBS = 1
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_13', 'sm_20', 'sm_21', 'sm_30']
@@ -1,6 +1,7 @@
BF_BUILDDIR = '../blender-build/linux-glibc211-i686'
BF_INSTALLDIR = '../blender-install/linux-glibc211-i686'
BF_NUMJOBS = 2
BF_NUMJOBS = 4
WITHOUT_BF_OVERWRITE_INSTALL = True
# Python configuration
BF_PYTHON_VERSION = '3.3'
@@ -109,8 +110,7 @@ BF_JACK_LIB_STATIC = '${BF_ZLIB}/lib/libjack.a'
# Cycles
WITH_BF_CYCLES = True
WITH_BF_CYCLES_CUDA_BINARIES = True
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_13', 'sm_20', 'sm_21', 'sm_30']
WITH_BF_CYCLES_CUDA_BINARIES = False
WITH_BF_OIIO = True
WITH_BF_STATICOIIO = True
@@ -1,6 +1,7 @@
BF_BUILDDIR = '../blender-build/linux-glibc211-x86_64'
BF_INSTALLDIR = '../blender-install/linux-glibc211-x86_64'
BF_NUMJOBS = 2
BF_NUMJOBS = 4
WITHOUT_BF_OVERWRITE_INSTALL = True
# Python configuration
BF_PYTHON_VERSION = '3.3'
@@ -109,8 +110,7 @@ BF_JACK_LIB_STATIC = '${BF_ZLIB}/lib/libjack.a'
# Cycles
WITH_BF_CYCLES = True
WITH_BF_CYCLES_CUDA_BINARIES = True
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_13', 'sm_20', 'sm_21', 'sm_30']
WITH_BF_CYCLES_CUDA_BINARIES = False
WITH_BF_OIIO = True
WITH_BF_STATICOIIO = True
@@ -1,149 +0,0 @@
BF_BUILDDIR = '../blender-build/linux-glibc27-i686'
BF_INSTALLDIR = '../blender-install/linux-glibc27-i686'
BF_NUMJOBS = 2
# Python configuration
BF_PYTHON_VERSION = '3.3'
BF_PYTHON_ABI_FLAGS = 'm'
BF_PYTHON = '/opt/python3'
WITH_BF_STATICPYTHON = True
# OpenCollada configuration
WITH_BF_COLLADA = True
BF_OPENCOLLADA = '/opt/opencollada'
BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include'
BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver buffer ftoa libxml2-static libexpat-static libpcre-static'
BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib /home/sources/staticlibs/lib32'
BF_PCRE_LIB = ''
BF_EXPAT_LIB = ''
# FFMPEG configuration
WITH_BF_FFMPEG = True
WITH_BF_STATICFFMPEG = True
BF_FFMPEG = '/home/sources/staticlibs/ffmpeg'
BF_FFMPEG_LIBPATH = '${BF_FFMPEG}/lib32'
BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libavformat.a ${BF_FFMPEG_LIBPATH}/libswscale.a ' + \
'${BF_FFMPEG_LIBPATH}/libavcodec.a ${BF_FFMPEG_LIBPATH}/libavdevice.a ${BF_FFMPEG_LIBPATH}/libavutil.a ' + \
'${BF_FFMPEG_LIBPATH}/libxvidcore.a ${BF_FFMPEG_LIBPATH}/libx264.a ${BF_FFMPEG_LIBPATH}/libmp3lame.a ' + \
'${BF_FFMPEG_LIBPATH}/libvpx.a ${BF_FFMPEG_LIBPATH}/libvorbis.a ${BF_FFMPEG_LIBPATH}/libogg.a ' + \
'${BF_FFMPEG_LIBPATH}/libvorbisenc.a ${BF_FFMPEG_LIBPATH}/libtheora.a ' + \
'${BF_FFMPEG_LIBPATH}/libschroedinger-1.0.a ${BF_FFMPEG_LIBPATH}/liborc-0.4.a ${BF_FFMPEG_LIBPATH}/libdirac_encoder.a ' + \
'${BF_FFMPEG_LIBPATH}/libfaad.a'
# Don't depend on system's libstdc++
WITH_BF_STATICCXX = True
BF_CXX_LIB_STATIC = '/usr/lib/gcc/i486-linux-gnu/4.3.4/libstdc++.a'
WITH_BF_OPENAL = True
WITH_BF_STATICOPENAL = True
BF_OPENAL_LIB_STATIC = '/opt/openal/lib/libopenal.a'
WITH_BF_GETTEXT_STATIC = True
BF_FREETYPE_LIB_STATIC = True
WITH_BF_OPENEXR = True
WITH_BF_STATICOPENEXR = True
WITH_BF_TIFF = True
WITH_BF_STATICTIFF = True
BF_TIFF_LIB_STATIC = '${BF_TIFF}/lib/libtiff.a'
WITH_BF_JPEG = True
BF_JPEG_LIB = 'libjpeg'
BF_JPEG_LIBPATH = '/home/sources/staticlibs/lib32'
WITH_BF_PNG = True
BF_PNG_LIB = 'libpng'
BF_PNG_LIBPATH = '/home/sources/staticlibs/lib32'
WITH_BF_STATICLIBSAMPLERATE = True
WITH_BF_ZLIB = True
WITH_BF_STATICZLIB = True
BF_ZLIB_LIB_STATIC = '${BF_ZLIB}/lib/libz.a'
WITH_BF_SDL = True
WITH_BF_OGG = True
WITH_BF_OPENMP = True
WITH_BF_GAMEENGINE = True
WITH_BF_BULLET = True
# Blender player (would be enabled in it's own config)
WITH_BF_PLAYER = False
# Use jemalloc memory manager
WITH_BF_JEMALLOC = True
WITH_BF_STATICJEMALLOC = True
BF_JEMALLOC = '/home/sources/staticlibs/jemalloc'
BF_JEMALLOC_LIBPATH = '${BF_JEMALLOC}/lib32'
# Use 3d mouse library
WITH_BF_3DMOUSE = True
WITH_BF_STATIC3DMOUSE = True
BF_3DMOUSE = '/home/sources/staticlibs/spnav'
BF_3DMOUSE_LIBPATH = '${BF_3DMOUSE}/lib32'
# FFT
WITH_BF_FFTW3 = True
WITH_BF_STATICFFTW3 = True
# JACK
WITH_BF_JACK = False
# Cycles
WITH_BF_CYCLES = True
WITH_BF_CYCLES_CUDA_BINARIES = True
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_13', 'sm_20', 'sm_21', 'sm_30']
WITH_BF_OIIO = True
WITH_BF_STATICOIIO = True
BF_OIIO = '/opt/oiio'
BF_OIIO_INC = '${BF_OIIO}/include'
BF_OIIO_LIB_STATIC = '${BF_OIIO_LIBPATH}/libOpenImageIO.a ${BF_OPENEXR}/lib/libIlmImf.a'
BF_OIIO_LIBPATH = '${BF_OIIO}/lib'
WITH_BF_CYCLES_OSL = True
WITH_BF_STATICOSL = False
BF_OSL = '/opt/osl'
BF_OSL_INC = '${BF_OSL}/include'
# note oslexec would passed via program linkflags, which is needed to
# make llvm happy with osl_allocate_closure_component
BF_OSL_LIB = 'oslcomp oslexec oslquery'
BF_OSL_LIBPATH = '${BF_OSL}/lib'
BF_OSL_COMPILER = '${BF_OSL}/bin/oslc'
WITH_BF_LLVM = True
WITH_BF_STATICLLVM = False
BF_LLVM = '/opt/llvm-3.1'
BF_LLVM_LIB = 'LLVMBitReader LLVMJIT LLVMipo LLVMVectorize LLVMBitWriter LLVMX86CodeGen LLVMX86Desc LLVMX86Info LLVMX86AsmPrinter ' + \
'LLVMX86Utils LLVMSelectionDAG LLVMCodeGen LLVMScalarOpts LLVMInstCombine LLVMTransformUtils LLVMipa LLVMAnalysis LLVMExecutionEngine ' + \
'LLVMTarget LLVMMC LLVMCore LLVMSupport'
BF_LLVM_LIBPATH = '${BF_LLVM}/lib'
# Color management
WITH_BF_OCIO = True
WITH_BF_STATICOCIO = True
BF_OCIO = '/opt/ocio'
BF_OCIO_INC = '${BF_OCIO}/include'
BF_OCIO_LIB_STATIC = '${BF_OCIO_LIBPATH}/libOpenColorIO.a ${BF_OCIO_LIBPATH}/libtinyxml.a ${BF_OCIO_LIBPATH}/libyaml-cpp.a'
BF_OCIO_LIBPATH = '${BF_OCIO}/lib'
WITH_BF_BOOST = True
WITH_BF_STATICBOOST = True
BF_BOOST = '/opt/boost'
BF_BOOST_INC = '${BF_BOOST}/include'
BF_BOOST_LIB_STATIC = '${BF_BOOST_LIBPATH}/libboost_filesystem.a ${BF_BOOST_LIBPATH}/libboost_date_time.a ${BF_BOOST_LIBPATH}/libboost_regex.a ${BF_BOOST_LIBPATH}/libboost_locale.a ${BF_BOOST_LIBPATH}/libboost_system.a ${BF_BOOST_LIBPATH}/libboost_thread.a'
BF_BOOST_LIBPATH = '${BF_BOOST}/lib'
# Ocean Simulation
WITH_BF_OCEANSIM = True
# Compilation and optimization
BF_DEBUG = False
REL_CCFLAGS = ['-DNDEBUG', '-DNDEBUG', '-O2'] # C & C++
PLATFORM_LINKFLAGS = ['-L/home/sources/staticlibs/lib32']
BF_PROGRAM_LINKFLAGS = ['-Wl,--whole-archive', '-loslexec', '-Wl,--no-whole-archive', '-Wl,--version-script=source/creator/blender.map']
@@ -1,149 +0,0 @@
BF_BUILDDIR = '../blender-build/linux-glibc27-x86_64'
BF_INSTALLDIR = '../blender-install/linux-glibc27-x86_64'
BF_NUMJOBS = 2
# Python configuration
BF_PYTHON_VERSION = '3.3'
BF_PYTHON_ABI_FLAGS = 'm'
BF_PYTHON = '/opt/python3'
WITH_BF_STATICPYTHON = True
# OpenCollada configuration
WITH_BF_COLLADA = True
BF_OPENCOLLADA = '/opt/opencollada'
BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include'
BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver buffer ftoa libxml2-static libexpat-static libpcre-static'
BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib /home/sources/staticlibs/lib64'
BF_PCRE_LIB = ''
BF_EXPAT_LIB = ''
# FFMPEG configuration
WITH_BF_FFMPEG = True
WITH_BF_STATICFFMPEG = True
BF_FFMPEG = '/home/sources/staticlibs/ffmpeg'
BF_FFMPEG_LIBPATH = '${BF_FFMPEG}/lib64'
BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libavformat.a ${BF_FFMPEG_LIBPATH}/libswscale.a ' + \
'${BF_FFMPEG_LIBPATH}/libavcodec.a ${BF_FFMPEG_LIBPATH}/libavdevice.a ${BF_FFMPEG_LIBPATH}/libavutil.a ' + \
'${BF_FFMPEG_LIBPATH}/libxvidcore.a ${BF_FFMPEG_LIBPATH}/libx264.a ${BF_FFMPEG_LIBPATH}/libmp3lame.a ' + \
'${BF_FFMPEG_LIBPATH}/libvpx.a ${BF_FFMPEG_LIBPATH}/libvorbis.a ${BF_FFMPEG_LIBPATH}/libogg.a ' + \
'${BF_FFMPEG_LIBPATH}/libvorbisenc.a ${BF_FFMPEG_LIBPATH}/libtheora.a ' + \
'${BF_FFMPEG_LIBPATH}/libschroedinger-1.0.a ${BF_FFMPEG_LIBPATH}/liborc-0.4.a ${BF_FFMPEG_LIBPATH}/libdirac_encoder.a ' + \
'${BF_FFMPEG_LIBPATH}/libfaad.a'
# Don't depend on system's libstdc++
WITH_BF_STATICCXX = True
BF_CXX_LIB_STATIC = '/usr/lib/gcc/x86_64-linux-gnu/4.3.4/libstdc++.a'
WITH_BF_OPENAL = True
WITH_BF_STATICOPENAL = True
BF_OPENAL_LIB_STATIC = '/opt/openal/lib/libopenal.a'
WITH_BF_GETTEXT_STATIC = True
BF_FREETYPE_LIB_STATIC = True
WITH_BF_OPENEXR = True
WITH_BF_STATICOPENEXR = True
WITH_BF_TIFF = True
WITH_BF_STATICTIFF = True
BF_TIFF_LIB_STATIC = '${BF_TIFF}/lib/libtiff.a'
WITH_BF_JPEG = True
BF_JPEG_LIB = 'libjpeg'
BF_JPEG_LIBPATH = '/home/sources/staticlibs/lib64'
WITH_BF_PNG = True
BF_PNG_LIB = 'libpng'
BF_PNG_LIBPATH = '/home/sources/staticlibs/lib64'
WITH_BF_STATICLIBSAMPLERATE = True
WITH_BF_ZLIB = True
WITH_BF_STATICZLIB = True
BF_ZLIB_LIB_STATIC = '${BF_ZLIB}/lib/libz.a'
WITH_BF_SDL = True
WITH_BF_OGG = True
WITH_BF_OPENMP = True
WITH_BF_GAMEENGINE = True
WITH_BF_BULLET = True
# Blender player (would be enabled in it's own config)
WITH_BF_PLAYER = False
# Use jemalloc memory manager
WITH_BF_JEMALLOC = True
WITH_BF_STATICJEMALLOC = True
BF_JEMALLOC = '/home/sources/staticlibs/jemalloc'
BF_JEMALLOC_LIBPATH = '${BF_JEMALLOC}/lib64'
# Use 3d mouse library
WITH_BF_3DMOUSE = True
WITH_BF_STATIC3DMOUSE = True
BF_3DMOUSE = '/home/sources/staticlibs/spnav'
BF_3DMOUSE_LIBPATH = '${BF_3DMOUSE}/lib64'
# FFT
WITH_BF_FFTW3 = True
WITH_BF_STATICFFTW3 = True
# JACK
WITH_BF_JACK = False
# Cycles
WITH_BF_CYCLES = True
WITH_BF_CYCLES_CUDA_BINARIES = True
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_13', 'sm_20', 'sm_21', 'sm_30']
WITH_BF_OIIO = True
WITH_BF_STATICOIIO = True
BF_OIIO = '/opt/oiio'
BF_OIIO_INC = '${BF_OIIO}/include'
BF_OIIO_LIB_STATIC = '${BF_OIIO_LIBPATH}/libOpenImageIO.a ${BF_OPENEXR}/lib/libIlmImf.a'
BF_OIIO_LIBPATH = '${BF_OIIO}/lib'
WITH_BF_CYCLES_OSL = True
WITH_BF_STATICOSL = False
BF_OSL = '/opt/osl'
BF_OSL_INC = '${BF_OSL}/include'
# note oslexec would passed via program linkflags, which is needed to
# make llvm happy with osl_allocate_closure_component
BF_OSL_LIB = 'oslcomp oslexec oslquery'
BF_OSL_LIBPATH = '${BF_OSL}/lib'
BF_OSL_COMPILER = '${BF_OSL}/bin/oslc'
WITH_BF_LLVM = True
WITH_BF_STATICLLVM = False
BF_LLVM = '/opt/llvm-3.1'
BF_LLVM_LIB = 'LLVMBitReader LLVMJIT LLVMipo LLVMVectorize LLVMBitWriter LLVMX86CodeGen LLVMX86Desc LLVMX86Info LLVMX86AsmPrinter ' + \
'LLVMX86Utils LLVMSelectionDAG LLVMCodeGen LLVMScalarOpts LLVMInstCombine LLVMTransformUtils LLVMipa LLVMAnalysis LLVMExecutionEngine ' + \
'LLVMTarget LLVMMC LLVMCore LLVMSupport'
BF_LLVM_LIBPATH = '${BF_LLVM}/lib'
# Color management
WITH_BF_OCIO = True
WITH_BF_STATICOCIO = True
BF_OCIO = '/opt/ocio'
BF_OCIO_INC = '${BF_OCIO}/include'
BF_OCIO_LIB_STATIC = '${BF_OCIO_LIBPATH}/libOpenColorIO.a ${BF_OCIO_LIBPATH}/libtinyxml.a ${BF_OCIO_LIBPATH}/libyaml-cpp.a'
BF_OCIO_LIBPATH = '${BF_OCIO}/lib'
WITH_BF_BOOST = True
WITH_BF_STATICBOOST = True
BF_BOOST = '/opt/boost'
BF_BOOST_INC = '${BF_BOOST}/include'
BF_BOOST_LIB_STATIC = '${BF_BOOST_LIBPATH}/libboost_filesystem.a ${BF_BOOST_LIBPATH}/libboost_date_time.a ${BF_BOOST_LIBPATH}/libboost_regex.a ${BF_BOOST_LIBPATH}/libboost_locale.a ${BF_BOOST_LIBPATH}/libboost_system.a ${BF_BOOST_LIBPATH}/libboost_thread.a'
BF_BOOST_LIBPATH = '${BF_BOOST}/lib'
# Ocean Simulation
WITH_BF_OCEANSIM = True
# Compilation and optimization
BF_DEBUG = False
REL_CCFLAGS = ['-DNDEBUG', '-O2', '-msse', '-msse2'] # C & C++
PLATFORM_LINKFLAGS = ['-L/home/sources/staticlibs/lib64']
BF_PROGRAM_LINKFLAGS = ['-Wl,--whole-archive', '-loslexec', '-Wl,--no-whole-archive', '-Wl,--version-script=source/creator/blender.map']
@@ -1,6 +1,6 @@
BF_BUILDDIR = '../blender-build/linux-glibc211-i686'
BF_INSTALLDIR = '../blender-install/linux-glibc211-i686'
BF_NUMJOBS = 2
BF_NUMJOBS = 4
# Python configuration
BF_PYTHON_VERSION = '3.3'
@@ -1,6 +1,6 @@
BF_BUILDDIR = '../blender-build/linux-glibc211-x86_64'
BF_INSTALLDIR = '../blender-install/linux-glibc211-x86_64'
BF_NUMJOBS = 2
BF_NUMJOBS = 4
# Python configuration
BF_PYTHON_VERSION = '3.3'
@@ -1,114 +0,0 @@
BF_BUILDDIR = '../blender-build/linux-glibc27-i686'
BF_INSTALLDIR = '../blender-install/linux-glibc27-i686'
BF_NUMJOBS = 2
# Python configuration
BF_PYTHON_VERSION = '3.3'
BF_PYTHON_ABI_FLAGS = 'm'
BF_PYTHON = '/opt/python3'
WITH_BF_STATICPYTHON = True
# OpenCollada configuration
WITH_BF_COLLADA = False
# FFMPEG configuration
WITH_BF_FFMPEG = True
WITH_BF_STATICFFMPEG = True
BF_FFMPEG = '/home/sources/staticlibs/ffmpeg'
BF_FFMPEG_LIBPATH = '${BF_FFMPEG}/lib32'
BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libavformat.a ${BF_FFMPEG_LIBPATH}/libswscale.a ' + \
'${BF_FFMPEG_LIBPATH}/libavcodec.a ${BF_FFMPEG_LIBPATH}/libavdevice.a ${BF_FFMPEG_LIBPATH}/libavutil.a ' + \
'${BF_FFMPEG_LIBPATH}/libxvidcore.a ${BF_FFMPEG_LIBPATH}/libx264.a ${BF_FFMPEG_LIBPATH}/libmp3lame.a ' + \
'${BF_FFMPEG_LIBPATH}/libvpx.a ${BF_FFMPEG_LIBPATH}/libvorbis.a ${BF_FFMPEG_LIBPATH}/libogg.a ' + \
'${BF_FFMPEG_LIBPATH}/libvorbisenc.a ${BF_FFMPEG_LIBPATH}/libtheora.a ' + \
'${BF_FFMPEG_LIBPATH}/libschroedinger-1.0.a ${BF_FFMPEG_LIBPATH}/liborc-0.4.a ${BF_FFMPEG_LIBPATH}/libdirac_encoder.a ' + \
'${BF_FFMPEG_LIBPATH}/libfaad.a'
# Don't depend on system's libstdc++
WITH_BF_STATICCXX = True
BF_CXX_LIB_STATIC = '/usr/lib/gcc/i486-linux-gnu/4.3.4/libstdc++.a'
WITH_BF_OPENAL = True
WITH_BF_STATICOPENAL = True
BF_OPENAL_LIB_STATIC = '/opt/openal/lib/libopenal.a'
WITH_BF_GETTEXT_STATIC = True
BF_FREETYPE_LIB_STATIC = True
WITH_BF_OPENEXR = False
WITH_BF_STATICOPENEXR = True
WITH_BF_TIFF = False
WITH_BF_STATICTIFF = True
BF_TIFF_LIB_STATIC = '${BF_TIFF}/lib/libtiff.a'
WITH_BF_JPEG = True
BF_JPEG_LIB = 'libjpeg'
BF_JPEG_LIBPATH = '/home/sources/staticlibs/lib32'
WITH_BF_PNG = True
BF_PNG_LIB = 'libpng'
BF_PNG_LIBPATH = '/home/sources/staticlibs/lib32'
WITH_BF_STATICLIBSAMPLERATE = True
WITH_BF_ZLIB = True
WITH_BF_STATICZLIB = True
BF_ZLIB_LIB_STATIC = '${BF_ZLIB}/lib/libz.a'
WITH_BF_SDL = True
WITH_BF_OGG = False
WITH_BF_OPENMP = True
WITH_BF_GAMEENGINE = True
WITH_BF_BULLET = True
# Do not build blender when building blenderplayer
WITH_BF_NOBLENDER = True
WITH_BF_PLAYER = True
# Use jemalloc memory manager
WITH_BF_JEMALLOC = True
WITH_BF_STATICJEMALLOC = True
BF_JEMALLOC = '/home/sources/staticlibs/jemalloc'
BF_JEMALLOC_LIBPATH = '${BF_JEMALLOC}/lib32'
# Use 3d mouse library
WITH_BF_3DMOUSE = True
WITH_BF_STATIC3DMOUSE = True
BF_3DMOUSE = '/home/sources/staticlibs/spnav'
BF_3DMOUSE_LIBPATH = '${BF_3DMOUSE}/lib32'
# Color management
WITH_BF_OCIO = True
WITH_BF_STATICOCIO = True
BF_OCIO = '/opt/ocio'
BF_OCIO_INC = '${BF_OCIO}/include'
BF_OCIO_LIB_STATIC = '${BF_OCIO_LIBPATH}/libOpenColorIO.a ${BF_OCIO_LIBPATH}/libtinyxml.a ${BF_OCIO_LIBPATH}/libyaml-cpp.a'
BF_OCIO_LIBPATH = '${BF_OCIO}/lib'
WITH_BF_BOOST = True
WITH_BF_STATICBOOST = True
BF_BOOST = '/opt/boost'
BF_BOOST_INC = '${BF_BOOST}/include'
BF_BOOST_LIB_STATIC = '${BF_BOOST_LIBPATH}/libboost_filesystem.a ${BF_BOOST_LIBPATH}/libboost_date_time.a ${BF_BOOST_LIBPATH}/libboost_regex.a ${BF_BOOST_LIBPATH}/libboost_locale.a ${BF_BOOST_LIBPATH}/libboost_system.a ${BF_BOOST_LIBPATH}/libboost_thread.a'
BF_BOOST_LIBPATH = '${BF_BOOST}/lib'
# JACK
WITH_BF_JACK = False
# Motion Tracking
WITH_BF_LIBMV = False
# Ocean Simulation
WITH_BF_FFTW3 = True
WITH_BF_STATICFFTW3 = True
WITH_BF_OCEANSIM = True
# Compilation and optimization
BF_DEBUG = False
REL_CCFLAGS = ['-DNDEBUG', '-O2'] # C & C++
PLATFORM_LINKFLAGS = ['-L/home/sources/staticlibs/lib32']
@@ -1,114 +0,0 @@
BF_BUILDDIR = '../blender-build/linux-glibc27-x86_64'
BF_INSTALLDIR = '../blender-install/linux-glibc27-x86_64'
BF_NUMJOBS = 2
# Python configuration
BF_PYTHON_VERSION = '3.3'
BF_PYTHON_ABI_FLAGS = 'm'
BF_PYTHON = '/opt/python3'
WITH_BF_STATICPYTHON = True
# OpenCollada configuration
WITH_BF_COLLADA = False
# FFMPEG configuration
WITH_BF_FFMPEG = True
WITH_BF_STATICFFMPEG = True
BF_FFMPEG = '/home/sources/staticlibs/ffmpeg'
BF_FFMPEG_LIBPATH = '${BF_FFMPEG}/lib64'
BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libavformat.a ${BF_FFMPEG_LIBPATH}/libswscale.a ' + \
'${BF_FFMPEG_LIBPATH}/libavcodec.a ${BF_FFMPEG_LIBPATH}/libavdevice.a ${BF_FFMPEG_LIBPATH}/libavutil.a ' + \
'${BF_FFMPEG_LIBPATH}/libxvidcore.a ${BF_FFMPEG_LIBPATH}/libx264.a ${BF_FFMPEG_LIBPATH}/libmp3lame.a ' + \
'${BF_FFMPEG_LIBPATH}/libvpx.a ${BF_FFMPEG_LIBPATH}/libvorbis.a ${BF_FFMPEG_LIBPATH}/libogg.a ' + \
'${BF_FFMPEG_LIBPATH}/libvorbisenc.a ${BF_FFMPEG_LIBPATH}/libtheora.a ' + \
'${BF_FFMPEG_LIBPATH}/libschroedinger-1.0.a ${BF_FFMPEG_LIBPATH}/liborc-0.4.a ${BF_FFMPEG_LIBPATH}/libdirac_encoder.a ' + \
'${BF_FFMPEG_LIBPATH}/libfaad.a'
# Don't depend on system's libstdc++
WITH_BF_STATICCXX = True
BF_CXX_LIB_STATIC = '/usr/lib/gcc/x86_64-linux-gnu/4.3.4/libstdc++.a'
WITH_BF_OPENAL = True
WITH_BF_STATICOPENAL = True
BF_OPENAL_LIB_STATIC = '/opt/openal/lib/libopenal.a'
WITH_BF_GETTEXT_STATIC = True
BF_FREETYPE_LIB_STATIC = True
WITH_BF_OPENEXR = False
WITH_BF_STATICOPENEXR = True
WITH_BF_TIFF = False
WITH_BF_STATICTIFF = True
BF_TIFF_LIB_STATIC = '${BF_TIFF}/lib/libtiff.a'
WITH_BF_JPEG = True
BF_JPEG_LIB = 'libjpeg'
BF_JPEG_LIBPATH = '/home/sources/staticlibs/lib64'
WITH_BF_STATICLIBSAMPLERATE = True
WITH_BF_PNG = True
BF_PNG_LIB = 'libpng'
BF_PNG_LIBPATH = '/home/sources/staticlibs/lib64'
WITH_BF_ZLIB = True
WITH_BF_STATICZLIB = True
BF_ZLIB_LIB_STATIC = '${BF_ZLIB}/lib/libz.a'
WITH_BF_SDL = True
WITH_BF_OGG = False
WITH_BF_OPENMP = True
WITH_BF_GAMEENGINE = True
WITH_BF_BULLET = True
# Do not build blender when building blenderplayer
WITH_BF_NOBLENDER = True
WITH_BF_PLAYER = True
# Use jemalloc memory manager
WITH_BF_JEMALLOC = True
WITH_BF_STATICJEMALLOC = True
BF_JEMALLOC = '/home/sources/staticlibs/jemalloc'
BF_JEMALLOC_LIBPATH = '${BF_JEMALLOC}/lib64'
# Use 3d mouse library
WITH_BF_3DMOUSE = True
WITH_BF_STATIC3DMOUSE = True
BF_3DMOUSE = '/home/sources/staticlibs/spnav'
BF_3DMOUSE_LIBPATH = '${BF_3DMOUSE}/lib64'
# Color management
WITH_BF_OCIO = True
WITH_BF_STATICOCIO = True
BF_OCIO = '/opt/ocio'
BF_OCIO_INC = '${BF_OCIO}/include'
BF_OCIO_LIB_STATIC = '${BF_OCIO_LIBPATH}/libOpenColorIO.a ${BF_OCIO_LIBPATH}/libtinyxml.a ${BF_OCIO_LIBPATH}/libyaml-cpp.a'
BF_OCIO_LIBPATH = '${BF_OCIO}/lib'
WITH_BF_BOOST = True
WITH_BF_STATICBOOST = True
BF_BOOST = '/opt/boost'
BF_BOOST_INC = '${BF_BOOST}/include'
BF_BOOST_LIB_STATIC = '${BF_BOOST_LIBPATH}/libboost_filesystem.a ${BF_BOOST_LIBPATH}/libboost_date_time.a ${BF_BOOST_LIBPATH}/libboost_regex.a ${BF_BOOST_LIBPATH}/libboost_locale.a ${BF_BOOST_LIBPATH}/libboost_system.a ${BF_BOOST_LIBPATH}/libboost_thread.a'
BF_BOOST_LIBPATH = '${BF_BOOST}/lib'
# JACK
WITH_BF_JACK = False
# Motion Tracking
WITH_BF_LIBMV = False
# Ocean Simulation
WITH_BF_FFTW3 = True
WITH_BF_STATICFFTW3 = True
WITH_BF_OCEANSIM = True
# Compilation and optimization
BF_DEBUG = False
REL_CCFLAGS = ['-DNDEBUG', '-O2', '-msse', '-msse2'] # C & C++
PLATFORM_LINKFLAGS = ['-L/home/sources/staticlibs/lib64']
+2 -2
View File
@@ -116,10 +116,10 @@ add_builder(c, 'mac_x86_64_10_5_scons', '', generic_builder, '', True)
add_builder(c, 'mac_i386_scons', 'darwin-9.x.universal', generic_builder)
add_builder(c, 'mac_ppc_scons', 'darwin-9.x.universal', generic_builder)
#add_builder(c, 'linux_x86_64_cmake', '', generic_builder)
add_builder(c, 'linux_glibc27_i386_scons', '', generic_builder)
#add_builder(c, 'linux_glibc27_i386_scons', '', generic_builder)
add_builder(c, 'linux_glibc211_i386_scons', '', generic_builder)
#add_builder(c, 'salad_linux_i386_scons', '', generic_builder, 'soc-2011-salad')
add_builder(c, 'linux_glibc27_x86_64_scons', '', generic_builder)
#add_builder(c, 'linux_glibc27_x86_64_scons', '', generic_builder)
add_builder(c, 'linux_glibc211_x86_64_scons', '', generic_builder)
#add_builder(c, 'salad_linux_x86_64_scons', '', generic_builder, 'soc-2011-salad')
add_builder(c, 'win32_scons', 'windows', generic_builder)
+35 -18
View File
@@ -60,6 +60,27 @@ else:
if builder.find('linux') != -1:
import shutil
configs = []
if builder.endswith('linux_glibc211_x86_64_scons'):
configs = ['user-config-player-glibc211-x86_64.py',
'user-config-cuda-glibc211-x86_64.py',
'user-config-glibc211-x86_64.py'
]
chroot_name = 'buildbot_squeeze_x86_64'
cuda_chroot = 'buildbot_squeeze_x86_64'
elif builder.endswith('linux_glibc211_i386_scons'):
configs = ['user-config-player-glibc211-i686.py',
'user-config-cuda-glibc211-i686.py',
'user-config-glibc211-i686.py']
chroot_name = 'buildbot_squeeze_i686'
# use 64bit cuda toolkit, so there'll be no memory limit issues
cuda_chroot = 'buildbot_squeeze_x86_64'
# Compilation will happen inside of chroot environment
prog_scons_cmd = ['schroot', '-c', chroot_name, '--'] + scons_cmd
cuda_scons_cmd = ['schroot', '-c', cuda_chroot, '--'] + scons_cmd
# We're using the same rules as release builder, so tweak
# build and install dirs
build_dir = os.path.join('..', 'build', builder)
@@ -74,20 +95,6 @@ else:
buildbot_dir = os.path.dirname(os.path.realpath(__file__))
config_dir = os.path.join(buildbot_dir, 'config')
configs = []
if builder.endswith('linux_glibc27_x86_64_scons'):
configs = ['user-config-player-glibc27-x86_64.py',
'user-config-glibc27-x86_64.py']
elif builder.endswith('linux_glibc27_i386_scons'):
configs = ['user-config-player-glibc27-i686.py',
'user-config-glibc27-i686.py']
if builder.endswith('linux_glibc211_x86_64_scons'):
configs = ['user-config-player-glibc211-x86_64.py',
'user-config-glibc211-x86_64.py']
elif builder.endswith('linux_glibc211_i386_scons'):
configs = ['user-config-player-glibc211-i686.py',
'user-config-glibc211-i686.py']
for config in configs:
config_fpath = os.path.join(config_dir, config)
@@ -100,14 +107,24 @@ else:
scons_options += common_options
if config.find('player') == -1:
scons_options.append('blender')
else:
if config.find('player') != -1:
scons_options.append('blenderplayer')
cur_scons_cmd = prog_scons_cmd
elif config.find('cuda') != -1:
scons_options.append('cudakernels')
cur_scons_cmd = cuda_scons_cmd
if config.find('i686') != -1:
scons_options.append('BF_BITNESS=32')
elif config.find('x86_64') != -1:
scons_options.append('BF_BITNESS=64')
else:
scons_options.append('blender')
cur_scons_cmd = prog_scons_cmd
scons_options.append('BF_CONFIG=' + config_fpath)
retcode = subprocess.call(scons_cmd + scons_options)
retcode = subprocess.call(cur_scons_cmd + scons_options)
if retcode != 0:
print('Error building rules wuth config ' + config)
sys.exit(retcode)
+4 -8
View File
@@ -57,17 +57,13 @@ if builder.find('scons') != -1:
config = None
bits = None
if builder.endswith('linux_glibc27_x86_64_scons'):
config = 'user-config-glibc27-x86_64.py'
bits = 64
elif builder.endswith('linux_glibc27_i386_scons'):
config = 'user-config-glibc27-i686.py'
bits = 32
if builder.endswith('linux_glibc211_x86_64_scons'):
config = 'user-config-glibc211-x86_64.py'
chroot_name = 'buildbot_squeeze_x86_64'
bits = 64
elif builder.endswith('linux_glibc211_i386_scons'):
config = 'user-config-glibc211-i686.py'
chroot_name = 'buildbot_squeeze_i686'
bits = 32
if config is not None:
@@ -76,7 +72,7 @@ if builder.find('scons') != -1:
blender = os.path.join(install_dir, 'blender')
blenderplayer = os.path.join(install_dir, 'blenderplayer')
subprocess.call(['strip', '--strip-all', blender, blenderplayer])
subprocess.call(['schroot', '-c', chroot_name, '--', 'strip', '--strip-all', blender, blenderplayer])
extra = '/' + os.path.join('home', 'sources', 'release-builder', 'extra')
mesalibs = os.path.join(extra, 'mesalibs' + str(bits) + '.tar.bz2')
@@ -86,7 +82,7 @@ if builder.find('scons') != -1:
os.system('cp %s %s' % (software_gl, install_dir))
os.system('chmod 755 %s' % (os.path.join(install_dir, 'blender-softwaregl')))
retcode = subprocess.call(['python', 'scons/scons.py'] + scons_options)
retcode = subprocess.call(['schroot', '-c', chroot_name, '--', 'python', 'scons/scons.py'] + scons_options)
sys.exit(retcode)
else:
@@ -56,6 +56,10 @@ def create_nb_project_main():
pass
else:
includes, defines = cmake_advanced_info()
if (includes, defines) == (None, None):
return
# for some reason it doesnt give all internal includes
includes = list(set(includes) | set(dirname(f) for f in files if is_c_header(f)))
includes.sort()
@@ -81,6 +81,9 @@ def create_qtc_project_main():
else:
includes, defines = cmake_advanced_info()
if (includes, defines) == (None, None):
return
# for some reason it doesnt give all internal includes
includes = list(set(includes) | set(os.path.dirname(f)
for f in files_rel if is_c_header(f)))
+8 -2
View File
@@ -149,14 +149,20 @@ def cmake_advanced_info():
raise Exception("Unknown make program %r" % make_exe)
os.system(cmd)
return join(CMAKE_DIR, ".cproject")
includes = []
defines = []
create_eclipse_project()
project_path = create_eclipse_project()
if not exists(project_path):
print("Generating Eclipse Prokect File Failed: %r not found" % project_path)
return None, None
from xml.dom.minidom import parse
tree = parse(join(CMAKE_DIR, ".cproject"))
tree = parse(project_path)
# to check on nicer xml
# f = open(".cproject_pretty", 'w')
+14 -1
View File
@@ -216,7 +216,8 @@ def print_targets(targs, bc):
def validate_targets(targs, bc):
valid_list = ['.', 'blender', 'blenderstatic', 'blenderplayer', 'webplugin',
'blendernogame', 'blenderstaticnogame', 'blenderlite', 'release',
'everything', 'clean', 'install-bin', 'install', 'nsis','buildslave']
'everything', 'clean', 'install-bin', 'install', 'nsis','buildslave',
'cudakernels']
oklist = []
for t in targs:
if t in valid_list:
@@ -829,6 +830,18 @@ def NSIS_Installer(target=None, source=None, env=None):
print data.strip().split("\n")[-1]
return rv
def cudakernels_print(target, source, env):
return "Running cudakernels target"
def cudakernels(target=None, source=None, env=None):
"""
Builder for cuda kernels compilation. Used by release build environment only
"""
# Currently nothing to do, everything is handled by a dependency resolver
pass
def check_environ():
problematic_envvars = ""
for i in os.environ:
+85
View File
@@ -0,0 +1,85 @@
"""
Get/Set Example
++++++++++++++
Get/Set functions can be used for boolean, int, float, string and enum properties.
If these callbacks are defined the property will not be stored in the ID properties
automatically, instead the get/set functions will be called when the property is
read or written from the API.
"""
import bpy
# Simple property reading/writing from ID properties.
# This is what the RNA would do internally.
def get_float(self):
return self["testprop"]
def set_float(self, value):
self["testprop"] = value
bpy.types.Scene.test_float = bpy.props.FloatProperty(get=get_float, set=set_float)
# Read-only string property, returns the current date
def get_date(self):
import datetime
return str(datetime.datetime.now())
bpy.types.Scene.test_date = bpy.props.StringProperty(get=get_date)
# Boolean array. Set function stores a single boolean value, returned as the second component.
# Array getters must return a list or tuple
# Array size must match the property vector size exactly
def get_array(self):
return (True, self["somebool"])
def set_array(self, values):
self["somebool"] = values[0] and values[1]
bpy.types.Scene.test_array = bpy.props.BoolVectorProperty(size=2, get=get_array, set=set_array)
# Enum property.
# Note: the getter/setter callback must use integer identifiers!
test_items = [
("RED", "Red", "", 1),
("GREEN", "Red", "", 2),
("BLUE", "Red", "", 3),
("YELLOW", "Red", "", 4),
]
def get_enum(self):
import random
return random.randint(1, 4)
def set_enum(self, value):
print("setting value", value)
bpy.types.Scene.test_enum = bpy.props.EnumProperty(items=test_items, get=get_enum, set=set_enum)
# Testing
scene = bpy.context.scene
scene.test_float = 12.34
print (scene.test_float)
scene.test_array = (True, False)
print ([x for x in scene.test_array])
#scene.test_date = "blah" # this would fail, property is read-only
print (scene.test_date)
scene.test_enum = 'BLUE'
print (scene.test_enum)
# >>> 12.34000015258789
# >>> [True, False]
# >>> 2013-01-05 16:33:52.135340
# >>> setting value 3
# >>> GREEN
+14
View File
@@ -95,6 +95,14 @@ enum_curves_interpolation = (
('CARDINAL', "Cardinal interpolation", "Use cardinal interpolation between segments"),
('BSPLINE', "B-spline interpolation", "Use b-spline interpolation between segments"),
)
enum_tile_order = (
('CENTER', "Center", "Render from center to the edges"),
('RIGHT_TO_LEFT', "Right to Left", "Render from right to left"),
('LEFT_TO_RIGHT', "Left to Right", "Render from left to right"),
('TOP_TO_BOTTOM', "Top to Bottom", "Render from top to bottom"),
('BOTTOM_TO_TOP', "Bottom to Top", "Render from bottom to top"),
)
class CyclesRenderSettings(bpy.types.PropertyGroup):
@classmethod
@@ -352,6 +360,12 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
description="Cache last built BVH to disk for faster re-render if no geometry changed",
default=False,
)
cls.tile_order = EnumProperty(
name="Tile Order",
description="Tile order for rendering",
items=enum_tile_order,
default='CENTER',
)
cls.use_progressive_refine = BoolProperty(
name="Progressive Refine",
description="Instead of rendering each tile until it is finished, "
+2 -1
View File
@@ -191,7 +191,8 @@ class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
sub.prop(rd, "threads")
sub = col.column(align=True)
sub.label(text="Tile Size:")
sub.label(text="Tiles:")
sub.prop(cscene, "tile_order", text="")
sub.prop(rd, "tile_x", text="X")
sub.prop(rd, "tile_y", text="Y")
+14 -6
View File
@@ -330,13 +330,17 @@ bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par
bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents)
{
#if 0
int keyno = 0;
#endif
if(!(mesh && b_mesh && b_ob && CData))
return false;
#if 0
Transform tfm = get_transform(b_ob->matrix_world());
Transform itfm = transform_quick_inverse(tfm);
#endif
BL::Object::modifiers_iterator b_mod;
for(b_ob->modifiers.begin(b_mod); b_mod != b_ob->modifiers.end(); ++b_mod) {
@@ -348,12 +352,13 @@ bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Parti
BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr);
if((b_psys.settings().render_type()==BL::ParticleSettings::render_type_PATH)&&(b_psys.settings().type()==BL::ParticleSettings::type_HAIR)) {
#if 0
int mi = clamp(b_psys.settings().material()-1, 0, mesh->used_shaders.size()-1);
int shader = mesh->used_shaders[mi];
int draw_step = b_psys.settings().draw_step();
int ren_step = (int)pow((float)2.0f,(float)draw_step);
/*b_psys.settings().render_step(draw_step);*/
b_psys.settings().render_step(draw_step);
#endif
int totparts = b_psys.particles.length();
int totchild = b_psys.child_particles.length() * b_psys.settings().draw_percentage() / 100;
@@ -397,13 +402,16 @@ bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Parti
bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents, int vcol_num)
{
#if 0
int keyno = 0;
#endif
if(!(mesh && b_mesh && b_ob && CData))
return false;
#if 0
Transform tfm = get_transform(b_ob->matrix_world());
Transform itfm = transform_quick_inverse(tfm);
#endif
BL::Object::modifiers_iterator b_mod;
for(b_ob->modifiers.begin(b_mod); b_mod != b_ob->modifiers.end(); ++b_mod) {
@@ -415,13 +423,13 @@ bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par
BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr);
if((b_psys.settings().render_type()==BL::ParticleSettings::render_type_PATH)&&(b_psys.settings().type()==BL::ParticleSettings::type_HAIR)) {
#if 0
int mi = clamp(b_psys.settings().material()-1, 0, mesh->used_shaders.size()-1);
int shader = mesh->used_shaders[mi];
int draw_step = b_psys.settings().draw_step();
int ren_step = (int)pow((float)2.0f,(float)draw_step);
/*b_psys.settings().render_step(draw_step);*/
b_psys.settings().render_step(draw_step);
#endif
int totparts = b_psys.particles.length();
int totchild = b_psys.child_particles.length() * b_psys.settings().draw_percentage() / 100;
int totcurves = totchild;
+4 -4
View File
@@ -127,8 +127,8 @@ void BlenderSync::sync_light(BL::Object b_parent, int persistent_id[OBJECT_PERSI
case BL::Lamp::type_AREA: {
BL::AreaLamp b_area_lamp(b_lamp);
light->size = 1.0f;
light->axisu = make_float3(tfm.x.x, tfm.y.x, tfm.z.x);
light->axisv = make_float3(tfm.x.y, tfm.y.y, tfm.z.y);
light->axisu = transform_get_column(&tfm, 0);
light->axisv = transform_get_column(&tfm, 1);
light->sizeu = b_area_lamp.size();
if(b_area_lamp.shape() == BL::AreaLamp::shape_RECTANGLE)
light->sizev = b_area_lamp.size_y();
@@ -140,8 +140,8 @@ void BlenderSync::sync_light(BL::Object b_parent, int persistent_id[OBJECT_PERSI
}
/* location and (inverted!) direction */
light->co = make_float3(tfm.x.w, tfm.y.w, tfm.z.w);
light->dir = -make_float3(tfm.x.z, tfm.y.z, tfm.z.z);
light->co = transform_get_column(&tfm, 3);
light->dir = -transform_get_column(&tfm, 2);
/* shader */
vector<uint> used_shaders;
@@ -139,6 +139,8 @@ void BlenderSession::reset_session(BL::BlendData b_data_, BL::Scene b_scene_)
session->progress.reset();
scene->reset();
session->tile_manager.set_tile_order(session_params.tile_order);
/* peak memory usage should show current render peak, not peak for all renders
* made by this render session
*/
+2
View File
@@ -396,6 +396,8 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine b_engine, BL::Use
params.tile_size = make_int2(tile_x, tile_y);
}
params.tile_order = RNA_enum_get(&cscene, "tile_order");
params.start_resolution = get_int(cscene, "preview_start_resolution");
+4 -1
View File
@@ -18,11 +18,14 @@ set(SRC
device_cpu.cpp
device_cuda.cpp
device_multi.cpp
device_network.cpp
device_opencl.cpp
device_task.cpp
)
if(WITH_NETWORK)
list(APPEND SRC device_network.cpp)
endif()
set(SRC_HEADERS
device.h
device_memory.h
-1
View File
@@ -199,7 +199,6 @@ __device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float ra
Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y + 1.0f, 0.0f));
ray->dD.dy = normalize(transform_direction(&cameratoworld, panorama_to_direction(kg, Pcamera.x, Pcamera.y))) - ray->D;
#endif
}
+45 -16
View File
@@ -66,6 +66,8 @@ __device float3 direct_emissive_eval(KernelGlobals *kg, float rando,
else
eval = make_float3(0.0f, 0.0f, 0.0f);
}
eval *= ls->eval_fac;
shader_release(kg, &sd);
@@ -74,29 +76,29 @@ __device float3 direct_emissive_eval(KernelGlobals *kg, float rando,
__device bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex,
float randt, float rando, float randu, float randv, Ray *ray, BsdfEval *eval,
bool *is_lamp)
int *lamp)
{
LightSample ls;
float pdf = -1.0f;
#ifdef __NON_PROGRESSIVE__
if(lindex != -1) {
/* sample position on a specified light */
light_select(kg, lindex, randu, randv, sd->P, &ls, &pdf);
light_select(kg, lindex, randu, randv, sd->P, &ls);
}
else
#endif
{
/* sample a light and position on int */
light_sample(kg, randt, randu, randv, sd->time, sd->P, &ls, &pdf);
light_sample(kg, randt, randu, randv, sd->time, sd->P, &ls);
}
/* compute pdf */
if(pdf < 0.0f)
pdf = light_sample_pdf(kg, &ls, -ls.D, ls.t);
/* return lamp index for MIS */
if(ls.use_mis)
*lamp = ls.lamp;
else
*lamp= ~0;
if(pdf == 0.0f)
if(ls.pdf == 0.0f)
return false;
/* evaluate closure */
@@ -112,13 +114,13 @@ __device bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex,
shader_bsdf_eval(kg, sd, ls.D, eval, &bsdf_pdf);
if(ls.prim != ~0 || ls.type == LIGHT_BACKGROUND) {
if(ls.use_mis) {
/* multiple importance sampling */
float mis_weight = power_heuristic(pdf, bsdf_pdf);
float mis_weight = power_heuristic(ls.pdf, bsdf_pdf);
light_eval *= mis_weight;
}
bsdf_eval_mul(eval, light_eval*(ls.eval_fac/pdf));
bsdf_eval_mul(eval, light_eval/ls.pdf);
if(bsdf_eval_is_zero(eval))
return false;
@@ -144,14 +146,12 @@ __device bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex,
ray->t = 0.0f;
}
*is_lamp = (ls.prim == ~0);
return true;
}
/* Indirect Emission */
/* Indirect Primitive Emission */
__device float3 indirect_emission(KernelGlobals *kg, ShaderData *sd, float t, int path_flag, float bsdf_pdf)
__device float3 indirect_primitive_emission(KernelGlobals *kg, ShaderData *sd, float t, int path_flag, float bsdf_pdf)
{
/* evaluate emissive closure */
float3 L = shader_emissive_eval(kg, sd);
@@ -172,6 +172,35 @@ __device float3 indirect_emission(KernelGlobals *kg, ShaderData *sd, float t, in
return L;
}
/* Indirect Lamp Emission */
__device bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf, float randt, float3 *emission)
{
LightSample ls;
int lamp = lamp_light_eval_sample(kg, randt);
if(lamp == ~0)
return false;
if(!lamp_light_eval(kg, lamp, ray->P, ray->D, ray->t, &ls))
return false;
/* todo: missing texture coordinates */
float u = 0.0f;
float v = 0.0f;
float3 L = direct_emissive_eval(kg, 0.0f, &ls, u, v, -ray->D, ls.t, ray->time);
if(!(path_flag & PATH_RAY_MIS_SKIP)) {
/* multiple importance sampling, get regular light pdf,
* and compute weight with respect to BSDF pdf */
float mis_weight = power_heuristic(bsdf_pdf, ls.pdf);
L *= mis_weight;
}
*emission = L;
return true;
}
/* Indirect Background */
__device float3 indirect_background(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf)
+303 -157
View File
@@ -18,49 +18,27 @@
CCL_NAMESPACE_BEGIN
/* Light Sample result */
typedef struct LightSample {
float3 P;
float3 D;
float3 Ng;
float t;
float eval_fac;
int object;
int prim;
int shader;
LightType type;
float3 P; /* position on light, or direction for distant light */
float3 Ng; /* normal on light */
float3 D; /* direction from shading point to light */
float t; /* distance to light (FLT_MAX for distant light) */
float pdf; /* light sampling probability density function */
float eval_fac; /* intensity multiplier */
int object; /* object id for triangle/curve lights */
int prim; /* primitive id for triangle/curve ligths */
int shader; /* shader id */
int lamp; /* lamp id */
int use_mis; /* for lamps with size zero */
LightType type; /* type of light */
} LightSample;
/* Regular Light */
__device float3 disk_light_sample(float3 v, float randu, float randv)
{
float3 ru, rv;
make_orthonormals(v, &ru, &rv);
to_unit_disk(&randu, &randv);
return ru*randu + rv*randv;
}
__device float3 distant_light_sample(float3 D, float size, float randu, float randv)
{
return normalize(D + disk_light_sample(D, randu, randv)*size);
}
__device float3 sphere_light_sample(float3 P, float3 center, float size, float randu, float randv)
{
return disk_light_sample(normalize(P - center), randu, randv)*size;
}
__device float3 area_light_sample(float3 axisu, float3 axisv, float randu, float randv)
{
randu = randu - 0.5f;
randv = randv - 0.5f;
return axisu*randu + axisv*randv;
}
/* Background Light */
#ifdef __BACKGROUND_MIS__
__device float3 background_light_sample(KernelGlobals *kg, float randu, float randv, float *pdf)
{
/* for the following, the CDF values are actually a pair of floats, with the
@@ -169,33 +147,108 @@ __device float background_light_pdf(KernelGlobals *kg, float3 direction)
}
#endif
__device void regular_light_sample(KernelGlobals *kg, int point,
float randu, float randv, float3 P, LightSample *ls, float *pdf)
/* Regular Light */
__device float3 disk_light_sample(float3 v, float randu, float randv)
{
float4 data0 = kernel_tex_fetch(__light_data, point*LIGHT_SIZE + 0);
float4 data1 = kernel_tex_fetch(__light_data, point*LIGHT_SIZE + 1);
float3 ru, rv;
make_orthonormals(v, &ru, &rv);
to_unit_disk(&randu, &randv);
return ru*randu + rv*randv;
}
__device float3 distant_light_sample(float3 D, float radius, float randu, float randv)
{
return normalize(D + disk_light_sample(D, randu, randv)*radius);
}
__device float3 sphere_light_sample(float3 P, float3 center, float radius, float randu, float randv)
{
return disk_light_sample(normalize(P - center), randu, randv)*radius;
}
__device float3 area_light_sample(float3 axisu, float3 axisv, float randu, float randv)
{
randu = randu - 0.5f;
randv = randv - 0.5f;
return axisu*randu + axisv*randv;
}
__device float spot_light_attenuation(float4 data1, float4 data2, LightSample *ls)
{
float3 dir = make_float3(data2.y, data2.z, data2.w);
float3 I = ls->Ng;
float spot_angle = data1.w;
float spot_smooth = data2.x;
float attenuation = dot(dir, I);
if(attenuation <= spot_angle) {
attenuation = 0.0f;
}
else {
float t = attenuation - spot_angle;
if(t < spot_smooth && spot_smooth != 0.0f)
attenuation *= smoothstepf(t/spot_smooth);
}
return attenuation;
}
__device float lamp_light_pdf(KernelGlobals *kg, const float3 Ng, const float3 I, float t)
{
float cos_pi = dot(Ng, I);
if(cos_pi <= 0.0f)
return 0.0f;
return t*t/cos_pi;
}
__device void lamp_light_sample(KernelGlobals *kg, int lamp,
float randu, float randv, float3 P, LightSample *ls)
{
float4 data0 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 0);
float4 data1 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 1);
LightType type = (LightType)__float_as_int(data0.x);
ls->type = type;
#ifdef __LAMP_MIS__
ls->use_mis = true;
#else
ls->use_mis = false;
#endif
if(type == LIGHT_DISTANT) {
/* distant light */
float3 D = make_float3(data0.y, data0.z, data0.w);
float size = data1.y;
float3 lightD = make_float3(data0.y, data0.z, data0.w);
float3 D = lightD;
float radius = data1.y;
float invarea = data1.w;
if(size > 0.0f)
D = distant_light_sample(D, size, randu, randv);
if(radius > 0.0f)
D = distant_light_sample(D, radius, randu, randv);
else
ls->use_mis = false;
ls->P = D;
ls->Ng = D;
ls->D = -D;
ls->t = FLT_MAX;
ls->eval_fac = 1.0f;
float costheta = dot(lightD, D);
ls->pdf = invarea/(costheta*costheta*costheta);
ls->eval_fac = ls->pdf*kernel_data.integrator.inv_pdf_lights;
}
#ifdef __BACKGROUND_MIS__
else if(type == LIGHT_BACKGROUND) {
/* infinite area light (e.g. light dome or env light) */
float3 D = background_light_sample(kg, randu, randv, pdf);
float3 D = background_light_sample(kg, randu, randv, &ls->pdf);
ls->P = D;
ls->Ng = D;
@@ -207,85 +260,203 @@ __device void regular_light_sample(KernelGlobals *kg, int point,
else {
ls->P = make_float3(data0.y, data0.z, data0.w);
if(type == LIGHT_POINT) {
float size = data1.y;
if(type == LIGHT_POINT || type == LIGHT_SPOT) {
float radius = data1.y;
/* sphere light */
if(size > 0.0f)
ls->P += sphere_light_sample(P, ls->P, size, randu, randv);
if(radius > 0.0f)
/* sphere light */
ls->P += sphere_light_sample(P, ls->P, radius, randu, randv);
else
ls->use_mis = false;
ls->Ng = normalize(P - ls->P);
ls->eval_fac = 0.25f*M_1_PI_F;
}
else if(type == LIGHT_SPOT) {
float4 data2 = kernel_tex_fetch(__light_data, point*LIGHT_SIZE + 2);
float size = data1.y;
ls->D = normalize_len(ls->P - P, &ls->t);
ls->Ng = -ls->D;
/* spot light */
if(size > 0.0f)
ls->P += sphere_light_sample(P, ls->P, size, randu, randv);
float invarea = data1.z;
ls->eval_fac = (0.25f*M_1_PI_F)*invarea;
ls->pdf = invarea;
float3 dir = make_float3(data1.z, data1.w, data2.x);
float3 I = normalize(P - ls->P);
float spot_angle = data2.y;
float spot_smooth = data2.z;
float eval_fac = dot(dir, I);
if(eval_fac <= spot_angle) {
eval_fac = 0.0f;
if(type == LIGHT_SPOT) {
/* spot light attentuation */
float4 data2 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 2);
ls->eval_fac *= spot_light_attenuation(data1, data2, ls);
}
else {
float t = eval_fac - spot_angle;
if(t < spot_smooth && spot_smooth != 0.0f)
eval_fac *= smoothstepf(t/spot_smooth);
}
ls->Ng = I;
ls->eval_fac = eval_fac*0.25f*M_1_PI_F;
}
else {
/* area light */
float4 data2 = kernel_tex_fetch(__light_data, point*LIGHT_SIZE + 2);
float4 data3 = kernel_tex_fetch(__light_data, point*LIGHT_SIZE + 3);
float4 data2 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 2);
float4 data3 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 3);
float3 axisu = make_float3(data1.y, data1.z, data2.w);
float3 axisu = make_float3(data1.y, data1.z, data1.w);
float3 axisv = make_float3(data2.y, data2.z, data2.w);
float3 D = make_float3(data3.y, data3.z, data3.w);
ls->P += area_light_sample(axisu, axisv, randu, randv);
ls->Ng = D;
ls->eval_fac = 0.25f;
ls->D = normalize_len(ls->P - P, &ls->t);
float invarea = data2.x;
if(invarea == 0.0f) {
ls->use_mis = false;
invarea = 1.0f;
}
ls->eval_fac = 0.25f*invarea;
ls->pdf = invarea;
}
ls->t = 0.0f;
ls->eval_fac *= kernel_data.integrator.inv_pdf_lights;
ls->pdf *= lamp_light_pdf(kg, ls->Ng, -ls->D, ls->t);
}
ls->shader = __float_as_int(data1.x);
ls->object = ~0;
ls->prim = ~0;
ls->lamp = lamp;
}
__device float regular_light_pdf(KernelGlobals *kg,
const float3 Ng, const float3 I, float t)
__device bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D, float t, LightSample *ls)
{
float pdf = kernel_data.integrator.pdf_lights;
float4 data0 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 0);
float4 data1 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 1);
if(t == FLT_MAX)
return pdf;
LightType type = (LightType)__float_as_int(data0.x);
ls->type = type;
ls->shader = __float_as_int(data1.x);
ls->object = ~0;
ls->prim = ~0;
ls->lamp = lamp;
ls->use_mis = false; /* flag not used for eval */
float cos_pi = dot(Ng, I);
if(type == LIGHT_DISTANT) {
/* distant light */
float radius = data1.y;
if(cos_pi <= 0.0f)
return 0.0f;
if(radius == 0.0f)
return false;
if(t != FLT_MAX)
return false;
return t*t*pdf/cos_pi;
/* a distant light is infinitely far away, but equivalent to a disk
* shaped light exactly 1 unit away from the current shading point.
*
* radius t^2/cos(theta)
* <----------> t = sqrt(1^2 + tan(theta)^2)
* tan(th) area = radius*radius*pi
* <----->
* \ | (1 + tan(theta)^2)/cos(theta)
* \ | (1 + tan(acos(cos(theta)))^2)/cos(theta)
* t \th| 1 simplifies to
* \-| 1/(cos(theta)^3)
* \| magic!
* P
*/
float3 lightD = make_float3(data0.y, data0.z, data0.w);
float costheta = dot(-lightD, D);
float cosangle = data1.z;
if(costheta < cosangle)
return false;
ls->P = -D;
ls->Ng = -D;
ls->D = D;
ls->t = FLT_MAX;
float invarea = data1.w;
ls->pdf = invarea/(costheta*costheta*costheta);
ls->eval_fac = ls->pdf;
}
else if(type == LIGHT_POINT || type == LIGHT_SPOT) {
float3 lightP = make_float3(data0.y, data0.z, data0.w);
float radius = data1.y;
/* sphere light */
if(radius == 0.0f)
return false;
if(!ray_aligned_disk_intersect(P, D, t,
lightP, radius, &ls->P, &ls->t))
return false;
ls->Ng = -D;
ls->D = D;
float invarea = data1.z;
ls->eval_fac = (0.25f*M_1_PI_F)*invarea;
ls->pdf = invarea;
if(type == LIGHT_SPOT) {
/* spot light attentuation */
float4 data2 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 2);
ls->eval_fac *= spot_light_attenuation(data1, data2, ls);
if(ls->eval_fac == 0.0f)
return false;
}
}
else if(type == LIGHT_AREA) {
/* area light */
float4 data2 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 2);
float4 data3 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 3);
float invarea = data2.x;
if(invarea == 0.0f)
return false;
float3 axisu = make_float3(data1.y, data1.z, data1.w);
float3 axisv = make_float3(data2.y, data2.z, data2.w);
float3 Ng = make_float3(data3.y, data3.z, data3.w);
/* one sided */
if(dot(D, Ng) >= 0.0f)
return false;
ls->P = make_float3(data0.y, data0.z, data0.w);
if(!ray_quad_intersect(P, D, t,
ls->P, axisu, axisv, &ls->P, &ls->t))
return false;
ls->D = D;
ls->Ng = Ng;
ls->pdf = invarea;
ls->eval_fac = 0.25f*ls->pdf;
}
else
return false;
/* compute pdf */
if(ls->t != FLT_MAX)
ls->pdf *= lamp_light_pdf(kg, ls->Ng, -ls->D, ls->t);
ls->eval_fac *= kernel_data.integrator.inv_pdf_lights;
return true;
}
/* Triangle Light */
__device void object_transform_light_sample(KernelGlobals *kg, LightSample *ls, int object, float time)
{
#ifdef __INSTANCING__
/* instance transform */
if(object >= 0) {
#ifdef __OBJECT_MOTION__
Transform itfm;
Transform tfm = object_fetch_transform_motion_test(kg, object, time, &itfm);
#else
Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM);
Transform itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
#endif
ls->P = transform_point(&tfm, ls->P);
ls->Ng = normalize(transform_direction(&tfm, ls->Ng));
}
#endif
}
__device void triangle_light_sample(KernelGlobals *kg, int prim, int object,
float randu, float randv, float time, LightSample *ls)
{
@@ -294,40 +465,30 @@ __device void triangle_light_sample(KernelGlobals *kg, int prim, int object,
ls->Ng = triangle_normal_MT(kg, prim, &ls->shader);
ls->object = object;
ls->prim = prim;
ls->lamp = ~0;
ls->use_mis = true;
ls->t = 0.0f;
ls->type = LIGHT_AREA;
ls->eval_fac = 1.0f;
#ifdef __INSTANCING__
/* instance transform */
if(ls->object >= 0) {
#ifdef __OBJECT_MOTION__
Transform itfm;
Transform tfm = object_fetch_transform_motion_test(kg, object, time, &itfm);
#else
Transform tfm = object_fetch_transform(kg, ls->object, OBJECT_TRANSFORM);
Transform itfm = object_fetch_transform(kg, ls->object, OBJECT_INVERSE_TRANSFORM);
#endif
ls->P = transform_point(&tfm, ls->P);
ls->Ng = normalize(transform_direction_transposed(&itfm, ls->Ng));
}
#endif
object_transform_light_sample(kg, ls, object, time);
}
__device float triangle_light_pdf(KernelGlobals *kg,
const float3 Ng, const float3 I, float t)
{
float pdf = kernel_data.integrator.pdf_triangles;
float cos_pi = fabsf(dot(Ng, I));
if(cos_pi == 0.0f)
return 0.0f;
return (t*t*kernel_data.integrator.pdf_triangles)/cos_pi;
return t*t*pdf/cos_pi;
}
/* Curve Light */
#ifdef __HAIR__
/* Strand Light */
__device void curve_segment_light_sample(KernelGlobals *kg, int prim, int object,
int segment, float randu, float randv, float time, LightSample *ls)
@@ -358,27 +519,16 @@ __device void curve_segment_light_sample(KernelGlobals *kg, int prim, int object
ls->P = randu * l * tg + (gd * l + r1) * ls->Ng;
ls->object = object;
ls->prim = prim;
ls->lamp = ~0;
ls->use_mis = true;
ls->t = 0.0f;
ls->type = LIGHT_STRAND;
ls->eval_fac = 1.0f;
ls->shader = __float_as_int(v00.z);
#ifdef __INSTANCING__
/* instance transform */
if(ls->object >= 0) {
#ifdef __OBJECT_MOTION__
Transform itfm;
Transform tfm = object_fetch_transform_motion_test(kg, object, time, &itfm);
#else
Transform tfm = object_fetch_transform(kg, ls->object, OBJECT_TRANSFORM);
Transform itfm = object_fetch_transform(kg, ls->object, OBJECT_INVERSE_TRANSFORM);
#endif
ls->P = transform_point(&tfm, ls->P);
ls->Ng = normalize(transform_direction(&tfm, ls->Ng));
}
#endif
object_transform_light_sample(kg, ls, object, time);
}
#endif
/* Light Distribution */
@@ -412,7 +562,7 @@ __device int light_distribution_sample(KernelGlobals *kg, float randt)
/* Generic Light */
__device void light_sample(KernelGlobals *kg, float randt, float randu, float randv, float time, float3 P, LightSample *ls, float *pdf)
__device void light_sample(KernelGlobals *kg, float randt, float randu, float randv, float time, float3 P, LightSample *ls)
{
/* sample index */
int index = light_distribution_sample(kg, randt);
@@ -420,12 +570,12 @@ __device void light_sample(KernelGlobals *kg, float randt, float randu, float ra
/* fetch light data */
float4 l = kernel_tex_fetch(__light_distribution, index);
int prim = __float_as_int(l.y);
#ifdef __HAIR__
int segment = __float_as_int(l.z);
#endif
if(prim >= 0) {
int object = __float_as_int(l.w);
#ifdef __HAIR__
int segment = __float_as_int(l.z);
#endif
#ifdef __HAIR__
if (segment != ~0)
@@ -433,27 +583,15 @@ __device void light_sample(KernelGlobals *kg, float randt, float randu, float ra
else
#endif
triangle_light_sample(kg, prim, object, randu, randv, time, ls);
/* compute incoming direction, distance and pdf */
ls->D = normalize_len(ls->P - P, &ls->t);
ls->pdf = triangle_light_pdf(kg, ls->Ng, -ls->D, ls->t);
}
else {
int point = -prim-1;
regular_light_sample(kg, point, randu, randv, P, ls, pdf);
int lamp = -prim-1;
lamp_light_sample(kg, lamp, randu, randv, P, ls);
}
/* compute incoming direction and distance */
if(ls->t != FLT_MAX)
ls->D = normalize_len(ls->P - P, &ls->t);
}
__device float light_sample_pdf(KernelGlobals *kg, LightSample *ls, float3 I, float t)
{
float pdf;
if(ls->prim != ~0)
pdf = triangle_light_pdf(kg, ls->Ng, I, t);
else
pdf = regular_light_pdf(kg, ls->Ng, I, t);
return pdf;
}
__device int light_select_num_samples(KernelGlobals *kg, int index)
@@ -462,18 +600,26 @@ __device int light_select_num_samples(KernelGlobals *kg, int index)
return __float_as_int(data3.x);
}
__device void light_select(KernelGlobals *kg, int index, float randu, float randv, float3 P, LightSample *ls, float *pdf)
__device void light_select(KernelGlobals *kg, int index, float randu, float randv, float3 P, LightSample *ls)
{
regular_light_sample(kg, index, randu, randv, P, ls, pdf);
/* compute incoming direction and distance */
if(ls->t != FLT_MAX)
ls->D = normalize_len(ls->P - P, &ls->t);
lamp_light_sample(kg, index, randu, randv, P, ls);
}
__device float light_select_pdf(KernelGlobals *kg, LightSample *ls, float3 I, float t)
__device int lamp_light_eval_sample(KernelGlobals *kg, float randt)
{
return regular_light_pdf(kg, ls->Ng, I, t);
/* sample index */
int index = light_distribution_sample(kg, randt);
/* fetch light data */
float4 l = kernel_tex_fetch(__light_distribution, index);
int prim = __float_as_int(l.y);
if(prim < 0) {
int lamp = -prim-1;
return lamp;
}
else
return ~0;
}
CCL_NAMESPACE_END
+78 -16
View File
@@ -238,6 +238,9 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
float min_ray_pdf = FLT_MAX;
float ray_pdf = 0.0f;
#ifdef __LAMP_MIS__
float ray_t = 0.0f;
#endif
PathState state;
int rng_offset = PRNG_BASE_NUM;
@@ -248,8 +251,29 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
/* intersect scene */
Intersection isect;
uint visibility = path_state_ray_visibility(kg, &state);
bool hit = scene_intersect(kg, &ray, visibility, &isect);
if(!scene_intersect(kg, &ray, visibility, &isect)) {
#ifdef __LAMP_MIS__
if(kernel_data.integrator.pdf_lights > 0.0f && !(state.flag & PATH_RAY_CAMERA)) {
/* ray starting from previous non-transparent bounce */
Ray light_ray;
light_ray.P = ray.P - ray_t*ray.D;
ray_t += isect.t;
light_ray.D = ray.D;
light_ray.t = ray_t;
light_ray.time = ray.time;
/* intersect with lamp */
float light_t = path_rng(kg, rng, sample, rng_offset + PRNG_LIGHT);
float3 emission;
if(indirect_lamp_emission(kg, &light_ray, state.flag, ray_pdf, light_t, &emission))
path_radiance_accum_emission(&L, throughput, emission, state.bounce);
}
#endif
if(!hit) {
/* eval background shader if nothing hit */
if(kernel_data.background.transparent && (state.flag & PATH_RAY_CAMERA)) {
L_transparent += average(throughput);
@@ -313,7 +337,8 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
#ifdef __EMISSION__
/* emission */
if(sd.flag & SD_EMISSION) {
float3 emission = indirect_emission(kg, &sd, isect.t, state.flag, ray_pdf);
/* todo: is isect.t wrong here for transparent surfaces? */
float3 emission = indirect_primitive_emission(kg, &sd, isect.t, state.flag, ray_pdf);
path_radiance_accum_emission(&L, throughput, emission, state.bounce);
}
#endif
@@ -374,18 +399,19 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
Ray light_ray;
BsdfEval L_light;
bool is_lamp;
int lamp;
#ifdef __OBJECT_MOTION__
light_ray.time = sd.time;
#endif
if(direct_emission(kg, &sd, -1, light_t, light_o, light_u, light_v, &light_ray, &L_light, &is_lamp)) {
if(direct_emission(kg, &sd, -1, light_t, light_o, light_u, light_v, &light_ray, &L_light, &lamp)) {
/* trace shadow ray */
float3 shadow;
if(!shadow_blocked(kg, &state, &light_ray, &shadow)) {
/* accumulate */
bool is_lamp = (lamp != ~0);
path_radiance_accum_light(&L, throughput, &L_light, shadow, state.bounce, is_lamp);
}
}
@@ -422,6 +448,9 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
/* set labels */
if(!(label & LABEL_TRANSPARENT)) {
ray_pdf = bsdf_pdf;
#ifdef __LAMP_MIS__
ray_t = 0.0f;
#endif
min_ray_pdf = fminf(bsdf_pdf, min_ray_pdf);
}
@@ -457,15 +486,41 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
#ifdef __NON_PROGRESSIVE__
__device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray ray, __global float *buffer,
float3 throughput, float min_ray_pdf, float ray_pdf, PathState state, int rng_offset, PathRadiance *L)
float3 throughput, float throughput_normalize,
float min_ray_pdf, float ray_pdf, PathState state, int rng_offset, PathRadiance *L)
{
#ifdef __LAMP_MIS__
float ray_t = 0.0f;
#endif
/* path iteration */
for(;; rng_offset += PRNG_BOUNCE_NUM) {
/* intersect scene */
Intersection isect;
uint visibility = path_state_ray_visibility(kg, &state);
bool hit = scene_intersect(kg, &ray, visibility, &isect);
if(!scene_intersect(kg, &ray, visibility, &isect)) {
#ifdef __LAMP_MIS__
if(kernel_data.integrator.pdf_lights > 0.0f && !(state.flag & PATH_RAY_CAMERA)) {
/* ray starting from previous non-transparent bounce */
Ray light_ray;
light_ray.P = ray.P - ray_t*ray.D;
ray_t += isect.t;
light_ray.D = ray.D;
light_ray.t = ray_t;
light_ray.time = ray.time;
/* intersect with lamp */
float light_t = path_rng(kg, rng, sample, rng_offset + PRNG_LIGHT);
float3 emission;
if(indirect_lamp_emission(kg, &light_ray, state.flag, ray_pdf, light_t, &emission))
path_radiance_accum_emission(L, throughput, emission, state.bounce);
}
#endif
if(!hit) {
#ifdef __BACKGROUND__
/* sample background shader */
float3 L_background = indirect_background(kg, &ray, state.flag, ray_pdf);
@@ -496,7 +551,7 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray
#ifdef __EMISSION__
/* emission */
if(sd.flag & SD_EMISSION) {
float3 emission = indirect_emission(kg, &sd, isect.t, state.flag, ray_pdf);
float3 emission = indirect_primitive_emission(kg, &sd, isect.t, state.flag, ray_pdf);
path_radiance_accum_emission(L, throughput, emission, state.bounce);
}
#endif
@@ -504,7 +559,7 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray
/* path termination. this is a strange place to put the termination, it's
* mainly due to the mixed in MIS that we use. gives too many unneeded
* shader evaluations, only need emission if we are going to terminate */
float probability = path_state_terminate_probability(kg, &state, throughput);
float probability = path_state_terminate_probability(kg, &state, throughput*throughput_normalize);
float terminate = path_rng(kg, rng, sample, rng_offset + PRNG_TERMINATE);
if(terminate >= probability) {
@@ -557,19 +612,20 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray
Ray light_ray;
BsdfEval L_light;
bool is_lamp;
int lamp;
#ifdef __OBJECT_MOTION__
light_ray.time = sd.time;
#endif
/* sample random light */
if(direct_emission(kg, &sd, -1, light_t, light_o, light_u, light_v, &light_ray, &L_light, &is_lamp)) {
if(direct_emission(kg, &sd, -1, light_t, light_o, light_u, light_v, &light_ray, &L_light, &lamp)) {
/* trace shadow ray */
float3 shadow;
if(!shadow_blocked(kg, &state, &light_ray, &shadow)) {
/* accumulate */
bool is_lamp = (lamp != ~0);
path_radiance_accum_light(L, throughput, &L_light, shadow, state.bounce, is_lamp);
}
}
@@ -606,6 +662,9 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray
/* set labels */
if(!(label & LABEL_TRANSPARENT)) {
ray_pdf = bsdf_pdf;
#ifdef __LAMP_MIS__
ray_t = 0.0f;
#endif
min_ray_pdf = fminf(bsdf_pdf, min_ray_pdf);
}
@@ -697,7 +756,7 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam
#ifdef __EMISSION__
/* emission */
if(sd.flag & SD_EMISSION) {
float3 emission = indirect_emission(kg, &sd, isect.t, state.flag, ray_pdf);
float3 emission = indirect_primitive_emission(kg, &sd, isect.t, state.flag, ray_pdf);
path_radiance_accum_emission(&L, throughput, emission, state.bounce);
}
#endif
@@ -760,7 +819,7 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam
if(sd.flag & SD_BSDF_HAS_EVAL) {
Ray light_ray;
BsdfEval L_light;
bool is_lamp;
int lamp;
#ifdef __OBJECT_MOTION__
light_ray.time = sd.time;
@@ -778,12 +837,13 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam
float light_u = path_rng(kg, rng, sample*num_samples + j, rng_offset + PRNG_LIGHT_U);
float light_v = path_rng(kg, rng, sample*num_samples + j, rng_offset + PRNG_LIGHT_V);
if(direct_emission(kg, &sd, i, 0.0f, 0.0f, light_u, light_v, &light_ray, &L_light, &is_lamp)) {
if(direct_emission(kg, &sd, i, 0.0f, 0.0f, light_u, light_v, &light_ray, &L_light, &lamp)) {
/* trace shadow ray */
float3 shadow;
if(!shadow_blocked(kg, &state, &light_ray, &shadow)) {
/* accumulate */
bool is_lamp = (lamp != ~0);
path_radiance_accum_light(&L, throughput*num_samples_inv, &L_light, shadow, state.bounce, is_lamp);
}
}
@@ -807,12 +867,13 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam
if(kernel_data.integrator.num_all_lights)
light_t = 0.5f*light_t;
if(direct_emission(kg, &sd, -1, light_t, 0.0f, light_u, light_v, &light_ray, &L_light, &is_lamp)) {
if(direct_emission(kg, &sd, -1, light_t, 0.0f, light_u, light_v, &light_ray, &L_light, &lamp)) {
/* trace shadow ray */
float3 shadow;
if(!shadow_blocked(kg, &state, &light_ray, &shadow)) {
/* accumulate */
bool is_lamp = (lamp != ~0);
path_radiance_accum_light(&L, throughput*num_samples_inv, &L_light, shadow, state.bounce, is_lamp);
}
}
@@ -885,8 +946,9 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam
bsdf_ray.time = sd.time;
#endif
kernel_path_indirect(kg, rng, sample*num_samples, bsdf_ray, buffer,
tp*num_samples_inv, min_ray_pdf, bsdf_pdf, ps, rng_offset+PRNG_BOUNCE_NUM, &L);
kernel_path_indirect(kg, rng, sample*num_samples + j, bsdf_ray, buffer,
tp*num_samples_inv, num_samples,
min_ray_pdf, bsdf_pdf, ps, rng_offset+PRNG_BOUNCE_NUM, &L);
}
}
+4 -2
View File
@@ -48,6 +48,7 @@ CCL_NAMESPACE_BEGIN
#endif
#define __NON_PROGRESSIVE__
#define __HAIR__
#define __LAMP_MIS__
#endif
#ifdef __KERNEL_CUDA__
@@ -384,7 +385,7 @@ typedef enum AttributeStandard {
/* Closure data */
#define MAX_CLOSURE 8
#define MAX_CLOSURE 16
typedef struct ShaderClosure {
ClosureType type;
@@ -636,6 +637,7 @@ typedef struct KernelIntegrator {
int num_all_lights;
float pdf_triangles;
float pdf_lights;
float inv_pdf_lights;
int pdf_background_res;
/* bounces */
@@ -671,7 +673,7 @@ typedef struct KernelIntegrator {
int transmission_samples;
int ao_samples;
int mesh_light_samples;
int pad1, pad2;
int pad1;
} KernelIntegrator;
typedef struct KernelBVH {
@@ -605,7 +605,11 @@ bool OSLRenderServices::get_object_standard_attribute(KernelGlobals *kg, ShaderD
return set_attribute_int(3, type, derivatives, val);
}
else if ((name == u_geom_trianglevertices || name == u_geom_polyvertices)
#ifdef __HAIR__
&& sd->segment == ~0) {
#else
) {
#endif
float3 P[3];
triangle_vertices(kg, sd->prim, P);
@@ -675,7 +679,11 @@ bool OSLRenderServices::get_attribute(void *renderstate, bool derivatives, ustri
else {
object = sd->object;
prim = sd->prim;
#ifdef __HAIR__
segment = sd->segment;
#else
segment = ~0;
#endif
if (object == ~0)
return get_background_attribute(kg, sd, name, type, derivatives, val);
+5 -1
View File
@@ -457,7 +457,11 @@ float3 OSLShader::volume_eval_phase(const ShaderClosure *sc, const float3 omega_
int OSLShader::find_attribute(KernelGlobals *kg, const ShaderData *sd, uint id, AttributeElement *elem)
{
/* for OSL, a hash map is used to lookup the attribute by name. */
int object = sd->object*ATTR_PRIM_TYPES + (sd->segment != ~0);
int object = sd->object*ATTR_PRIM_TYPES;
#ifdef __HAIR__
if(sd->segment != ~0) object += ATTR_PRIM_CURVE;
#endif
OSLGlobals::AttributeMap &attr_map = kg->osl->attribute_map[object];
ustring stdname(std::string("geom:") + std::string(Attribute::standard_name((AttributeStandard)id)));
OSLGlobals::AttributeMap::const_iterator it = attr_map.find(stdname);
@@ -37,14 +37,14 @@ float noise_musgrave_fBm(point p, string basis, float H, float lacunarity, float
int i;
for (i = 0; i < (int)octaves; i++) {
value += noise("perlin", p) * pwr;
value += safe_noise(p) * pwr;
pwr *= pwHL;
p *= lacunarity;
}
rmd = octaves - floor(octaves);
if (rmd != 0.0)
value += rmd * noise("perlin", p) * pwr;
value += rmd * safe_noise(p) * pwr;
return value;
}
@@ -65,14 +65,14 @@ float noise_musgrave_multi_fractal(point p, string basis, float H, float lacunar
int i;
for (i = 0; i < (int)octaves; i++) {
value *= (pwr * noise("perlin", p) + 1.0);
value *= (pwr * safe_noise(p) + 1.0);
pwr *= pwHL;
p *= lacunarity;
}
rmd = octaves - floor(octaves);
if (rmd != 0.0)
value *= (rmd * pwr * noise("perlin", p) + 1.0); /* correct? */
value *= (rmd * pwr * safe_noise(p) + 1.0); /* correct? */
return value;
}
@@ -93,11 +93,11 @@ float noise_musgrave_hetero_terrain(point p, string basis, float H, float lacuna
int i;
/* first unscaled octave of function; later octaves are scaled */
value = offset + noise("perlin", p);
value = offset + safe_noise(p);
p *= lacunarity;
for (i = 1; i < (int)octaves; i++) {
increment = (noise("perlin", p) + offset) * pwr * value;
increment = (safe_noise(p) + offset) * pwr * value;
value += increment;
pwr *= pwHL;
p *= lacunarity;
@@ -105,7 +105,7 @@ float noise_musgrave_hetero_terrain(point p, string basis, float H, float lacuna
rmd = octaves - floor(octaves);
if (rmd != 0.0) {
increment = (noise("perlin", p) + offset) * pwr * value;
increment = (safe_noise(p) + offset) * pwr * value;
value += rmd * increment;
}
@@ -128,7 +128,7 @@ float noise_musgrave_hybrid_multi_fractal(point p, string basis, float H,
float pwr = pwHL;
int i;
result = noise("perlin", p) + offset;
result = safe_noise(p) + offset;
weight = gain * result;
p *= lacunarity;
@@ -136,7 +136,7 @@ float noise_musgrave_hybrid_multi_fractal(point p, string basis, float H,
if (weight > 1.0)
weight = 1.0;
signal = (noise("perlin", p) + offset) * pwr;
signal = (safe_noise(p) + offset) * pwr;
pwr *= pwHL;
result += weight * signal;
weight *= gain * signal;
@@ -145,7 +145,7 @@ float noise_musgrave_hybrid_multi_fractal(point p, string basis, float H,
rmd = octaves - floor(octaves);
if (rmd != 0.0)
result += rmd * ((noise("perlin", p) + offset) * pwr);
result += rmd * ((safe_noise(p) + offset) * pwr);
return result;
}
@@ -166,7 +166,7 @@ float noise_musgrave_ridged_multi_fractal(point p, string basis, float H,
float pwr = pwHL;
int i;
signal = offset - fabs(noise("perlin", p));
signal = offset - fabs(safe_noise(p));
signal *= signal;
result = signal;
weight = 1.0;
@@ -174,7 +174,7 @@ float noise_musgrave_ridged_multi_fractal(point p, string basis, float H,
for (i = 1; i < (int)octaves; i++) {
p *= lacunarity;
weight = clamp(signal * gain, 0.0, 1.0);
signal = offset - fabs(noise("perlin", p));
signal = offset - fabs(safe_noise(p));
signal *= signal;
signal *= weight;
result += signal * pwr;
+12 -1
View File
@@ -151,12 +151,23 @@ float voronoi_CrS(point p) { return 2.0 * voronoi_Cr(p) - 1.0; }
/* Noise Bases */
float safe_noise(point p)
{
float f = noise(p);
/* can happen for big coordinates, things even out to 0.5 then anyway */
if(!isfinite(f))
return 0.5;
return f;
}
float noise_basis(point p, string basis)
{
float result = 0.0;
if (basis == "Perlin")
result = noise(p); /* returns perlin noise in range 0..1 */
result = safe_noise(p); /* returns perlin noise in range 0..1 */
if (basis == "Voronoi F1")
result = voronoi_F1S(p);
if (basis == "Voronoi F2")
+10 -5
View File
@@ -84,9 +84,8 @@ __device uint phash(int kx, int ky, int kz, int3 p)
__device float floorfrac(float x, int* i)
{
float f = floorf(x);
*i = (int)f;
return x - f;
*i = quick_floor(x);
return x - *i;
}
__device float fade(float t)
@@ -133,7 +132,10 @@ __device_noinline float perlin(float x, float y, float z)
grad (hash (X+1, Y , Z+1), fx-1.0f, fy , fz-1.0f )),
nerp (u, grad (hash (X , Y+1, Z+1), fx , fy-1.0f, fz-1.0f ),
grad (hash (X+1, Y+1, Z+1), fx-1.0f, fy-1.0f, fz-1.0f ))));
return scale3(result);
float r = scale3(result);
/* can happen for big coordinates, things even out to 0.0 then anyway */
return (isfinite(r))? r: 0.0f;
}
__device_noinline float perlin_periodic(float x, float y, float z, float3 pperiod)
@@ -162,7 +164,10 @@ __device_noinline float perlin_periodic(float x, float y, float z, float3 pperio
grad (phash (X+1, Y , Z+1, p), fx-1.0f, fy , fz-1.0f )),
nerp (u, grad (phash (X , Y+1, Z+1, p), fx , fy-1.0f, fz-1.0f ),
grad (phash (X+1, Y+1, Z+1, p), fx-1.0f, fy-1.0f, fz-1.0f ))));
return scale3(result);
float r = scale3(result);
/* can happen for big coordinates, things even out to 0.0 then anyway */
return (isfinite(r))? r: 0.0f;
}
/* perlin noise in range 0..1 */
+22 -5
View File
@@ -323,6 +323,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
/* precompute pdfs */
kintegrator->pdf_triangles = 0.0f;
kintegrator->pdf_lights = 0.0f;
kintegrator->inv_pdf_lights = 0.0f;
/* sample one, with 0.5 probability of light or triangle */
kintegrator->num_all_lights = num_lights;
@@ -337,6 +338,8 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
kintegrator->pdf_lights = 1.0f/num_lights;
if(trianglearea > 0.0f)
kintegrator->pdf_lights *= 0.5f;
kintegrator->inv_pdf_lights = 1.0f/kintegrator->pdf_lights;
}
/* CDF */
@@ -349,6 +352,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
kintegrator->num_all_lights = 0;
kintegrator->pdf_triangles = 0.0f;
kintegrator->pdf_lights = 0.0f;
kintegrator->inv_pdf_lights = 0.0f;
}
}
@@ -475,16 +479,25 @@ void LightManager::device_update_points(Device *device, DeviceScene *dscene, Sce
if(light->type == LIGHT_POINT) {
shader_id &= ~SHADER_AREA_LIGHT;
float radius = light->size;
float invarea = (radius > 0.0f)? 1.0f/(M_PI_F*radius*radius): 1.0f;
light_data[i*LIGHT_SIZE + 0] = make_float4(__int_as_float(light->type), co.x, co.y, co.z);
light_data[i*LIGHT_SIZE + 1] = make_float4(__int_as_float(shader_id), light->size, 0.0f, 0.0f);
light_data[i*LIGHT_SIZE + 1] = make_float4(__int_as_float(shader_id), radius, invarea, 0.0f);
light_data[i*LIGHT_SIZE + 2] = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
light_data[i*LIGHT_SIZE + 3] = make_float4(samples, 0.0f, 0.0f, 0.0f);
}
else if(light->type == LIGHT_DISTANT) {
shader_id &= ~SHADER_AREA_LIGHT;
float radius = light->size;
float angle = atanf(radius);
float cosangle = cosf(angle);
float area = M_PI_F*radius*radius;
float invarea = (area > 0.0f)? 1.0f/area: 1.0f;
light_data[i*LIGHT_SIZE + 0] = make_float4(__int_as_float(light->type), dir.x, dir.y, dir.z);
light_data[i*LIGHT_SIZE + 1] = make_float4(__int_as_float(shader_id), light->size, 0.0f, 0.0f);
light_data[i*LIGHT_SIZE + 1] = make_float4(__int_as_float(shader_id), radius, cosangle, invarea);
light_data[i*LIGHT_SIZE + 2] = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
light_data[i*LIGHT_SIZE + 3] = make_float4(samples, 0.0f, 0.0f, 0.0f);
}
@@ -499,21 +512,25 @@ void LightManager::device_update_points(Device *device, DeviceScene *dscene, Sce
else if(light->type == LIGHT_AREA) {
float3 axisu = light->axisu*(light->sizeu*light->size);
float3 axisv = light->axisv*(light->sizev*light->size);
float area = len(axisu)*len(axisv);
float invarea = (area > 0.0f)? 1.0f/area: 0.0f;
light_data[i*LIGHT_SIZE + 0] = make_float4(__int_as_float(light->type), co.x, co.y, co.z);
light_data[i*LIGHT_SIZE + 1] = make_float4(__int_as_float(shader_id), axisu.x, axisu.y, axisu.z);
light_data[i*LIGHT_SIZE + 2] = make_float4(0.0f, axisv.x, axisv.y, axisv.z);
light_data[i*LIGHT_SIZE + 2] = make_float4(invarea, axisv.x, axisv.y, axisv.z);
light_data[i*LIGHT_SIZE + 3] = make_float4(samples, dir.x, dir.y, dir.z);
}
else if(light->type == LIGHT_SPOT) {
shader_id &= ~SHADER_AREA_LIGHT;
float radius = light->size;
float invarea = (radius > 0.0f)? 1.0f/(M_PI_F*radius*radius): 1.0f;
float spot_angle = cosf(light->spot_angle*0.5f);
float spot_smooth = (1.0f - spot_angle)*light->spot_smooth;
light_data[i*LIGHT_SIZE + 0] = make_float4(__int_as_float(light->type), co.x, co.y, co.z);
light_data[i*LIGHT_SIZE + 1] = make_float4(__int_as_float(shader_id), light->size, dir.x, dir.y);
light_data[i*LIGHT_SIZE + 2] = make_float4(dir.z, spot_angle, spot_smooth, 0.0f);
light_data[i*LIGHT_SIZE + 1] = make_float4(__int_as_float(shader_id), radius, invarea, spot_angle);
light_data[i*LIGHT_SIZE + 2] = make_float4(spot_smooth, dir.x, dir.y, dir.z);
light_data[i*LIGHT_SIZE + 3] = make_float4(samples, 0.0f, 0.0f, 0.0f);
}
}
+1 -1
View File
@@ -41,7 +41,7 @@ CCL_NAMESPACE_BEGIN
Session::Session(const SessionParams& params_)
: params(params_),
tile_manager(params.progressive, params.samples, params.tile_size, params.start_resolution,
params.background == false || params.progressive_refine, params.background,
params.background == false || params.progressive_refine, params.background, params.tile_order,
max(params.device.multi_devices.size(), 1)),
stats()
{
+1
View File
@@ -51,6 +51,7 @@ public:
bool experimental;
int samples;
int2 tile_size;
int tile_order;
int start_resolution;
int threads;
+50 -10
View File
@@ -24,10 +24,11 @@
CCL_NAMESPACE_BEGIN
TileManager::TileManager(bool progressive_, int num_samples_, int2 tile_size_, int start_resolution_,
bool preserve_tile_device_, bool background_, int num_devices_)
bool preserve_tile_device_, bool background_, int tile_order_, int num_devices_)
{
progressive = progressive_;
tile_size = tile_size_;
tile_order = tile_order_;
start_resolution = start_resolution_;
num_devices = num_devices_;
preserve_tile_device = preserve_tile_device_;
@@ -165,6 +166,20 @@ void TileManager::set_tiles()
state.buffer.full_height = max(1, params.full_height/resolution);
}
list<Tile>::iterator TileManager::next_viewport_tile(int device)
{
list<Tile>::iterator iter;
int logical_device = preserve_tile_device? device: 0;
for(iter = state.tiles.begin(); iter != state.tiles.end(); iter++) {
if(iter->device == logical_device && iter->rendering == false)
return iter;
}
return state.tiles.end();
}
list<Tile>::iterator TileManager::next_center_tile(int device)
{
list<Tile>::iterator iter, best = state.tiles.end();
@@ -210,28 +225,53 @@ list<Tile>::iterator TileManager::next_center_tile(int device)
return best;
}
list<Tile>::iterator TileManager::next_simple_tile(int device)
list<Tile>::iterator TileManager::next_simple_tile(int device, int tile_order)
{
list<Tile>::iterator iter;
list<Tile>::iterator iter, best = state.tiles.end();
int resolution = state.resolution_divider;
int logical_device = preserve_tile_device? device: 0;
int64_t cordx = max(1, params.width/resolution);
int64_t cordy = max(1, params.height/resolution);
int64_t mindist = cordx * cordy;
for(iter = state.tiles.begin(); iter != state.tiles.end(); iter++) {
if(iter->device == logical_device && iter->rendering == false)
return iter;
if(iter->device == logical_device && iter->rendering == false) {
Tile &cur_tile = *iter;
int64_t distx = cordx;
if (tile_order == TileManager::RIGHT_TO_LEFT)
distx = cordx - cur_tile.x;
else if (tile_order == TileManager::LEFT_TO_RIGHT)
distx = cordx + cur_tile.x;
else if (tile_order == TileManager::TOP_TO_BOTTOM)
distx = cordx - cur_tile.y;
else /* TileManager::BOTTOM_TO_TOP */
distx = cordx + cur_tile.y;
if(distx < mindist) {
best = iter;
mindist = distx;
}
}
}
return state.tiles.end();
return best;
}
bool TileManager::next_tile(Tile& tile, int device)
{
list<Tile>::iterator tile_it;
if(background)
tile_it = next_center_tile(device);
if (background) {
if(tile_order == TileManager::CENTER)
tile_it = next_center_tile(device);
else
tile_it = next_simple_tile(device, tile_order);
}
else
tile_it = next_simple_tile(device);
tile_it = next_viewport_tile(device);
if(tile_it != state.tiles.end()) {
tile_it->rendering = true;
+17 -3
View File
@@ -59,7 +59,7 @@ public:
} state;
TileManager(bool progressive, int num_samples, int2 tile_size, int start_resolution,
bool preserve_tile_device, bool background, int num_devices = 1);
bool preserve_tile_device, bool background, int tile_order, int num_devices = 1);
~TileManager();
void reset(BufferParams& params, int num_samples);
@@ -68,12 +68,23 @@ public:
bool next_tile(Tile& tile, int device = 0);
bool done();
void set_tile_order(int tile_order_) { tile_order = tile_order_; }
protected:
/* Note: this should match enum_tile_order in properties.py */
enum {
CENTER = 0,
RIGHT_TO_LEFT = 1,
LEFT_TO_RIGHT = 2,
TOP_TO_BOTTOM = 3,
BOTTOM_TO_TOP = 4
} TileOrder;
void set_tiles();
bool progressive;
int num_samples;
int2 tile_size;
int tile_order;
int start_resolution;
int num_devices;
@@ -106,9 +117,12 @@ protected:
* mimics behavior of blender internal's tile order
*/
list<Tile>::iterator next_center_tile(int device);
/* returns simple tile order */
list<Tile>::iterator next_simple_tile(int device, int tile_order);
/* returns first unhandled tile starting from left bottom corner of the image */
list<Tile>::iterator next_simple_tile(int device);
/* returns first unhandled tile (for viewport) */
list<Tile>::iterator next_viewport_tile(int device);
};
CCL_NAMESPACE_END
+124
View File
@@ -1161,6 +1161,130 @@ __device float safe_divide(float a, float b)
return result;
}
/* Ray Intersection */
__device bool ray_sphere_intersect(
float3 ray_P, float3 ray_D, float ray_t,
float3 sphere_P, float sphere_radius,
float3 *isect_P, float *isect_t)
{
float3 d = sphere_P - ray_P;
float radiussq = sphere_radius*sphere_radius;
float tsq = dot(d, d);
if(tsq > radiussq) { /* ray origin outside sphere */
float tp = dot(d, ray_D);
if(tp < 0.0f) /* dir points away from sphere */
return false;
float dsq = tsq - tp*tp; /* pythagoras */
if(dsq > radiussq) /* closest point on ray outside sphere */
return false;
float t = tp - sqrtf(radiussq - dsq); /* pythagoras */
if(t < ray_t) {
*isect_t = t;
*isect_P = ray_P + ray_D*t;
return true;
}
}
return false;
}
__device bool ray_aligned_disk_intersect(
float3 ray_P, float3 ray_D, float ray_t,
float3 disk_P, float disk_radius,
float3 *isect_P, float *isect_t)
{
/* aligned disk normal */
float disk_t;
float3 disk_N = normalize_len(ray_P - disk_P, &disk_t);
float div = dot(ray_D, disk_N);
if(div == 0.0f)
return false;
/* compute t to intersection point */
float t = -disk_t/div;
if(t < 0.0f || t > ray_t)
return false;
/* test if within radius */
float3 P = ray_P + ray_D*t;
if(len_squared(P - disk_P) > disk_radius*disk_radius)
return false;
*isect_P = P;
*isect_t = t;
return true;
}
__device bool ray_triangle_intersect(
float3 ray_P, float3 ray_D, float ray_t,
float3 v0, float3 v1, float3 v2,
float3 *isect_P, float *isect_t)
{
/* Calculate intersection */
float3 e1 = v1 - v0;
float3 e2 = v2 - v0;
float3 s1 = cross(ray_D, e2);
const float divisor = dot(s1, e1);
if(divisor == 0.0f)
return false;
const float invdivisor = 1.0f/divisor;
/* compute first barycentric coordinate */
const float3 d = ray_P - v0;
const float u = dot(d, s1)*invdivisor;
if(u < 0.0f)
return false;
/* Compute second barycentric coordinate */
const float3 s2 = cross(d, e1);
const float v = dot(ray_D, s2)*invdivisor;
if(v < 0.0f)
return false;
const float b0 = 1.0f - u - v;
if(b0 < 0.0f)
return false;
/* compute t to intersection point */
const float t = dot(e2, s2)*invdivisor;
if(t < 0.0f || t > ray_t)
return false;
*isect_t = t;
*isect_P = ray_P + ray_D*t;
return true;
}
__device bool ray_quad_intersect(
float3 ray_P, float3 ray_D, float ray_t,
float3 quad_P, float3 quad_u, float3 quad_v,
float3 *isect_P, float *isect_t)
{
float3 v0 = quad_P - quad_u*0.5f - quad_v*0.5f;
float3 v1 = quad_P + quad_u*0.5f - quad_v*0.5f;
float3 v2 = quad_P + quad_u*0.5f + quad_v*0.5f;
float3 v3 = quad_P - quad_u*0.5f + quad_v*0.5f;
if(ray_triangle_intersect(ray_P, ray_D, ray_t, v0, v1, v2, isect_P, isect_t))
return true;
else if(ray_triangle_intersect(ray_P, ray_D, ray_t, v0, v2, v3, isect_P, isect_t))
return true;
return false;
}
CCL_NAMESPACE_END
#endif /* __UTIL_MATH_H__ */
+37 -14
View File
@@ -574,13 +574,7 @@ GHOST_SystemCocoa::GHOST_SystemCocoa()
rstring = (char*)malloc( len );
sysctl( mib, 2, rstring, &len, NULL, 0 );
//Hack on MacBook revision, as multitouch avail. function missing
//MacbookAir or MacBook version >= 5 (retina is MacBookPro10,1)
if (strstr(rstring,"MacBookAir") ||
(strstr(rstring,"MacBook") && (rstring[strlen(rstring)-3]>='5') && (rstring[strlen(rstring)-3]<='9')) ||
(strstr(rstring,"MacBook") && (rstring[strlen(rstring)-4]>='1') && (rstring[strlen(rstring)-4]<='9')))
m_hasMultiTouchTrackpad = true;
else m_hasMultiTouchTrackpad = false;
m_hasMultiTouchTrackpad = false;
free( rstring );
rstring = NULL;
@@ -1445,6 +1439,27 @@ bool GHOST_SystemCocoa::handleTabletEvent(void *eventPtr)
}
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
enum {
NSEventPhaseNone = 0,
NSEventPhaseBegan = 0x1 << 0,
NSEventPhaseStationary = 0x1 << 1,
NSEventPhaseChanged = 0x1 << 2,
NSEventPhaseEnded = 0x1 << 3,
NSEventPhaseCancelled = 0x1 << 4,
};
typedef NSUInteger NSEventPhase;
@interface NSEvent (AvailableOn1070AndLater)
- (BOOL)hasPreciseScrollingDeltas;
- (CGFloat)scrollingDeltaX;
- (CGFloat)scrollingDeltaY;
- (NSEventPhase)momentumPhase;
- (BOOL)isDirectionInvertedFromDevice;
- (NSEventPhase)phase;
@end
#endif
GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
{
NSEvent *event = (NSEvent *)eventPtr;
@@ -1577,15 +1592,23 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
}
break;
/* these events only happen on swiping trackpads */
case NSEventTypeBeginGesture:
m_hasMultiTouchTrackpad = 1;
break;
case NSEventTypeEndGesture:
m_hasMultiTouchTrackpad = 0;
break;
case NSScrollWheel:
{
int momentum = 0;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
m_hasMultiTouchTrackpad = 0;
momentum = [event momentumPhase] || [event phase];
#endif
/* standard scrollwheel case */
if (!m_hasMultiTouchTrackpad && momentum == 0) {
int *momentum = NULL;
if ([event respondsToSelector:@selector(momentumPhase)])
momentum = (int *)[event momentumPhase];
/* standard scrollwheel case, if no swiping happened, and no momentum (kinetic scroll) works */
if (!m_hasMultiTouchTrackpad && momentum == NULL) {
GHOST_TInt32 delta;
double deltaF = [event deltaY];
@@ -761,6 +761,7 @@ GHOST_Event *GHOST_SystemWin32::processWindowEvent(GHOST_TEventType type, GHOST_
if (type == GHOST_kEventWindowActivate) {
system->getWindowManager()->setActiveWindow(window);
((GHOST_WindowWin32*)window)->bringTabletContextToFront();
}
return new GHOST_Event(system->getMilliSeconds(), type, window);
+2 -2
View File
@@ -132,7 +132,7 @@ GHOST_SystemX11(
GHOST_ASSERT(false, "Could not instantiate timer!");
}
/* Taking care not to overflow the tv.tv_sec*1000 */
/* Taking care not to overflow the tv.tv_sec * 1000 */
m_start_time = GHOST_TUns64(tv.tv_sec) * 1000 + tv.tv_usec / 1000;
@@ -190,7 +190,7 @@ getMilliSeconds() const
GHOST_ASSERT(false, "Could not compute time!");
}
/* Taking care not to overflow the tv.tv_sec*1000 */
/* Taking care not to overflow the tv.tv_sec * 1000 */
return GHOST_TUns64(tv.tv_sec) * 1000 + tv.tv_usec / 1000 - m_start_time;
}
+15 -5
View File
@@ -428,6 +428,14 @@ extern "C" {
#pragma mark initialization / finalization
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
@interface NSView (NSOpenGLSurfaceResolution)
- (BOOL)wantsBestResolutionOpenGLSurface;
- (void)setWantsBestResolutionOpenGLSurface:(BOOL)flag;
- (NSRect)convertRectToBacking:(NSRect)bounds;
@end
#endif
NSOpenGLContext* GHOST_WindowCocoa::s_firstOpenGLcontext = nil;
GHOST_WindowCocoa::GHOST_WindowCocoa(
@@ -579,13 +587,15 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
setDrawingContextType(type);
updateDrawingContext();
activateDrawingContext();
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 // retina support started with 10.7.4 afaik
if (m_systemCocoa->m_nativePixel) {
[m_openGLView setWantsBestResolutionOpenGLSurface:YES];
NSRect backingBounds = [m_openGLView convertRectToBacking:[m_openGLView bounds]];
m_systemCocoa->m_nativePixelSize = (float)backingBounds.size.width / (float)rect.size.width;
if ([m_openGLView respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) {
[m_openGLView setWantsBestResolutionOpenGLSurface:YES];
NSRect backingBounds = [m_openGLView convertRectToBacking:[m_openGLView bounds]];
m_systemCocoa->m_nativePixelSize = (float)backingBounds.size.width / (float)rect.size.width;
}
}
#endif
m_tablet.Active = GHOST_kTabletModeNone;
+10
View File
@@ -1192,6 +1192,16 @@ void GHOST_WindowWin32::processWin32TabletEvent(WPARAM wParam, LPARAM lParam)
}
}
void GHOST_WindowWin32::bringTabletContextToFront()
{
if (m_wintab) {
GHOST_WIN32_WTOverlap fpWTOverlap = (GHOST_WIN32_WTOverlap) ::GetProcAddress(m_wintab, "WTOverlap");
if (fpWTOverlap) {
fpWTOverlap(m_tablet, TRUE);
}
}
}
/** Reverse the bits in a GHOST_TUns8 */
static GHOST_TUns8 uns8ReverseBits(GHOST_TUns8 ch)
{
+2
View File
@@ -58,6 +58,7 @@ typedef UINT (API * GHOST_WIN32_WTInfo)(UINT, UINT, LPVOID);
typedef HCTX (API * GHOST_WIN32_WTOpen)(HWND, LPLOGCONTEXTA, BOOL);
typedef BOOL (API * GHOST_WIN32_WTClose)(HCTX);
typedef BOOL (API * GHOST_WIN32_WTPacket)(HCTX, UINT, LPVOID);
typedef BOOL (API * GHOST_WIN32_WTOverlap)(HCTX, BOOL);
/**
* GHOST window on M$ Windows OSs.
@@ -273,6 +274,7 @@ public:
void processWin32TabletInitEvent();
void processWin32TabletEvent(WPARAM wParam, LPARAM lParam);
void bringTabletContextToFront();
protected:
GHOST_TSuccess initMultisample(PIXELFORMATDESCRIPTOR pfd);
+1 -1
View File
@@ -331,7 +331,7 @@ void FallbackImpl::displayTransformRelease(OCIO_DisplayTransformRcPtr *)
}
OCIO_PackedImageDesc *FallbackImpl::createOCIO_PackedImageDesc(float *data, long width, long height, long numChannels,
long chanStrideBytes, long xStrideBytes, long yStrideBytes)
long chanStrideBytes, long xStrideBytes, long yStrideBytes)
{
OCIO_PackedImageDescription *desc = (OCIO_PackedImageDescription*)MEM_callocN(sizeof(OCIO_PackedImageDescription), "OCIO_PackedImageDescription");
+2 -2
View File
@@ -238,12 +238,12 @@ void OCIO_displayTransformRelease(OCIO_DisplayTransformRcPtr *dt)
}
OCIO_PackedImageDesc *OCIO_createOCIO_PackedImageDesc(float *data, long width, long height, long numChannels,
long chanStrideBytes, long xStrideBytes, long yStrideBytes)
long chanStrideBytes, long xStrideBytes, long yStrideBytes)
{
return impl->createOCIO_PackedImageDesc(data, width, height, numChannels, chanStrideBytes, xStrideBytes, yStrideBytes);
}
void OCIO_OCIO_PackedImageDescRelease(OCIO_PackedImageDesc* id)
void OCIO_PackedImageDescRelease(OCIO_PackedImageDesc* id)
{
impl->OCIO_PackedImageDescRelease(id);
}
+2 -2
View File
@@ -105,9 +105,9 @@ void OCIO_displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt, OCIO_Const
void OCIO_displayTransformRelease(OCIO_DisplayTransformRcPtr *dt);
OCIO_PackedImageDesc *OCIO_createOCIO_PackedImageDesc(float *data, long width, long height, long numChannels,
long chanStrideBytes, long xStrideBytes, long yStrideBytes);
long chanStrideBytes, long xStrideBytes, long yStrideBytes);
void OCIO_OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *p);
void OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *p);
OCIO_ExponentTransformRcPtr *OCIO_createExponentTransform(void);
void OCIO_exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et, const float *exponent);
+1 -1
View File
@@ -479,7 +479,7 @@ void OCIOImpl::displayTransformRelease(OCIO_DisplayTransformRcPtr *dt)
}
OCIO_PackedImageDesc *OCIOImpl::createOCIO_PackedImageDesc(float *data, long width, long height, long numChannels,
long chanStrideBytes, long xStrideBytes, long yStrideBytes)
long chanStrideBytes, long xStrideBytes, long yStrideBytes)
{
try {
void *mem = MEM_mallocN(sizeof(PackedImageDesc), __func__);
Binary file not shown.
@@ -49,8 +49,13 @@ def extend(obj, operator, EXTEND_MODE):
# our own local walker
def walk_face_init(faces, f_act):
# first tag all faces True (so we dont uvmap them)
for f in bm.faces:
f.tag = True
# then tag faces arg False
for f in faces:
f.tag = False
# tag the active face True since we begin there
f_act.tag = True
def walk_face(f):
+1 -1
View File
@@ -44,7 +44,7 @@ class MESH_OT_delete_edgeloop(Operator):
mesh = context.object.data
use_mirror_x = mesh.use_mirror_x
mesh.use_mirror_x = False
if 'FINISHED' in bpy.ops.transform.edge_slide(value=1.0):
if 'FINISHED' in bpy.ops.transform.edge_slide(value=1.0, correct_uv=True):
bpy.ops.mesh.select_more()
bpy.ops.mesh.remove_doubles()
ret = {'FINISHED'}
@@ -330,7 +330,7 @@ class DATA_PT_uv_texture(MeshButtonsPanel, Panel):
row = layout.row()
col = row.column()
col.template_list("MESH_UL_uvmaps_vcols", "", me, "uv_textures", me.uv_textures, "active_index", rows=2)
col.template_list("MESH_UL_uvmaps_vcols", "uvmaps", me, "uv_textures", me.uv_textures, "active_index", rows=2)
col = row.column(align=True)
col.operator("mesh.uv_texture_add", icon='ZOOMIN', text="")
@@ -353,7 +353,7 @@ class DATA_PT_vertex_colors(MeshButtonsPanel, Panel):
row = layout.row()
col = row.column()
col.template_list("MESH_UL_uvmaps_vcols", "", me, "vertex_colors", me.vertex_colors, "active_index", rows=2)
col.template_list("MESH_UL_uvmaps_vcols", "vcols", me, "vertex_colors", me.vertex_colors, "active_index", rows=2)
col = row.column(align=True)
col.operator("mesh.vertex_color_add", icon='ZOOMIN', text="")
@@ -372,17 +372,20 @@ class DATA_PT_customdata(MeshButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
# me = context.mesh
obj = context.object
me = context.mesh
col = layout.column()
# sticky has no UI access since 2.49 - we may remove
'''
row = col.row(align=True)
row.operator("mesh.customdata_create_sticky")
row.operator("mesh.customdata_clear_sticky", icon='X')
'''
col.operator("mesh.customdata_clear_mask", icon='X')
col.operator("mesh.customdata_clear_skin", icon='X')
col = layout.column()
col.enabled = (obj.mode != 'EDIT')
col.prop(me, "use_customdata_vertex_bevel")
col.prop(me, "use_customdata_edge_bevel")
col.prop(me, "use_customdata_edge_crease")
class DATA_PT_custom_props_mesh(MeshButtonsPanel, PropertyPanel, Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@@ -289,6 +289,9 @@ class OBJECT_PT_relations_extras(ObjectButtonsPanel, Panel):
row.active = ((ob.parent is not None) and (ob.use_slow_parent))
row.prop(ob, "slow_parent_offset", text="Offset")
layout.prop(ob, "extra_recalc_object")
layout.prop(ob, "extra_recalc_data")
from bl_ui.properties_animviz import (MotionPathButtonsPanel,
OnionSkinButtonsPanel)
@@ -64,7 +64,7 @@ class TEXTURE_UL_texslots(UIList):
tex = slot.texture if slot else None
if self.layout_type in {'DEFAULT', 'COMPACT'}:
layout.label(tex.name if tex else "", icon_value=icon)
if tex:
if tex and isinstance(item, bpy.types.MaterialTextureSlot):
layout.prop(ma, "use_textures", text="", index=index)
elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'
@@ -200,7 +200,7 @@ class USERPREF_PT_interface(Panel):
col.prop(view, "show_playback_fps", text="Playback FPS")
col.prop(view, "use_global_scene")
col.prop(view, "object_origin_size")
col.separator()
col.separator()
col.separator()
@@ -1120,11 +1120,11 @@ class VIEW3D_PT_tools_projectpaint(View3DPanel, Panel):
row.menu("VIEW3D_MT_tools_projectpaint_stencil", text=stencil_text)
row.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA')
row = layout.row()
row.active = (settings.brush.image_tool == 'CLONE')
row.prop(ipaint, "use_clone_layer", text="Clone")
col = layout.column()
col.active = (settings.brush.image_tool == 'CLONE')
col.prop(ipaint, "use_clone_layer", text="Clone from UV map")
clone_text = mesh.uv_texture_clone.name if mesh.uv_texture_clone else ""
row.menu("VIEW3D_MT_tools_projectpaint_clone", text=clone_text)
col.menu("VIEW3D_MT_tools_projectpaint_clone", text=clone_text)
layout.prop(ipaint, "seam_bleed")
+4 -5
View File
@@ -83,7 +83,7 @@ GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font)
memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table));
memset(gc->bucket, 0, sizeof(gc->bucket));
gc->textures = (GLuint *)malloc(sizeof(GLuint) * 256);
gc->textures = (GLuint *)MEM_mallocN(sizeof(GLuint) * 256, __func__);
gc->ntex = 256;
gc->cur_tex = -1;
gc->x_offs = 0;
@@ -150,7 +150,7 @@ void blf_glyph_cache_free(GlyphCacheBLF *gc)
if (gc->cur_tex + 1 > 0)
glDeleteTextures(gc->cur_tex + 1, gc->textures);
free((void *)gc->textures);
MEM_freeN((void *)gc->textures);
MEM_freeN(gc);
}
@@ -178,8 +178,7 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc)
gc->p2_height = font->max_tex_size;
tot_mem = gc->p2_width * gc->p2_height;
buf = (unsigned char *)malloc(tot_mem);
memset((void *)buf, 0, tot_mem);
buf = (unsigned char *)MEM_callocN(tot_mem, __func__);
glGenTextures(1, &gc->textures[gc->cur_tex]);
glBindTexture(GL_TEXTURE_2D, (font->tex_bind_state = gc->textures[gc->cur_tex]));
@@ -189,7 +188,7 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, gc->p2_width, gc->p2_height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, buf);
free((void *)buf);
MEM_freeN((void *)buf);
}
GlyphBLF *blf_glyph_search(GlyphCacheBLF *gc, unsigned int c)
@@ -173,6 +173,9 @@ struct DerivedMesh {
float auto_bump_scale;
DMDirtyFlag dirty;
/* use for converting to BMesh which doesn't store bevel weight and edge crease by default */
char cd_flag;
/** Calculate vert and face normals */
void (*calcNormals)(DerivedMesh *dm);
+1 -1
View File
@@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 265
#define BLENDER_SUBVERSION 5
#define BLENDER_SUBVERSION 8
/* 262 was the last editmesh release but it has compatibility code for bmesh data */
#define BLENDER_MINVERSION 262
@@ -63,14 +63,12 @@ DerivedMesh *CDDM_from_editbmesh(struct BMEditMesh *em, int use_mdisps, int use_
/* merge verts */
DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap);
DerivedMesh *CDDM_from_curve_orco(struct Scene *scene, struct Object *ob);
/* creates a CDDerivedMesh from the given curve object */
struct DerivedMesh *CDDM_from_curve(struct Object *ob);
/* creates a CDDerivedMesh from the given curve object and specified dispbase */
/* useful for OrcoDM creation for curves with constructive modifiers */
DerivedMesh *CDDM_from_curve_displist(struct Object *ob, struct ListBase *dispbase, int **orco_index_ptr);
DerivedMesh *CDDM_from_curve_displist(struct Object *ob, struct ListBase *dispbase);
/* Copies the given DerivedMesh with verts, faces & edges stored as
* custom element data.
+6 -1
View File
@@ -39,6 +39,7 @@ extern "C" {
#endif
#include "../blenloader/BLO_sys_types.h" /* XXX, should have a more generic include for this */
#include "BLI_utildefines.h"
struct BMesh;
struct ID;
@@ -215,6 +216,8 @@ void CustomData_free_elem(struct CustomData *data, int index, int count);
void CustomData_interp(const struct CustomData *source, struct CustomData *dest,
int *src_indices, float *weights, float *sub_weights,
int count, int dest_index);
void CustomData_bmesh_interp_n(struct CustomData *data, void **src_blocks, const float *weights,
const float *sub_weights, int count, void *dest_block, int n);
void CustomData_bmesh_interp(struct CustomData *data, void **src_blocks,
const float *weights, const float *sub_weights, int count,
void *dest_block);
@@ -246,6 +249,8 @@ void *CustomData_get_layer(const struct CustomData *data, int type);
void *CustomData_get_layer_n(const struct CustomData *data, int type, int n);
void *CustomData_get_layer_named(const struct CustomData *data, int type,
const char *name);
int CustomData_get_offset(const struct CustomData *data, int type);
int CustomData_get_n_offset(const struct CustomData *data, int type, int n);
int CustomData_get_layer_index(const struct CustomData *data, int type);
int CustomData_get_layer_index_n(const struct CustomData *data, int type, int n);
@@ -304,7 +309,7 @@ void CustomData_bmesh_free_block(struct CustomData *data, void **block);
/* copy custom data to/from layers as in mesh/derivedmesh, to editmesh
* blocks of data. the CustomData's must not be compatible */
void CustomData_to_bmesh_block(const struct CustomData *source,
struct CustomData *dest, int src_index, void **dest_block);
struct CustomData *dest, int src_index, void **dest_block, bool use_default_init);
void CustomData_from_bmesh_block(const struct CustomData *source,
struct CustomData *dest, void *src_block, int dest_index);
+1 -1
View File
@@ -96,7 +96,7 @@ typedef struct Main {
} Main;
#define MAIN_VERSION_ATLEAST(main, ver, subver) \
((main)->versionfile >= (ver) || (main->versionfile == (ver) && (main)->subversionfile >= (subver)))
((main)->versionfile > (ver) || (main->versionfile == (ver) && (main)->subversionfile >= (subver)))
#ifdef __cplusplus
}
+4 -6
View File
@@ -154,13 +154,9 @@ int BKE_mesh_nurbs_to_mdata(struct Object *ob, struct MVert **allvert, int *tot
int *totloop, int *totpoly);
int BKE_mesh_nurbs_displist_to_mdata(struct Object *ob, struct ListBase *dispbase, struct MVert **allvert, int *_totvert,
struct MEdge **alledge, int *_totedge, struct MLoop **allloop, struct MPoly **allpoly,
int *_totloop, int *_totpoly, int **orco_index_ptr);
void BKE_mesh_nurbs_to_mdata_orco(struct MPoly *mpoly, int totpoly,
struct MLoop *mloops, struct MLoopUV *mloopuvs,
float (*orco)[3], int (*orco_index)[4]);
struct MLoopUV **alluv, int *_totloop, int *_totpoly);
void BKE_mesh_from_nurbs_displist(struct Object *ob, struct ListBase *dispbase, int use_orco_uv);
void BKE_mesh_from_nurbs(struct Object *ob);
void BKE_mesh_from_nurbs_displist(struct Object *ob, struct ListBase *dispbase,
int **orco_index_ptr);
void BKE_mesh_from_curve(struct Scene *scene, struct Object *ob);
void BKE_mesh_delete_material_index(struct Mesh *me, short index);
void BKE_mesh_smooth_flag_set(struct Object *meshOb, int enableSmooth);
@@ -334,6 +330,8 @@ void BKE_mesh_loops_to_mface_corners(struct CustomData *fdata, struct CustomData
void BKE_mesh_poly_calc_angles(struct MVert *mvert, struct MLoop *mloop,
struct MPoly *mp, float angles[]);
void BKE_mesh_do_versions_cd_flag_init(struct Mesh *mesh);
#ifdef __cplusplus
}
#endif
+5 -1
View File
@@ -35,6 +35,7 @@ extern "C" {
#endif
#include "DNA_windowmanager_types.h"
#include "BLI_utildefines.h"
/* Reporting Information and Errors
*
@@ -72,7 +73,10 @@ void BKE_reports_print(ReportList *reports, ReportType level);
Report *BKE_reports_last_displayable(ReportList *reports);
int BKE_reports_contain(ReportList *reports, ReportType level);
bool BKE_report_write_file_fp(FILE *fp, ReportList *reports, const char *header);
bool BKE_report_write_file(const char *filepath, ReportList *reports, const char *header);
#ifdef __cplusplus
}
#endif
@@ -313,6 +313,8 @@ void DM_from_template(DerivedMesh *dm, DerivedMesh *source, DerivedMeshType type
CustomData_copy(&source->polyData, &dm->polyData, CD_MASK_DERIVEDMESH,
CD_CALLOC, numPolys);
dm->cd_flag = source->cd_flag;
dm->type = type;
dm->numVertData = numVerts;
dm->numEdgeData = numEdges;
@@ -483,11 +485,13 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob)
totedge = tmp.totedge = dm->getNumEdges(dm);
totloop = tmp.totloop = dm->getNumLoops(dm);
totpoly = tmp.totpoly = dm->getNumPolys(dm);
tmp.totface = 0;
CustomData_copy(&dm->vertData, &tmp.vdata, CD_MASK_MESH, CD_DUPLICATE, totvert);
CustomData_copy(&dm->edgeData, &tmp.edata, CD_MASK_MESH, CD_DUPLICATE, totedge);
CustomData_copy(&dm->loopData, &tmp.ldata, CD_MASK_MESH, CD_DUPLICATE, totloop);
CustomData_copy(&dm->polyData, &tmp.pdata, CD_MASK_MESH, CD_DUPLICATE, totpoly);
me->cd_flag = dm->cd_flag;
if (CustomData_has_layer(&dm->vertData, CD_SHAPEKEY)) {
KeyBlock *kb;
@@ -538,9 +542,10 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob)
}
/* yes, must be before _and_ after tessellate */
mesh_update_customdata_pointers(&tmp, TRUE);
mesh_update_customdata_pointers(&tmp, false);
BKE_mesh_tessface_calc(&tmp);
/* since 2.65 caller must do! */
// BKE_mesh_tessface_calc(&tmp);
CustomData_free(&me->vdata, me->totvert);
CustomData_free(&me->edata, me->totedge);
@@ -647,6 +647,23 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
index_mp_to_orig = NULL;
}
/* TODO: not entirely correct, but currently dynamic topology will
* destroy UVs anyway, so textured display wouldn't work anyway
*
* this will do more like solid view with lights set up for
* textured view, but object itself will be displayed gray
* (the same as it'll display without UV maps in textured view)
*/
if (cddm->pbvh && cddm->pbvh_draw && BKE_pbvh_type(cddm->pbvh) == PBVH_BMESH) {
if (dm->numTessFaceData) {
glDisable(GL_TEXTURE_2D);
BKE_pbvh_draw(cddm->pbvh, NULL, NULL, NULL, FALSE);
glEnable(GL_TEXTURE_2D);
}
return;
}
colType = CD_TEXTURE_MCOL;
mcol = dm->getTessFaceDataArray(dm, colType);
if (!mcol) {
@@ -1726,6 +1743,7 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *UNUSED(ob))
mesh->totloop, mesh->totpoly);
dm->deformedOnly = 1;
dm->cd_flag = mesh->cd_flag;
alloctype = CD_REFERENCE;
@@ -1757,49 +1775,10 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *UNUSED(ob))
DerivedMesh *CDDM_from_curve(Object *ob)
{
return CDDM_from_curve_displist(ob, &ob->disp, NULL);
return CDDM_from_curve_displist(ob, &ob->disp);
}
DerivedMesh *CDDM_from_curve_orco(struct Scene *scene, Object *ob)
{
int *orco_index_ptr = NULL;
int (*orco_index)[4] = NULL;
float (*orco)[3] = NULL;
DerivedMesh *dm = CDDM_from_curve_displist(ob, &ob->disp, &orco_index_ptr);
if (orco_index_ptr) {
orco = (float (*)[3])BKE_curve_make_orco(scene, ob);
}
if (orco && orco_index_ptr) {
const char *uvname = "Orco";
int totpoly = dm->getNumPolys(dm);
MPoly *mpolys = dm->getPolyArray(dm);
MLoop *mloops = dm->getLoopArray(dm);
MLoopUV *mloopuvs;
CustomData_add_layer_named(&dm->polyData, CD_MTEXPOLY, CD_DEFAULT, NULL, dm->numPolyData, uvname);
mloopuvs = CustomData_add_layer_named(&dm->loopData, CD_MLOOPUV, CD_DEFAULT, NULL, dm->numLoopData, uvname);
BKE_mesh_nurbs_to_mdata_orco(mpolys, totpoly,
mloops, mloopuvs,
orco, orco_index);
}
if (orco_index) {
MEM_freeN(orco_index);
}
if (orco) {
MEM_freeN(orco);
}
return dm;
}
DerivedMesh *CDDM_from_curve_displist(Object *ob, ListBase *dispbase, int **orco_index_ptr)
DerivedMesh *CDDM_from_curve_displist(Object *ob, ListBase *dispbase)
{
DerivedMesh *dm;
CDDerivedMesh *cddm;
@@ -1810,7 +1789,8 @@ DerivedMesh *CDDM_from_curve_displist(Object *ob, ListBase *dispbase, int **orco
int totvert, totedge, totloop, totpoly;
if (BKE_mesh_nurbs_displist_to_mdata(ob, dispbase, &allvert, &totvert, &alledge,
&totedge, &allloop, &allpoly, &totloop, &totpoly, orco_index_ptr) != 0)
&totedge, &allloop, &allpoly, NULL,
&totloop, &totpoly) != 0)
{
/* Error initializing mdata. This often happens when curve is empty */
return CDDM_new(0, 0, 0, 0, 0);
@@ -1909,13 +1889,12 @@ static DerivedMesh *cddm_from_bmesh_ex(struct BMesh *bm, int use_mdisps,
int numCol = CustomData_number_of_layers(&bm->ldata, CD_MLOOPCOL);
int numTex = CustomData_number_of_layers(&bm->pdata, CD_MTEXPOLY);
int *index, add_orig;
int has_crease, has_edge_bweight, has_vert_bweight;
CustomDataMask mask;
unsigned int i, j;
has_edge_bweight = CustomData_has_layer(&bm->edata, CD_BWEIGHT);
has_vert_bweight = CustomData_has_layer(&bm->vdata, CD_BWEIGHT);
has_crease = CustomData_has_layer(&bm->edata, CD_CREASE);
const int cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT);
const int cd_edge_bweight_offset = CustomData_get_offset(&bm->edata, CD_BWEIGHT);
const int cd_edge_crease_offset = CustomData_get_offset(&bm->edata, CD_CREASE);
dm->deformedOnly = 1;
@@ -1955,8 +1934,7 @@ static DerivedMesh *cddm_from_bmesh_ex(struct BMesh *bm, int use_mdisps,
mv->flag = BM_vert_flag_to_mflag(eve);
if (has_vert_bweight)
mv->bweight = (unsigned char)(BM_elem_float_data_get(&bm->vdata, eve, CD_BWEIGHT) * 255.0f);
if (cd_vert_bweight_offset != -1) mv->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eve, cd_vert_bweight_offset);
if (add_orig) *index = i;
@@ -1974,11 +1952,6 @@ static DerivedMesh *cddm_from_bmesh_ex(struct BMesh *bm, int use_mdisps,
med->v1 = BM_elem_index_get(eed->v1);
med->v2 = BM_elem_index_get(eed->v2);
if (has_crease)
med->crease = (unsigned char)(BM_elem_float_data_get(&bm->edata, eed, CD_CREASE) * 255.0f);
if (has_edge_bweight)
med->bweight = (unsigned char)(BM_elem_float_data_get(&bm->edata, eed, CD_BWEIGHT) * 255.0f);
med->flag = BM_edge_flag_to_mflag(eed);
/* handle this differently to editmode switching,
@@ -1989,6 +1962,9 @@ static DerivedMesh *cddm_from_bmesh_ex(struct BMesh *bm, int use_mdisps,
}
}
if (cd_edge_crease_offset != -1) med->crease = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eed, cd_edge_crease_offset);
if (cd_edge_bweight_offset != -1) med->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eed, cd_edge_bweight_offset);
CustomData_from_bmesh_block(&bm->edata, &dm->edgeData, eed->head.data, i);
if (add_orig) *index = i;
}
@@ -2051,6 +2027,8 @@ static DerivedMesh *cddm_from_bmesh_ex(struct BMesh *bm, int use_mdisps,
}
bm->elem_index_dirty &= ~BM_FACE;
dm->cd_flag = BM_mesh_cd_flag_from_bmesh(bm);
return dm;
}
@@ -2088,6 +2066,7 @@ static DerivedMesh *cddm_copy_ex(DerivedMesh *source, int faces_from_tessfaces)
DM_from_template(dm, source, DM_TYPE_CDDM, numVerts, numEdges, numTessFaces,
numLoops, numPolys);
dm->deformedOnly = source->deformedOnly;
dm->cd_flag = source->cd_flag;
dm->dirty = source->dirty;
CustomData_copy_data(&source->vertData, &dm->vertData, 0, 0, numVerts);
+1 -1
View File
@@ -875,7 +875,7 @@ static void basisNurb(float t, short order, short pnts, float *knots, float *bas
void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int resolv)
/* coord_array has to be 3*4*resolu*resolv in size, and zero-ed */
/* coord_array has to be (3 * 4 * resolu * resolv) in size, and zero-ed */
{
BPoint *bp;
float *basisu, *basis, *basisv, *sum, *fp, *in;
+89 -26
View File
@@ -2095,6 +2095,23 @@ void *CustomData_get_layer_named(const struct CustomData *data, int type,
return data->layers[layer_index].data;
}
int CustomData_get_offset(const CustomData *data, int type)
{
/* get the layer index of the active layer of type */
int layer_index = CustomData_get_active_layer_index(data, type);
if (layer_index < 0) return -1;
return data->layers[layer_index].offset;
}
int CustomData_get_n_offset(const CustomData *data, int type, int n)
{
/* get the layer index of the active layer of type */
int layer_index = CustomData_get_layer_index_n(data, type, n);
if (layer_index < 0) return -1;
return data->layers[layer_index].offset;
}
int CustomData_set_layer_name(const CustomData *data, int type, int n, const char *name)
{
@@ -2298,34 +2315,46 @@ void CustomData_bmesh_merge(CustomData *source, CustomData *dest,
BMIter iter;
CustomData destold;
void *tmp;
int t;
int iter_type;
int totelem;
/* copy old layer description so that old data can be copied into
* the new allocation */
destold = *dest;
if (destold.layers) destold.layers = MEM_dupallocN(destold.layers);
CustomData_merge(source, dest, mask, alloctype, 0);
dest->pool = NULL;
CustomData_bmesh_init_pool(dest, 512, htype);
if (destold.layers) {
destold.layers = MEM_dupallocN(destold.layers);
}
switch (htype) {
case BM_VERT:
t = BM_VERTS_OF_MESH; break;
iter_type = BM_VERTS_OF_MESH;
totelem = bm->totvert;
break;
case BM_EDGE:
t = BM_EDGES_OF_MESH; break;
iter_type = BM_EDGES_OF_MESH;
totelem = bm->totedge;
break;
case BM_LOOP:
t = BM_LOOPS_OF_FACE; break;
iter_type = BM_LOOPS_OF_FACE;
totelem = bm->totloop;
break;
case BM_FACE:
t = BM_FACES_OF_MESH; break;
iter_type = BM_FACES_OF_MESH;
totelem = bm->totface;
break;
default: /* should never happen */
BLI_assert(!"invalid type given");
t = BM_VERTS_OF_MESH;
iter_type = BM_VERTS_OF_MESH;
totelem = bm->totvert;
}
if (t != BM_LOOPS_OF_FACE) {
CustomData_merge(source, dest, mask, alloctype, 0);
dest->pool = NULL;
CustomData_bmesh_init_pool(dest, totelem, htype);
if (iter_type != BM_LOOPS_OF_FACE) {
/*ensure all current elements follow new customdata layout*/
BM_ITER_MESH (h, &iter, bm, t) {
BM_ITER_MESH (h, &iter, bm, iter_type) {
tmp = NULL;
CustomData_bmesh_copy_data(&destold, dest, h->data, &tmp);
CustomData_bmesh_free_block(&destold, &h->data);
@@ -2618,6 +2647,19 @@ void CustomData_bmesh_set_layer_n(CustomData *data, void *block, int n, void *so
memcpy(dest, source, typeInfo->size);
}
/**
* \param src_blocks must be pointers to the data, offset by layer->offset already.
*/
void CustomData_bmesh_interp_n(CustomData *data, void **src_blocks, const float *weights,
const float *sub_weights, int count, void *dest_block, int n)
{
CustomDataLayer *layer = &data->layers[n];
const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type);
typeInfo->interp(src_blocks, weights, sub_weights, count,
(char *)dest_block + layer->offset);
}
void CustomData_bmesh_interp(CustomData *data, void **src_blocks, const float *weights,
const float *sub_weights, int count, void *dest_block)
{
@@ -2640,36 +2682,47 @@ void CustomData_bmesh_interp(CustomData *data, void **src_blocks, const float *w
for (j = 0; j < count; ++j) {
sources[j] = (char *)src_blocks[j] + layer->offset;
}
typeInfo->interp(sources, weights, sub_weights, count,
(char *)dest_block + layer->offset);
CustomData_bmesh_interp_n(data, sources, weights, sub_weights, count, dest_block, i);
}
}
if (count > SOURCE_BUF_SIZE) MEM_freeN(sources);
}
void CustomData_bmesh_set_default(CustomData *data, void **block)
static void CustomData_bmesh_set_default_n(CustomData *data, void **block, int n)
{
const LayerTypeInfo *typeInfo;
int offset = data->layers[n].offset;
typeInfo = layerType_getInfo(data->layers[n].type);
if (typeInfo->set_default) {
typeInfo->set_default((char *)*block + offset, 1);
}
else {
memset((char *)*block + offset, 0, typeInfo->size);
}
}
void CustomData_bmesh_set_default(CustomData *data, void **block)
{
int i;
if (*block == NULL)
CustomData_bmesh_alloc_block(data, block);
for (i = 0; i < data->totlayer; ++i) {
int offset = data->layers[i].offset;
typeInfo = layerType_getInfo(data->layers[i].type);
if (typeInfo->set_default)
typeInfo->set_default((char *)*block + offset, 1);
else memset((char *)*block + offset, 0, typeInfo->size);
CustomData_bmesh_set_default_n(data, block, i);
}
}
/**
* \param use_default_init initializes data which can't be copied,
* typically you'll want to use this if the BM_xxx create function
* is called with BM_CREATE_SKIP_CD flag
*/
void CustomData_to_bmesh_block(const CustomData *source, CustomData *dest,
int src_index, void **dest_block)
int src_index, void **dest_block, bool use_default_init)
{
const LayerTypeInfo *typeInfo;
int dest_i, src_i, src_offset;
@@ -2685,11 +2738,14 @@ void CustomData_to_bmesh_block(const CustomData *source, CustomData *dest,
* (this should work because layers are ordered by type)
*/
while (dest_i < dest->totlayer && dest->layers[dest_i].type < source->layers[src_i].type) {
if (use_default_init) {
CustomData_bmesh_set_default_n(dest, dest_block, dest_i);
}
dest_i++;
}
/* if there are no more dest layers, we're done */
if (dest_i >= dest->totlayer) return;
if (dest_i >= dest->totlayer) break;
/* if we found a matching layer, copy the data */
if (dest->layers[dest_i].type == source->layers[src_i].type) {
@@ -2712,6 +2768,13 @@ void CustomData_to_bmesh_block(const CustomData *source, CustomData *dest,
dest_i++;
}
}
if (use_default_init) {
while (dest_i < dest->totlayer) {
CustomData_bmesh_set_default_n(dest, dest_block, dest_i);
dest_i++;
}
}
}
void CustomData_from_bmesh_block(const CustomData *source, CustomData *dest,
+3 -4
View File
@@ -975,7 +975,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
curve_to_filledpoly(cu, nurb, dispbase);
}
dm = CDDM_from_curve_displist(ob, dispbase, NULL);
dm = CDDM_from_curve_displist(ob, dispbase);
CDDM_calc_normals_mapping(dm);
}
@@ -1065,7 +1065,7 @@ static DerivedMesh *create_orco_dm(Scene *scene, Object *ob)
/* OrcoDM should be created from underformed disp lists */
BKE_displist_make_curveTypes_forOrco(scene, ob, &disp);
dm = CDDM_from_curve_displist(ob, &disp, NULL);
dm = CDDM_from_curve_displist(ob, &disp);
BKE_displist_free(&disp);
@@ -1485,8 +1485,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
float *cur_data = data;
if (cu->taperobj == NULL) {
if ( (cu->bevobj != NULL) || !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) )
fac = bevp->radius;
fac = bevp->radius;
}
else {
float len, taper_fac;
@@ -782,22 +782,18 @@ static void emDM_drawMappedFaces(DerivedMesh *dm,
if (poly_prev != GL_ZERO) glEnd();
}
static void bmdm_get_tri_tex(BMesh *bm, BMLoop **ls, MLoopUV *luv[3], MLoopCol *lcol[3],
int has_uv, int has_col)
static void bmdm_get_tri_uv(BMLoop *ls[3], MLoopUV *luv[3], const int cd_loop_uv_offset)
{
if (has_uv) {
luv[0] = CustomData_bmesh_get(&bm->ldata, ls[0]->head.data, CD_MLOOPUV);
luv[1] = CustomData_bmesh_get(&bm->ldata, ls[1]->head.data, CD_MLOOPUV);
luv[2] = CustomData_bmesh_get(&bm->ldata, ls[2]->head.data, CD_MLOOPUV);
}
if (has_col) {
lcol[0] = CustomData_bmesh_get(&bm->ldata, ls[0]->head.data, CD_MLOOPCOL);
lcol[1] = CustomData_bmesh_get(&bm->ldata, ls[1]->head.data, CD_MLOOPCOL);
lcol[2] = CustomData_bmesh_get(&bm->ldata, ls[2]->head.data, CD_MLOOPCOL);
}
luv[0] = BM_ELEM_CD_GET_VOID_P(ls[0], cd_loop_uv_offset);
luv[1] = BM_ELEM_CD_GET_VOID_P(ls[1], cd_loop_uv_offset);
luv[2] = BM_ELEM_CD_GET_VOID_P(ls[2], cd_loop_uv_offset);
}
static void bmdm_get_tri_col(BMLoop *ls[3], MLoopCol *lcol[3], const int cd_loop_color_offset)
{
lcol[0] = BM_ELEM_CD_GET_VOID_P(ls[0], cd_loop_color_offset);
lcol[1] = BM_ELEM_CD_GET_VOID_P(ls[1], cd_loop_color_offset);
lcol[2] = BM_ELEM_CD_GET_VOID_P(ls[2], cd_loop_color_offset);
}
static void emDM_drawFacesTex_common(DerivedMesh *dm,
@@ -813,15 +809,19 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
float (*vertexNos)[3] = bmdm->vertexNos;
BMFace *efa;
MLoopUV *luv[3], dummyluv = {{0}};
MLoopCol *lcol[3] = {NULL}, dummylcol = {0};
int i, has_vcol = CustomData_has_layer(&bm->ldata, CD_MLOOPCOL);
int has_uv = CustomData_has_layer(&bm->pdata, CD_MTEXPOLY);
MLoopCol *lcol[3] = {NULL} /* , dummylcol = {0} */;
const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
const int cd_loop_color_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPCOL);
const int cd_poly_tex_offset = CustomData_get_offset(&bm->pdata, CD_MTEXPOLY);
bool has_uv = (cd_loop_uv_offset != -1);
bool has_vcol = (cd_loop_color_offset != -1);
int i;
(void) compareDrawOptions;
luv[0] = luv[1] = luv[2] = &dummyluv;
dummylcol.r = dummylcol.g = dummylcol.b = dummylcol.a = 255;
// dummylcol.r = dummylcol.g = dummylcol.b = dummylcol.a = 255; /* UNUSED */
/* always use smooth shading even for flat faces, else vertex colors wont interpolate */
glShadeModel(GL_SMOOTH);
@@ -833,7 +833,7 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
for (i = 0; i < em->tottri; i++) {
BMLoop **ls = em->looptris[i];
MTexPoly *tp = has_uv ? CustomData_bmesh_get(&bm->pdata, ls[0]->f->head.data, CD_MTEXPOLY) : NULL;
MTexPoly *tp = (cd_poly_tex_offset != -1) ? BM_ELEM_CD_GET_VOID_P(ls[0]->f, cd_poly_tex_offset) : NULL;
MTFace mtf = {{{0}}};
/*unsigned char *cp = NULL;*/ /*UNUSED*/
int drawSmooth = BM_elem_flag_test(ls[0]->f, BM_ELEM_SMOOTH);
@@ -841,7 +841,7 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
efa = ls[0]->f;
if (has_uv) {
if (cd_poly_tex_offset != -1) {
ME_MTEXFACE_CPY(&mtf, tp);
}
@@ -858,25 +858,27 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
if (!drawSmooth) {
glNormal3fv(bmdm->polyNos[BM_elem_index_get(efa)]);
bmdm_get_tri_tex(bm, ls, luv, lcol, has_uv, has_vcol);
if (has_uv) bmdm_get_tri_uv(ls, luv, cd_loop_uv_offset);
if (has_vcol) bmdm_get_tri_col(ls, lcol, cd_loop_color_offset);
glTexCoord2fv(luv[0]->uv);
if (lcol[0])
if (has_vcol)
glColor3ubv((const GLubyte *)&(lcol[0]->r));
glVertex3fv(vertexCos[BM_elem_index_get(ls[0]->v)]);
glTexCoord2fv(luv[1]->uv);
if (lcol[1])
if (has_vcol)
glColor3ubv((const GLubyte *)&(lcol[1]->r));
glVertex3fv(vertexCos[BM_elem_index_get(ls[1]->v)]);
glTexCoord2fv(luv[2]->uv);
if (lcol[2])
if (has_vcol)
glColor3ubv((const GLubyte *)&(lcol[2]->r));
glVertex3fv(vertexCos[BM_elem_index_get(ls[2]->v)]);
}
else {
bmdm_get_tri_tex(bm, ls, luv, lcol, has_uv, has_vcol);
if (has_uv) bmdm_get_tri_uv(ls, luv, cd_loop_uv_offset);
if (has_vcol) bmdm_get_tri_col(ls, lcol, cd_loop_color_offset);
glTexCoord2fv(luv[0]->uv);
if (lcol[0])
@@ -905,7 +907,7 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
for (i = 0; i < em->tottri; i++) {
BMLoop **ls = em->looptris[i];
MTexPoly *tp = has_uv ? CustomData_bmesh_get(&bm->pdata, ls[0]->f->head.data, CD_MTEXPOLY) : NULL;
MTexPoly *tp = (cd_poly_tex_offset != -1) ? BM_ELEM_CD_GET_VOID_P(ls[0]->f, cd_poly_tex_offset) : NULL;
MTFace mtf = {{{0}}};
/*unsigned char *cp = NULL;*/ /*UNUSED*/
int drawSmooth = BM_elem_flag_test(ls[0]->f, BM_ELEM_SMOOTH);
@@ -913,12 +915,12 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
efa = ls[0]->f;
if (has_uv) {
if (cd_poly_tex_offset != -1) {
ME_MTEXFACE_CPY(&mtf, tp);
}
if (drawParams)
draw_option = drawParams(&mtf, has_vcol, efa->mat_nr);
draw_option = drawParams(&mtf, (has_vcol), efa->mat_nr);
else if (drawParamsMapped)
draw_option = drawParamsMapped(userData, BM_elem_index_get(efa));
else
@@ -930,46 +932,42 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
if (!drawSmooth) {
glNormal3fv(efa->no);
bmdm_get_tri_tex(bm, ls, luv, lcol, has_uv, has_vcol);
if (has_uv) bmdm_get_tri_uv(ls, luv, cd_loop_uv_offset);
if (has_vcol) bmdm_get_tri_col(ls, lcol, cd_loop_color_offset);
if (luv[0])
glTexCoord2fv(luv[0]->uv);
if (lcol[0])
glTexCoord2fv(luv[0]->uv);
if (has_vcol)
glColor3ubv((const GLubyte *)&(lcol[0]->r));
glVertex3fv(ls[0]->v->co);
if (luv[1])
glTexCoord2fv(luv[1]->uv);
if (lcol[1])
glTexCoord2fv(luv[1]->uv);
if (has_vcol)
glColor3ubv((const GLubyte *)&(lcol[1]->r));
glVertex3fv(ls[1]->v->co);
if (luv[2])
glTexCoord2fv(luv[2]->uv);
if (lcol[2])
glTexCoord2fv(luv[2]->uv);
if (has_vcol)
glColor3ubv((const GLubyte *)&(lcol[2]->r));
glVertex3fv(ls[2]->v->co);
}
else {
bmdm_get_tri_tex(bm, ls, luv, lcol, has_uv, has_vcol);
if (has_uv) bmdm_get_tri_uv(ls, luv, cd_loop_uv_offset);
if (has_vcol) bmdm_get_tri_col(ls, lcol, cd_loop_color_offset);
if (luv[0])
glTexCoord2fv(luv[0]->uv);
if (lcol[0])
glTexCoord2fv(luv[0]->uv);
if (has_vcol)
glColor3ubv((const GLubyte *)&(lcol[0]->r));
glNormal3fv(ls[0]->v->no);
glVertex3fv(ls[0]->v->co);
if (luv[1])
glTexCoord2fv(luv[1]->uv);
if (lcol[1])
glTexCoord2fv(luv[1]->uv);
if (has_vcol)
glColor3ubv((const GLubyte *)&(lcol[1]->r));
glNormal3fv(ls[1]->v->no);
glVertex3fv(ls[1]->v->co);
if (luv[2])
glTexCoord2fv(luv[2]->uv);
if (lcol[2])
glTexCoord2fv(luv[2]->uv);
if (has_vcol)
glColor3ubv((const GLubyte *)&(lcol[2]->r));
glNormal3fv(ls[2]->v->no);
glVertex3fv(ls[2]->v->co);
@@ -1309,14 +1307,16 @@ static int emDM_getNumPolys(DerivedMesh *dm)
static int bmvert_to_mvert(BMesh *bm, BMVert *ev, MVert *vert_r)
{
float *f;
copy_v3_v3(vert_r->co, ev->co);
normal_float_to_short_v3(vert_r->no, ev->no);
vert_r->flag = BM_vert_flag_to_mflag(ev);
if (CustomData_has_layer(&bm->vdata, CD_BWEIGHT)) {
vert_r->bweight = (unsigned char) (BM_elem_float_data_get(&bm->vdata, ev, CD_BWEIGHT) * 255.0f);
if ((f = CustomData_bmesh_get(&bm->vdata, ev->head.data, CD_BWEIGHT))) {
vert_r->bweight = (unsigned char)((*f) * 255.0f);
}
return 1;
@@ -1332,8 +1332,8 @@ static void emDM_getVert(DerivedMesh *dm, int index, MVert *vert_r)
return;
}
// ev = EDBM_vert_at_index(bmdm->tc, index);
ev = BM_vert_at_index(bmdm->tc->bm, index); /* warning, does list loop, _not_ ideal */
ev = bmdm->tc->vert_index[index]; /* should be EDBM_vert_at_index() */
// ev = BM_vert_at_index(bmdm->tc->bm, index); /* warning, does list loop, _not_ ideal */
bmvert_to_mvert(bmdm->tc->bm, ev, vert_r);
if (bmdm->vertexCos)
@@ -1345,27 +1345,27 @@ static void emDM_getEdge(DerivedMesh *dm, int index, MEdge *edge_r)
EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
BMesh *bm = bmdm->tc->bm;
BMEdge *e;
float *f;
if (index < 0 || index >= bmdm->te) {
printf("error in emDM_getEdge.\n");
return;
}
// e = EDBM_edge_at_index(bmdm->tc, index);
e = BM_edge_at_index(bmdm->tc->bm, index); /* warning, does list loop, _not_ ideal */
if (CustomData_has_layer(&bm->edata, CD_BWEIGHT)) {
edge_r->bweight = (unsigned char) (BM_elem_float_data_get(&bm->edata, e, CD_BWEIGHT) * 255.0f);
}
if (CustomData_has_layer(&bm->edata, CD_CREASE)) {
edge_r->crease = (unsigned char) (BM_elem_float_data_get(&bm->edata, e, CD_CREASE) * 255.0f);
}
e = bmdm->tc->edge_index[index]; /* should be EDBM_edge_at_index() */
// e = BM_edge_at_index(bmdm->tc->bm, index); /* warning, does list loop, _not_ ideal */
edge_r->flag = BM_edge_flag_to_mflag(e);
edge_r->v1 = BM_elem_index_get(e->v1);
edge_r->v2 = BM_elem_index_get(e->v2);
if ((f = CustomData_bmesh_get(&bm->edata, e->head.data, CD_BWEIGHT))) {
edge_r->bweight = (unsigned char)((*f) * 255.0f);
}
if ((f = CustomData_bmesh_get(&bm->edata, e->head.data, CD_CREASE))) {
edge_r->crease = (unsigned char)((*f) * 255.0f);
}
}
static void emDM_getTessFace(DerivedMesh *dm, int index, MFace *face_r)
@@ -1400,7 +1400,7 @@ static void emDM_copyVertArray(DerivedMesh *dm, MVert *vert_r)
BMesh *bm = bmdm->tc->bm;
BMVert *eve;
BMIter iter;
const int has_bweight = CustomData_has_layer(&bm->vdata, CD_BWEIGHT);
const int cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT);
if (bmdm->vertexCos) {
int i;
@@ -1410,9 +1410,8 @@ static void emDM_copyVertArray(DerivedMesh *dm, MVert *vert_r)
normal_float_to_short_v3(vert_r->no, eve->no);
vert_r->flag = BM_vert_flag_to_mflag(eve);
if (has_bweight) {
vert_r->bweight = (unsigned char) (BM_elem_float_data_get(&bm->vdata, eve, CD_BWEIGHT) * 255.0f);
}
if (cd_vert_bweight_offset != -1) vert_r->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eve, cd_vert_bweight_offset);
vert_r++;
}
}
@@ -1422,9 +1421,8 @@ static void emDM_copyVertArray(DerivedMesh *dm, MVert *vert_r)
normal_float_to_short_v3(vert_r->no, eve->no);
vert_r->flag = BM_vert_flag_to_mflag(eve);
if (has_bweight) {
vert_r->bweight = (unsigned char) (BM_elem_float_data_get(&bm->vdata, eve, CD_BWEIGHT) * 255.0f);
}
if (cd_vert_bweight_offset != -1) vert_r->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eve, cd_vert_bweight_offset);
vert_r++;
}
}
@@ -1435,24 +1433,20 @@ static void emDM_copyEdgeArray(DerivedMesh *dm, MEdge *edge_r)
BMesh *bm = ((EditDerivedBMesh *)dm)->tc->bm;
BMEdge *eed;
BMIter iter;
const int has_bweight = CustomData_has_layer(&bm->edata, CD_BWEIGHT);
const int has_crease = CustomData_has_layer(&bm->edata, CD_CREASE);
const int cd_edge_bweight_offset = CustomData_get_offset(&bm->edata, CD_BWEIGHT);
const int cd_edge_crease_offset = CustomData_get_offset(&bm->edata, CD_CREASE);
BM_mesh_elem_index_ensure(bm, BM_VERT);
BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
if (has_bweight) {
edge_r->bweight = (unsigned char) (BM_elem_float_data_get(&bm->edata, eed, CD_BWEIGHT) * 255.0f);
}
if (has_crease) {
edge_r->crease = (unsigned char) (BM_elem_float_data_get(&bm->edata, eed, CD_CREASE) * 255.0f);
}
edge_r->v1 = BM_elem_index_get(eed->v1);
edge_r->v2 = BM_elem_index_get(eed->v2);
edge_r->flag = BM_edge_flag_to_mflag(eed);
edge_r->v1 = BM_elem_index_get(eed->v1);
edge_r->v2 = BM_elem_index_get(eed->v2);
if (cd_edge_crease_offset != -1) edge_r->crease = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eed, cd_edge_crease_offset);
if (cd_edge_bweight_offset != -1) edge_r->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eed, cd_edge_bweight_offset);
edge_r++;
}
@@ -1660,6 +1654,9 @@ DerivedMesh *getEditDerivedBMesh(BMEditMesh *em,
DM_init((DerivedMesh *)bmdm, DM_TYPE_EDITBMESH, em->bm->totvert,
em->bm->totedge, em->tottri, em->bm->totloop, em->bm->totface);
/* could also get from the objects mesh directly */
bmdm->dm.cd_flag = BM_mesh_cd_flag_from_bmesh(bm);
bmdm->dm.getVertCos = emDM_getVertCos;
bmdm->dm.getMinMax = emDM_getMinMax;
+17 -38
View File
@@ -141,55 +141,34 @@ static void fcm_generator_verify(FModifier *fcm)
switch (data->mode) {
case FCM_GENERATOR_POLYNOMIAL: /* expanded polynomial expression */
{
const int arraysize_new = data->poly_order + 1;
/* arraysize needs to be order+1, so resize if not */
if (data->arraysize != (data->poly_order + 1)) {
float *nc;
/* make new coefficients array, and copy over as much data as can fit */
nc = MEM_callocN(sizeof(float) * (data->poly_order + 1), "FMod_Generator_Coefs");
if (data->arraysize != arraysize_new) {
if (data->coefficients) {
if ((int)data->arraysize > (data->poly_order + 1))
memcpy(nc, data->coefficients, sizeof(float) * (data->poly_order + 1));
else
memcpy(nc, data->coefficients, sizeof(float) * data->arraysize);
/* free the old data */
MEM_freeN(data->coefficients);
data->coefficients = MEM_recallocN(data->coefficients, sizeof(float) * arraysize_new);
}
/* set the new data */
data->coefficients = nc;
data->arraysize = data->poly_order + 1;
else {
data->coefficients = MEM_callocN(sizeof(float) * arraysize_new, "FMod_Generator_Coefs");
}
data->arraysize = arraysize_new;
}
break;
}
break;
case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* expanded polynomial expression */
{
/* arraysize needs to be 2*order, so resize if not */
if (data->arraysize != (data->poly_order * 2)) {
float *nc;
/* make new coefficients array, and copy over as much data as can fit */
nc = MEM_callocN(sizeof(float) * (data->poly_order * 2), "FMod_Generator_Coefs");
const int arraysize_new = data->poly_order * 2;
/* arraysize needs to be (2 * order), so resize if not */
if (data->arraysize != arraysize_new) {
if (data->coefficients) {
if (data->arraysize > (unsigned int)(data->poly_order * 2))
memcpy(nc, data->coefficients, sizeof(float) * (data->poly_order * 2));
else
memcpy(nc, data->coefficients, sizeof(float) * data->arraysize);
/* free the old data */
MEM_freeN(data->coefficients);
data->coefficients = MEM_recallocN(data->coefficients, sizeof(float) * arraysize_new);
}
/* set the new data */
data->coefficients = nc;
data->arraysize = data->poly_order * 2;
else {
data->coefficients = MEM_callocN(sizeof(float) * arraysize_new, "FMod_Generator_Coefs");
}
data->arraysize = arraysize_new;
}
break;
}
break;
}
}
+1 -1
View File
@@ -904,7 +904,7 @@ void BKE_image_free_all_textures(void)
image_free_buffers(ima);
}
}
/* printf("freed total %d MB\n", totsize/(1024*1024)); */
/* printf("freed total %d MB\n", totsize / (1024 * 1024)); */
}
/* except_frame is weak, only works for seqs without offset... */
+87 -47
View File
@@ -1204,8 +1204,8 @@ int BKE_mesh_nurbs_to_mdata(Object *ob, MVert **allvert, int *totvert,
return BKE_mesh_nurbs_displist_to_mdata(ob, &ob->disp,
allvert, totvert,
alledge, totedge,
allloop, allpoly,
totloop, totpoly, NULL);
allloop, allpoly, NULL,
totloop, totpoly);
}
/* BMESH: this doesn't calculate all edges from polygons,
@@ -1213,25 +1213,24 @@ int BKE_mesh_nurbs_to_mdata(Object *ob, MVert **allvert, int *totvert,
/* Initialize mverts, medges and, faces for converting nurbs to mesh and derived mesh */
/* use specified dispbase */
/* TODO: orco values for non DL_SURF types */
int BKE_mesh_nurbs_displist_to_mdata(Object *ob, ListBase *dispbase,
MVert **allvert, int *_totvert,
MEdge **alledge, int *_totedge,
MLoop **allloop, MPoly **allpoly,
int *_totloop, int *_totpoly,
int **orco_index_ptr)
MLoopUV **alluv,
int *_totloop, int *_totpoly)
{
DispList *dl;
Curve *cu;
MVert *mvert;
MPoly *mpoly;
MLoop *mloop;
MLoopUV *mloopuv = NULL;
MEdge *medge;
float *data;
int a, b, ofs, vertcount, startvert, totvert = 0, totedge = 0, totloop = 0, totvlak = 0;
int p1, p2, p3, p4, *index;
int conv_polys = 0;
int (*orco_index)[4] = NULL;
cu = ob->data;
@@ -1278,15 +1277,13 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob, ListBase *dispbase,
*alledge = medge = MEM_callocN(sizeof(MEdge) * totedge, "nurbs_init medge");
*allloop = mloop = MEM_callocN(sizeof(MLoop) * totvlak * 4, "nurbs_init mloop"); // totloop
*allpoly = mpoly = MEM_callocN(sizeof(MPoly) * totvlak, "nurbs_init mloop");
if (alluv)
*alluv = mloopuv = MEM_callocN(sizeof(MLoopUV) * totvlak * 4, "nurbs_init mloopuv");
/* verts and faces */
vertcount = 0;
if (orco_index_ptr) {
*orco_index_ptr = MEM_callocN(sizeof(int) * totvlak * 4, "nurbs_init orco");
orco_index = (int (*)[4]) *orco_index_ptr;
}
dl = dispbase->first;
while (dl) {
int smooth = dl->rt & CU_SMOOTH ? 1 : 0;
@@ -1359,6 +1356,15 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob, ListBase *dispbase,
mpoly->totloop = 3;
mpoly->mat_nr = dl->col;
if (mloopuv) {
int i;
for (i = 0; i < 3; i++, mloopuv++) {
mloopuv->uv[0] = (mloop[i].v - startvert)/(float)(dl->nr - 1);
mloopuv->uv[1] = 0.0f;
}
}
if (smooth) mpoly->flag |= ME_SMOOTH;
mpoly++;
mloop += 3;
@@ -1408,13 +1414,29 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob, ListBase *dispbase,
mpoly->totloop = 4;
mpoly->mat_nr = dl->col;
if (orco_index) {
const int poly_index = mpoly - *allpoly;
const int p_orco_base = startvert + ((dl->nr + 1) * a) + b;
orco_index[poly_index][0] = p_orco_base + 1;
orco_index[poly_index][1] = p_orco_base + dl->nr + 2;
orco_index[poly_index][2] = p_orco_base + dl->nr + 1;
orco_index[poly_index][3] = p_orco_base;
if (mloopuv) {
int orco_sizeu = dl->nr - 1;
int orco_sizev = dl->parts - 1;
int i;
/* exception as handled in convertblender.c too */
if (dl->flag & DL_CYCL_U) {
orco_sizeu++;
if (dl->flag & DL_CYCL_V)
orco_sizev++;
}
for (i = 0; i < 4; i++, mloopuv++) {
/* find uv based on vertex index into grid array */
int v = mloop[i].v - startvert;
mloopuv->uv[0] = (v / dl->nr)/(float)orco_sizev;
mloopuv->uv[1] = (v % dl->nr)/(float)orco_sizeu;
/* cyclic correction */
if ((i == 0 || i == 1) && mloopuv->uv[1] == 0.0f)
mloopuv->uv[1] = 1.0f;
}
}
if (smooth) mpoly->flag |= ME_SMOOTH;
@@ -1427,7 +1449,6 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob, ListBase *dispbase,
p1++;
}
}
}
dl = dl->next;
@@ -1448,33 +1469,8 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob, ListBase *dispbase,
}
MINLINE void copy_uv_orco_v2_v2(float r[2], const float a[2])
{
r[0] = 0.5f + a[0] * 0.5f;
r[1] = 0.5f + a[1] * 0.5f;
}
/**
* orco is normally from #BKE_curve_make_orco
*/
void BKE_mesh_nurbs_to_mdata_orco(MPoly *mpoly, int totpoly,
MLoop *mloops, MLoopUV *mloopuvs,
float (*orco)[3], int (*orco_index)[4])
{
MPoly *mp;
int i, j;
for (i = 0, mp = mpoly; i < totpoly; i++, mp++) {
MLoop *ml = mloops + mp->loopstart;
MLoopUV *mluv = mloopuvs + mp->loopstart;
for (j = 0; j < mp->totloop; j++, ml++, mluv++) {
copy_uv_orco_v2_v2(mluv->uv, orco[orco_index[i][j]]);
}
}
}
/* this may fail replacing ob->data, be sure to check ob->type */
void BKE_mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, int **orco_index_ptr)
void BKE_mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, int use_orco_uv)
{
Main *bmain = G.main;
Object *ob1;
@@ -1484,6 +1480,7 @@ void BKE_mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, int **orco_ind
MVert *allvert = NULL;
MEdge *alledge = NULL;
MLoop *allloop = NULL;
MLoopUV *alluv = NULL;
MPoly *allpoly = NULL;
int totvert, totedge, totloop, totpoly;
@@ -1492,7 +1489,8 @@ void BKE_mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, int **orco_ind
if (dm == NULL) {
if (BKE_mesh_nurbs_displist_to_mdata(ob, dispbase, &allvert, &totvert,
&alledge, &totedge, &allloop,
&allpoly, &totloop, &totpoly, orco_index_ptr) != 0)
&allpoly, (use_orco_uv)? &alluv: NULL,
&totloop, &totpoly) != 0)
{
/* Error initializing */
return;
@@ -1510,6 +1508,12 @@ void BKE_mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, int **orco_ind
me->mloop = CustomData_add_layer(&me->ldata, CD_MLOOP, CD_ASSIGN, allloop, me->totloop);
me->mpoly = CustomData_add_layer(&me->pdata, CD_MPOLY, CD_ASSIGN, allpoly, me->totpoly);
if (alluv) {
const char *uvname = "Orco";
me->mtpoly = CustomData_add_layer_named(&me->pdata, CD_MTEXPOLY, CD_DEFAULT, NULL, me->totpoly, uvname);
me->mloopuv = CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_ASSIGN, alluv, me->totloop, uvname);
}
BKE_mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL);
BKE_mesh_calc_edges(me, TRUE);
@@ -1548,7 +1552,7 @@ void BKE_mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, int **orco_ind
void BKE_mesh_from_nurbs(Object *ob)
{
BKE_mesh_from_nurbs_displist(ob, &ob->disp, NULL);
BKE_mesh_from_nurbs_displist(ob, &ob->disp, false);
}
typedef struct EdgeLink {
@@ -3337,3 +3341,39 @@ void BKE_mesh_poly_calc_angles(MVert *mvert, MLoop *mloop,
}
}
#endif
void BKE_mesh_do_versions_cd_flag_init(Mesh *mesh)
{
if (UNLIKELY(mesh->cd_flag)) {
return;
}
else {
MVert *mv;
MEdge *med;
int i;
for (mv = mesh->mvert, i = 0; i < mesh->totvert; mv++, i++) {
if (mv->bweight != 0) {
mesh->cd_flag |= ME_CDFLAG_VERT_BWEIGHT;
break;
}
}
for (med = mesh->medge, i = 0; i < mesh->totedge; med++, i++) {
if (med->bweight != 0) {
mesh->cd_flag |= ME_CDFLAG_EDGE_BWEIGHT;
if (mesh->cd_flag & ME_CDFLAG_EDGE_CREASE) {
break;
}
}
if (med->crease != 0) {
mesh->cd_flag |= ME_CDFLAG_EDGE_CREASE;
if (mesh->cd_flag & ME_CDFLAG_EDGE_BWEIGHT) {
break;
}
}
}
}
}
@@ -59,9 +59,14 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
BLI_array_declare(verts);
BLI_array_declare(edges);
int i, j, k, totvert, totedge /* , totface */ /* UNUSED */ ;
int is_init = (bm->totvert == 0) && (bm->totedge == 0) && (bm->totface == 0);
bool is_init = (bm->totvert == 0) && (bm->totedge == 0) && (bm->totface == 0);
bool is_cddm = (dm->type == DM_TYPE_CDDM); /* duplicate the arrays for non cddm */
char has_orig_hflag = 0;
int cd_vert_bweight_offset;
int cd_edge_bweight_offset;
int cd_edge_crease_offset;
if (is_init == FALSE) {
/* check if we have an origflag */
has_orig_hflag |= CustomData_has_layer(&bm->vdata, CD_ORIGINDEX) ? BM_VERT : 0;
@@ -75,43 +80,45 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
CustomData_bmesh_merge(&dm->loopData, &bm->ldata, CD_MASK_DERIVEDMESH, CD_CALLOC, bm, BM_LOOP);
CustomData_bmesh_merge(&dm->polyData, &bm->pdata, CD_MASK_DERIVEDMESH, CD_CALLOC, bm, BM_FACE);
if (is_init) {
BM_mesh_cd_flag_apply(bm, dm->cd_flag);
}
cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT);
cd_edge_bweight_offset = CustomData_get_offset(&bm->edata, CD_BWEIGHT);
cd_edge_crease_offset = CustomData_get_offset(&bm->edata, CD_CREASE);
totvert = dm->getNumVerts(dm);
totedge = dm->getNumEdges(dm);
/* totface = dm->getNumPolys(dm); */ /* UNUSED */
/* add crease layer */
BM_data_layer_add(bm, &bm->edata, CD_CREASE);
/* add bevel weight layers */
BM_data_layer_add(bm, &bm->edata, CD_BWEIGHT);
BM_data_layer_add(bm, &bm->vdata, CD_BWEIGHT);
vtable = MEM_callocN(sizeof(void **) * totvert, __func__);
etable = MEM_callocN(sizeof(void **) * totedge, __func__);
/*do verts*/
mv = mvert = dm->dupVertArray(dm);
mv = mvert = is_cddm ? dm->getVertArray(dm) : dm->dupVertArray(dm);
for (i = 0; i < totvert; i++, mv++) {
v = BM_vert_create(bm, mv->co, NULL, BM_CREATE_SKIP_CD);
normal_short_to_float_v3(v->no, mv->no);
v->head.hflag = BM_vert_flag_from_mflag(mv->flag);
BM_elem_index_set(v, i); /* set_inline */
CustomData_to_bmesh_block(&dm->vertData, &bm->vdata, i, &v->head.data);
CustomData_to_bmesh_block(&dm->vertData, &bm->vdata, i, &v->head.data, true);
vtable[i] = v;
/* add bevel weight */
BM_elem_float_data_set(&bm->vdata, v, CD_BWEIGHT, (float)mv->bweight / 255.0f);
if (cd_vert_bweight_offset != -1) BM_ELEM_CD_SET_FLOAT(v, cd_vert_bweight_offset, (float)mv->bweight / 255.0f);
if (UNLIKELY(has_orig_hflag & BM_VERT)) {
int *orig_index = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_ORIGINDEX);
*orig_index = ORIGINDEX_NONE;
}
}
MEM_freeN(mvert);
if (!is_cddm) MEM_freeN(mvert);
if (is_init) bm->elem_index_dirty &= ~BM_VERT;
/*do edges*/
me = medge = dm->dupEdgeArray(dm);
me = medge = is_cddm ? dm->getEdgeArray(dm) : dm->dupEdgeArray(dm);
for (i = 0; i < totedge; i++, me++) {
//BLI_assert(BM_edge_exists(vtable[me->v1], vtable[me->v2]) == NULL);
e = BM_edge_create(bm, vtable[me->v1], vtable[me->v2], NULL, BM_CREATE_SKIP_CD);
@@ -119,20 +126,18 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
e->head.hflag = BM_edge_flag_from_mflag(me->flag);
BM_elem_index_set(e, i); /* set_inline */
CustomData_to_bmesh_block(&dm->edgeData, &bm->edata, i, &e->head.data);
CustomData_to_bmesh_block(&dm->edgeData, &bm->edata, i, &e->head.data, true);
etable[i] = e;
/* add crease */
BM_elem_float_data_set(&bm->edata, e, CD_CREASE, (float)me->crease / 255.0f);
/* add bevel weight */
BM_elem_float_data_set(&bm->edata, e, CD_BWEIGHT, (float)me->bweight / 255.0f);
if (cd_edge_bweight_offset != -1) BM_ELEM_CD_SET_FLOAT(e, cd_edge_bweight_offset, (float)me->bweight / 255.0f);
if (cd_edge_crease_offset != -1) BM_ELEM_CD_SET_FLOAT(e, cd_edge_crease_offset, (float)me->crease / 255.0f);
if (UNLIKELY(has_orig_hflag & BM_EDGE)) {
int *orig_index = CustomData_bmesh_get(&bm->edata, e->head.data, CD_ORIGINDEX);
*orig_index = ORIGINDEX_NONE;
}
}
MEM_freeN(medge);
if (!is_cddm) MEM_freeN(medge);
if (is_init) bm->elem_index_dirty &= ~BM_EDGE;
/* do faces */
@@ -156,7 +161,7 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
edges[j] = etable[ml->e];
}
f = BM_face_create_ngon(bm, verts[0], verts[1], edges, mp->totloop, BM_CREATE_SKIP_CD);
f = BM_face_create(bm, verts, edges, mp->totloop, BM_CREATE_SKIP_CD);
if (UNLIKELY(f == NULL)) {
continue;
@@ -169,10 +174,10 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
l = BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, f);
for (k = mp->loopstart; l; l = BM_iter_step(&liter), k++) {
CustomData_to_bmesh_block(&dm->loopData, &bm->ldata, k, &l->head.data);
CustomData_to_bmesh_block(&dm->loopData, &bm->ldata, k, &l->head.data, true);
}
CustomData_to_bmesh_block(&dm->polyData, &bm->pdata, i, &f->head.data);
CustomData_to_bmesh_block(&dm->polyData, &bm->pdata, i, &f->head.data, true);
if (face_normals) {
copy_v3_v3(f->no, face_normals[i]);
@@ -2396,6 +2396,7 @@ typedef struct SPHRangeData {
ParticleData *pa;
float h;
float mass;
float massfac;
int use_size;
} SPHRangeData;
@@ -2408,7 +2409,7 @@ static void sph_evaluate_func(BVHTree *tree, ParticleSystem **psys, float co[3],
for (i=0; i < 10 && psys[i]; i++) {
pfr->npsys = psys[i];
pfr->massfac = psys[i]->part->mass;
pfr->massfac = psys[i]->part->mass / pfr->mass;
pfr->use_size = psys[i]->part->flag & PART_SIZEMASS;
if (tree) {
@@ -2491,7 +2492,6 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
ParticleSpring *spring = NULL;
SPHRangeData pfr;
SPHNeighbor *pfn;
float mass = sphdata->mass;
float *gravity = sphdata->gravity;
EdgeHash *springhash = sphdata->eh;
@@ -2501,7 +2501,7 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
float visc = fluid->viscosity_omega;
float stiff_visc = fluid->viscosity_beta * (fluid->flag & SPH_FAC_VISCOSITY ? fluid->viscosity_omega : 1.f);
float inv_mass = 1.0f/mass;
float inv_mass = 1.0f / sphdata->mass;
float spring_constant = fluid->spring_k;
/* 4.0 seems to be a pretty good value */
@@ -2526,6 +2526,7 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
pfr.data = data;
pfr.h = h;
pfr.pa = pa;
pfr.mass = sphdata->mass;
sph_evaluate_func( NULL, psys, state->co, &pfr, interaction_radius, sph_density_accum_cb);
@@ -2644,7 +2645,7 @@ static void sphclassical_density_accum_cb(void *userdata, int index, float UNUSE
* q1(x) = (2.0 - x)**4 * ( 1.0 + 2.0 * x)
* plot [0:2] q1(x) */
q = qfac / pow3(pfr->h) * pow4(2.0f - rij_h) * ( 1.0f + 2.0f * rij_h);
q *= pfr->massfac;
q *= pfr->npsys->part->mass;
if (pfr->use_size)
q *= pfr->pa->size;
@@ -2696,7 +2697,8 @@ static void sphclassical_force_cb(void *sphdata_v, ParticleKey *state, float *fo
/* 4.77 is an experimentally determined density factor */
float rest_density = fluid->rest_density * (fluid->flag & SPH_FAC_DENSITY ? 4.77f : 1.0f);
float stiffness = fluid->stiffness_k;
// Use speed of sound squared
float stiffness = pow2(fluid->stiffness_k);
ParticleData *npa;
float vec[3];
@@ -2792,6 +2794,7 @@ static void sphclassical_calc_dens(ParticleData *pa, float UNUSED(dfra), SPHData
pfr.data = data;
pfr.h = interaction_radius * sphdata->hfac;
pfr.pa = pa;
pfr.mass = sphdata->mass;
sph_evaluate_func( NULL, psys, pa->state.co, &pfr, interaction_radius, sphclassical_density_accum_cb);
pa->sphdensity = MIN2(MAX2(data[0], fluid->rest_density * 0.9f), fluid->rest_density * 1.1f);
@@ -2851,7 +2854,8 @@ void psys_sph_density(BVHTree *tree, SPHData *sphdata, float co[3], float vars[2
density[0] = density[1] = 0.0f;
pfr.data = density;
pfr.h = interaction_radius*sphdata->hfac;
pfr.h = interaction_radius * sphdata->hfac;
pfr.mass = sphdata->mass;
sph_evaluate_func(tree, psys, co, &pfr, interaction_radius, sphdata->density_cb);
@@ -4220,7 +4224,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
ParticleSettings *part = sim->psys->part;
psys_sph_init(sim, &sphdata);
if (part->fluid->flag & SPH_SOLVER_DDR) {
if (part->fluid->solver == SPH_SOLVER_DDR) {
/* Apply SPH forces using double-density relaxation algorithm
* (Clavat et. al.) */
#pragma omp parallel for firstprivate (sphdata) private (pa) schedule(dynamic,5)
+11 -11
View File
@@ -272,7 +272,7 @@ static void ptcache_particle_read(int index, void *psys_v, void **data, float cf
ParticleSystem *psys= psys_v;
ParticleData *pa;
BoidParticle *boid;
float timestep = 0.04f*psys->part->timetweak;
float timestep = 0.04f * psys->part->timetweak;
if (index >= psys->totpart)
return;
@@ -333,7 +333,7 @@ static void ptcache_particle_interpolate(int index, void *psys_v, void **data, f
ParticleSystem *psys= psys_v;
ParticleData *pa;
ParticleKey keys[4];
float dfra, timestep = 0.04f*psys->part->timetweak;
float dfra, timestep = 0.04f * psys->part->timetweak;
if (index >= psys->totpart)
return;
@@ -559,7 +559,7 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
float dt, dx, *dens, *react, *fuel, *flame, *heat, *heatold, *vx, *vy, *vz, *r, *g, *b;
unsigned char *obstacles;
unsigned int in_len = sizeof(float)*(unsigned int)res;
unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer");
unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len) * 4, "pointcache_lzo_buffer");
//int mode = res >= 1000000 ? 2 : 1;
int mode=1; // light
if (sds->cache_comp == SM_CACHE_HEAVY) mode=2; // heavy
@@ -792,7 +792,7 @@ static int ptcache_dynamicpaint_write(PTCacheFile *pf, void *dp_v)
int cache_compress = 1;
/* version header */
ptcache_file_write(pf, DPAINT_CACHE_VERSION, 1, sizeof(char)*4);
ptcache_file_write(pf, DPAINT_CACHE_VERSION, 1, sizeof(char) * 4);
if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && surface->data) {
int total_points=surface->data->total_points;
@@ -831,7 +831,7 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v)
char version[4];
/* version header */
ptcache_file_read(pf, version, 1, sizeof(char)*4);
ptcache_file_read(pf, version, 1, sizeof(char) * 4);
if (strncmp(version, DPAINT_CACHE_VERSION, 4)) {printf("Dynamic Paint: Invalid cache version: %s!\n", version); return 0;}
if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && surface->data) {
@@ -1163,7 +1163,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup
*/
#define MAX_PTCACHE_PATH FILE_MAX
#define MAX_PTCACHE_FILE ((FILE_MAX)*2)
#define MAX_PTCACHE_FILE (FILE_MAX * 2)
static int ptcache_path(PTCacheID *pid, char *filename)
{
@@ -1258,7 +1258,7 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra)
{
PTCacheFile *pf;
FILE *fp = NULL;
char filename[(FILE_MAX)*2];
char filename[FILE_MAX * 2];
#ifndef DURIAN_POINTCACHE_LIB_OK
/* don't allow writing for linked objects */
@@ -1311,7 +1311,7 @@ static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result,
size_t out_len = len;
#endif
unsigned char *in;
unsigned char *props = MEM_callocN(16*sizeof(char), "tmp");
unsigned char *props = MEM_callocN(16 * sizeof(char), "tmp");
ptcache_file_read(pf, &compressed, 1, sizeof(unsigned char));
if (compressed) {
@@ -1354,7 +1354,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns
int r = 0;
unsigned char compressed = 0;
size_t out_len= 0;
unsigned char *props = MEM_callocN(16*sizeof(char), "tmp");
unsigned char *props = MEM_callocN(16 * sizeof(char), "tmp");
size_t sizeOfIt = 5;
(void)mode; /* unused when building w/o compression */
@@ -1787,7 +1787,7 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm)
for (i=0; i<BPHYS_TOT_DATA; i++) {
if (pm->data[i]) {
unsigned int in_len = pm->totpoint*ptcache_data_size[i];
unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer");
unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len) * 4, "pointcache_lzo_buffer");
ptcache_file_compressed_write(pf, (unsigned char *)(pm->data[i]), in_len, out, pid->cache->compression);
MEM_freeN(out);
}
@@ -1820,7 +1820,7 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm)
if (pid->cache->compression) {
unsigned int in_len = extra->totdata * ptcache_extra_datasize[extra->type];
unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer");
unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len) * 4, "pointcache_lzo_buffer");
ptcache_file_compressed_write(pf, (unsigned char *)(extra->data), in_len, out, pid->cache->compression);
MEM_freeN(out);
}
+37 -4
View File
@@ -27,6 +27,10 @@
* \ingroup bke
*/
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "MEM_guardedalloc.h"
@@ -39,10 +43,6 @@
#include "BKE_report.h"
#include "BKE_global.h" /* G.background only */
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
static const char *report_type_str(int type)
{
switch (type) {
@@ -302,3 +302,36 @@ int BKE_reports_contain(ReportList *reports, ReportType level)
return FALSE;
}
bool BKE_report_write_file_fp(FILE *fp, ReportList *reports, const char *header)
{
Report *report;
if (header) {
fputs(header, fp);
}
for (report = reports->list.first; report; report = report->next) {
fprintf((FILE *)fp, "%s # %s\n", report->message, report->typestr);
}
return true;
}
bool BKE_report_write_file(const char *filepath, ReportList *reports, const char *header)
{
FILE *fp;
errno = 0;
fp = BLI_fopen(filepath, "wb");
if (fp == NULL) {
fprintf(stderr, "Unable to save '%s': %s\n",
filepath, errno ? strerror(errno) : "Unknown error opening file");
return false;
}
BKE_report_write_file_fp(fp, reports, header);
fclose(fp);
return true;
}
+44
View File
@@ -1045,6 +1045,47 @@ static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene)
}
}
/* deps hack - do extra recalcs at end */
static void scene_depsgraph_hack(Scene *scene, Scene *scene_parent)
{
Base *base;
scene->customdata_mask = scene_parent->customdata_mask;
/* sets first, we allow per definition current scene to have
* dependencies on sets, but not the other way around. */
if (scene->set)
scene_depsgraph_hack(scene->set, scene_parent);
for (base = scene->base.first; base; base = base->next) {
Object *ob = base->object;
if (ob->depsflag) {
int recalc = 0;
// printf("depshack %s\n", ob->id.name+2);
if (ob->depsflag & OB_DEPS_EXTRA_OB_RECALC)
recalc |= OB_RECALC_OB;
if (ob->depsflag & OB_DEPS_EXTRA_DATA_RECALC)
recalc |= OB_RECALC_DATA;
ob->recalc |= recalc;
BKE_object_handle_update(scene_parent, ob);
if (ob->dup_group && (ob->transflag & OB_DUPLIGROUP)) {
GroupObject *go;
for (go = ob->dup_group->gobject.first; go; go = go->next) {
if (go->ob)
go->ob->recalc |= recalc;
}
group_handle_recalc_and_update(scene_parent, ob, ob->dup_group);
}
}
}
}
static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scene_parent)
{
Base *base;
@@ -1080,6 +1121,7 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen
/* update masking curves */
BKE_mask_update_scene(bmain, scene, FALSE);
}
/* this is called in main loop, doing tagged updates before redraw */
@@ -1172,6 +1214,8 @@ void BKE_scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay)
/* BKE_object_handle_update() on all objects, groups and sets */
scene_update_tagged_recursive(bmain, sce, sce);
scene_depsgraph_hack(sce, sce);
/* notify editors and python about recalc */
BLI_callback_exec(bmain, &sce->id, BLI_CB_EVT_SCENE_UPDATE_POST);
BLI_callback_exec(bmain, &sce->id, BLI_CB_EVT_FRAME_CHANGE_POST);
@@ -167,6 +167,7 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
newar->prev = newar->next = NULL;
newar->handlers.first = newar->handlers.last = NULL;
newar->uiblocks.first = newar->uiblocks.last = NULL;
newar->ui_lists.first = newar->ui_lists.last = NULL;
newar->swinid = 0;
/* use optional regiondata callback */
@@ -1150,7 +1150,7 @@ static void do_mul_effect_byte(float facf0, float facf1, int x, int y, unsigned
fac3 = (int)(256.0f * facf1);
/* formula:
* fac * (a * b) + (1-fac)*a => fac * a * (b - 1) + axaux = c * px + py * s; //+centx
* fac * (a * b) + (1 - fac) * a => fac * a * (b - 1) + axaux = c * px + py * s; //+centx
* yaux = -s * px + c * py; //+centy
*/
+1 -1
View File
@@ -2391,7 +2391,7 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float
BKE_scene_update_for_newframe(context.bmain, scene, scene->lay);
ibuf = sequencer_view3d_cb(scene, camera, context.rectx, context.recty, IB_rect,
context.scene->r.seq_prev_type, context.scene->r.seq_flag & R_SEQ_SOLID_TEX,
TRUE, FALSE, err_out);
TRUE, scene->r.alphamode, err_out);
if (ibuf == NULL) {
fprintf(stderr, "seq_render_scene_strip failed to get opengl buffer: %s\n", err_out);
}
@@ -1322,8 +1322,8 @@ static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop)
for (index = 0; index < totface; index++) {
CCGFace *f = ccgdm->faceMap[index].face;
int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
/* int flag = (faceFlags)? faceFlags[index*2]: ME_SMOOTH; */ /* UNUSED */
/* int mat_nr = (faceFlags)? faceFlags[index*2+1]: 0; */ /* UNUSED */
/* int flag = (faceFlags) ? faceFlags[index * 2]: ME_SMOOTH; */ /* UNUSED */
/* int mat_nr = (faceFlags) ? faceFlags[index * 2 + 1]: 0; */ /* UNUSED */
for (S = 0; S < numVerts; S++) {
for (y = 0; y < gridSize - 1; y++) {
@@ -3328,7 +3328,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
/*I think this is for interpolating the center vert?*/
w2 = w; // + numVerts*(g2_wid-1)*(g2_wid-1); //numVerts*((g2_wid-1)*g2_wid+g2_wid-1);
w2 = w; // + numVerts*(g2_wid-1) * (g2_wid-1); //numVerts*((g2_wid-1) * g2_wid+g2_wid-1);
DM_interp_vert_data(dm, &ccgdm->dm, vertidx, w2,
numVerts, vertNum);
if (vertOrigIndex) {
+7 -1
View File
@@ -53,6 +53,7 @@ float area_tri_signed_v2(const float v1[2], const float v2[2], const float v3[2]
float area_tri_v3(const float a[3], const float b[3], const float c[3]);
float area_quad_v3(const float a[3], const float b[3], const float c[3], const float d[3]);
float area_poly_v3(int nr, float verts[][3], const float normal[3]);
float area_poly_v2(int nr, float verts[][2]);
int is_quad_convex_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3]);
int is_quad_convex_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2]);
@@ -260,7 +261,12 @@ MINLINE void madd_sh_shfl(float r[9], const float sh[3], const float f);
float form_factor_hemi_poly(float p[3], float n[3],
float v1[3], float v2[3], float v3[3], float v4[3]);
void axis_dominant_v3(int *axis_a, int *axis_b, const float axis[3]);
void axis_dominant_v3(int *r_axis_a, int *r_axis_b, const float axis[3]);
float axis_dominant_v3_max(int *r_axis_a, int *r_axis_b, const float axis[3])
#ifdef __GNUC__
__attribute__((warn_unused_result))
#endif
;
MINLINE int max_axis_v3(const float vec[3]);
MINLINE int min_axis_v3(const float vec[3]);
+2
View File
@@ -56,6 +56,8 @@ void BLI_rctf_translate(struct rctf *rect, float x, float y);
void BLI_rcti_translate(struct rcti *rect, int x, int y);
void BLI_rcti_resize(struct rcti *rect, int x, int y);
void BLI_rctf_resize(struct rctf *rect, float x, float y);
void BLI_rcti_scale(rcti *rect, const float scale);
void BLI_rctf_scale(rctf *rect, const float scale);
void BLI_rctf_interp(struct rctf *rect, const struct rctf *rect_a, const struct rctf *rect_b, const float fac);
//void BLI_rcti_interp(struct rctf *rect, struct rctf *rect_a, struct rctf *rect_b, float fac);
int BLI_rctf_clamp_pt_v(const struct rctf *rect, float xy[2]);
+1 -1
View File
@@ -103,7 +103,7 @@ enum {
BLI_SCANFILL_CALC_REMOVE_DOUBLES = (1 << 1),
/* note: This flag removes checks for overlapping polygons.
* when this flag is set, we'll never get back more faces then (totvert - 2)*/
* when this flag is set, we'll never get back more faces then (totvert - 2) */
BLI_SCANFILL_CALC_HOLES = (1 << 2)
};
+4
View File
@@ -32,6 +32,10 @@
* \ingroup bli
*/
#ifndef NDEBUG /* for BLI_assert */
#include <stdio.h>
#endif
/* note: use of (int, TRUE / FALSE) is deprecated,
* use (bool, true / false) instead */
#ifdef HAVE_STDBOOL_H
+106 -39
View File
@@ -131,35 +131,43 @@ float area_tri_v3(const float v1[3], const float v2[3], const float v3[3])
float area_poly_v3(int nr, float verts[][3], const float normal[3])
{
float x, y, z, area, max;
float *cur, *prev;
int a, px = 0, py = 1;
/* first: find dominant axis: 0==X, 1==Y, 2==Z
* don't use 'axis_dominant_v3()' because we need max axis too */
x = fabsf(normal[0]);
y = fabsf(normal[1]);
z = fabsf(normal[2]);
max = max_fff(x, y, z);
if (max == y) py = 2;
else if (max == x) {
px = 1;
py = 2;
}
int a, px, py;
const float max = axis_dominant_v3_max(&px, &py, normal);
float area;
float *co_curr, *co_prev;
/* The Trapezium Area Rule */
prev = verts[nr - 1];
cur = verts[0];
area = 0;
co_prev = verts[nr - 1];
co_curr = verts[0];
area = 0.0f;
for (a = 0; a < nr; a++) {
area += (cur[px] - prev[px]) * (cur[py] + prev[py]);
prev = verts[a];
cur = verts[a + 1];
area += (co_curr[px] - co_prev[px]) * (co_curr[py] + co_prev[py]);
co_prev = verts[a];
co_curr = verts[a + 1];
}
return fabsf(0.5f * area / max);
}
float area_poly_v2(int nr, float verts[][2])
{
int a;
float area;
float *co_curr, *co_prev;
/* The Trapezium Area Rule */
co_prev = verts[nr - 1];
co_curr = verts[0];
area = 0.0f;
for (a = 0; a < nr; a++) {
area += (co_curr[0] - co_prev[0]) * (co_curr[1] + co_prev[1]);
co_prev = verts[a];
co_curr = verts[a + 1];
}
return fabsf(0.5f * area);
}
/********************************* Distance **********************************/
/* distance p to line v1-v2
@@ -329,7 +337,7 @@ void closest_on_tri_to_point_v3(float r[3], const float p[3],
return;
}
/* Check if P in edge region of AB, if so return projection of P onto AB */
vc = d1*d4 - d3*d2;
vc = d1 * d4 - d3 * d2;
if (vc <= 0.0f && d1 >= 0.0f && d3 <= 0.0f) {
float v = d1 / (d1 - d3);
/* barycentric coordinates (1-v,v,0) */
@@ -346,7 +354,7 @@ void closest_on_tri_to_point_v3(float r[3], const float p[3],
return;
}
/* Check if P in edge region of AC, if so return projection of P onto AC */
vb = d5*d2 - d1*d6;
vb = d5 * d2 - d1 * d6;
if (vb <= 0.0f && d2 >= 0.0f && d6 <= 0.0f) {
float w = d2 / (d2 - d6);
/* barycentric coordinates (1-w,0,w) */
@@ -354,7 +362,7 @@ void closest_on_tri_to_point_v3(float r[3], const float p[3],
return;
}
/* Check if P in edge region of BC, if so return projection of P onto BC */
va = d3*d6 - d5*d4;
va = d3 * d6 - d5 * d4;
if (va <= 0.0f && (d4 - d3) >= 0.0f && (d5 - d6) >= 0.0f) {
float w = (d4 - d3) / ((d4 - d3) + (d5 - d6));
/* barycentric coordinates (0,1-w,w) */
@@ -1817,7 +1825,7 @@ static int point_in_slice_as(float p[3], float origin[3], float normal[3])
return 1;
}
/*mama (knowing the squared length of the normal)*/
/*mama (knowing the squared length of the normal) */
static int point_in_slice_m(float p[3], float origin[3], float normal[3], float lns)
{
float h, rp[3];
@@ -1952,15 +1960,27 @@ void plot_line_v2v2i(const int p1[2], const int p2[2], int (*callback)(int, int,
/****************************** Interpolation ********************************/
/* get the 2 dominant axis values, 0==X, 1==Y, 2==Z */
void axis_dominant_v3(int *axis_a, int *axis_b, const float axis[3])
void axis_dominant_v3(int *r_axis_a, int *r_axis_b, const float axis[3])
{
const float xn = fabsf(axis[0]);
const float yn = fabsf(axis[1]);
const float zn = fabsf(axis[2]);
if (zn >= xn && zn >= yn) { *axis_a = 0; *axis_b = 1; }
else if (yn >= xn && yn >= zn) { *axis_a = 0; *axis_b = 2; }
else { *axis_a = 1; *axis_b = 2; }
if (zn >= xn && zn >= yn) { *r_axis_a = 0; *r_axis_b = 1; }
else if (yn >= xn && yn >= zn) { *r_axis_a = 0; *r_axis_b = 2; }
else { *r_axis_a = 1; *r_axis_b = 2; }
}
/* same as axis_dominant_v3 but return the max value */
float axis_dominant_v3_max(int *r_axis_a, int *r_axis_b, const float axis[3])
{
const float xn = fabsf(axis[0]);
const float yn = fabsf(axis[1]);
const float zn = fabsf(axis[2]);
if (zn >= xn && zn >= yn) { *r_axis_a = 0; *r_axis_b = 1; return zn; }
else if (yn >= xn && yn >= zn) { *r_axis_a = 0; *r_axis_b = 2; return yn; }
else { *r_axis_a = 1; *r_axis_b = 2; return xn; }
}
static float tri_signed_area(const float v1[3], const float v2[3], const float v3[3], const int i, const int j)
@@ -2334,14 +2354,25 @@ void interp_weights_poly_v3(float *w, float v[][3], const int n, const float co[
{
/* TODO: t1 and t2 overlap each iter, we could call this only once per iter and reuse previous value */
float totweight, t1, t2, len, *vmid, *vprev, *vnext;
int i;
int i, i_next, i_curr;
bool edge_interp = false;
totweight = 0.0f;
for (i = 0; i < n; i++) {
i_curr = i;
i_next = (i == n - 1) ? 0 : i + 1;
vmid = v[i];
vprev = (i == 0) ? v[n - 1] : v[i - 1];
vnext = (i == n - 1) ? v[0] : v[i + 1];
vnext = v[i_next];
/* Mark Mayer et al algorithm that is used here does not operate well if vertex is close
* to borders of face. In that case, do simple linear interpolation between the two edge vertices */
if (dist_to_line_segment_v3(co, vmid, vnext) < 10 * FLT_EPSILON) {
edge_interp = true;
break;
}
t1 = mean_value_half_tan_v3(co, vprev, vmid);
t2 = mean_value_half_tan_v3(co, vmid, vnext);
@@ -2351,25 +2382,49 @@ void interp_weights_poly_v3(float *w, float v[][3], const int n, const float co[
totweight += w[i];
}
if (totweight != 0.0f) {
for (i = 0; i < n; i++) {
w[i] /= totweight;
if (edge_interp) {
float len_curr = len_v3v3(co, vmid);
float len_next = len_v3v3(co, vnext);
float edge_len = len_curr + len_next;
for (i = 0; i < n; i++)
w[i] = 0.0;
w[i_curr] = len_next / edge_len;
w[i_next] = len_curr / edge_len;
}
else {
if (totweight != 0.0f) {
for (i = 0; i < n; i++) {
w[i] /= totweight;
}
}
}
}
void interp_weights_poly_v2(float *w, float v[][2], const int n, const float co[2])
{
/* TODO: t1 and t2 overlap each iter, we could call this only once per iter and reuse previous value */
float totweight, t1, t2, len, *vmid, *vprev, *vnext;
int i;
int i, i_next, i_curr;
bool edge_interp = false;
totweight = 0.0f;
for (i = 0; i < n; i++) {
i_curr = i;
i_next = (i == n - 1) ? 0 : i + 1;
vmid = v[i];
vprev = (i == 0) ? v[n - 1] : v[i - 1];
vnext = (i == n - 1) ? v[0] : v[i + 1];
vnext = v[i_next];
/* Mark Mayer et al algorithm that is used here does not operate well if vertex is close
* to borders of face. In that case, do simple linear interpolation between the two edge vertices */
if (dist_to_line_segment_v2(co, vmid, vnext) < 10 * FLT_EPSILON) {
edge_interp = true;
break;
}
t1 = mean_value_half_tan_v2(co, vprev, vmid);
t2 = mean_value_half_tan_v2(co, vmid, vnext);
@@ -2379,9 +2434,21 @@ void interp_weights_poly_v2(float *w, float v[][2], const int n, const float co[
totweight += w[i];
}
if (totweight != 0.0f) {
for (i = 0; i < n; i++) {
w[i] /= totweight;
if (edge_interp) {
float len_curr = len_v2v2(co, vmid);
float len_next = len_v2v2(co, vnext);
float edge_len = len_curr + len_next;
for (i = 0; i < n; i++)
w[i] = 0.0;
w[i_curr] = len_next / edge_len;
w[i_next] = len_curr / edge_len;
}
else {
if (totweight != 0.0f) {
for (i = 0; i < n; i++) {
w[i] /= totweight;
}
}
}
}
+24
View File
@@ -317,6 +317,30 @@ void BLI_rctf_resize(rctf *rect, float x, float y)
rect->ymax = rect->ymin + y;
}
void BLI_rcti_scale(rcti *rect, const float scale)
{
const int cent_x = BLI_rcti_cent_x(rect);
const int cent_y = BLI_rcti_cent_y(rect);
const int size_x_half = BLI_rcti_size_x(rect) * (scale * 0.5f);
const int size_y_half = BLI_rcti_size_y(rect) * (scale * 0.5f);
rect->xmin = cent_x - size_x_half;
rect->ymin = cent_y - size_y_half;
rect->xmax = cent_x + size_x_half;
rect->ymax = cent_y + size_y_half;
}
void BLI_rctf_scale(rctf *rect, const float scale)
{
const float cent_x = BLI_rctf_cent_x(rect);
const float cent_y = BLI_rctf_cent_y(rect);
const float size_x_half = BLI_rctf_size_x(rect) * (scale * 0.5f);
const float size_y_half = BLI_rctf_size_y(rect) * (scale * 0.5f);
rect->xmin = cent_x - size_x_half;
rect->ymin = cent_y - size_y_half;
rect->xmax = cent_x + size_x_half;
rect->ymax = cent_y + size_y_half;
}
void BLI_rctf_interp(rctf *rect, const rctf *rect_a, const rctf *rect_b, const float fac)
{
const float ifac = 1.0f - fac;
+1 -1
View File
@@ -412,7 +412,7 @@ int BLI_natstrcmp(const char *s1, const char *s2)
void BLI_timestr(double _time, char *str)
{
/* format 00:00:00.00 (hr:min:sec) string has to be 12 long */
int hr = ( (int) _time) / (60*60);
int hr = ( (int) _time) / (60 * 60);
int min = (((int) _time) / 60 ) % 60;
int sec = ( (int) (_time)) % 60;
int hun = ( (int) (_time * 100.0)) % 100;
@@ -5137,6 +5137,16 @@ static void direct_link_scene(FileData *fd, Scene *sce)
sce->toolsettings->imapaint.paintcursor = NULL;
sce->toolsettings->particle.paintcursor = NULL;
/* in rare cases this is needed, see [#33806] */
if (sce->toolsettings->vpaint) {
sce->toolsettings->vpaint->vpaint_prev = NULL;
sce->toolsettings->vpaint->tot = 0;
}
if (sce->toolsettings->wpaint) {
sce->toolsettings->wpaint->wpaint_prev = NULL;
sce->toolsettings->wpaint->tot = 0;
}
}
if (sce->ed) {
@@ -8811,6 +8821,49 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
if (main->versionfile < 265 || (main->versionfile == 265 && main->subversionfile < 7)) {
Curve *cu;
for (cu = main->curve.first; cu; cu = cu->id.next) {
if (cu->flag & (CU_FRONT | CU_BACK)) {
if ( cu->ext1 != 0.0f || cu->ext2 != 0.0f) {
Nurb *nu;
for (nu = cu->nurb.first; nu; nu = nu->next) {
int a;
if (nu->bezt) {
BezTriple *bezt = nu->bezt;
a = nu->pntsu;
while (a--) {
bezt->radius = 1.0f;
bezt++;
}
}
else if (nu->bp) {
BPoint *bp = nu->bp;
a = nu->pntsu * nu->pntsv;
while (a--) {
bp->radius = 1.0f;
bp++;
}
}
}
}
}
}
}
if (!MAIN_VERSION_ATLEAST(main, 265, 8)) {
Mesh *me;
for (me = main->mesh.first; me; me = me->id.next) {
BKE_mesh_do_versions_cd_flag_init(me);
}
}
// if (main->versionfile < 265 || (main->versionfile == 265 && main->subversionfile < 7)) {
#ifdef WITH_FREESTYLE
/* default values in Freestyle settings */
+3 -2
View File
@@ -48,11 +48,12 @@
#include "BLO_readfile.h"
#include "BLO_runtime.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BKE_blender.h"
#include "BKE_report.h"
#include "BLI_blenlib.h"
/* Runtime reading */
static int handle_read_msb_int(int handle)
+3 -3
View File
@@ -1423,8 +1423,8 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
int size = mmd->dyngridsize;
writestruct(wd, DATA, "MDefInfluence", mmd->totinfluence, mmd->bindinfluences);
writedata(wd, DATA, sizeof(int)*(mmd->totvert+1), mmd->bindoffsets);
writedata(wd, DATA, sizeof(float)*3*mmd->totcagevert,
writedata(wd, DATA, sizeof(int) * (mmd->totvert + 1), mmd->bindoffsets);
writedata(wd, DATA, sizeof(float) * 3 * mmd->totcagevert,
mmd->bindcagecos);
writestruct(wd, DATA, "MDefCell", size*size*size, mmd->dyngrid);
writestruct(wd, DATA, "MDefInfluence", mmd->totinfluence, mmd->dyninfluences);
@@ -1681,7 +1681,7 @@ static void write_mdisps(WriteData *wd, int count, MDisps *mdlist, int external)
MDisps *md = &mdlist[i];
if (md->disps) {
if (!external)
writedata(wd, DATA, sizeof(float)*3*md->totdisp, md->disps);
writedata(wd, DATA, sizeof(float) * 3 * md->totdisp, md->disps);
}
if (md->hidden)
+15 -3
View File
@@ -184,10 +184,10 @@ typedef struct BMesh {
* BM_LOOP isn't handled so far. */
char elem_index_dirty;
/*element pools*/
/* element pools */
struct BLI_mempool *vpool, *epool, *lpool, *fpool;
/*operator api stuff (must be all NULL or all alloc'd)*/
/* operator api stuff (must be all NULL or all alloc'd) */
struct BLI_mempool *vtoolflagpool, *etoolflagpool, *ftoolflagpool;
int stackdepth;
@@ -205,7 +205,7 @@ typedef struct BMesh {
* Only use when the edit mesh cant be accessed - campbell */
short selectmode;
/*ID of the shape key this bmesh came from*/
/* ID of the shape key this bmesh came from */
int shapenr;
int walkers, totflags;
@@ -257,6 +257,18 @@ enum {
/* defines */
#define BM_ELEM_CD_GET_VOID_P(ele, offset) \
((void)0, (void *)((char *)(ele)->head.data + (offset)))
#define BM_ELEM_CD_SET_FLOAT(ele, offset, f) \
{ *((float *)((char *)(ele)->head.data + (offset))) = (f); } (void)0
#define BM_ELEM_CD_GET_FLOAT(ele, offset) \
((void)0, *((float *)((char *)(ele)->head.data + (offset))))
#define BM_ELEM_CD_GET_FLOAT_AS_UCHAR(ele, offset) \
(unsigned char)(BM_ELEM_CD_GET_FLOAT(ele, offset) * 255.0f)
/*forward declarations*/
#ifdef USE_BMESH_HOLES
+5 -29
View File
@@ -606,9 +606,9 @@ void BM_loop_interp_from_face(BMesh *bm, BMLoop *target, BMFace *source,
void **vblocks = do_vertex ? BLI_array_alloca(vblocks, source->len) : NULL;
void **blocks = BLI_array_alloca(blocks, source->len);
float (*cos)[3] = BLI_array_alloca(cos, source->len);
float (*cos_2d)[2] = BLI_array_alloca(cos_2d, source->len);
float *w = BLI_array_alloca(w, source->len);
float co[3];
float cent[3] = {0.0f, 0.0f, 0.0f};
float co[2];
int i, ax, ay;
BM_elem_attrs_copy(bm, bm, source, target->f);
@@ -617,7 +617,6 @@ void BM_loop_interp_from_face(BMesh *bm, BMLoop *target, BMFace *source,
l_iter = l_first = BM_FACE_FIRST_LOOP(source);
do {
copy_v3_v3(cos[i], l_iter->v->co);
add_v3_v3(cent, cos[i]);
w[i] = 0.0f;
blocks[i] = l_iter->head.data;
@@ -634,28 +633,17 @@ void BM_loop_interp_from_face(BMesh *bm, BMLoop *target, BMFace *source,
axis_dominant_v3(&ax, &ay, source->no);
/* scale source face coordinates a bit, so points sitting directly on an
* edge will work. */
mul_v3_fl(cent, 1.0f / (float)source->len);
for (i = 0; i < source->len; i++) {
float vec[3], tmp[3];
sub_v3_v3v3(vec, cent, cos[i]);
mul_v3_fl(vec, 0.001f);
add_v3_v3(cos[i], vec);
copy_v3_v3(tmp, cos[i]);
cos[i][0] = tmp[ax];
cos[i][1] = tmp[ay];
cos[i][2] = 0.0f;
cos_2d[i][0] = cos[i][ax];
cos_2d[i][1] = cos[i][ay];
}
/* interpolate */
co[0] = target->v->co[ax];
co[1] = target->v->co[ay];
co[2] = 0.0f;
interp_weights_poly_v3(w, cos, source->len, co);
interp_weights_poly_v2(w, cos_2d, source->len, co);
CustomData_bmesh_interp(&bm->ldata, blocks, w, NULL, source->len, target->head.data);
if (do_vertex) {
CustomData_bmesh_interp(&bm->vdata, vblocks, w, NULL, source->len, target->v->head.data);
@@ -676,30 +664,18 @@ void BM_vert_interp_from_face(BMesh *bm, BMVert *v, BMFace *source)
void **blocks = BLI_array_alloca(blocks, source->len);
float (*cos)[3] = BLI_array_alloca(cos, source->len);
float *w = BLI_array_alloca(w, source->len);
float cent[3] = {0.0f, 0.0f, 0.0f};
int i;
i = 0;
l_iter = l_first = BM_FACE_FIRST_LOOP(source);
do {
copy_v3_v3(cos[i], l_iter->v->co);
add_v3_v3(cent, cos[i]);
w[i] = 0.0f;
blocks[i] = l_iter->v->head.data;
i++;
} while ((l_iter = l_iter->next) != l_first);
/* scale source face coordinates a bit, so points sitting directly on an
* edge will work. */
mul_v3_fl(cent, 1.0f / (float)source->len);
for (i = 0; i < source->len; i++) {
float vec[3];
sub_v3_v3v3(vec, cent, cos[i]);
mul_v3_fl(vec, 0.01f);
add_v3_v3(cos[i], vec);
}
/* interpolate */
interp_weights_poly_v3(w, cos, source->len, v->co);
CustomData_bmesh_interp(&bm->vdata, blocks, w, NULL, source->len, v->head.data);
+2 -2
View File
@@ -523,14 +523,14 @@ void BM_log_mesh_elems_reorder(BMesh *bm, BMLog *log)
i = 0;
varr = MEM_mallocN(sizeof(int) * bm->totvert, AT);
BM_ITER_MESH (v, &bm_iter, bm, BM_VERTS_OF_MESH) {
((unsigned int*)varr)[i++] = bm_log_vert_id_get(log, v);
((unsigned int *)varr)[i++] = bm_log_vert_id_get(log, v);
}
/* Put all face IDs into an array */
i = 0;
farr = MEM_mallocN(sizeof(int) * bm->totface, AT);
BM_ITER_MESH (f, &bm_iter, bm, BM_FACES_OF_MESH) {
((unsigned int*)farr)[i++] = bm_log_face_id_get(log, f);
((unsigned int *)farr)[i++] = bm_log_face_id_get(log, f);
}
/* Create BMVert index remap array */
+91 -25
View File
@@ -98,6 +98,70 @@
#include "bmesh.h"
#include "intern/bmesh_private.h" /* for element checking */
void BM_mesh_cd_flag_ensure(BMesh *bm, Mesh *mesh, const char cd_flag)
{
const char cd_flag_all = BM_mesh_cd_flag_from_bmesh(bm) | cd_flag;
BM_mesh_cd_flag_apply(bm, cd_flag_all);
if (mesh) {
mesh->cd_flag = cd_flag_all;
}
}
void BM_mesh_cd_flag_apply(BMesh *bm, const char cd_flag)
{
/* CustomData_bmesh_init_pool() must run first */
BLI_assert(bm->vdata.totlayer == 0 || bm->vdata.pool != NULL);
BLI_assert(bm->edata.totlayer == 0 || bm->edata.pool != NULL);
if (cd_flag & ME_CDFLAG_VERT_BWEIGHT) {
if (!CustomData_has_layer(&bm->vdata, CD_BWEIGHT)) {
BM_data_layer_add(bm, &bm->vdata, CD_BWEIGHT);
}
}
else {
if (CustomData_has_layer(&bm->vdata, CD_BWEIGHT)) {
BM_data_layer_free(bm, &bm->vdata, CD_BWEIGHT);
}
}
if (cd_flag & ME_CDFLAG_EDGE_BWEIGHT) {
if (!CustomData_has_layer(&bm->edata, CD_BWEIGHT)) {
BM_data_layer_add(bm, &bm->edata, CD_BWEIGHT);
}
}
else {
if (CustomData_has_layer(&bm->edata, CD_BWEIGHT)) {
BM_data_layer_free(bm, &bm->edata, CD_BWEIGHT);
}
}
if (cd_flag & ME_CDFLAG_EDGE_CREASE) {
if (!CustomData_has_layer(&bm->edata, CD_CREASE)) {
BM_data_layer_add(bm, &bm->edata, CD_CREASE);
}
}
else {
if (CustomData_has_layer(&bm->edata, CD_CREASE)) {
BM_data_layer_free(bm, &bm->edata, CD_CREASE);
}
}
}
char BM_mesh_cd_flag_from_bmesh(BMesh *bm)
{
char cd_flag = 0;
if (CustomData_has_layer(&bm->vdata, CD_BWEIGHT)) {
cd_flag |= ME_CDFLAG_VERT_BWEIGHT;
}
if (CustomData_has_layer(&bm->edata, CD_BWEIGHT)) {
cd_flag |= ME_CDFLAG_EDGE_BWEIGHT;
}
if (CustomData_has_layer(&bm->edata, CD_CREASE)) {
cd_flag |= ME_CDFLAG_EDGE_CREASE;
}
return cd_flag;
}
/* Mesh -> BMesh */
void BM_mesh_bm_from_me(BMesh *bm, Mesh *me, int set_key, int act_key_nr)
{
@@ -116,6 +180,10 @@ void BM_mesh_bm_from_me(BMesh *bm, Mesh *me, int set_key, int act_key_nr)
int *keyi;
int totuv, i, j;
int cd_vert_bweight_offset;
int cd_edge_bweight_offset;
int cd_edge_crease_offset;
/* free custom data */
/* this isnt needed in most cases but do just incase */
CustomData_free(&bm->vdata, bm->totvert);
@@ -152,15 +220,6 @@ void BM_mesh_bm_from_me(BMesh *bm, Mesh *me, int set_key, int act_key_nr)
CustomData_set_layer_name(&bm->ldata, CD_MLOOPUV, i, bm->pdata.layers[li].name);
}
if (!CustomData_has_layer(&bm->edata, CD_CREASE))
CustomData_add_layer(&bm->edata, CD_CREASE, CD_ASSIGN, NULL, 0);
if (!CustomData_has_layer(&bm->edata, CD_BWEIGHT))
CustomData_add_layer(&bm->edata, CD_BWEIGHT, CD_ASSIGN, NULL, 0);
if (!CustomData_has_layer(&bm->vdata, CD_BWEIGHT))
CustomData_add_layer(&bm->vdata, CD_BWEIGHT, CD_ASSIGN, NULL, 0);
if ((act_key_nr != 0) && (me->key != NULL)) {
actkey = BLI_findlink(&me->key->block, act_key_nr - 1);
}
@@ -205,6 +264,12 @@ void BM_mesh_bm_from_me(BMesh *bm, Mesh *me, int set_key, int act_key_nr)
CustomData_bmesh_init_pool(&bm->ldata, me->totloop, BM_LOOP);
CustomData_bmesh_init_pool(&bm->pdata, me->totpoly, BM_FACE);
BM_mesh_cd_flag_apply(bm, me->cd_flag);
cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT);
cd_edge_bweight_offset = CustomData_get_offset(&bm->edata, CD_BWEIGHT);
cd_edge_crease_offset = CustomData_get_offset(&bm->edata, CD_CREASE);
for (i = 0, mvert = me->mvert; i < me->totvert; i++, mvert++) {
v = BM_vert_create(bm, keyco && set_key ? keyco[i] : mvert->co, NULL, BM_CREATE_SKIP_CD);
BM_elem_index_set(v, i); /* set_ok */
@@ -221,9 +286,9 @@ void BM_mesh_bm_from_me(BMesh *bm, Mesh *me, int set_key, int act_key_nr)
normal_short_to_float_v3(v->no, mvert->no);
/* Copy Custom Data */
CustomData_to_bmesh_block(&me->vdata, &bm->vdata, i, &v->head.data);
CustomData_to_bmesh_block(&me->vdata, &bm->vdata, i, &v->head.data, true);
BM_elem_float_data_set(&bm->vdata, v, CD_BWEIGHT, (float)mvert->bweight / 255.0f);
if (cd_vert_bweight_offset != -1) BM_ELEM_CD_SET_FLOAT(v, cd_vert_bweight_offset, (float)mvert->bweight / 255.0f);
/* set shapekey data */
if (me->key) {
@@ -267,10 +332,11 @@ void BM_mesh_bm_from_me(BMesh *bm, Mesh *me, int set_key, int act_key_nr)
}
/* Copy Custom Data */
CustomData_to_bmesh_block(&me->edata, &bm->edata, i, &e->head.data);
CustomData_to_bmesh_block(&me->edata, &bm->edata, i, &e->head.data, true);
if (cd_edge_bweight_offset != -1) BM_ELEM_CD_SET_FLOAT(e, cd_edge_bweight_offset, (float)medge->bweight / 255.0f);
if (cd_edge_crease_offset != -1) BM_ELEM_CD_SET_FLOAT(e, cd_edge_crease_offset, (float)medge->crease / 255.0f);
BM_elem_float_data_set(&bm->edata, e, CD_CREASE, (float)medge->crease / 255.0f);
BM_elem_float_data_set(&bm->edata, e, CD_BWEIGHT, (float)medge->bweight / 255.0f);
}
bm->elem_index_dirty &= ~BM_EDGE; /* added in order, clear dirty flag */
@@ -338,11 +404,11 @@ void BM_mesh_bm_from_me(BMesh *bm, Mesh *me, int set_key, int act_key_nr)
j = 0;
BM_ITER_ELEM_INDEX (l, &iter, f, BM_LOOPS_OF_FACE, j) {
/* Save index of correspsonding MLoop */
CustomData_to_bmesh_block(&me->ldata, &bm->ldata, mpoly->loopstart + j, &l->head.data);
CustomData_to_bmesh_block(&me->ldata, &bm->ldata, mpoly->loopstart + j, &l->head.data, true);
}
/* Copy Custom Data */
CustomData_to_bmesh_block(&me->pdata, &bm->pdata, i, &f->head.data);
CustomData_to_bmesh_block(&me->pdata, &bm->pdata, i, &f->head.data, true);
}
bm->elem_index_dirty &= ~BM_FACE; /* added in order, clear dirty flag */
@@ -496,6 +562,10 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, int dotess)
BMIter iter, liter;
int i, j, ototvert;
const int cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT);
const int cd_edge_bweight_offset = CustomData_get_offset(&bm->edata, CD_BWEIGHT);
const int cd_edge_crease_offset = CustomData_get_offset(&bm->edata, CD_CREASE);
ototvert = me->totvert;
/* new vertex block */
@@ -555,10 +625,6 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, int dotess)
i = 0;
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
float *bweight = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_BWEIGHT);
mvert->bweight = bweight ? (char)((*bweight) * 255) : 0;
copy_v3_v3(mvert->co, v->co);
normal_float_to_short_v3(mvert->no, v->no);
@@ -569,6 +635,8 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, int dotess)
/* copy over customdat */
CustomData_from_bmesh_block(&bm->vdata, &me->vdata, v->head.data, i);
if (cd_vert_bweight_offset != -1) mvert->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(v, cd_vert_bweight_offset);
i++;
mvert++;
@@ -579,13 +647,8 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, int dotess)
med = medge;
i = 0;
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
float *crease = CustomData_bmesh_get(&bm->edata, e->head.data, CD_CREASE);
float *bweight = CustomData_bmesh_get(&bm->edata, e->head.data, CD_BWEIGHT);
med->v1 = BM_elem_index_get(e->v1);
med->v2 = BM_elem_index_get(e->v2);
med->crease = crease ? (char)((*crease) * 255) : 0;
med->bweight = bweight ? (char)((*bweight) * 255) : 0;
med->flag = BM_edge_flag_to_mflag(e);
@@ -596,6 +659,9 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, int dotess)
bmesh_quick_edgedraw_flag(med, e);
if (cd_edge_crease_offset != -1) med->crease = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(e, cd_edge_crease_offset);
if (cd_edge_bweight_offset != -1) med->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(e, cd_edge_bweight_offset);
i++;
med++;
BM_CHECK_ELEMENT(e);

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