Merged changes in the trunk up to revision 51126.

Conflicts resolved:
source/blender/blenloader/intern/readfile.c
source/blender/windowmanager/WM_types.h
This commit is contained in:
2012-10-06 23:32:21 +00:00
281 changed files with 6630 additions and 4255 deletions

View File

@@ -254,6 +254,9 @@ set(CYCLES_CUDA_BINARIES_ARCH sm_13 sm_20 sm_21 sm_30 CACHE STRING "CUDA archite
mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
unset(PLATFORM_DEFAULT)
# LLVM
option(WITH_LLVM "Use LLVM" OFF)
# disable for now, but plan to support on all platforms eventually
option(WITH_MEM_JEMALLOC "Enable malloc replacement (http://www.canonware.com/jemalloc)" OFF)
mark_as_advanced(WITH_MEM_JEMALLOC)
@@ -316,6 +319,9 @@ if(APPLE)
option(WITH_COCOA "Use Cocoa framework instead of deprecated Carbon" ON)
option(USE_QTKIT "Use QtKit instead of Carbon quicktime (needed for having partial quicktime for 64bit)" OFF)
option(WITH_LIBS10.5 "Use 10.5 libs (needed for 64bit builds)" OFF)
if(CMAKE_OSX_ARCHITECTURES MATCHES x86_64)
set(USE_QTKIT ON CACHE BOOL "ON" FORCE) # no Quicktime in 64bit
endif()
endif()
@@ -371,6 +377,11 @@ if(WITH_CYCLES OR WITH_MOD_BOOLEAN)
set(WITH_BOOST ON)
endif()
# auto enable llvm for cycles_osl
if(WITH_CYCLES_OSL)
set(WITH_LLVM ON CACHE BOOL "ON" FORCE)
endif()
# don't store paths to libs for portable distribution
if(WITH_INSTALL_PORTABLE)
set(CMAKE_SKIP_BUILD_RPATH TRUE)
@@ -569,7 +580,7 @@ if(UNIX AND NOT APPLE)
# lame, but until we have proper find module for ffmpeg
set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
if(EXISTS "${FFMPEG}/include/ffmpeg/")
set(FFMPEG_INCLUDE_DIRS "${FFMPEG_INCLUDE_DIRS} ${FFMPEG}/include/ffmpeg")
list(APPEND FFMPEG_INCLUDE_DIRS "${FFMPEG}/include/ffmpeg")
endif()
# end lameness
@@ -704,6 +715,56 @@ if(UNIX AND NOT APPLE)
endif()
endif()
if(WITH_LLVM)
set(LLVM_DIRECTORY ${LIBDIR}/llvm CACHE PATH "Path to the LLVM installation")
set(LLVM_VERSION "3.0" CACHE STRING "Version of LLVM to use" "")
set(LLVM_STATIC YES)
if(LLVM_DIRECTORY)
set(LLVM_CONFIG "${LLVM_DIRECTORY}/bin/llvm-config")
else()
set(LLVM_CONFIG llvm-config)
endif()
execute_process(COMMAND ${LLVM_CONFIG} --version
OUTPUT_VARIABLE LLVM_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${LLVM_CONFIG} --prefix
OUTPUT_VARIABLE LLVM_DIRECTORY
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${LLVM_CONFIG} --libdir
OUTPUT_VARIABLE LLVM_LIB_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${LLVM_CONFIG} --includedir
OUTPUT_VARIABLE LLVM_INCLUDES
OUTPUT_STRIP_TRAILING_WHITESPACE)
find_library(LLVM_LIBRARY
NAMES libLLVMAnalysis.a # first of a whole bunch of libs to get
PATHS ${LLVM_LIB_DIR})
message(STATUS "LLVM version = ${LLVM_VERSION}")
message(STATUS "LLVM dir = ${LLVM_DIRECTORY}")
message(STATUS "LLVM includes = ${LLVM_INCLUDES}")
message(STATUS "LLVM lib dir = ${LLVM_LIB_DIR}")
if(LLVM_LIBRARY AND LLVM_INCLUDES AND LLVM_DIRECTORY AND LLVM_LIB_DIR)
# ensure include directory is added (in case of non-standard locations
include_directories(BEFORE "${LLVM_INCLUDES}")
string(REGEX REPLACE "\\." "" OSL_LLVM_VERSION ${LLVM_VERSION})
message(STATUS "LLVM OSL_LLVM_VERSION = ${OSL_LLVM_VERSION}")
add_definitions("-DOSL_LLVM_VERSION=${OSL_LLVM_VERSION}")
if(LLVM_STATIC)
# if static LLVM libraries were requested, use llvm-config to generate
# the list of what libraries we need, and substitute that in the right
# way for LLVM_LIBRARY.
execute_process(COMMAND ${LLVM_CONFIG} --libfiles
OUTPUT_VARIABLE LLVM_LIBRARY
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REPLACE " " ";" LLVM_LIBRARY ${LLVM_LIBRARY})
endif()
message(STATUS "LLVM library = ${LLVM_LIBRARY}")
else()
message(FATAL_ERROR "LLVM not found.")
endif()
endif()
if(WITH_CYCLES_OSL)
set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
@@ -712,8 +773,9 @@ if(UNIX AND NOT APPLE)
find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib)
find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib)
# WARNING! depends on correct order of OSL libs linking
list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} ${OSL_LIB_EXEC} ${OSL_LIB_QUERY})
# Note: --whole-archive is needed to force loading of all symbols in liboslexec,
# otherwise LLVM is missing the osl_allocate_closure_component function
list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} -Wl,--whole-archive ${OSL_LIB_EXEC} -Wl,--no-whole-archive ${OSL_LIB_QUERY})
find_path(OSL_INCLUDES OSL/oslclosure.h PATHS ${CYCLES_OSL}/include)
find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin)
@@ -1559,6 +1621,56 @@ elseif(APPLE)
set(OPENCOLORIO_DEFINITIONS "-DOCIO_STATIC_BUILD")
endif()
if(WITH_LLVM)
set(LLVM_DIRECTORY ${LIBDIR}/llvm CACHE PATH "Path to the LLVM installation")
set(LLVM_VERSION "3.1" CACHE STRING "Version of LLVM to use" "")
set(LLVM_STATIC YES)
if(LLVM_DIRECTORY)
set(LLVM_CONFIG "${LLVM_DIRECTORY}/bin/llvm-config")
else()
set(LLVM_CONFIG llvm-config)
endif()
execute_process(COMMAND ${LLVM_CONFIG} --version
OUTPUT_VARIABLE LLVM_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${LLVM_CONFIG} --prefix
OUTPUT_VARIABLE LLVM_DIRECTORY
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${LLVM_CONFIG} --libdir
OUTPUT_VARIABLE LLVM_LIB_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${LLVM_CONFIG} --includedir
OUTPUT_VARIABLE LLVM_INCLUDES
OUTPUT_STRIP_TRAILING_WHITESPACE)
find_library(LLVM_LIBRARY
NAMES libLLVMAnalysis.a # first of a whole bunch of libs to get
PATHS ${LLVM_LIB_DIR})
message(STATUS "LLVM version = ${LLVM_VERSION}")
message(STATUS "LLVM dir = ${LLVM_DIRECTORY}")
message(STATUS "LLVM includes = ${LLVM_INCLUDES}")
message(STATUS "LLVM lib dir = ${LLVM_LIB_DIR}")
if(LLVM_LIBRARY AND LLVM_INCLUDES AND LLVM_DIRECTORY AND LLVM_LIB_DIR)
# ensure include directory is added (in case of non-standard locations
include_directories(BEFORE "${LLVM_INCLUDES}")
string(REGEX REPLACE "\\." "" OSL_LLVM_VERSION ${LLVM_VERSION})
message(STATUS "LLVM OSL_LLVM_VERSION = ${OSL_LLVM_VERSION}")
add_definitions("-DOSL_LLVM_VERSION=${OSL_LLVM_VERSION}")
if(LLVM_STATIC)
# if static LLVM libraries were requested, use llvm-config to generate
# the list of what libraries we need, and substitute that in the right
# way for LLVM_LIBRARY.
execute_process(COMMAND ${LLVM_CONFIG} --libfiles
OUTPUT_VARIABLE LLVM_LIBRARY
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REPLACE " " ";" LLVM_LIBRARY ${LLVM_LIBRARY})
endif()
message(STATUS "LLVM library = ${LLVM_LIBRARY}")
else()
message(FATAL_ERROR "LLVM not found.")
endif()
endif()
if(WITH_CYCLES_OSL)
set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
@@ -1582,78 +1694,19 @@ elseif(APPLE)
endif()
include_directories(${OSL_INCLUDES})
# LLVM library setup, needed for osl
set(LLVM_DIRECTORY "${LIBDIR}/llvm")
set(LLVM_STATIC YES)
if (LLVM_DIRECTORY)
set (LLVM_CONFIG "${LLVM_DIRECTORY}/bin/llvm-config")
else ()
set (LLVM_CONFIG llvm-config)
endif ()
execute_process (COMMAND ${LLVM_CONFIG} --version
OUTPUT_VARIABLE LLVM_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ${LLVM_CONFIG} --prefix
OUTPUT_VARIABLE LLVM_DIRECTORY
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ${LLVM_CONFIG} --libdir
OUTPUT_VARIABLE LLVM_LIB_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ${LLVM_CONFIG} --includedir
OUTPUT_VARIABLE LLVM_INCLUDES
OUTPUT_STRIP_TRAILING_WHITESPACE)
find_library ( LLVM_LIBRARY
NAMES libLLVMAnalysis.a # first of a whole bunch of libs to get
PATHS ${LLVM_LIB_DIR})
message (STATUS "LLVM version = ${LLVM_VERSION}")
message (STATUS "LLVM dir = ${LLVM_DIRECTORY}")
message (STATUS "LLVM includes = ${LLVM_INCLUDES}")
message (STATUS "LLVM lib dir = ${LLVM_LIB_DIR}")
if (LLVM_LIBRARY AND LLVM_INCLUDES AND LLVM_DIRECTORY AND LLVM_LIB_DIR)
# ensure include directory is added (in case of non-standard locations
include_directories (BEFORE "${LLVM_INCLUDES}")
string (REGEX REPLACE "\\." "" OSL_LLVM_VERSION ${LLVM_VERSION})
message (STATUS "LLVM OSL_LLVM_VERSION = ${OSL_LLVM_VERSION}")
add_definitions ("-DOSL_LLVM_VERSION=${OSL_LLVM_VERSION}")
if (LLVM_STATIC)
# if static LLVM libraries were requested, use llvm-config to generate
# the list of what libraries we need, and substitute that in the right
# way for LLVM_LIBRARY.
set (LLVM_LIBRARY "")
execute_process (COMMAND ${LLVM_CONFIG} --libs
OUTPUT_VARIABLE llvm_library_list
OUTPUT_STRIP_TRAILING_WHITESPACE)
string (REPLACE "-l" "" llvm_library_list ${llvm_library_list})
string (REPLACE " " ";" llvm_library_list ${llvm_library_list})
foreach (f ${llvm_library_list})
list (APPEND LLVM_LIBRARY "${LLVM_LIB_DIR}/lib${f}.a")
endforeach ()
endif ()
string (REPLACE ";" " " LLVM_LIBRARY "${LLVM_LIBRARY}")
message (STATUS "LLVM library = ${LLVM_LIBRARY}")
else ()
message (FATAL_ERROR "LLVM not found.")
endif ()
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${LLVM_LIBRARY}")
# end LLVM library setup
endif()
set(EXETYPE MACOSX_BUNDLE)
set(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
set(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
if(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR CMAKE_OSX_ARCHITECTURES MATCHES "i386")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -msse -msse2 -msse3 -mssse3")
set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic -msse -msse2 -msse3 -mssse3")
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ftree-vectorize -fvariable-expansion-in-unroller")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ftree-vectorize -fvariable-expansion-in-unroller")
endif()
else()
set(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
@@ -1676,6 +1729,12 @@ if(WITH_CYCLES)
if(NOT WITH_BOOST)
message(FATAL_ERROR "Cycles reqires WITH_BOOST, the library may not have been found. Configure BOOST or disable WITH_CYCLES")
endif()
if(WITH_CYCLES_OSL)
if(NOT WITH_LLVM)
message(FATAL_ERROR "Cycles OSL reqires WITH_LLVM, the library may not have been found. Configure LLVM or disable WITH_CYCLES_OSL")
endif()
endif()
endif()
@@ -1827,9 +1886,6 @@ if(CMAKE_COMPILER_IS_GNUCC)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero)
# # this causes too many warnings, disable
# ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNDEFINED -Wundef)
# disable because it gives warnings for printf() & friends.
# ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion)
@@ -1840,14 +1896,17 @@ if(CMAKE_COMPILER_IS_GNUCC)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_MISSING_DECLARATIONS -Wmissing-declarations)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_LOGICAL_OP -Wlogical-op)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEF -Wundef)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_INIT_SELF -Winit-self) # needs -Wuninitialized
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEFINED -Wundef)
# causes too many warnings
if(NOT APPLE)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEF -Wundef)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_MISSING_DECLARATIONS -Wmissing-declarations)
endif()
# flags to undo strict flags
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations)

View File

@@ -171,6 +171,7 @@ help:
@echo ""
@echo "Static Source Code Checking (not associated with building blender)"
@echo " * check_cppcheck - run blender source through cppcheck (C & C++)"
@echo " * check_clang_array - run blender source through clang array checking script (C & C++)"
@echo " * check_splint - run blenders source through splint (C only)"
@echo " * check_sparse - run blenders source through sparse (C only)"
@echo " * check_smatch - run blenders source through smatch (C only)"
@@ -244,6 +245,10 @@ check_cppcheck:
$(CMAKE_CONFIG)
cd $(BUILD_DIR) ; python3.2 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py
check_clang_array:
$(CMAKE_CONFIG)
cd $(BUILD_DIR) ; python3.2 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py
check_splint:
$(CMAKE_CONFIG)
cd $(BUILD_DIR) ; python3.2 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py

View File

@@ -0,0 +1,337 @@
# ---
# * Licensed under the Apache License, Version 2.0 (the "License");
# * you may not use this file except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.apache.org/licenses/LICENSE-2.0
# ---
# by Campbell Barton
"""
Invocation:
export CLANG_BIND_DIR="/dsk/src/llvm/tools/clang/bindings/python"
export CLANG_LIB_DIR="/opt/llvm/lib"
python2 clang_array_check.py somefile.c -DSOME_DEFINE -I/some/include
... defines and includes are optional
"""
# -----------------------------------------------------------------------------
# predefined function/arg sizes, handy sometimes, but not complete...
defs_precalc = {
"glColor3bv": {0: 3},
"glColor4bv": {0: 4},
"glColor3ubv": {0: 3},
"glColor4ubv": {0: 4},
"glColor4usv": {0: 3},
"glColor4usv": {0: 4},
"glColor3fv": {0: 3},
"glColor4fv": {0: 4},
"glColor3dv": {0: 3},
"glColor4dv": {0: 4},
"glVertex2fv": {0: 2},
"glVertex3fv": {0: 3},
"glVertex4fv": {0: 4},
"glEvalCoord1fv": {0: 1},
"glEvalCoord1dv": {0: 1},
"glEvalCoord2fv": {0: 2},
"glEvalCoord2dv": {0: 2},
"glRasterPos2dv": {0: 2},
"glRasterPos3dv": {0: 3},
"glRasterPos4dv": {0: 4},
"glRasterPos2fv": {0: 2},
"glRasterPos3fv": {0: 3},
"glRasterPos4fv": {0: 4},
"glRasterPos2sv": {0: 2},
"glRasterPos3sv": {0: 3},
"glRasterPos4sv": {0: 4},
"glTexCoord2fv": {0: 2},
"glTexCoord3fv": {0: 3},
"glTexCoord4fv": {0: 4},
"glTexCoord2dv": {0: 2},
"glTexCoord3dv": {0: 3},
"glTexCoord4dv": {0: 4},
"glNormal3fv": {0: 3},
"glNormal3dv": {0: 3},
"glNormal3bv": {0: 3},
"glNormal3iv": {0: 3},
"glNormal3sv": {0: 3},
}
# -----------------------------------------------------------------------------
import sys
if 0:
# Examples with LLVM as the root dir: '/dsk/src/llvm'
# path containing 'clang/__init__.py'
CLANG_BIND_DIR = "/dsk/src/llvm/tools/clang/bindings/python"
# path containing libclang.so
CLANG_LIB_DIR = "/opt/llvm/lib"
else:
import os
CLANG_BIND_DIR = os.environ.get("CLANG_BIND_DIR")
CLANG_LIB_DIR = os.environ.get("CLANG_LIB_DIR")
if CLANG_BIND_DIR is None:
print("$CLANG_BIND_DIR python binding dir not set")
if CLANG_LIB_DIR is None:
print("$CLANG_LIB_DIR clang lib dir not set")
sys.path.append(CLANG_BIND_DIR)
import clang
import clang.cindex
from clang.cindex import (CursorKind,
TypeKind,
TokenKind)
clang.cindex.Config.set_library_path(CLANG_LIB_DIR)
index = clang.cindex.Index.create()
args = sys.argv[2:]
# print(args)
tu = index.parse(sys.argv[1], args)
print 'Translation unit:', tu.spelling
# -----------------------------------------------------------------------------
def function_parm_wash_tokens(parm):
# print(parm.kind)
assert parm.kind in (CursorKind.PARM_DECL,
CursorKind.VAR_DECL, # XXX, double check this
CursorKind.FIELD_DECL,
)
"""
Return tolens without trailing commads and 'const'
"""
tokens = [t for t in parm.get_tokens()]
if not tokens:
return tokens
#if tokens[-1].kind == To
# remove trailing char
if tokens[-1].kind == TokenKind.PUNCTUATION:
if tokens[-1].spelling in (",", ")", ";"):
tokens.pop()
#else:
# print(tokens[-1].spelling)
t_new = []
for t in tokens:
t_kind = t.kind
t_spelling = t.spelling
ok = True
if t_kind == TokenKind.KEYWORD:
if t_spelling in ("const", "restrict", "volatile"):
ok = False
elif t_spelling.startswith("__"):
ok = False # __restrict
elif t_kind in (TokenKind.COMMENT, ):
ok = False
# Use these
elif t_kind in (TokenKind.LITERAL,
TokenKind.PUNCTUATION,
TokenKind.IDENTIFIER):
# use but ignore
pass
else:
print("Unknown!", t_kind, t_spelling)
# if its OK we will add
if ok:
t_new.append(t)
return t_new
def parm_size(node_child):
tokens = function_parm_wash_tokens(node_child)
# print(" ".join([t.spelling for t in tokens]))
# NOT PERFECT CODE, EXTRACT SIZE FROM TOKENS
if len(tokens) >= 3: # foo [ 1 ]
if ((tokens[-3].kind == TokenKind.PUNCTUATION and tokens[-3].spelling == "[") and
(tokens[-2].kind == TokenKind.LITERAL and tokens[-2].spelling.isdigit()) and
(tokens[-1].kind == TokenKind.PUNCTUATION and tokens[-1].spelling == "]")):
# ---
return int(tokens[-2].spelling)
return -1
def function_get_arg_sizes(node):
# Return a dict if (index: size) items
# {arg_indx: arg_array_size, ... ]
arg_sizes = {}
if node.spelling == "BM_vert_create" or 1:
node_parms = [node_child for node_child in node.get_children()
if node_child.kind == CursorKind.PARM_DECL]
for i, node_child in enumerate(node_parms):
# print(node_child.kind, node_child.spelling)
#print(node_child.type.kind, node_child.spelling) # TypeKind.POINTER
if node_child.type.kind == TypeKind.POINTER:
pointee = node_child.type.get_pointee()
if pointee.is_pod():
size = parm_size(node_child)
if size != -1:
arg_sizes[i] = size
return arg_sizes
# -----------------------------------------------------------------------------
_defs = {}
def lookup_function_size_def(func_id):
return _defs.get(func_id, ())
# -----------------------------------------------------------------------------
def file_check_arg_sizes(tu):
# main checking function
def validate_arg_size(node):
"""
Loop over args and validate sizes for args we KNOW the size of.
"""
assert node.kind == CursorKind.CALL_EXPR
# print("---", " <~> ".join([" ".join([t.spelling for t in C.get_tokens()]) for C in node.get_children()]))
# print(node.location)
# first child is the function call, skip that.
children = list(node.get_children())
if not children:
return # XXX, look into this, happens on C++
func = children[0]
# get the func declaration!
# works but we can better scan for functions ahead of time.
if 0:
func_dec = func.get_definition()
if func_dec:
print("FD", " ".join([t.spelling for t in func_dec.get_tokens()]))
else:
# HRMP'f - why does this fail?
print("AA", " ".join([t.spelling for t in node.get_tokens()]))
else:
args_size_definition = () # dummy
# get the key
tok = list(func.get_tokens())
if tok:
func_id = tok[0].spelling
args_size_definition = lookup_function_size_def(func_id)
if not args_size_definition:
return
children = children[1:]
for i, node_child in enumerate(children):
children = list(node_child.get_children())
# skip if we dont have an index...
size_def = args_size_definition.get(i, -1)
if size_def == -1:
continue
#print([c.kind for c in children])
# print(" ".join([t.spelling for t in node_child.get_tokens()]))
if len(children) == 1:
arg = children[0]
if arg.kind in (CursorKind.DECL_REF_EXPR,
CursorKind.UNEXPOSED_EXPR):
if arg.type.kind == TypeKind.POINTER:
dec = arg.get_definition()
if dec:
size = parm_size(dec)
# size == 0 is for 'float *a'
if size != -1 and size != 0:
# nice print!
'''
print("".join([t.spelling for t in func.get_tokens()]),
i,
" ".join([t.spelling for t in dec.get_tokens()]))
'''
# testing
# size_def = 100
if size < size_def:
location = node.location
print("%s:%d:%d: argument %d is size %d, should be %d" %
(location.file,
location.line,
location.column,
i + 1, size, size_def
))
# we dont really care what we are looking at, just scan entire file for
# function calls.
def recursive_func_call_check(node):
if node.kind == CursorKind.CALL_EXPR:
validate_arg_size(node)
for c in node.get_children():
recursive_func_call_check(c)
recursive_func_call_check(tu.cursor)
# -- first pass, cache function definitions sizes
# PRINT FUNC DEFINES
def recursive_arg_sizes(node, ):
# print(node.kind, node.spelling)
if node.kind == CursorKind.FUNCTION_DECL:
args_sizes = function_get_arg_sizes(node)
#if args_sizes:
# print(node.spelling, args_sizes)
_defs[node.spelling] = args_sizes
# print("adding", node.spelling)
for c in node.get_children():
recursive_arg_sizes(c)
# cache function sizes
recursive_arg_sizes(tu.cursor)
_defs.update(defs_precalc)
# --- second pass, check against def's
file_check_arg_sizes(tu)

View File

@@ -0,0 +1,76 @@
#!/usr/bin/env python3.2
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Contributor(s): Campbell Barton
#
# ***** END GPL LICENSE BLOCK *****
# <pep8 compliant>
import project_source_info
import subprocess
import sys
import os
CHECKER_IGNORE_PREFIX = [
"extern",
"intern/moto",
]
CHECKER_BIN = "python2"
CHECKER_ARGS = [
os.path.join(os.path.dirname(__file__), "clang_array_check.py"),
# not sure why this is needed, but it is.
"-I" + os.path.join(project_source_info.SOURCE_DIR, "extern", "glew", "include"),
]
def main():
source_info = project_source_info.build_info(ignore_prefix_list=CHECKER_IGNORE_PREFIX)
check_commands = []
for c, inc_dirs, defs in source_info:
cmd = ([CHECKER_BIN] +
CHECKER_ARGS +
[c] +
[("-I%s" % i) for i in inc_dirs] +
[("-D%s" % d) for d in defs]
)
check_commands.append((c, cmd))
process_functions = []
def my_process(i, c, cmd):
percent = 100.0 * (i / (len(check_commands) - 1))
percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
sys.stdout.flush()
sys.stdout.write("%s " % percent_str)
return subprocess.Popen(cmd)
for i, (c, cmd) in enumerate(check_commands):
process_functions.append((my_process, (i, c, cmd)))
project_source_info.queue_processes(process_functions)
if __name__ == "__main__":
main()

View File

@@ -244,6 +244,9 @@ macro(SETUP_LIBDIRS)
link_directories(${PCRE_LIBPATH})
link_directories(${EXPAT_LIBPATH})
endif()
if(WITH_LLVM)
link_directories(${LLVM_LIB_DIR})
endif()
if(WITH_MEM_JEMALLOC)
link_directories(${JEMALLOC_LIBPATH})
endif()
@@ -382,6 +385,9 @@ macro(setup_liblinks
if(WITH_CYCLES_OSL)
target_link_libraries(${target} ${OSL_LIBRARIES})
endif()
if(WITH_LLVM)
target_link_libraries(${target} ${LLVM_LIBRARY})
endif()
if(WIN32 AND NOT UNIX)
target_link_libraries(${target} ${PTHREADS_LIBRARIES})
endif()

View File

@@ -76,6 +76,7 @@ fi || :
%defattr(-,root,root,-)
%{_bindir}/%{name}
%{_datadir}/%{name}/%{blender_api}/datafiles/fonts
%{_datadir}/%{name}/%{blender_api}/datafiles/colormanagement
%{_datadir}/%{name}/%{blender_api}/scripts
%{_datadir}/icons/hicolor/*/apps/%{name}.*
%{_datadir}/applications/%{name}.desktop

View File

@@ -1,4 +1,4 @@
.TH "BLENDER" "1" "July 19, 2012" "Blender Blender 2\&.63 (sub 14)"
.TH "BLENDER" "1" "October 04, 2012" "Blender Blender 2\&.64 (sub 0)"
.SH NAME
blender \- a 3D modelling and rendering package
@@ -15,7 +15,7 @@ Use Blender to create TV commercials, to make technical visualizations, business
http://www.blender.org
.SH OPTIONS
Blender 2.63 (sub 14)
Blender 2.64 (sub 0)
Usage: blender [args ...] [file] [args ...]
.br
.SS "Render Options:"

View File

@@ -2,9 +2,9 @@
Game Logic (bge.logic)
======================
*****
Intro
*****
************
Introduction
************
Module to access logic functions, imported automatically into the python controllers namespace.

View File

@@ -4,6 +4,33 @@ Game Types (bge.types)
.. module:: bge.types
************
Introduction
************
This module contains the classes that appear as instances in the Game Engine. A
script must interact with these classes if it is to affect the behaviour of
objects in a game.
The following example would move an object (i.e. an instance of
:class:`KX_GameObject`) one unit up.
.. code-block:: python
# bge.types.SCA_PythonController
cont = bge.logic.getCurrentController()
# bge.types.KX_GameObject
obj = cont.owner
obj.worldPosition.z += 1
To run the code, it could be placed in a Blender text block and executed with
a :class:`SCA_PythonController` logic brick.
*****
Types
*****
.. class:: PyObjectPlus
PyObjectPlus base class of most other types in the Game Engine.
@@ -854,6 +881,52 @@ Game Types (bge.types)
Calling ANY method or attribute on an object that has been removed from a scene will raise a SystemError, if an object may have been removed since last accessing it use the :data:`invalid` attribute to check.
KX_GameObject can be subclassed to extend functionality. For example:
.. code-block:: python
import bge
class CustomGameObject(bge.types.KX_GameObject):
RATE = 0.05
def __init__(self, old_owner):
# "old_owner" can just be ignored. At this point, "self" is
# already the object in the scene, and "old_owner" has been
# destroyed.
# New attributes can be defined - but we could also use a game
# property, like "self['rate']".
self.rate = CustomGameObject.RATE
def update(self):
self.worldPosition.z += self.rate
# switch direction
if self.worldPosition.z > 1.0:
self.rate = -CustomGameObject.RATE
elif self.worldPosition.z < 0.0:
self.rate = CustomGameObject.RATE
# Called first
def mutate(cont):
old_object = cont.owner
mutated_object = CustomGameObject(cont.owner)
# After calling the constructor above, references to the old object
# should not be used.
assert(old_object is not mutated_object)
assert(old_object.invalid)
assert(mutated_object is cont.owner)
# Called later - note we are now working with the mutated object.
def update(cont):
cont.owner.update()
When subclassing objects other than empties and meshes, the specific type
should be used - e.g. inherit from :class:`BL_ArmatureObject` when the object
to mutate is an armature.
.. attribute:: name
The object's name. (read-only).

View File

@@ -158,7 +158,7 @@ if(WITH_BOOST)
-DCARVE_SYSTEM_BOOST
)
list(APPEND INC
list(APPEND INC_SYS
${BOOST_INCLUDE_DIR}
)
endif()

View File

@@ -62,7 +62,7 @@ if(WITH_BOOST)
-DCARVE_SYSTEM_BOOST
)
list(APPEND INC
list(APPEND INC_SYS
${BOOST_INCLUDE_DIR}
)
endif()

View File

@@ -58,7 +58,7 @@ static bool isQuadPlanar(carve::geom3d::Vector &v1, carve::geom3d::Vector &v2,
cross = carve::geom::cross(vec1, vec2);
float production = carve::geom::dot(cross, vec3);
float magnitude = 1e-6 * cross.length();
float magnitude = 1e-5 * cross.length();
return fabs(production) < magnitude;
}

View File

@@ -955,7 +955,7 @@ def draw_device(self, context):
elif device_type == 'OPENCL' and cscene.feature_set == 'EXPERIMENTAL':
layout.prop(cscene, "device")
if cscene.feature_set == 'EXPERIMENTAL' and cscene.device == 'CPU' and engine.with_osl():
if engine.with_osl() and (cscene.device == 'CPU' or device_type == 'None'):
layout.prop(cscene, "shading_system")

View File

@@ -94,7 +94,7 @@ static float blender_camera_focal_distance(BL::Object b_ob, BL::Camera b_camera)
return fabsf(transform_get_column(&mat, 3).z);
}
static void blender_camera_from_object(BlenderCamera *bcam, BL::Object b_ob)
static void blender_camera_from_object(BlenderCamera *bcam, BL::Object b_ob, bool skip_panorama = false)
{
BL::ID b_ob_data = b_ob.data();
@@ -111,7 +111,10 @@ static void blender_camera_from_object(BlenderCamera *bcam, BL::Object b_ob)
bcam->type = CAMERA_ORTHOGRAPHIC;
break;
case BL::Camera::type_PANO:
if(!skip_panorama)
bcam->type = CAMERA_PANORAMA;
else
bcam->type = CAMERA_PERSPECTIVE;
break;
case BL::Camera::type_PERSP:
default:
@@ -378,7 +381,7 @@ void BlenderSync::sync_camera_motion(BL::Object b_ob, int motion)
/* Sync 3D View Camera */
static void blender_camera_from_view(BlenderCamera *bcam, BL::Scene b_scene, BL::SpaceView3D b_v3d, BL::RegionView3D b_rv3d, int width, int height)
static void blender_camera_from_view(BlenderCamera *bcam, BL::Scene b_scene, BL::SpaceView3D b_v3d, BL::RegionView3D b_rv3d, int width, int height, bool skip_panorama = false)
{
/* 3d view parameters */
bcam->nearclip = b_v3d.clip_start();
@@ -391,7 +394,7 @@ static void blender_camera_from_view(BlenderCamera *bcam, BL::Scene b_scene, BL:
BL::Object b_ob = (b_v3d.lock_camera_and_layers())? b_scene.camera(): b_v3d.camera();
if(b_ob) {
blender_camera_from_object(bcam, b_ob);
blender_camera_from_object(bcam, b_ob, skip_panorama);
/* magic zoom formula */
bcam->zoom = (float)b_rv3d.view_camera_zoom();
@@ -447,7 +450,7 @@ static void blender_camera_border(BlenderCamera *bcam, BL::Scene b_scene, BL::Sp
/* get viewport viewplane */
BlenderCamera view_bcam;
blender_camera_init(&view_bcam);
blender_camera_from_view(&view_bcam, b_scene, b_v3d, b_rv3d, width, height);
blender_camera_from_view(&view_bcam, b_scene, b_v3d, b_rv3d, width, height, true);
blender_camera_viewplane(&view_bcam, width, height,
&view_left, &view_right, &view_bottom, &view_top, &view_aspect, &sensor_size);
@@ -460,7 +463,7 @@ static void blender_camera_border(BlenderCamera *bcam, BL::Scene b_scene, BL::Sp
/* get camera viewplane */
BlenderCamera cam_bcam;
blender_camera_init(&cam_bcam);
blender_camera_from_object(&cam_bcam, b_ob);
blender_camera_from_object(&cam_bcam, b_ob, true);
width = (int)(r.resolution_x()*r.resolution_percentage()/100);
height = (int)(r.resolution_y()*r.resolution_percentage()/100);

View File

@@ -194,8 +194,10 @@ void BlenderSync::sync_background_light()
/* Object */
void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm, uint layer_flag, int motion, int particle_id)
void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::DupliObject b_dupli_ob, Transform& tfm, uint layer_flag, int motion, int particle_id)
{
BL::Object b_ob = (b_dupli_ob ? b_dupli_ob.object() : b_parent);
/* light is handled separately */
if(object_is_light(b_ob)) {
if(!motion)
@@ -274,6 +276,15 @@ void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob,
object->visibility &= ~PATH_RAY_CAMERA;
}
if (b_dupli_ob) {
object->dupli_generated = get_float3(b_dupli_ob.orco());
object->dupli_uv = get_float2(b_dupli_ob.uv());
}
else {
object->dupli_generated = make_float3(0.0f, 0.0f, 0.0f);
object->dupli_uv = make_float2(0.0f, 0.0f);
}
object->particle_id = particle_id;
object->tag_update(scene);
@@ -328,7 +339,7 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion)
bool dup_hide = (b_v3d)? b_dup_ob.hide(): b_dup_ob.hide_render();
if(!(b_dup->hide() || dup_hide)) {
sync_object(*b_ob, b_index, b_dup_ob, tfm, ob_layer, motion, b_dup->particle_index() + particle_offset);
sync_object(*b_ob, b_index, *b_dup, tfm, ob_layer, motion, b_dup->particle_index() + particle_offset);
}
++b_index;
@@ -346,7 +357,7 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion)
if(!hide) {
/* object itself */
Transform tfm = get_transform(b_ob->matrix_world());
sync_object(*b_ob, 0, *b_ob, tfm, ob_layer, motion, 0);
sync_object(*b_ob, 0, PointerRNA_NULL, tfm, ob_layer, motion, 0);
}
particle_offset += num_particles;

View File

@@ -490,7 +490,10 @@ static ShaderNode *add_node(BL::BlendData b_data, BL::Scene b_scene, ShaderGraph
break;
}
case BL::ShaderNode::type_TEX_COORD: {
node = new TextureCoordinateNode();
BL::ShaderNodeTexCoord b_tex_coord_node(b_node);
TextureCoordinateNode *tex_coord = new TextureCoordinateNode();
tex_coord->from_dupli = b_tex_coord_node.from_dupli();
node = tex_coord;
break;
}
case BL::ShaderNode::type_TEX_SKY: {

View File

@@ -81,7 +81,7 @@ private:
void sync_nodes(Shader *shader, BL::ShaderNodeTree b_ntree);
Mesh *sync_mesh(BL::Object b_ob, bool object_updated);
void sync_object(BL::Object b_parent, int b_index, BL::Object b_object, Transform& tfm, uint layer_flag, int motion, int particle_id);
void sync_object(BL::Object b_parent, int b_index, BL::DupliObject b_dupli_object, Transform& tfm, uint layer_flag, int motion, int particle_id);
void sync_light(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm);
void sync_background_light();
void sync_mesh_motion(BL::Object b_ob, Mesh *mesh, int motion);

View File

@@ -36,7 +36,7 @@ struct RenderResult;
ID *rna_Object_to_mesh(void *_self, void *reports, void *scene, int apply_modifiers, int settings);
void rna_Main_meshes_remove(void *bmain, void *reports, void *mesh);
void rna_Object_create_duplilist(void *ob, void *reports, void *sce);
void rna_Object_create_duplilist(void *ob, void *reports, void *sce, int settings);
void rna_Object_free_duplilist(void *ob);
void rna_RenderLayer_rect_set(PointerRNA *ptr, const float *values);
void rna_RenderPass_rect_set(PointerRNA *ptr, const float *values);
@@ -84,7 +84,7 @@ static inline void object_remove_mesh(BL::BlendData data, BL::Mesh mesh)
static inline void object_create_duplilist(BL::Object self, BL::Scene scene)
{
rna_Object_create_duplilist(self.ptr.data, NULL, scene.ptr.data);
rna_Object_create_duplilist(self.ptr.data, NULL, scene.ptr.data, 2);
}
static inline void object_free_duplilist(BL::Object self)

View File

@@ -23,7 +23,8 @@ enum ObjectTransform {
OBJECT_INVERSE_TRANSFORM = 3,
OBJECT_PROPERTIES = 6,
OBJECT_TRANSFORM_MOTION_PRE = 8,
OBJECT_TRANSFORM_MOTION_POST = 12
OBJECT_TRANSFORM_MOTION_POST = 12,
OBJECT_DUPLI = 16
};
__device_inline Transform object_fetch_transform(KernelGlobals *kg, int object, float time, enum ObjectTransform type)
@@ -164,6 +165,27 @@ __device_inline uint object_particle_id(KernelGlobals *kg, int object)
return __float_as_int(f.w);
}
__device_inline float3 object_dupli_generated(KernelGlobals *kg, int object)
{
if(object == ~0)
return make_float3(0.0f, 0.0f, 0.0f);
int offset = object*OBJECT_SIZE + OBJECT_DUPLI;
float4 f = kernel_tex_fetch(__objects, offset);
return make_float3(f.x, f.y, f.z);
}
__device_inline float3 object_dupli_uv(KernelGlobals *kg, int object)
{
if(object == ~0)
return make_float3(0.0f, 0.0f, 0.0f);
int offset = object*OBJECT_SIZE + OBJECT_DUPLI;
float4 f = kernel_tex_fetch(__objects, offset + 1);
return make_float3(f.x, f.y, 0.0f);
}
__device int shader_pass_id(KernelGlobals *kg, ShaderData *sd)
{
return kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*2 + 1);

View File

@@ -29,7 +29,7 @@
CCL_NAMESPACE_BEGIN
/* constants */
#define OBJECT_SIZE 16
#define OBJECT_SIZE 18
#define LIGHT_SIZE 4
#define FILTER_TABLE_SIZE 256
#define RAMP_TABLE_SIZE 256

View File

@@ -85,16 +85,25 @@ public:
}
};
ClosureParam closure_background_params[] = {
ClosureParam *closure_background_params()
{
static ClosureParam params[] = {
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(GenericBackgroundClosure)
};
};
return params;
}
CLOSURE_PREPARE(closure_background_prepare, GenericBackgroundClosure)
ClosureParam closure_holdout_params[] = {
ClosureParam *closure_holdout_params()
{
static ClosureParam params[] = {
CLOSURE_FINISH_PARAM(HoldoutClosure)
};
};
return params;
}
CLOSURE_PREPARE(closure_holdout_prepare, HoldoutClosure)

View File

@@ -173,12 +173,16 @@ public:
ClosureParam bsdf_ashikhmin_velvet_params[] = {
ClosureParam *bsdf_ashikhmin_velvet_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(AshikhminVelvetClosure, m_N),
CLOSURE_FLOAT_PARAM(AshikhminVelvetClosure, m_sigma),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(AshikhminVelvetClosure)
};
};
return params;
}
CLOSURE_PREPARE(bsdf_ashikhmin_velvet_prepare, AshikhminVelvetClosure)

View File

@@ -168,17 +168,25 @@ public:
}
};
ClosureParam bsdf_diffuse_params[] = {
ClosureParam *bsdf_diffuse_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(DiffuseClosure, m_N),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(DiffuseClosure)
};
};
return params;
}
ClosureParam bsdf_translucent_params[] = {
ClosureParam *bsdf_translucent_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(TranslucentClosure, m_N),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(TranslucentClosure)
};
};
return params;
}
CLOSURE_PREPARE(bsdf_diffuse_prepare, DiffuseClosure)
CLOSURE_PREPARE(bsdf_translucent_prepare, TranslucentClosure)

View File

@@ -503,35 +503,51 @@ public:
ClosureParam bsdf_microfacet_ggx_params[] = {
ClosureParam *bsdf_microfacet_ggx_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(MicrofacetGGXClosure<0>, m_N),
CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure<0>, m_ag),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(MicrofacetGGXClosure<0>)
};
};
return params;
}
ClosureParam bsdf_microfacet_ggx_refraction_params[] = {
ClosureParam *bsdf_microfacet_ggx_refraction_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(MicrofacetGGXClosure<1>, m_N),
CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure<1>, m_ag),
CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure<1>, m_eta),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(MicrofacetGGXClosure<1>)
};
};
return params;
}
ClosureParam bsdf_microfacet_beckmann_params[] = {
ClosureParam *bsdf_microfacet_beckmann_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(MicrofacetBeckmannClosure<0>, m_N),
CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure<0>, m_ab),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(MicrofacetBeckmannClosure<0>)
};
};
return params;
}
ClosureParam bsdf_microfacet_beckmann_refraction_params[] = {
ClosureParam *bsdf_microfacet_beckmann_refraction_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(MicrofacetBeckmannClosure<1>, m_N),
CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure<1>, m_ab),
CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure<1>, m_eta),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(MicrofacetBeckmannClosure<1>)
};
};
return params;
}
CLOSURE_PREPARE(bsdf_microfacet_ggx_prepare, MicrofacetGGXClosure<0>)
CLOSURE_PREPARE(bsdf_microfacet_ggx_refraction_prepare, MicrofacetGGXClosure<1>)

View File

@@ -125,12 +125,16 @@ private:
}
};
ClosureParam bsdf_oren_nayar_params[] = {
ClosureParam *bsdf_oren_nayar_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(OrenNayarClosure, m_N),
CLOSURE_FLOAT_PARAM(OrenNayarClosure, m_sigma),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(OrenNayarClosure)
};
};
return params;
}
CLOSURE_PREPARE(bsdf_oren_nayar_prepare, OrenNayarClosure)

View File

@@ -258,18 +258,28 @@ public:
ClosureParam bsdf_phong_params[] = {
ClosureParam *bsdf_phong_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(PhongClosure, m_N),
CLOSURE_FLOAT_PARAM (PhongClosure, m_exponent),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(PhongClosure) };
CLOSURE_FINISH_PARAM(PhongClosure)
};
return params;
}
ClosureParam bsdf_phong_ramp_params[] = {
ClosureParam *bsdf_phong_ramp_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM (PhongRampClosure, m_N),
CLOSURE_FLOAT_PARAM (PhongRampClosure, m_exponent),
CLOSURE_COLOR_ARRAY_PARAM(PhongRampClosure, m_colors, PhongRampClosure::MAXCOLORS),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM (PhongRampClosure) };
CLOSURE_FINISH_PARAM (PhongRampClosure)
};
return params;
}
CLOSURE_PREPARE(bsdf_phong_prepare, PhongClosure)
CLOSURE_PREPARE(bsdf_phong_ramp_prepare, PhongRampClosure)

View File

@@ -97,11 +97,15 @@ public:
}
};
ClosureParam bsdf_reflection_params[] = {
ClosureParam *bsdf_reflection_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(ReflectionClosure, m_N),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(ReflectionClosure)
};
};
return params;
}
CLOSURE_PREPARE(bsdf_reflection_prepare, ReflectionClosure)

View File

@@ -108,12 +108,16 @@ public:
}
};
ClosureParam bsdf_refraction_params[] = {
ClosureParam *bsdf_refraction_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(RefractionClosure, m_N),
CLOSURE_FLOAT_PARAM(RefractionClosure, m_eta),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(RefractionClosure)
};
};
return params;
}
CLOSURE_PREPARE(bsdf_refraction_prepare, RefractionClosure)

View File

@@ -87,10 +87,14 @@ public:
ClosureParam bsdf_transparent_params[] = {
ClosureParam *bsdf_transparent_params()
{
static ClosureParam params[] = {
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(TransparentClosure)
};
};
return params;
}
CLOSURE_PREPARE(bsdf_transparent_prepare, TransparentClosure)

View File

@@ -211,14 +211,18 @@ public:
ClosureParam bsdf_ward_params[] = {
ClosureParam *bsdf_ward_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(WardClosure, m_N),
CLOSURE_VECTOR_PARAM(WardClosure, m_T),
CLOSURE_FLOAT_PARAM(WardClosure, m_ax),
CLOSURE_FLOAT_PARAM(WardClosure, m_ay),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(WardClosure)
};
};
return params;
}
CLOSURE_PREPARE(bsdf_ward_prepare, WardClosure)

View File

@@ -222,19 +222,27 @@ public:
ClosureParam bsdf_westin_backscatter_params[] = {
ClosureParam *bsdf_westin_backscatter_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(WestinBackscatterClosure, m_N),
CLOSURE_FLOAT_PARAM(WestinBackscatterClosure, m_roughness),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(WestinBackscatterClosure)
};
};
return params;
}
ClosureParam bsdf_westin_sheen_params[] = {
ClosureParam *bsdf_westin_sheen_params()
{
static ClosureParam params[] = {
CLOSURE_VECTOR_PARAM(WestinSheenClosure, m_N),
CLOSURE_FLOAT_PARAM(WestinSheenClosure, m_edginess),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(WestinSheenClosure)
};
};
return params;
}
CLOSURE_PREPARE(bsdf_westin_backscatter_prepare, WestinBackscatterClosure)
CLOSURE_PREPARE(bsdf_westin_sheen_prepare, WestinSheenClosure)

View File

@@ -94,11 +94,15 @@ public:
ClosureParam closure_bssrdf_cubic_params[] = {
ClosureParam *closure_bssrdf_cubic_params()
{
static ClosureParam params[] = {
CLOSURE_COLOR_PARAM(BSSRDFCubicClosure, m_radius),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(BSSRDFCubicClosure)
};
};
return params;
}
CLOSURE_PREPARE(closure_bssrdf_cubic_prepare, BSSRDFCubicClosure)

View File

@@ -69,11 +69,15 @@ public:
};
ClosureParam closure_debug_params[] = {
ClosureParam *closure_debug_params()
{
static ClosureParam params[] = {
CLOSURE_STRING_PARAM(DebugClosure, m_tag),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(DebugClosure)
};
};
return params;
}
CLOSURE_PREPARE(closure_debug_prepare, DebugClosure)

View File

@@ -97,10 +97,14 @@ public:
ClosureParam closure_emission_params[] = {
ClosureParam *closure_emission_params()
{
static ClosureParam params[] = {
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(GenericEmissiveClosure)
};
};
return params;
}
CLOSURE_PREPARE(closure_emission_prepare, GenericEmissiveClosure)

View File

@@ -64,28 +64,28 @@ static void register_closure(OSL::ShadingSystem *ss, const char *name, int id, O
void OSLShader::register_closures(OSL::ShadingSystem *ss)
{
register_closure(ss, "diffuse", OSL_CLOSURE_BSDF_DIFFUSE_ID, bsdf_diffuse_params, bsdf_diffuse_prepare);
register_closure(ss, "oren_nayar", OSL_CLOSURE_BSDF_OREN_NAYAR_ID, bsdf_oren_nayar_params, bsdf_oren_nayar_prepare);
register_closure(ss, "translucent", OSL_CLOSURE_BSDF_TRANSLUCENT_ID, bsdf_translucent_params, bsdf_translucent_prepare);
register_closure(ss, "reflection", OSL_CLOSURE_BSDF_REFLECTION_ID, bsdf_reflection_params, bsdf_reflection_prepare);
register_closure(ss, "refraction", OSL_CLOSURE_BSDF_REFRACTION_ID, bsdf_refraction_params, bsdf_refraction_prepare);
register_closure(ss, "transparent", OSL_CLOSURE_BSDF_TRANSPARENT_ID, bsdf_transparent_params, bsdf_transparent_prepare);
register_closure(ss, "microfacet_ggx", OSL_CLOSURE_BSDF_MICROFACET_GGX_ID, bsdf_microfacet_ggx_params, bsdf_microfacet_ggx_prepare);
register_closure(ss, "microfacet_ggx_refraction", OSL_CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID, bsdf_microfacet_ggx_refraction_params, bsdf_microfacet_ggx_refraction_prepare);
register_closure(ss, "microfacet_beckmann", OSL_CLOSURE_BSDF_MICROFACET_BECKMANN_ID, bsdf_microfacet_beckmann_params, bsdf_microfacet_beckmann_prepare);
register_closure(ss, "microfacet_beckmann_refraction", OSL_CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID, bsdf_microfacet_beckmann_refraction_params, bsdf_microfacet_beckmann_refraction_prepare);
register_closure(ss, "ward", OSL_CLOSURE_BSDF_WARD_ID, bsdf_ward_params, bsdf_ward_prepare);
register_closure(ss, "phong", OSL_CLOSURE_BSDF_PHONG_ID, bsdf_phong_params, bsdf_phong_prepare);
register_closure(ss, "phong_ramp", OSL_CLOSURE_BSDF_PHONG_RAMP_ID, bsdf_phong_ramp_params, bsdf_phong_ramp_prepare);
register_closure(ss, "ashikhmin_velvet", OSL_CLOSURE_BSDF_ASHIKHMIN_VELVET_ID, bsdf_ashikhmin_velvet_params, bsdf_ashikhmin_velvet_prepare);
register_closure(ss, "westin_backscatter", OSL_CLOSURE_BSDF_WESTIN_BACKSCATTER_ID, bsdf_westin_backscatter_params, bsdf_westin_backscatter_prepare);
register_closure(ss, "westin_sheen", OSL_CLOSURE_BSDF_WESTIN_SHEEN_ID, bsdf_westin_sheen_params, bsdf_westin_sheen_prepare);
register_closure(ss, "bssrdf_cubic", OSL_CLOSURE_BSSRDF_CUBIC_ID, closure_bssrdf_cubic_params, closure_bssrdf_cubic_prepare);
register_closure(ss, "emission", OSL_CLOSURE_EMISSION_ID, closure_emission_params, closure_emission_prepare);
register_closure(ss, "debug", OSL_CLOSURE_DEBUG_ID, closure_debug_params, closure_debug_prepare);
register_closure(ss, "background", OSL_CLOSURE_BACKGROUND_ID, closure_background_params, closure_background_prepare);
register_closure(ss, "holdout", OSL_CLOSURE_HOLDOUT_ID, closure_holdout_params, closure_holdout_prepare);
register_closure(ss, "subsurface", OSL_CLOSURE_SUBSURFACE_ID, closure_subsurface_params, closure_subsurface_prepare);
register_closure(ss, "diffuse", OSL_CLOSURE_BSDF_DIFFUSE_ID, bsdf_diffuse_params(), bsdf_diffuse_prepare);
register_closure(ss, "oren_nayar", OSL_CLOSURE_BSDF_OREN_NAYAR_ID, bsdf_oren_nayar_params(), bsdf_oren_nayar_prepare);
register_closure(ss, "translucent", OSL_CLOSURE_BSDF_TRANSLUCENT_ID, bsdf_translucent_params(), bsdf_translucent_prepare);
register_closure(ss, "reflection", OSL_CLOSURE_BSDF_REFLECTION_ID, bsdf_reflection_params(), bsdf_reflection_prepare);
register_closure(ss, "refraction", OSL_CLOSURE_BSDF_REFRACTION_ID, bsdf_refraction_params(), bsdf_refraction_prepare);
register_closure(ss, "transparent", OSL_CLOSURE_BSDF_TRANSPARENT_ID, bsdf_transparent_params(), bsdf_transparent_prepare);
register_closure(ss, "microfacet_ggx", OSL_CLOSURE_BSDF_MICROFACET_GGX_ID, bsdf_microfacet_ggx_params(), bsdf_microfacet_ggx_prepare);
register_closure(ss, "microfacet_ggx_refraction", OSL_CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID, bsdf_microfacet_ggx_refraction_params(), bsdf_microfacet_ggx_refraction_prepare);
register_closure(ss, "microfacet_beckmann", OSL_CLOSURE_BSDF_MICROFACET_BECKMANN_ID, bsdf_microfacet_beckmann_params(), bsdf_microfacet_beckmann_prepare);
register_closure(ss, "microfacet_beckmann_refraction", OSL_CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID, bsdf_microfacet_beckmann_refraction_params(), bsdf_microfacet_beckmann_refraction_prepare);
register_closure(ss, "ward", OSL_CLOSURE_BSDF_WARD_ID, bsdf_ward_params(), bsdf_ward_prepare);
register_closure(ss, "phong", OSL_CLOSURE_BSDF_PHONG_ID, bsdf_phong_params(), bsdf_phong_prepare);
register_closure(ss, "phong_ramp", OSL_CLOSURE_BSDF_PHONG_RAMP_ID, bsdf_phong_ramp_params(), bsdf_phong_ramp_prepare);
register_closure(ss, "ashikhmin_velvet", OSL_CLOSURE_BSDF_ASHIKHMIN_VELVET_ID, bsdf_ashikhmin_velvet_params(), bsdf_ashikhmin_velvet_prepare);
register_closure(ss, "westin_backscatter", OSL_CLOSURE_BSDF_WESTIN_BACKSCATTER_ID, bsdf_westin_backscatter_params(), bsdf_westin_backscatter_prepare);
register_closure(ss, "westin_sheen", OSL_CLOSURE_BSDF_WESTIN_SHEEN_ID, bsdf_westin_sheen_params(), bsdf_westin_sheen_prepare);
register_closure(ss, "bssrdf_cubic", OSL_CLOSURE_BSSRDF_CUBIC_ID, closure_bssrdf_cubic_params(), closure_bssrdf_cubic_prepare);
register_closure(ss, "emission", OSL_CLOSURE_EMISSION_ID, closure_emission_params(), closure_emission_prepare);
register_closure(ss, "debug", OSL_CLOSURE_DEBUG_ID, closure_debug_params(), closure_debug_prepare);
register_closure(ss, "background", OSL_CLOSURE_BACKGROUND_ID, closure_background_params(), closure_background_prepare);
register_closure(ss, "holdout", OSL_CLOSURE_HOLDOUT_ID, closure_holdout_params(), closure_holdout_prepare);
register_closure(ss, "subsurface", OSL_CLOSURE_SUBSURFACE_ID, closure_subsurface_params(), closure_subsurface_prepare);
}
CCL_NAMESPACE_END

View File

@@ -64,28 +64,28 @@ enum {
OSL_CLOSURE_SUBSURFACE_ID
};
extern OSL::ClosureParam bsdf_diffuse_params[];
extern OSL::ClosureParam bsdf_oren_nayar_params[];
extern OSL::ClosureParam bsdf_translucent_params[];
extern OSL::ClosureParam bsdf_reflection_params[];
extern OSL::ClosureParam bsdf_refraction_params[];
extern OSL::ClosureParam bsdf_transparent_params[];
extern OSL::ClosureParam bsdf_microfacet_ggx_params[];
extern OSL::ClosureParam bsdf_microfacet_ggx_refraction_params[];
extern OSL::ClosureParam bsdf_microfacet_beckmann_params[];
extern OSL::ClosureParam bsdf_microfacet_beckmann_refraction_params[];
extern OSL::ClosureParam bsdf_ward_params[];
extern OSL::ClosureParam bsdf_phong_params[];
extern OSL::ClosureParam bsdf_phong_ramp_params[];
extern OSL::ClosureParam bsdf_ashikhmin_velvet_params[];
extern OSL::ClosureParam bsdf_westin_backscatter_params[];
extern OSL::ClosureParam bsdf_westin_sheen_params[];
extern OSL::ClosureParam closure_bssrdf_cubic_params[];
extern OSL::ClosureParam closure_emission_params[];
extern OSL::ClosureParam closure_debug_params[];
extern OSL::ClosureParam closure_background_params[];
extern OSL::ClosureParam closure_holdout_params[];
extern OSL::ClosureParam closure_subsurface_params[];
OSL::ClosureParam *bsdf_diffuse_params();
OSL::ClosureParam *bsdf_oren_nayar_params();
OSL::ClosureParam *bsdf_translucent_params();
OSL::ClosureParam *bsdf_reflection_params();
OSL::ClosureParam *bsdf_refraction_params();
OSL::ClosureParam *bsdf_transparent_params();
OSL::ClosureParam *bsdf_microfacet_ggx_params();
OSL::ClosureParam *bsdf_microfacet_ggx_refraction_params();
OSL::ClosureParam *bsdf_microfacet_beckmann_params();
OSL::ClosureParam *bsdf_microfacet_beckmann_refraction_params();
OSL::ClosureParam *bsdf_ward_params();
OSL::ClosureParam *bsdf_phong_params();
OSL::ClosureParam *bsdf_phong_ramp_params();
OSL::ClosureParam *bsdf_ashikhmin_velvet_params();
OSL::ClosureParam *bsdf_westin_backscatter_params();
OSL::ClosureParam *bsdf_westin_sheen_params();
OSL::ClosureParam *closure_bssrdf_cubic_params();
OSL::ClosureParam *closure_emission_params();
OSL::ClosureParam *closure_debug_params();
OSL::ClosureParam *closure_background_params();
OSL::ClosureParam *closure_holdout_params();
OSL::ClosureParam *closure_subsurface_params();
void bsdf_diffuse_prepare(OSL::RendererServices *, int id, void *data);
void bsdf_oren_nayar_prepare(OSL::RendererServices *, int id, void *data);

View File

@@ -139,15 +139,27 @@ static void flatten_surface_closure_tree(ShaderData *sd, bool no_glossy,
float sample_weight = fabsf(average(weight)) * albedo;
sc.sample_weight = sample_weight;
sc.type = CLOSURE_BSDF_ID;
/* scattering flags */
if (scattering == OSL::Labels::DIFFUSE)
if (scattering == OSL::Labels::DIFFUSE) {
sd->flag |= SD_BSDF | SD_BSDF_HAS_EVAL;
else if (scattering == OSL::Labels::GLOSSY)
sc.type = CLOSURE_BSDF_DIFFUSE_ID;
}
else if (scattering == OSL::Labels::GLOSSY) {
sd->flag |= SD_BSDF | SD_BSDF_HAS_EVAL | SD_BSDF_GLOSSY;
else
sc.type = CLOSURE_BSDF_GLOSSY_ID;
}
else if (scattering == OSL::Labels::STRAIGHT) {
sd->flag |= SD_BSDF;
sc.type = CLOSURE_BSDF_TRANSPARENT_ID;
}
else {
/* todo: we don't actually have a way to determine if
* this closure will reflect/transmit. could add our own
* own scattering flag that do give this info */
sd->flag |= SD_BSDF;
sc.type = CLOSURE_BSDF_GLOSSY_ID;
}
/* add */
sd->closure[sd->num_closure++] = sc;

View File

@@ -122,14 +122,18 @@ public:
ClosureParam closure_subsurface_params[] = {
ClosureParam *closure_subsurface_params()
{
static ClosureParam params[] = {
CLOSURE_FLOAT_PARAM(SubsurfaceClosure, m_eta),
CLOSURE_FLOAT_PARAM(SubsurfaceClosure, m_g),
CLOSURE_COLOR_PARAM(SubsurfaceClosure, m_mfp),
CLOSURE_COLOR_PARAM(SubsurfaceClosure, m_albedo),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(SubsurfaceClosure)
};
};
return params;
}
CLOSURE_PREPARE(closure_subsurface_prepare, SubsurfaceClosure)

View File

@@ -92,6 +92,14 @@ __device void svm_node_tex_coord(KernelGlobals *kg, ShaderData *sd, float *stack
data = sd->I;
break;
}
case NODE_TEXCO_DUPLI_GENERATED: {
data = object_dupli_generated(kg, sd->object);
break;
}
case NODE_TEXCO_DUPLI_UV: {
data = object_dupli_uv(kg, sd->object);
break;
}
}
stack_store_float3(stack, out_offset, data);
@@ -141,6 +149,14 @@ __device void svm_node_tex_coord_bump_dx(KernelGlobals *kg, ShaderData *sd, floa
data = sd->I;
break;
}
case NODE_TEXCO_DUPLI_GENERATED: {
data = object_dupli_generated(kg, sd->object);
break;
}
case NODE_TEXCO_DUPLI_UV: {
data = object_dupli_uv(kg, sd->object);
break;
}
}
stack_store_float3(stack, out_offset, data);
@@ -193,6 +209,14 @@ __device void svm_node_tex_coord_bump_dy(KernelGlobals *kg, ShaderData *sd, floa
data = sd->I;
break;
}
case NODE_TEXCO_DUPLI_GENERATED: {
data = object_dupli_generated(kg, sd->object);
break;
}
case NODE_TEXCO_DUPLI_UV: {
data = object_dupli_uv(kg, sd->object);
break;
}
}
stack_store_float3(stack, out_offset, data);

View File

@@ -43,6 +43,7 @@ typedef enum NodeType {
NODE_TEX_IMAGE_BOX,
NODE_TEX_SKY,
NODE_GEOMETRY,
NODE_GEOMETRY_DUPLI,
NODE_LIGHT_PATH,
NODE_VALUE_F,
NODE_VALUE_V,
@@ -149,7 +150,9 @@ typedef enum NodeTexCoord {
NODE_TEXCO_OBJECT,
NODE_TEXCO_CAMERA,
NODE_TEXCO_WINDOW,
NODE_TEXCO_REFLECTION
NODE_TEXCO_REFLECTION,
NODE_TEXCO_DUPLI_GENERATED,
NODE_TEXCO_DUPLI_UV
} NodeTexCoord;
typedef enum NodeMix {
@@ -284,16 +287,18 @@ typedef enum ClosureType {
CLOSURE_BSDF_DIFFUSE_ID,
CLOSURE_BSDF_OREN_NAYAR_ID,
CLOSURE_BSDF_GLOSSY_ID,
CLOSURE_BSDF_REFLECTION_ID,
CLOSURE_BSDF_MICROFACET_GGX_ID,
CLOSURE_BSDF_MICROFACET_BECKMANN_ID,
CLOSURE_BSDF_WARD_ID,
CLOSURE_BSDF_ASHIKHMIN_VELVET_ID,
CLOSURE_BSDF_WESTIN_SHEEN_ID,
CLOSURE_BSDF_TRANSMISSION_ID,
CLOSURE_BSDF_TRANSLUCENT_ID,
CLOSURE_BSDF_REFRACTION_ID,
CLOSURE_BSDF_WESTIN_BACKSCATTER_ID,
CLOSURE_BSDF_ASHIKHMIN_VELVET_ID,
CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID,
CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID,
CLOSURE_BSDF_GLASS_ID,
@@ -317,8 +322,8 @@ typedef enum ClosureType {
/* watch this, being lazy with memory usage */
#define CLOSURE_IS_BSDF(type) (type <= CLOSURE_BSDF_TRANSPARENT_ID)
#define CLOSURE_IS_BSDF_DIFFUSE(type) (type >= CLOSURE_BSDF_DIFFUSE_ID && type <= CLOSURE_BSDF_OREN_NAYAR_ID)
#define CLOSURE_IS_BSDF_GLOSSY(type) (type >= CLOSURE_BSDF_REFLECTION_ID && type <= CLOSURE_BSDF_WESTIN_SHEEN_ID)
#define CLOSURE_IS_BSDF_TRANSMISSION(type) (type >= CLOSURE_BSDF_TRANSLUCENT_ID && type <= CLOSURE_BSDF_GLASS_ID)
#define CLOSURE_IS_BSDF_GLOSSY(type) (type >= CLOSURE_BSDF_GLOSSY_ID && type <= CLOSURE_BSDF_WESTIN_SHEEN_ID)
#define CLOSURE_IS_BSDF_TRANSMISSION(type) (type >= CLOSURE_BSDF_TRANSMISSION_ID && type <= CLOSURE_BSDF_GLASS_ID)
#define CLOSURE_IS_VOLUME(type) (type >= CLOSURE_VOLUME_ID && type <= CLOSURE_VOLUME_ISOTROPIC_ID)
#define CLOSURE_IS_EMISSION(type) (type == CLOSURE_EMISSION_ID)
#define CLOSURE_IS_HOLDOUT(type) (type == CLOSURE_HOLDOUT_ID)

View File

@@ -7,7 +7,6 @@ set(INC
../kernel/osl
../bvh
../util
${GLEW_INCLUDE_PATH}
)
set(INC_SYS
${GLEW_INCLUDE_PATH}

View File

@@ -181,14 +181,14 @@ void ShaderGraph::connect(ShaderOutput *from, ShaderInput *to)
assert(from && to);
if(to->link) {
fprintf(stderr, "ShaderGraph connect: input already connected.\n");
fprintf(stderr, "Cycles shader graph connect: input already connected.\n");
return;
}
if(from->type != to->type) {
/* for closures we can't do automatic conversion */
if(from->type == SHADER_SOCKET_CLOSURE || to->type == SHADER_SOCKET_CLOSURE) {
fprintf(stderr, "ShaderGraph connect: can only connect closure to closure "
fprintf(stderr, "Cycles shader graph connect: can only connect closure to closure "
"(ShaderNode:%s, ShaderOutput:%s , type:%d -> to ShaderNode:%s, ShaderInput:%s, type:%d).\n",
from->parent->name.c_str(), from->name, (int)from->type,
to->parent->name.c_str(), to->name, (int)to->type);
@@ -363,7 +363,7 @@ void ShaderGraph::break_cycles(ShaderNode *node, vector<bool>& visited, vector<b
if(on_stack[depnode->id]) {
/* break cycle */
disconnect(input);
fprintf(stderr, "ShaderGraph: detected cycle in graph, connection removed.\n");
fprintf(stderr, "Cycles shader graph: detected cycle in graph, connection removed.\n");
}
else if(!visited[depnode->id]) {
/* visit dependencies */

View File

@@ -67,6 +67,8 @@ static void dump_background_pixels(Device *device, DeviceScene *dscene, int res,
main_task.shader_x = 0;
main_task.shader_w = width*height;
/* disabled splitting for now, there's an issue with multi-GPU mem_copy_from */
#if 0
list<DeviceTask> split_tasks;
main_task.split_max_size(split_tasks, 128*128);
@@ -74,6 +76,10 @@ static void dump_background_pixels(Device *device, DeviceScene *dscene, int res,
device->task_add(task);
device->task_wait();
}
#else
device->task_add(main_task);
device->task_wait();
#endif
device->mem_copy_from(d_output, 0, 1, d_output.size(), sizeof(float4));
device->mem_free(d_input);

View File

@@ -1644,14 +1644,18 @@ TextureCoordinateNode::TextureCoordinateNode()
add_output("Camera", SHADER_SOCKET_POINT);
add_output("Window", SHADER_SOCKET_POINT);
add_output("Reflection", SHADER_SOCKET_NORMAL);
from_dupli = false;
}
void TextureCoordinateNode::attributes(AttributeRequestSet *attributes)
{
if(!from_dupli) {
if(!output("Generated")->links.empty())
attributes->add(ATTR_STD_GENERATED);
if(!output("UV")->links.empty())
attributes->add(ATTR_STD_UV);
}
ShaderNode::attributes(attributes);
}
@@ -1680,12 +1684,18 @@ void TextureCoordinateNode::compile(SVMCompiler& compiler)
compiler.stack_assign(out);
compiler.add_node(geom_node, NODE_GEOM_P, out->stack_offset);
}
else {
if(from_dupli) {
compiler.stack_assign(out);
compiler.add_node(texco_node, NODE_TEXCO_DUPLI_GENERATED, out->stack_offset);
}
else {
int attr = compiler.attribute(ATTR_STD_GENERATED);
compiler.stack_assign(out);
compiler.add_node(attr_node, attr, out->stack_offset, NODE_ATTR_FLOAT3);
}
}
}
out = output("Normal");
if(!out->links.empty()) {
@@ -1695,10 +1705,16 @@ void TextureCoordinateNode::compile(SVMCompiler& compiler)
out = output("UV");
if(!out->links.empty()) {
if(from_dupli) {
compiler.stack_assign(out);
compiler.add_node(texco_node, NODE_TEXCO_DUPLI_UV, out->stack_offset);
}
else {
int attr = compiler.attribute(ATTR_STD_UV);
compiler.stack_assign(out);
compiler.add_node(attr_node, attr, out->stack_offset, NODE_ATTR_FLOAT3);
}
}
out = output("Object");
if(!out->links.empty()) {

View File

@@ -284,6 +284,8 @@ class TextureCoordinateNode : public ShaderNode {
public:
SHADER_NODE_CLASS(TextureCoordinateNode)
void attributes(AttributeRequestSet *attributes);
bool from_dupli;
};
class LightPathNode : public ShaderNode {

View File

@@ -235,6 +235,10 @@ void ObjectManager::device_update_transforms(Device *device, DeviceScene *dscene
}
}
/* dupli object coords */
objects[offset+16] = make_float4(ob->dupli_generated[0], ob->dupli_generated[1], ob->dupli_generated[2], 0.0f);
objects[offset+17] = make_float4(ob->dupli_uv[0], ob->dupli_uv[1], 0.0f, 0.0f);
/* object flag */
if(ob->use_holdout)
flag |= SD_HOLDOUT_MASK;

View File

@@ -49,6 +49,9 @@ public:
bool use_motion;
bool use_holdout;
float3 dupli_generated;
float2 dupli_uv;
int particle_id;
Object();

View File

@@ -274,6 +274,17 @@ void SVMCompiler::stack_clear_users(ShaderNode *node, set<ShaderNode*>& done)
foreach(ShaderInput *in, output->links)
in->stack_offset = SVM_STACK_INVALID;
/* unmark any nodes that have no more valid outputs, see [#31806] */
if(done.find(output->parent) != done.end()) {
all_done = true;
foreach(ShaderOutput *pout, output->parent->outputs)
if(pout->stack_offset != SVM_STACK_INVALID)
all_done = false;
if(all_done)
done.erase(output->parent);
}
}
}
}

View File

@@ -384,22 +384,22 @@ InternalNode *Octree::addTriangle(InternalNode *node, CubeTriangleIsect *p, int
/* Pruning using intersection test */
if (subp->isIntersecting()) {
if (!hasChild(node, i)) {
if (!node->has_child(i)) {
if (height == 1)
node = addLeafChild(node, i, count, createLeaf(0));
else
node = addInternalChild(node, i, count, createInternal(0));
}
Node *chd = getChild(node, count);
Node *chd = node->get_child(count);
if (node->is_child_leaf(i))
setChild(node, count, (Node *)updateCell(&chd->leaf, subp));
node->set_child(count, (Node *)updateCell(&chd->leaf, subp));
else
setChild(node, count, (Node *)addTriangle(&chd->internal, subp, height - 1));
node->set_child(count, (Node *)addTriangle(&chd->internal, subp, height - 1));
}
}
if (hasChild(node, i))
if (node->has_child(i))
count++;
}
@@ -450,11 +450,11 @@ void Octree::preparePrimalEdgesMask(InternalNode *node)
{
int count = 0;
for (int i = 0; i < 8; i++) {
if (hasChild(node, i)) {
if (node->has_child(i)) {
if (node->is_child_leaf(i))
createPrimalEdgesMask(&getChild(node, count)->leaf);
createPrimalEdgesMask(&node->get_child(count)->leaf);
else
preparePrimalEdgesMask(&getChild(node, count)->internal);
preparePrimalEdgesMask(&node->get_child(count)->internal);
count++;
}
@@ -487,7 +487,7 @@ Node *Octree::trace(Node *newnode, int *st, int len, int depth, PathList *& path
// Get children paths
int chdleaf[8];
fillChildren(&newnode->internal, chd, chdleaf);
newnode->internal.fill_children(chd, chdleaf);
// int count = 0;
for (i = 0; i < 8; i++) {
@@ -510,7 +510,7 @@ Node *Octree::trace(Node *newnode, int *st, int len, int depth, PathList *& path
int df[2] = {depth - 1, depth - 1};
int *nstf[2];
fillChildren(&newnode->internal, chd, chdleaf);
newnode->internal.fill_children(chd, chdleaf);
for (i = 0; i < 12; i++) {
int c[2] = {cellProcFaceMask[i][0], cellProcFaceMask[i][1]};
@@ -590,7 +590,7 @@ void Octree::findPaths(Node *node[2], int leaf[2], int depth[2], int *st[2], int
for (j = 0; j < 2; j++) {
if (!leaf[j]) {
fillChildren(&node[j]->internal, chd[j], chdleaf[j]);
node[j]->internal.fill_children(chd[j], chdleaf[j]);
int len = (dimen >> (maxDepth - depth[j] + 1));
for (i = 0; i < 8; i++) {
@@ -966,10 +966,10 @@ Node *Octree::patch(Node *newnode, int st[3], int len, PathList *rings)
st[1] + len * vertmap[i][1],
st[2] + len * vertmap[i][2]
};
patch(getChild(&newnode->internal, count), nori, len, zlists[i]);
patch(newnode->internal.get_child(count), nori, len, zlists[i]);
}
if (hasChild(&newnode->internal, i)) {
if (newnode->internal.has_child(i)) {
count++;
}
}
@@ -1408,16 +1408,16 @@ Node *Octree::locateCell(InternalNode *node, int st[3], int len, int ori[3], int
rst[1] = st[1] + vertmap[ind][1] * len;
rst[2] = st[2] + vertmap[ind][2] * len;
if (hasChild(node, ind)) {
int count = getChildCount(node, ind);
Node *chd = getChild(node, count);
if (node->has_child(ind)) {
int count = node->get_child_count(ind);
Node *chd = node->get_child(count);
if (node->is_child_leaf(ind)) {
rleaf = chd;
rlen = len;
}
else {
// Recur
setChild(node, count, locateCell(&chd->internal, rst, len, ori, dir, side, rleaf, rst, rlen));
node->set_child(count, locateCell(&chd->internal, rst, len, ori, dir, side, rleaf, rst, rlen));
}
}
else {
@@ -1724,7 +1724,7 @@ void Octree::buildSigns(unsigned char table[], Node *node, int isLeaf, int sg, i
// Internal node
Node *chd[8];
int leaf[8];
fillChildren(&node->internal, chd, leaf);
node->internal.fill_children(chd, leaf);
// Get the signs at the corners of the first cube
rvalue[0] = sg;
@@ -1784,8 +1784,8 @@ void Octree::clearProcessBits(Node *node, int height)
// Internal cell, recur
int count = 0;
for (i = 0; i < 8; i++) {
if (hasChild(&node->internal, i)) {
clearProcessBits(getChild(&node->internal, count), height - 1);
if (node->internal.has_child(i)) {
clearProcessBits(node->internal.get_child(count), height - 1);
count++;
}
}
@@ -2016,13 +2016,13 @@ int Octree::floodFill(Node *node, int st[3], int len, int height, int threshold)
int count = 0;
len >>= 1;
for (i = 0; i < 8; i++) {
if (hasChild((InternalNode *)node, i)) {
if (node->internal.has_child(i)) {
int nst[3];
nst[0] = st[0] + vertmap[i][0] * len;
nst[1] = st[1] + vertmap[i][1] * len;
nst[2] = st[2] + vertmap[i][2] * len;
int d = floodFill(getChild((InternalNode *)node, count), nst, len, height - 1, threshold);
int d = floodFill(node->internal.get_child(count), nst, len, height - 1, threshold);
if (d > maxtotal) {
maxtotal = d;
}
@@ -2062,9 +2062,9 @@ void Octree::writeOut()
void Octree::countIntersection(Node *node, int height, int& nedge, int& ncell, int& nface)
{
if (height > 0) {
int total = getNumChildren(&node->internal);
int total = node->internal.get_num_children();
for (int i = 0; i < total; i++) {
countIntersection(getChild(&node->internal, i), height - 1, nedge, ncell, nface);
countIntersection(node->internal.get_child(i), height - 1, nedge, ncell, nface);
}
}
else {
@@ -2128,6 +2128,30 @@ static void solve_least_squares(const float halfA[], const float b[],
rvalue[i] = result(i);
}
static void mass_point(float mp[3], const float pts[12][3], const int parity[12])
{
int ec = 0;
for (int i = 0; i < 12; i++) {
if (parity[i]) {
const float *p = pts[i];
mp[0] += p[0];
mp[1] += p[1];
mp[2] += p[2];
ec++;
}
}
if (ec == 0) {
return;
}
mp[0] /= ec;
mp[1] /= ec;
mp[2] /= ec;
}
static void minimize(float rvalue[3], float mp[3], const float pts[12][3],
const float norms[12][3], const int parity[12])
{
@@ -2175,35 +2199,52 @@ static void minimize(float rvalue[3], float mp[3], const float pts[12][3],
solve_least_squares(ata, atb, mp, rvalue);
}
void Octree::computeMinimizer(LeafNode *leaf, int st[3], int len, float rvalue[3])
void Octree::computeMinimizer(const LeafNode *leaf, int st[3], int len,
float rvalue[3]) const
{
// First, gather all edge intersections
float pts[12][3], norms[12][3];
int parity[12];
fillEdgeIntersections(leaf, st, len, pts, norms, parity);
// Next, construct QEF and minimizer
switch (mode) {
case DUALCON_CENTROID:
rvalue[0] = (float) st[0] + len / 2;
rvalue[1] = (float) st[1] + len / 2;
rvalue[2] = (float) st[2] + len / 2;
break;
case DUALCON_MASS_POINT:
rvalue[0] = rvalue[1] = rvalue[2] = 0;
mass_point(rvalue, pts, parity);
break;
default: {
// Sharp features */
// construct QEF and minimizer
float mp[3] = {0, 0, 0};
minimize(rvalue, mp, pts, norms, parity);
/* Restraining the location of the minimizer */
float nh1 = hermite_num * len;
float nh2 = (1 + hermite_num) * len;
if ((mode == DUALCON_MASS_POINT || mode == DUALCON_CENTROID) ||
(rvalue[0] < st[0] - nh1 || rvalue[1] < st[1] - nh1 || rvalue[2] < st[2] - nh1 ||
rvalue[0] > st[0] + nh2 || rvalue[1] > st[1] + nh2 || rvalue[2] > st[2] + nh2)) {
if (mode == DUALCON_CENTROID) {
// Use centroids
rvalue[0] = (float) st[0] + len / 2;
rvalue[1] = (float) st[1] + len / 2;
rvalue[2] = (float) st[2] + len / 2;
}
else {
if (rvalue[0] < st[0] - nh1 ||
rvalue[1] < st[1] - nh1 ||
rvalue[2] < st[2] - nh1 ||
rvalue[0] > st[0] + nh2 ||
rvalue[1] > st[1] + nh2 ||
rvalue[2] > st[2] + nh2)
{
// Use mass point instead
rvalue[0] = mp[0];
rvalue[1] = mp[1];
rvalue[2] = mp[2];
}
break;
}
}
}
@@ -2253,13 +2294,13 @@ void Octree::generateMinimizer(Node *node, int st[3], int len, int height, int&
int count = 0;
len >>= 1;
for (i = 0; i < 8; i++) {
if (hasChild(&node->internal, i)) {
if (node->internal.has_child(i)) {
int nst[3];
nst[0] = st[0] + vertmap[i][0] * len;
nst[1] = st[1] + vertmap[i][1] * len;
nst[2] = st[2] + vertmap[i][2] * len;
generateMinimizer(getChild(&node->internal, count),
generateMinimizer(node->internal.get_child(count),
nst, len, height - 1, offset);
count++;
}
@@ -2344,9 +2385,9 @@ void Octree::edgeProcContour(Node *node[4], int leaf[4], int depth[4], int maxde
Node *chd[4][8];
for (j = 0; j < 4; j++) {
for (i = 0; i < 8; i++) {
chd[j][i] = ((!leaf[j]) && hasChild(&node[j]->internal, i)) ?
getChild(&node[j]->internal,
getChildCount(&node[j]->internal, i)) : NULL;
chd[j][i] = ((!leaf[j]) && node[j]->internal.has_child(i)) ?
node[j]->internal.get_child(
node[j]->internal.get_child_count(i)) : NULL;
}
}
@@ -2391,9 +2432,9 @@ void Octree::faceProcContour(Node *node[2], int leaf[2], int depth[2], int maxde
Node *chd[2][8];
for (j = 0; j < 2; j++) {
for (i = 0; i < 8; i++) {
chd[j][i] = ((!leaf[j]) && hasChild(&node[j]->internal, i)) ?
getChild(&node[j]->internal,
getChildCount(&node[j]->internal, i)) : NULL;
chd[j][i] = ((!leaf[j]) && node[j]->internal.has_child(i)) ?
node[j]->internal.get_child(
node[j]->internal.get_child_count(i)) : NULL;
}
}
@@ -2460,9 +2501,8 @@ void Octree::cellProcContour(Node *node, int leaf, int depth)
// Fill children nodes
Node *chd[8];
for (i = 0; i < 8; i++) {
chd[i] = ((!leaf) && hasChild(&node->internal, i)) ?
getChild(&node->internal,
getChildCount(&node->internal, i)) : NULL;
chd[i] = ((!leaf) && node->internal.has_child(i)) ?
node->internal.get_child(node->internal.get_child_count(i)) : NULL;
}
// 8 Cell calls
@@ -2539,8 +2579,8 @@ void Octree::edgeProcParity(Node *node[4], int leaf[4], int depth[4], int maxdep
Node *chd[4][8];
for (j = 0; j < 4; j++) {
for (i = 0; i < 8; i++) {
chd[j][i] = ((!leaf[j]) && hasChild(&node[j]->internal, i)) ?
getChild(&node[j]->internal, getChildCount(&node[j]->internal, i)) : NULL;
chd[j][i] = ((!leaf[j]) && node[j]->internal.has_child(i)) ?
node[j]->internal.get_child( node[j]->internal.get_child_count(i)) : NULL;
}
}
@@ -2589,9 +2629,9 @@ void Octree::faceProcParity(Node *node[2], int leaf[2], int depth[2], int maxdep
Node *chd[2][8];
for (j = 0; j < 2; j++) {
for (i = 0; i < 8; i++) {
chd[j][i] = ((!leaf[j]) && hasChild(&node[j]->internal, i)) ?
getChild(&node[j]->internal,
getChildCount(&node[j]->internal, i)) : NULL;
chd[j][i] = ((!leaf[j]) && node[j]->internal.has_child(i)) ?
node[j]->internal.get_child(
node[j]->internal.get_child_count(i)) : NULL;
}
}
@@ -2658,9 +2698,8 @@ void Octree::cellProcParity(Node *node, int leaf, int depth)
// Fill children nodes
Node *chd[8];
for (i = 0; i < 8; i++) {
chd[i] = ((!leaf) && hasChild((InternalNode *)node, i)) ?
getChild((InternalNode *)node,
getChildCount((InternalNode *)node, i)) : NULL;
chd[i] = ((!leaf) && node->internal.has_child(i)) ?
node->internal.get_child(node->internal.get_child_count(i)) : NULL;
}
// 8 Cell calls
@@ -2803,3 +2842,7 @@ const int dirEdge[3][4] = {
{7, 6, 5, 4},
{11, 10, 9, 8}
};
int InternalNode::numChildrenTable[256];
int InternalNode::childrenCountTable[256][8];
int InternalNode::childrenIndexTable[256][8];

View File

@@ -56,12 +56,18 @@
#define EDGE_FLOATS 4
union Node;
struct LeafNode;
struct InternalNode {
/* Treat as bitfield, bit N indicates whether child N exists or not */
unsigned char has_child;
/* Treat as bitfield, bit N indicates whether child N is a leaf or not */
unsigned char child_is_leaf;
/* Initialized in Octree::BuildTable */
static int numChildrenTable[256];
static int childrenCountTable[256][8];
static int childrenIndexTable[256][8];
/* Bit N indicates whether child N exists or not */
unsigned char has_child_bitfield;
/* Bit N indicates whether child N is a leaf or not */
unsigned char child_is_leaf_bitfield;
/* Can have up to eight children */
Node *children[0];
@@ -69,7 +75,78 @@ struct InternalNode {
/// Test if child is leaf
int is_child_leaf(int index) const
{
return (child_is_leaf >> index) & 1;
return (child_is_leaf_bitfield >> index) & 1;
}
/// If child index exists
int has_child(int index) const
{
return (has_child_bitfield >> index) & 1;
}
/// Get the pointer to child index
Node *get_child(int count)
{
return children[count];
}
const Node *get_child(int count) const
{
return children[count];
}
/// Get total number of children
int get_num_children() const
{
return numChildrenTable[has_child_bitfield];
}
/// Get the count of children
int get_child_count(int index) const
{
return childrenCountTable[has_child_bitfield][index];
}
int get_child_index(int count)
{
return childrenIndexTable[has_child_bitfield][count];
}
const int *get_child_counts() const
{
return childrenCountTable[has_child_bitfield];
}
/// Get all children
void fill_children(Node *children[8], int leaf[8])
{
int count = 0;
for (int i = 0; i < 8; i++) {
leaf[i] = is_child_leaf(i);
if (has_child(i)) {
children[i] = get_child(count);
count++;
}
else {
children[i] = NULL;
leaf[i] = 0;
}
}
}
/// Sets the child pointer
void set_child(int count, Node *chd)
{
children[count] = chd;
}
void set_internal_child(int index, int count, InternalNode *chd)
{
set_child(count, (Node *)chd);
has_child_bitfield |= (1 << index);
}
void set_leaf_child(int index, int count, LeafNode *chd)
{
set_child(count, (Node *)chd);
has_child_bitfield |= (1 << index);
child_is_leaf_bitfield |= (1 << index);
}
};
@@ -345,7 +422,8 @@ class Octree
void countIntersection(Node *node, int height, int& nedge, int& ncell, int& nface);
void generateMinimizer(Node * node, int st[3], int len, int height, int& offset);
void computeMinimizer(LeafNode * leaf, int st[3], int len, float rvalue[3]);
void computeMinimizer(const LeafNode * leaf, int st[3], int len,
float rvalue[3]) const;
/**
* Traversal functions to generate polygon model
* op: 0 for counting, 1 for writing OBJ, 2 for writing OFF, 3 for writing PLY
@@ -365,9 +443,6 @@ class Octree
/************ Operators for all nodes ************/
/// Lookup table
int numChildrenTable[256];
int childrenCountTable[256][8];
int childrenIndexTable[256][8];
int numEdgeTable[8];
int edgeCountTable[8][3];
@@ -375,12 +450,12 @@ class Octree
void buildTable()
{
for (int i = 0; i < 256; i++) {
numChildrenTable[i] = 0;
InternalNode::numChildrenTable[i] = 0;
int count = 0;
for (int j = 0; j < 8; j++) {
numChildrenTable[i] += ((i >> j) & 1);
childrenCountTable[i][j] = count;
childrenIndexTable[i][count] = j;
InternalNode::numChildrenTable[i] += ((i >> j) & 1);
InternalNode::childrenCountTable[i][j] = count;
InternalNode::childrenIndexTable[i][count] = j;
count += ((i >> j) & 1);
}
}
@@ -402,15 +477,15 @@ class Octree
return getSign(&node->leaf, index);
}
else {
if (hasChild(&node->internal, index)) {
return getSign(getChild(&node->internal, getChildCount(&node->internal, index)),
if (node->internal.has_child(index)) {
return getSign(node->internal.get_child(node->internal.get_child_count(index)),
height - 1,
index);
}
else {
return getSign(getChild(&node->internal, 0),
return getSign(node->internal.get_child(0),
height - 1,
7 - getChildIndex(&node->internal, 0));
7 - node->internal.get_child_index(0));
}
}
}
@@ -469,7 +544,7 @@ class Octree
leaf->signs |= ((sign & 1) << index);
}
int getSignMask(const LeafNode *leaf)
int getSignMask(const LeafNode *leaf) const
{
return leaf->signs;
}
@@ -536,7 +611,7 @@ class Octree
}
/// Get edge parity
int getEdgeParity(LeafNode *leaf, int index)
int getEdgeParity(const LeafNode *leaf, int index) const
{
assert(index >= 0 && index <= 11);
@@ -597,7 +672,8 @@ class Octree
leaf->primary_edge_intersections |= (1 << pindex);
}
int getStoredEdgesParity(LeafNode *leaf, int pindex)
int getStoredEdgesParity(const LeafNode *leaf, int pindex) const
{
assert(pindex <= 2 && pindex >= 0);
@@ -652,7 +728,7 @@ class Octree
InternalNode *parent = locateParent(node, len, st, count);
// Update
setChild(parent, count, (Node *)leaf);
parent->set_child(count, (Node *)leaf);
}
void updateParent(InternalNode *node, int len, int st[3])
@@ -667,14 +743,14 @@ class Octree
InternalNode *parent = locateParent(len, st, count);
// UPdate
setChild(parent, count, (Node *)node);
parent->set_child(count, (Node *)node);
}
/// Find edge intersection on a given edge
int getEdgeIntersectionByIndex(int st[3], int index, float pt[3], int check)
int getEdgeIntersectionByIndex(int st[3], int index, float pt[3], int check) const
{
// First, locat the leaf
LeafNode *leaf;
const LeafNode *leaf;
if (check) {
leaf = locateLeafCheck(st);
}
@@ -697,7 +773,7 @@ class Octree
}
/// Retrieve number of edges intersected
int getPrimalEdgesMask(LeafNode *leaf)
int getPrimalEdgesMask(const LeafNode *leaf) const
{
return leaf->primary_edge_intersections;
}
@@ -710,7 +786,7 @@ class Octree
}
/// Get the count for a primary edge
int getEdgeCount(LeafNode *leaf, int index)
int getEdgeCount(const LeafNode *leaf, int index) const
{
return edgeCountTable[getPrimalEdgesMask(leaf)][index];
}
@@ -744,7 +820,7 @@ class Octree
}
/// Retrieve edge intersection
float getEdgeOffset(LeafNode *leaf, int count)
float getEdgeOffset(const LeafNode *leaf, int count) const
{
return leaf->edge_intersections[4 * count];
}
@@ -834,10 +910,11 @@ class Octree
}
/// Retrieve complete edge intersection
void getEdgeIntersectionByIndex(LeafNode *leaf, int index, int st[3], int len, float pt[3], float nm[3])
void getEdgeIntersectionByIndex(const LeafNode *leaf, int index, int st[3],
int len, float pt[3], float nm[3]) const
{
int count = getEdgeCount(leaf, index);
float *pts = leaf->edge_intersections;
const float *pts = leaf->edge_intersections;
float off = pts[4 * count];
@@ -865,7 +942,8 @@ class Octree
return off;
}
void fillEdgeIntersections(LeafNode *leaf, int st[3], int len, float pts[12][3], float norms[12][3])
void fillEdgeIntersections(const LeafNode *leaf, int st[3], int len,
float pts[12][3], float norms[12][3]) const
{
int i;
// int stt[3] = {0, 0, 0};
@@ -890,7 +968,7 @@ class Octree
nst[i] += len;
// int nstt[3] = {0, 0, 0};
// nstt[i] += 1;
LeafNode *node = locateLeaf(nst);
const LeafNode *node = locateLeaf(nst);
if (e1) {
// getEdgeIntersectionByIndex(node, femask[i][0], nstt, 1, pts[fmask[i][0]], norms[fmask[i][0]]);
@@ -912,7 +990,7 @@ class Octree
nst[i] -= len;
// int nstt[3] = {1, 1, 1};
// nstt[i] -= 1;
LeafNode *node = locateLeaf(nst);
const LeafNode *node = locateLeaf(nst);
// getEdgeIntersectionByIndex(node, eemask[i], nstt, 1, pts[emask[i]], norms[emask[i]]);
getEdgeIntersectionByIndex(node, eemask[i], nst, len, pts[emask[i]], norms[emask[i]]);
@@ -921,7 +999,9 @@ class Octree
}
void fillEdgeIntersections(LeafNode *leaf, int st[3], int len, float pts[12][3], float norms[12][3], int parity[12])
void fillEdgeIntersections(const LeafNode *leaf, int st[3], int len,
float pts[12][3], float norms[12][3],
int parity[12]) const
{
int i;
for (i = 0; i < 12; i++) {
@@ -948,7 +1028,7 @@ class Octree
nst[i] += len;
// int nstt[3] = {0, 0, 0};
// nstt[i] += 1;
LeafNode *node = locateLeafCheck(nst);
const LeafNode *node = locateLeafCheck(nst);
if (node == NULL) {
continue;
}
@@ -979,7 +1059,7 @@ class Octree
nst[i] -= len;
// int nstt[3] = {1, 1, 1};
// nstt[i] -= 1;
LeafNode *node = locateLeafCheck(nst);
const LeafNode *node = locateLeafCheck(nst);
if (node == NULL) {
continue;
}
@@ -1088,7 +1168,20 @@ class Octree
int index = (((st[0] >> i) & 1) << 2) |
(((st[1] >> i) & 1) << 1) |
(((st[2] >> i) & 1));
node = getChild(&node->internal, getChildCount(&node->internal, index));
node = node->internal.get_child(node->internal.get_child_count(index));
}
return &node->leaf;
}
const LeafNode *locateLeaf(int st[3]) const
{
const Node *node = root;
for (int i = GRID_DIMENSION - 1; i > GRID_DIMENSION - maxDepth - 1; i--) {
int index = (((st[0] >> i) & 1) << 2) |
(((st[1] >> i) & 1) << 1) |
(((st[2] >> i) & 1));
node = node->internal.get_child(node->internal.get_child_count(index));
}
return &node->leaf;
@@ -1102,8 +1195,7 @@ class Octree
index = (((st[0] & i) ? 4 : 0) |
((st[1] & i) ? 2 : 0) |
((st[2] & i) ? 1 : 0));
node = getChild(&node->internal,
getChildCount(&node->internal, index));
node = node->internal.get_child(node->internal.get_child_count(index));
}
return &node->leaf;
@@ -1116,10 +1208,26 @@ class Octree
int index = (((st[0] >> i) & 1) << 2) |
(((st[1] >> i) & 1) << 1) |
(((st[2] >> i) & 1));
if (!hasChild(&node->internal, index)) {
if (!node->internal.has_child(index)) {
return NULL;
}
node = getChild(&node->internal, getChildCount(&node->internal, index));
node = node->internal.get_child(node->internal.get_child_count(index));
}
return &node->leaf;
}
const LeafNode *locateLeafCheck(int st[3]) const
{
const Node *node = root;
for (int i = GRID_DIMENSION - 1; i > GRID_DIMENSION - maxDepth - 1; i--) {
int index = (((st[0] >> i) & 1) << 2) |
(((st[1] >> i) & 1) << 1) |
(((st[2] >> i) & 1));
if (!node->internal.has_child(index)) {
return NULL;
}
node = node->internal.get_child(node->internal.get_child_count(index));
}
return &node->leaf;
@@ -1135,10 +1243,10 @@ class Octree
((st[1] & i) ? 2 : 0) |
((st[2] & i) ? 1 : 0));
pre = node;
node = &getChild(node, getChildCount(node, index))->internal;
node = &node->get_child(node->get_child_count(index))->internal;
}
count = getChildCount(pre, index);
count = pre->get_child_count(index);
return pre;
}
@@ -1152,88 +1260,21 @@ class Octree
((st[1] & i) ? 2 : 0) |
((st[2] & i) ? 1 : 0));
pre = node;
node = (InternalNode *)getChild(node, getChildCount(node, index));
node = &node->get_child(node->get_child_count(index))->internal;
}
count = getChildCount(pre, index);
count = pre->get_child_count(index);
return pre;
}
/************ Operators for internal nodes ************/
/// If child index exists
int hasChild(InternalNode *node, int index)
{
return (node->has_child >> index) & 1;
}
/// Get the pointer to child index
Node *getChild(InternalNode *node, int count)
{
return node->children[count];
};
/// Get total number of children
int getNumChildren(InternalNode *node)
{
return numChildrenTable[node->has_child];
}
/// Get the count of children
int getChildCount(InternalNode *node, int index)
{
return childrenCountTable[node->has_child][index];
}
int getChildIndex(InternalNode *node, int count)
{
return childrenIndexTable[node->has_child][count];
}
int *getChildCounts(InternalNode *node)
{
return childrenCountTable[node->has_child];
}
/// Get all children
void fillChildren(InternalNode *node, Node *children[8], int leaf[8])
{
int count = 0;
for (int i = 0; i < 8; i++) {
leaf[i] = node->is_child_leaf(i);
if (hasChild(node, i)) {
children[i] = getChild(node, count);
count++;
}
else {
children[i] = NULL;
leaf[i] = 0;
}
}
}
/// Sets the child pointer
void setChild(InternalNode *node, int count, Node *chd)
{
node->children[count] = chd;
}
void setInternalChild(InternalNode *node, int index, int count, InternalNode *chd)
{
setChild(node, count, (Node *)chd);
node->has_child |= (1 << index);
}
void setLeafChild(InternalNode *node, int index, int count, LeafNode *chd)
{
setChild(node, count, (Node *)chd);
node->has_child |= (1 << index);
node->child_is_leaf |= (1 << index);
}
/// Add a kid to an existing internal node
/// Fix me: can we do this without wasting memory ?
/// Fixed: using variable memory
InternalNode *addChild(InternalNode *node, int index, Node *child, int aLeaf)
{
// Create new internal node
int num = getNumChildren(node);
int num = node->get_num_children();
InternalNode *rnode = createInternal(num + 1);
// Establish children
@@ -1242,19 +1283,19 @@ class Octree
for (i = 0; i < 8; i++) {
if (i == index) {
if (aLeaf) {
setLeafChild(rnode, i, count2, &child->leaf);
rnode->set_leaf_child(i, count2, &child->leaf);
}
else {
setInternalChild(rnode, i, count2, &child->internal);
rnode->set_internal_child(i, count2, &child->internal);
}
count2++;
}
else if (hasChild(node, i)) {
else if (node->has_child(i)) {
if (node->is_child_leaf(i)) {
setLeafChild(rnode, i, count2, &getChild(node, count1)->leaf);
rnode->set_leaf_child(i, count2, &node->get_child(count1)->leaf);
}
else {
setInternalChild(rnode, i, count2, &getChild(node, count1)->internal);
rnode->set_internal_child(i, count2, &node->get_child(count1)->internal);
}
count1++;
count2++;
@@ -1269,8 +1310,8 @@ class Octree
InternalNode *createInternal(int length)
{
InternalNode *inode = (InternalNode *)alloc[length]->allocate();
inode->has_child = 0;
inode->child_is_leaf = 0;
inode->has_child_bitfield = 0;
inode->child_is_leaf_bitfield = 0;
return inode;
}
@@ -1301,21 +1342,21 @@ class Octree
InternalNode *addLeafChild(InternalNode *par, int index, int count,
LeafNode *leaf)
{
int num = getNumChildren(par) + 1;
int num = par->get_num_children() + 1;
InternalNode *npar = createInternal(num);
*npar = *par;
if (num == 1) {
setLeafChild(npar, index, 0, leaf);
npar->set_leaf_child(index, 0, leaf);
}
else {
int i;
for (i = 0; i < count; i++) {
setChild(npar, i, getChild(par, i));
npar->set_child(i, par->get_child(i));
}
setLeafChild(npar, index, count, leaf);
npar->set_leaf_child(index, count, leaf);
for (i = count + 1; i < num; i++) {
setChild(npar, i, getChild(par, i - 1));
npar->set_child(i, par->get_child(i - 1));
}
}
@@ -1326,21 +1367,21 @@ class Octree
InternalNode *addInternalChild(InternalNode *par, int index, int count,
InternalNode *node)
{
int num = getNumChildren(par) + 1;
int num = par->get_num_children() + 1;
InternalNode *npar = createInternal(num);
*npar = *par;
if (num == 1) {
setInternalChild(npar, index, 0, node);
npar->set_internal_child(index, 0, node);
}
else {
int i;
for (i = 0; i < count; i++) {
setChild(npar, i, getChild(par, i));
npar->set_child(i, par->get_child(i));
}
setInternalChild(npar, index, count, node);
npar->set_internal_child(index, count, node);
for (i = count + 1; i < num; i++) {
setChild(npar, i, getChild(par, i - 1));
npar->set_child(i, par->get_child(i - 1));
}
}

View File

@@ -23,40 +23,42 @@
#
# ***** END GPL LICENSE BLOCK *****
if(WITH_OPENCOLORIO)
set(INC
set(INC
.
../guardedalloc
../../source/blender/blenlib
)
set(INC_SYS
)
set(SRC
ocio_capi.cc
fallback_impl.cc
ocio_capi.h
ocio_impl.h
)
if(WITH_OPENCOLORIO)
add_definitions(
-DWITH_OCIO
)
list(APPEND INC_SYS
${OPENCOLORIO_INCLUDE_DIRS}
)
set(SRC
ocio_capi.cpp
ocio_capi.h
list(APPEND SRC
ocio_impl.cc
)
if(WIN32 AND NOT MINGW)
list(APPEND INC
list(APPEND INC_SYS
${BOOST_INCLUDE_DIR}
)
endif()
else()
set(INC
.
../../source/blender/blenlib
)
set(SRC
ocio_capi_stub.cpp
ocio_capi.h
)
endif()
set(INC_SYS
../guardedalloc
)
add_definitions(
)
blender_add_lib(bf_intern_opencolorio "${SRC}" "${INC}" "${INC_SYS}")

View File

@@ -2,18 +2,18 @@
Import('env')
sources = env.Glob('*.cpp')
sources = env.Glob('*.cc')
incs = '. ../guardedalloc ../../source/blender/blenlib'
defs = []
if env['WITH_BF_OCIO']:
sources.remove('ocio_capi_stub.cpp')
defs.append('WITH_OCIO')
incs += ' ' + env['BF_OCIO_INC']
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
incs += ' ' + env['BF_BOOST_INC']
else:
sources.remove('ocio_capi.cpp')
sources.remove('ocio_impl.cc')
env.BlenderLib( 'bf_intern_opencolorio', sources, Split(incs), [], libtype=['extern','player'], priority=[10, 185])
env.BlenderLib( 'bf_intern_opencolorio', sources, Split(incs), defs, libtype=['extern','player'], priority=[10, 185])

View File

@@ -0,0 +1,382 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2012 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Brecht van Lommel
*
* ***** END GPL LICENSE BLOCK *****
*/
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_math_color.h"
#include "ocio_impl.h"
#define CONFIG_DEFAULT ((OCIO_ConstConfigRcPtr*)1)
#define PROCESSOR_LINEAR_TO_SRGB ((OCIO_ConstProcessorRcPtr*)1)
#define PROCESSOR_SRGB_TO_LINEAR ((OCIO_ConstProcessorRcPtr*)2)
#define PROCESSOR_UNKNOWN ((OCIO_ConstProcessorRcPtr*)3)
#define COLORSPACE_LINEAR ((OCIO_ConstColorSpaceRcPtr*)1)
#define COLORSPACE_SRGB ((OCIO_ConstColorSpaceRcPtr*)2)
typedef struct OCIO_PackedImageDescription {
float *data;
long width;
long height;
long numChannels;
long chanStrideBytes;
long xStrideBytes;
long yStrideBytes;
} OCIO_PackedImageDescription;
OCIO_ConstConfigRcPtr *FallbackImpl::getCurrentConfig(void)
{
return CONFIG_DEFAULT;
}
void FallbackImpl::setCurrentConfig(const OCIO_ConstConfigRcPtr *)
{
}
OCIO_ConstConfigRcPtr *FallbackImpl::configCreateFromEnv(void)
{
return CONFIG_DEFAULT;
}
OCIO_ConstConfigRcPtr *FallbackImpl::configCreateFromFile(const char *)
{
return CONFIG_DEFAULT;
}
void FallbackImpl::configRelease(OCIO_ConstConfigRcPtr *)
{
}
int FallbackImpl::configGetNumColorSpaces(OCIO_ConstConfigRcPtr *)
{
return 2;
}
const char *FallbackImpl::configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr *, int index)
{
if (index == 0)
return "Linear";
else if (index == 1)
return "sRGB";
return NULL;
}
OCIO_ConstColorSpaceRcPtr *FallbackImpl::configGetColorSpace(OCIO_ConstConfigRcPtr *, const char *name)
{
if (strcmp(name, "scene_linear") == 0)
return COLORSPACE_LINEAR;
else if (strcmp(name, "color_picking") == 0)
return COLORSPACE_SRGB;
else if (strcmp(name, "texture_paint") == 0)
return COLORSPACE_LINEAR;
else if (strcmp(name, "default_byte") == 0)
return COLORSPACE_SRGB;
else if (strcmp(name, "default_float") == 0)
return COLORSPACE_LINEAR;
else if (strcmp(name, "default_sequencer") == 0)
return COLORSPACE_SRGB;
else if (strcmp(name, "Linear") == 0)
return COLORSPACE_LINEAR;
else if (strcmp(name, "sRGB") == 0)
return COLORSPACE_SRGB;
return NULL;
}
int FallbackImpl::configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name)
{
OCIO_ConstColorSpaceRcPtr *cs = configGetColorSpace(config, name);
if (cs == COLORSPACE_LINEAR)
return 0;
else if (cs == COLORSPACE_SRGB)
return 1;
return -1;
}
const char *FallbackImpl::configGetDefaultDisplay(OCIO_ConstConfigRcPtr *)
{
return "sRGB";
}
int FallbackImpl::configGetNumDisplays(OCIO_ConstConfigRcPtr* config)
{
return 1;
}
const char *FallbackImpl::configGetDisplay(OCIO_ConstConfigRcPtr *, int index)
{
if (index == 0)
return "sRGB";
return NULL;
}
const char *FallbackImpl::configGetDefaultView(OCIO_ConstConfigRcPtr *, const char *)
{
return "Default";
}
int FallbackImpl::configGetNumViews(OCIO_ConstConfigRcPtr *, const char *)
{
return 1;
}
const char *FallbackImpl::configGetView(OCIO_ConstConfigRcPtr *, const char *, int index)
{
if (index == 0)
return "Default";
return NULL;
}
const char *FallbackImpl::configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *, const char *, const char *)
{
return "sRGB";
}
int FallbackImpl::colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs)
{
return 1;
}
int FallbackImpl::colorSpaceIsData(OCIO_ConstColorSpaceRcPtr *cs)
{
return 0;
}
void FallbackImpl::colorSpaceRelease(OCIO_ConstColorSpaceRcPtr *cs)
{
}
OCIO_ConstProcessorRcPtr *FallbackImpl::configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config, const char *srcName, const char *dstName)
{
OCIO_ConstColorSpaceRcPtr *cs_src = configGetColorSpace(config, srcName);
OCIO_ConstColorSpaceRcPtr *cs_dst = configGetColorSpace(config, dstName);
if (cs_src == COLORSPACE_LINEAR && cs_dst == COLORSPACE_SRGB)
return PROCESSOR_LINEAR_TO_SRGB;
else if (cs_src == COLORSPACE_SRGB && cs_dst == COLORSPACE_LINEAR)
return PROCESSOR_SRGB_TO_LINEAR;
return 0;
}
OCIO_ConstProcessorRcPtr *FallbackImpl::configGetProcessor(OCIO_ConstConfigRcPtr *, OCIO_ConstTransformRcPtr *tfm)
{
return (OCIO_ConstProcessorRcPtr*)tfm;
}
void FallbackImpl::processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img)
{
/* OCIO_TODO stride not respected, channels must be 3 or 4 */
OCIO_PackedImageDescription *desc = (OCIO_PackedImageDescription*)img;
int channels = desc->numChannels;
float *pixels = desc->data;
int width = desc->width;
int height = desc->height;
int x, y;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
float *pixel = pixels + channels * (y * width + x);
if (channels == 4)
processorApplyRGBA(processor, pixel);
else if (channels == 3)
processorApplyRGB(processor, pixel);
}
}
}
void FallbackImpl::processorApply_predivide(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img)
{
/* OCIO_TODO stride not respected, channels must be 3 or 4 */
OCIO_PackedImageDescription *desc = (OCIO_PackedImageDescription*)img;
int channels = desc->numChannels;
float *pixels = desc->data;
int width = desc->width;
int height = desc->height;
int x, y;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
float *pixel = pixels + channels * (y * width + x);
if (channels == 4)
processorApplyRGBA_predivide(processor, pixel);
else if (channels == 3)
processorApplyRGB(processor, pixel);
}
}
}
void FallbackImpl::processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel)
{
if (processor == PROCESSOR_LINEAR_TO_SRGB)
linearrgb_to_srgb_v3_v3(pixel, pixel);
else if (processor == PROCESSOR_SRGB_TO_LINEAR)
srgb_to_linearrgb_v3_v3(pixel, pixel);
}
void FallbackImpl::processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel)
{
if (processor == PROCESSOR_LINEAR_TO_SRGB)
linearrgb_to_srgb_v4(pixel, pixel);
else if (processor == PROCESSOR_SRGB_TO_LINEAR)
srgb_to_linearrgb_v4(pixel, pixel);
}
void FallbackImpl::processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel)
{
if (pixel[3] == 1.0f || pixel[3] == 0.0f) {
processorApplyRGBA(processor, pixel);
}
else {
float alpha, inv_alpha;
alpha = pixel[3];
inv_alpha = 1.0f / alpha;
pixel[0] *= inv_alpha;
pixel[1] *= inv_alpha;
pixel[2] *= inv_alpha;
processorApplyRGBA(processor, pixel);
pixel[0] *= alpha;
pixel[1] *= alpha;
pixel[2] *= alpha;
}
}
void FallbackImpl::processorRelease(OCIO_ConstProcessorRcPtr *)
{
}
const char *FallbackImpl::colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs)
{
if (cs == COLORSPACE_LINEAR)
return "Linear";
else if (cs == COLORSPACE_SRGB)
return "sRGB";
return NULL;
}
const char *FallbackImpl::colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *)
{
return "";
}
const char *FallbackImpl::colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *)
{
return "";
}
OCIO_DisplayTransformRcPtr *FallbackImpl::createDisplayTransform(void)
{
return (OCIO_DisplayTransformRcPtr*)PROCESSOR_LINEAR_TO_SRGB;
}
void FallbackImpl::displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *, const char *)
{
}
void FallbackImpl::displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *, const char *)
{
}
void FallbackImpl::displayTransformSetView(OCIO_DisplayTransformRcPtr *, const char *)
{
}
void FallbackImpl::displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *, OCIO_ConstTransformRcPtr *)
{
}
void FallbackImpl::displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *, OCIO_ConstTransformRcPtr *)
{
}
void FallbackImpl::displayTransformRelease(OCIO_DisplayTransformRcPtr *)
{
}
OCIO_PackedImageDesc *FallbackImpl::createOCIO_PackedImageDesc(float *data, long width, long height, long numChannels,
long chanStrideBytes, long xStrideBytes, long yStrideBytes)
{
OCIO_PackedImageDescription *desc = (OCIO_PackedImageDescription*)MEM_callocN(sizeof(OCIO_PackedImageDescription), "OCIO_PackedImageDescription");
desc->data = data;
desc->width = width;
desc->height = height;
desc->numChannels = numChannels;
desc->chanStrideBytes = chanStrideBytes;
desc->xStrideBytes = xStrideBytes;
desc->yStrideBytes = yStrideBytes;
return (OCIO_PackedImageDesc*)desc;
}
void FallbackImpl::OCIO_PackedImageDescRelease(OCIO_PackedImageDesc* id)
{
MEM_freeN(id);
}
OCIO_ExponentTransformRcPtr *FallbackImpl::createExponentTransform(void)
{
return (OCIO_ExponentTransformRcPtr*)PROCESSOR_UNKNOWN;
}
void FallbackImpl::exponentTransformSetValue(OCIO_ExponentTransformRcPtr *, const float *)
{
}
void FallbackImpl::exponentTransformRelease(OCIO_ExponentTransformRcPtr *)
{
}
OCIO_MatrixTransformRcPtr *FallbackImpl::createMatrixTransform(void)
{
return (OCIO_MatrixTransformRcPtr*)PROCESSOR_UNKNOWN;
}
void FallbackImpl::matrixTransformSetValue(OCIO_MatrixTransformRcPtr *, const float *, const float *)
{
}
void FallbackImpl::matrixTransformRelease(OCIO_MatrixTransformRcPtr *)
{
}
void FallbackImpl::matrixTransformScale(float * , float * , const float *)
{
}

View File

@@ -0,0 +1,284 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2012 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "MEM_guardedalloc.h"
#include "ocio_impl.h"
static IOCIOImpl *impl = NULL;
void OCIO_init(void)
{
#ifdef WITH_OCIO
impl = new OCIOImpl();
#else
impl = new FallbackImpl();
#endif
}
void OCIO_exit(void)
{
delete impl;
impl = NULL;
}
OCIO_ConstConfigRcPtr *OCIO_getCurrentConfig(void)
{
return impl->getCurrentConfig();
}
OCIO_ConstConfigRcPtr *OCIO_configCreateFallback(void)
{
delete impl;
impl = new FallbackImpl();
return impl->getCurrentConfig();
}
void OCIO_setCurrentConfig(const OCIO_ConstConfigRcPtr *config)
{
impl->setCurrentConfig(config);
}
OCIO_ConstConfigRcPtr *OCIO_configCreateFromEnv(void)
{
return impl->configCreateFromEnv();
}
OCIO_ConstConfigRcPtr *OCIO_configCreateFromFile(const char *filename)
{
return impl->configCreateFromFile(filename);
}
void OCIO_configRelease(OCIO_ConstConfigRcPtr *config)
{
impl->configRelease(config);
}
int OCIO_configGetNumColorSpaces(OCIO_ConstConfigRcPtr *config)
{
return impl->configGetNumColorSpaces(config);
}
const char *OCIO_configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr *config, int index)
{
return impl->configGetColorSpaceNameByIndex(config, index);
}
OCIO_ConstColorSpaceRcPtr *OCIO_configGetColorSpace(OCIO_ConstConfigRcPtr *config, const char *name)
{
return impl->configGetColorSpace(config, name);
}
int OCIO_configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name)
{
return impl->configGetIndexForColorSpace(config, name);
}
const char *OCIO_configGetDefaultDisplay(OCIO_ConstConfigRcPtr *config)
{
return impl->configGetDefaultDisplay(config);
}
int OCIO_configGetNumDisplays(OCIO_ConstConfigRcPtr* config)
{
return impl->configGetNumDisplays(config);
}
const char *OCIO_configGetDisplay(OCIO_ConstConfigRcPtr *config, int index)
{
return impl->configGetDisplay(config, index);
}
const char *OCIO_configGetDefaultView(OCIO_ConstConfigRcPtr *config, const char *display)
{
return impl->configGetDefaultView(config, display);
}
int OCIO_configGetNumViews(OCIO_ConstConfigRcPtr *config, const char *display)
{
return impl->configGetNumViews(config, display);
}
const char *OCIO_configGetView(OCIO_ConstConfigRcPtr *config, const char *display, int index)
{
return impl->configGetView(config, display, index);
}
const char *OCIO_configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config, const char *display, const char *view)
{
return impl->configGetDisplayColorSpaceName(config, display, view);
}
int OCIO_colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs)
{
return impl->colorSpaceIsInvertible(cs);
}
int OCIO_colorSpaceIsData(OCIO_ConstColorSpaceRcPtr *cs)
{
return impl->colorSpaceIsData(cs);
}
void OCIO_colorSpaceRelease(OCIO_ConstColorSpaceRcPtr *cs)
{
impl->colorSpaceRelease(cs);
}
OCIO_ConstProcessorRcPtr *OCIO_configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config, const char *srcName, const char *dstName)
{
return impl->configGetProcessorWithNames(config, srcName, dstName);
}
OCIO_ConstProcessorRcPtr *OCIO_configGetProcessor(OCIO_ConstConfigRcPtr *config, OCIO_ConstTransformRcPtr *transform)
{
return impl->configGetProcessor(config, transform);
}
void OCIO_processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img)
{
impl->processorApply(processor, img);
}
void OCIO_processorApply_predivide(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img)
{
impl->processorApply_predivide(processor, img);
}
void OCIO_processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel)
{
impl->processorApplyRGB(processor, pixel);
}
void OCIO_processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel)
{
impl->processorApplyRGBA(processor, pixel);
}
void OCIO_processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel)
{
impl->processorApplyRGBA_predivide(processor, pixel);
}
void OCIO_processorRelease(OCIO_ConstProcessorRcPtr *p)
{
impl->processorRelease(p);
}
const char *OCIO_colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs)
{
return impl->colorSpaceGetName(cs);
}
const char *OCIO_colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs)
{
return impl->colorSpaceGetDescription(cs);
}
const char *OCIO_colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs)
{
return impl->colorSpaceGetFamily(cs);
}
OCIO_DisplayTransformRcPtr *OCIO_createDisplayTransform(void)
{
return impl->createDisplayTransform();
}
void OCIO_displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *dt, const char *name)
{
impl->displayTransformSetInputColorSpaceName(dt, name);
}
void OCIO_displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *dt, const char *name)
{
impl->displayTransformSetDisplay(dt, name);
}
void OCIO_displayTransformSetView(OCIO_DisplayTransformRcPtr *dt, const char *name)
{
impl->displayTransformSetView(dt, name);
}
void OCIO_displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *t)
{
impl->displayTransformSetDisplayCC(dt, t);
}
void OCIO_displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *t)
{
impl->displayTransformSetLinearCC(dt, t);
}
void OCIO_displayTransformRelease(OCIO_DisplayTransformRcPtr *dt)
{
impl->displayTransformRelease(dt);
}
OCIO_PackedImageDesc *OCIO_createOCIO_PackedImageDesc(float *data, long width, long height, long numChannels,
long chanStrideBytes, long xStrideBytes, long yStrideBytes)
{
return impl->createOCIO_PackedImageDesc(data, width, height, numChannels, chanStrideBytes, xStrideBytes, yStrideBytes);
}
void OCIO_OCIO_PackedImageDescRelease(OCIO_PackedImageDesc* id)
{
impl->OCIO_PackedImageDescRelease(id);
}
OCIO_ExponentTransformRcPtr *OCIO_createExponentTransform(void)
{
return impl->createExponentTransform();
}
void OCIO_exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et, const float *exponent)
{
impl->exponentTransformSetValue(et, exponent);
}
void OCIO_exponentTransformRelease(OCIO_ExponentTransformRcPtr *et)
{
impl->exponentTransformRelease(et);
}
OCIO_MatrixTransformRcPtr *OCIO_createMatrixTransform(void)
{
return impl->createMatrixTransform();
}
void OCIO_matrixTransformSetValue(OCIO_MatrixTransformRcPtr *mt, const float *m44, const float *offset4)
{
impl->matrixTransformSetValue(mt, m44, offset4);
}
void OCIO_matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt)
{
impl->matrixTransformRelease(mt);
}
void OCIO_matrixTransformScale(float * m44, float * offset4, const float *scale4f)
{
impl->matrixTransformScale(m44, offset4, scale4f);
}

View File

@@ -1,546 +0,0 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2012 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Xavier Thomas
* Lukas Toene,
* Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
#include <iostream>
#include <string.h>
#include <OpenColorIO/OpenColorIO.h>
#include "MEM_guardedalloc.h"
#define OCIO_CAPI_IMPLEMENTATION
#include "ocio_capi.h"
#if !defined(WITH_ASSERT_ABORT)
# define OCIO_abort()
#else
# include <stdlib.h>
# define OCIO_abort() abort()
#endif
#if defined(_MSC_VER)
# define __func__ __FUNCTION__
#endif
#define MEM_NEW(type) new(MEM_mallocN(sizeof(type), __func__)) type()
#define MEM_DELETE(what, type) if(what) { what->~type(); MEM_freeN(what); } (void)0
static void OCIO_reportError(const char *err)
{
std::cerr << "OpenColorIO Error: " << err << std::endl;
OCIO_abort();
}
static void OCIO_reportException(Exception &exception)
{
OCIO_reportError(exception.what());
}
ConstConfigRcPtr *OCIO_getCurrentConfig(void)
{
ConstConfigRcPtr *config = MEM_NEW(ConstConfigRcPtr);
try {
*config = GetCurrentConfig();
if(*config)
return config;
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
MEM_DELETE(config, ConstConfigRcPtr);
return NULL;
}
ConstConfigRcPtr *OCIO_getDefaultConfig(void)
{
return NULL;
}
void OCIO_setCurrentConfig(const ConstConfigRcPtr *config)
{
try {
SetCurrentConfig(*config);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
}
ConstConfigRcPtr *OCIO_configCreateFromEnv(void)
{
ConstConfigRcPtr *config = MEM_NEW(ConstConfigRcPtr);
try {
*config = Config::CreateFromEnv();
if (*config)
return config;
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
MEM_DELETE(config, ConstConfigRcPtr);
return NULL;
}
ConstConfigRcPtr *OCIO_configCreateFromFile(const char *filename)
{
ConstConfigRcPtr *config = MEM_NEW(ConstConfigRcPtr);
try {
*config = Config::CreateFromFile(filename);
if (*config)
return config;
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
MEM_DELETE(config, ConstConfigRcPtr);
return NULL;
}
void OCIO_configRelease(ConstConfigRcPtr *config)
{
MEM_DELETE(config, ConstConfigRcPtr);
}
int OCIO_configGetNumColorSpaces(ConstConfigRcPtr *config)
{
try {
return (*config)->getNumColorSpaces();
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return 0;
}
const char *OCIO_configGetColorSpaceNameByIndex(ConstConfigRcPtr *config, int index)
{
try {
return (*config)->getColorSpaceNameByIndex(index);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
ConstColorSpaceRcPtr *OCIO_configGetColorSpace(ConstConfigRcPtr *config, const char *name)
{
ConstColorSpaceRcPtr *cs = MEM_NEW(ConstColorSpaceRcPtr);
try {
*cs = (*config)->getColorSpace(name);
if (*cs)
return cs;
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
MEM_DELETE(cs, ConstColorSpaceRcPtr);
return NULL;
}
int OCIO_configGetIndexForColorSpace(ConstConfigRcPtr *config, const char *name)
{
try {
return (*config)->getIndexForColorSpace(name);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return -1;
}
const char *OCIO_configGetDefaultDisplay(ConstConfigRcPtr *config)
{
try {
return (*config)->getDefaultDisplay();
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
int OCIO_configGetNumDisplays(ConstConfigRcPtr* config)
{
try {
return (*config)->getNumDisplays();
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return 0;
}
const char *OCIO_configGetDisplay(ConstConfigRcPtr *config, int index)
{
try {
return (*config)->getDisplay(index);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
const char *OCIO_configGetDefaultView(ConstConfigRcPtr *config, const char *display)
{
try {
return (*config)->getDefaultView(display);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
int OCIO_configGetNumViews(ConstConfigRcPtr *config, const char *display)
{
try {
return (*config)->getNumViews(display);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return 0;
}
const char *OCIO_configGetView(ConstConfigRcPtr *config, const char *display, int index)
{
try {
return (*config)->getView(display, index);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
const char *OCIO_configGetDisplayColorSpaceName(ConstConfigRcPtr *config, const char *display, const char *view)
{
try {
return (*config)->getDisplayColorSpaceName(display, view);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
int OCIO_colorSpaceIsInvertible(ConstColorSpaceRcPtr *cs)
{
const char *family = (*cs)->getFamily();
if (!strcmp(family, "rrt") || !strcmp(family, "display")) {
/* assume display and rrt transformations are not invertible
* in fact some of them could be, but it doesn't make much sense to allow use them as invertible
*/
return false;
}
if ((*cs)->isData()) {
/* data color spaces don't have transformation at all */
return true;
}
if ((*cs)->getTransform(COLORSPACE_DIR_TO_REFERENCE)) {
/* if there's defined transform to reference space, color space could be converted to scene linear */
return true;
}
return true;
}
int OCIO_colorSpaceIsData(ConstColorSpaceRcPtr *cs)
{
return ((*cs)->isData());
}
void OCIO_colorSpaceRelease(ConstColorSpaceRcPtr *cs)
{
MEM_DELETE(cs, ConstColorSpaceRcPtr);
}
ConstProcessorRcPtr *OCIO_configGetProcessorWithNames(ConstConfigRcPtr *config, const char *srcName, const char *dstName)
{
ConstProcessorRcPtr *p = MEM_NEW(ConstProcessorRcPtr);
try {
*p = (*config)->getProcessor(srcName, dstName);
if (*p)
return p;
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
MEM_DELETE(p, ConstProcessorRcPtr);
return 0;
}
ConstProcessorRcPtr *OCIO_configGetProcessor(ConstConfigRcPtr *config, ConstTransformRcPtr *transform)
{
ConstProcessorRcPtr *p = MEM_NEW(ConstProcessorRcPtr);
try {
*p = (*config)->getProcessor(*transform);
if (*p)
return p;
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
MEM_DELETE(p, ConstProcessorRcPtr);
return NULL;
}
void OCIO_processorApply(ConstProcessorRcPtr *processor, PackedImageDesc *img)
{
try {
(*processor)->apply(*img);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
}
void OCIO_processorApply_predivide(ConstProcessorRcPtr *processor, PackedImageDesc *img)
{
try {
int channels = img->getNumChannels();
if (channels == 4) {
float *pixels = img->getData();
int width = img->getWidth();
int height = img->getHeight();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
float *pixel = pixels + 4 * (y * width + x);
OCIO_processorApplyRGBA_predivide(processor, pixel);
}
}
}
else {
(*processor)->apply(*img);
}
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
}
void OCIO_processorApplyRGB(ConstProcessorRcPtr *processor, float *pixel)
{
(*processor)->applyRGB(pixel);
}
void OCIO_processorApplyRGBA(ConstProcessorRcPtr *processor, float *pixel)
{
(*processor)->applyRGBA(pixel);
}
void OCIO_processorApplyRGBA_predivide(ConstProcessorRcPtr *processor, float *pixel)
{
if (pixel[3] == 1.0f || pixel[3] == 0.0f) {
(*processor)->applyRGBA(pixel);
}
else {
float alpha, inv_alpha;
alpha = pixel[3];
inv_alpha = 1.0f / alpha;
pixel[0] *= inv_alpha;
pixel[1] *= inv_alpha;
pixel[2] *= inv_alpha;
(*processor)->applyRGBA(pixel);
pixel[0] *= alpha;
pixel[1] *= alpha;
pixel[2] *= alpha;
}
}
void OCIO_processorRelease(ConstProcessorRcPtr *p)
{
p->~ConstProcessorRcPtr();
MEM_freeN(p);
}
const char *OCIO_colorSpaceGetName(ConstColorSpaceRcPtr *cs)
{
return (*cs)->getName();
}
const char *OCIO_colorSpaceGetDescription(ConstColorSpaceRcPtr *cs)
{
return (*cs)->getDescription();
}
const char *OCIO_colorSpaceGetFamily(ConstColorSpaceRcPtr *cs)
{
return (*cs)->getFamily();
}
DisplayTransformRcPtr *OCIO_createDisplayTransform(void)
{
DisplayTransformRcPtr *dt = MEM_NEW(DisplayTransformRcPtr);
*dt = DisplayTransform::Create();
return dt;
}
void OCIO_displayTransformSetInputColorSpaceName(DisplayTransformRcPtr *dt, const char *name)
{
(*dt)->setInputColorSpaceName(name);
}
void OCIO_displayTransformSetDisplay(DisplayTransformRcPtr *dt, const char *name)
{
(*dt)->setDisplay(name);
}
void OCIO_displayTransformSetView(DisplayTransformRcPtr *dt, const char *name)
{
(*dt)->setView(name);
}
void OCIO_displayTransformSetDisplayCC(DisplayTransformRcPtr *dt, ConstTransformRcPtr *t)
{
(*dt)->setDisplayCC(*t);
}
void OCIO_displayTransformSetLinearCC(DisplayTransformRcPtr *dt, ConstTransformRcPtr *t)
{
(*dt)->setLinearCC(*t);
}
void OCIO_displayTransformRelease(DisplayTransformRcPtr *dt)
{
MEM_DELETE(dt, DisplayTransformRcPtr);
}
PackedImageDesc *OCIO_createPackedImageDesc(float *data, long width, long height, long numChannels,
long chanStrideBytes, long xStrideBytes, long yStrideBytes)
{
try {
void *mem = MEM_mallocN(sizeof(PackedImageDesc), __func__);
PackedImageDesc *id = new(mem) PackedImageDesc(data, width, height, numChannels, chanStrideBytes, xStrideBytes, yStrideBytes);
return id;
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
void OCIO_packedImageDescRelease(PackedImageDesc* id)
{
MEM_DELETE(id, PackedImageDesc);
}
ExponentTransformRcPtr *OCIO_createExponentTransform(void)
{
ExponentTransformRcPtr *et = MEM_NEW(ExponentTransformRcPtr);
*et = ExponentTransform::Create();
return et;
}
void OCIO_exponentTransformSetValue(ExponentTransformRcPtr *et, const float *exponent)
{
(*et)->setValue(exponent);
}
void OCIO_exponentTransformRelease(ExponentTransformRcPtr *et)
{
MEM_DELETE(et, ExponentTransformRcPtr);
}
MatrixTransformRcPtr *OCIO_createMatrixTransform(void)
{
MatrixTransformRcPtr *mt = MEM_NEW(MatrixTransformRcPtr);
*mt = MatrixTransform::Create();
return mt;
}
void OCIO_matrixTransformSetValue(MatrixTransformRcPtr *mt, const float *m44, const float *offset4)
{
(*mt)->setValue(m44, offset4);
}
void OCIO_matrixTransformRelease(MatrixTransformRcPtr *mt)
{
MEM_DELETE(mt, MatrixTransformRcPtr);
}
void OCIO_matrixTransformScale(float * m44, float * offset4, const float *scale4f)
{
MatrixTransform::Scale(m44, offset4, scale4f);
}

View File

@@ -28,98 +28,94 @@
#ifndef __OCIO_CAPI_H__
#define __OCIO_CAPI_H__
#ifdef __cplusplus
using namespace OCIO_NAMESPACE;
extern "C" {
#endif
#define OCIO_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
#define OCIO_ROLE_SCENE_LINEAR "scene_linear"
#define OCIO_ROLE_COLOR_PICKING "color_picking"
#define OCIO_ROLE_TEXTURE_PAINT "texture_paint"
#define OCIO_ROLE_DEFAULT_BYTE "default_byte"
#define OCIO_ROLE_DEFAULT_FLOAT "default_float"
#define OCIO_ROLE_DEFAULT_SEQUENCER "default_sequencer"
#ifndef OCIO_CAPI_IMPLEMENTATION
#define OCIO_ROLE_SCENE_LINEAR "scene_linear"
#define OCIO_ROLE_COLOR_PICKING "color_picking"
#define OCIO_ROLE_TEXTURE_PAINT "texture_paint"
#define OCIO_ROLE_DEFAULT_BYTE "default_byte"
#define OCIO_ROLE_DEFAULT_FLOAT "default_float"
#define OCIO_ROLE_DEFAULT_SEQUENCER "default_sequencer"
OCIO_DECLARE_HANDLE(OCIO_ConstConfigRcPtr);
OCIO_DECLARE_HANDLE(OCIO_ConstColorSpaceRcPtr);
OCIO_DECLARE_HANDLE(OCIO_ConstProcessorRcPtr);
OCIO_DECLARE_HANDLE(OCIO_ConstContextRcPtr);
OCIO_DECLARE_HANDLE(OCIO_PackedImageDesc);
OCIO_DECLARE_HANDLE(OCIO_DisplayTransformRcPtr);
OCIO_DECLARE_HANDLE(OCIO_ConstTransformRcPtr);
OCIO_DECLARE_HANDLE(OCIO_ExponentTransformRcPtr);
OCIO_DECLARE_HANDLE(OCIO_MatrixTransformRcPtr);
OCIO_DECLARE_HANDLE(ConstConfigRcPtr);
OCIO_DECLARE_HANDLE(ConstColorSpaceRcPtr);
OCIO_DECLARE_HANDLE(ConstProcessorRcPtr);
OCIO_DECLARE_HANDLE(ConstContextRcPtr);
OCIO_DECLARE_HANDLE(PackedImageDesc);
OCIO_DECLARE_HANDLE(DisplayTransformRcPtr);
OCIO_DECLARE_HANDLE(ConstTransformRcPtr);
OCIO_DECLARE_HANDLE(ExponentTransformRcPtr);
OCIO_DECLARE_HANDLE(MatrixTransformRcPtr);
#endif
void OCIO_init(void);
void OCIO_exit(void);
OCIO_ConstConfigRcPtr *OCIO_getCurrentConfig(void);
void OCIO_setCurrentConfig(const OCIO_ConstConfigRcPtr *config);
ConstConfigRcPtr *OCIO_getCurrentConfig(void);
ConstConfigRcPtr *OCIO_getDefaultConfig(void);
void OCIO_setCurrentConfig(const ConstConfigRcPtr *config);
OCIO_ConstConfigRcPtr *OCIO_configCreateFromEnv(void);
OCIO_ConstConfigRcPtr *OCIO_configCreateFromFile(const char* filename);
OCIO_ConstConfigRcPtr *OCIO_configCreateFallback(void);
ConstConfigRcPtr *OCIO_configCreateFromEnv(void);
ConstConfigRcPtr *OCIO_configCreateFromFile(const char* filename);
void OCIO_configRelease(OCIO_ConstConfigRcPtr *config);
void OCIO_configRelease(ConstConfigRcPtr *config);
int OCIO_configGetNumColorSpaces(OCIO_ConstConfigRcPtr *config);
const char *OCIO_configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr *config, int index);
OCIO_ConstColorSpaceRcPtr *OCIO_configGetColorSpace(OCIO_ConstConfigRcPtr *config, const char *name);
int OCIO_configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name);
int OCIO_configGetNumColorSpaces(ConstConfigRcPtr *config);
const char *OCIO_configGetColorSpaceNameByIndex(ConstConfigRcPtr *config, int index);
ConstColorSpaceRcPtr *OCIO_configGetColorSpace(ConstConfigRcPtr *config, const char *name);
int OCIO_configGetIndexForColorSpace(ConstConfigRcPtr *config, const char *name);
int OCIO_colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs);
int OCIO_colorSpaceIsData(OCIO_ConstColorSpaceRcPtr *cs);
int OCIO_colorSpaceIsInvertible(ConstColorSpaceRcPtr *cs);
int OCIO_colorSpaceIsData(ConstColorSpaceRcPtr *cs);
void OCIO_colorSpaceRelease(OCIO_ConstColorSpaceRcPtr *cs);
void OCIO_colorSpaceRelease(ConstColorSpaceRcPtr *cs);
const char *OCIO_configGetDefaultDisplay(OCIO_ConstConfigRcPtr *config);
int OCIO_configGetNumDisplays(OCIO_ConstConfigRcPtr *config);
const char *OCIO_configGetDisplay(OCIO_ConstConfigRcPtr *config, int index);
const char *OCIO_configGetDefaultView(OCIO_ConstConfigRcPtr *config, const char *display);
int OCIO_configGetNumViews(OCIO_ConstConfigRcPtr *config, const char *display);
const char *OCIO_configGetView(OCIO_ConstConfigRcPtr *config, const char *display, int index);
const char *OCIO_configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config, const char *display, const char *view);
const char *OCIO_configGetDefaultDisplay(ConstConfigRcPtr *config);
int OCIO_configGetNumDisplays(ConstConfigRcPtr *config);
const char *OCIO_configGetDisplay(ConstConfigRcPtr *config, int index);
const char *OCIO_configGetDefaultView(ConstConfigRcPtr *config, const char *display);
int OCIO_configGetNumViews(ConstConfigRcPtr *config, const char *display);
const char *OCIO_configGetView(ConstConfigRcPtr *config, const char *display, int index);
const char *OCIO_configGetDisplayColorSpaceName(ConstConfigRcPtr *config, const char *display, const char *view);
OCIO_ConstProcessorRcPtr *OCIO_configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config, const char *srcName, const char *dstName);
OCIO_ConstProcessorRcPtr *OCIO_configGetProcessor(OCIO_ConstConfigRcPtr *config, OCIO_ConstTransformRcPtr *transform);
ConstProcessorRcPtr *OCIO_configGetProcessorWithNames(ConstConfigRcPtr *config, const char *srcName, const char *dstName);
ConstProcessorRcPtr *OCIO_configGetProcessor(ConstConfigRcPtr *config, ConstTransformRcPtr *transform);
void OCIO_processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img);
void OCIO_processorApply_predivide(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img);
void OCIO_processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel);
void OCIO_processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel);
void OCIO_processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel);
void OCIO_processorApply(ConstProcessorRcPtr *processor, PackedImageDesc *img);
void OCIO_processorApply_predivide(ConstProcessorRcPtr *processor, PackedImageDesc *img);
void OCIO_processorApplyRGB(ConstProcessorRcPtr *processor, float *pixel);
void OCIO_processorApplyRGBA(ConstProcessorRcPtr *processor, float *pixel);
void OCIO_processorApplyRGBA_predivide(ConstProcessorRcPtr *processor, float *pixel);
void OCIO_processorRelease(OCIO_ConstProcessorRcPtr *p);
void OCIO_processorRelease(ConstProcessorRcPtr *p);
const char *OCIO_colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs);
const char *OCIO_colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs);
const char *OCIO_colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs);
const char *OCIO_colorSpaceGetName(ConstColorSpaceRcPtr *cs);
const char *OCIO_colorSpaceGetDescription(ConstColorSpaceRcPtr *cs);
const char *OCIO_colorSpaceGetFamily(ConstColorSpaceRcPtr *cs);
OCIO_DisplayTransformRcPtr *OCIO_createDisplayTransform(void);
void OCIO_displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *dt, const char *name);
void OCIO_displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *dt, const char *name);
void OCIO_displayTransformSetView(OCIO_DisplayTransformRcPtr *dt, const char *name);
void OCIO_displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et);
void OCIO_displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et);
void OCIO_displayTransformRelease(OCIO_DisplayTransformRcPtr *dt);
DisplayTransformRcPtr *OCIO_createDisplayTransform(void);
void OCIO_displayTransformSetInputColorSpaceName(DisplayTransformRcPtr *dt, const char *name);
void OCIO_displayTransformSetDisplay(DisplayTransformRcPtr *dt, const char *name);
void OCIO_displayTransformSetView(DisplayTransformRcPtr *dt, const char *name);
void OCIO_displayTransformSetDisplayCC(DisplayTransformRcPtr *dt, ConstTransformRcPtr *et);
void OCIO_displayTransformSetLinearCC(DisplayTransformRcPtr *dt, ConstTransformRcPtr *et);
void OCIO_displayTransformRelease(DisplayTransformRcPtr *dt);
PackedImageDesc *OCIO_createPackedImageDesc(float *data, long width, long height, long numChannels,
OCIO_PackedImageDesc *OCIO_createOCIO_PackedImageDesc(float *data, long width, long height, long numChannels,
long chanStrideBytes, long xStrideBytes, long yStrideBytes);
void OCIO_packedImageDescRelease(PackedImageDesc *p);
void OCIO_OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *p);
ExponentTransformRcPtr *OCIO_createExponentTransform(void);
void OCIO_exponentTransformSetValue(ExponentTransformRcPtr *et, const float *exponent);
void OCIO_exponentTransformRelease(ExponentTransformRcPtr *et);
OCIO_ExponentTransformRcPtr *OCIO_createExponentTransform(void);
void OCIO_exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et, const float *exponent);
void OCIO_exponentTransformRelease(OCIO_ExponentTransformRcPtr *et);
MatrixTransformRcPtr *OCIO_createMatrixTransform(void);
void OCIO_matrixTransformSetValue(MatrixTransformRcPtr *et, const float *m44, const float *offset4);
void OCIO_matrixTransformRelease(MatrixTransformRcPtr *mt);
OCIO_MatrixTransformRcPtr *OCIO_createMatrixTransform(void);
void OCIO_matrixTransformSetValue(OCIO_MatrixTransformRcPtr *et, const float *m44, const float *offset4);
void OCIO_matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt);
void OCIO_matrixTransformScale(float * m44, float * offset4, const float * scale4);
@@ -127,4 +123,4 @@ void OCIO_matrixTransformScale(float * m44, float * offset4, const float * scale
}
#endif
#endif //OCIO_CAPI_H
#endif /* OCIO_CAPI_H */

View File

@@ -1,390 +0,0 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2012 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Brecht van Lommel
*
* ***** END GPL LICENSE BLOCK *****
*/
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_math_color.h"
namespace OCIO_NAMESPACE {};
#include "ocio_capi.h"
#define CONFIG_DEFAULT ((ConstConfigRcPtr*)1)
#define PROCESSOR_LINEAR_TO_SRGB ((ConstProcessorRcPtr*)1)
#define PROCESSOR_SRGB_TO_LINEAR ((ConstProcessorRcPtr*)2)
#define PROCESSOR_UNKNOWN ((ConstProcessorRcPtr*)3)
#define COLORSPACE_LINEAR ((ConstColorSpaceRcPtr*)1)
#define COLORSPACE_SRGB ((ConstColorSpaceRcPtr*)2)
typedef struct PackedImageDescription {
float *data;
long width;
long height;
long numChannels;
long chanStrideBytes;
long xStrideBytes;
long yStrideBytes;
} PackedImageDescription;
ConstConfigRcPtr *OCIO_getCurrentConfig(void)
{
return CONFIG_DEFAULT;
}
ConstConfigRcPtr *OCIO_getDefaultConfig(void)
{
return CONFIG_DEFAULT;
}
void OCIO_setCurrentConfig(const ConstConfigRcPtr *)
{
}
ConstConfigRcPtr *OCIO_configCreateFromEnv(void)
{
return CONFIG_DEFAULT;
}
ConstConfigRcPtr *OCIO_configCreateFromFile(const char *)
{
return CONFIG_DEFAULT;
}
void OCIO_configRelease(ConstConfigRcPtr *)
{
}
int OCIO_configGetNumColorSpaces(ConstConfigRcPtr *)
{
return 2;
}
const char *OCIO_configGetColorSpaceNameByIndex(ConstConfigRcPtr *, int index)
{
if (index == 0)
return "Linear";
else if (index == 1)
return "sRGB";
return NULL;
}
ConstColorSpaceRcPtr *OCIO_configGetColorSpace(ConstConfigRcPtr *, const char *name)
{
if (strcmp(name, "scene_linear") == 0)
return COLORSPACE_LINEAR;
else if (strcmp(name, "color_picking") == 0)
return COLORSPACE_SRGB;
else if (strcmp(name, "texture_paint") == 0)
return COLORSPACE_LINEAR;
else if (strcmp(name, "default_byte") == 0)
return COLORSPACE_SRGB;
else if (strcmp(name, "default_float") == 0)
return COLORSPACE_LINEAR;
else if (strcmp(name, "default_sequencer") == 0)
return COLORSPACE_SRGB;
else if (strcmp(name, "Linear") == 0)
return COLORSPACE_LINEAR;
else if (strcmp(name, "sRGB") == 0)
return COLORSPACE_SRGB;
return NULL;
}
int OCIO_configGetIndexForColorSpace(ConstConfigRcPtr *config, const char *name)
{
ConstColorSpaceRcPtr *cs = OCIO_configGetColorSpace(config, name);
if (cs == COLORSPACE_LINEAR)
return 0;
else if (cs == COLORSPACE_SRGB)
return 1;
return -1;
}
const char *OCIO_configGetDefaultDisplay(ConstConfigRcPtr *)
{
return "sRGB";
}
int OCIO_configGetNumDisplays(ConstConfigRcPtr* config)
{
return 1;
}
const char *OCIO_configGetDisplay(ConstConfigRcPtr *, int index)
{
if (index == 0)
return "sRGB";
return NULL;
}
const char *OCIO_configGetDefaultView(ConstConfigRcPtr *, const char *)
{
return "Default";
}
int OCIO_configGetNumViews(ConstConfigRcPtr *, const char *)
{
return 1;
}
const char *OCIO_configGetView(ConstConfigRcPtr *, const char *, int index)
{
if (index == 0)
return "Default";
return NULL;
}
const char *OCIO_configGetDisplayColorSpaceName(ConstConfigRcPtr *, const char *, const char *)
{
return "sRGB";
}
int OCIO_colorSpaceIsInvertible(ConstColorSpaceRcPtr *cs)
{
return 1;
}
int OCIO_colorSpaceIsData(ConstColorSpaceRcPtr *cs)
{
return 0;
}
void OCIO_colorSpaceRelease(ConstColorSpaceRcPtr *cs)
{
}
ConstProcessorRcPtr *OCIO_configGetProcessorWithNames(ConstConfigRcPtr *config, const char *srcName, const char *dstName)
{
ConstColorSpaceRcPtr *cs_src = OCIO_configGetColorSpace(config, srcName);
ConstColorSpaceRcPtr *cs_dst = OCIO_configGetColorSpace(config, dstName);
if (cs_src == COLORSPACE_LINEAR && cs_dst == COLORSPACE_SRGB)
return PROCESSOR_LINEAR_TO_SRGB;
else if (cs_src == COLORSPACE_SRGB && cs_dst == COLORSPACE_LINEAR)
return PROCESSOR_SRGB_TO_LINEAR;
return 0;
}
ConstProcessorRcPtr *OCIO_configGetProcessor(ConstConfigRcPtr *, ConstTransformRcPtr *tfm)
{
return (ConstProcessorRcPtr*)tfm;
}
void OCIO_processorApply(ConstProcessorRcPtr *processor, PackedImageDesc *img)
{
/* OCIO_TODO stride not respected, channels must be 3 or 4 */
PackedImageDescription *desc = (PackedImageDescription*)img;
int channels = desc->numChannels;
float *pixels = desc->data;
int width = desc->width;
int height = desc->height;
int x, y;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
float *pixel = pixels + channels * (y * width + x);
if (channels == 4)
OCIO_processorApplyRGBA(processor, pixel);
else if (channels == 3)
OCIO_processorApplyRGB(processor, pixel);
}
}
}
void OCIO_processorApply_predivide(ConstProcessorRcPtr *processor, PackedImageDesc *img)
{
/* OCIO_TODO stride not respected, channels must be 3 or 4 */
PackedImageDescription *desc = (PackedImageDescription*)img;
int channels = desc->numChannels;
float *pixels = desc->data;
int width = desc->width;
int height = desc->height;
int x, y;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
float *pixel = pixels + channels * (y * width + x);
if (channels == 4)
OCIO_processorApplyRGBA_predivide(processor, pixel);
else if (channels == 3)
OCIO_processorApplyRGB(processor, pixel);
}
}
}
void OCIO_processorApplyRGB(ConstProcessorRcPtr *processor, float *pixel)
{
if (processor == PROCESSOR_LINEAR_TO_SRGB)
linearrgb_to_srgb_v3_v3(pixel, pixel);
else if (processor == PROCESSOR_SRGB_TO_LINEAR)
srgb_to_linearrgb_v3_v3(pixel, pixel);
}
void OCIO_processorApplyRGBA(ConstProcessorRcPtr *processor, float *pixel)
{
if (processor == PROCESSOR_LINEAR_TO_SRGB)
linearrgb_to_srgb_v4(pixel, pixel);
else if (processor == PROCESSOR_SRGB_TO_LINEAR)
srgb_to_linearrgb_v4(pixel, pixel);
}
void OCIO_processorApplyRGBA_predivide(ConstProcessorRcPtr *processor, float *pixel)
{
if (pixel[3] == 1.0f || pixel[3] == 0.0f) {
OCIO_processorApplyRGBA(processor, pixel);
}
else {
float alpha, inv_alpha;
alpha = pixel[3];
inv_alpha = 1.0f / alpha;
pixel[0] *= inv_alpha;
pixel[1] *= inv_alpha;
pixel[2] *= inv_alpha;
OCIO_processorApplyRGBA(processor, pixel);
pixel[0] *= alpha;
pixel[1] *= alpha;
pixel[2] *= alpha;
}
}
void OCIO_processorRelease(ConstProcessorRcPtr *)
{
}
const char *OCIO_colorSpaceGetName(ConstColorSpaceRcPtr *cs)
{
if (cs == COLORSPACE_LINEAR)
return "Linear";
else if (cs == COLORSPACE_SRGB)
return "sRGB";
return NULL;
}
const char *OCIO_colorSpaceGetDescription(ConstColorSpaceRcPtr *)
{
return "";
}
const char *OCIO_colorSpaceGetFamily(ConstColorSpaceRcPtr *)
{
return "";
}
DisplayTransformRcPtr *OCIO_createDisplayTransform(void)
{
return (DisplayTransformRcPtr*)PROCESSOR_LINEAR_TO_SRGB;
}
void OCIO_displayTransformSetInputColorSpaceName(DisplayTransformRcPtr *, const char *)
{
}
void OCIO_displayTransformSetDisplay(DisplayTransformRcPtr *, const char *)
{
}
void OCIO_displayTransformSetView(DisplayTransformRcPtr *, const char *)
{
}
void OCIO_displayTransformSetDisplayCC(DisplayTransformRcPtr *, ConstTransformRcPtr *)
{
}
void OCIO_displayTransformSetLinearCC(DisplayTransformRcPtr *, ConstTransformRcPtr *)
{
}
void OCIO_displayTransformRelease(DisplayTransformRcPtr *)
{
}
PackedImageDesc *OCIO_createPackedImageDesc(float *data, long width, long height, long numChannels,
long chanStrideBytes, long xStrideBytes, long yStrideBytes)
{
PackedImageDescription *desc = (PackedImageDescription*)MEM_callocN(sizeof(PackedImageDescription), "PackedImageDescription");
desc->data = data;
desc->width = width;
desc->height = height;
desc->numChannels = numChannels;
desc->chanStrideBytes = chanStrideBytes;
desc->xStrideBytes = xStrideBytes;
desc->yStrideBytes = yStrideBytes;
return (PackedImageDesc*)desc;
}
void OCIO_packedImageDescRelease(PackedImageDesc* id)
{
MEM_freeN(id);
}
ExponentTransformRcPtr *OCIO_createExponentTransform(void)
{
return (ExponentTransformRcPtr*)PROCESSOR_UNKNOWN;
}
void OCIO_exponentTransformSetValue(ExponentTransformRcPtr *, const float *)
{
}
void OCIO_exponentTransformRelease(ExponentTransformRcPtr *)
{
}
MatrixTransformRcPtr *OCIO_createMatrixTransform(void)
{
return (MatrixTransformRcPtr*)PROCESSOR_UNKNOWN;
}
void OCIO_matrixTransformSetValue(MatrixTransformRcPtr *, const float *, const float *)
{
}
void OCIO_matrixTransformRelease(MatrixTransformRcPtr *)
{
}
void OCIO_matrixTransformScale(float * , float * , const float *)
{
}

View File

@@ -0,0 +1,544 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2012 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Xavier Thomas
* Lukas Toene,
* Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
#include <iostream>
#include <string.h>
#include <OpenColorIO/OpenColorIO.h>
using namespace OCIO_NAMESPACE;
#include "MEM_guardedalloc.h"
#include "ocio_impl.h"
#if !defined(WITH_ASSERT_ABORT)
# define OCIO_abort()
#else
# include <stdlib.h>
# define OCIO_abort() abort()
#endif
#if defined(_MSC_VER)
# define __func__ __FUNCTION__
#endif
#define MEM_NEW(type) new(MEM_mallocN(sizeof(type), __func__)) type()
#define MEM_DELETE(what, type) if(what) { (what)->~type(); MEM_freeN(what); } (void)0
static void OCIO_reportError(const char *err)
{
std::cerr << "OpenColorIO Error: " << err << std::endl;
OCIO_abort();
}
static void OCIO_reportException(Exception &exception)
{
OCIO_reportError(exception.what());
}
OCIO_ConstConfigRcPtr *OCIOImpl::getCurrentConfig(void)
{
ConstConfigRcPtr *config = MEM_NEW(ConstConfigRcPtr);
try {
*config = GetCurrentConfig();
if (*config)
return (OCIO_ConstConfigRcPtr *) config;
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
MEM_DELETE(config, ConstConfigRcPtr);
return NULL;
}
void OCIOImpl::setCurrentConfig(const OCIO_ConstConfigRcPtr *config)
{
try {
SetCurrentConfig(*(ConstConfigRcPtr *) config);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
}
OCIO_ConstConfigRcPtr *OCIOImpl::configCreateFromEnv(void)
{
ConstConfigRcPtr *config = MEM_NEW(ConstConfigRcPtr);
try {
*config = Config::CreateFromEnv();
if (*config)
return (OCIO_ConstConfigRcPtr *) config;
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
MEM_DELETE(config, ConstConfigRcPtr);
return NULL;
}
OCIO_ConstConfigRcPtr *OCIOImpl::configCreateFromFile(const char *filename)
{
ConstConfigRcPtr *config = MEM_NEW(ConstConfigRcPtr);
try {
*config = Config::CreateFromFile(filename);
if (*config)
return (OCIO_ConstConfigRcPtr *) config;
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
MEM_DELETE(config, ConstConfigRcPtr);
return NULL;
}
void OCIOImpl::configRelease(OCIO_ConstConfigRcPtr *config)
{
MEM_DELETE((ConstConfigRcPtr *) config, ConstConfigRcPtr);
}
int OCIOImpl::configGetNumColorSpaces(OCIO_ConstConfigRcPtr *config)
{
try {
return (*(ConstConfigRcPtr *) config)->getNumColorSpaces();
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return 0;
}
const char *OCIOImpl::configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr *config, int index)
{
try {
return (*(ConstConfigRcPtr *) config)->getColorSpaceNameByIndex(index);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
OCIO_ConstColorSpaceRcPtr *OCIOImpl::configGetColorSpace(OCIO_ConstConfigRcPtr *config, const char *name)
{
ConstColorSpaceRcPtr *cs = MEM_NEW(ConstColorSpaceRcPtr);
try {
*cs = (*(ConstConfigRcPtr *) config)->getColorSpace(name);
if (*cs)
return (OCIO_ConstColorSpaceRcPtr *) cs;
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
MEM_DELETE(cs, ConstColorSpaceRcPtr);
return NULL;
}
int OCIOImpl::configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name)
{
try {
return (*(ConstConfigRcPtr *) config)->getIndexForColorSpace(name);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return -1;
}
const char *OCIOImpl::configGetDefaultDisplay(OCIO_ConstConfigRcPtr *config)
{
try {
return (*(ConstConfigRcPtr *) config)->getDefaultDisplay();
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
int OCIOImpl::configGetNumDisplays(OCIO_ConstConfigRcPtr* config)
{
try {
return (*(ConstConfigRcPtr *) config)->getNumDisplays();
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return 0;
}
const char *OCIOImpl::configGetDisplay(OCIO_ConstConfigRcPtr *config, int index)
{
try {
return (*(ConstConfigRcPtr *) config)->getDisplay(index);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
const char *OCIOImpl::configGetDefaultView(OCIO_ConstConfigRcPtr *config, const char *display)
{
try {
return (*(ConstConfigRcPtr *) config)->getDefaultView(display);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
int OCIOImpl::configGetNumViews(OCIO_ConstConfigRcPtr *config, const char *display)
{
try {
return (*(ConstConfigRcPtr *) config)->getNumViews(display);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return 0;
}
const char *OCIOImpl::configGetView(OCIO_ConstConfigRcPtr *config, const char *display, int index)
{
try {
return (*(ConstConfigRcPtr *) config)->getView(display, index);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
const char *OCIOImpl::configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config, const char *display, const char *view)
{
try {
return (*(ConstConfigRcPtr *) config)->getDisplayColorSpaceName(display, view);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
int OCIOImpl::colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs_)
{
ConstColorSpaceRcPtr *cs = (ConstColorSpaceRcPtr *) cs_;
const char *family = (*cs)->getFamily();
if (!strcmp(family, "rrt") || !strcmp(family, "display")) {
/* assume display and rrt transformations are not invertible
* in fact some of them could be, but it doesn't make much sense to allow use them as invertible
*/
return false;
}
if ((*cs)->isData()) {
/* data color spaces don't have transformation at all */
return true;
}
if ((*cs)->getTransform(COLORSPACE_DIR_TO_REFERENCE)) {
/* if there's defined transform to reference space, color space could be converted to scene linear */
return true;
}
return true;
}
int OCIOImpl::colorSpaceIsData(OCIO_ConstColorSpaceRcPtr *cs)
{
return (*(ConstColorSpaceRcPtr *) cs)->isData();
}
void OCIOImpl::colorSpaceRelease(OCIO_ConstColorSpaceRcPtr *cs)
{
MEM_DELETE((ConstColorSpaceRcPtr *) cs, ConstColorSpaceRcPtr);
}
OCIO_ConstProcessorRcPtr *OCIOImpl::configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config, const char *srcName, const char *dstName)
{
ConstProcessorRcPtr *p = MEM_NEW(ConstProcessorRcPtr);
try {
*p = (*(ConstConfigRcPtr *) config)->getProcessor(srcName, dstName);
if (*p)
return (OCIO_ConstProcessorRcPtr *) p;
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
MEM_DELETE(p, ConstProcessorRcPtr);
return 0;
}
OCIO_ConstProcessorRcPtr *OCIOImpl::configGetProcessor(OCIO_ConstConfigRcPtr *config, OCIO_ConstTransformRcPtr *transform)
{
ConstProcessorRcPtr *p = MEM_NEW(ConstProcessorRcPtr);
try {
*p = (*(ConstConfigRcPtr *) config)->getProcessor(*(ConstTransformRcPtr *) transform);
if (*p)
return (OCIO_ConstProcessorRcPtr *) p;
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
MEM_DELETE(p, ConstProcessorRcPtr);
return NULL;
}
void OCIOImpl::processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img)
{
try {
(*(ConstProcessorRcPtr *) processor)->apply(*(PackedImageDesc *) img);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
}
void OCIOImpl::processorApply_predivide(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img_)
{
try {
PackedImageDesc *img = (PackedImageDesc *) img_;
int channels = img->getNumChannels();
if (channels == 4) {
float *pixels = img->getData();
int width = img->getWidth();
int height = img->getHeight();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
float *pixel = pixels + 4 * (y * width + x);
processorApplyRGBA_predivide(processor, pixel);
}
}
}
else {
(*(ConstProcessorRcPtr *) processor)->apply(*img);
}
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
}
void OCIOImpl::processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel)
{
(*(ConstProcessorRcPtr *) processor)->applyRGB(pixel);
}
void OCIOImpl::processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel)
{
(*(ConstProcessorRcPtr *) processor)->applyRGBA(pixel);
}
void OCIOImpl::processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel)
{
if (pixel[3] == 1.0f || pixel[3] == 0.0f) {
(*(ConstProcessorRcPtr *) processor)->applyRGBA(pixel);
}
else {
float alpha, inv_alpha;
alpha = pixel[3];
inv_alpha = 1.0f / alpha;
pixel[0] *= inv_alpha;
pixel[1] *= inv_alpha;
pixel[2] *= inv_alpha;
(*(ConstProcessorRcPtr *) processor)->applyRGBA(pixel);
pixel[0] *= alpha;
pixel[1] *= alpha;
pixel[2] *= alpha;
}
}
void OCIOImpl::processorRelease(OCIO_ConstProcessorRcPtr *p)
{
p->~OCIO_ConstProcessorRcPtr();
MEM_freeN(p);
}
const char *OCIOImpl::colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs)
{
return (*(ConstColorSpaceRcPtr *) cs)->getName();
}
const char *OCIOImpl::colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs)
{
return (*(ConstColorSpaceRcPtr *) cs)->getDescription();
}
const char *OCIOImpl::colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs)
{
return (*(ConstColorSpaceRcPtr *)cs)->getFamily();
}
OCIO_DisplayTransformRcPtr *OCIOImpl::createDisplayTransform(void)
{
DisplayTransformRcPtr *dt = MEM_NEW(DisplayTransformRcPtr);
*dt = DisplayTransform::Create();
return (OCIO_DisplayTransformRcPtr *) dt;
}
void OCIOImpl::displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *dt, const char *name)
{
(*(DisplayTransformRcPtr *) dt)->setInputColorSpaceName(name);
}
void OCIOImpl::displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *dt, const char *name)
{
(*(DisplayTransformRcPtr *) dt)->setDisplay(name);
}
void OCIOImpl::displayTransformSetView(OCIO_DisplayTransformRcPtr *dt, const char *name)
{
(*(DisplayTransformRcPtr *) dt)->setView(name);
}
void OCIOImpl::displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *t)
{
(*(DisplayTransformRcPtr *) dt)->setDisplayCC(* (ConstTransformRcPtr *) t);
}
void OCIOImpl::displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *t)
{
(*(DisplayTransformRcPtr *) dt)->setLinearCC(*(ConstTransformRcPtr *) t);
}
void OCIOImpl::displayTransformRelease(OCIO_DisplayTransformRcPtr *dt)
{
MEM_DELETE((DisplayTransformRcPtr *) dt, DisplayTransformRcPtr);
}
OCIO_PackedImageDesc *OCIOImpl::createOCIO_PackedImageDesc(float *data, long width, long height, long numChannels,
long chanStrideBytes, long xStrideBytes, long yStrideBytes)
{
try {
void *mem = MEM_mallocN(sizeof(PackedImageDesc), __func__);
PackedImageDesc *id = new(mem) PackedImageDesc(data, width, height, numChannels, chanStrideBytes, xStrideBytes, yStrideBytes);
return (OCIO_PackedImageDesc *) id;
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
void OCIOImpl::OCIO_PackedImageDescRelease(OCIO_PackedImageDesc* id)
{
MEM_DELETE((PackedImageDesc *) id, PackedImageDesc);
}
OCIO_ExponentTransformRcPtr *OCIOImpl::createExponentTransform(void)
{
ExponentTransformRcPtr *et = MEM_NEW(ExponentTransformRcPtr);
*et = ExponentTransform::Create();
return (OCIO_ExponentTransformRcPtr *) et;
}
void OCIOImpl::exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et, const float *exponent)
{
(*(ExponentTransformRcPtr *) et)->setValue(exponent);
}
void OCIOImpl::exponentTransformRelease(OCIO_ExponentTransformRcPtr *et)
{
MEM_DELETE((ExponentTransformRcPtr *) et, ExponentTransformRcPtr);
}
OCIO_MatrixTransformRcPtr *OCIOImpl::createMatrixTransform(void)
{
MatrixTransformRcPtr *mt = MEM_NEW(MatrixTransformRcPtr);
*mt = MatrixTransform::Create();
return (OCIO_MatrixTransformRcPtr *) mt;
}
void OCIOImpl::matrixTransformSetValue(OCIO_MatrixTransformRcPtr *mt, const float *m44, const float *offset4)
{
(*(MatrixTransformRcPtr *) mt)->setValue(m44, offset4);
}
void OCIOImpl::matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt)
{
MEM_DELETE((MatrixTransformRcPtr *) mt, MatrixTransformRcPtr);
}
void OCIOImpl::matrixTransformScale(float * m44, float * offset4, const float *scale4f)
{
MatrixTransform::Scale(m44, offset4, scale4f);
}

View File

@@ -0,0 +1,240 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2012 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __OCIO_IMPL_H__
#define __OCIO_IMPL_H__
#include "ocio_capi.h"
class IOCIOImpl {
public:
virtual ~IOCIOImpl() {};
virtual OCIO_ConstConfigRcPtr *getCurrentConfig(void) = 0;
virtual void setCurrentConfig(const OCIO_ConstConfigRcPtr *config) = 0;
virtual OCIO_ConstConfigRcPtr *configCreateFromEnv(void) = 0;
virtual OCIO_ConstConfigRcPtr *configCreateFromFile(const char* filename) = 0;
virtual void configRelease(OCIO_ConstConfigRcPtr *config) = 0;
virtual int configGetNumColorSpaces(OCIO_ConstConfigRcPtr *config) = 0;
virtual const char *configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr *config, int index) = 0;
virtual OCIO_ConstColorSpaceRcPtr *configGetColorSpace(OCIO_ConstConfigRcPtr *config, const char *name) = 0;
virtual int configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name) = 0;
virtual int colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs) = 0;
virtual int colorSpaceIsData(OCIO_ConstColorSpaceRcPtr *cs) = 0;
virtual void colorSpaceRelease(OCIO_ConstColorSpaceRcPtr *cs) = 0;
virtual const char *configGetDefaultDisplay(OCIO_ConstConfigRcPtr *config) = 0;
virtual int configGetNumDisplays(OCIO_ConstConfigRcPtr *config) = 0;
virtual const char *configGetDisplay(OCIO_ConstConfigRcPtr *config, int index) = 0;
virtual const char *configGetDefaultView(OCIO_ConstConfigRcPtr *config, const char *display) = 0;
virtual int configGetNumViews(OCIO_ConstConfigRcPtr *config, const char *display) = 0;
virtual const char *configGetView(OCIO_ConstConfigRcPtr *config, const char *display, int index) = 0;
virtual const char *configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config, const char *display, const char *view) = 0;
virtual OCIO_ConstProcessorRcPtr *configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config, const char *srcName, const char *dstName) = 0;
virtual OCIO_ConstProcessorRcPtr *configGetProcessor(OCIO_ConstConfigRcPtr *config, OCIO_ConstTransformRcPtr *transform) = 0;
virtual void processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img) = 0;
virtual void processorApply_predivide(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img) = 0;
virtual void processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel) = 0;
virtual void processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel) = 0;
virtual void processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel) = 0;
virtual void processorRelease(OCIO_ConstProcessorRcPtr *p) = 0;
virtual const char *colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs) = 0;
virtual const char *colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs) = 0;
virtual const char *colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs) = 0;
virtual OCIO_DisplayTransformRcPtr *createDisplayTransform(void) = 0;
virtual void displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *dt, const char *name) = 0;
virtual void displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *dt, const char *name) = 0;
virtual void displayTransformSetView(OCIO_DisplayTransformRcPtr *dt, const char *name) = 0;
virtual void displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et) = 0;
virtual void displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et) = 0;
virtual void displayTransformRelease(OCIO_DisplayTransformRcPtr *dt) = 0;
virtual OCIO_PackedImageDesc *createOCIO_PackedImageDesc(float *data, long width, long height, long numChannels,
long chanStrideBytes, long xStrideBytes, long yStrideBytes) = 0;
virtual void OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *p) = 0;
virtual OCIO_ExponentTransformRcPtr *createExponentTransform(void) = 0;
virtual void exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et, const float *exponent) = 0;
virtual void exponentTransformRelease(OCIO_ExponentTransformRcPtr *et) = 0;
virtual OCIO_MatrixTransformRcPtr *createMatrixTransform(void) = 0;
virtual void matrixTransformSetValue(OCIO_MatrixTransformRcPtr *et, const float *m44, const float *offset4) = 0;
virtual void matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt) = 0;
virtual void matrixTransformScale(float * m44, float * offset4, const float * scale4) = 0;
};
class FallbackImpl : public IOCIOImpl {
public:
FallbackImpl() {};
OCIO_ConstConfigRcPtr *getCurrentConfig(void);
void setCurrentConfig(const OCIO_ConstConfigRcPtr *config);
OCIO_ConstConfigRcPtr *configCreateFromEnv(void);
OCIO_ConstConfigRcPtr *configCreateFromFile(const char* filename);
void configRelease(OCIO_ConstConfigRcPtr *config);
int configGetNumColorSpaces(OCIO_ConstConfigRcPtr *config);
const char *configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr *config, int index);
OCIO_ConstColorSpaceRcPtr *configGetColorSpace(OCIO_ConstConfigRcPtr *config, const char *name);
int configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name);
int colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs);
int colorSpaceIsData(OCIO_ConstColorSpaceRcPtr *cs);
void colorSpaceRelease(OCIO_ConstColorSpaceRcPtr *cs);
const char *configGetDefaultDisplay(OCIO_ConstConfigRcPtr *config);
int configGetNumDisplays(OCIO_ConstConfigRcPtr *config);
const char *configGetDisplay(OCIO_ConstConfigRcPtr *config, int index);
const char *configGetDefaultView(OCIO_ConstConfigRcPtr *config, const char *display);
int configGetNumViews(OCIO_ConstConfigRcPtr *config, const char *display);
const char *configGetView(OCIO_ConstConfigRcPtr *config, const char *display, int index);
const char *configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config, const char *display, const char *view);
OCIO_ConstProcessorRcPtr *configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config, const char *srcName, const char *dstName);
OCIO_ConstProcessorRcPtr *configGetProcessor(OCIO_ConstConfigRcPtr *config, OCIO_ConstTransformRcPtr *transform);
void processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img);
void processorApply_predivide(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img);
void processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel);
void processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel);
void processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel);
void processorRelease(OCIO_ConstProcessorRcPtr *p);
const char *colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs);
const char *colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs);
const char *colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs);
OCIO_DisplayTransformRcPtr *createDisplayTransform(void);
void displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *dt, const char *name);
void displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *dt, const char *name);
void displayTransformSetView(OCIO_DisplayTransformRcPtr *dt, const char *name);
void displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et);
void displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et);
void displayTransformRelease(OCIO_DisplayTransformRcPtr *dt);
OCIO_PackedImageDesc *createOCIO_PackedImageDesc(float *data, long width, long height, long numChannels,
long chanStrideBytes, long xStrideBytes, long yStrideBytes);
void OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *p);
OCIO_ExponentTransformRcPtr *createExponentTransform(void);
void exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et, const float *exponent);
void exponentTransformRelease(OCIO_ExponentTransformRcPtr *et);
OCIO_MatrixTransformRcPtr *createMatrixTransform(void);
void matrixTransformSetValue(OCIO_MatrixTransformRcPtr *et, const float *m44, const float *offset4);
void matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt);
void matrixTransformScale(float * m44, float * offset4, const float * scale4);
};
#ifdef WITH_OCIO
class OCIOImpl : public IOCIOImpl {
public:
OCIOImpl() {};
OCIO_ConstConfigRcPtr *getCurrentConfig(void);
void setCurrentConfig(const OCIO_ConstConfigRcPtr *config);
OCIO_ConstConfigRcPtr *configCreateFromEnv(void);
OCIO_ConstConfigRcPtr *configCreateFromFile(const char* filename);
void configRelease(OCIO_ConstConfigRcPtr *config);
int configGetNumColorSpaces(OCIO_ConstConfigRcPtr *config);
const char *configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr *config, int index);
OCIO_ConstColorSpaceRcPtr *configGetColorSpace(OCIO_ConstConfigRcPtr *config, const char *name);
int configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name);
int colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs);
int colorSpaceIsData(OCIO_ConstColorSpaceRcPtr *cs);
void colorSpaceRelease(OCIO_ConstColorSpaceRcPtr *cs);
const char *configGetDefaultDisplay(OCIO_ConstConfigRcPtr *config);
int configGetNumDisplays(OCIO_ConstConfigRcPtr *config);
const char *configGetDisplay(OCIO_ConstConfigRcPtr *config, int index);
const char *configGetDefaultView(OCIO_ConstConfigRcPtr *config, const char *display);
int configGetNumViews(OCIO_ConstConfigRcPtr *config, const char *display);
const char *configGetView(OCIO_ConstConfigRcPtr *config, const char *display, int index);
const char *configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config, const char *display, const char *view);
OCIO_ConstProcessorRcPtr *configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config, const char *srcName, const char *dstName);
OCIO_ConstProcessorRcPtr *configGetProcessor(OCIO_ConstConfigRcPtr *config, OCIO_ConstTransformRcPtr *transform);
void processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img);
void processorApply_predivide(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img);
void processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel);
void processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel);
void processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel);
void processorRelease(OCIO_ConstProcessorRcPtr *p);
const char *colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs);
const char *colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs);
const char *colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs);
OCIO_DisplayTransformRcPtr *createDisplayTransform(void);
void displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *dt, const char *name);
void displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *dt, const char *name);
void displayTransformSetView(OCIO_DisplayTransformRcPtr *dt, const char *name);
void displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et);
void displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et);
void displayTransformRelease(OCIO_DisplayTransformRcPtr *dt);
OCIO_PackedImageDesc *createOCIO_PackedImageDesc(float *data, long width, long height, long numChannels,
long chanStrideBytes, long xStrideBytes, long yStrideBytes);
void OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *p);
OCIO_ExponentTransformRcPtr *createExponentTransform(void);
void exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et, const float *exponent);
void exponentTransformRelease(OCIO_ExponentTransformRcPtr *et);
OCIO_MatrixTransformRcPtr *createMatrixTransform(void);
void matrixTransformSetValue(OCIO_MatrixTransformRcPtr *et, const float *m44, const float *offset4);
void matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt);
void matrixTransformScale(float * m44, float * offset4, const float * scale4);
};
#endif
#endif /* OCIO_IMPL_H */

View File

@@ -138,13 +138,13 @@ static void __nl_should_not_have_reached(char* file, int line) {
/* memory management */
#define __NL_NEW(T) (T*)(calloc(1, sizeof(T)))
#define __NL_NEW_ARRAY(T,NB) (T*)(calloc((NB),sizeof(T)))
#define __NL_NEW_ARRAY(T,NB) (T*)(calloc(MAX(NB, 1),sizeof(T)))
#define __NL_RENEW_ARRAY(T,x,NB) (T*)(realloc(x,(NB)*sizeof(T)))
#define __NL_DELETE(x) free(x); x = NULL
#define __NL_DELETE_ARRAY(x) free(x); x = NULL
#define __NL_DELETE(x) if(x) free(x); x = NULL
#define __NL_DELETE_ARRAY(x) if(x) free(x); x = NULL
#define __NL_CLEAR(T, x) memset(x, 0, sizeof(T))
#define __NL_CLEAR_ARRAY(T,x,NB) memset(x, 0, (NB)*sizeof(T))
#define __NL_CLEAR_ARRAY(T,x,NB) if(NB) memset(x, 0, (NB)*sizeof(T))
/************************************************************************************/
/* Dynamic arrays for sparse row/columns */
@@ -1042,6 +1042,9 @@ static NLboolean __nlFactorize_SUPERLU(__NLContext *context, NLint *permutation)
NLuint n = context->n;
NLuint nnz = __nlSparseMatrixNNZ(M); /* number of non-zero coeffs */
/*if(n > 10)
n = 10;*/
/* Compressed Row Storage matrix representation */
NLint *xa = __NL_NEW_ARRAY(NLint, n+1);
NLfloat *rhs = __NL_NEW_ARRAY(NLfloat, n);

View File

@@ -173,6 +173,7 @@ getata(
/* Flag the diagonal so it's not included in the B matrix */
marker[j] = j;
if ( *atanz ) {
for (i = colptr[j]; i < colptr[j+1]; ++i) {
/* A_kj is nonzero, add pattern of column T_*k to B_*j */
k = rowind[i];
@@ -185,6 +186,7 @@ getata(
}
}
}
}
b_colptr[n] = num_nz;
SUPERLU_FREE(marker);
@@ -305,6 +307,7 @@ at_plus_a(
marker[j] = j;
/* Add pattern of column A_*k to B_*j */
if (*bnz) {
for (i = colptr[j]; i < colptr[j+1]; ++i) {
k = rowind[i];
if ( marker[k] != j ) {
@@ -322,6 +325,7 @@ at_plus_a(
}
}
}
}
(*b_colptr)[n] = num_nz;
SUPERLU_FREE(marker);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 224 KiB

After

Width:  |  Height:  |  Size: 207 KiB

View File

@@ -34,6 +34,7 @@
import sys
import ctypes
import re
try:
import settings
@@ -87,44 +88,64 @@ FRIBIDI_FLAGS_ARABIC = FRIBIDI_FLAG_SHAPE_ARAB_PRES | \
FRIBIDI_FLAG_SHAPE_ARAB_LIGA
MENU_DETECT_REGEX = re.compile("%x\\d+\\|")
##### Kernel processing funcs. #####
def protect_format_seq(msg):
"""
Find some specific escaping/formating sequences (like \", %s, etc.,
and protect them from any modification!
"""
# LRM = "\u200E"
# RLM = "\u200F"
LRE = "\u202A"
RLE = "\u202B"
PDF = "\u202C"
LRO = "\u202D"
RLO = "\u202E"
uctrl = {LRE, RLE, PDF, LRO, RLO}
# Most likely incomplete, but seems to cover current needs.
format_codes = set("tslfd")
digits = set(".0123456789")
if not msg:
return msg
elif MENU_DETECT_REGEX.search(msg):
# An ugly "menu" message, just force it whole LRE if not yet done.
if msg[0] not in {LRE, LRO}:
msg = LRE + msg
idx = 0
ret = []
ln = len(msg)
while idx < ln:
dlt = 1
# # If we find a control char, skip any additional protection!
# if msg[idx] in uctrl:
# ret.append(msg[idx:])
# break
# \" or \'
if idx < (ln - 1) and msg[idx] == '\\' and msg[idx + 1] in "\"\'":
dlt = 2
# %x12
elif idx < (ln - 2) and msg[idx] == '%' and msg[idx + 1] in "x" and \
msg[idx + 2] in digits:
# %x12|
elif idx < (ln - 2) and msg[idx] == '%' and msg[idx + 1] in "x" and msg[idx + 2] in digits:
dlt = 2
while (idx + dlt + 1) < ln and msg[idx + dlt + 1] in digits:
while (idx + dlt) < ln and msg[idx + dlt] in digits:
dlt += 1
if (idx + dlt) < ln and msg[idx + dlt] is '|':
dlt += 1
# %.4f
elif idx < (ln - 3) and msg[idx] == '%' and msg[idx + 1] in digits:
dlt = 2
while (idx + dlt + 1) < ln and msg[idx + dlt + 1] in digits:
while (idx + dlt) < ln and msg[idx + dlt] in digits:
dlt += 1
if (idx + dlt + 1) < ln and msg[idx + dlt + 1] in format_codes:
if (idx + dlt) < ln and msg[idx + dlt] in format_codes:
dlt += 1
else:
dlt = 1
# %s
elif idx < (ln - 1) and msg[idx] == '%' and \
msg[idx + 1] in format_codes:
elif idx < (ln - 1) and msg[idx] == '%' and msg[idx + 1] in format_codes:
dlt = 2
if dlt > 1:

View File

@@ -9,6 +9,7 @@
handle_auto="#909000"
handle_sel_auto="#f0ff40"
bone_pose="#50c8ff"
bone_pose_active="#8cffff"
bone_solid="#c8c8c8"
bundle_solid="#c8c8c8"
camera="#000000"

View File

@@ -9,6 +9,7 @@
handle_auto="#909000"
handle_sel_auto="#f0ff40"
bone_pose="#50c8ff"
bone_pose_active="#8cffff"
bone_solid="#c8c8c8"
bundle_solid="#c8c8c8"
camera="#000000"

View File

@@ -9,6 +9,7 @@
handle_auto="#909000"
handle_sel_auto="#f0ff40"
bone_pose="#50c8ff"
bone_pose_active="#8cffff"
bone_solid="#c8c8c8"
bundle_solid="#c8c8c8"
camera="#000000"
@@ -282,7 +283,7 @@
<ThemeInfo>
<space>
<ThemeSpaceGeneric header="#3b3b3b"
header_text="#8b8b8b"
header_text="#000000"
header_text_hi="#000000"
button="#3b3b3b"
button_text="#000000"

View File

@@ -9,6 +9,7 @@
handle_auto="#909000"
handle_sel_auto="#f0ff40"
bone_pose="#50c8ff"
bone_pose_active="#8cffff"
bone_solid="#c8c8c8"
bundle_solid="#c8c8c8"
camera="#000000"

View File

@@ -9,6 +9,7 @@
handle_auto="#909000"
handle_sel_auto="#f0ff40"
bone_pose="#50c8ff"
bone_pose_active="#8cffff"
bone_solid="#c8c8c8"
bundle_solid="#c8c8c8"
camera="#000000"

View File

@@ -189,7 +189,7 @@ class BakeAction(Operator):
name="Only Selected",
default=True,
)
clear_consraints = BoolProperty(
clear_constraints = BoolProperty(
name="Clear Constraints",
default=False,
)
@@ -212,7 +212,7 @@ class BakeAction(Operator):
self.only_selected,
'POSE' in self.bake_types,
'OBJECT' in self.bake_types,
self.clear_consraints,
self.clear_constraints,
True,
)

View File

@@ -1028,7 +1028,7 @@ class WM_OT_properties_edit(Operator):
min = rna_min
max = rna_max
description = StringProperty(
name="Tip",
name="Tooltip",
)
def execute(self, context):

View File

@@ -65,10 +65,13 @@ class MotionPathButtonsPanel():
sub.prop(mpath, "frame_start", text="From")
sub.prop(mpath, "frame_end", text="To")
sub = col.row(align=True)
if bones:
col.operator("pose.paths_update", text="Update Paths", icon='BONE_DATA')
sub.operator("pose.paths_update", text="Update Paths", icon='BONE_DATA')
sub.operator("pose.paths_clear", text="", icon='X')
else:
col.operator("object.paths_update", text="Update Paths", icon='OBJECT_DATA')
sub.operator("object.paths_update", text="Update Paths", icon='OBJECT_DATA')
sub.operator("object.paths_clear", text="", icon='X')
else:
sub = col.column(align=True)
sub.label(text="Nothing to show yet...", icon='ERROR')

View File

@@ -212,6 +212,7 @@ class ConstraintButtonsPanel():
def FOLLOW_PATH(self, context, layout, con):
self.target_template(layout, con)
layout.operator("constraint.followpath_path_animate", text="Animate Path", icon='ANIM_DATA')
split = layout.split()

View File

@@ -790,42 +790,45 @@ class CLIP_PT_proxy(CLIP_PT_clip_view_panel, Panel):
sc = context.space_data
clip = sc.clip
layout.active = clip.use_proxy
col = layout.column()
col.active = clip.use_proxy
layout.label(text="Build Original:")
col.label(text="Build Original:")
row = layout.row(align=True)
row = col.row(align=True)
row.prop(clip.proxy, "build_25", toggle=True)
row.prop(clip.proxy, "build_50", toggle=True)
row.prop(clip.proxy, "build_75", toggle=True)
row.prop(clip.proxy, "build_100", toggle=True)
layout.label(text="Build Undistorted:")
col.label(text="Build Undistorted:")
row = layout.row(align=True)
row = col.row(align=True)
row.prop(clip.proxy, "build_undistorted_25", toggle=True)
row.prop(clip.proxy, "build_undistorted_50", toggle=True)
row.prop(clip.proxy, "build_undistorted_75", toggle=True)
row.prop(clip.proxy, "build_undistorted_100", toggle=True)
layout.prop(clip.proxy, "quality")
col.prop(clip.proxy, "quality")
layout.prop(clip, "use_proxy_custom_directory")
col.prop(clip, "use_proxy_custom_directory")
if clip.use_proxy_custom_directory:
layout.prop(clip.proxy, "directory")
col.prop(clip.proxy, "directory")
layout.operator("clip.rebuild_proxy", text="Build Proxy")
col.operator("clip.rebuild_proxy", text="Build Proxy")
if clip.source == 'MOVIE':
col = layout.column()
col2 = col.column()
col.label(text="Use timecode index:")
col.prop(clip.proxy, "timecode", text="")
col2.label(text="Use timecode index:")
col2.prop(clip.proxy, "timecode", text="")
col = layout.column()
col.label(text="Proxy render size:")
col2 = col.column()
col2.label(text="Proxy render size:")
col.prop(sc.clip_user, "proxy_render_size", text="")
col = layout.column()
col.prop(sc.clip_user, "use_render_undistorted")

View File

@@ -192,7 +192,7 @@ class INFO_MT_mesh_add(Menu):
def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator_context = 'EXEC_REGION_WIN'
layout.operator("mesh.primitive_plane_add", icon='MESH_PLANE', text="Plane")
layout.operator("mesh.primitive_cube_add", icon='MESH_CUBE', text="Cube")
layout.operator("mesh.primitive_circle_add", icon='MESH_CIRCLE', text="Circle")
@@ -203,7 +203,7 @@ class INFO_MT_mesh_add(Menu):
layout.separator()
layout.operator("mesh.primitive_grid_add", icon='MESH_GRID', text="Grid")
layout.operator("mesh.primitive_monkey_add", icon='MESH_MONKEY', text="Monkey")
layout.operator("mesh.primitive_torus_add", text="Torus", icon='MESH_TORUS')
layout.operator("mesh.primitive_torus_add", icon='MESH_TORUS', text="Torus")
class INFO_MT_curve_add(Menu):
@@ -213,7 +213,7 @@ class INFO_MT_curve_add(Menu):
def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator_context = 'EXEC_REGION_WIN'
layout.operator("curve.primitive_bezier_curve_add", icon='CURVE_BEZCURVE', text="Bezier")
layout.operator("curve.primitive_bezier_circle_add", icon='CURVE_BEZCIRCLE', text="Circle")
layout.operator("curve.primitive_nurbs_curve_add", icon='CURVE_NCURVE', text="Nurbs Curve")
@@ -221,6 +221,22 @@ class INFO_MT_curve_add(Menu):
layout.operator("curve.primitive_nurbs_path_add", icon='CURVE_PATH', text="Path")
class INFO_MT_surface_add(Menu):
bl_idname = "INFO_MT_surface_add"
bl_label = "Surface"
def draw(self, context):
layout = self.layout
layout.operator_context = 'EXEC_REGION_WIN'
layout.operator("surface.primitive_nurbs_surface_curve_add", icon='SURFACE_NCURVE', text="NURBS Curve")
layout.operator("surface.primitive_nurbs_surface_circle_add", icon='SURFACE_NCIRCLE', text="NURBS Circle")
layout.operator("surface.primitive_nurbs_surface_surface_add", icon='SURFACE_NSURFACE', text="NURBS Surface")
layout.operator("surface.primitive_nurbs_surface_cylinder_add", icon='SURFACE_NCYLINDER', text="NURBS Cylinder")
layout.operator("surface.primitive_nurbs_surface_sphere_add", icon='SURFACE_NSPHERE', text="NURBS Sphere")
layout.operator("surface.primitive_nurbs_surface_torus_add", icon='SURFACE_NTORUS', text="NURBS Torus")
class INFO_MT_edit_curve_add(Menu):
bl_idname = "INFO_MT_edit_curve_add"
bl_label = "Add"
@@ -229,7 +245,7 @@ class INFO_MT_edit_curve_add(Menu):
is_surf = context.active_object.type == 'SURFACE'
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator_context = 'EXEC_REGION_WIN'
if is_surf:
INFO_MT_surface_add.draw(self, context)
@@ -237,22 +253,6 @@ class INFO_MT_edit_curve_add(Menu):
INFO_MT_curve_add.draw(self, context)
class INFO_MT_surface_add(Menu):
bl_idname = "INFO_MT_surface_add"
bl_label = "Surface"
def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("surface.primitive_nurbs_surface_curve_add", icon='SURFACE_NCURVE', text="NURBS Curve")
layout.operator("surface.primitive_nurbs_surface_circle_add", icon='SURFACE_NCIRCLE', text="NURBS Circle")
layout.operator("surface.primitive_nurbs_surface_surface_add", icon='SURFACE_NSURFACE', text="NURBS Surface")
layout.operator("surface.primitive_nurbs_surface_cylinder_add", icon='SURFACE_NCYLINDER', text="NURBS Cylinder")
layout.operator("surface.primitive_nurbs_surface_sphere_add", icon='SURFACE_NSPHERE', text="NURBS Sphere")
layout.operator("surface.primitive_nurbs_surface_torus_add", icon='SURFACE_NTORUS', text="NURBS Torus")
class INFO_MT_armature_add(Menu):
bl_idname = "INFO_MT_armature_add"
bl_label = "Armature"
@@ -260,7 +260,7 @@ class INFO_MT_armature_add(Menu):
def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator_context = 'EXEC_REGION_WIN'
layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA')
@@ -272,7 +272,9 @@ class INFO_MT_add(Menu):
# note, don't use 'EXEC_SCREEN' or operators wont get the 'v3d' context.
layout.operator_context = 'EXEC_AREA'
# Note: was EXEC_AREA, but this context does not have the 'rv3d', which prevents
# "align_view" to work on first call (see [#32719]).
layout.operator_context = 'EXEC_REGION_WIN'
#layout.operator_menu_enum("object.mesh_add", "type", text="Mesh", icon='OUTLINER_OB_MESH')
layout.menu("INFO_MT_mesh_add", icon='OUTLINER_OB_MESH')
@@ -282,20 +284,18 @@ class INFO_MT_add(Menu):
#layout.operator_menu_enum("object.surface_add", "type", text="Surface", icon='OUTLINER_OB_SURFACE')
layout.menu("INFO_MT_surface_add", icon='OUTLINER_OB_SURFACE')
layout.operator_menu_enum("object.metaball_add", "type", text="Metaball", icon='OUTLINER_OB_META')
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT')
layout.separator()
layout.menu("INFO_MT_armature_add", icon='OUTLINER_OB_ARMATURE')
layout.operator("object.add", text="Lattice", icon='OUTLINER_OB_LATTICE').type = 'LATTICE'
layout.operator("object.add", text="Empty", icon='OUTLINER_OB_EMPTY').type = 'EMPTY'
layout.operator_menu_enum("object.empty_add", "type", text="Empty", icon='OUTLINER_OB_EMPTY')
layout.separator()
layout.operator("object.speaker_add", text="Speaker", icon='OUTLINER_OB_SPEAKER')
layout.separator()
layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA')
layout.operator_context = 'EXEC_AREA'
layout.operator_menu_enum("object.lamp_add", "type", text="Lamp", icon='OUTLINER_OB_LAMP')
layout.separator()
@@ -303,7 +303,7 @@ class INFO_MT_add(Menu):
layout.separator()
if(len(bpy.data.groups) > 10):
layout.operator_context = 'INVOKE_DEFAULT'
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("object.group_instance_add", text="Group Instance...", icon='OUTLINER_OB_EMPTY')
else:
layout.operator_menu_enum("object.group_instance_add", "group", text="Group Instance", icon='OUTLINER_OB_EMPTY')

View File

@@ -20,7 +20,6 @@
import bpy
from bpy.types import Header, Menu, Panel
import os
import addon_utils
def ui_items_general(col, context):
@@ -1033,6 +1032,8 @@ class USERPREF_PT_addons(Panel):
box.label(l)
def draw(self, context):
import addon_utils
layout = self.layout
userpref = context.user_preferences

View File

@@ -807,7 +807,8 @@ class VIEW3D_MT_object_animation(Menu):
layout = self.layout
layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframe...")
layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframes...")
layout.operator("anim.keyframe_clear_v3d", text="Clear Keyframes...")
layout.operator("anim.keying_set_active_set", text="Change Keying Set...")
layout.separator()

View File

@@ -97,6 +97,8 @@ const char *BLF_translate_do_tooltip(const char *contex, const char *msgid);
/* Default context for operator names/labels. */
#define BLF_I18NCONTEXT_OPERATOR_DEFAULT "Operator"
/* Audio disambiguation context. */
#define BLF_I18NCONTEXT_AUDIO "Audio"
#endif /* __BLF_TRANSLATION_H__ */

View File

@@ -65,8 +65,8 @@ int where_on_path(struct Object *ob, float ctime, float vec[4], float dir[3], fl
/* ---------------------------------------------------- */
/* Dupli-Geometry */
struct ListBase *object_duplilist_ex(struct Scene *sce, struct Object *ob, int update);
struct ListBase *object_duplilist(struct Scene *sce, struct Object *ob);
struct ListBase *object_duplilist_ex(struct Scene *sce, struct Object *ob, int update, int for_render);
struct ListBase *object_duplilist(struct Scene *sce, struct Object *ob, int for_render);
void free_object_duplilist(struct ListBase *lb);
int count_duplilist(struct Object *ob);

View File

@@ -132,6 +132,7 @@ Mat4 *b_bone_spline_setup(struct bPoseChannel *pchan, int rest);
/* like EBONE_VISIBLE */
#define PBONE_VISIBLE(arm, bone) (((bone)->layer & (arm)->layer) && !((bone)->flag & BONE_HIDDEN_P))
#define PBONE_SELECTABLE(arm, bone) (PBONE_VISIBLE(arm, bone) && !((bone)->flag & BONE_UNSELECTABLE))
#ifdef __cplusplus
}

View File

@@ -41,8 +41,8 @@ extern "C" {
/* these lines are grep'd, watch out for our not-so-awesome regex
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 263
#define BLENDER_SUBVERSION 22
#define BLENDER_VERSION 264
#define BLENDER_SUBVERSION 1
/* 262 was the last editmesh release but its has compatibility code for bmesh data,
* so set the minversion to 2.61 */
@@ -51,9 +51,9 @@ extern "C" {
/* used by packaging tools */
/* can be left blank, otherwise a,b,c... etc with no quotes */
#define BLENDER_VERSION_CHAR a
#define BLENDER_VERSION_CHAR
/* alpha/beta/rc/release, docs use this */
#define BLENDER_VERSION_CYCLE rc
#define BLENDER_VERSION_CYCLE alpha
extern char versionstr[]; /* from blender.c */

View File

@@ -44,7 +44,7 @@ void free_gpencil_layers(struct ListBase *list);
void BKE_gpencil_free(struct bGPdata *gpd);
struct bGPDframe *gpencil_frame_addnew(struct bGPDlayer *gpl, int cframe);
struct bGPDlayer *gpencil_layer_addnew(struct bGPdata *gpd);
struct bGPDlayer *gpencil_layer_addnew(struct bGPdata *gpd, const char *name, int setactive);
struct bGPdata *gpencil_data_addnew(const char name[]);
struct bGPDframe *gpencil_frame_duplicate(struct bGPDframe *src);
@@ -62,6 +62,6 @@ struct bGPDframe *gpencil_layer_getframe(struct bGPDlayer *gpl, int cframe, shor
void gpencil_layer_delframe(struct bGPDlayer *gpl, struct bGPDframe *gpf);
struct bGPDlayer *gpencil_layer_getactive(struct bGPdata *gpd);
void gpencil_layer_setactive(struct bGPdata *gpd, struct bGPDlayer *active);
void gpencil_layer_delactive(struct bGPdata *gpd);
void gpencil_layer_delete(struct bGPdata *gpd, struct bGPDlayer *gpl);
#endif /* __BKE_GPENCIL_H__ */

View File

@@ -59,8 +59,12 @@ void BKE_mball_properties_copy(struct Scene *scene, struct Object *active_object
int BKE_mball_minmax(struct MetaBall *mb, float min[3], float max[3]);
int BKE_mball_center_median(struct MetaBall *mb, float r_cent[3]);
int BKE_mball_center_bounds(struct MetaBall *mb, float r_cent[3]);
void BKE_mball_translate(struct MetaBall *mb, float offset[3]);
void BKE_mball_translate(struct MetaBall *mb, const float offset[3]);
struct MetaElem *BKE_mball_element_add(struct MetaBall *mb, const int type);
void BKE_mball_select_all(struct MetaBall *mb);
void BKE_mball_deselect_all(struct MetaBall *mb);
void BKE_mball_select_swap(struct MetaBall *mb);
#endif

View File

@@ -475,6 +475,8 @@ struct bNodeSocket *node_group_add_extern_socket(struct bNodeTree *ntree, ListBa
void register_node_type_frame(struct bNodeTreeType *ttype);
void register_node_type_reroute(struct bNodeTreeType *ttype);
void BKE_node_tree_unlink_id_cb(void *calldata, struct ID *owner_id, struct bNodeTree *ntree);
/* ************** SHADER NODES *************** */
struct ShadeInput;

View File

@@ -109,6 +109,7 @@ float get_render_aosss_error(struct RenderData *r, float error);
int BKE_scene_use_new_shading_nodes(struct Scene *scene);
void BKE_scene_disable_color_management(struct Scene *scene);
int BKE_scene_check_color_management_enabled(const struct Scene *scene);
#ifdef __cplusplus
}

View File

@@ -64,29 +64,29 @@ typedef struct SeqIterator {
int valid;
} SeqIterator;
void BKE_seqence_iterator_begin(struct Editing *ed, SeqIterator *iter, int use_pointer);
void BKE_seqence_iterator_next(SeqIterator *iter);
void BKE_seqence_iterator_end(SeqIterator *iter);
void BKE_sequence_iterator_begin(struct Editing *ed, SeqIterator *iter, int use_pointer);
void BKE_sequence_iterator_next(SeqIterator *iter);
void BKE_sequence_iterator_end(SeqIterator *iter);
#define SEQP_BEGIN(ed, _seq) \
{ \
SeqIterator iter; \
for (BKE_seqence_iterator_begin(ed, &iter, 1); \
for (BKE_sequence_iterator_begin(ed, &iter, 1); \
iter.valid; \
BKE_seqence_iterator_next(&iter)) { \
BKE_sequence_iterator_next(&iter)) { \
_seq = iter.seq;
#define SEQ_BEGIN(ed, _seq) \
{ \
SeqIterator iter; \
for (BKE_seqence_iterator_begin(ed, &iter, 0); \
for (BKE_sequence_iterator_begin(ed, &iter, 0); \
iter.valid; \
BKE_seqence_iterator_next(&iter)) { \
BKE_sequence_iterator_next(&iter)) { \
_seq = iter.seq;
#define SEQ_END \
} \
BKE_seqence_iterator_end(&iter); \
BKE_sequence_iterator_end(&iter); \
}
typedef struct SeqRenderData {
@@ -307,7 +307,7 @@ int BKE_sequence_swap(struct Sequence *seq_a, struct Sequence *seq_b, const char
int BKE_sequence_check_depend(struct Sequence *seq, struct Sequence *cur);
void BKE_sequence_invalidate_cache(struct Scene *scene, struct Sequence *seq);
void BKE_sequence_invalidate_deendent(struct Scene *scene, struct Sequence *seq);
void BKE_sequence_invalidate_dependent(struct Scene *scene, struct Sequence *seq);
void BKE_sequence_invalidate_cache_for_modifier(struct Scene *scene, struct Sequence *seq);
void BKE_sequencer_update_sound_bounds_all(struct Scene *scene);
@@ -315,9 +315,9 @@ void BKE_sequencer_update_sound_bounds(struct Scene *scene, struct Sequence *seq
void BKE_sequencer_update_muting(struct Editing *ed);
void BKE_sequencer_update_sound(struct Scene *scene, struct bSound *sound);
void BKE_seqence_base_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq);
void BKE_sequence_base_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq);
void BKE_sequence_base_dupli_recursive(struct Scene *scene, struct Scene *scene_to, ListBase *nseqbase, ListBase *seqbase, int dupe_flag);
int BKE_seqence_is_valid_check(struct Sequence *seq);
int BKE_sequence_is_valid_check(struct Sequence *seq);
void BKE_sequencer_clear_scene_in_allseqs(struct Main *bmain, struct Scene *sce);

View File

@@ -578,6 +578,13 @@ void DM_set_only_copy(DerivedMesh *dm, CustomDataMask mask)
CustomData_set_only_copy(&dm->vertData, mask);
CustomData_set_only_copy(&dm->edgeData, mask);
CustomData_set_only_copy(&dm->faceData, mask);
/* this wasn't in 2.63 and is disabled for 2.64 because it gives problems with
* weight paint mode when there are modifiers applied, needs further investigation,
* see replies to r50969, Campbell */
#if 0
CustomData_set_only_copy(&dm->loopData, mask);
CustomData_set_only_copy(&dm->polyData, mask);
#endif
}
void DM_add_vert_layer(DerivedMesh *dm, int type, int alloctype, void *layer)

View File

@@ -539,6 +539,7 @@ void BKE_pose_copy_data(bPose **dst, bPose *src, int copycon)
outPose->iksolver = src->iksolver;
outPose->ikdata = NULL;
outPose->ikparam = MEM_dupallocN(src->ikparam);
outPose->avs = src->avs;
for (pchan = outPose->chanbase.first; pchan; pchan = pchan->next) {
/* TODO: rename this argument... */

View File

@@ -75,7 +75,7 @@
/* forward declarations */
static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBase *duplilist, float par_space_mat[][4], int par_index,
int level, short animated, short update);
int level, short flag);
/* ******************************************************************** */
/* Animation Visualization */
@@ -700,7 +700,11 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua
/* ******************************************************************** */
/* Dupli-Geometry */
static DupliObject *new_dupli_object(ListBase *lb, Object *ob, float mat[][4], int lay, int index, int par_index, int type, short animated)
#define DUPLILIST_DO_UPDATE 1
#define DUPLILIST_FOR_RENDER 2
#define DUPLILIST_ANIMATED 4
static DupliObject *new_dupli_object(ListBase *lb, Object *ob, float mat[][4], int lay, int index, int par_index, int type, short flag)
{
DupliObject *dob = MEM_callocN(sizeof(DupliObject), "dupliobject");
@@ -712,14 +716,14 @@ static DupliObject *new_dupli_object(ListBase *lb, Object *ob, float mat[][4], i
dob->index = index;
dob->particle_index = par_index;
dob->type = type;
dob->animated = (type == OB_DUPLIGROUP) && animated;
dob->animated = (type == OB_DUPLIGROUP) && (flag & DUPLILIST_ANIMATED);
ob->lay = lay;
return dob;
}
static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int par_index,
int level, short animated, short update)
int level, short flag)
{
DupliObject *dob;
Group *group;
@@ -735,13 +739,14 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int par_inde
/* handles animated groups, and */
/* we need to check update for objects that are not in scene... */
if (update) {
if (flag & DUPLILIST_DO_UPDATE) {
/* note: update is optional because we don't always need object
* transformations to be correct. Also fixes bug [#29616]. */
group_handle_recalc_and_update(scene, ob, group);
}
animated = animated || group_is_animated(ob, group);
if (group_is_animated(ob, group))
flag |= DUPLILIST_ANIMATED;
for (go = group->gobject.first; go; go = go->next) {
/* note, if you check on layer here, render goes wrong... it still deforms verts and uses parent imat */
@@ -757,7 +762,7 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int par_inde
mult_m4_m4m4(mat, ob->obmat, go->ob->obmat);
}
dob = new_dupli_object(lb, go->ob, mat, ob->lay, 0, par_index, OB_DUPLIGROUP, animated);
dob = new_dupli_object(lb, go->ob, mat, ob->lay, 0, par_index, OB_DUPLIGROUP, flag);
/* check the group instance and object layers match, also that the object visible flags are ok. */
if ((dob->origlay & group->layer) == 0 ||
@@ -772,14 +777,14 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int par_inde
if (go->ob->transflag & OB_DUPLI) {
copy_m4_m4(dob->ob->obmat, dob->mat);
object_duplilist_recursive(&group->id, scene, go->ob, lb, ob->obmat, par_index, level + 1, animated, update);
object_duplilist_recursive(&group->id, scene, go->ob, lb, ob->obmat, par_index, level + 1, flag);
copy_m4_m4(dob->ob->obmat, dob->omat);
}
}
}
}
static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int par_index, int level, short animated)
static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int par_index, int level, short flag)
{
extern int enable_cu_speed; /* object.c */
Object copyob;
@@ -827,7 +832,7 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int par_ind
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */
BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra);
dob = new_dupli_object(lb, ob, ob->obmat, ob->lay, scene->r.cfra, par_index, OB_DUPLIFRAMES, animated);
dob = new_dupli_object(lb, ob, ob->obmat, ob->lay, scene->r.cfra, par_index, OB_DUPLIFRAMES, flag);
copy_m4_m4(dob->omat, copyob.obmat);
}
}
@@ -851,8 +856,7 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int par_ind
typedef struct VertexDupliData {
ID *id; /* scene or group, for recursive loops */
int level;
short animated;
short update;
short flag;
ListBase *lb;
float pmat[4][4];
float obmat[4][4]; /* Only used for dupliverts inside dupligroups, where the ob->obmat is modified */
@@ -896,7 +900,7 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3],
origlay = vdd->ob->lay;
dob = new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay, index, vdd->par_index, OB_DUPLIVERTS, vdd->animated);
dob = new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay, index, vdd->par_index, OB_DUPLIVERTS, vdd->flag);
/* restore the original layer so that each dupli will have proper dob->origlay */
vdd->ob->lay = origlay;
@@ -908,13 +912,13 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3],
float tmpmat[4][4];
copy_m4_m4(tmpmat, vdd->ob->obmat);
copy_m4_m4(vdd->ob->obmat, obmat); /* pretend we are really this mat */
object_duplilist_recursive((ID *)vdd->id, vdd->scene, vdd->ob, vdd->lb, obmat, vdd->par_index, vdd->level + 1, vdd->animated, vdd->update);
object_duplilist_recursive((ID *)vdd->id, vdd->scene, vdd->ob, vdd->lb, obmat, vdd->par_index, vdd->level + 1, vdd->flag);
copy_m4_m4(vdd->ob->obmat, tmpmat);
}
}
static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], int par_index,
int level, short animated, short update)
int level, short flag)
{
Object *ob, *ob_iter;
Mesh *me = par->data;
@@ -942,7 +946,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
else
dm = mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH);
if (G.is_rendering) {
if (flag & DUPLILIST_FOR_RENDER) {
vdd.orco = (float(*)[3])BKE_mesh_orco_verts_get(par);
BKE_mesh_orco_verts_transform(me, vdd.orco, me->totvert, 0);
}
@@ -992,8 +996,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
vdd.id = id;
vdd.level = level;
vdd.animated = animated;
vdd.update = update;
vdd.flag = flag;
vdd.lb = lb;
vdd.ob = ob;
vdd.scene = scene;
@@ -1039,7 +1042,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
}
static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], int par_index,
int level, short animated, short update)
int level, short flag)
{
Object *ob, *ob_iter;
Base *base = NULL;
@@ -1076,8 +1079,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
mloop = dm->getLoopArray(dm);
mvert = dm->getVertArray(dm);
if (G.is_rendering) {
if (flag & DUPLILIST_FOR_RENDER) {
orco = (float(*)[3])BKE_mesh_orco_verts_get(par);
BKE_mesh_orco_verts_transform(me, orco, me->totvert, 0);
mloopuv = me->mloopuv;
@@ -1182,8 +1184,8 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
copy_m4_m4(tmat, obmat);
mul_m4_m4m3(obmat, tmat, mat);
dob = new_dupli_object(lb, ob, obmat, par->lay, a, par_index, OB_DUPLIFACES, animated);
if (G.is_rendering) {
dob = new_dupli_object(lb, ob, obmat, par->lay, a, par_index, OB_DUPLIFACES, (flag & DUPLILIST_ANIMATED));
if (flag & DUPLILIST_FOR_RENDER) {
w = 1.0f / (float)mp->totloop;
if (orco) {
@@ -1205,7 +1207,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
float tmpmat[4][4];
copy_m4_m4(tmpmat, ob->obmat);
copy_m4_m4(ob->obmat, obmat); /* pretend we are really this mat */
object_duplilist_recursive((ID *)id, scene, ob, lb, ob->obmat, par_index, level + 1, animated, update);
object_duplilist_recursive((ID *)id, scene, ob, lb, ob->obmat, par_index, level + 1, flag);
copy_m4_m4(ob->obmat, tmpmat);
}
}
@@ -1226,7 +1228,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
}
static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], int UNUSED(par_index), ParticleSystem *psys,
int level, short animated, short update)
int level, short flag)
{
GroupObject *go;
Object *ob = NULL, **oblist = NULL, obcopy, *obcopylist = NULL;
@@ -1309,7 +1311,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
/* gather list of objects or single object */
if (part->ren_as == PART_DRAW_GR) {
if (update) {
if (flag & DUPLILIST_DO_UPDATE) {
group_handle_recalc_and_update(scene, par, part->dup_group);
}
@@ -1452,9 +1454,9 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
else
copy_m4_m4(mat, tmat);
dob = new_dupli_object(lb, go->ob, mat, par->lay, counter, index, OB_DUPLIPARTS, animated);
dob = new_dupli_object(lb, go->ob, mat, par->lay, counter, index, OB_DUPLIPARTS, (flag & DUPLILIST_ANIMATED));
copy_m4_m4(dob->omat, obcopylist[b].obmat);
if (G.is_rendering)
if (flag & DUPLILIST_FOR_RENDER)
psys_get_dupli_texture(psys, part, sim.psmd, pa, cpa, dob->uv, dob->orco);
}
}
@@ -1512,9 +1514,9 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
if (part->draw & PART_DRAW_GLOBAL_OB)
add_v3_v3v3(mat[3], mat[3], vec);
dob = new_dupli_object(lb, ob, mat, ob->lay, counter, index, GS(id->name) == ID_GR ? OB_DUPLIGROUP : OB_DUPLIPARTS, animated);
dob = new_dupli_object(lb, ob, mat, ob->lay, counter, index, GS(id->name) == ID_GR ? OB_DUPLIGROUP : OB_DUPLIPARTS, (flag & DUPLILIST_ANIMATED));
copy_m4_m4(dob->omat, oldobmat);
if (G.is_rendering)
if (flag & DUPLILIST_FOR_RENDER)
psys_get_dupli_texture(psys, part, sim.psmd, pa, cpa, dob->uv, dob->orco);
}
@@ -1566,7 +1568,7 @@ static Object *find_family_object(Object **obar, char *family, char ch)
}
static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int par_index, int level, short animated)
static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int par_index, int level, short flag)
{
Object *ob, *obar[256] = {NULL};
Curve *cu;
@@ -1605,7 +1607,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int par_inde
copy_m4_m4(obmat, par->obmat);
copy_v3_v3(obmat[3], vec);
new_dupli_object(lb, ob, obmat, par->lay, a, par_index, OB_DUPLIVERTS, animated);
new_dupli_object(lb, ob, obmat, par->lay, a, par_index, OB_DUPLIVERTS, flag);
}
}
@@ -1615,7 +1617,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int par_inde
/* ------------- */
static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBase *duplilist, float par_space_mat[][4], int par_index,
int level, short animated, short update)
int level, short flag)
{
if ((ob->transflag & OB_DUPLI) == 0)
return;
@@ -1635,31 +1637,31 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBas
if (ob->transflag & OB_DUPLIPARTS) {
ParticleSystem *psys = ob->particlesystem.first;
for (; psys; psys = psys->next)
new_particle_duplilist(duplilist, id, scene, ob, par_space_mat, par_index, psys, level + 1, animated, update);
new_particle_duplilist(duplilist, id, scene, ob, par_space_mat, par_index, psys, level + 1, flag);
}
else if (ob->transflag & OB_DUPLIVERTS) {
if (ob->type == OB_MESH) {
vertex_duplilist(duplilist, id, scene, ob, par_space_mat, par_index, level + 1, animated, update);
vertex_duplilist(duplilist, id, scene, ob, par_space_mat, par_index, level + 1, flag);
}
else if (ob->type == OB_FONT) {
if (GS(id->name) == ID_SCE) { /* TODO - support dupligroups */
font_duplilist(duplilist, scene, ob, par_index, level + 1, animated);
font_duplilist(duplilist, scene, ob, par_index, level + 1, flag);
}
}
}
else if (ob->transflag & OB_DUPLIFACES) {
if (ob->type == OB_MESH)
face_duplilist(duplilist, id, scene, ob, par_space_mat, par_index, level + 1, animated, update);
face_duplilist(duplilist, id, scene, ob, par_space_mat, par_index, level + 1, flag);
}
else if (ob->transflag & OB_DUPLIFRAMES) {
if (GS(id->name) == ID_SCE) { /* TODO - support dupligroups */
frames_duplilist(duplilist, scene, ob, par_index, level + 1, animated);
frames_duplilist(duplilist, scene, ob, par_index, level + 1, flag);
}
}
else if (ob->transflag & OB_DUPLIGROUP) {
DupliObject *dob;
group_duplilist(duplilist, scene, ob, par_index, level + 1, animated, update); /* now recursive */
group_duplilist(duplilist, scene, ob, par_index, level + 1, flag); /* now recursive */
if (level == 0) {
for (dob = duplilist->first; dob; dob = dob->next)
@@ -1671,19 +1673,24 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBas
/* Returns a list of DupliObject
* note; group dupli's already set transform matrix. see note in group_duplilist() */
ListBase *object_duplilist_ex(Scene *sce, Object *ob, int update)
ListBase *object_duplilist_ex(Scene *sce, Object *ob, int update, int for_render)
{
ListBase *duplilist = MEM_mallocN(sizeof(ListBase), "duplilist");
int flag = 0;
if(update) flag |= DUPLILIST_DO_UPDATE;
if(for_render) flag |= DUPLILIST_FOR_RENDER;
duplilist->first = duplilist->last = NULL;
object_duplilist_recursive((ID *)sce, sce, ob, duplilist, NULL, 0, 0, 0, update);
object_duplilist_recursive((ID *)sce, sce, ob, duplilist, NULL, 0, 0, flag);
return duplilist;
}
/* note: previously updating was always done, this is why it defaults to be on
* but there are likely places it can be called without updating */
ListBase *object_duplilist(Scene *sce, Object *ob)
ListBase *object_duplilist(Scene *sce, Object *ob, int for_render)
{
return object_duplilist_ex(sce, ob, TRUE);
return object_duplilist_ex(sce, ob, TRUE, for_render);
}

View File

@@ -1999,7 +1999,7 @@ void CustomData_interp(const CustomData *source, CustomData *dest,
}
/* 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) {

View File

@@ -163,7 +163,7 @@ bGPDframe *gpencil_frame_addnew(bGPDlayer *gpl, int cframe)
}
/* add a new gp-layer and make it the active layer */
bGPDlayer *gpencil_layer_addnew(bGPdata *gpd)
bGPDlayer *gpencil_layer_addnew(bGPdata *gpd, const char *name, int setactive)
{
bGPDlayer *gpl;
@@ -182,10 +182,11 @@ bGPDlayer *gpencil_layer_addnew(bGPdata *gpd)
gpl->thickness = 3;
/* auto-name */
strcpy(gpl->info, "GP_Layer");
strcpy(gpl->info, name);
BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info), sizeof(gpl->info));
/* make this one the active one */
if (setactive)
gpencil_layer_setactive(gpd, gpl);
/* return layer */
@@ -509,10 +510,8 @@ void gpencil_layer_setactive(bGPdata *gpd, bGPDlayer *active)
}
/* delete the active gp-layer */
void gpencil_layer_delactive(bGPdata *gpd)
void gpencil_layer_delete(bGPdata *gpd, bGPDlayer *gpl)
{
bGPDlayer *gpl = gpencil_layer_getactive(gpd);
/* error checking */
if (ELEM(NULL, gpd, gpl))
return;

View File

@@ -2563,7 +2563,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_
*lock_r = re;
}
/* this gives active layer, composite or seqence result */
/* this gives active layer, composite or sequence result */
rect = (unsigned int *)rres.rect32;
rectf = rres.rectf;
rectz = rres.rectz;

View File

@@ -1757,13 +1757,13 @@ void do_versions_ipos_to_animato(Main *main)
{
/* If we have any empty action actuators, assume they were
converted IPO Actuators using the object IPO */
* converted IPO Actuators using the object IPO */
bActuator *act;
bActionActuator *aa;
for (act = ob->actuators.first; act; act = act->next) {
/* Any actuators set to ACT_IPO at this point are actually Action Actuators that
need this converted IPO to finish converting the actuator. */
* need this converted IPO to finish converting the actuator. */
if (act->type == ACT_IPO) {
aa = (bActionActuator *)act->data;
aa->act = ob->adt->action;

View File

@@ -916,19 +916,6 @@ void BKE_mask_free_nolib(Mask *mask)
BKE_mask_layer_free_list(&mask->masklayers);
}
static void ntree_unlink_mask_cb(void *calldata, struct ID *UNUSED(owner_id), struct bNodeTree *ntree)
{
ID *id = (ID *)calldata;
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
if (node->id == id) {
node->id = NULL;
}
}
}
void BKE_mask_free(Main *bmain, Mask *mask)
{
bScreen *scr;
@@ -975,21 +962,11 @@ void BKE_mask_free(Main *bmain, Mask *mask)
}
SEQ_END
}
if (scene->nodetree) {
bNode *node;
for (node = scene->nodetree->nodes.first; node; node = node->next) {
if (node->id == &mask->id) {
node->id = NULL;
}
}
}
}
{
bNodeTreeType *treetype = ntreeGetType(NTREE_COMPOSIT);
treetype->foreach_nodetree(bmain, (void *)mask, &ntree_unlink_mask_cb);
treetype->foreach_nodetree(bmain, (void *)mask, &BKE_node_tree_unlink_id_cb);
}
/* free mask data */
@@ -1548,7 +1525,7 @@ void BKE_mask_parent_init(MaskParent *parent)
}
/* *** own animation/shapekey implimentation ***
/* *** own animation/shapekey implementation ***
* BKE_mask_layer_shape_XXX */
int BKE_mask_layer_shape_totvert(MaskLayer *masklay)

View File

@@ -2388,7 +2388,7 @@ int BKE_mball_center_bounds(MetaBall *mb, float r_cent[3])
return 0;
}
void BKE_mball_translate(MetaBall *mb, float offset[3])
void BKE_mball_translate(MetaBall *mb, const float offset[3])
{
MetaElem *ml;
@@ -2396,3 +2396,32 @@ void BKE_mball_translate(MetaBall *mb, float offset[3])
add_v3_v3(&ml->x, offset);
}
}
/* *** select funcs *** */
void BKE_mball_select_all(struct MetaBall *mb)
{
MetaElem *ml;
for (ml = mb->editelems->first; ml; ml = ml->next) {
ml->flag |= SELECT;
}
}
void BKE_mball_deselect_all(MetaBall *mb)
{
MetaElem *ml;
for (ml = mb->editelems->first; ml; ml = ml->next) {
ml->flag &= ~SELECT;
}
}
void BKE_mball_select_swap(struct MetaBall *mb)
{
MetaElem *ml;
for (ml = mb->editelems->first; ml; ml = ml->next) {
ml->flag ^= SELECT;
}
}

View File

@@ -2043,7 +2043,7 @@ static void bm_corners_to_loops_ex(ID *id, CustomData *fdata, CustomData *ldata,
int side, corners;
if (CustomData_external_test(fdata, CD_MDISPS)) {
if (id) {
if (id && fdata->external) {
CustomData_external_add(ldata, id, CD_MDISPS,
totloop, fdata->external->filename);
}

View File

@@ -49,7 +49,7 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
MLoop *mloop, *ml;
BMVert *v, **vtable, **verts = NULL;
BMEdge *e, **etable, **edges = NULL;
float has_face_normals;
float (*face_normals)[3];
BMFace *f;
BMIter liter;
BLI_array_declare(verts);
@@ -72,8 +72,8 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
BM_data_layer_add(bm, &bm->edata, CD_BWEIGHT);
BM_data_layer_add(bm, &bm->vdata, CD_BWEIGHT);
vtable = MEM_callocN(sizeof(void **) * totvert, "vert table in BMDM_Copy");
etable = MEM_callocN(sizeof(void **) * totedge, "edge table in BMDM_Copy");
vtable = MEM_callocN(sizeof(void **) * totvert, __func__);
etable = MEM_callocN(sizeof(void **) * totedge, __func__);
/*do verts*/
mv = mvert = dm->dupVertArray(dm);
@@ -110,7 +110,7 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
/*do faces*/
mp = dm->getPolyArray(dm);
mloop = dm->getLoopArray(dm);
has_face_normals = CustomData_has_layer(&dm->polyData, CD_NORMAL);
face_normals = CustomData_get_layer(&dm->polyData, CD_NORMAL); /* can be NULL */
for (i = 0; i < dm->numPolyData; i++, mp++) {
BMLoop *l;
@@ -129,8 +129,9 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
f = BM_face_create_ngon(bm, verts[0], verts[1], edges, mp->totloop, FALSE);
if (!f)
if (UNLIKELY(f == NULL)) {
continue;
}
f->head.hflag = BM_face_flag_from_mflag(mp->flag);
f->mat_nr = mp->mat_nr;
@@ -143,11 +144,11 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
CustomData_to_bmesh_block(&dm->polyData, &bm->pdata, i, &f->head.data);
if (has_face_normals) {
float *fno;
fno = CustomData_bmesh_get(&bm->pdata, &f->head.data, CD_NORMAL);
copy_v3_v3(f->no, fno);
if (face_normals) {
copy_v3_v3(f->no, face_normals[i]);
}
else {
BM_face_normal_update(f);
}
}

View File

@@ -52,6 +52,7 @@
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_movieclip_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_view3d_types.h"
@@ -71,6 +72,7 @@
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_movieclip.h"
#include "BKE_node.h"
#include "BKE_image.h" /* openanim */
#include "BKE_tracking.h"
@@ -624,24 +626,22 @@ static ImBuf *get_undistorted_ibuf(MovieClip *clip, struct MovieDistortion *dist
return undistibuf;
}
static int need_undistortion_postprocess(MovieClipUser *user, int flag)
static int need_undistortion_postprocess(MovieClipUser *user)
{
int result = 0;
/* only full undistorted render can be used as on-fly undistorting image */
if (flag & MCLIP_USE_PROXY) {
result |= (user->render_size == MCLIP_PROXY_RENDER_SIZE_FULL) &&
(user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT) != 0;
}
return result;
}
static int need_postprocessed_frame(MovieClipUser *user, int flag, int postprocess_flag)
static int need_postprocessed_frame(MovieClipUser *user, int postprocess_flag)
{
int result = postprocess_flag;
result |= need_undistortion_postprocess(user, flag);
result |= need_undistortion_postprocess(user);
return result;
}
@@ -688,7 +688,7 @@ static ImBuf *get_postprocessed_cached_frame(MovieClip *clip, MovieClipUser *use
if (cache->postprocessed.flag != postprocess_flag)
return NULL;
if (need_undistortion_postprocess(user, flag)) {
if (need_undistortion_postprocess(user)) {
if (!check_undistortion_cache_flags(clip))
return NULL;
}
@@ -719,7 +719,7 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u
cache->postprocessed.render_flag = 0;
}
if (need_undistortion_postprocess(user, flag)) {
if (need_undistortion_postprocess(user)) {
copy_v2_v2(cache->postprocessed.principal, camera->principal);
copy_v3_v3(&cache->postprocessed.k1, &camera->k1);
cache->postprocessed.undistortion_used = TRUE;
@@ -763,7 +763,7 @@ static ImBuf *movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *u
BLI_lock_thread(LOCK_MOVIECLIP);
/* try to obtain cached postprocessed frame first */
if (need_postprocessed_frame(user, flag, postprocess_flag)) {
if (need_postprocessed_frame(user, postprocess_flag)) {
ibuf = get_postprocessed_cached_frame(clip, user, flag, postprocess_flag);
if (!ibuf)
@@ -1326,6 +1326,11 @@ void BKE_movieclip_unlink(Main *bmain, MovieClip *clip)
}
}
{
bNodeTreeType *treetype = ntreeGetType(NTREE_COMPOSIT);
treetype->foreach_nodetree(bmain, (void *)clip, &BKE_node_tree_unlink_id_cb);
}
clip->id.us = 0;
}

View File

@@ -666,10 +666,12 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl)
mdisp->totdisp = totdisp;
mdisp->level = lvl;
if (gpm) {
multires_grid_paint_mask_downsample(&gpm[g], lvl);
}
}
}
}
else {
multires_customdata_delete(me);
}
@@ -893,15 +895,16 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl
CCGKey highGridKey, lowGridKey;
CCGSubSurf *ss;
int i, numGrids, highGridSize;
int has_mask = CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK);
/* create subsurf DM from original mesh at high level */
cddm = CDDM_from_mesh(me, NULL);
DM_set_only_copy(cddm, CD_MASK_BAREMESH);
highdm = subsurf_dm_create_local(ob, cddm, totlvl, simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, TRUE);
highdm = subsurf_dm_create_local(ob, cddm, totlvl, simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask);
ss = ((CCGDerivedMesh *)highdm)->ss;
/* create multires DM from original mesh at low level */
lowdm = multires_dm_create_local(ob, cddm, lvl, lvl, simple, TRUE);
lowdm = multires_dm_create_local(ob, cddm, lvl, lvl, simple, has_mask);
cddm->release(cddm);
/* copy subsurf grids and replace them with low displaced grids */
@@ -1164,17 +1167,18 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm)
CCGKey highGridKey, lowGridKey;
CCGSubSurf *ss;
int i, j, numGrids, highGridSize, lowGridSize;
int has_mask = CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK);
/* create subsurf DM from original mesh at high level */
if (ob->derivedDeform) cddm = CDDM_copy(ob->derivedDeform);
else cddm = CDDM_from_mesh(me, NULL);
DM_set_only_copy(cddm, CD_MASK_BAREMESH);
highdm = subsurf_dm_create_local(ob, cddm, totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, TRUE);
highdm = subsurf_dm_create_local(ob, cddm, totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask);
ss = ((CCGDerivedMesh *)highdm)->ss;
/* create multires DM from original mesh and displacements */
lowdm = multires_dm_create_local(ob, cddm, lvl, totlvl, mmd->simple, TRUE);
lowdm = multires_dm_create_local(ob, cddm, lvl, totlvl, mmd->simple, has_mask);
cddm->release(cddm);
/* gather grid data */
@@ -1226,12 +1230,13 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm)
}
else {
DerivedMesh *cddm, *subdm;
int has_mask = CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK);
if (ob->derivedDeform) cddm = CDDM_copy(ob->derivedDeform);
else cddm = CDDM_from_mesh(me, NULL);
DM_set_only_copy(cddm, CD_MASK_BAREMESH);
subdm = subsurf_dm_create_local(ob, cddm, mmd->totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, TRUE);
subdm = subsurf_dm_create_local(ob, cddm, mmd->totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask);
cddm->release(cddm);
multiresModifier_disp_run(dm, me, NULL, CALC_DISPLACEMENTS, subdm->getGridData(subdm), mmd->totlvl);
@@ -2107,7 +2112,7 @@ void multires_load_old(Object *ob, Mesh *me)
* reference subsurfed dm with this option, before calling multiresModifier_disp_run(),
* which implicitly expects both subsurfs from its first dm and oldGridData parameters to
* be of the same "format"! */
dm = multires_make_derived_from_derived(orig, mmd, ob, MULTIRES_ALLOC_PAINT_MASK);
dm = multires_make_derived_from_derived(orig, mmd, ob, 0);
multires_load_old_dm(dm, me, mmd->totlvl + 1);

View File

@@ -1030,9 +1030,18 @@ void ntreeFreeTree_ex(bNodeTree *ntree, const short do_id_user)
next = node->next;
/* ntreeUserIncrefID inline */
/* XXX, this is correct, however when freeing the entire database
* this ends up accessing freed data which isn't properly unlinking
* its self from scene nodes, SO - for now prefer invalid usercounts
* on free rather then bad memory access - Campbell */
#if 0
if (do_id_user) {
id_us_min(node->id);
}
#else
(void)do_id_user;
#endif
nodeFreeNode(ntree, node);
}

View File

@@ -2271,7 +2271,7 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const short u
Curve *cu = ob->data;
/* Use the object bounding box so that modifier output
gets taken into account */
* gets taken into account */
if (ob->bb)
bb = *(ob->bb);
else {
@@ -2372,7 +2372,7 @@ int BKE_object_minmax_dupli(Scene *scene, Object *ob, float r_min[3], float r_ma
ListBase *lb;
DupliObject *dob;
lb = object_duplilist(scene, ob);
lb = object_duplilist(scene, ob, FALSE);
for (dob = lb->first; dob; dob = dob->next) {
if ((use_hidden == FALSE) && (dob->no_draw != 0)) {
/* pass */
@@ -2449,7 +2449,7 @@ void BKE_scene_foreach_display_point(
ListBase *lb;
DupliObject *dob;
lb = object_duplilist(scene, ob);
lb = object_duplilist(scene, ob, FALSE);
for (dob = lb->first; dob; dob = dob->next) {
if (dob->no_draw == 0) {
BKE_object_foreach_display_point(dob->ob, dob->mat, func_cb, user_data);

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